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
package/dist/bun/index.js CHANGED
@@ -1,37 +1,26 @@
1
- import {
2
- buildConfig
3
- } from "../chunk-W6HENTK7.js";
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";
4
+ import { pathToFileURL } from "node:url";
9
5
 
10
- // src/bun/index.ts
11
- import { pathToFileURL } from "url";
6
+ //#region src/bun/index.ts
12
7
  function createContentPlugin(options = {}) {
13
- const {
14
- outDir = Core.defaultOptions.outDir,
15
- configPath = Core.defaultOptions.configPath
16
- } = options;
17
- return {
18
- name: "fuma-content",
19
- async setup(build) {
20
- const importPath = pathToFileURL(configPath).href;
21
- const core = new Core({
22
- outDir,
23
- configPath
24
- });
25
- await core.init({
26
- config: buildConfig(await import(importPath))
27
- });
28
- const ctx = core.getPluginContext();
29
- for (const plugin of core.getPlugins(true)) {
30
- await plugin.bun?.build?.call(ctx, build);
31
- }
32
- }
33
- };
8
+ const { outDir = Core.defaultOptions.outDir, configPath = Core.defaultOptions.configPath } = options;
9
+ return {
10
+ name: "fuma-content",
11
+ async setup(build) {
12
+ const importPath = pathToFileURL(configPath).href;
13
+ const core = new Core({
14
+ outDir,
15
+ configPath
16
+ });
17
+ await core.init({ config: buildConfig(await import(importPath)) });
18
+ const ctx = core.getPluginContext();
19
+ for (const plugin of core.getPlugins(true)) await plugin.bun?.build?.call(ctx, build);
20
+ }
21
+ };
34
22
  }
35
- export {
36
- createContentPlugin
37
- };
23
+
24
+ //#endregion
25
+ export { createContentPlugin };
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/bun/index.ts"],"sourcesContent":["import type { BunPlugin } from \"bun\";\nimport { buildConfig } from \"@/config/build\";\nimport { pathToFileURL } from \"node:url\";\nimport { type CoreOptions, Core } from \"@/core\";\n\nexport type ContentPluginOptions = Partial<CoreOptions>;\n\nexport function createContentPlugin(\n options: ContentPluginOptions = {},\n): BunPlugin {\n const {\n outDir = Core.defaultOptions.outDir,\n configPath = Core.defaultOptions.configPath,\n } = options;\n\n return {\n name: \"fuma-content\",\n async setup(build) {\n const importPath = pathToFileURL(configPath).href;\n const core = new Core({\n outDir,\n configPath,\n });\n\n await core.init({\n config: buildConfig(await import(importPath)),\n });\n\n const ctx = core.getPluginContext();\n for (const plugin of core.getPlugins(true)) {\n await plugin.bun?.build?.call(ctx, build);\n }\n },\n };\n}\n"],"mappings":";;;;;;AAOA,SAAgB,oBACd,UAAgC,EAAE,EACvB;CACX,MAAM,EACJ,SAAS,KAAK,eAAe,QAC7B,aAAa,KAAK,eAAe,eAC/B;AAEJ,QAAO;EACL,MAAM;EACN,MAAM,MAAM,OAAO;GACjB,MAAM,aAAa,cAAc,WAAW,CAAC;GAC7C,MAAM,OAAO,IAAI,KAAK;IACpB;IACA;IACD,CAAC;AAEF,SAAM,KAAK,KAAK,EACd,QAAQ,YAAY,MAAM,OAAO,YAAY,EAC9C,CAAC;GAEF,MAAM,MAAM,KAAK,kBAAkB;AACnC,QAAK,MAAM,UAAU,KAAK,WAAW,KAAK,CACxC,OAAM,OAAO,KAAK,OAAO,KAAK,KAAK,MAAM;;EAG9C"}
@@ -0,0 +1,35 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { parse } from "node:querystring";
3
+
4
+ //#region src/plugins/with-loader/bun.ts
5
+ function toBun(test = /.+/, loader) {
6
+ function toResult(output) {
7
+ if (!output) return;
8
+ return {
9
+ contents: output.code,
10
+ loader: "js"
11
+ };
12
+ }
13
+ return (build) => {
14
+ build.onLoad({ filter: test }, (args) => {
15
+ const [filePath, query = ""] = args.path.split("?", 2);
16
+ const input = {
17
+ async getSource() {
18
+ return Bun.file(filePath).text();
19
+ },
20
+ query: parse(query),
21
+ filePath,
22
+ development: false,
23
+ compiler: { addDependency() {} }
24
+ };
25
+ if (loader.bun?.load) return loader.bun.load(readFileSync(filePath).toString(), input);
26
+ const result = loader.load(input);
27
+ if (result instanceof Promise) return result.then(toResult);
28
+ return toResult(result);
29
+ });
30
+ };
31
+ }
32
+
33
+ //#endregion
34
+ export { toBun };
35
+ //# sourceMappingURL=bun-QKQnqgIi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bun-QKQnqgIi.js","names":["input: LoaderInput"],"sources":["../src/plugins/with-loader/bun.ts"],"sourcesContent":["import { parse } from \"node:querystring\";\nimport { readFileSync } from \"node:fs\";\nimport type { LoaderInput, Loader, LoaderOutput } from \"@/plugins/with-loader\";\n\nexport function toBun(test: RegExp = /.+/, loader: Loader) {\n function toResult(output: LoaderOutput | null): Bun.OnLoadResult {\n // it errors, treat this as an exception\n if (!output) return;\n\n return {\n contents: output.code,\n loader: \"js\",\n };\n }\n\n return (build: Bun.PluginBuilder): void => {\n // avoid using async here, because it will cause dynamic require() to fail\n build.onLoad({ filter: test }, (args) => {\n const [filePath, query = \"\"] = args.path.split(\"?\", 2);\n const input: LoaderInput = {\n async getSource() {\n return Bun.file(filePath).text();\n },\n query: parse(query),\n filePath,\n development: false,\n compiler: {\n addDependency() {},\n },\n };\n\n if (loader.bun?.load) {\n return loader.bun.load(readFileSync(filePath).toString(), input);\n }\n\n const result = loader.load(input);\n if (result instanceof Promise) {\n return result.then(toResult);\n }\n return toResult(result);\n });\n };\n}\n"],"mappings":";;;;AAIA,SAAgB,MAAM,OAAe,MAAM,QAAgB;CACzD,SAAS,SAAS,QAA+C;AAE/D,MAAI,CAAC,OAAQ;AAEb,SAAO;GACL,UAAU,OAAO;GACjB,QAAQ;GACT;;AAGH,SAAQ,UAAmC;AAEzC,QAAM,OAAO,EAAE,QAAQ,MAAM,GAAG,SAAS;GACvC,MAAM,CAAC,UAAU,QAAQ,MAAM,KAAK,KAAK,MAAM,KAAK,EAAE;GACtD,MAAMA,QAAqB;IACzB,MAAM,YAAY;AAChB,YAAO,IAAI,KAAK,SAAS,CAAC,MAAM;;IAElC,OAAO,MAAM,MAAM;IACnB;IACA,aAAa;IACb,UAAU,EACR,gBAAgB,IACjB;IACF;AAED,OAAI,OAAO,KAAK,KACd,QAAO,OAAO,IAAI,KAAK,aAAa,SAAS,CAAC,UAAU,EAAE,MAAM;GAGlE,MAAM,SAAS,OAAO,KAAK,MAAM;AACjC,OAAI,kBAAkB,QACpB,QAAO,OAAO,KAAK,SAAS;AAE9B,UAAO,SAAS,OAAO;IACvB"}
@@ -0,0 +1,133 @@
1
+ import { t as createCache } from "./async-cache-BM9Yf4Nw.js";
2
+ import path from "node:path";
3
+ import { glob } from "tinyglobby";
4
+
5
+ //#region src/utils/code-generator.ts
6
+ function importInfo() {
7
+ return {
8
+ named: /* @__PURE__ */ new Map(),
9
+ namespaces: /* @__PURE__ */ new Set(),
10
+ isUsed: /* @__PURE__ */ new Set()
11
+ };
12
+ }
13
+ /**
14
+ * Code generator (one instance per file)
15
+ */
16
+ var CodeGenerator = class {
17
+ lines = [];
18
+ globCache;
19
+ importInfos = /* @__PURE__ */ new Map();
20
+ eagerImportId = 0;
21
+ options;
22
+ constructor({ target = "default", jsExtension = false, globCache = /* @__PURE__ */ new Map(), outDir = "" }) {
23
+ this.options = {
24
+ target,
25
+ jsExtension,
26
+ globCache,
27
+ outDir
28
+ };
29
+ this.globCache = createCache(globCache);
30
+ }
31
+ addNamespaceImport(namespace, specifier, types = false) {
32
+ const info = this.importInfos.get(specifier) ?? importInfo();
33
+ this.importInfos.set(specifier, info);
34
+ if (!types) info.isUsed.add(namespace);
35
+ info.namespaces.add(namespace);
36
+ }
37
+ addNamedImport(names, specifier, types = false) {
38
+ const info = this.importInfos.get(specifier) ?? importInfo();
39
+ this.importInfos.set(specifier, info);
40
+ for (const name of names) {
41
+ const [memberName, importName = memberName] = name.split(/\s+as\s+/, 2);
42
+ info.named.set(importName, memberName);
43
+ if (!types) info.isUsed.add(importName);
44
+ }
45
+ }
46
+ push(...insert) {
47
+ this.lines.push(...insert);
48
+ }
49
+ async pushAsync(insert) {
50
+ for (const line of await Promise.all(insert)) {
51
+ if (line === void 0) continue;
52
+ this.lines.push(line);
53
+ }
54
+ }
55
+ async generateGlobImport(patterns, options) {
56
+ if (this.options.target === "vite") return this.generateViteGlobImport(patterns, options);
57
+ return this.generateNodeGlobImport(patterns, options);
58
+ }
59
+ generateViteGlobImport(patterns, { base, ...rest }) {
60
+ patterns = (typeof patterns === "string" ? [patterns] : patterns).map(normalizeViteGlobPath);
61
+ return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify({
62
+ base: normalizeViteGlobPath(path.relative(this.options.outDir, base)),
63
+ ...rest
64
+ }, null, 2)})`;
65
+ }
66
+ async generateNodeGlobImport(patterns, { base, eager = false, query = {}, import: importName }) {
67
+ const files = await this.globCache.cached(JSON.stringify({
68
+ patterns,
69
+ base
70
+ }), () => glob(patterns, { cwd: base }));
71
+ let code = "{";
72
+ for (const item of files) {
73
+ const fullPath = path.join(base, item);
74
+ const searchParams = new URLSearchParams();
75
+ for (const [k, v] of Object.entries(query)) if (v !== void 0) searchParams.set(k, v);
76
+ const importPath = `${this.formatImportPath(fullPath)}?${searchParams.toString()}`;
77
+ if (eager) {
78
+ const name = `__fd_glob_${this.eagerImportId++}`;
79
+ this.lines.unshift(importName ? `import { ${importName} as ${name} } from ${JSON.stringify(importPath)}` : `import * as ${name} from ${JSON.stringify(importPath)}`);
80
+ code += `${JSON.stringify(item)}: ${name}, `;
81
+ } else {
82
+ let line = `${JSON.stringify(item)}: () => import(${JSON.stringify(importPath)})`;
83
+ if (importName) line += `.then(mod => mod.${importName})`;
84
+ code += `${line}, `;
85
+ }
86
+ }
87
+ code += "}";
88
+ return code;
89
+ }
90
+ formatImportPath(file) {
91
+ const ext = path.extname(file);
92
+ let filename;
93
+ if (ext === ".ts") {
94
+ filename = file.substring(0, file.length - ext.length);
95
+ if (this.options.jsExtension) filename += ".js";
96
+ } else filename = file;
97
+ const importPath = slash(path.relative(this.options.outDir, filename));
98
+ return importPath.startsWith(".") ? importPath : `./${importPath}`;
99
+ }
100
+ toString() {
101
+ const final = ["// @ts-nocheck"];
102
+ if (this.options.target === "vite") final.push("/// <reference types=\"vite/client\" />");
103
+ for (const [specifier, info] of this.importInfos) {
104
+ const { namespaces, named, isUsed } = info;
105
+ for (const namespace of namespaces) final.push(isUsed.has(namespace) ? `import * as ${namespace} from "${specifier}";` : `import type * as ${namespace} from "${specifier}";`);
106
+ const namedImports = [];
107
+ for (const [importName, memberName] of named) {
108
+ const item = importName === memberName ? importName : `${memberName} as ${importName}`;
109
+ namedImports.push(isUsed.has(importName) ? item : `type ${item}`);
110
+ }
111
+ if (namedImports.length > 0) final.push(`import { ${namedImports.join(", ")} } from "${specifier}";`);
112
+ }
113
+ final.push(...this.lines);
114
+ return final.join("\n");
115
+ }
116
+ };
117
+ /**
118
+ * convert into POSIX & relative file paths, such that Vite can accept it.
119
+ */
120
+ function normalizeViteGlobPath(file) {
121
+ file = slash(file);
122
+ if (file.startsWith("./")) return file;
123
+ if (file.startsWith("/")) return `.${file}`;
124
+ return `./${file}`;
125
+ }
126
+ function slash(path$1) {
127
+ if (path$1.startsWith("\\\\?\\")) return path$1;
128
+ return path$1.replaceAll("\\", "/");
129
+ }
130
+
131
+ //#endregion
132
+ export { slash as n, CodeGenerator as t };
133
+ //# sourceMappingURL=code-generator-gPtrfZ6Q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-generator-gPtrfZ6Q.js","names":["code: string","filename: string","final: string[]","namedImports: string[]","path"],"sources":["../src/utils/code-generator.ts"],"sourcesContent":["import path from \"node:path\";\nimport { glob } from \"tinyglobby\";\nimport { type AsyncCache, createCache } from \"@/utils/async-cache\";\n\nexport interface GlobImportOptions {\n base: string;\n query?: Record<string, string | undefined>;\n import?: string;\n eager?: boolean;\n}\n\nexport interface CodeGeneratorOptions {\n target: \"default\" | \"vite\";\n outDir: string;\n /**\n * add .js extenstion to imports\n */\n jsExtension: boolean;\n globCache: Map<string, Promise<string[]>>;\n}\n\ninterface ImportInfo {\n // import name -> member name\n named: Map<string, string>;\n namespaces: Set<string>;\n /**\n * a set of import names, the import is type-only if its name is missing in this set.\n */\n isUsed: Set<string>;\n}\n\nfunction importInfo(): ImportInfo {\n return {\n named: new Map(),\n namespaces: new Set(),\n isUsed: new Set(),\n };\n}\n\n/**\n * Code generator (one instance per file)\n */\nexport class CodeGenerator {\n private readonly lines: string[] = [];\n private readonly globCache: AsyncCache<string[]>;\n // specifier -> imported members/info\n private readonly importInfos = new Map<string, ImportInfo>();\n private eagerImportId = 0;\n\n readonly options: CodeGeneratorOptions;\n constructor({\n target = \"default\",\n jsExtension = false,\n globCache = new Map(),\n outDir = \"\",\n }: Partial<CodeGeneratorOptions>) {\n this.options = {\n target,\n jsExtension,\n globCache,\n outDir,\n };\n this.globCache = createCache(globCache);\n }\n\n addNamespaceImport(namespace: string, specifier: string, types = false) {\n const info = this.importInfos.get(specifier) ?? importInfo();\n this.importInfos.set(specifier, info);\n if (!types) info.isUsed.add(namespace);\n info.namespaces.add(namespace);\n }\n\n addNamedImport(names: string[], specifier: string, types = false) {\n const info = this.importInfos.get(specifier) ?? importInfo();\n this.importInfos.set(specifier, info);\n for (const name of names) {\n const [memberName, importName = memberName] = name.split(/\\s+as\\s+/, 2);\n info.named.set(importName, memberName);\n if (!types) info.isUsed.add(importName);\n }\n }\n\n push(...insert: string[]) {\n this.lines.push(...insert);\n }\n\n async pushAsync(insert: Promise<string | undefined>[]) {\n for (const line of await Promise.all(insert)) {\n if (line === undefined) continue;\n\n this.lines.push(line);\n }\n }\n\n async generateGlobImport(\n patterns: string | string[],\n options: GlobImportOptions,\n ): Promise<string> {\n if (this.options.target === \"vite\") {\n return this.generateViteGlobImport(patterns, options);\n }\n\n return this.generateNodeGlobImport(patterns, options);\n }\n\n private generateViteGlobImport(\n patterns: string | string[],\n { base, ...rest }: GlobImportOptions,\n ): string {\n patterns = (typeof patterns === \"string\" ? [patterns] : patterns).map(\n normalizeViteGlobPath,\n );\n\n return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(\n {\n base: normalizeViteGlobPath(path.relative(this.options.outDir, base)),\n ...rest,\n },\n null,\n 2,\n )})`;\n }\n\n private async generateNodeGlobImport(\n patterns: string | string[],\n { base, eager = false, query = {}, import: importName }: GlobImportOptions,\n ): Promise<string> {\n const files = await this.globCache.cached(\n JSON.stringify({ patterns, base }),\n () =>\n glob(patterns, {\n cwd: base,\n }),\n );\n\n let code: string = \"{\";\n for (const item of files) {\n const fullPath = path.join(base, item);\n const searchParams = new URLSearchParams();\n\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined) searchParams.set(k, v);\n }\n\n const importPath = `${this.formatImportPath(fullPath)}?${searchParams.toString()}`;\n if (eager) {\n const name = `__fd_glob_${this.eagerImportId++}`;\n this.lines.unshift(\n importName\n ? `import { ${importName} as ${name} } from ${JSON.stringify(importPath)}`\n : `import * as ${name} from ${JSON.stringify(importPath)}`,\n );\n\n code += `${JSON.stringify(item)}: ${name}, `;\n } else {\n let line = `${JSON.stringify(item)}: () => import(${JSON.stringify(importPath)})`;\n if (importName) {\n line += `.then(mod => mod.${importName})`;\n }\n\n code += `${line}, `;\n }\n }\n\n code += \"}\";\n return code;\n }\n\n formatImportPath(file: string) {\n const ext = path.extname(file);\n let filename: string;\n\n if (ext === \".ts\") {\n filename = file.substring(0, file.length - ext.length);\n if (this.options.jsExtension) filename += \".js\";\n } else {\n filename = file;\n }\n\n const importPath = slash(path.relative(this.options.outDir, filename));\n return importPath.startsWith(\".\") ? importPath : `./${importPath}`;\n }\n\n toString() {\n const final: string[] = [\"// @ts-nocheck\"];\n if (this.options.target === \"vite\") {\n final.push('/// <reference types=\"vite/client\" />');\n }\n\n for (const [specifier, info] of this.importInfos) {\n const { namespaces, named, isUsed } = info;\n for (const namespace of namespaces) {\n final.push(\n isUsed.has(namespace)\n ? `import * as ${namespace} from \"${specifier}\";`\n : `import type * as ${namespace} from \"${specifier}\";`,\n );\n }\n\n const namedImports: string[] = [];\n for (const [importName, memberName] of named) {\n const item =\n importName === memberName\n ? importName\n : `${memberName} as ${importName}`;\n\n namedImports.push(isUsed.has(importName) ? item : `type ${item}`);\n }\n\n if (namedImports.length > 0) {\n final.push(\n `import { ${namedImports.join(\", \")} } from \"${specifier}\";`,\n );\n }\n }\n\n final.push(...this.lines);\n return final.join(\"\\n\");\n }\n}\n\n/**\n * convert into POSIX & relative file paths, such that Vite can accept it.\n */\nfunction normalizeViteGlobPath(file: string) {\n file = slash(file);\n if (file.startsWith(\"./\")) return file;\n if (file.startsWith(\"/\")) return `.${file}`;\n\n return `./${file}`;\n}\n\nexport function slash(path: string): string {\n const isExtendedLengthPath = path.startsWith(\"\\\\\\\\?\\\\\");\n\n if (isExtendedLengthPath) {\n return path;\n }\n\n return path.replaceAll(\"\\\\\", \"/\");\n}\n\nexport function ident(code: string, tab: number = 1) {\n return code\n .split(\"\\n\")\n .map((v) => \" \".repeat(tab) + v)\n .join(\"\\n\");\n}\n"],"mappings":";;;;;AA+BA,SAAS,aAAyB;AAChC,QAAO;EACL,uBAAO,IAAI,KAAK;EAChB,4BAAY,IAAI,KAAK;EACrB,wBAAQ,IAAI,KAAK;EAClB;;;;;AAMH,IAAa,gBAAb,MAA2B;CACzB,AAAiB,QAAkB,EAAE;CACrC,AAAiB;CAEjB,AAAiB,8BAAc,IAAI,KAAyB;CAC5D,AAAQ,gBAAgB;CAExB,AAAS;CACT,YAAY,EACV,SAAS,WACT,cAAc,OACd,4BAAY,IAAI,KAAK,EACrB,SAAS,MACuB;AAChC,OAAK,UAAU;GACb;GACA;GACA;GACA;GACD;AACD,OAAK,YAAY,YAAY,UAAU;;CAGzC,mBAAmB,WAAmB,WAAmB,QAAQ,OAAO;EACtE,MAAM,OAAO,KAAK,YAAY,IAAI,UAAU,IAAI,YAAY;AAC5D,OAAK,YAAY,IAAI,WAAW,KAAK;AACrC,MAAI,CAAC,MAAO,MAAK,OAAO,IAAI,UAAU;AACtC,OAAK,WAAW,IAAI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UAAU,MAC5C,oBAAoB,UAAU,SAAS,UAAU,IACtD;GAGH,MAAMC,eAAyB,EAAE;AACjC,QAAK,MAAM,CAAC,YAAY,eAAe,OAAO;IAC5C,MAAM,OACJ,eAAe,aACX,aACA,GAAG,WAAW,MAAM;AAE1B,iBAAa,KAAK,OAAO,IAAI,WAAW,GAAG,OAAO,QAAQ,OAAO;;AAGnE,OAAI,aAAa,SAAS,EACxB,OAAM,KACJ,YAAY,aAAa,KAAK,KAAK,CAAC,WAAW,UAAU,IAC1D;;AAIL,QAAM,KAAK,GAAG,KAAK,MAAM;AACzB,SAAO,MAAM,KAAK,KAAK;;;;;;AAO3B,SAAS,sBAAsB,MAAc;AAC3C,QAAO,MAAM,KAAK;AAClB,KAAI,KAAK,WAAW,KAAK,CAAE,QAAO;AAClC,KAAI,KAAK,WAAW,IAAI,CAAE,QAAO,IAAI;AAErC,QAAO,KAAK;;AAGd,SAAgB,MAAM,QAAsB;AAG1C,KAF6BC,OAAK,WAAW,UAAU,CAGrD,QAAOA;AAGT,QAAOA,OAAK,WAAW,MAAM,IAAI"}
@@ -1,10 +1,2 @@
1
- export { m as FIleCollectionHandler, F as FileHandlerConfig, n as buildFileHandler } from '../../core-Bo8KaWQz.js';
2
- import 'chokidar';
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';
1
+ import { X as FileHandlerConfig, Y as FIleCollectionHandler, Z as initFileCollection } from "../../core-Bkh-SI_3.js";
2
+ export { FIleCollectionHandler, FileHandlerConfig, initFileCollection };
@@ -1,6 +1,28 @@
1
- import {
2
- buildFileHandler
3
- } from "../../chunk-E4HRKSP4.js";
4
- export {
5
- buildFileHandler
6
- };
1
+ import path from "node:path";
2
+ import picomatch from "picomatch";
3
+
4
+ //#region src/collections/handlers/fs.ts
5
+ function initFileCollection(collection, init, config) {
6
+ const { workspace } = init;
7
+ const { supportedFormats, dir, files } = config;
8
+ const patterns = files ?? (supportedFormats ? [`**/*.{${supportedFormats.join(",")}}`] : [`**/*`]);
9
+ let matcher;
10
+ collection.handlers.fs = {
11
+ patterns,
12
+ dir: workspace ? path.resolve(workspace.dir, dir) : dir,
13
+ isFileSupported(filePath) {
14
+ if (!supportedFormats) return true;
15
+ return supportedFormats.some((format) => filePath.endsWith(`.${format}`));
16
+ },
17
+ hasFile(filePath) {
18
+ if (!this.isFileSupported(filePath)) return false;
19
+ const relativePath = path.relative(this.dir, filePath);
20
+ if (relativePath.startsWith(`..${path.sep}`)) return false;
21
+ return (matcher ??= picomatch(patterns))(relativePath);
22
+ }
23
+ };
24
+ }
25
+
26
+ //#endregion
27
+ export { initFileCollection };
28
+ //# sourceMappingURL=fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.js","names":["matcher: picomatch.Matcher"],"sources":["../../../src/collections/handlers/fs.ts"],"sourcesContent":["import picomatch from \"picomatch\";\nimport path from \"node:path\";\nimport type { Collection, InitOptions } from \"@/collections\";\n\nexport interface FileHandlerConfig {\n /**\n * Directory to scan\n */\n dir: string;\n\n /**\n * what files to include/exclude (glob patterns)\n *\n * Include all files if not specified\n */\n files?: string[];\n\n /**\n * Restrict to a list of file extensions to include, e.g. `['js', 'ts']`.\n */\n supportedFormats?: string[];\n}\n\nexport interface FIleCollectionHandler {\n /**\n * content directory (absolute)\n */\n dir: string;\n hasFile: (filePath: string) => boolean;\n isFileSupported: (filePath: string) => boolean;\n patterns: string[];\n}\n\nexport function initFileCollection(\n collection: Collection,\n init: InitOptions,\n config: FileHandlerConfig,\n) {\n const { workspace } = init;\n const { supportedFormats, dir, files } = config;\n const patterns =\n files ??\n (supportedFormats ? [`**/*.{${supportedFormats.join(\",\")}}`] : [`**/*`]);\n let matcher: picomatch.Matcher;\n\n collection.handlers.fs = {\n patterns,\n dir: workspace ? path.resolve(workspace.dir, dir) : dir,\n isFileSupported(filePath) {\n if (!supportedFormats) return true;\n\n return supportedFormats.some((format) => filePath.endsWith(`.${format}`));\n },\n hasFile(filePath) {\n if (!this.isFileSupported(filePath)) return false;\n\n const relativePath = path.relative(this.dir, filePath);\n if (relativePath.startsWith(`..${path.sep}`)) return false;\n\n return (matcher ??= picomatch(patterns))(relativePath);\n },\n };\n}\n"],"mappings":";;;;AAiCA,SAAgB,mBACd,YACA,MACA,QACA;CACA,MAAM,EAAE,cAAc;CACtB,MAAM,EAAE,kBAAkB,KAAK,UAAU;CACzC,MAAM,WACJ,UACC,mBAAmB,CAAC,SAAS,iBAAiB,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,OAAO;CACzE,IAAIA;AAEJ,YAAW,SAAS,KAAK;EACvB;EACA,KAAK,YAAY,KAAK,QAAQ,UAAU,KAAK,IAAI,GAAG;EACpD,gBAAgB,UAAU;AACxB,OAAI,CAAC,iBAAkB,QAAO;AAE9B,UAAO,iBAAiB,MAAM,WAAW,SAAS,SAAS,IAAI,SAAS,CAAC;;EAE3E,QAAQ,UAAU;AAChB,OAAI,CAAC,KAAK,gBAAgB,SAAS,CAAE,QAAO;GAE5C,MAAM,eAAe,KAAK,SAAS,KAAK,KAAK,SAAS;AACtD,OAAI,aAAa,WAAW,KAAK,KAAK,MAAM,CAAE,QAAO;AAErD,WAAQ,YAAY,UAAU,SAAS,EAAE,aAAa;;EAEzD"}
@@ -1,10 +1,2 @@
1
- export { d as Collection, A as CollectionHandlers, z as CollectionTypeInfo, I as InitOptions, B as createCollection } from '../core-Bo8KaWQz.js';
2
- import 'chokidar';
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';
1
+ import { _ as CollectionTypeInfo, g as CollectionHandlers, h as Collection, v as InitOptions, y as createCollection } from "../core-Bkh-SI_3.js";
2
+ export { Collection, CollectionHandlers, CollectionTypeInfo, InitOptions, createCollection };
@@ -1,6 +1,16 @@
1
- import {
2
- createCollection
3
- } from "../chunk-BTRE6MOX.js";
4
- export {
5
- createCollection
6
- };
1
+ //#region src/collections/index.ts
2
+ function createCollection(info, init) {
3
+ return {
4
+ name: "",
5
+ handlers: {},
6
+ init(options) {
7
+ this.name = options.name;
8
+ init(this, options);
9
+ },
10
+ typeInfo: info
11
+ };
12
+ }
13
+
14
+ //#endregion
15
+ export { createCollection };
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/collections/index.ts"],"sourcesContent":["import type { WorkspaceConfig } from \"@/config\";\nimport type { JSONSchemaHandler } from \"@/plugins/json-schema\";\nimport type { FIleCollectionHandler } from \"@/collections/handlers/fs\";\nimport type { MDXCollectionHandler } from \"@/collections/mdx\";\nimport type { MetaCollectionHandler } from \"@/collections/meta\";\nimport type { VersionControlHandler } from \"@/plugins/git\";\nimport type { PluginOption } from \"@/core\";\n\nexport interface InitOptions {\n name: string;\n workspace?: WorkspaceConfig;\n}\n\nexport interface Collection {\n name: string;\n init?: (options: InitOptions) => void;\n\n readonly handlers: CollectionHandlers;\n\n /**\n * information for the collection type, can be shared for all collections of same type.\n */\n readonly typeInfo: CollectionTypeInfo;\n}\n\nexport interface CollectionTypeInfo {\n /**\n * ID for collection type.\n *\n * @example `my-package:my-collection-type`\n */\n readonly id: string;\n\n /**\n * plugins to register, registered once for each collection type.\n */\n readonly plugins?: PluginOption;\n}\n\nexport interface CollectionHandlers {\n fs?: FIleCollectionHandler;\n mdx?: MDXCollectionHandler;\n meta?: MetaCollectionHandler;\n \"json-schema\"?: JSONSchemaHandler;\n \"version-control\"?: VersionControlHandler;\n}\n\nexport function createCollection(\n info: CollectionTypeInfo,\n init: (collection: Collection, options: InitOptions) => void,\n): Collection {\n return {\n name: \"\",\n handlers: {},\n init(options) {\n this.name = options.name;\n init(this, options);\n },\n typeInfo: info,\n };\n}\n"],"mappings":";AA+CA,SAAgB,iBACd,MACA,MACY;AACZ,QAAO;EACL,MAAM;EACN,UAAU,EAAE;EACZ,KAAK,SAAS;AACZ,QAAK,OAAO,QAAQ;AACpB,QAAK,MAAM,QAAQ;;EAErB,UAAU;EACX"}
@@ -1,17 +1,9 @@
1
- import { LoaderContext } from 'webpack';
2
- import { WebpackLoaderOptions } from '../../plugins/with-loader/webpack.js';
3
- import '../../plugins/with-loader/index.js';
4
- import '../../core-Bo8KaWQz.js';
5
- import 'chokidar';
6
- import '@mdx-js/mdx';
7
- import 'vfile';
8
- import '@standard-schema/spec';
9
- import 'unified';
10
- import 'mdast';
11
- import 'vite';
12
- import 'next';
13
- import 'node:module';
1
+ import "../../core-Bkh-SI_3.js";
2
+ import { WebpackLoaderOptions } from "../../plugins/with-loader/webpack.js";
3
+ import { LoaderContext } from "webpack";
14
4
 
5
+ //#region src/collections/mdx/loader-webpack.d.ts
15
6
  declare function loader(this: LoaderContext<WebpackLoaderOptions>, source: string): Promise<void>;
16
-
7
+ //#endregion
17
8
  export { loader as default };
9
+ //# sourceMappingURL=loader-webpack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader-webpack.d.ts","names":[],"sources":["../../../src/collections/mdx/loader-webpack.ts"],"sourcesContent":[],"mappings":";;;;;iBAY8B,MAAA,OACtB,cAAc,wCAEnB"}
@@ -1,39 +1,26 @@
1
- import {
2
- createMdxLoader
3
- } from "../../chunk-KH5GT2Y5.js";
4
- import {
5
- getCore,
6
- toWebpack
7
- } from "../../chunk-XR5N6ZXJ.js";
8
- import "../../chunk-OUJENWQ4.js";
9
- import {
10
- createDynamicCore
11
- } from "../../chunk-GGL4EF6H.js";
12
- import "../../chunk-VWJKRQZR.js";
13
- import "../../chunk-NRZ4GE5O.js";
14
- import "../../chunk-MT7RY65Y.js";
15
- import "../../chunk-JBZTQ55D.js";
1
+ import "../../code-generator-gPtrfZ6Q.js";
2
+ import "../../core-ZuoVBkeg.js";
3
+ import "../../validation-BOJKRAp5.js";
4
+ import { t as createDynamicCore } from "../../dynamic-B40uAtdo.js";
5
+ import "../../fuma-matter-O4fA6nSx.js";
6
+ import { t as createMdxLoader } from "../../loader-CXnMFuyE.js";
7
+ import { getCore, toWebpack } from "../../plugins/with-loader/webpack.js";
16
8
 
17
- // src/collections/mdx/loader-webpack.ts
18
- var instance;
9
+ //#region src/collections/mdx/loader-webpack.ts
10
+ let instance;
19
11
  async function loader(source) {
20
- const callback = this.async();
21
- const options = this.getOptions();
22
- this.cacheable(true);
23
- this.addDependency(options.absoluteCompiledConfigPath);
24
- if (!instance) {
25
- instance = toWebpack(
26
- createMdxLoader(
27
- createDynamicCore({
28
- core: getCore(options),
29
- buildConfig: false,
30
- mode: options.isDev ? "dev" : "production"
31
- })
32
- )
33
- );
34
- }
35
- await instance.call(this, source, callback);
12
+ const callback = this.async();
13
+ const options = this.getOptions();
14
+ this.cacheable(true);
15
+ this.addDependency(options.absoluteCompiledConfigPath);
16
+ if (!instance) instance = toWebpack(createMdxLoader(createDynamicCore({
17
+ core: getCore(options),
18
+ buildConfig: false,
19
+ mode: options.isDev ? "dev" : "production"
20
+ })));
21
+ await instance.call(this, source, callback);
36
22
  }
37
- export {
38
- loader as default
39
- };
23
+
24
+ //#endregion
25
+ export { loader as default };
26
+ //# sourceMappingURL=loader-webpack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader-webpack.js","names":["instance: WebpackLoader | undefined"],"sources":["../../../src/collections/mdx/loader-webpack.ts"],"sourcesContent":["import type { LoaderContext } from \"webpack\";\nimport { createDynamicCore } from \"@/config/dynamic\";\nimport { createMdxLoader } from \"@/collections/mdx/loader\";\nimport {\n getCore,\n toWebpack,\n type WebpackLoader,\n type WebpackLoaderOptions,\n} from \"@/plugins/with-loader/webpack\";\n\nlet instance: WebpackLoader | undefined;\n\nexport default async function loader(\n this: LoaderContext<WebpackLoaderOptions>,\n source: string,\n): Promise<void> {\n const callback = this.async();\n const options = this.getOptions();\n this.cacheable(true);\n this.addDependency(options.absoluteCompiledConfigPath);\n\n if (!instance) {\n instance = toWebpack(\n createMdxLoader(\n createDynamicCore({\n core: getCore(options),\n buildConfig: false,\n mode: options.isDev ? \"dev\" : \"production\",\n }),\n ),\n );\n }\n\n await instance.call(this, source, callback);\n}\n"],"mappings":";;;;;;;;;AAUA,IAAIA;AAEJ,eAA8B,OAE5B,QACe;CACf,MAAM,WAAW,KAAK,OAAO;CAC7B,MAAM,UAAU,KAAK,YAAY;AACjC,MAAK,UAAU,KAAK;AACpB,MAAK,cAAc,QAAQ,2BAA2B;AAEtD,KAAI,CAAC,SACH,YAAW,UACT,gBACE,kBAAkB;EAChB,MAAM,QAAQ,QAAQ;EACtB,aAAa;EACb,MAAM,QAAQ,QAAQ,QAAQ;EAC/B,CAAC,CACH,CACF;AAGH,OAAM,SAAS,KAAK,MAAM,QAAQ,SAAS"}
@@ -1,40 +1,29 @@
1
- import { ReactNode } from 'react';
2
- import { CompiledMDXProperties } from './runtime.js';
3
- import { GetCollectionConfig } from '../../index.js';
4
- import { M as MDXCollection, E as ExtractedReference, V as VersionControlFileData } from '../../core-Bo8KaWQz.js';
5
- import { SimpleCollectionStore } from '../runtime/store.js';
6
- import '../runtime/file-store.js';
7
- import 'mdx/types';
8
- import 'chokidar';
9
- import '@mdx-js/mdx';
10
- import 'vfile';
11
- import '@standard-schema/spec';
12
- import 'unified';
13
- import 'mdast';
14
- import 'vite';
15
- import 'next';
16
- import 'node:module';
1
+ import { A as MDXCollection, J as ExtractedReference, P as CompiledMDX, S as VersionControlFileData, q as GetCollectionConfig } from "../../core-Bkh-SI_3.js";
2
+ import { n as SimpleCollectionStore } from "../../store-DEjYYF6a.js";
3
+ import { ReactNode } from "react";
17
4
 
5
+ //#region src/utils/async-cache.d.ts
18
6
  interface AsyncCache<V> {
19
- cached: (key: string, fn: () => V | Promise<V>) => V | Promise<V>;
20
- $value: <T>() => AsyncCache<T>;
21
- invalidate: (key: string) => void;
7
+ cached: (key: string, fn: () => V | Promise<V>) => V | Promise<V>;
8
+ $value: <T>() => AsyncCache<T>;
9
+ invalidate: (key: string) => void;
22
10
  }
23
-
24
- interface MDXStoreBrowserData<Frontmatter, CustomData> {
25
- id: string;
26
- preload: () => (CompiledMDXProperties<Frontmatter> & CustomData) | Promise<CompiledMDXProperties<Frontmatter> & CustomData>;
27
- _renderer: StoreRendererData;
11
+ //#endregion
12
+ //#region src/collections/mdx/runtime-browser.d.ts
13
+ interface MDXStoreBrowserData<Frontmatter$1, CustomData$1> {
14
+ id: string;
15
+ preload: () => (CompiledMDX<Frontmatter$1> & CustomData$1) | Promise<CompiledMDX<Frontmatter$1> & CustomData$1>;
16
+ _renderer: StoreRendererData;
28
17
  }
29
18
  interface StoreRendererData {
30
- storeId: string;
31
- renderers: Map<string, {
32
- fn: () => ReactNode;
33
- forceOnDemand: boolean;
34
- }>;
19
+ storeId: string;
20
+ renderers: Map<string, {
21
+ fn: () => ReactNode;
22
+ forceOnDemand: boolean;
23
+ }>;
35
24
  }
36
25
  interface StoreData {
37
- preloaded: AsyncCache<CompiledMDXProperties>;
26
+ preloaded: AsyncCache<CompiledMDX>;
38
27
  }
39
28
  type GetFrontmatter<Config, Name extends string> = GetCollectionConfig<Config, Name> extends MDXCollection<infer _Frontmatter> ? _Frontmatter : never;
40
29
  declare const _internal_data: Map<string, StoreData>;
@@ -42,14 +31,15 @@ declare function mdxStoreBrowser<Config, Name extends string>(name: Name, _input
42
31
  /**
43
32
  * Renders content with `React.lazy`.
44
33
  */
45
- declare function useRenderer<Frontmatter, CustomData>(entry: MDXStoreBrowserData<Frontmatter, CustomData> | undefined, renderFn: (data: CompiledMDXProperties<Frontmatter> & CustomData) => ReactNode): ReactNode;
34
+ declare function useRenderer<Frontmatter$1, CustomData$1>(entry: MDXStoreBrowserData<Frontmatter$1, CustomData$1> | undefined, renderFn: (data: CompiledMDX<Frontmatter$1> & CustomData$1) => ReactNode): ReactNode;
46
35
  declare function $attachCompiled<Add>(): <T>(data: T) => T extends MDXStoreBrowserData<infer Frontmatter, infer CustomData> ? MDXStoreBrowserData<Frontmatter, CustomData & Add> : T;
47
36
  declare function $extractedReferences(): <T>(data: T) => T extends MDXStoreBrowserData<infer Frontmatter, infer CustomData> ? MDXStoreBrowserData<Frontmatter, CustomData & {
48
- /**
49
- * extracted references (e.g. hrefs, paths), useful for analyzing relationships between pages.
50
- */
51
- extractedReferences: ExtractedReference[];
37
+ /**
38
+ * extracted references (e.g. hrefs, paths), useful for analyzing relationships between pages.
39
+ */
40
+ extractedReferences: ExtractedReference[];
52
41
  }> : T;
53
42
  declare function $versionControl(): <T>(data: T) => T extends MDXStoreBrowserData<infer Frontmatter, infer CustomData> ? MDXStoreBrowserData<Frontmatter, CustomData & VersionControlFileData> : T;
54
-
55
- export { $attachCompiled, $extractedReferences, $versionControl, type MDXStoreBrowserData, _internal_data, mdxStoreBrowser, useRenderer };
43
+ //#endregion
44
+ export { $attachCompiled, $extractedReferences, $versionControl, MDXStoreBrowserData, _internal_data, mdxStoreBrowser, useRenderer };
45
+ //# sourceMappingURL=runtime-browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-browser.d.ts","names":[],"sources":["../../../src/utils/async-cache.ts","../../../src/collections/mdx/runtime-browser.ts"],"sourcesContent":[],"mappings":";;;;;UAAiB;kCACiB,IAAI,QAAQ,OAAO,IAAI,QAAQ;mBAC9C,WAAW;;;;;AADQ,UCUrB,mBDVqB,CAAA,aAAA,EAAA,YAAA,CAAA,CAAA;EAAe,EAAA,EAAA,MAAA;EAAY,OAAA,EAAA,GAAA,GAAA,CCa1D,WDb0D,CCa9C,aDb8C,CAAA,GCa/B,YDb+B,CAAA,GCc3D,ODd2D,CCcnD,WDdmD,CCcvC,aDduC,CAAA,GCcxB,YDdwB,CAAA;EAAR,SAAA,ECe5C,iBDf4C;;UCkB/C,iBAAA,CDjBS;EAAU,OAAA,EAAA,MAAA;aCmBhB;cAGG;;EAbC,CAAA,CAAA;;UAmBP,SAAA,CAhBH;EAA2B,SAAA,EAiBrB,UAjBqB,CAiBV,WAjBU,CAAA;;KAoB7B,cAnB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