fuma-content 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/async-cache-C0J_pTbk.js +29 -0
- package/dist/async-cache-C0J_pTbk.js.map +1 -0
- package/dist/bin.d.ts +1 -1
- package/dist/bin.js +21 -14
- package/dist/bin.js.map +1 -0
- package/dist/build-mdx-CSrSOQxF.js +4 -0
- package/dist/build-mdx-DugsQ0sk.js +395 -0
- package/dist/build-mdx-DugsQ0sk.js.map +1 -0
- package/dist/bun/index.d.ts +6 -13
- package/dist/bun/index.d.ts.map +1 -0
- package/dist/bun/index.js +18 -34
- package/dist/bun/index.js.map +1 -0
- package/dist/bun-Br1ReMiq.js +35 -0
- package/dist/bun-Br1ReMiq.js.map +1 -0
- package/dist/code-generator-BvuyL0UO.js +133 -0
- package/dist/code-generator-BvuyL0UO.js.map +1 -0
- package/dist/collections/handlers/fs.d.ts +2 -10
- package/dist/collections/handlers/fs.js +31 -6
- package/dist/collections/handlers/fs.js.map +1 -0
- package/dist/collections/index.d.ts +2 -10
- package/dist/collections/index.js +16 -6
- package/dist/collections/index.js.map +1 -0
- package/dist/collections/mdx/loader-webpack.d.ts +6 -14
- package/dist/collections/mdx/loader-webpack.d.ts.map +1 -0
- package/dist/collections/mdx/loader-webpack.js +23 -36
- package/dist/collections/mdx/loader-webpack.js.map +1 -0
- package/dist/collections/mdx/runtime-browser.d.ts +27 -37
- package/dist/collections/mdx/runtime-browser.d.ts.map +1 -0
- package/dist/collections/mdx/runtime-browser.js +57 -70
- package/dist/collections/mdx/runtime-browser.js.map +1 -0
- package/dist/collections/mdx/runtime-dynamic.d.ts +22 -30
- package/dist/collections/mdx/runtime-dynamic.d.ts.map +1 -0
- package/dist/collections/mdx/runtime-dynamic.js +62 -85
- package/dist/collections/mdx/runtime-dynamic.js.map +1 -0
- package/dist/collections/mdx/runtime.d.ts +31 -52
- package/dist/collections/mdx/runtime.d.ts.map +1 -0
- package/dist/collections/mdx/runtime.js +24 -34
- package/dist/collections/mdx/runtime.js.map +1 -0
- package/dist/collections/mdx.d.ts +2 -10
- package/dist/collections/mdx.js +241 -284
- package/dist/collections/mdx.js.map +1 -0
- package/dist/collections/meta/loader-webpack.d.ts +6 -14
- package/dist/collections/meta/loader-webpack.d.ts.map +1 -0
- package/dist/collections/meta/loader-webpack.js +22 -39
- package/dist/collections/meta/loader-webpack.js.map +1 -0
- package/dist/collections/meta/runtime.d.ts +7 -15
- package/dist/collections/meta/runtime.d.ts.map +1 -0
- package/dist/collections/meta/runtime.js +9 -15
- package/dist/collections/meta/runtime.js.map +1 -0
- package/dist/collections/meta.d.ts +2 -10
- package/dist/collections/meta.js +125 -164
- package/dist/collections/meta.js.map +1 -0
- package/dist/collections/runtime/file-store.d.ts +17 -14
- package/dist/collections/runtime/file-store.d.ts.map +1 -0
- package/dist/collections/runtime/file-store.js +30 -6
- package/dist/collections/runtime/file-store.js.map +1 -0
- package/dist/collections/runtime/store.d.ts +3 -28
- package/dist/collections/runtime/store.js +3 -6
- package/dist/config/index.d.ts +2 -10
- package/dist/config/index.js +6 -5
- package/dist/config/index.js.map +1 -0
- package/dist/core-CRWvbE7W.d.ts +588 -0
- package/dist/core-CRWvbE7W.d.ts.map +1 -0
- package/dist/core-CnZQDCJ1.js +205 -0
- package/dist/core-CnZQDCJ1.js.map +1 -0
- package/dist/dynamic.d.ts +24 -0
- package/dist/dynamic.d.ts.map +1 -0
- package/dist/dynamic.js +28 -0
- package/dist/dynamic.js.map +1 -0
- package/dist/fuma-matter-D3kkMkdj.js +27 -0
- package/dist/fuma-matter-D3kkMkdj.js.map +1 -0
- package/dist/index.d.ts +17 -16
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -8
- package/dist/load-from-file-BctwhOUd.js +3 -0
- package/dist/load-from-file-XiM8eZha.js +37 -0
- package/dist/load-from-file-XiM8eZha.js.map +1 -0
- package/dist/loader-BHMDOncZ.js +4 -0
- package/dist/loader-C7W_Rwj8.js +80 -0
- package/dist/loader-C7W_Rwj8.js.map +1 -0
- package/dist/loader-DLSJPUiO.js +69 -0
- package/dist/loader-DLSJPUiO.js.map +1 -0
- package/dist/loader-DkmGoUvo.js +4 -0
- package/dist/next/index.cjs +457 -554
- package/dist/next/index.d.ts +16 -22
- package/dist/next/index.d.ts.map +1 -0
- package/dist/next/index.js +71 -89
- package/dist/next/index.js.map +1 -0
- package/dist/node/loader.d.ts +4 -2
- package/dist/node/loader.d.ts.map +1 -0
- package/dist/node/loader.js +29 -44
- package/dist/node/loader.js.map +1 -0
- package/dist/node-CVAU22o3.js +31 -0
- package/dist/node-CVAU22o3.js.map +1 -0
- package/dist/pipe-UEMV1mRg.js +31 -0
- package/dist/pipe-UEMV1mRg.js.map +1 -0
- package/dist/plugins/git.d.ts +2 -10
- package/dist/plugins/git.js +57 -65
- package/dist/plugins/git.js.map +1 -0
- package/dist/plugins/json-schema.d.ts +2 -10
- package/dist/plugins/json-schema.js +60 -58
- package/dist/plugins/json-schema.js.map +1 -0
- package/dist/plugins/with-loader/index.d.ts +2 -61
- package/dist/plugins/with-loader/index.js +28 -6
- package/dist/plugins/with-loader/index.js.map +1 -0
- package/dist/plugins/with-loader/webpack.d.ts +10 -18
- package/dist/plugins/with-loader/webpack.d.ts.map +1 -0
- package/dist/plugins/with-loader/webpack.js +43 -12
- package/dist/plugins/with-loader/webpack.js.map +1 -0
- package/dist/store-BtGmZUAC.d.ts +31 -0
- package/dist/store-BtGmZUAC.d.ts.map +1 -0
- package/dist/store-D166MOLw.js +37 -0
- package/dist/store-D166MOLw.js.map +1 -0
- package/dist/validation-BYUzZIfc.js +37 -0
- package/dist/validation-BYUzZIfc.js.map +1 -0
- package/dist/vite/index.d.ts +22 -28
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +44 -53
- package/dist/vite/index.js.map +1 -0
- package/dist/vite-6awgG092.js +33 -0
- package/dist/vite-6awgG092.js.map +1 -0
- package/package.json +47 -42
- package/dist/build-mdx-I4NROXCF.js +0 -8
- package/dist/bun-DMNX4PBC.js +0 -40
- package/dist/chunk-3VQS3KSP.js +0 -39
- package/dist/chunk-BTRE6MOX.js +0 -16
- package/dist/chunk-E4HRKSP4.js +0 -24
- package/dist/chunk-ERBMAQYP.js +0 -33
- package/dist/chunk-GGL4EF6H.js +0 -38
- package/dist/chunk-JBZTQ55D.js +0 -30
- package/dist/chunk-KH5GT2Y5.js +0 -104
- package/dist/chunk-LUM7SIZN.js +0 -40
- package/dist/chunk-MT7RY65Y.js +0 -167
- package/dist/chunk-NRZ4GE5O.js +0 -207
- package/dist/chunk-OQQNA7L7.js +0 -412
- package/dist/chunk-OUJENWQ4.js +0 -45
- package/dist/chunk-RMSV4HP6.js +0 -85
- package/dist/chunk-RXR7OL76.js +0 -37
- package/dist/chunk-VWJKRQZR.js +0 -19
- package/dist/chunk-W6HENTK7.js +0 -44
- package/dist/chunk-XR5N6ZXJ.js +0 -50
- package/dist/core-Bo8KaWQz.d.ts +0 -411
- package/dist/load-from-file-HL2VEY3M.js +0 -7
- package/dist/loader-NFSL6P5I.js +0 -7
- package/dist/loader-T756NSCS.js +0 -7
- package/dist/node-DCMYL4DL.js +0 -34
- package/dist/vite-QCUPZHHB.js +0 -32
|
@@ -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: output.moduleType ?? "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-Br1ReMiq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bun-Br1ReMiq.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: output.moduleType ?? \"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,OAAO,cAAc;GAC9B;;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-C0J_pTbk.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-BvuyL0UO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-generator-BvuyL0UO.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(normalizeViteGlobPath);\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(JSON.stringify({ patterns, base }), () =>\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 = importName === memberName ? importName : `${memberName} as ${importName}`;\n\n namedImports.push(isUsed.has(importName) ? item : `type ${item}`);\n }\n\n if (namedImports.length > 0) {\n final.push(`import { ${namedImports.join(\", \")} } from \"${specifier}\";`);\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,UAAU;;CAGhC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5C,oBAAoB,UAAU,SAAS,UAAU,IACtD;GAGH,MAAMC,eAAyB,EAAE;AACjC,QAAK,MAAM,CAAC,YAAY,eAAe,OAAO;IAC5C,MAAM,OAAO,eAAe,aAAa,aAAa,GAAG,WAAW,MAAM;AAE1E,iBAAa,KAAK,OAAO,IAAI,WAAW,GAAG,OAAO,QAAQ,OAAO;;AAGnE,OAAI,aAAa,SAAS,EACxB,OAAM,KAAK,YAAY,aAAa,KAAK,KAAK,CAAC,WAAW,UAAU,IAAI;;AAI5E,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
|
-
|
|
2
|
-
|
|
3
|
-
import '@mdx-js/mdx';
|
|
4
|
-
import 'vfile';
|
|
5
|
-
import '@standard-schema/spec';
|
|
6
|
-
import 'unified';
|
|
7
|
-
import 'mdast';
|
|
8
|
-
import 'vite';
|
|
9
|
-
import 'next';
|
|
10
|
-
import 'node:module';
|
|
1
|
+
import { $ as FileHandlerConfig, Q as FIleCollectionHandler, et as initFileCollection } from "../../core-CRWvbE7W.js";
|
|
2
|
+
export { FIleCollectionHandler, FileHandlerConfig, initFileCollection };
|
|
@@ -1,6 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 { cwd } = init.core.getOptions();
|
|
7
|
+
const { supportedFormats } = config;
|
|
8
|
+
let matcher;
|
|
9
|
+
collection.handlers.fs = {
|
|
10
|
+
patterns: config.files ?? [supportedFormats ? `**/*.{${supportedFormats.join(",")}}` : `**/*`],
|
|
11
|
+
dir: path.resolve(cwd, config.dir),
|
|
12
|
+
isFileSupported(filePath) {
|
|
13
|
+
if (!supportedFormats) return true;
|
|
14
|
+
return supportedFormats.some((format) => filePath.endsWith(`.${format}`));
|
|
15
|
+
},
|
|
16
|
+
async getFiles() {
|
|
17
|
+
const { glob } = await import("tinyglobby");
|
|
18
|
+
return (await glob(this.patterns, { cwd: this.dir })).filter((v) => this.isFileSupported(v));
|
|
19
|
+
},
|
|
20
|
+
hasFile(filePath) {
|
|
21
|
+
if (!this.isFileSupported(filePath)) return false;
|
|
22
|
+
const relativePath = path.relative(this.dir, filePath);
|
|
23
|
+
if (relativePath.startsWith(`..${path.sep}`)) return false;
|
|
24
|
+
return (matcher ??= picomatch(this.patterns))(relativePath);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { initFileCollection };
|
|
31
|
+
//# 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 /**\n * get all included files, relative to `dir`\n */\n getFiles: () => Promise<string[]>;\n patterns: string[];\n}\n\nexport function initFileCollection(\n collection: Collection,\n init: InitOptions,\n config: FileHandlerConfig,\n) {\n const { cwd } = init.core.getOptions();\n const { supportedFormats } = config;\n let matcher: picomatch.Matcher;\n\n collection.handlers.fs = {\n patterns: config.files ?? [supportedFormats ? `**/*.{${supportedFormats.join(\",\")}}` : `**/*`],\n dir: path.resolve(cwd, config.dir),\n isFileSupported(filePath) {\n if (!supportedFormats) return true;\n\n return supportedFormats.some((format) => filePath.endsWith(`.${format}`));\n },\n async getFiles() {\n const { glob } = await import(\"tinyglobby\");\n return (await glob(this.patterns, { cwd: this.dir })).filter((v) => this.isFileSupported(v));\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(this.patterns))(relativePath);\n },\n };\n}\n"],"mappings":";;;;AAqCA,SAAgB,mBACd,YACA,MACA,QACA;CACA,MAAM,EAAE,QAAQ,KAAK,KAAK,YAAY;CACtC,MAAM,EAAE,qBAAqB;CAC7B,IAAIA;AAEJ,YAAW,SAAS,KAAK;EACvB,UAAU,OAAO,SAAS,CAAC,mBAAmB,SAAS,iBAAiB,KAAK,IAAI,CAAC,KAAK,OAAO;EAC9F,KAAK,KAAK,QAAQ,KAAK,OAAO,IAAI;EAClC,gBAAgB,UAAU;AACxB,OAAI,CAAC,iBAAkB,QAAO;AAE9B,UAAO,iBAAiB,MAAM,WAAW,SAAS,SAAS,IAAI,SAAS,CAAC;;EAE3E,MAAM,WAAW;GACf,MAAM,EAAE,SAAS,MAAM,OAAO;AAC9B,WAAQ,MAAM,KAAK,KAAK,UAAU,EAAE,KAAK,KAAK,KAAK,CAAC,EAAE,QAAQ,MAAM,KAAK,gBAAgB,EAAE,CAAC;;EAE9F,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,KAAK,SAAS,EAAE,aAAa;;EAE9D"}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import '@mdx-js/mdx';
|
|
4
|
-
import 'vfile';
|
|
5
|
-
import '@standard-schema/spec';
|
|
6
|
-
import 'unified';
|
|
7
|
-
import 'mdast';
|
|
8
|
-
import 'vite';
|
|
9
|
-
import 'next';
|
|
10
|
-
import 'node:module';
|
|
1
|
+
import { _ as InitOptions, g as CollectionTypeInfo, h as CollectionHandlers, m as Collection, v as createCollection } from "../core-CRWvbE7W.js";
|
|
2
|
+
export { Collection, CollectionHandlers, CollectionTypeInfo, InitOptions, createCollection };
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 { 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 { Core, PluginOption } from \"@/core\";\n\nexport interface InitOptions {\n name: string;\n core: Core;\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":";AA8CA,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
|
|
2
|
-
import { WebpackLoaderOptions } from
|
|
3
|
-
import
|
|
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-CRWvbE7W.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
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "../../
|
|
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 { createDynamicCore } from "../../dynamic.js";
|
|
2
|
+
import "../../code-generator-BvuyL0UO.js";
|
|
3
|
+
import "../../core-CnZQDCJ1.js";
|
|
4
|
+
import "../../validation-BYUzZIfc.js";
|
|
5
|
+
import "../../fuma-matter-D3kkMkdj.js";
|
|
6
|
+
import { t as createMdxLoader } from "../../loader-C7W_Rwj8.js";
|
|
7
|
+
import { getCore, toWebpack } from "../../plugins/with-loader/webpack.js";
|
|
16
8
|
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
//#region src/collections/mdx/loader-webpack.ts
|
|
10
|
+
let instance;
|
|
19
11
|
async function loader(source) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
38
|
-
|
|
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 \"@/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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 { N as CompiledMDX, Z as ExtractedReference, k as MDXCollection, q as GetCollectionConfig, x as VersionControlFileData } from "../../core-CRWvbE7W.js";
|
|
2
|
+
import { n as SimpleCollectionStore } from "../../store-BtGmZUAC.js";
|
|
3
|
+
import { ReactNode } from "react";
|
|
17
4
|
|
|
5
|
+
//#region src/utils/async-cache.d.ts
|
|
18
6
|
interface AsyncCache<V> {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
storeId: string;
|
|
20
|
+
renderers: Map<string, {
|
|
21
|
+
fn: () => ReactNode;
|
|
22
|
+
forceOnDemand: boolean;
|
|
23
|
+
}>;
|
|
35
24
|
}
|
|
36
25
|
interface StoreData {
|
|
37
|
-
|
|
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:
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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,
|
|
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,W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AAA,GAoFuD,mBApFvD,CAoFuD,WApFvD,EAoFuD,UApFvD,GAAA;EAAQ;;;EAA2B,mBAAA,EA8FhC,kBA9FgC,EAAA;AAIzD,CAAA,CAAA,IAAa;AAEG,iBA4FA,eAAA,CAAA,CA5Fe,EAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EA6EpB,CA7EoB,EAAA,GA6EpB,CA7EoB,SA6EpB,mBA7EoB,CAAA,KAAA,YAAA,EAAA,KAAA,WAAA,CAAA,GA8E8C,mBA9E9C,CA8E8C,WA9E9C,EA8E8C,UA9E9C,GA8E8C,sBA9E9C,CAAA,GA8E8C,CA9E9C"}
|
|
@@ -1,82 +1,69 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
SimpleCollectionStore
|
|
4
|
-
} from "../../chunk-3VQS3KSP.js";
|
|
5
|
-
import {
|
|
6
|
-
createCache
|
|
7
|
-
} from "../../chunk-JBZTQ55D.js";
|
|
8
2
|
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
|
|
3
|
+
import { t as createCache } from "../../async-cache-C0J_pTbk.js";
|
|
4
|
+
import { t as SimpleCollectionStore } from "../../store-D166MOLw.js";
|
|
5
|
+
import { createElement, lazy } from "react";
|
|
6
|
+
|
|
7
|
+
//#region src/collections/mdx/runtime-browser.ts
|
|
8
|
+
const _internal_data = /* @__PURE__ */ new Map();
|
|
12
9
|
function mdxStoreBrowser(name, _input) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
_renderer
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return new SimpleCollectionStore(merged);
|
|
10
|
+
const input = _input;
|
|
11
|
+
const merged = /* @__PURE__ */ new Map();
|
|
12
|
+
function getStoreData() {
|
|
13
|
+
let store = _internal_data.get(name);
|
|
14
|
+
if (store) return store;
|
|
15
|
+
store = { preloaded: createCache() };
|
|
16
|
+
_internal_data.set(name, store);
|
|
17
|
+
return store;
|
|
18
|
+
}
|
|
19
|
+
const _renderer = {
|
|
20
|
+
storeId: name,
|
|
21
|
+
renderers: /* @__PURE__ */ new Map()
|
|
22
|
+
};
|
|
23
|
+
for (const [key, value] of Object.entries(input)) merged.set(key, {
|
|
24
|
+
id: key,
|
|
25
|
+
preload() {
|
|
26
|
+
return getStoreData().preloaded.$value().cached(key, value);
|
|
27
|
+
},
|
|
28
|
+
_renderer
|
|
29
|
+
});
|
|
30
|
+
return new SimpleCollectionStore(merged);
|
|
38
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Renders content with `React.lazy`.
|
|
34
|
+
*/
|
|
39
35
|
function useRenderer(entry, renderFn) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
renderers.set(id, renderer);
|
|
63
|
-
}
|
|
64
|
-
return renderer.fn();
|
|
36
|
+
if (!entry) return null;
|
|
37
|
+
const { id, _renderer: { renderers } } = entry;
|
|
38
|
+
let renderer = renderers.get(id);
|
|
39
|
+
if (!renderer) {
|
|
40
|
+
const OnDemand = lazy(async () => {
|
|
41
|
+
const loaded = await entry.preload();
|
|
42
|
+
return { default: () => renderFn(loaded) };
|
|
43
|
+
});
|
|
44
|
+
renderer = {
|
|
45
|
+
forceOnDemand: false,
|
|
46
|
+
fn() {
|
|
47
|
+
const v = entry.preload();
|
|
48
|
+
if (!(v instanceof Promise) && !this.forceOnDemand) return renderFn(v);
|
|
49
|
+
this.forceOnDemand = true;
|
|
50
|
+
return createElement(OnDemand);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
renderers.set(id, renderer);
|
|
54
|
+
}
|
|
55
|
+
return renderer.fn();
|
|
65
56
|
}
|
|
66
57
|
function $attachCompiled() {
|
|
67
|
-
|
|
58
|
+
return (data) => data;
|
|
68
59
|
}
|
|
69
60
|
function $extractedReferences() {
|
|
70
|
-
|
|
61
|
+
return $attachCompiled();
|
|
71
62
|
}
|
|
72
63
|
function $versionControl() {
|
|
73
|
-
|
|
64
|
+
return $attachCompiled();
|
|
74
65
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
_internal_data,
|
|
80
|
-
mdxStoreBrowser,
|
|
81
|
-
useRenderer
|
|
82
|
-
};
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
export { $attachCompiled, $extractedReferences, $versionControl, _internal_data, mdxStoreBrowser, useRenderer };
|
|
69
|
+
//# sourceMappingURL=runtime-browser.js.map
|