fuma-content 1.0.1 → 1.0.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/async-cache-BM9Yf4Nw.js +29 -0
- package/dist/async-cache-BM9Yf4Nw.js.map +1 -0
- package/dist/bin.d.ts +1 -1
- package/dist/bin.js +21 -14
- package/dist/bin.js.map +1 -0
- package/dist/build-D8A5ByFk.js +42 -0
- package/dist/build-D8A5ByFk.js.map +1 -0
- package/dist/build-mdx-C1PZsGp2.js +395 -0
- package/dist/build-mdx-C1PZsGp2.js.map +1 -0
- package/dist/build-mdx-DFndaVbS.js +4 -0
- package/dist/bun/index.d.ts +6 -13
- package/dist/bun/index.d.ts.map +1 -0
- package/dist/bun/index.js +23 -34
- package/dist/bun/index.js.map +1 -0
- package/dist/bun-QKQnqgIi.js +35 -0
- package/dist/bun-QKQnqgIi.js.map +1 -0
- package/dist/code-generator-gPtrfZ6Q.js +133 -0
- package/dist/code-generator-gPtrfZ6Q.js.map +1 -0
- package/dist/collections/handlers/fs.d.ts +2 -10
- package/dist/collections/handlers/fs.js +28 -6
- package/dist/collections/handlers/fs.js.map +1 -0
- package/dist/collections/index.d.ts +2 -10
- package/dist/collections/index.js +16 -6
- package/dist/collections/index.js.map +1 -0
- package/dist/collections/mdx/loader-webpack.d.ts +6 -14
- package/dist/collections/mdx/loader-webpack.d.ts.map +1 -0
- package/dist/collections/mdx/loader-webpack.js +23 -36
- package/dist/collections/mdx/loader-webpack.js.map +1 -0
- package/dist/collections/mdx/runtime-browser.d.ts +27 -37
- package/dist/collections/mdx/runtime-browser.d.ts.map +1 -0
- package/dist/collections/mdx/runtime-browser.js +57 -70
- package/dist/collections/mdx/runtime-browser.js.map +1 -0
- package/dist/collections/mdx/runtime-dynamic.d.ts +22 -30
- package/dist/collections/mdx/runtime-dynamic.d.ts.map +1 -0
- package/dist/collections/mdx/runtime-dynamic.js +63 -85
- package/dist/collections/mdx/runtime-dynamic.js.map +1 -0
- package/dist/collections/mdx/runtime.d.ts +31 -52
- package/dist/collections/mdx/runtime.d.ts.map +1 -0
- package/dist/collections/mdx/runtime.js +24 -34
- package/dist/collections/mdx/runtime.js.map +1 -0
- package/dist/collections/mdx.d.ts +2 -10
- package/dist/collections/mdx.js +240 -284
- package/dist/collections/mdx.js.map +1 -0
- package/dist/collections/meta/loader-webpack.d.ts +6 -14
- package/dist/collections/meta/loader-webpack.d.ts.map +1 -0
- package/dist/collections/meta/loader-webpack.js +25 -39
- package/dist/collections/meta/loader-webpack.js.map +1 -0
- package/dist/collections/meta/runtime.d.ts +7 -15
- package/dist/collections/meta/runtime.d.ts.map +1 -0
- package/dist/collections/meta/runtime.js +9 -15
- package/dist/collections/meta/runtime.js.map +1 -0
- package/dist/collections/meta.d.ts +2 -10
- package/dist/collections/meta.js +128 -164
- package/dist/collections/meta.js.map +1 -0
- package/dist/collections/runtime/file-store.d.ts +17 -14
- package/dist/collections/runtime/file-store.d.ts.map +1 -0
- package/dist/collections/runtime/file-store.js +30 -6
- package/dist/collections/runtime/file-store.js.map +1 -0
- package/dist/collections/runtime/store.d.ts +3 -28
- package/dist/collections/runtime/store.js +3 -6
- package/dist/config/index.d.ts +2 -10
- package/dist/config/index.js +6 -5
- package/dist/config/index.js.map +1 -0
- package/dist/core-Bkh-SI_3.d.ts +561 -0
- package/dist/core-Bkh-SI_3.d.ts.map +1 -0
- package/dist/core-ZuoVBkeg.js +170 -0
- package/dist/core-ZuoVBkeg.js.map +1 -0
- package/dist/dynamic-B40uAtdo.js +28 -0
- package/dist/dynamic-B40uAtdo.js.map +1 -0
- package/dist/fuma-matter-O4fA6nSx.js +27 -0
- package/dist/fuma-matter-O4fA6nSx.js.map +1 -0
- package/dist/index.d.ts +13 -16
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -8
- package/dist/load-from-file-1f4WaHsf.js +38 -0
- package/dist/load-from-file-1f4WaHsf.js.map +1 -0
- package/dist/load-from-file-BTNnBu6f.js +3 -0
- package/dist/loader-80abXEHx.js +4 -0
- package/dist/loader-BFhPyg3z.js +4 -0
- package/dist/loader-CXnMFuyE.js +80 -0
- package/dist/loader-CXnMFuyE.js.map +1 -0
- package/dist/loader-gk94iHf5.js +66 -0
- package/dist/loader-gk94iHf5.js.map +1 -0
- package/dist/next/index.cjs +459 -551
- package/dist/next/index.d.ts +16 -22
- package/dist/next/index.d.ts.map +1 -0
- package/dist/next/index.js +71 -89
- package/dist/next/index.js.map +1 -0
- package/dist/node/loader.d.ts +4 -2
- package/dist/node/loader.d.ts.map +1 -0
- package/dist/node/loader.js +32 -44
- package/dist/node/loader.js.map +1 -0
- package/dist/node-CGIIJIcs.js +31 -0
- package/dist/node-CGIIJIcs.js.map +1 -0
- package/dist/pipe-5cnvE6KY.js +31 -0
- package/dist/pipe-5cnvE6KY.js.map +1 -0
- package/dist/plugins/git.d.ts +2 -10
- package/dist/plugins/git.js +57 -65
- package/dist/plugins/git.js.map +1 -0
- package/dist/plugins/json-schema.d.ts +2 -10
- package/dist/plugins/json-schema.js +60 -58
- package/dist/plugins/json-schema.js.map +1 -0
- package/dist/plugins/with-loader/index.d.ts +2 -61
- package/dist/plugins/with-loader/index.js +28 -6
- package/dist/plugins/with-loader/index.js.map +1 -0
- package/dist/plugins/with-loader/webpack.d.ts +10 -18
- package/dist/plugins/with-loader/webpack.d.ts.map +1 -0
- package/dist/plugins/with-loader/webpack.js +43 -12
- package/dist/plugins/with-loader/webpack.js.map +1 -0
- package/dist/store-0LQ2PlH6.js +37 -0
- package/dist/store-0LQ2PlH6.js.map +1 -0
- package/dist/store-DEjYYF6a.d.ts +31 -0
- package/dist/store-DEjYYF6a.d.ts.map +1 -0
- package/dist/validation-BOJKRAp5.js +28 -0
- package/dist/validation-BOJKRAp5.js.map +1 -0
- package/dist/vite/index.d.ts +22 -28
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +37 -52
- package/dist/vite/index.js.map +1 -0
- package/dist/vite-X-2Al8fq.js +32 -0
- package/dist/vite-X-2Al8fq.js.map +1 -0
- package/package.json +7 -6
- package/dist/build-mdx-I4NROXCF.js +0 -8
- package/dist/bun-DMNX4PBC.js +0 -40
- package/dist/chunk-3VQS3KSP.js +0 -39
- package/dist/chunk-BTRE6MOX.js +0 -16
- package/dist/chunk-E4HRKSP4.js +0 -24
- package/dist/chunk-ERBMAQYP.js +0 -33
- package/dist/chunk-GGL4EF6H.js +0 -38
- package/dist/chunk-JBZTQ55D.js +0 -30
- package/dist/chunk-KH5GT2Y5.js +0 -104
- package/dist/chunk-LUM7SIZN.js +0 -40
- package/dist/chunk-MT7RY65Y.js +0 -167
- package/dist/chunk-NRZ4GE5O.js +0 -207
- package/dist/chunk-OQQNA7L7.js +0 -412
- package/dist/chunk-OUJENWQ4.js +0 -45
- package/dist/chunk-RMSV4HP6.js +0 -85
- package/dist/chunk-RXR7OL76.js +0 -37
- package/dist/chunk-VWJKRQZR.js +0 -19
- package/dist/chunk-W6HENTK7.js +0 -44
- package/dist/chunk-XR5N6ZXJ.js +0 -50
- package/dist/core-Bo8KaWQz.d.ts +0 -411
- package/dist/load-from-file-HL2VEY3M.js +0 -7
- package/dist/loader-NFSL6P5I.js +0 -7
- package/dist/loader-T756NSCS.js +0 -7
- package/dist/node-DCMYL4DL.js +0 -34
- package/dist/vite-QCUPZHHB.js +0 -32
|
@@ -1,59 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
import fs from "fs/promises";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/json-schema.ts
|
|
5
|
+
/**
|
|
6
|
+
* Generate JSON schemas locally for collection schemas
|
|
7
|
+
*
|
|
8
|
+
* note: **it only works with Zod**
|
|
9
|
+
*/
|
|
10
|
+
function jsonSchema({ insert = false } = {}) {
|
|
11
|
+
function getSchemaPath(name) {
|
|
12
|
+
return `json-schema/${name}.json`;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
name: "json-schema",
|
|
16
|
+
configureServer(server) {
|
|
17
|
+
const { outDir } = this.core.getOptions();
|
|
18
|
+
if (!server.watcher || !insert) return;
|
|
19
|
+
server.watcher.on("add", async (file) => {
|
|
20
|
+
const match = this.core.getCollections().find((collection) => {
|
|
21
|
+
const handler = collection.handlers.fs;
|
|
22
|
+
if (!handler) return false;
|
|
23
|
+
return handler.hasFile(file);
|
|
24
|
+
});
|
|
25
|
+
if (!match) return;
|
|
26
|
+
let obj;
|
|
27
|
+
try {
|
|
28
|
+
const content = (await fs.readFile(file)).toString();
|
|
29
|
+
obj = content.length > 0 ? JSON.parse(content) : {};
|
|
30
|
+
} catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if ("$schema" in obj) return;
|
|
34
|
+
const schemaPath = path.join(outDir, getSchemaPath(parent ? `${parent.name}.meta` : match.name));
|
|
35
|
+
const updated = {
|
|
36
|
+
$schema: path.relative(path.dirname(file), schemaPath),
|
|
37
|
+
...obj
|
|
38
|
+
};
|
|
39
|
+
await fs.writeFile(file, JSON.stringify(updated, null, 2));
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
async emit() {
|
|
43
|
+
const files = [];
|
|
44
|
+
for (const collection of this.core.getCollections()) {
|
|
45
|
+
const handler = collection.handlers["json-schema"];
|
|
46
|
+
if (!handler) continue;
|
|
47
|
+
const jsonSchema$1 = await handler.create();
|
|
48
|
+
if (!jsonSchema$1) continue;
|
|
49
|
+
files.push({
|
|
50
|
+
path: getSchemaPath(collection.name),
|
|
51
|
+
content: JSON.stringify(jsonSchema$1, null, 2)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return files;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { jsonSchema as default };
|
|
61
|
+
//# sourceMappingURL=json-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.js","names":["obj: object","files: EmitEntry[]","jsonSchema"],"sources":["../../src/plugins/json-schema.ts"],"sourcesContent":["import type { EmitEntry, Plugin } from \"@/core\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport interface JSONSchemaOptions {\n /**\n * insert `$schema` field to JSON files on creation.\n *\n * @defaultValue false\n */\n insert?: boolean;\n}\n\nexport interface JSONSchemaHandler {\n create: () => object | undefined | Promise<object | undefined>;\n}\n\n/**\n * Generate JSON schemas locally for collection schemas\n *\n * note: **it only works with Zod**\n */\nexport default function jsonSchema({\n insert = false,\n}: JSONSchemaOptions = {}): Plugin {\n function getSchemaPath(name: string) {\n return `json-schema/${name}.json`;\n }\n\n return {\n name: \"json-schema\",\n configureServer(server) {\n const { outDir } = this.core.getOptions();\n if (!server.watcher || !insert) return;\n\n server.watcher.on(\"add\", async (file) => {\n const match = this.core.getCollections().find((collection) => {\n const handler = collection.handlers.fs;\n if (!handler) return false;\n return handler.hasFile(file);\n });\n\n if (!match) return;\n let obj: object;\n try {\n const content = (await fs.readFile(file)).toString();\n obj = content.length > 0 ? JSON.parse(content) : {};\n } catch {\n return;\n }\n\n if (\"$schema\" in obj) return;\n const schemaPath = path.join(\n outDir,\n getSchemaPath(parent ? `${parent.name}.meta` : match.name),\n );\n const updated = {\n $schema: path.relative(path.dirname(file), schemaPath),\n ...obj,\n };\n\n await fs.writeFile(file, JSON.stringify(updated, null, 2));\n });\n },\n async emit() {\n const files: EmitEntry[] = [];\n\n for (const collection of this.core.getCollections()) {\n const handler = collection.handlers[\"json-schema\"];\n if (!handler) continue;\n\n const jsonSchema = await handler.create();\n if (!jsonSchema) continue;\n files.push({\n path: getSchemaPath(collection.name),\n content: JSON.stringify(jsonSchema, null, 2),\n });\n }\n\n return files;\n },\n };\n}\n"],"mappings":";;;;;;;;;AAsBA,SAAwB,WAAW,EACjC,SAAS,UACY,EAAE,EAAU;CACjC,SAAS,cAAc,MAAc;AACnC,SAAO,eAAe,KAAK;;AAG7B,QAAO;EACL,MAAM;EACN,gBAAgB,QAAQ;GACtB,MAAM,EAAE,WAAW,KAAK,KAAK,YAAY;AACzC,OAAI,CAAC,OAAO,WAAW,CAAC,OAAQ;AAEhC,UAAO,QAAQ,GAAG,OAAO,OAAO,SAAS;IACvC,MAAM,QAAQ,KAAK,KAAK,gBAAgB,CAAC,MAAM,eAAe;KAC5D,MAAM,UAAU,WAAW,SAAS;AACpC,SAAI,CAAC,QAAS,QAAO;AACrB,YAAO,QAAQ,QAAQ,KAAK;MAC5B;AAEF,QAAI,CAAC,MAAO;IACZ,IAAIA;AACJ,QAAI;KACF,MAAM,WAAW,MAAM,GAAG,SAAS,KAAK,EAAE,UAAU;AACpD,WAAM,QAAQ,SAAS,IAAI,KAAK,MAAM,QAAQ,GAAG,EAAE;YAC7C;AACN;;AAGF,QAAI,aAAa,IAAK;IACtB,MAAM,aAAa,KAAK,KACtB,QACA,cAAc,SAAS,GAAG,OAAO,KAAK,SAAS,MAAM,KAAK,CAC3D;IACD,MAAM,UAAU;KACd,SAAS,KAAK,SAAS,KAAK,QAAQ,KAAK,EAAE,WAAW;KACtD,GAAG;KACJ;AAED,UAAM,GAAG,UAAU,MAAM,KAAK,UAAU,SAAS,MAAM,EAAE,CAAC;KAC1D;;EAEJ,MAAM,OAAO;GACX,MAAMC,QAAqB,EAAE;AAE7B,QAAK,MAAM,cAAc,KAAK,KAAK,gBAAgB,EAAE;IACnD,MAAM,UAAU,WAAW,SAAS;AACpC,QAAI,CAAC,QAAS;IAEd,MAAMC,eAAa,MAAM,QAAQ,QAAQ;AACzC,QAAI,CAACA,aAAY;AACjB,UAAM,KAAK;KACT,MAAM,cAAc,WAAW,KAAK;KACpC,SAAS,KAAK,UAAUA,cAAY,MAAM,EAAE;KAC7C,CAAC;;AAGJ,UAAO;;EAEV"}
|
|
@@ -1,61 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import '@mdx-js/mdx';
|
|
4
|
-
import 'vfile';
|
|
5
|
-
import '@standard-schema/spec';
|
|
6
|
-
import 'unified';
|
|
7
|
-
import 'mdast';
|
|
8
|
-
import 'vite';
|
|
9
|
-
import 'next';
|
|
10
|
-
import 'node:module';
|
|
11
|
-
|
|
12
|
-
type Awaitable<T> = T | Promise<T>;
|
|
13
|
-
interface CompilerOptions {
|
|
14
|
-
addDependency: (file: string) => void;
|
|
15
|
-
}
|
|
16
|
-
type LoaderEnvironment = "vite" | "bun" | "node";
|
|
17
|
-
interface Loader {
|
|
18
|
-
/**
|
|
19
|
-
* Transform input into JavaScript.
|
|
20
|
-
*
|
|
21
|
-
* Returns:
|
|
22
|
-
* - `LoaderOutput`: JavaScript code & source map.
|
|
23
|
-
* - `null`: skip the loader. Fallback to default behaviour if possible, otherwise the adapter will try workarounds.
|
|
24
|
-
*/
|
|
25
|
-
load: (input: LoaderInput) => Awaitable<LoaderOutput | null>;
|
|
26
|
-
bun?: {
|
|
27
|
-
/**
|
|
28
|
-
* 1. Bun doesn't allow `null` in loaders.
|
|
29
|
-
* 2. Bun requires sync result to support dynamic require().
|
|
30
|
-
*/
|
|
31
|
-
load?: (source: string, input: LoaderInput) => Awaitable<Bun.OnLoadResult>;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
interface LoaderInput {
|
|
35
|
-
development: boolean;
|
|
36
|
-
compiler: CompilerOptions;
|
|
37
|
-
filePath: string;
|
|
38
|
-
query: Record<string, string | string[] | undefined>;
|
|
39
|
-
getSource: () => string | Promise<string>;
|
|
40
|
-
}
|
|
41
|
-
interface LoaderOutput {
|
|
42
|
-
code: string;
|
|
43
|
-
map?: unknown;
|
|
44
|
-
}
|
|
45
|
-
interface WithLoaderConfig {
|
|
46
|
-
/**
|
|
47
|
-
* Filter file paths, the input can be either a file URL or file path.
|
|
48
|
-
*
|
|
49
|
-
* Must take resource query into consideration.
|
|
50
|
-
*/
|
|
51
|
-
test?: RegExp;
|
|
52
|
-
createLoader: (this: PluginContext, environment: LoaderEnvironment) => Promise<Loader>;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* a light layer for implementing loaders.
|
|
56
|
-
*
|
|
57
|
-
* @remarks it doesn't include Next.js, you have to define the webpack/turbopack config, and export the loaders on your own.
|
|
58
|
-
*/
|
|
59
|
-
declare function withLoader(plugin: Plugin, { test, createLoader }: WithLoaderConfig): Plugin;
|
|
60
|
-
|
|
61
|
-
export { type CompilerOptions, type Loader, type LoaderInput, type LoaderOutput, type WithLoaderConfig, withLoader };
|
|
1
|
+
import { B as WithLoaderConfig, I as CompilerOptions, L as Loader, R as LoaderInput, V as withLoader, z as LoaderOutput } from "../../core-Bkh-SI_3.js";
|
|
2
|
+
export { CompilerOptions, Loader, LoaderInput, LoaderOutput, WithLoaderConfig, withLoader };
|
|
@@ -1,6 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
//#region src/plugins/with-loader/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* a light layer for implementing loaders.
|
|
4
|
+
*
|
|
5
|
+
* @remarks it doesn't include Next.js, you have to define the webpack/turbopack config, and export the loaders on your own.
|
|
6
|
+
*/
|
|
7
|
+
function withLoader(plugin, { test, createLoader }) {
|
|
8
|
+
let loader;
|
|
9
|
+
return {
|
|
10
|
+
bun: { async build(build) {
|
|
11
|
+
const { toBun } = await import("../../bun-QKQnqgIi.js");
|
|
12
|
+
toBun(test, await (loader ??= createLoader.call(this, "bun")))(build);
|
|
13
|
+
} },
|
|
14
|
+
node: { async createLoad() {
|
|
15
|
+
const { toNode } = await import("../../node-CGIIJIcs.js");
|
|
16
|
+
return toNode(test, await (loader ??= createLoader.call(this, "node")));
|
|
17
|
+
} },
|
|
18
|
+
vite: { async createPlugin() {
|
|
19
|
+
const { toVite } = await import("../../vite-X-2Al8fq.js");
|
|
20
|
+
return toVite(plugin.name, test, await (loader ??= createLoader.call(this, "vite")));
|
|
21
|
+
} },
|
|
22
|
+
...plugin
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { withLoader };
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["loader: Promise<Loader> | undefined"],"sources":["../../../src/plugins/with-loader/index.ts"],"sourcesContent":["import type { Plugin, PluginContext } from \"@/core\";\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\nexport interface WithLoaderConfig {\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 createLoader: (\n this: PluginContext,\n environment: LoaderEnvironment,\n ) => Promise<Loader>;\n}\n\n/**\n * a light layer for implementing loaders.\n *\n * @remarks it doesn't include Next.js, you have to define the webpack/turbopack config, and export the loaders on your own.\n */\nexport function withLoader(\n plugin: Plugin,\n { test, createLoader }: WithLoaderConfig,\n): Plugin {\n let loader: Promise<Loader> | undefined;\n\n return {\n bun: {\n async build(build) {\n const { toBun } = await import(\"./bun\");\n toBun(test, await (loader ??= createLoader.call(this, \"bun\")))(build);\n },\n },\n node: {\n async createLoad() {\n const { toNode } = await import(\"./node\");\n return toNode(test, await (loader ??= createLoader.call(this, \"node\")));\n },\n },\n vite: {\n async createPlugin() {\n const { toVite } = await import(\"./vite\");\n return toVite(\n plugin.name,\n test,\n await (loader ??= createLoader.call(this, \"vite\")),\n );\n },\n },\n ...plugin,\n };\n}\n"],"mappings":";;;;;;AA8DA,SAAgB,WACd,QACA,EAAE,MAAM,gBACA;CACR,IAAIA;AAEJ,QAAO;EACL,KAAK,EACH,MAAM,MAAM,OAAO;GACjB,MAAM,EAAE,UAAU,MAAM,OAAO;AAC/B,SAAM,MAAM,OAAO,WAAW,aAAa,KAAK,MAAM,MAAM,EAAE,CAAC,MAAM;KAExE;EACD,MAAM,EACJ,MAAM,aAAa;GACjB,MAAM,EAAE,WAAW,MAAM,OAAO;AAChC,UAAO,OAAO,MAAM,OAAO,WAAW,aAAa,KAAK,MAAM,OAAO,EAAE;KAE1E;EACD,MAAM,EACJ,MAAM,eAAe;GACnB,MAAM,EAAE,WAAW,MAAM,OAAO;AAChC,UAAO,OACL,OAAO,MACP,MACA,OAAO,WAAW,aAAa,KAAK,MAAM,OAAO,EAClD;KAEJ;EACD,GAAG;EACJ"}
|
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as Core } from '../../core-Bo8KaWQz.js';
|
|
4
|
-
import 'chokidar';
|
|
5
|
-
import '@mdx-js/mdx';
|
|
6
|
-
import 'vfile';
|
|
7
|
-
import '@standard-schema/spec';
|
|
8
|
-
import 'unified';
|
|
9
|
-
import 'mdast';
|
|
10
|
-
import 'vite';
|
|
11
|
-
import 'next';
|
|
12
|
-
import 'node:module';
|
|
1
|
+
import { L as Loader, t as Core } from "../../core-Bkh-SI_3.js";
|
|
2
|
+
import { LoaderContext } from "webpack";
|
|
13
3
|
|
|
4
|
+
//#region src/plugins/with-loader/webpack.d.ts
|
|
14
5
|
type WebpackLoader = (this: LoaderContext<unknown>, source: string, callback: LoaderContext<unknown>["callback"]) => Promise<void>;
|
|
15
6
|
interface WebpackLoaderOptions {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
absoluteCompiledConfigPath: string;
|
|
8
|
+
configPath: string;
|
|
9
|
+
outDir: string;
|
|
10
|
+
isDev: boolean;
|
|
20
11
|
}
|
|
21
12
|
declare function getCore(options: WebpackLoaderOptions): Core;
|
|
22
13
|
/**
|
|
23
14
|
* need to handle the `test` regex in Webpack config instead.
|
|
24
15
|
*/
|
|
25
16
|
declare function toWebpack(loader: Loader): WebpackLoader;
|
|
26
|
-
|
|
27
|
-
export {
|
|
17
|
+
//#endregion
|
|
18
|
+
export { WebpackLoader, WebpackLoaderOptions, getCore, toWebpack };
|
|
19
|
+
//# sourceMappingURL=webpack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack.d.ts","names":[],"sources":["../../../src/plugins/with-loader/webpack.ts"],"sourcesContent":[],"mappings":";;;;KAOY,aAAA,UACJ,kDAEI,uCACP;AAJO,UAMK,oBAAA,CANQ;EACjB,0BAAA,EAAA,MAAA;EAEI,UAAA,EAAA,MAAA;EACP,MAAA,EAAA,MAAA;EAAO,KAAA,EAAA,OAAA;AAEZ;AASgB,iBAAA,OAAA,CAAiB,OAAA,EAAA,oBAAoB,CAAA,EAAA,IAAA;AAUrD;;;iBAAgB,SAAA,SAAkB,SAAS"}
|
|
@@ -1,12 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import "../../code-generator-gPtrfZ6Q.js";
|
|
2
|
+
import { t as Core } from "../../core-ZuoVBkeg.js";
|
|
3
|
+
import { t as ValidationError } from "../../validation-BOJKRAp5.js";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { parse } from "node:querystring";
|
|
6
|
+
|
|
7
|
+
//#region src/plugins/with-loader/webpack.ts
|
|
8
|
+
let core;
|
|
9
|
+
function getCore(options) {
|
|
10
|
+
return core ??= new Core({
|
|
11
|
+
outDir: options.outDir,
|
|
12
|
+
configPath: options.configPath
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* need to handle the `test` regex in Webpack config instead.
|
|
17
|
+
*/
|
|
18
|
+
function toWebpack(loader) {
|
|
19
|
+
return async function(source, callback) {
|
|
20
|
+
try {
|
|
21
|
+
const result = await loader.load({
|
|
22
|
+
filePath: this.resourcePath,
|
|
23
|
+
query: parse(this.resourceQuery.slice(1)),
|
|
24
|
+
getSource() {
|
|
25
|
+
return source;
|
|
26
|
+
},
|
|
27
|
+
development: this.mode === "development",
|
|
28
|
+
compiler: this
|
|
29
|
+
});
|
|
30
|
+
if (result === null) callback(void 0, source);
|
|
31
|
+
else callback(void 0, result.code, result.map);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (error instanceof ValidationError) return callback(new Error(await error.toStringFormatted()));
|
|
34
|
+
if (!(error instanceof Error)) throw error;
|
|
35
|
+
error.message = `${path.relative(this.context, this.resourcePath)}:${error.name}: ${error.message}`;
|
|
36
|
+
callback(error);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { getCore, toWebpack };
|
|
43
|
+
//# sourceMappingURL=webpack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack.js","names":["core: Core"],"sources":["../../../src/plugins/with-loader/webpack.ts"],"sourcesContent":["import type { LoaderContext } from \"webpack\";\nimport { parse } from \"node:querystring\";\nimport { ValidationError } from \"@/utils/validation\";\nimport path from \"node:path\";\nimport type { Loader } from \"@/plugins/with-loader\";\nimport { Core } from \"@/core\";\n\nexport type WebpackLoader = (\n this: LoaderContext<unknown>,\n source: string,\n callback: LoaderContext<unknown>[\"callback\"],\n) => Promise<void>;\n\nexport interface WebpackLoaderOptions {\n absoluteCompiledConfigPath: string;\n configPath: string;\n outDir: string;\n isDev: boolean;\n}\n\nlet core: Core;\n\nexport function getCore(options: WebpackLoaderOptions) {\n return (core ??= new Core({\n outDir: options.outDir,\n configPath: options.configPath,\n }));\n}\n\n/**\n * need to handle the `test` regex in Webpack config instead.\n */\nexport function toWebpack(loader: Loader): WebpackLoader {\n return async function (source, callback) {\n try {\n const result = await loader.load({\n filePath: this.resourcePath,\n query: parse(this.resourceQuery.slice(1)),\n getSource() {\n return source;\n },\n development: this.mode === \"development\",\n compiler: this,\n });\n\n if (result === null) {\n callback(undefined, source);\n } else {\n callback(undefined, result.code, result.map as string);\n }\n } catch (error) {\n if (error instanceof ValidationError) {\n return callback(new Error(await error.toStringFormatted()));\n }\n\n if (!(error instanceof Error)) throw error;\n\n const fpath = path.relative(this.context, this.resourcePath);\n error.message = `${fpath}:${error.name}: ${error.message}`;\n callback(error);\n }\n };\n}\n"],"mappings":";;;;;;;AAoBA,IAAIA;AAEJ,SAAgB,QAAQ,SAA+B;AACrD,QAAQ,SAAS,IAAI,KAAK;EACxB,QAAQ,QAAQ;EAChB,YAAY,QAAQ;EACrB,CAAC;;;;;AAMJ,SAAgB,UAAU,QAA+B;AACvD,QAAO,eAAgB,QAAQ,UAAU;AACvC,MAAI;GACF,MAAM,SAAS,MAAM,OAAO,KAAK;IAC/B,UAAU,KAAK;IACf,OAAO,MAAM,KAAK,cAAc,MAAM,EAAE,CAAC;IACzC,YAAY;AACV,YAAO;;IAET,aAAa,KAAK,SAAS;IAC3B,UAAU;IACX,CAAC;AAEF,OAAI,WAAW,KACb,UAAS,QAAW,OAAO;OAE3B,UAAS,QAAW,OAAO,MAAM,OAAO,IAAc;WAEjD,OAAO;AACd,OAAI,iBAAiB,gBACnB,QAAO,SAAS,IAAI,MAAM,MAAM,MAAM,mBAAmB,CAAC,CAAC;AAG7D,OAAI,EAAE,iBAAiB,OAAQ,OAAM;AAGrC,SAAM,UAAU,GADF,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACnC,GAAG,MAAM,KAAK,IAAI,MAAM;AACjD,YAAS,MAAM"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/collections/runtime/store.ts
|
|
2
|
+
var SimpleCollectionStore = class {
|
|
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
|
+
$data(_cast) {
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* in-place transformation on all data
|
|
20
|
+
*/
|
|
21
|
+
transform(fn) {
|
|
22
|
+
this.dataList.length = 0;
|
|
23
|
+
const dataMap = this.dataMap;
|
|
24
|
+
const dataList = this.dataList;
|
|
25
|
+
for (const [k, v] of this.dataMap) {
|
|
26
|
+
const updated = fn(v);
|
|
27
|
+
dataMap.set(k, updated);
|
|
28
|
+
dataList.push(updated);
|
|
29
|
+
}
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
get $inferData() {}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { SimpleCollectionStore as t };
|
|
37
|
+
//# sourceMappingURL=store-0LQ2PlH6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-0LQ2PlH6.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 change data type, doesn't do any runtime transformation.\n */\n $data: <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, can be anything\n */\n $inferData: Data;\n}\n\nexport class SimpleCollectionStore<Data> implements CollectionStore<\n string,\n Data\n> {\n private readonly dataMap: Map<string, Data>;\n private readonly dataList: Data[];\n\n constructor(input: Map<string, Data>) {\n this.dataMap = input;\n this.dataList = Array.from(input.values());\n }\n\n get(id: string): Data | undefined {\n return this.dataMap.get(id);\n }\n\n list(): Data[] {\n return this.dataList;\n }\n\n $data<T>(_cast: (input: Data) => T): SimpleCollectionStore<T> {\n return this as unknown as SimpleCollectionStore<T>;\n }\n\n /**\n * in-place transformation on all data\n */\n transform<T>(fn: (input: Data) => T): SimpleCollectionStore<T> {\n this.dataList.length = 0;\n const dataMap = this.dataMap as unknown as Map<string, T>;\n const dataList = this.dataList as unknown as T[];\n\n for (const [k, v] of this.dataMap) {\n const updated = fn(v);\n dataMap.set(k, updated);\n dataList.push(updated);\n }\n\n return this as unknown as SimpleCollectionStore<T>;\n }\n\n get $inferData(): Data {\n return undefined as Data;\n }\n}\n"],"mappings":";AAiBA,IAAa,wBAAb,MAGE;CACA,AAAiB;CACjB,AAAiB;CAEjB,YAAY,OAA0B;AACpC,OAAK,UAAU;AACf,OAAK,WAAW,MAAM,KAAK,MAAM,QAAQ,CAAC;;CAG5C,IAAI,IAA8B;AAChC,SAAO,KAAK,QAAQ,IAAI,GAAG;;CAG7B,OAAe;AACb,SAAO,KAAK;;CAGd,MAAS,OAAqD;AAC5D,SAAO;;;;;CAMT,UAAa,IAAkD;AAC7D,OAAK,SAAS,SAAS;EACvB,MAAM,UAAU,KAAK;EACrB,MAAM,WAAW,KAAK;AAEtB,OAAK,MAAM,CAAC,GAAG,MAAM,KAAK,SAAS;GACjC,MAAM,UAAU,GAAG,EAAE;AACrB,WAAQ,IAAI,GAAG,QAAQ;AACvB,YAAS,KAAK,QAAQ;;AAGxB,SAAO;;CAGT,IAAI,aAAmB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { K as Awaitable } from "./core-Bkh-SI_3.js";
|
|
2
|
+
|
|
3
|
+
//#region src/collections/runtime/store.d.ts
|
|
4
|
+
interface CollectionStore<Id, Data> {
|
|
5
|
+
/**
|
|
6
|
+
* type-only operation to change data type, doesn't do any runtime transformation.
|
|
7
|
+
*/
|
|
8
|
+
$data: <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, can be anything
|
|
13
|
+
*/
|
|
14
|
+
$inferData: Data;
|
|
15
|
+
}
|
|
16
|
+
declare class SimpleCollectionStore<Data> implements CollectionStore<string, Data> {
|
|
17
|
+
private readonly dataMap;
|
|
18
|
+
private readonly dataList;
|
|
19
|
+
constructor(input: Map<string, Data>);
|
|
20
|
+
get(id: string): Data | undefined;
|
|
21
|
+
list(): Data[];
|
|
22
|
+
$data<T>(_cast: (input: Data) => T): SimpleCollectionStore<T>;
|
|
23
|
+
/**
|
|
24
|
+
* in-place transformation on all data
|
|
25
|
+
*/
|
|
26
|
+
transform<T>(fn: (input: Data) => T): SimpleCollectionStore<T>;
|
|
27
|
+
get $inferData(): Data;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { SimpleCollectionStore as n, CollectionStore as t };
|
|
31
|
+
//# sourceMappingURL=store-DEjYYF6a.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-DEjYYF6a.d.ts","names":[],"sources":["../src/collections/runtime/store.ts"],"sourcesContent":[],"mappings":";;;UAEiB;;AAAjB;;EAIqC,KAAA,EAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAAA,CAAA,KAAA,EAAT,IAAS,EAAA,GAAA,CAAA,EAAA,GAAM,eAAN,CAAsB,EAAtB,EAA0B,CAA1B,CAAA;EAAsB,GAAA,EAAA,CAAA,EAAA,EAE/C,EAF+C,EAAA,GAExC,SAFwC,CAE9B,IAF8B,GAAA,SAAA,CAAA;EAAI,IAAA,EAAA,GAAA,GAGjD,SAHiD,CAGvC,IAHuC,EAAA,CAAA;EAApB;;;EAExB,UAAA,EAML,IANK;;AACL,cAQD,qBARC,CAAA,IAAA,CAAA,YAQsC,eARtC,CAAA,MAAA,EAUZ,IAVY,CAAA,CAAA;EAKA,iBAAA,OAAA;EAAI,iBAAA,QAAA;EAGL,WAAA,CAAA,KAAA,EAOQ,GAPR,CAAA,MAAqB,EAOD,IAPC,CAAA;EAEhC,GAAA,CAAA,EAAA,EAAA,MAAA,CAAA,EAUiB,IAVjB,GAAA,SAAA;EAK+B,IAAA,CAAA,CAAA,EASvB,IATuB,EAAA;EAAZ,KAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAAA,CAAA,KAAA,EAaK,IAbL,EAAA,GAac,CAbd,CAAA,EAakB,qBAblB,CAawC,CAbxC,CAAA;EAKF;;;EAQgB,SAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,KAAA,EAOR,IAPQ,EAAA,GAOC,CAPD,CAAA,EAOK,qBAPL,CAO2B,CAP3B,CAAA;EAA0B,IAAA,UAAA,CAAA,CAAA,EAqBzC,IArByC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/utils/validation.ts
|
|
2
|
+
var ValidationError = class extends Error {
|
|
3
|
+
title;
|
|
4
|
+
issues;
|
|
5
|
+
constructor(message, issues) {
|
|
6
|
+
super(`${message}:\n${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`);
|
|
7
|
+
this.title = message;
|
|
8
|
+
this.issues = issues;
|
|
9
|
+
}
|
|
10
|
+
async toStringFormatted() {
|
|
11
|
+
const picocolorsModule = await import("picocolors");
|
|
12
|
+
const picocolors = picocolorsModule.default ?? picocolorsModule;
|
|
13
|
+
return [picocolors.bold(`[Fuma Content] ${this.title}:`), ...this.issues.map((issue) => picocolors.redBright(`- ${picocolors.bold(issue.path?.join(".") ?? "*")}: ${issue.message}`))].join("\n");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
async function validate(schema, data, context, errorMessage) {
|
|
17
|
+
if (typeof schema === "function" && !("~standard" in schema)) schema = schema(context);
|
|
18
|
+
if ("~standard" in schema) {
|
|
19
|
+
const result = await schema["~standard"].validate(data);
|
|
20
|
+
if (result.issues) throw new ValidationError(errorMessage, result.issues);
|
|
21
|
+
return result.value;
|
|
22
|
+
}
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { validate as n, ValidationError as t };
|
|
28
|
+
//# sourceMappingURL=validation-BOJKRAp5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-BOJKRAp5.js","names":[],"sources":["../src/utils/validation.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nexport class ValidationError extends Error {\n title: string;\n issues: readonly StandardSchemaV1.Issue[];\n\n constructor(message: string, issues: readonly StandardSchemaV1.Issue[]) {\n super(\n `${message}:\\n${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join(\"\\n\")}`,\n );\n\n this.title = message;\n this.issues = issues;\n }\n\n async toStringFormatted() {\n // Handle ESM/CJS interop: picocolors is a CJS module that exports via\n // module.exports = createColors(). When dynamically imported in ESM context\n // (e.g., Next.js 16 Turbopack), the exports are wrapped under .default\n const picocolorsModule = await import(\"picocolors\");\n const picocolors = picocolorsModule.default ?? picocolorsModule;\n\n return [\n picocolors.bold(`[Fuma Content] ${this.title}:`),\n ...this.issues.map((issue) =>\n picocolors.redBright(\n `- ${picocolors.bold(issue.path?.join(\".\") ?? \"*\")}: ${issue.message}`,\n ),\n ),\n ].join(\"\\n\");\n }\n}\n\nexport async function validate<Schema extends StandardSchemaV1, Context>(\n schema: StandardSchemaV1 | ((context: Context) => StandardSchemaV1),\n data: unknown,\n context: Context,\n errorMessage: string,\n): Promise<StandardSchemaV1.InferOutput<Schema>> {\n if (typeof schema === \"function\" && !(\"~standard\" in schema)) {\n schema = schema(context);\n }\n\n if (\"~standard\" in schema) {\n const result = await (schema as StandardSchemaV1)[\"~standard\"].validate(\n data,\n );\n\n if (result.issues) {\n throw new ValidationError(errorMessage, result.issues);\n }\n\n return result.value;\n }\n\n return data;\n}\n"],"mappings":";AAEA,IAAa,kBAAb,cAAqC,MAAM;CACzC;CACA;CAEA,YAAY,SAAiB,QAA2C;AACtE,QACE,GAAG,QAAQ,KAAK,OAAO,KAAK,UAAU,KAAK,MAAM,KAAK,IAAI,MAAM,UAAU,CAAC,KAAK,KAAK,GACtF;AAED,OAAK,QAAQ;AACb,OAAK,SAAS;;CAGhB,MAAM,oBAAoB;EAIxB,MAAM,mBAAmB,MAAM,OAAO;EACtC,MAAM,aAAa,iBAAiB,WAAW;AAE/C,SAAO,CACL,WAAW,KAAK,kBAAkB,KAAK,MAAM,GAAG,EAChD,GAAG,KAAK,OAAO,KAAK,UAClB,WAAW,UACT,KAAK,WAAW,KAAK,MAAM,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,MAAM,UAC9D,CACF,CACF,CAAC,KAAK,KAAK;;;AAIhB,eAAsB,SACpB,QACA,MACA,SACA,cAC+C;AAC/C,KAAI,OAAO,WAAW,cAAc,EAAE,eAAe,QACnD,UAAS,OAAO,QAAQ;AAG1B,KAAI,eAAe,QAAQ;EACzB,MAAM,SAAS,MAAO,OAA4B,aAAa,SAC7D,KACD;AAED,MAAI,OAAO,OACT,OAAM,IAAI,gBAAgB,cAAc,OAAO,OAAO;AAGxD,SAAO,OAAO;;AAGhB,QAAO"}
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import 'chokidar';
|
|
4
|
-
import '@mdx-js/mdx';
|
|
5
|
-
import 'vfile';
|
|
6
|
-
import '@standard-schema/spec';
|
|
7
|
-
import 'unified';
|
|
8
|
-
import 'mdast';
|
|
9
|
-
import 'next';
|
|
10
|
-
import 'node:module';
|
|
1
|
+
import { t as Core } from "../core-Bkh-SI_3.js";
|
|
2
|
+
import { PluginOption } from "vite";
|
|
11
3
|
|
|
4
|
+
//#region src/vite/index.d.ts
|
|
12
5
|
interface PluginOptions {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @defaultValue content.config.ts
|
|
8
|
+
*/
|
|
9
|
+
configPath?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Update Vite config to fix module resolution of Fumadocs
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue true
|
|
14
|
+
*/
|
|
15
|
+
updateViteConfig?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Output directory of generated files
|
|
18
|
+
*
|
|
19
|
+
* @defaultValue '.content'
|
|
20
|
+
*/
|
|
21
|
+
outDir?: string;
|
|
29
22
|
}
|
|
30
23
|
declare function content(config: Record<string, unknown>, pluginOptions?: PluginOptions): Promise<PluginOption[]>;
|
|
31
24
|
declare function createStandaloneCore(pluginOptions?: PluginOptions): Promise<Core>;
|
|
32
|
-
|
|
33
|
-
export {
|
|
25
|
+
//#endregion
|
|
26
|
+
export { PluginOptions, createStandaloneCore, content as default };
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/vite/index.ts"],"sourcesContent":[],"mappings":";;;;UAKiB,aAAA;;AAAjB;AAmBC;EAGS,UAAA,CAAA,EAAA,MAAA;EACO;;;;AA2BjB;EAA0D,gBAAA,CAAA,EAAA,OAAA;EAAkB;;;;;;;iBA7B9C,OAAA,SACpB,yCACO,gBACd,QAAQ;iBA0BW,oBAAA,iBAAoC,gBAAkB,QAAA"}
|
package/dist/vite/index.js
CHANGED
|
@@ -1,61 +1,46 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
} from "../
|
|
4
|
-
import {
|
|
5
|
-
Core
|
|
6
|
-
} from "../chunk-NRZ4GE5O.js";
|
|
7
|
-
import "../chunk-MT7RY65Y.js";
|
|
8
|
-
import "../chunk-JBZTQ55D.js";
|
|
1
|
+
import "../code-generator-gPtrfZ6Q.js";
|
|
2
|
+
import { t as Core } from "../core-ZuoVBkeg.js";
|
|
3
|
+
import { t as buildConfig } from "../build-D8A5ByFk.js";
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
//#region src/vite/index.ts
|
|
11
6
|
async function content(config, pluginOptions = {}) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
async configureServer(server) {
|
|
26
|
-
await core.initServer({
|
|
27
|
-
watcher: server.watcher
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
];
|
|
7
|
+
const core = createViteCore(applyDefaults(pluginOptions));
|
|
8
|
+
await core.init({ config: buildConfig(config) });
|
|
9
|
+
const ctx = core.getPluginContext();
|
|
10
|
+
return [...core.getPlugins(true).map((plugin) => plugin.vite?.createPlugin?.call(ctx)), {
|
|
11
|
+
name: "fuma-content",
|
|
12
|
+
async buildStart() {
|
|
13
|
+
await core.emit({ write: true });
|
|
14
|
+
},
|
|
15
|
+
async configureServer(server) {
|
|
16
|
+
await core.initServer({ watcher: server.watcher });
|
|
17
|
+
}
|
|
18
|
+
}];
|
|
32
19
|
}
|
|
33
20
|
async function createStandaloneCore(pluginOptions = {}) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
return core;
|
|
21
|
+
const { loadConfig } = await import("../load-from-file-BTNnBu6f.js");
|
|
22
|
+
const core = createViteCore(applyDefaults(pluginOptions));
|
|
23
|
+
await core.init({ config: loadConfig(core, true) });
|
|
24
|
+
return core;
|
|
40
25
|
}
|
|
41
26
|
function createViteCore({ configPath, outDir }) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
27
|
+
return new Core({
|
|
28
|
+
configPath,
|
|
29
|
+
outDir,
|
|
30
|
+
emit: {
|
|
31
|
+
target: "vite",
|
|
32
|
+
jsExtension: false
|
|
33
|
+
}
|
|
34
|
+
});
|
|
50
35
|
}
|
|
51
36
|
function applyDefaults(options) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
return {
|
|
38
|
+
updateViteConfig: options.updateViteConfig ?? true,
|
|
39
|
+
configPath: options.configPath ?? Core.defaultOptions.configPath,
|
|
40
|
+
outDir: options.outDir ?? Core.defaultOptions.outDir
|
|
41
|
+
};
|
|
57
42
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { createStandaloneCore, content as default };
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/vite/index.ts"],"sourcesContent":["import type { PluginOption } from \"vite\";\nimport { buildConfig } from \"@/config/build\";\nimport type { FSWatcher } from \"chokidar\";\nimport { Core } from \"@/core\";\n\nexport interface PluginOptions {\n /**\n * @defaultValue content.config.ts\n */\n configPath?: string;\n\n /**\n * Update Vite config to fix module resolution of Fumadocs\n *\n * @defaultValue true\n */\n updateViteConfig?: boolean;\n\n /**\n * Output directory of generated files\n *\n * @defaultValue '.content'\n */\n outDir?: string;\n}\n\nexport default async function content(\n config: Record<string, unknown>,\n pluginOptions: PluginOptions = {},\n): Promise<PluginOption[]> {\n const options = applyDefaults(pluginOptions);\n const core = createViteCore(options);\n await core.init({\n config: buildConfig(config),\n });\n\n const ctx = core.getPluginContext();\n return [\n ...core\n .getPlugins(true)\n .map((plugin) => plugin.vite?.createPlugin?.call(ctx)),\n {\n name: \"fuma-content\",\n async buildStart() {\n await core.emit({ write: true });\n },\n async configureServer(server) {\n await core.initServer({\n watcher: server.watcher as unknown as FSWatcher,\n });\n },\n },\n ];\n}\n\nexport async function createStandaloneCore(pluginOptions: PluginOptions = {}) {\n const { loadConfig } = await import(\"@/config/load-from-file\");\n const core = createViteCore(applyDefaults(pluginOptions));\n await core.init({\n config: loadConfig(core, true),\n });\n return core;\n}\n\nfunction createViteCore({ configPath, outDir }: Required<PluginOptions>) {\n return new Core({\n configPath,\n outDir,\n emit: {\n target: \"vite\",\n jsExtension: false,\n },\n });\n}\n\nfunction applyDefaults(options: PluginOptions): Required<PluginOptions> {\n return {\n updateViteConfig: options.updateViteConfig ?? true,\n configPath: options.configPath ?? Core.defaultOptions.configPath,\n outDir: options.outDir ?? Core.defaultOptions.outDir,\n };\n}\n"],"mappings":";;;;;AA0BA,eAA8B,QAC5B,QACA,gBAA+B,EAAE,EACR;CAEzB,MAAM,OAAO,eADG,cAAc,cAAc,CACR;AACpC,OAAM,KAAK,KAAK,EACd,QAAQ,YAAY,OAAO,EAC5B,CAAC;CAEF,MAAM,MAAM,KAAK,kBAAkB;AACnC,QAAO,CACL,GAAG,KACA,WAAW,KAAK,CAChB,KAAK,WAAW,OAAO,MAAM,cAAc,KAAK,IAAI,CAAC,EACxD;EACE,MAAM;EACN,MAAM,aAAa;AACjB,SAAM,KAAK,KAAK,EAAE,OAAO,MAAM,CAAC;;EAElC,MAAM,gBAAgB,QAAQ;AAC5B,SAAM,KAAK,WAAW,EACpB,SAAS,OAAO,SACjB,CAAC;;EAEL,CACF;;AAGH,eAAsB,qBAAqB,gBAA+B,EAAE,EAAE;CAC5E,MAAM,EAAE,eAAe,MAAM,OAAO;CACpC,MAAM,OAAO,eAAe,cAAc,cAAc,CAAC;AACzD,OAAM,KAAK,KAAK,EACd,QAAQ,WAAW,MAAM,KAAK,EAC/B,CAAC;AACF,QAAO;;AAGT,SAAS,eAAe,EAAE,YAAY,UAAmC;AACvE,QAAO,IAAI,KAAK;EACd;EACA;EACA,MAAM;GACJ,QAAQ;GACR,aAAa;GACd;EACF,CAAC;;AAGJ,SAAS,cAAc,SAAiD;AACtE,QAAO;EACL,kBAAkB,QAAQ,oBAAoB;EAC9C,YAAY,QAAQ,cAAc,KAAK,eAAe;EACtD,QAAQ,QAAQ,UAAU,KAAK,eAAe;EAC/C"}
|