fuma-content 1.0.0 → 1.0.1

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 (49) hide show
  1. package/dist/{build-mdx-Q4RMDWYK.js → build-mdx-I4NROXCF.js} +2 -2
  2. package/dist/bun/index.d.ts +1 -1
  3. package/dist/bun/index.js +4 -3
  4. package/dist/{chunk-LDBQ66H3.js → chunk-GGL4EF6H.js} +1 -1
  5. package/dist/{chunk-6XDQG2GV.js → chunk-JBZTQ55D.js} +14 -1
  6. package/dist/{chunk-PNA5UGSL.js → chunk-KH5GT2Y5.js} +1 -1
  7. package/dist/{chunk-M72VQL5M.js → chunk-LUM7SIZN.js} +1 -1
  8. package/dist/chunk-MT7RY65Y.js +167 -0
  9. package/dist/chunk-NRZ4GE5O.js +207 -0
  10. package/dist/{chunk-AMBGM4OK.js → chunk-OQQNA7L7.js} +1 -1
  11. package/dist/{chunk-IGLM4N4P.js → chunk-W6HENTK7.js} +11 -1
  12. package/dist/{chunk-4RMSJCK2.js → chunk-XR5N6ZXJ.js} +1 -1
  13. package/dist/collections/handlers/fs.d.ts +1 -1
  14. package/dist/collections/index.d.ts +1 -1
  15. package/dist/collections/mdx/loader-webpack.d.ts +1 -1
  16. package/dist/collections/mdx/loader-webpack.js +6 -5
  17. package/dist/collections/mdx/runtime-browser.d.ts +21 -10
  18. package/dist/collections/mdx/runtime-browser.js +29 -21
  19. package/dist/collections/mdx/runtime-dynamic.d.ts +3 -2
  20. package/dist/collections/mdx/runtime-dynamic.js +10 -8
  21. package/dist/collections/mdx/runtime.d.ts +4 -3
  22. package/dist/collections/mdx.d.ts +1 -1
  23. package/dist/collections/mdx.js +14 -10
  24. package/dist/collections/meta/loader-webpack.d.ts +1 -1
  25. package/dist/collections/meta/loader-webpack.js +5 -4
  26. package/dist/collections/meta/runtime.d.ts +1 -1
  27. package/dist/collections/meta.d.ts +1 -1
  28. package/dist/collections/meta.js +6 -2
  29. package/dist/config/index.d.ts +1 -1
  30. package/dist/{core-DxnSmTRe.d.ts → core-Bo8KaWQz.d.ts} +3 -3
  31. package/dist/index.d.ts +5 -3
  32. package/dist/index.js +8 -0
  33. package/dist/load-from-file-HL2VEY3M.js +7 -0
  34. package/dist/{loader-VGDLYG4T.js → loader-NFSL6P5I.js} +1 -1
  35. package/dist/next/index.cjs +25 -2
  36. package/dist/next/index.d.ts +1 -1
  37. package/dist/next/index.js +5 -4
  38. package/dist/node/loader.js +4 -3
  39. package/dist/plugins/git.d.ts +1 -1
  40. package/dist/plugins/git.js +1 -1
  41. package/dist/plugins/json-schema.d.ts +1 -1
  42. package/dist/plugins/with-loader/index.d.ts +1 -1
  43. package/dist/plugins/with-loader/webpack.d.ts +1 -1
  44. package/dist/plugins/with-loader/webpack.js +4 -3
  45. package/dist/vite/index.d.ts +1 -1
  46. package/dist/vite/index.js +5 -4
  47. package/package.json +11 -10
  48. package/dist/chunk-Z7KHD7MS.js +0 -368
  49. package/dist/load-from-file-MLL4WQ5J.js +0 -7
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  buildMDX
3
- } from "./chunk-AMBGM4OK.js";
3
+ } from "./chunk-OQQNA7L7.js";
4
4
  import "./chunk-VWJKRQZR.js";
5
- import "./chunk-6XDQG2GV.js";
5
+ import "./chunk-JBZTQ55D.js";
6
6
  export {
7
7
  buildMDX
8
8
  };
@@ -1,5 +1,5 @@
1
1
  import { BunPlugin } from 'bun';
2
- import { C as CoreOptions } from '../core-DxnSmTRe.js';
2
+ import { C as CoreOptions } from '../core-Bo8KaWQz.js';
3
3
  import 'chokidar';
4
4
  import '@mdx-js/mdx';
5
5
  import 'vfile';
package/dist/bun/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  buildConfig
3
- } from "../chunk-IGLM4N4P.js";
3
+ } from "../chunk-W6HENTK7.js";
4
4
  import {
5
5
  Core
6
- } from "../chunk-Z7KHD7MS.js";
7
- import "../chunk-6XDQG2GV.js";
6
+ } from "../chunk-NRZ4GE5O.js";
7
+ import "../chunk-MT7RY65Y.js";
8
+ import "../chunk-JBZTQ55D.js";
8
9
 
9
10
  // src/bun/index.ts
10
11
  import { pathToFileURL } from "url";
@@ -20,7 +20,7 @@ function createDynamicCore({
20
20
  prev = {
21
21
  hash,
22
22
  init: (async () => {
23
- const { loadConfig } = await import("./load-from-file-MLL4WQ5J.js");
23
+ const { loadConfig } = await import("./load-from-file-HL2VEY3M.js");
24
24
  await core.init({
25
25
  config: loadConfig(core, buildConfig)
26
26
  });
@@ -1,13 +1,26 @@
1
1
  // src/utils/async-cache.ts
2
2
  function createCache(store = /* @__PURE__ */ new Map()) {
3
3
  return {
4
- store,
5
4
  cached(key, fn) {
6
5
  let cached = store.get(key);
7
6
  if (cached) return cached;
8
7
  cached = fn();
8
+ if (cached instanceof Promise) {
9
+ cached = cached.then((out) => {
10
+ if (store.has(key)) {
11
+ store.set(key, out);
12
+ }
13
+ return out;
14
+ });
15
+ }
9
16
  store.set(key, cached);
10
17
  return cached;
18
+ },
19
+ invalidate(key) {
20
+ store.delete(key);
21
+ },
22
+ $value() {
23
+ return this;
11
24
  }
12
25
  };
13
26
  }
@@ -70,7 +70,7 @@ function createMdxLoader({ getCore }) {
70
70
  };
71
71
  }
72
72
  const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
73
- const { buildMDX } = await import("./build-mdx-Q4RMDWYK.js");
73
+ const { buildMDX } = await import("./build-mdx-I4NROXCF.js");
74
74
  const compiled = await buildMDX(core, collection, {
75
75
  isDevelopment,
76
76
  source: "\n".repeat(lineOffset) + matter.content,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildConfig
3
- } from "./chunk-IGLM4N4P.js";
3
+ } from "./chunk-W6HENTK7.js";
4
4
 
5
5
  // src/config/load-from-file.ts
6
6
  import { pathToFileURL } from "url";
@@ -0,0 +1,167 @@
1
+ import {
2
+ createCache
3
+ } from "./chunk-JBZTQ55D.js";
4
+
5
+ // src/utils/code-generator.ts
6
+ import path from "path";
7
+ import { glob } from "tinyglobby";
8
+ function importInfo() {
9
+ return {
10
+ named: /* @__PURE__ */ new Map(),
11
+ namespaces: /* @__PURE__ */ new Set(),
12
+ isUsed: /* @__PURE__ */ new Set()
13
+ };
14
+ }
15
+ var CodeGenerator = class {
16
+ lines = [];
17
+ globCache;
18
+ // specifier -> imported members/info
19
+ importInfos = /* @__PURE__ */ new Map();
20
+ eagerImportId = 0;
21
+ options;
22
+ constructor({
23
+ target = "default",
24
+ jsExtension = false,
25
+ globCache = /* @__PURE__ */ new Map(),
26
+ outDir = ""
27
+ }) {
28
+ this.options = {
29
+ target,
30
+ jsExtension,
31
+ globCache,
32
+ outDir
33
+ };
34
+ this.globCache = createCache(globCache);
35
+ }
36
+ addNamespaceImport(namespace, specifier, types = false) {
37
+ const info = this.importInfos.get(specifier) ?? importInfo();
38
+ this.importInfos.set(specifier, info);
39
+ if (!types) info.isUsed.add(namespace);
40
+ info.namespaces.add(namespace);
41
+ }
42
+ addNamedImport(names, specifier, types = false) {
43
+ const info = this.importInfos.get(specifier) ?? importInfo();
44
+ this.importInfos.set(specifier, info);
45
+ for (const name of names) {
46
+ const [memberName, importName = memberName] = name.split(/\s+as\s+/, 2);
47
+ info.named.set(importName, memberName);
48
+ if (!types) info.isUsed.add(importName);
49
+ }
50
+ }
51
+ push(...insert) {
52
+ this.lines.push(...insert);
53
+ }
54
+ async pushAsync(insert) {
55
+ for (const line of await Promise.all(insert)) {
56
+ if (line === void 0) continue;
57
+ this.lines.push(line);
58
+ }
59
+ }
60
+ async generateGlobImport(patterns, options) {
61
+ if (this.options.target === "vite") {
62
+ return this.generateViteGlobImport(patterns, options);
63
+ }
64
+ return this.generateNodeGlobImport(patterns, options);
65
+ }
66
+ generateViteGlobImport(patterns, { base, ...rest }) {
67
+ patterns = (typeof patterns === "string" ? [patterns] : patterns).map(
68
+ normalizeViteGlobPath
69
+ );
70
+ return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(
71
+ {
72
+ base: normalizeViteGlobPath(path.relative(this.options.outDir, base)),
73
+ ...rest
74
+ },
75
+ null,
76
+ 2
77
+ )})`;
78
+ }
79
+ async generateNodeGlobImport(patterns, { base, eager = false, query = {}, import: importName }) {
80
+ const files = await this.globCache.cached(
81
+ JSON.stringify({ patterns, base }),
82
+ () => glob(patterns, {
83
+ cwd: base
84
+ })
85
+ );
86
+ let code = "{";
87
+ for (const item of files) {
88
+ const fullPath = path.join(base, item);
89
+ const searchParams = new URLSearchParams();
90
+ for (const [k, v] of Object.entries(query)) {
91
+ if (v !== void 0) searchParams.set(k, v);
92
+ }
93
+ const importPath = `${this.formatImportPath(fullPath)}?${searchParams.toString()}`;
94
+ if (eager) {
95
+ const name = `__fd_glob_${this.eagerImportId++}`;
96
+ this.lines.unshift(
97
+ importName ? `import { ${importName} as ${name} } from ${JSON.stringify(importPath)}` : `import * as ${name} from ${JSON.stringify(importPath)}`
98
+ );
99
+ code += `${JSON.stringify(item)}: ${name}, `;
100
+ } else {
101
+ let line = `${JSON.stringify(item)}: () => import(${JSON.stringify(importPath)})`;
102
+ if (importName) {
103
+ line += `.then(mod => mod.${importName})`;
104
+ }
105
+ code += `${line}, `;
106
+ }
107
+ }
108
+ code += "}";
109
+ return code;
110
+ }
111
+ formatImportPath(file) {
112
+ const ext = path.extname(file);
113
+ let filename;
114
+ if (ext === ".ts") {
115
+ filename = file.substring(0, file.length - ext.length);
116
+ if (this.options.jsExtension) filename += ".js";
117
+ } else {
118
+ filename = file;
119
+ }
120
+ const importPath = slash(path.relative(this.options.outDir, filename));
121
+ return importPath.startsWith(".") ? importPath : `./${importPath}`;
122
+ }
123
+ toString() {
124
+ const final = ["// @ts-nocheck"];
125
+ if (this.options.target === "vite") {
126
+ final.push('/// <reference types="vite/client" />');
127
+ }
128
+ for (const [specifier, info] of this.importInfos) {
129
+ const { namespaces, named, isUsed } = info;
130
+ for (const namespace of namespaces) {
131
+ final.push(
132
+ isUsed.has(namespace) ? `import * as ${namespace} from "${specifier}";` : `import type * as ${namespace} from "${specifier}";`
133
+ );
134
+ }
135
+ const namedImports = [];
136
+ for (const [importName, memberName] of named) {
137
+ const item = importName === memberName ? importName : `${memberName} as ${importName}`;
138
+ namedImports.push(isUsed.has(importName) ? item : `type ${item}`);
139
+ }
140
+ if (namedImports.length > 0) {
141
+ final.push(
142
+ `import { ${namedImports.join(", ")} } from "${specifier}";`
143
+ );
144
+ }
145
+ }
146
+ final.push(...this.lines);
147
+ return final.join("\n");
148
+ }
149
+ };
150
+ function normalizeViteGlobPath(file) {
151
+ file = slash(file);
152
+ if (file.startsWith("./")) return file;
153
+ if (file.startsWith("/")) return `.${file}`;
154
+ return `./${file}`;
155
+ }
156
+ function slash(path2) {
157
+ const isExtendedLengthPath = path2.startsWith("\\\\?\\");
158
+ if (isExtendedLengthPath) {
159
+ return path2;
160
+ }
161
+ return path2.replaceAll("\\", "/");
162
+ }
163
+
164
+ export {
165
+ CodeGenerator,
166
+ slash
167
+ };
@@ -0,0 +1,207 @@
1
+ import {
2
+ CodeGenerator
3
+ } from "./chunk-MT7RY65Y.js";
4
+
5
+ // src/core.ts
6
+ import path from "path";
7
+ import fs from "fs/promises";
8
+ async function getPlugins(pluginOptions) {
9
+ const plugins = [];
10
+ for (const option of await Promise.all(pluginOptions)) {
11
+ if (!option) continue;
12
+ if (Array.isArray(option)) plugins.push(...await getPlugins(option));
13
+ else plugins.push(option);
14
+ }
15
+ return plugins;
16
+ }
17
+ var Core = class _Core {
18
+ workspaces = /* @__PURE__ */ new Map();
19
+ options;
20
+ plugins = [];
21
+ config;
22
+ static defaultOptions = {
23
+ configPath: "content.config.ts",
24
+ outDir: ".content"
25
+ };
26
+ /**
27
+ * Convenient cache store, reset when config changes.
28
+ *
29
+ * You can group namespaces in cache key with ":", like `my-plugin:data`
30
+ */
31
+ cache = /* @__PURE__ */ new Map();
32
+ constructor(options) {
33
+ this.options = options;
34
+ }
35
+ async init({ config: newConfig }) {
36
+ this.config = await newConfig;
37
+ this.cache.clear();
38
+ this.workspaces.clear();
39
+ const loadedCollectionTypeIds = /* @__PURE__ */ new Set();
40
+ this.plugins = await getPlugins([
41
+ this.options.plugins,
42
+ this.config.plugins,
43
+ ...this.config.collections.values().map(({ typeInfo }) => {
44
+ if (loadedCollectionTypeIds.has(typeInfo.id)) return false;
45
+ loadedCollectionTypeIds.add(typeInfo.id);
46
+ return typeInfo.plugins;
47
+ })
48
+ ]);
49
+ const ctx = this.getPluginContext();
50
+ for (const plugin of this.plugins) {
51
+ const out = await plugin.config?.call(ctx, this.config);
52
+ if (out) this.config = out;
53
+ }
54
+ const { workspace, outDir } = this.options;
55
+ if (!workspace) {
56
+ await Promise.all(
57
+ Object.entries(this.config.workspaces).map(
58
+ async ([name, workspace2]) => {
59
+ const child = new _Core({
60
+ ...this.options,
61
+ outDir: path.join(outDir, name),
62
+ workspace: {
63
+ name,
64
+ parent: this,
65
+ dir: workspace2.dir
66
+ }
67
+ });
68
+ await child.init({ config: workspace2.config });
69
+ this.workspaces.set(name, child);
70
+ }
71
+ )
72
+ );
73
+ }
74
+ await Promise.all(
75
+ this.config.collections.values().map(async (collection) => {
76
+ for (const plugin of this.plugins) {
77
+ await plugin.collection?.call(ctx, collection);
78
+ }
79
+ })
80
+ );
81
+ }
82
+ getWorkspaces() {
83
+ return this.workspaces;
84
+ }
85
+ getOptions() {
86
+ return this.options;
87
+ }
88
+ getConfig() {
89
+ return this.config;
90
+ }
91
+ /**
92
+ * The file path of compiled config file, the file may not exist (e.g. on Vite, or still compiling)
93
+ */
94
+ getCompiledConfigPath() {
95
+ return path.join(this.options.outDir, "content.config.mjs");
96
+ }
97
+ getPlugins(workspace = false) {
98
+ if (workspace) {
99
+ const plugins = [...this.plugins];
100
+ for (const workspace2 of this.workspaces.values()) {
101
+ plugins.push(...workspace2.plugins);
102
+ }
103
+ return plugins;
104
+ }
105
+ return this.plugins;
106
+ }
107
+ getCollections(workspace = false) {
108
+ const list = Array.from(this.config.collections.values());
109
+ if (workspace) {
110
+ for (const workspace2 of this.workspaces.values()) {
111
+ list.push(...workspace2.getCollections());
112
+ }
113
+ }
114
+ return list;
115
+ }
116
+ getCollection(name) {
117
+ return this.config.collections.get(name);
118
+ }
119
+ getPluginContext() {
120
+ return {
121
+ core: this
122
+ };
123
+ }
124
+ async initServer(server) {
125
+ const ctx = this.getPluginContext();
126
+ const promises = [];
127
+ for (const plugin of this.plugins) {
128
+ promises.push(plugin.configureServer?.call(ctx, server));
129
+ }
130
+ for (const workspace of this.workspaces.values()) {
131
+ promises.push(workspace.initServer(server));
132
+ }
133
+ await Promise.all(promises);
134
+ }
135
+ async emit(emitOptions = {}) {
136
+ const {
137
+ workspace,
138
+ outDir,
139
+ emit: { target, jsExtension } = {}
140
+ } = this.options;
141
+ const { filterPlugin, filterWorkspace, write = false } = emitOptions;
142
+ const start = performance.now();
143
+ const globCache = /* @__PURE__ */ new Map();
144
+ const ctx = {
145
+ ...this.getPluginContext(),
146
+ createCodeGenerator: async (path2, content) => {
147
+ const codegen = new CodeGenerator({
148
+ target,
149
+ outDir,
150
+ jsExtension,
151
+ globCache
152
+ });
153
+ await content({
154
+ core: this,
155
+ codegen,
156
+ workspace: workspace?.name
157
+ });
158
+ return {
159
+ path: path2,
160
+ content: codegen.toString()
161
+ };
162
+ }
163
+ };
164
+ const added = /* @__PURE__ */ new Set();
165
+ const out = {
166
+ entries: [],
167
+ workspaces: {}
168
+ };
169
+ for (const li of await Promise.all(
170
+ this.plugins.map((plugin) => {
171
+ if (filterPlugin && !filterPlugin(plugin) || !plugin.emit)
172
+ return null;
173
+ return plugin.emit.call(ctx);
174
+ })
175
+ )) {
176
+ if (!li) continue;
177
+ for (const item of li) {
178
+ if (added.has(item.path)) continue;
179
+ out.entries.push(item);
180
+ added.add(item.path);
181
+ }
182
+ }
183
+ if (write) {
184
+ await Promise.all(
185
+ out.entries.map(async (entry) => {
186
+ const file = path.join(outDir, entry.path);
187
+ await fs.mkdir(path.dirname(file), { recursive: true });
188
+ await fs.writeFile(file, entry.content);
189
+ })
190
+ );
191
+ console.log(
192
+ workspace ? `[MDX: ${workspace.name}] generated files in ${performance.now() - start}ms` : `[MDX] generated files in ${performance.now() - start}ms`
193
+ );
194
+ }
195
+ await Promise.all(
196
+ this.workspaces.entries().map(async ([name, workspace2]) => {
197
+ if (filterWorkspace && !filterWorkspace(name)) return;
198
+ out.workspaces[name] = (await workspace2.emit(emitOptions)).entries;
199
+ })
200
+ );
201
+ return out;
202
+ }
203
+ };
204
+
205
+ export {
206
+ Core
207
+ };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-VWJKRQZR.js";
4
4
  import {
5
5
  createCache
6
- } from "./chunk-6XDQG2GV.js";
6
+ } from "./chunk-JBZTQ55D.js";
7
7
 
8
8
  // src/collections/mdx/build-mdx.ts
9
9
  import { createProcessor } from "@mdx-js/mdx";
@@ -2,7 +2,17 @@
2
2
  function buildConfig(config, workspace) {
3
3
  const collections = /* @__PURE__ */ new Map();
4
4
  const loaded = {};
5
- const globalConfig = config.default ?? config;
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
+ }
6
16
  if (globalConfig.collections) {
7
17
  for (const [name, collection] of Object.entries(globalConfig.collections)) {
8
18
  collection.init?.({ name, workspace });
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-OUJENWQ4.js";
4
4
  import {
5
5
  Core
6
- } from "./chunk-Z7KHD7MS.js";
6
+ } from "./chunk-NRZ4GE5O.js";
7
7
 
8
8
  // src/plugins/with-loader/webpack.ts
9
9
  import { parse } from "querystring";
@@ -1,4 +1,4 @@
1
- export { m as FIleCollectionHandler, F as FileHandlerConfig, n as buildFileHandler } from '../../core-DxnSmTRe.js';
1
+ export { m as FIleCollectionHandler, F as FileHandlerConfig, n as buildFileHandler } from '../../core-Bo8KaWQz.js';
2
2
  import 'chokidar';
3
3
  import '@mdx-js/mdx';
4
4
  import 'vfile';
@@ -1,4 +1,4 @@
1
- export { y as Collection, A as CollectionHandlers, z as CollectionTypeInfo, I as InitOptions, B as createCollection } from '../core-DxnSmTRe.js';
1
+ export { d as Collection, A as CollectionHandlers, z as CollectionTypeInfo, I as InitOptions, B as createCollection } from '../core-Bo8KaWQz.js';
2
2
  import 'chokidar';
3
3
  import '@mdx-js/mdx';
4
4
  import 'vfile';
@@ -1,7 +1,7 @@
1
1
  import { LoaderContext } from 'webpack';
2
2
  import { WebpackLoaderOptions } from '../../plugins/with-loader/webpack.js';
3
3
  import '../../plugins/with-loader/index.js';
4
- import '../../core-DxnSmTRe.js';
4
+ import '../../core-Bo8KaWQz.js';
5
5
  import 'chokidar';
6
6
  import '@mdx-js/mdx';
7
7
  import 'vfile';
@@ -1,17 +1,18 @@
1
1
  import {
2
2
  createMdxLoader
3
- } from "../../chunk-PNA5UGSL.js";
3
+ } from "../../chunk-KH5GT2Y5.js";
4
4
  import {
5
5
  getCore,
6
6
  toWebpack
7
- } from "../../chunk-4RMSJCK2.js";
7
+ } from "../../chunk-XR5N6ZXJ.js";
8
8
  import "../../chunk-OUJENWQ4.js";
9
9
  import {
10
10
  createDynamicCore
11
- } from "../../chunk-LDBQ66H3.js";
11
+ } from "../../chunk-GGL4EF6H.js";
12
12
  import "../../chunk-VWJKRQZR.js";
13
- import "../../chunk-Z7KHD7MS.js";
14
- import "../../chunk-6XDQG2GV.js";
13
+ import "../../chunk-NRZ4GE5O.js";
14
+ import "../../chunk-MT7RY65Y.js";
15
+ import "../../chunk-JBZTQ55D.js";
15
16
 
16
17
  // src/collections/mdx/loader-webpack.ts
17
18
  var instance;
@@ -1,7 +1,7 @@
1
- import { FC, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { CompiledMDXProperties } from './runtime.js';
3
3
  import { GetCollectionConfig } from '../../index.js';
4
- import { M as MDXCollection, E as ExtractedReference, V as VersionControlFileData } from '../../core-DxnSmTRe.js';
4
+ import { M as MDXCollection, E as ExtractedReference, V as VersionControlFileData } from '../../core-Bo8KaWQz.js';
5
5
  import { SimpleCollectionStore } from '../runtime/store.js';
6
6
  import '../runtime/file-store.js';
7
7
  import 'mdx/types';
@@ -15,19 +15,30 @@ import 'vite';
15
15
  import 'next';
16
16
  import 'node:module';
17
17
 
18
+ interface AsyncCache<V> {
19
+ cached: (key: string, fn: () => V | Promise<V>) => V | Promise<V>;
20
+ $value: <T>() => AsyncCache<T>;
21
+ invalidate: (key: string) => void;
22
+ }
23
+
18
24
  interface MDXStoreBrowserData<Frontmatter, CustomData> {
19
- preload: () => Promise<CompiledMDXProperties<Frontmatter> & CustomData>;
20
- _renderer: {
21
- id: string;
22
- renderers?: Map<string, FC>;
23
- getStoreData: () => StoreData;
24
- };
25
+ id: string;
26
+ preload: () => (CompiledMDXProperties<Frontmatter> & CustomData) | Promise<CompiledMDXProperties<Frontmatter> & CustomData>;
27
+ _renderer: StoreRendererData;
28
+ }
29
+ interface StoreRendererData {
30
+ storeId: string;
31
+ renderers: Map<string, {
32
+ fn: () => ReactNode;
33
+ forceOnDemand: boolean;
34
+ }>;
25
35
  }
26
36
  interface StoreData {
27
- preloaded: Map<string, Promise<CompiledMDXProperties>>;
37
+ preloaded: AsyncCache<CompiledMDXProperties>;
28
38
  }
39
+ type GetFrontmatter<Config, Name extends string> = GetCollectionConfig<Config, Name> extends MDXCollection<infer _Frontmatter> ? _Frontmatter : never;
29
40
  declare const _internal_data: Map<string, StoreData>;
30
- declare function mdxStoreBrowser<Config, Name extends string>(name: Name, _input: Record<string, () => Promise<unknown>>): SimpleCollectionStore<MDXStoreBrowserData<GetCollectionConfig<Config, Name> extends MDXCollection<infer Frontmatter> ? Frontmatter : never, unknown>>;
41
+ declare function mdxStoreBrowser<Config, Name extends string>(name: Name, _input: Record<string, () => Promise<unknown>>): SimpleCollectionStore<MDXStoreBrowserData<GetFrontmatter<Config, Name>, unknown>>;
31
42
  /**
32
43
  * Renders content with `React.lazy`.
33
44
  */