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.
Files changed (147) hide show
  1. package/dist/async-cache-BM9Yf4Nw.js +29 -0
  2. package/dist/async-cache-BM9Yf4Nw.js.map +1 -0
  3. package/dist/bin.d.ts +1 -1
  4. package/dist/bin.js +21 -14
  5. package/dist/bin.js.map +1 -0
  6. package/dist/build-D8A5ByFk.js +42 -0
  7. package/dist/build-D8A5ByFk.js.map +1 -0
  8. package/dist/build-mdx-C1PZsGp2.js +395 -0
  9. package/dist/build-mdx-C1PZsGp2.js.map +1 -0
  10. package/dist/build-mdx-DFndaVbS.js +4 -0
  11. package/dist/bun/index.d.ts +6 -13
  12. package/dist/bun/index.d.ts.map +1 -0
  13. package/dist/bun/index.js +23 -34
  14. package/dist/bun/index.js.map +1 -0
  15. package/dist/bun-QKQnqgIi.js +35 -0
  16. package/dist/bun-QKQnqgIi.js.map +1 -0
  17. package/dist/code-generator-gPtrfZ6Q.js +133 -0
  18. package/dist/code-generator-gPtrfZ6Q.js.map +1 -0
  19. package/dist/collections/handlers/fs.d.ts +2 -10
  20. package/dist/collections/handlers/fs.js +28 -6
  21. package/dist/collections/handlers/fs.js.map +1 -0
  22. package/dist/collections/index.d.ts +2 -10
  23. package/dist/collections/index.js +16 -6
  24. package/dist/collections/index.js.map +1 -0
  25. package/dist/collections/mdx/loader-webpack.d.ts +6 -14
  26. package/dist/collections/mdx/loader-webpack.d.ts.map +1 -0
  27. package/dist/collections/mdx/loader-webpack.js +23 -36
  28. package/dist/collections/mdx/loader-webpack.js.map +1 -0
  29. package/dist/collections/mdx/runtime-browser.d.ts +27 -37
  30. package/dist/collections/mdx/runtime-browser.d.ts.map +1 -0
  31. package/dist/collections/mdx/runtime-browser.js +57 -70
  32. package/dist/collections/mdx/runtime-browser.js.map +1 -0
  33. package/dist/collections/mdx/runtime-dynamic.d.ts +22 -30
  34. package/dist/collections/mdx/runtime-dynamic.d.ts.map +1 -0
  35. package/dist/collections/mdx/runtime-dynamic.js +63 -85
  36. package/dist/collections/mdx/runtime-dynamic.js.map +1 -0
  37. package/dist/collections/mdx/runtime.d.ts +31 -52
  38. package/dist/collections/mdx/runtime.d.ts.map +1 -0
  39. package/dist/collections/mdx/runtime.js +24 -34
  40. package/dist/collections/mdx/runtime.js.map +1 -0
  41. package/dist/collections/mdx.d.ts +2 -10
  42. package/dist/collections/mdx.js +240 -284
  43. package/dist/collections/mdx.js.map +1 -0
  44. package/dist/collections/meta/loader-webpack.d.ts +6 -14
  45. package/dist/collections/meta/loader-webpack.d.ts.map +1 -0
  46. package/dist/collections/meta/loader-webpack.js +25 -39
  47. package/dist/collections/meta/loader-webpack.js.map +1 -0
  48. package/dist/collections/meta/runtime.d.ts +7 -15
  49. package/dist/collections/meta/runtime.d.ts.map +1 -0
  50. package/dist/collections/meta/runtime.js +9 -15
  51. package/dist/collections/meta/runtime.js.map +1 -0
  52. package/dist/collections/meta.d.ts +2 -10
  53. package/dist/collections/meta.js +128 -164
  54. package/dist/collections/meta.js.map +1 -0
  55. package/dist/collections/runtime/file-store.d.ts +17 -14
  56. package/dist/collections/runtime/file-store.d.ts.map +1 -0
  57. package/dist/collections/runtime/file-store.js +30 -6
  58. package/dist/collections/runtime/file-store.js.map +1 -0
  59. package/dist/collections/runtime/store.d.ts +3 -28
  60. package/dist/collections/runtime/store.js +3 -6
  61. package/dist/config/index.d.ts +2 -10
  62. package/dist/config/index.js +6 -5
  63. package/dist/config/index.js.map +1 -0
  64. package/dist/core-Bkh-SI_3.d.ts +561 -0
  65. package/dist/core-Bkh-SI_3.d.ts.map +1 -0
  66. package/dist/core-ZuoVBkeg.js +170 -0
  67. package/dist/core-ZuoVBkeg.js.map +1 -0
  68. package/dist/dynamic-B40uAtdo.js +28 -0
  69. package/dist/dynamic-B40uAtdo.js.map +1 -0
  70. package/dist/fuma-matter-O4fA6nSx.js +27 -0
  71. package/dist/fuma-matter-O4fA6nSx.js.map +1 -0
  72. package/dist/index.d.ts +13 -16
  73. package/dist/index.d.ts.map +1 -0
  74. package/dist/index.js +6 -8
  75. package/dist/load-from-file-1f4WaHsf.js +38 -0
  76. package/dist/load-from-file-1f4WaHsf.js.map +1 -0
  77. package/dist/load-from-file-BTNnBu6f.js +3 -0
  78. package/dist/loader-80abXEHx.js +4 -0
  79. package/dist/loader-BFhPyg3z.js +4 -0
  80. package/dist/loader-CXnMFuyE.js +80 -0
  81. package/dist/loader-CXnMFuyE.js.map +1 -0
  82. package/dist/loader-gk94iHf5.js +66 -0
  83. package/dist/loader-gk94iHf5.js.map +1 -0
  84. package/dist/next/index.cjs +459 -551
  85. package/dist/next/index.d.ts +16 -22
  86. package/dist/next/index.d.ts.map +1 -0
  87. package/dist/next/index.js +71 -89
  88. package/dist/next/index.js.map +1 -0
  89. package/dist/node/loader.d.ts +4 -2
  90. package/dist/node/loader.d.ts.map +1 -0
  91. package/dist/node/loader.js +32 -44
  92. package/dist/node/loader.js.map +1 -0
  93. package/dist/node-CGIIJIcs.js +31 -0
  94. package/dist/node-CGIIJIcs.js.map +1 -0
  95. package/dist/pipe-5cnvE6KY.js +31 -0
  96. package/dist/pipe-5cnvE6KY.js.map +1 -0
  97. package/dist/plugins/git.d.ts +2 -10
  98. package/dist/plugins/git.js +57 -65
  99. package/dist/plugins/git.js.map +1 -0
  100. package/dist/plugins/json-schema.d.ts +2 -10
  101. package/dist/plugins/json-schema.js +60 -58
  102. package/dist/plugins/json-schema.js.map +1 -0
  103. package/dist/plugins/with-loader/index.d.ts +2 -61
  104. package/dist/plugins/with-loader/index.js +28 -6
  105. package/dist/plugins/with-loader/index.js.map +1 -0
  106. package/dist/plugins/with-loader/webpack.d.ts +10 -18
  107. package/dist/plugins/with-loader/webpack.d.ts.map +1 -0
  108. package/dist/plugins/with-loader/webpack.js +43 -12
  109. package/dist/plugins/with-loader/webpack.js.map +1 -0
  110. package/dist/store-0LQ2PlH6.js +37 -0
  111. package/dist/store-0LQ2PlH6.js.map +1 -0
  112. package/dist/store-DEjYYF6a.d.ts +31 -0
  113. package/dist/store-DEjYYF6a.d.ts.map +1 -0
  114. package/dist/validation-BOJKRAp5.js +28 -0
  115. package/dist/validation-BOJKRAp5.js.map +1 -0
  116. package/dist/vite/index.d.ts +22 -28
  117. package/dist/vite/index.d.ts.map +1 -0
  118. package/dist/vite/index.js +37 -52
  119. package/dist/vite/index.js.map +1 -0
  120. package/dist/vite-X-2Al8fq.js +32 -0
  121. package/dist/vite-X-2Al8fq.js.map +1 -0
  122. package/package.json +7 -6
  123. package/dist/build-mdx-I4NROXCF.js +0 -8
  124. package/dist/bun-DMNX4PBC.js +0 -40
  125. package/dist/chunk-3VQS3KSP.js +0 -39
  126. package/dist/chunk-BTRE6MOX.js +0 -16
  127. package/dist/chunk-E4HRKSP4.js +0 -24
  128. package/dist/chunk-ERBMAQYP.js +0 -33
  129. package/dist/chunk-GGL4EF6H.js +0 -38
  130. package/dist/chunk-JBZTQ55D.js +0 -30
  131. package/dist/chunk-KH5GT2Y5.js +0 -104
  132. package/dist/chunk-LUM7SIZN.js +0 -40
  133. package/dist/chunk-MT7RY65Y.js +0 -167
  134. package/dist/chunk-NRZ4GE5O.js +0 -207
  135. package/dist/chunk-OQQNA7L7.js +0 -412
  136. package/dist/chunk-OUJENWQ4.js +0 -45
  137. package/dist/chunk-RMSV4HP6.js +0 -85
  138. package/dist/chunk-RXR7OL76.js +0 -37
  139. package/dist/chunk-VWJKRQZR.js +0 -19
  140. package/dist/chunk-W6HENTK7.js +0 -44
  141. package/dist/chunk-XR5N6ZXJ.js +0 -50
  142. package/dist/core-Bo8KaWQz.d.ts +0 -411
  143. package/dist/load-from-file-HL2VEY3M.js +0 -7
  144. package/dist/loader-NFSL6P5I.js +0 -7
  145. package/dist/loader-T756NSCS.js +0 -7
  146. package/dist/node-DCMYL4DL.js +0 -34
  147. package/dist/vite-QCUPZHHB.js +0 -32
@@ -1,85 +0,0 @@
1
- import {
2
- validate
3
- } from "./chunk-OUJENWQ4.js";
4
-
5
- // src/collections/meta/loader.ts
6
- import { dump, load } from "js-yaml";
7
- import { z } from "zod";
8
- var querySchema = z.object({
9
- collection: z.string().optional(),
10
- workspace: z.string().optional()
11
- }).loose();
12
- function createMetaLoader({ getCore }, resolve = {}) {
13
- const { json: resolveJson = "js", yaml: resolveYaml = "js" } = resolve;
14
- function parse(filePath, source) {
15
- try {
16
- if (filePath.endsWith(".json")) return JSON.parse(source);
17
- if (filePath.endsWith(".yaml")) return load(source);
18
- } catch (e) {
19
- throw new Error(`invalid data in ${filePath}`, { cause: e });
20
- }
21
- throw new Error(`Unknown file type ${filePath}`);
22
- }
23
- function onMeta(source, { filePath, query }) {
24
- const parsed = querySchema.safeParse(query);
25
- if (!parsed.success || !parsed.data.collection) return null;
26
- const { collection: collectionName, workspace } = parsed.data;
27
- return async () => {
28
- let core = await getCore();
29
- if (workspace) {
30
- core = core.getWorkspaces().get(workspace) ?? core;
31
- }
32
- const collection = core.getCollection(collectionName);
33
- const handler = collection?.handlers.meta;
34
- let data = parse(filePath, source);
35
- if (!handler) return data;
36
- const context = {
37
- path: filePath,
38
- source
39
- };
40
- if (handler.schema) {
41
- data = await validate(
42
- handler.schema,
43
- data,
44
- context,
45
- `invalid data in ${filePath}`
46
- );
47
- }
48
- return handler.transform?.call(context, data);
49
- };
50
- }
51
- return {
52
- async load(input) {
53
- const result = onMeta(await input.getSource(), input);
54
- if (result === null) return null;
55
- const data = await result();
56
- if (input.filePath.endsWith(".json")) {
57
- return {
58
- code: resolveJson === "json" ? JSON.stringify(data) : `export default ${JSON.stringify(data)}`
59
- };
60
- } else {
61
- return {
62
- code: resolveYaml === "yaml" ? dump(data) : `export default ${JSON.stringify(data)}`
63
- };
64
- }
65
- },
66
- bun: {
67
- load(source, input) {
68
- const result = onMeta(source, input);
69
- if (result === null)
70
- return {
71
- loader: "object",
72
- exports: parse(input.filePath, source)
73
- };
74
- return result().then((data) => ({
75
- loader: "object",
76
- exports: { default: data }
77
- }));
78
- }
79
- }
80
- };
81
- }
82
-
83
- export {
84
- createMetaLoader
85
- };
@@ -1,37 +0,0 @@
1
- import {
2
- SimpleCollectionStore
3
- } from "./chunk-3VQS3KSP.js";
4
-
5
- // src/collections/runtime/file-store.ts
6
- import path from "path";
7
- function fileInfo(base, globKey) {
8
- if (globKey.startsWith("./")) {
9
- globKey = globKey.slice(2);
10
- }
11
- return {
12
- path: globKey,
13
- fullPath: path.join(base, globKey)
14
- };
15
- }
16
- var FileCollectionStore = class extends SimpleCollectionStore {
17
- constructor(base, glob) {
18
- const data = /* @__PURE__ */ new Map();
19
- for (const [key, value] of Object.entries(glob)) {
20
- data.set(key, {
21
- ...value,
22
- ...fileInfo(base, key)
23
- });
24
- }
25
- super(data);
26
- }
27
- transform(fn) {
28
- return super.transform(fn);
29
- }
30
- $data(_cast) {
31
- return super.$data(_cast);
32
- }
33
- };
34
-
35
- export {
36
- FileCollectionStore
37
- };
@@ -1,19 +0,0 @@
1
- // src/utils/fuma-matter.ts
2
- import { load } from "js-yaml";
3
- var regex = /^---\r?\n(.+?)\r?\n---\r?\n/s;
4
- function fumaMatter(input) {
5
- const output = { matter: "", data: {}, content: input };
6
- const match = regex.exec(input);
7
- if (!match) {
8
- return output;
9
- }
10
- output.matter = match[0];
11
- output.content = input.slice(match[0].length);
12
- const loaded = load(match[1]);
13
- output.data = loaded ?? {};
14
- return output;
15
- }
16
-
17
- export {
18
- fumaMatter
19
- };
@@ -1,44 +0,0 @@
1
- // src/config/build.ts
2
- function buildConfig(config, workspace) {
3
- const collections = /* @__PURE__ */ new Map();
4
- const loaded = {};
5
- let globalConfig;
6
- if ("default" in config) {
7
- globalConfig = config.default;
8
- for (const [k, v] of Object.entries(config)) {
9
- if (k === "default") continue;
10
- globalConfig.collections ??= {};
11
- globalConfig.collections[k] = v;
12
- }
13
- } else {
14
- globalConfig = config;
15
- }
16
- if (globalConfig.collections) {
17
- for (const [name, collection] of Object.entries(globalConfig.collections)) {
18
- collection.init?.({ name, workspace });
19
- collections.set(name, collection);
20
- }
21
- }
22
- return {
23
- ...globalConfig,
24
- collections,
25
- workspaces: Object.fromEntries(
26
- Object.entries(loaded.workspaces ?? {}).map(([key, value]) => {
27
- return [
28
- key,
29
- {
30
- dir: value.dir,
31
- config: buildConfig(value.config, {
32
- ...value,
33
- name: key
34
- })
35
- }
36
- ];
37
- })
38
- )
39
- };
40
- }
41
-
42
- export {
43
- buildConfig
44
- };
@@ -1,50 +0,0 @@
1
- import {
2
- ValidationError
3
- } from "./chunk-OUJENWQ4.js";
4
- import {
5
- Core
6
- } from "./chunk-NRZ4GE5O.js";
7
-
8
- // src/plugins/with-loader/webpack.ts
9
- import { parse } from "querystring";
10
- import path from "path";
11
- var core;
12
- function getCore(options) {
13
- return core ??= new Core({
14
- outDir: options.outDir,
15
- configPath: options.configPath
16
- });
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) {
31
- callback(void 0, source);
32
- } else {
33
- callback(void 0, result.code, result.map);
34
- }
35
- } catch (error) {
36
- if (error instanceof ValidationError) {
37
- return callback(new Error(await error.toStringFormatted()));
38
- }
39
- if (!(error instanceof Error)) throw error;
40
- const fpath = path.relative(this.context, this.resourcePath);
41
- error.message = `${fpath}:${error.name}: ${error.message}`;
42
- callback(error);
43
- }
44
- };
45
- }
46
-
47
- export {
48
- getCore,
49
- toWebpack
50
- };
@@ -1,411 +0,0 @@
1
- import { FSWatcher } from 'chokidar';
2
- import { ProcessorOptions } from '@mdx-js/mdx';
3
- import { VFile } from 'vfile';
4
- import { StandardSchemaV1 } from '@standard-schema/spec';
5
- import { Processor } from 'unified';
6
- import { Root } from 'mdast';
7
- import * as Vite from 'vite';
8
- import { NextConfig } from 'next';
9
- import { LoadHook } from 'node:module';
10
-
11
- interface JSONSchemaOptions {
12
- /**
13
- * insert `$schema` field to JSON files on creation.
14
- *
15
- * @defaultValue false
16
- */
17
- insert?: boolean;
18
- }
19
- interface JSONSchemaHandler {
20
- create: () => object | undefined | Promise<object | undefined>;
21
- }
22
- /**
23
- * Generate JSON schemas locally for collection schemas
24
- *
25
- * note: **it only works with Zod**
26
- */
27
- declare function jsonSchema({ insert, }?: JSONSchemaOptions): Plugin;
28
-
29
- interface FileHandlerConfig {
30
- /**
31
- * Directory to scan
32
- */
33
- dir: string;
34
- /**
35
- * what files to include/exclude (glob patterns)
36
- *
37
- * Include all files if not specified
38
- */
39
- files?: string[];
40
- }
41
- interface FIleCollectionHandler {
42
- /**
43
- * content directory (absolute)
44
- */
45
- dir: string;
46
- hasFile: (filePath: string) => boolean;
47
- isFileSupported: (filePath: string) => boolean;
48
- patterns: string[];
49
- }
50
- declare function buildFileHandler({ workspace }: InitOptions, config: FileHandlerConfig, supportedFormats: string[]): FIleCollectionHandler;
51
-
52
- interface ExtractedReference {
53
- href: string;
54
- }
55
- interface PostprocessOptions {
56
- _format: "md" | "mdx";
57
- /**
58
- * Properties to export from `vfile.data`
59
- */
60
- valueToExport?: string[];
61
- /**
62
- * stringify MDAST and export via `_markdown`.
63
- */
64
- includeProcessedMarkdown?: boolean;
65
- /**
66
- * extract link references, export via `extractedReferences`.
67
- */
68
- extractLinkReferences?: boolean;
69
- /**
70
- * store MDAST and export via `_mdast`.
71
- */
72
- includeMDAST?: boolean | {
73
- removePosition?: boolean;
74
- };
75
- }
76
-
77
- interface PreprocessOptions {
78
- preprocessor?: Processor<Root>;
79
- }
80
- declare module "vfile" {
81
- interface DataMap {
82
- _preprocessed?: boolean;
83
- }
84
- }
85
-
86
- type Awaitable$2<T> = T | PromiseLike<T>;
87
- interface CompilationContext {
88
- collection: Collection;
89
- filePath: string;
90
- source: string;
91
- }
92
- interface MDXCollectionHandler {
93
- readonly cwd: string;
94
- readonly dynamic: boolean;
95
- readonly lazy: boolean;
96
- preprocess?: PreprocessOptions;
97
- postprocess?: Partial<PostprocessOptions>;
98
- getMDXOptions?: (environment: "bundler" | "runtime") => Awaitable$2<ProcessorOptions>;
99
- /**
100
- * Transform frontmatter
101
- */
102
- frontmatter?: (this: CompilationContext, data: Record<string, unknown>) => Awaitable$2<Record<string, unknown> | undefined>;
103
- /**
104
- * Transform `vfile` on compilation stage
105
- */
106
- vfile?: (this: CompilationContext, file: VFile) => Awaitable$2<VFile>;
107
- onGenerateStore?: (this: EmitCodeGeneratorContext & {
108
- environment: "browser" | "server" | "dynamic";
109
- }, initializer: string) => string;
110
- }
111
- interface MDXCollectionConfig<FrontmatterSchema extends StandardSchemaV1 | undefined = undefined> extends FileHandlerConfig {
112
- postprocess?: Partial<PostprocessOptions>;
113
- frontmatter?: FrontmatterSchema;
114
- options?: (environment: "bundler" | "runtime") => Awaitable$2<ProcessorOptions>;
115
- lazy?: boolean;
116
- dynamic?: boolean;
117
- }
118
- type MDXCollection<Frontmatter> = Collection & {
119
- _frontmatter?: Frontmatter;
120
- };
121
- declare function defineMDX<FrontmatterSchema extends StandardSchemaV1 | undefined = undefined>(config: MDXCollectionConfig<FrontmatterSchema>): MDXCollection<FrontmatterSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<FrontmatterSchema> : Record<string, unknown>>;
122
-
123
- type Awaitable$1<T> = T | PromiseLike<T>;
124
- interface MetaContext {
125
- path: string;
126
- source: string;
127
- }
128
- interface MetaCollectionHandler {
129
- /**
130
- * Transform metadata
131
- */
132
- transform?: (this: MetaContext, data: unknown) => Awaitable$1<unknown | undefined>;
133
- schema?: StandardSchemaV1;
134
- }
135
- interface MetaCollectionConfig<Schema extends StandardSchemaV1> extends FileHandlerConfig {
136
- schema?: Schema;
137
- }
138
- type MetaCollection<_Data> = Collection & {
139
- _type?: _Data;
140
- };
141
- declare function defineMeta<Schema extends StandardSchemaV1>(config: MetaCollectionConfig<Schema>): MetaCollection<Schema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Schema> : Record<string, unknown>>;
142
-
143
- interface VersionControlFileData {
144
- /**
145
- * Last modified date of file, obtained from version control.
146
- */
147
- lastModified: Date | null;
148
- /**
149
- * Creation date of file, obtained from version control.
150
- */
151
- creationDate: Date | null;
152
- }
153
- interface VersionControlHandler {
154
- /**
155
- * receive the version control client.
156
- */
157
- client: (context: {
158
- client: VersionControlClient;
159
- }) => void | Promise<void>;
160
- }
161
- interface GitPluginOptions {
162
- /**
163
- * Filter the collections to include by names
164
- */
165
- filter?: (collection: string) => boolean;
166
- }
167
- /**
168
- * Add version control integration for Git.
169
- * 1. Injects `creationDate` & `lastModified` properties to page exports.
170
- *
171
- * @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.
172
- */
173
- declare function git(options?: GitPluginOptions): Plugin;
174
- interface VersionControlClient {
175
- getFileData: (options: {
176
- filePath: string;
177
- }) => Promise<VersionControlFileData>;
178
- }
179
-
180
- interface InitOptions {
181
- name: string;
182
- workspace?: WorkspaceConfig;
183
- }
184
- interface Collection {
185
- name: string;
186
- init?: (options: InitOptions) => void;
187
- readonly handlers: CollectionHandlers;
188
- /**
189
- * information for the collection type, can be shared for all collections of same type.
190
- */
191
- readonly typeInfo: CollectionTypeInfo;
192
- }
193
- interface CollectionTypeInfo {
194
- /**
195
- * ID for collection type.
196
- *
197
- * @example `my-package:my-collection-type`
198
- */
199
- readonly id: string;
200
- /**
201
- * plugins to register, registered once for each collection type.
202
- */
203
- readonly plugins?: PluginOption;
204
- }
205
- interface CollectionHandlers {
206
- fs?: FIleCollectionHandler;
207
- mdx?: MDXCollectionHandler;
208
- meta?: MetaCollectionHandler;
209
- "json-schema"?: JSONSchemaHandler;
210
- "version-control"?: VersionControlHandler;
211
- }
212
- declare function createCollection(info: CollectionTypeInfo, init: (collection: Collection, options: InitOptions) => void): Collection;
213
-
214
- interface GlobalConfig<Collections extends Record<string, Collection> = Record<string, Collection>> {
215
- plugins?: PluginOption[];
216
- collections?: Collections;
217
- workspaces?: Record<string, Omit<WorkspaceConfig, "name">>;
218
- /**
219
- * specify a directory to access & store cache (disabled during development mode).
220
- *
221
- * The cache will never be updated, delete the cache folder to clean.
222
- */
223
- experimentalBuildCache?: string;
224
- }
225
- interface WorkspaceConfig {
226
- name: string;
227
- dir: string;
228
- config: GlobalConfig | {
229
- default: GlobalConfig;
230
- };
231
- }
232
- declare function defineConfig<Collections extends Record<string, Collection> = Record<string, Collection>>(config?: GlobalConfig<Collections>): GlobalConfig<Collections>;
233
-
234
- interface LoadedConfig extends Omit<GlobalConfig, "workspaces" | "collections"> {
235
- collections: Map<string, Collection>;
236
- workspaces: Record<string, {
237
- dir: string;
238
- config: LoadedConfig;
239
- }>;
240
- }
241
-
242
- interface GlobImportOptions {
243
- base: string;
244
- query?: Record<string, string | undefined>;
245
- import?: string;
246
- eager?: boolean;
247
- }
248
- interface CodeGeneratorOptions {
249
- target: "default" | "vite";
250
- outDir: string;
251
- /**
252
- * add .js extenstion to imports
253
- */
254
- jsExtension: boolean;
255
- globCache: Map<string, Promise<string[]>>;
256
- }
257
- /**
258
- * Code generator (one instance per file)
259
- */
260
- declare class CodeGenerator {
261
- private readonly lines;
262
- private readonly globCache;
263
- private readonly importInfos;
264
- private eagerImportId;
265
- readonly options: CodeGeneratorOptions;
266
- constructor({ target, jsExtension, globCache, outDir, }: Partial<CodeGeneratorOptions>);
267
- addNamespaceImport(namespace: string, specifier: string, types?: boolean): void;
268
- addNamedImport(names: string[], specifier: string, types?: boolean): void;
269
- push(...insert: string[]): void;
270
- pushAsync(insert: Promise<string | undefined>[]): Promise<void>;
271
- generateGlobImport(patterns: string | string[], options: GlobImportOptions): Promise<string>;
272
- private generateViteGlobImport;
273
- private generateNodeGlobImport;
274
- formatImportPath(file: string): string;
275
- toString(): string;
276
- }
277
-
278
- type Awaitable<T> = T | PromiseLike<T>;
279
- interface EmitEntry {
280
- /**
281
- * path relative to output directory
282
- */
283
- path: string;
284
- content: string;
285
- }
286
- interface PluginContext {
287
- core: Core;
288
- }
289
- interface EmitContext extends PluginContext {
290
- createCodeGenerator: (path: string, content: (ctx: EmitCodeGeneratorContext) => Promise<void>) => Promise<EmitEntry>;
291
- }
292
- interface EmitCodeGeneratorContext {
293
- core: Core;
294
- workspace?: string;
295
- codegen: CodeGenerator;
296
- }
297
- interface Plugin {
298
- /**
299
- * unique name for plugin
300
- *
301
- * @example `my-package:my-plugin`
302
- */
303
- name: string;
304
- /**
305
- * on config loaded/updated
306
- */
307
- config?: (this: PluginContext, config: LoadedConfig) => Awaitable<void | LoadedConfig>;
308
- collection?: (this: PluginContext, collection: Collection) => Awaitable<void>;
309
- /**
310
- * Generate files (e.g. types, index file, or JSON schemas)
311
- */
312
- emit?: (this: EmitContext) => Awaitable<EmitEntry[]>;
313
- /**
314
- * Configure Fumadocs dev server
315
- */
316
- configureServer?: (this: PluginContext, server: ServerContext) => Awaitable<void>;
317
- vite?: {
318
- createPlugin?: (this: PluginContext) => Vite.PluginOption;
319
- };
320
- bun?: {
321
- build?: (this: PluginContext, build: Bun.PluginBuilder) => Awaitable<void>;
322
- };
323
- next?: {
324
- config?: (this: PluginContext, config: NextConfig) => NextConfig;
325
- };
326
- node?: {
327
- createLoad?: (this: PluginContext) => Awaitable<LoadHook>;
328
- };
329
- }
330
- type PluginOption = Awaitable<Plugin | PluginOption[] | false | undefined>;
331
- interface ServerContext {
332
- /**
333
- * the file watcher, by default all content files are watched, along with other files.
334
- *
335
- * make sure to filter when listening to events
336
- */
337
- watcher?: FSWatcher;
338
- }
339
- interface CoreOptions {
340
- configPath: string;
341
- outDir: string;
342
- plugins?: PluginOption[];
343
- emit?: {
344
- target?: "default" | "vite";
345
- /**
346
- * add .js extenstion to imports
347
- */
348
- jsExtension?: boolean;
349
- };
350
- /**
351
- * the workspace info if this instance is created as a workspace
352
- */
353
- workspace?: {
354
- parent: Core;
355
- name: string;
356
- dir: string;
357
- };
358
- }
359
- interface EmitOptions {
360
- /**
361
- * filter the plugins to run emit
362
- */
363
- filterPlugin?: (plugin: Plugin) => boolean;
364
- /**
365
- * filter the workspaces to run emit
366
- */
367
- filterWorkspace?: (workspace: string) => boolean;
368
- /**
369
- * write files
370
- */
371
- write?: boolean;
372
- }
373
- interface EmitOutput {
374
- entries: EmitEntry[];
375
- workspaces: Record<string, EmitEntry[]>;
376
- }
377
- declare class Core {
378
- private readonly workspaces;
379
- private readonly options;
380
- private plugins;
381
- private config;
382
- static defaultOptions: {
383
- configPath: string;
384
- outDir: string;
385
- };
386
- /**
387
- * Convenient cache store, reset when config changes.
388
- *
389
- * You can group namespaces in cache key with ":", like `my-plugin:data`
390
- */
391
- readonly cache: Map<string, unknown>;
392
- constructor(options: CoreOptions);
393
- init({ config: newConfig }: {
394
- config: Awaitable<LoadedConfig>;
395
- }): Promise<void>;
396
- getWorkspaces(): Map<string, Core>;
397
- getOptions(): CoreOptions;
398
- getConfig(): LoadedConfig;
399
- /**
400
- * The file path of compiled config file, the file may not exist (e.g. on Vite, or still compiling)
401
- */
402
- getCompiledConfigPath(): string;
403
- getPlugins(workspace?: boolean): Plugin[];
404
- getCollections(workspace?: boolean): Collection[];
405
- getCollection(name: string): Collection | undefined;
406
- getPluginContext(): PluginContext;
407
- initServer(server: ServerContext): Promise<void>;
408
- emit(emitOptions?: EmitOptions): Promise<EmitOutput>;
409
- }
410
-
411
- export { type CollectionHandlers as A, createCollection as B, type CoreOptions as C, defineConfig as D, type ExtractedReference as E, type FileHandlerConfig as F, type GlobalConfig as G, type InitOptions as I, type JSONSchemaOptions as J, type MDXCollection as M, type PluginContext as P, type ServerContext as S, type VersionControlFileData as V, type WorkspaceConfig as W, Core as a, type MetaCollection as b, type Plugin as c, type Collection as d, type EmitEntry as e, type EmitContext as f, type EmitCodeGeneratorContext as g, type PluginOption as h, type EmitOptions as i, type EmitOutput as j, jsonSchema as k, type JSONSchemaHandler as l, type FIleCollectionHandler as m, buildFileHandler as n, type MDXCollectionHandler as o, type MDXCollectionConfig as p, defineMDX as q, type MetaContext as r, type MetaCollectionHandler as s, type MetaCollectionConfig as t, defineMeta as u, git as v, type VersionControlHandler as w, type GitPluginOptions as x, type VersionControlClient as y, type CollectionTypeInfo as z };
@@ -1,7 +0,0 @@
1
- import {
2
- loadConfig
3
- } from "./chunk-LUM7SIZN.js";
4
- import "./chunk-W6HENTK7.js";
5
- export {
6
- loadConfig
7
- };
@@ -1,7 +0,0 @@
1
- import {
2
- createMdxLoader
3
- } from "./chunk-KH5GT2Y5.js";
4
- import "./chunk-VWJKRQZR.js";
5
- export {
6
- createMdxLoader
7
- };
@@ -1,7 +0,0 @@
1
- import {
2
- createMetaLoader
3
- } from "./chunk-RMSV4HP6.js";
4
- import "./chunk-OUJENWQ4.js";
5
- export {
6
- createMetaLoader
7
- };