fuma-content 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{async-cache-BM9Yf4Nw.js → async-cache-U87GzQTb.js} +1 -1
- package/dist/async-cache-U87GzQTb.js.map +1 -0
- package/dist/{build-mdx-C1PZsGp2.js → build-mdx-BZxE8t2a.js} +16 -11
- package/dist/build-mdx-BZxE8t2a.js.map +1 -0
- package/dist/build-mdx-LhpFasX-.js +4 -0
- package/dist/bun/index.d.ts +7 -4
- package/dist/bun/index.d.ts.map +1 -1
- package/dist/bun/index.js +25 -19
- package/dist/bun/index.js.map +1 -1
- package/dist/{bun-QKQnqgIi.js → bun-CBROq3I0.js} +3 -3
- package/dist/bun-CBROq3I0.js.map +1 -0
- package/dist/code-generator-CjC4EEXg.js +102 -0
- package/dist/code-generator-CjC4EEXg.js.map +1 -0
- package/dist/collections/data/runtime.d.ts +15 -0
- package/dist/collections/data/runtime.d.ts.map +1 -0
- package/dist/collections/{meta → data}/runtime.js +4 -4
- package/dist/collections/data/runtime.js.map +1 -0
- package/dist/collections/data.d.ts +47 -0
- package/dist/collections/data.d.ts.map +1 -0
- package/dist/collections/data.js +5 -0
- package/dist/collections/fs.d.ts +3 -0
- package/dist/collections/fs.js +3 -0
- package/dist/collections/index.d.ts +2 -2
- package/dist/collections/index.js +2 -15
- package/dist/collections/json/loader-webpack.d.ts +9 -0
- package/dist/collections/json/loader-webpack.d.ts.map +1 -0
- package/dist/collections/json/loader-webpack.js +15 -0
- package/dist/collections/json/loader-webpack.js.map +1 -0
- package/dist/collections/mdx/loader-webpack.d.ts +5 -5
- package/dist/collections/mdx/loader-webpack.d.ts.map +1 -1
- package/dist/collections/mdx/loader-webpack.js +11 -21
- package/dist/collections/mdx/loader-webpack.js.map +1 -1
- package/dist/collections/mdx/react.d.ts +22 -0
- package/dist/collections/mdx/react.d.ts.map +1 -0
- package/dist/collections/mdx/react.js +35 -0
- package/dist/collections/mdx/react.js.map +1 -0
- package/dist/collections/mdx/runtime-browser.d.ts +11 -45
- package/dist/collections/mdx/runtime-browser.js +6 -44
- package/dist/collections/mdx/runtime-browser.js.map +1 -1
- package/dist/collections/mdx/runtime-dynamic.d.ts +16 -28
- package/dist/collections/mdx/runtime-dynamic.d.ts.map +1 -1
- package/dist/collections/mdx/runtime-dynamic.js +19 -23
- package/dist/collections/mdx/runtime-dynamic.js.map +1 -1
- package/dist/collections/mdx/runtime.d.ts +10 -49
- package/dist/collections/mdx/runtime.js +2 -11
- package/dist/collections/mdx/runtime.js.map +1 -1
- package/dist/collections/mdx.d.ts +6 -2
- package/dist/collections/mdx.js +6 -246
- package/dist/collections/runtime/file-store.d.ts +4 -22
- package/dist/collections/runtime/file-store.js +15 -14
- package/dist/collections/runtime/file-store.js.map +1 -1
- package/dist/collections/runtime/store.d.ts +3 -3
- package/dist/collections/runtime/store.js +2 -2
- package/dist/collections/yaml/loader-webpack.d.ts +9 -0
- package/dist/collections/yaml/loader-webpack.d.ts.map +1 -0
- package/dist/collections/yaml/loader-webpack.js +15 -0
- package/dist/collections/yaml/loader-webpack.js.map +1 -0
- package/dist/collections-DNFRdCuB.js +98 -0
- package/dist/collections-DNFRdCuB.js.map +1 -0
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/core-BO3b8jMg.d.ts +313 -0
- package/dist/core-BO3b8jMg.d.ts.map +1 -0
- package/dist/core-D5QHSKk6.js +223 -0
- package/dist/core-D5QHSKk6.js.map +1 -0
- package/dist/data-9h98oZwj.js +158 -0
- package/dist/data-9h98oZwj.js.map +1 -0
- package/dist/dynamic-CTYYdl7_.d.ts +33 -0
- package/dist/dynamic-CTYYdl7_.d.ts.map +1 -0
- package/dist/{dynamic-B40uAtdo.js → dynamic-DhKTOrIl.js} +8 -7
- package/dist/dynamic-DhKTOrIl.js.map +1 -0
- package/dist/dynamic.d.ts +3 -0
- package/dist/dynamic.js +3 -0
- package/dist/file-store-laO4IjvB.d.ts +21 -0
- package/dist/file-store-laO4IjvB.d.ts.map +1 -0
- package/dist/fs-D34Sztbh.d.ts +44 -0
- package/dist/fs-D34Sztbh.d.ts.map +1 -0
- package/dist/fs-WWbLA7Gx.js +66 -0
- package/dist/fs-WWbLA7Gx.js.map +1 -0
- package/dist/{fuma-matter-O4fA6nSx.js → fuma-matter-BuBO2w-p.js} +2 -2
- package/dist/fuma-matter-BuBO2w-p.js.map +1 -0
- package/dist/git-2CjUW3M5.d.ts +37 -0
- package/dist/git-2CjUW3M5.d.ts.map +1 -0
- package/dist/git-CQWA37-X.js +60 -0
- package/dist/git-CQWA37-X.js.map +1 -0
- package/dist/index-Da88Sj8w.d.ts +87 -0
- package/dist/index-Da88Sj8w.d.ts.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- package/dist/load-from-file-BZxc_BhC.js +3 -0
- package/dist/{load-from-file-1f4WaHsf.js → load-from-file-irx0JI6j.js} +5 -8
- package/dist/load-from-file-irx0JI6j.js.map +1 -0
- package/dist/loader-AIEwGc2f.js +9 -0
- package/dist/loader-BhXHF8vy.js +16 -0
- package/dist/loader-BhXHF8vy.js.map +1 -0
- package/dist/loader-BuR4gkKg.js +77 -0
- package/dist/loader-BuR4gkKg.js.map +1 -0
- package/dist/loader-BzQpSBvP.js +59 -0
- package/dist/loader-BzQpSBvP.js.map +1 -0
- package/dist/{loader-CXnMFuyE.js → loader-D6StkShK.js} +8 -7
- package/dist/loader-D6StkShK.js.map +1 -0
- package/dist/loader-DCK4RwOh.js +8 -0
- package/dist/loader-DwpOcxgh.js +17 -0
- package/dist/loader-DwpOcxgh.js.map +1 -0
- package/dist/loader-zsTVgQjO.js +8 -0
- package/dist/mdx-Dt9hirUu.d.ts +144 -0
- package/dist/mdx-Dt9hirUu.d.ts.map +1 -0
- package/dist/mdx-iZ2uP27Z.js +303 -0
- package/dist/mdx-iZ2uP27Z.js.map +1 -0
- package/dist/next/index.d.ts +6 -10
- package/dist/next/index.d.ts.map +1 -1
- package/dist/next/index.js +23 -31
- package/dist/next/index.js.map +1 -1
- package/dist/node/index.d.ts +8 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +10 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/loader.d.ts +5 -2
- package/dist/node/loader.d.ts.map +1 -1
- package/dist/node/loader.js +17 -14
- package/dist/node/loader.js.map +1 -1
- package/dist/{node-CGIIJIcs.js → node-2VZOh3P9.js} +7 -5
- package/dist/node-2VZOh3P9.js.map +1 -0
- package/dist/plugins/git.d.ts +3 -2
- package/dist/plugins/git.js +2 -61
- package/dist/plugins/json-schema.d.ts +26 -2
- package/dist/plugins/json-schema.d.ts.map +1 -0
- package/dist/plugins/json-schema.js +42 -51
- package/dist/plugins/json-schema.js.map +1 -1
- package/dist/plugins/loader/index.d.ts +4 -0
- package/dist/plugins/loader/index.js +3 -0
- package/dist/plugins/loader/webpack.d.ts +4 -0
- package/dist/plugins/loader/webpack.js +60 -0
- package/dist/plugins/loader/webpack.js.map +1 -0
- package/dist/runtime-HN-HSB0Z.d.ts +31 -0
- package/dist/runtime-HN-HSB0Z.d.ts.map +1 -0
- package/dist/runtime-browser-BQEk7qjc.d.ts +29 -0
- package/dist/runtime-browser-BQEk7qjc.d.ts.map +1 -0
- package/dist/store-DiuGdV5M.d.ts +31 -0
- package/dist/store-DiuGdV5M.d.ts.map +1 -0
- package/dist/{store-0LQ2PlH6.js → store-IvpEBdxi.js} +4 -4
- package/dist/store-IvpEBdxi.js.map +1 -0
- package/dist/{validation-BOJKRAp5.js → validation-BvVvvLII.js} +11 -2
- package/dist/validation-BvVvvLII.js.map +1 -0
- package/dist/vite/index.d.ts +5 -15
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +24 -21
- package/dist/vite/index.js.map +1 -1
- package/dist/{vite-X-2Al8fq.js → vite-C1qXY47G.js} +4 -3
- package/dist/vite-C1qXY47G.js.map +1 -0
- package/package.json +51 -46
- package/dist/async-cache-BM9Yf4Nw.js.map +0 -1
- package/dist/build-D8A5ByFk.js +0 -42
- package/dist/build-D8A5ByFk.js.map +0 -1
- package/dist/build-mdx-C1PZsGp2.js.map +0 -1
- package/dist/build-mdx-DFndaVbS.js +0 -4
- package/dist/bun-QKQnqgIi.js.map +0 -1
- package/dist/code-generator-gPtrfZ6Q.js +0 -133
- package/dist/code-generator-gPtrfZ6Q.js.map +0 -1
- package/dist/collections/handlers/fs.d.ts +0 -2
- package/dist/collections/handlers/fs.js +0 -28
- package/dist/collections/handlers/fs.js.map +0 -1
- package/dist/collections/index.js.map +0 -1
- package/dist/collections/mdx/runtime-browser.d.ts.map +0 -1
- package/dist/collections/mdx/runtime.d.ts.map +0 -1
- package/dist/collections/mdx.js.map +0 -1
- package/dist/collections/meta/loader-webpack.d.ts +0 -9
- package/dist/collections/meta/loader-webpack.d.ts.map +0 -1
- package/dist/collections/meta/loader-webpack.js +0 -28
- package/dist/collections/meta/loader-webpack.js.map +0 -1
- package/dist/collections/meta/runtime.d.ts +0 -11
- package/dist/collections/meta/runtime.d.ts.map +0 -1
- package/dist/collections/meta/runtime.js.map +0 -1
- package/dist/collections/meta.d.ts +0 -2
- package/dist/collections/meta.js +0 -134
- package/dist/collections/meta.js.map +0 -1
- package/dist/collections/runtime/file-store.d.ts.map +0 -1
- package/dist/core-Bkh-SI_3.d.ts +0 -561
- package/dist/core-Bkh-SI_3.d.ts.map +0 -1
- package/dist/core-ZuoVBkeg.js +0 -170
- package/dist/core-ZuoVBkeg.js.map +0 -1
- package/dist/dynamic-B40uAtdo.js.map +0 -1
- package/dist/fuma-matter-O4fA6nSx.js.map +0 -1
- package/dist/load-from-file-1f4WaHsf.js.map +0 -1
- package/dist/load-from-file-BTNnBu6f.js +0 -3
- package/dist/loader-80abXEHx.js +0 -4
- package/dist/loader-BFhPyg3z.js +0 -4
- package/dist/loader-CXnMFuyE.js.map +0 -1
- package/dist/loader-gk94iHf5.js +0 -66
- package/dist/loader-gk94iHf5.js.map +0 -1
- package/dist/next/index.cjs +0 -502
- package/dist/node-CGIIJIcs.js.map +0 -1
- package/dist/pipe-5cnvE6KY.js +0 -31
- package/dist/pipe-5cnvE6KY.js.map +0 -1
- package/dist/plugins/git.js.map +0 -1
- package/dist/plugins/with-loader/index.d.ts +0 -2
- package/dist/plugins/with-loader/index.js +0 -28
- package/dist/plugins/with-loader/index.js.map +0 -1
- package/dist/plugins/with-loader/webpack.d.ts +0 -19
- package/dist/plugins/with-loader/webpack.d.ts.map +0 -1
- package/dist/plugins/with-loader/webpack.js +0 -43
- package/dist/plugins/with-loader/webpack.js.map +0 -1
- package/dist/store-0LQ2PlH6.js.map +0 -1
- package/dist/store-DEjYYF6a.d.ts +0 -31
- package/dist/store-DEjYYF6a.d.ts.map +0 -1
- package/dist/validation-BOJKRAp5.js.map +0 -1
- package/dist/vite-X-2Al8fq.js.map +0 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { r as asyncPipe } from "./collections-DNFRdCuB.js";
|
|
2
|
+
import { n as slash } from "./code-generator-CjC4EEXg.js";
|
|
3
|
+
import { t as loaderHook } from "./loader-BuR4gkKg.js";
|
|
4
|
+
import { t as FileSystemCollection } from "./fs-WWbLA7Gx.js";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
|
|
7
|
+
//#region src/collections/data.ts
|
|
8
|
+
var DataCollection = class extends FileSystemCollection {
|
|
9
|
+
schema;
|
|
10
|
+
/**
|
|
11
|
+
* Transform data
|
|
12
|
+
*/
|
|
13
|
+
onLoad = asyncPipe();
|
|
14
|
+
$inferInput = void 0;
|
|
15
|
+
$inferOutput = void 0;
|
|
16
|
+
constructor({ dir, files, loaders: _loadersConfig = {}, schema }) {
|
|
17
|
+
const loadersConfig = { ..._loadersConfig.custom };
|
|
18
|
+
if (_loadersConfig.json !== false) loadersConfig.json = jsonLoader();
|
|
19
|
+
if (_loadersConfig.yaml !== false) loadersConfig.yaml = yamlLoader();
|
|
20
|
+
super({
|
|
21
|
+
dir,
|
|
22
|
+
files,
|
|
23
|
+
supportedFormats: Object.keys(loadersConfig)
|
|
24
|
+
});
|
|
25
|
+
this.schema = schema;
|
|
26
|
+
this.onServer.hook(({ core, server }) => {
|
|
27
|
+
if (!server.watcher) return;
|
|
28
|
+
server.watcher.on("all", async (event, file) => {
|
|
29
|
+
if (event === "change" || !this.hasFile(file)) return;
|
|
30
|
+
await core.emit({
|
|
31
|
+
filterCollection: (collection) => collection === this,
|
|
32
|
+
filterWorkspace: () => false,
|
|
33
|
+
write: true
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
this.onEmit.pipe(async (entries, { createCodeGenerator }) => {
|
|
38
|
+
entries.push(await createCodeGenerator(`${this.name}.ts`, (ctx) => this.generateCollectionStore(ctx)));
|
|
39
|
+
return entries;
|
|
40
|
+
});
|
|
41
|
+
this.pluginHook(loaderHook).loaders.push(...Object.values(loadersConfig));
|
|
42
|
+
}
|
|
43
|
+
async generateCollectionStore(context) {
|
|
44
|
+
const { codegen, core, workspace } = context;
|
|
45
|
+
codegen.addNamedImport(["dataStore"], "fuma-content/collections/data/runtime");
|
|
46
|
+
codegen.addNamespaceImport("Config", codegen.formatImportPath(core.getOptions().configPath), true);
|
|
47
|
+
const base = slash(core._toRuntimePath(this.dir));
|
|
48
|
+
let records = "{";
|
|
49
|
+
const query = codegen.formatQuery({
|
|
50
|
+
collection: this.name,
|
|
51
|
+
workspace
|
|
52
|
+
});
|
|
53
|
+
for (const file of await this.getFiles()) {
|
|
54
|
+
const fullPath = path.join(this.dir, file);
|
|
55
|
+
const specifier = `${codegen.formatImportPath(fullPath)}?${query}`;
|
|
56
|
+
const name = codegen.generateImportName();
|
|
57
|
+
codegen.addNamedImport([`default as ${name}`], specifier);
|
|
58
|
+
records += `"${slash(file)}": ${name},`;
|
|
59
|
+
}
|
|
60
|
+
records += "}";
|
|
61
|
+
codegen.push(`export const ${this.name} = dataStore<typeof Config, "${this.name}">("${this.name}", "${base}", ${records});`);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
function dataCollection(config) {
|
|
65
|
+
return new DataCollection(config);
|
|
66
|
+
}
|
|
67
|
+
function yamlLoader() {
|
|
68
|
+
const test = /\.yaml(\?.+?)?$/;
|
|
69
|
+
return {
|
|
70
|
+
id: "yaml",
|
|
71
|
+
test,
|
|
72
|
+
configureNext(nextConfig) {
|
|
73
|
+
const loaderPath = "fuma-content/collections/yaml/loader-webpack";
|
|
74
|
+
const loaderOptions = this.getLoaderOptions();
|
|
75
|
+
return {
|
|
76
|
+
...nextConfig,
|
|
77
|
+
turbopack: {
|
|
78
|
+
...nextConfig.turbopack,
|
|
79
|
+
rules: {
|
|
80
|
+
...nextConfig.turbopack?.rules,
|
|
81
|
+
"*.yaml": {
|
|
82
|
+
loaders: [{
|
|
83
|
+
loader: loaderPath,
|
|
84
|
+
options: loaderOptions
|
|
85
|
+
}],
|
|
86
|
+
as: "*.js"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
webpack(config, options) {
|
|
91
|
+
config.module ||= {};
|
|
92
|
+
config.module.rules ||= [];
|
|
93
|
+
config.module.rules.push({
|
|
94
|
+
test,
|
|
95
|
+
enforce: "pre",
|
|
96
|
+
use: [{
|
|
97
|
+
loader: loaderPath,
|
|
98
|
+
options: loaderOptions
|
|
99
|
+
}]
|
|
100
|
+
});
|
|
101
|
+
return nextConfig.webpack?.(config, options) ?? config;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
async createLoader() {
|
|
106
|
+
const { createYamlLoader } = await import("./loader-zsTVgQjO.js");
|
|
107
|
+
return createYamlLoader({ getCore: () => this.core });
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function jsonLoader() {
|
|
112
|
+
const test = /\.json(\?.+?)?$/;
|
|
113
|
+
return {
|
|
114
|
+
id: "json",
|
|
115
|
+
test,
|
|
116
|
+
configureNext(nextConfig) {
|
|
117
|
+
const loaderPath = "fuma-content/collections/json/loader-webpack";
|
|
118
|
+
const loaderOptions = this.getLoaderOptions();
|
|
119
|
+
return {
|
|
120
|
+
...nextConfig,
|
|
121
|
+
turbopack: {
|
|
122
|
+
...nextConfig.turbopack,
|
|
123
|
+
rules: {
|
|
124
|
+
...nextConfig.turbopack?.rules,
|
|
125
|
+
"*.json": {
|
|
126
|
+
loaders: [{
|
|
127
|
+
loader: loaderPath,
|
|
128
|
+
options: loaderOptions
|
|
129
|
+
}],
|
|
130
|
+
as: "*.json"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
webpack(config, options) {
|
|
135
|
+
config.module ||= {};
|
|
136
|
+
config.module.rules ||= [];
|
|
137
|
+
config.module.rules.push({
|
|
138
|
+
test,
|
|
139
|
+
enforce: "pre",
|
|
140
|
+
use: [{
|
|
141
|
+
loader: loaderPath,
|
|
142
|
+
options: loaderOptions
|
|
143
|
+
}]
|
|
144
|
+
});
|
|
145
|
+
return nextConfig.webpack?.(config, options) ?? config;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
},
|
|
149
|
+
async createLoader(environment) {
|
|
150
|
+
const { createJsonLoader } = await import("./loader-DCK4RwOh.js");
|
|
151
|
+
return createJsonLoader({ getCore: () => this.core }, environment === "vite" ? "json" : "js");
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
157
|
+
export { yamlLoader as i, dataCollection as n, jsonLoader as r, DataCollection as t };
|
|
158
|
+
//# sourceMappingURL=data-9h98oZwj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-9h98oZwj.js","names":["loadersConfig: Record<string, LoaderConfig>"],"sources":["../src/collections/data.ts"],"sourcesContent":["import type { EmitCodeGeneratorContext } from \"@/core\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { Configuration } from \"webpack\";\nimport { LoaderConfig, loaderHook } from \"@/plugins/loader\";\nimport type { TurbopackLoaderOptions } from \"next/dist/server/config-shared\";\nimport { asyncPipe } from \"@/utils/pipe\";\nimport { slash } from \"@/utils/code-generator\";\nimport { FileSystemCollection, FileSystemCollectionConfig } from \"./fs\";\nimport path from \"node:path\";\n\nexport interface DataTransformationContext {\n path: string;\n source: string;\n}\n\ninterface LoadersConfig {\n json?: boolean;\n yaml?: boolean;\n custom?: Record<string, LoaderConfig>;\n}\n\nexport interface DataCollectionConfig<Schema extends StandardSchemaV1 | undefined> extends Omit<\n FileSystemCollectionConfig,\n \"supportedFormats\"\n> {\n schema?: Schema;\n /**\n * Configurations for loaders to parse data files.\n *\n * By default, JSON and YAML are enabled.\n * */\n loaders?: LoadersConfig;\n}\n\nexport class DataCollection<\n Schema extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined,\n> extends FileSystemCollection {\n schema?: Schema;\n /**\n * Transform data\n */\n readonly onLoad = asyncPipe<unknown, DataTransformationContext>();\n $inferInput: Schema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Schema> : unknown =\n undefined as never;\n $inferOutput: Schema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Schema> : unknown =\n undefined as never;\n\n constructor({ dir, files, loaders: _loadersConfig = {}, schema }: DataCollectionConfig<Schema>) {\n const loadersConfig: Record<string, LoaderConfig> = {\n ..._loadersConfig.custom,\n };\n if (_loadersConfig.json !== false) loadersConfig.json = jsonLoader();\n if (_loadersConfig.yaml !== false) loadersConfig.yaml = yamlLoader();\n\n super({ dir, files, supportedFormats: Object.keys(loadersConfig) });\n this.schema = schema;\n this.onServer.hook(({ core, server }) => {\n if (!server.watcher) return;\n\n server.watcher.on(\"all\", async (event, file) => {\n if (event === \"change\" || !this.hasFile(file)) return;\n\n await core.emit({\n filterCollection: (collection) => collection === this,\n filterWorkspace: () => false,\n write: true,\n });\n });\n });\n this.onEmit.pipe(async (entries, { createCodeGenerator }) => {\n entries.push(\n await createCodeGenerator(`${this.name}.ts`, (ctx) => this.generateCollectionStore(ctx)),\n );\n return entries;\n });\n\n this.pluginHook(loaderHook).loaders.push(...Object.values(loadersConfig));\n }\n\n private async generateCollectionStore(context: EmitCodeGeneratorContext) {\n const { codegen, core, workspace } = context;\n codegen.addNamedImport([\"dataStore\"], \"fuma-content/collections/data/runtime\");\n codegen.addNamespaceImport(\n \"Config\",\n codegen.formatImportPath(core.getOptions().configPath),\n true,\n );\n const base = slash(core._toRuntimePath(this.dir));\n let records = \"{\";\n const query = codegen.formatQuery({\n collection: this.name,\n workspace,\n });\n for (const file of await this.getFiles()) {\n const fullPath = path.join(this.dir, file);\n const specifier = `${codegen.formatImportPath(fullPath)}?${query}`;\n const name = codegen.generateImportName();\n codegen.addNamedImport([`default as ${name}`], specifier);\n records += `\"${slash(file)}\": ${name},`;\n }\n records += \"}\";\n codegen.push(\n `export const ${this.name} = dataStore<typeof Config, \"${this.name}\">(\"${this.name}\", \"${base}\", ${records});`,\n );\n }\n}\n\nexport function dataCollection<Schema extends StandardSchemaV1 | undefined = undefined>(\n config: DataCollectionConfig<Schema>,\n) {\n return new DataCollection(config);\n}\n\nexport function yamlLoader(): LoaderConfig {\n const test = /\\.yaml(\\?.+?)?$/;\n\n return {\n id: \"yaml\",\n test,\n configureNext(nextConfig) {\n const loaderPath = \"fuma-content/collections/yaml/loader-webpack\";\n const loaderOptions = this.getLoaderOptions();\n\n return {\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n rules: {\n ...nextConfig.turbopack?.rules,\n \"*.yaml\": {\n loaders: [\n {\n loader: loaderPath,\n options: loaderOptions as unknown as TurbopackLoaderOptions,\n },\n ],\n as: \"*.js\",\n },\n },\n },\n webpack(config: Configuration, options) {\n config.module ||= {};\n config.module.rules ||= [];\n config.module.rules.push({\n test,\n enforce: \"pre\",\n use: [\n {\n loader: loaderPath,\n options: loaderOptions,\n },\n ],\n });\n\n return nextConfig.webpack?.(config, options) ?? config;\n },\n };\n },\n async createLoader() {\n const { createYamlLoader } = await import(\"./yaml/loader\");\n return createYamlLoader({\n getCore: () => this.core,\n });\n },\n };\n}\n\nexport function jsonLoader(): LoaderConfig {\n const test = /\\.json(\\?.+?)?$/;\n\n return {\n id: \"json\",\n test,\n configureNext(nextConfig) {\n const loaderPath = \"fuma-content/collections/json/loader-webpack\";\n const loaderOptions = this.getLoaderOptions();\n\n return {\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n rules: {\n ...nextConfig.turbopack?.rules,\n \"*.json\": {\n loaders: [\n {\n loader: loaderPath,\n options: loaderOptions as unknown as TurbopackLoaderOptions,\n },\n ],\n as: \"*.json\",\n },\n },\n },\n webpack(config: Configuration, options) {\n config.module ||= {};\n config.module.rules ||= [];\n config.module.rules.push({\n test,\n enforce: \"pre\",\n use: [\n {\n loader: loaderPath,\n options: loaderOptions,\n },\n ],\n });\n\n return nextConfig.webpack?.(config, options) ?? config;\n },\n };\n },\n async createLoader(environment) {\n const { createJsonLoader } = await import(\"./json/loader\");\n return createJsonLoader(\n {\n getCore: () => this.core,\n },\n environment === \"vite\" ? \"json\" : \"js\",\n );\n },\n };\n}\n"],"mappings":";;;;;;;AAkCA,IAAa,iBAAb,cAEU,qBAAqB;CAC7B;;;;CAIA,AAAS,SAAS,WAA+C;CACjE,cACE;CACF,eACE;CAEF,YAAY,EAAE,KAAK,OAAO,SAAS,iBAAiB,EAAE,EAAE,UAAwC;EAC9F,MAAMA,gBAA8C,EAClD,GAAG,eAAe,QACnB;AACD,MAAI,eAAe,SAAS,MAAO,eAAc,OAAO,YAAY;AACpE,MAAI,eAAe,SAAS,MAAO,eAAc,OAAO,YAAY;AAEpE,QAAM;GAAE;GAAK;GAAO,kBAAkB,OAAO,KAAK,cAAc;GAAE,CAAC;AACnE,OAAK,SAAS;AACd,OAAK,SAAS,MAAM,EAAE,MAAM,aAAa;AACvC,OAAI,CAAC,OAAO,QAAS;AAErB,UAAO,QAAQ,GAAG,OAAO,OAAO,OAAO,SAAS;A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,UAAO,iBACL,EACE,eAAe,KAAK,MACrB,EACD,gBAAgB,SAAS,SAAS,KACnC;;EAEJ"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { t as Core } from "./core-BO3b8jMg.js";
|
|
2
|
+
|
|
3
|
+
//#region src/config/load-from-file.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* - `true`: compile the config before loading.
|
|
7
|
+
* - `false`: import the config directly (without compiling it).
|
|
8
|
+
* - `skip`: assume the config is already compiled.
|
|
9
|
+
*/
|
|
10
|
+
type CompileMode = boolean | "skip";
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/dynamic.d.ts
|
|
13
|
+
interface DynamicCore {
|
|
14
|
+
getCore(): Core | Promise<Core>;
|
|
15
|
+
}
|
|
16
|
+
declare function createDynamicCore({
|
|
17
|
+
core,
|
|
18
|
+
compileMode,
|
|
19
|
+
mode
|
|
20
|
+
}: {
|
|
21
|
+
/**
|
|
22
|
+
* core (not initialized)
|
|
23
|
+
*/
|
|
24
|
+
core: Core;
|
|
25
|
+
compileMode?: CompileMode;
|
|
26
|
+
/**
|
|
27
|
+
* In dev mode, the config file is dynamically re-loaded when it's updated.
|
|
28
|
+
*/
|
|
29
|
+
mode: "dev" | "production";
|
|
30
|
+
}): DynamicCore;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { createDynamicCore as n, DynamicCore as t };
|
|
33
|
+
//# sourceMappingURL=dynamic-CTYYdl7_.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-CTYYdl7_.d.ts","names":[],"sources":["../src/config/load-from-file.ts","../src/dynamic.ts"],"sourcesContent":[],"mappings":";;;;;;AAQA;;;KAAY,WAAA;;;UCJK,WAAA;EDIL,OAAA,EAAA,ECHC,IDGU,GCHH,ODGG,CCHK,IDGL,CAAA;;iBCAP,iBAAA;;;;;;AAJhB;;EAC4B,IAAA,EAWpB,IAXoB;EAAR,WAAA,CAAA,EAYJ,WAZI;EAAO;AAG3B;;EAEE,IAAA,EAAA,KAAA,GAAA,YAAA;CACA,CAAA,EAWE,WAXF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
4
|
-
function createDynamicCore({ core,
|
|
3
|
+
//#region src/dynamic.ts
|
|
4
|
+
function createDynamicCore({ core, compileMode = true, mode }) {
|
|
5
5
|
let prev;
|
|
6
6
|
async function getConfigHash() {
|
|
7
7
|
if (mode === "production") return "static";
|
|
@@ -9,14 +9,15 @@ function createDynamicCore({ core, buildConfig, mode }) {
|
|
|
9
9
|
throw new Error("Cannot find config file");
|
|
10
10
|
})).mtime.getTime().toString();
|
|
11
11
|
}
|
|
12
|
+
async function init() {
|
|
13
|
+
const { loadConfig } = await import("./load-from-file-BZxc_BhC.js");
|
|
14
|
+
await core.init({ config: loadConfig(core, compileMode) });
|
|
15
|
+
}
|
|
12
16
|
return { async getCore() {
|
|
13
17
|
const hash = await getConfigHash();
|
|
14
18
|
if (!prev || hash !== prev.hash) prev = {
|
|
15
19
|
hash,
|
|
16
|
-
init: (
|
|
17
|
-
const { loadConfig } = await import("./load-from-file-BTNnBu6f.js");
|
|
18
|
-
await core.init({ config: loadConfig(core, buildConfig) });
|
|
19
|
-
})()
|
|
20
|
+
init: init()
|
|
20
21
|
};
|
|
21
22
|
await prev.init;
|
|
22
23
|
return core;
|
|
@@ -25,4 +26,4 @@ function createDynamicCore({ core, buildConfig, mode }) {
|
|
|
25
26
|
|
|
26
27
|
//#endregion
|
|
27
28
|
export { createDynamicCore as t };
|
|
28
|
-
//# sourceMappingURL=dynamic-
|
|
29
|
+
//# sourceMappingURL=dynamic-DhKTOrIl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-DhKTOrIl.js","names":["prev:\n | {\n hash: string;\n init: Promise<void>;\n }\n | undefined"],"sources":["../src/dynamic.ts"],"sourcesContent":["import type { Core } from \"@/core\";\nimport fs from \"node:fs/promises\";\nimport type { CompileMode } from \"./config/load-from-file\";\n\nexport interface DynamicCore {\n getCore(): Core | Promise<Core>;\n}\n\nexport function createDynamicCore({\n core,\n compileMode = true,\n mode,\n}: {\n /**\n * core (not initialized)\n */\n core: Core;\n compileMode?: CompileMode;\n /**\n * In dev mode, the config file is dynamically re-loaded when it's updated.\n */\n mode: \"dev\" | \"production\";\n}): DynamicCore {\n let prev:\n | {\n hash: string;\n init: Promise<void>;\n }\n | undefined;\n\n async function getConfigHash(): Promise<string> {\n if (mode === \"production\") return \"static\";\n\n const stats = await fs.stat(core.getOptions().configPath).catch(() => {\n throw new Error(\"Cannot find config file\");\n });\n\n return stats.mtime.getTime().toString();\n }\n\n async function init() {\n const { loadConfig } = await import(\"./config/load-from-file\");\n await core.init({\n config: loadConfig(core, compileMode),\n });\n }\n\n return {\n async getCore() {\n const hash = await getConfigHash();\n if (!prev || hash !== prev.hash) {\n prev = {\n hash,\n init: init(),\n };\n }\n\n await prev.init;\n return core;\n },\n };\n}\n"],"mappings":";;;AAQA,SAAgB,kBAAkB,EAChC,MACA,cAAc,MACd,QAWc;CACd,IAAIA;CAOJ,eAAe,gBAAiC;AAC9C,MAAI,SAAS,aAAc,QAAO;AAMlC,UAJc,MAAM,GAAG,KAAK,KAAK,YAAY,CAAC,WAAW,CAAC,YAAY;AACpE,SAAM,IAAI,MAAM,0BAA0B;IAC1C,EAEW,MAAM,SAAS,CAAC,UAAU;;CAGzC,eAAe,OAAO;EACpB,MAAM,EAAE,eAAe,MAAM,OAAO;AACpC,QAAM,KAAK,KAAK,EACd,QAAQ,WAAW,MAAM,YAAY,EACtC,CAAC;;AAGJ,QAAO,EACL,MAAM,UAAU;EACd,MAAM,OAAO,MAAM,eAAe;AAClC,MAAI,CAAC,QAAQ,SAAS,KAAK,KACzB,QAAO;GACL;GACA,MAAM,MAAM;GACb;AAGH,QAAM,KAAK;AACX,SAAO;IAEV"}
|
package/dist/dynamic.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { n as MapCollectionStore } from "./store-DiuGdV5M.js";
|
|
2
|
+
|
|
3
|
+
//#region src/collections/runtime/file-store.d.ts
|
|
4
|
+
interface FileInfo {
|
|
5
|
+
/**
|
|
6
|
+
* path relative to content directory
|
|
7
|
+
*/
|
|
8
|
+
path: string;
|
|
9
|
+
/**
|
|
10
|
+
* the full file path in file system
|
|
11
|
+
*/
|
|
12
|
+
fullPath: string;
|
|
13
|
+
}
|
|
14
|
+
declare class FileCollectionStore<V> extends MapCollectionStore<string, FileInfo & V> {
|
|
15
|
+
constructor(base: string, glob: Record<string, V>);
|
|
16
|
+
transform<T>(fn: (input: FileInfo & V) => FileInfo & T): FileCollectionStore<T>;
|
|
17
|
+
castData<T>(_cast: (input: FileInfo & V) => FileInfo & T): FileCollectionStore<T>;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { FileInfo as n, FileCollectionStore as t };
|
|
21
|
+
//# sourceMappingURL=file-store-laO4IjvB.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-store-laO4IjvB.d.ts","names":[],"sources":["../src/collections/runtime/file-store.ts"],"sourcesContent":[],"mappings":";;;UAGiB,QAAA;;AAAjB;AAoBA;EAAuE,IAAA,EAAA,MAAA;EAAW;;;EAcvD,QAAA,EAAA,MAAA;;AAAiB,cAd/B,mBAc+B,CAAA,CAAA,CAAA,SAdA,kBAcA,CAAA,MAAA,EAd2B,QAc3B,GAdsC,CActC,CAAA,CAAA;EAAW,WAAA,CAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAbrB,MAaqB,CAAA,MAAA,EAbN,CAaM,CAAA;EAAwB,SAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,KAAA,EAApD,QAAoD,GAAzC,CAAyC,EAAA,GAAnC,QAAmC,GAAxB,CAAwB,CAAA,EAApB,mBAAoB,CAAA,CAAA,CAAA;EAApB,QAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EAAA,CAAA,KAAA,EAI9B,QAJ8B,GAInB,CAJmB,EAAA,GAIb,QAJa,GAIF,CAJE,CAAA,EAIE,mBAJF,CAIsB,CAJtB,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { m as Collection } from "./core-BO3b8jMg.js";
|
|
2
|
+
|
|
3
|
+
//#region src/collections/fs.d.ts
|
|
4
|
+
declare class FileSystemCollection extends Collection {
|
|
5
|
+
private matcher;
|
|
6
|
+
/**
|
|
7
|
+
* content directory (absolute)
|
|
8
|
+
*/
|
|
9
|
+
dir: string;
|
|
10
|
+
private readonly config;
|
|
11
|
+
private readonly filesCache;
|
|
12
|
+
constructor(config: FileSystemCollectionConfig);
|
|
13
|
+
isFileSupported(filePath: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* get all included files, relative to `dir`.
|
|
16
|
+
*
|
|
17
|
+
* the result is cached.
|
|
18
|
+
*/
|
|
19
|
+
getFiles(): Promise<string[]>;
|
|
20
|
+
hasFile(filePath: string): boolean;
|
|
21
|
+
/** get glob patterns to match files in collection, this doesn't take `supportedFormats` into account. */
|
|
22
|
+
getPatterns(): string[];
|
|
23
|
+
invalidateCache(): void;
|
|
24
|
+
}
|
|
25
|
+
interface FileSystemCollectionConfig {
|
|
26
|
+
/**
|
|
27
|
+
* Directory to scan
|
|
28
|
+
*/
|
|
29
|
+
dir: string;
|
|
30
|
+
/**
|
|
31
|
+
* what files to include/exclude (glob patterns)
|
|
32
|
+
*
|
|
33
|
+
* Include all files if not specified
|
|
34
|
+
*/
|
|
35
|
+
files?: string[];
|
|
36
|
+
/**
|
|
37
|
+
* Restrict to a list of file extensions to include, e.g. `['js', 'ts']`.
|
|
38
|
+
*/
|
|
39
|
+
supportedFormats?: string[];
|
|
40
|
+
}
|
|
41
|
+
declare function fileSystemCollection(config: FileSystemCollectionConfig): FileSystemCollection;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { FileSystemCollectionConfig as n, fileSystemCollection as r, FileSystemCollection as t };
|
|
44
|
+
//# sourceMappingURL=fs-D34Sztbh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-D34Sztbh.d.ts","names":[],"sources":["../src/collections/fs.ts"],"sourcesContent":[],"mappings":";;;cAKa,oBAAA,SAA6B,UAAA;;EAA7B;;;EAA6B,GAAA,EAAA,MAAA;EAAU,iBAAA,MAAA;EAiEnC,iBAAA,UAAA;EAmBD,WAAA,CAAA,MAAA,EA3EM,0BA2EuB;;;;;;;cAhD7B;;;;;;UA6BC,0BAAA;;;;;;;;;;;;;;;;iBAmBD,oBAAA,SAA6B,6BAA0B"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { t as Collection } from "./collections-DNFRdCuB.js";
|
|
2
|
+
import { t as createCache } from "./async-cache-U87GzQTb.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import picomatch from "picomatch";
|
|
5
|
+
|
|
6
|
+
//#region src/collections/fs.ts
|
|
7
|
+
var FileSystemCollection = class extends Collection {
|
|
8
|
+
matcher;
|
|
9
|
+
/**
|
|
10
|
+
* content directory (absolute)
|
|
11
|
+
*/
|
|
12
|
+
dir = null;
|
|
13
|
+
config;
|
|
14
|
+
filesCache = createCache();
|
|
15
|
+
constructor(config) {
|
|
16
|
+
super();
|
|
17
|
+
this.config = config;
|
|
18
|
+
this.onInit.hook(({ core }) => {
|
|
19
|
+
this.dir = path.resolve(core.getOptions().cwd, config.dir);
|
|
20
|
+
});
|
|
21
|
+
this.onServer.hook(({ server }) => {
|
|
22
|
+
server.watcher?.add(this.dir);
|
|
23
|
+
server.watcher?.on("all", (event, file) => {
|
|
24
|
+
if (event === "change" || !this.hasFile(file)) return;
|
|
25
|
+
this.filesCache.invalidate("");
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
isFileSupported(filePath) {
|
|
30
|
+
const { supportedFormats } = this.config;
|
|
31
|
+
if (!supportedFormats) return true;
|
|
32
|
+
return supportedFormats.some((format) => filePath.endsWith(`.${format}`));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* get all included files, relative to `dir`.
|
|
36
|
+
*
|
|
37
|
+
* the result is cached.
|
|
38
|
+
*/
|
|
39
|
+
async getFiles() {
|
|
40
|
+
return this.filesCache.cached("", async () => {
|
|
41
|
+
const { glob } = await import("tinyglobby");
|
|
42
|
+
return (await glob(this.getPatterns(), { cwd: this.dir })).filter((v) => this.isFileSupported(v));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
hasFile(filePath) {
|
|
46
|
+
if (!this.isFileSupported(filePath)) return false;
|
|
47
|
+
const relativePath = path.relative(this.dir, filePath);
|
|
48
|
+
if (relativePath.startsWith(`..${path.sep}`)) return false;
|
|
49
|
+
return (this.matcher ??= picomatch(this.getPatterns()))(relativePath);
|
|
50
|
+
}
|
|
51
|
+
/** get glob patterns to match files in collection, this doesn't take `supportedFormats` into account. */
|
|
52
|
+
getPatterns() {
|
|
53
|
+
const { files, supportedFormats } = this.config;
|
|
54
|
+
return files ?? [supportedFormats ? `**/*.{${supportedFormats.join(",")}}` : `**/*`];
|
|
55
|
+
}
|
|
56
|
+
invalidateCache() {
|
|
57
|
+
this.filesCache.invalidate("");
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
function fileSystemCollection(config) {
|
|
61
|
+
return new FileSystemCollection(config);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { fileSystemCollection as n, FileSystemCollection as t };
|
|
66
|
+
//# sourceMappingURL=fs-WWbLA7Gx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-WWbLA7Gx.js","names":[],"sources":["../src/collections/fs.ts"],"sourcesContent":["import picomatch from \"picomatch\";\nimport path from \"node:path\";\nimport { Collection } from \".\";\nimport { createCache } from \"@/utils/async-cache\";\n\nexport class FileSystemCollection extends Collection {\n private matcher: picomatch.Matcher | undefined;\n /**\n * content directory (absolute)\n */\n dir = null as unknown as string;\n private readonly config: FileSystemCollectionConfig;\n private readonly filesCache = createCache<string[]>();\n\n constructor(config: FileSystemCollectionConfig) {\n super();\n this.config = config;\n this.onInit.hook(({ core }) => {\n this.dir = path.resolve(core.getOptions().cwd, config.dir);\n });\n this.onServer.hook(({ server }) => {\n server.watcher?.add(this.dir);\n server.watcher?.on(\"all\", (event, file) => {\n if (event === \"change\" || !this.hasFile(file)) return;\n this.filesCache.invalidate(\"\");\n });\n });\n }\n\n isFileSupported(filePath: string) {\n const { supportedFormats } = this.config;\n if (!supportedFormats) return true;\n\n return supportedFormats.some((format) => filePath.endsWith(`.${format}`));\n }\n\n /**\n * get all included files, relative to `dir`.\n *\n * the result is cached.\n */\n async getFiles() {\n return this.filesCache.cached(\"\", async () => {\n const { glob } = await import(\"tinyglobby\");\n\n const out = await glob(this.getPatterns(), { cwd: this.dir });\n return out.filter((v) => this.isFileSupported(v));\n });\n }\n\n hasFile(filePath: string) {\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 (this.matcher ??= picomatch(this.getPatterns()))(relativePath);\n }\n\n /** get glob patterns to match files in collection, this doesn't take `supportedFormats` into account. */\n getPatterns() {\n const { files, supportedFormats } = this.config;\n return files ?? [supportedFormats ? `**/*.{${supportedFormats.join(\",\")}}` : `**/*`];\n }\n\n invalidateCache() {\n this.filesCache.invalidate(\"\");\n }\n}\n\nexport interface FileSystemCollectionConfig {\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 function fileSystemCollection(config: FileSystemCollectionConfig) {\n return new FileSystemCollection(config);\n}\n"],"mappings":";;;;;;AAKA,IAAa,uBAAb,cAA0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AAW,WAAW,GAAG;;;AAuBlC,SAAgB,qBAAqB,QAAoC;AACvE,QAAO,IAAI,qBAAqB,OAAO"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { load } from "js-yaml";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/collections/mdx/fuma-matter.ts
|
|
4
4
|
/**
|
|
5
5
|
* Inspired by https://github.com/jonschlinkert/gray-matter
|
|
6
6
|
*/
|
|
@@ -24,4 +24,4 @@ function fumaMatter(input) {
|
|
|
24
24
|
|
|
25
25
|
//#endregion
|
|
26
26
|
export { fumaMatter as t };
|
|
27
|
-
//# sourceMappingURL=fuma-matter-
|
|
27
|
+
//# sourceMappingURL=fuma-matter-BuBO2w-p.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fuma-matter-BuBO2w-p.js","names":["output: Output"],"sources":["../src/collections/mdx/fuma-matter.ts"],"sourcesContent":["/**\n * Inspired by https://github.com/jonschlinkert/gray-matter\n */\nimport { load } from \"js-yaml\";\n\ninterface Output {\n /**\n * The matter section, including the delimiter.\n */\n matter: string;\n content: string;\n data: unknown;\n}\n\nconst regex = /^---\\r?\\n(.+?)\\r?\\n---\\r?\\n/s;\n\n/**\n * parse frontmatter, it supports only yaml format\n */\nexport function fumaMatter(input: string): Output {\n const output: Output = { matter: \"\", data: {}, content: input };\n const match = regex.exec(input);\n if (!match) {\n return output;\n }\n\n // get the raw front-matter block\n output.matter = match[0];\n output.content = input.slice(match[0].length);\n\n const loaded = load(match[1]);\n output.data = loaded ?? {};\n\n return output;\n}\n"],"mappings":";;;;;;AAcA,MAAM,QAAQ;;;;AAKd,SAAgB,WAAW,OAAuB;CAChD,MAAMA,SAAiB;EAAE,QAAQ;EAAI,MAAM,EAAE;EAAE,SAAS;EAAO;CAC/D,MAAM,QAAQ,MAAM,KAAK,MAAM;AAC/B,KAAI,CAAC,MACH,QAAO;AAIT,QAAO,SAAS,MAAM;AACtB,QAAO,UAAU,MAAM,MAAM,MAAM,GAAG,OAAO;AAG7C,QAAO,OADQ,KAAK,MAAM,GAAG,IACL,EAAE;AAE1B,QAAO"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { S as AsyncHook, c as Plugin, h as CollectionHook } from "./core-BO3b8jMg.js";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/git.d.ts
|
|
4
|
+
interface GitFileData {
|
|
5
|
+
/**
|
|
6
|
+
* Last modified date of file, obtained from version control.
|
|
7
|
+
*/
|
|
8
|
+
lastModified: Date | null;
|
|
9
|
+
/**
|
|
10
|
+
* Creation date of file, obtained from version control.
|
|
11
|
+
*/
|
|
12
|
+
creationDate: Date | null;
|
|
13
|
+
}
|
|
14
|
+
interface GitHook {
|
|
15
|
+
/**
|
|
16
|
+
* receive the client.
|
|
17
|
+
*/
|
|
18
|
+
onClient: AsyncHook<{
|
|
19
|
+
client: GitClient;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
declare const gitHook: CollectionHook<GitHook, undefined>;
|
|
23
|
+
/**
|
|
24
|
+
* Add version control integration for Git.
|
|
25
|
+
* 1. Injects `creationDate` & `lastModified` properties to page exports.
|
|
26
|
+
*
|
|
27
|
+
* @remarks If you are using Vercel, please set `VERCEL_DEEP_CLONE` environment variable to `true`. This ensures the client can access the full commit history of Git.
|
|
28
|
+
*/
|
|
29
|
+
declare function git(): Plugin;
|
|
30
|
+
interface GitClient {
|
|
31
|
+
getFileData: (options: {
|
|
32
|
+
filePath: string;
|
|
33
|
+
}) => Promise<GitFileData>;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { gitHook as a, git as i, GitFileData as n, GitHook as r, GitClient as t };
|
|
37
|
+
//# sourceMappingURL=git-2CjUW3M5.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-2CjUW3M5.d.ts","names":[],"sources":["../src/plugins/git.ts"],"sourcesContent":[],"mappings":";;;UAOiB,WAAA;EAAA;AAWjB;AAOA;EAUwB,YAAG,EAxBX,IAwBe,GAAA,IAAM;EAepB;;;gBAnCD;;UAGC,OAAA;;;;YAIL;YAAoB;;;cAGnB,SAAO,eAAA;;;;;;;iBAUI,GAAA,CAAA,GAAO;UAed,SAAA;;;QACiC,QAAQ"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { a as asyncHook, n as defineCollectionHook } from "./collections-DNFRdCuB.js";
|
|
2
|
+
import { t as createCache } from "./async-cache-U87GzQTb.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { x } from "tinyexec";
|
|
5
|
+
|
|
6
|
+
//#region src/plugins/git.ts
|
|
7
|
+
const gitHook = defineCollectionHook(() => ({ onClient: asyncHook() }));
|
|
8
|
+
/**
|
|
9
|
+
* Add version control integration for Git.
|
|
10
|
+
* 1. Injects `creationDate` & `lastModified` properties to page exports.
|
|
11
|
+
*
|
|
12
|
+
* @remarks If you are using Vercel, please set `VERCEL_DEEP_CLONE` environment variable to `true`. This ensures the client can access the full commit history of Git.
|
|
13
|
+
*/
|
|
14
|
+
function git() {
|
|
15
|
+
let client;
|
|
16
|
+
return {
|
|
17
|
+
name: "git",
|
|
18
|
+
config() {
|
|
19
|
+
const { cwd } = this.core.getOptions();
|
|
20
|
+
client = createGitClient(cwd);
|
|
21
|
+
},
|
|
22
|
+
async collection(collection) {
|
|
23
|
+
await collection.getPluginHook(gitHook)?.onClient.run({ client });
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function createGitClient(cwd) {
|
|
28
|
+
const cache = createCache();
|
|
29
|
+
function mapDate(out) {
|
|
30
|
+
if (out.exitCode !== 0) return null;
|
|
31
|
+
const date = new Date(out.stdout);
|
|
32
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
33
|
+
}
|
|
34
|
+
return { async getFileData({ filePath }) {
|
|
35
|
+
return cache.cached(filePath, async () => {
|
|
36
|
+
const relativePath = path.relative(cwd, filePath);
|
|
37
|
+
const [mod, create] = await Promise.all([x("git", [
|
|
38
|
+
"log",
|
|
39
|
+
"-1",
|
|
40
|
+
"--pretty=%ai",
|
|
41
|
+
relativePath
|
|
42
|
+
], { nodeOptions: { cwd } }), x("git", [
|
|
43
|
+
"log",
|
|
44
|
+
"--diff-filter=A",
|
|
45
|
+
"--follow",
|
|
46
|
+
"--format=%ai",
|
|
47
|
+
"-1",
|
|
48
|
+
relativePath
|
|
49
|
+
], { nodeOptions: { cwd } })]);
|
|
50
|
+
return {
|
|
51
|
+
lastModified: mapDate(mod),
|
|
52
|
+
creationDate: mapDate(create)
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
} };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { gitHook as n, git as t };
|
|
60
|
+
//# sourceMappingURL=git-CQWA37-X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-CQWA37-X.js","names":["client: GitClient"],"sources":["../src/plugins/git.ts"],"sourcesContent":["import path from \"node:path\";\nimport { type Output, x } from \"tinyexec\";\nimport type { Plugin } from \"@/core\";\nimport { createCache } from \"@/utils/async-cache\";\nimport { defineCollectionHook } from \"@/collections\";\nimport { asyncHook, AsyncHook } from \"@/utils/hook\";\n\nexport interface GitFileData {\n /**\n * Last modified date of file, obtained from version control.\n */\n lastModified: Date | null;\n /**\n * Creation date of file, obtained from version control.\n */\n creationDate: Date | null;\n}\n\nexport interface GitHook {\n /**\n * receive the client.\n */\n onClient: AsyncHook<{ client: GitClient }>;\n}\n\nexport const gitHook = defineCollectionHook<GitHook>(() => ({\n onClient: asyncHook(),\n}));\n\n/**\n * Add version control integration for Git.\n * 1. Injects `creationDate` & `lastModified` properties to page exports.\n *\n * @remarks If you are using Vercel, please set `VERCEL_DEEP_CLONE` environment variable to `true`. This ensures the client can access the full commit history of Git.\n */\nexport default function git(): Plugin {\n let client: GitClient;\n\n return {\n name: \"git\",\n config() {\n const { cwd } = this.core.getOptions();\n client = createGitClient(cwd);\n },\n async collection(collection) {\n await collection.getPluginHook(gitHook)?.onClient.run({ client });\n },\n };\n}\n\nexport interface GitClient {\n getFileData: (options: { filePath: string }) => Promise<GitFileData>;\n}\n\nfunction createGitClient(cwd: string): GitClient {\n const cache = createCache<GitFileData>();\n\n function mapDate(out: Output): Date | null {\n if (out.exitCode !== 0) return null;\n const date = new Date(out.stdout);\n return Number.isNaN(date.getTime()) ? null : date;\n }\n\n return {\n async getFileData({ filePath }) {\n return cache.cached(filePath, async () => {\n const relativePath = path.relative(cwd, filePath);\n const [mod, create] = await Promise.all([\n x(\"git\", [\"log\", \"-1\", \"--pretty=%ai\", relativePath], {\n nodeOptions: {\n cwd,\n },\n }),\n x(\"git\", [\"log\", \"--diff-filter=A\", \"--follow\", \"--format=%ai\", \"-1\", relativePath], {\n nodeOptions: {\n cwd,\n },\n }),\n ]);\n\n return {\n lastModified: mapDate(mod),\n creationDate: mapDate(create),\n };\n });\n },\n };\n}\n"],"mappings":";;;;;;AAyBA,MAAa,UAAU,4BAAqC,EAC1D,UAAU,WAAW,EACtB,EAAE;;;;;;;AAQH,SAAwB,MAAc;CACpC,IAAIA;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP,MAAM,EAAE,QAAQ,KAAK,KAAK,YAAY;AACtC,YAAS,gBAAgB,IAAI;;EAE/B,MAAM,WAAW,YAAY;AAC3B,SAAM,WAAW,cAAc,QAAQ,EAAE,SAAS,IAAI,EAAE,QAAQ,CAAC;;EAEpE;;AAOH,SAAS,gBAAgB,KAAwB;CAC/C,MAAM,QAAQ,aAA0B;CAExC,SAAS,QAAQ,KAA0B;AACzC,MAAI,IAAI,aAAa,EAAG,QAAO;EAC/B,MAAM,OAAO,IAAI,KAAK,IAAI,OAAO;AACjC,SAAO,OAAO,MAAM,KAAK,SAAS,CAAC,GAAG,OAAO;;AAG/C,QAAO,EACL,MAAM,YAAY,EAAE,YAAY;AAC9B,SAAO,MAAM,OAAO,UAAU,YAAY;GACxC,MAAM,eAAe,KAAK,SAAS,KAAK,SAAS;GACjD,MAAM,CAAC,KAAK,UAAU,MAAM,QAAQ,IAAI,CACtC,EAAE,OAAO;IAAC;IAAO;IAAM;IAAgB;IAAa,EAAE,EACpD,aAAa,EACX,KACD,EACF,CAAC,EACF,EAAE,OAAO;IAAC;IAAO;IAAmB;IAAY;IAAgB;IAAM;IAAa,EAAE,EACnF,aAAa,EACX,KACD,EACF,CAAC,CACH,CAAC;AAEF,UAAO;IACL,cAAc,QAAQ,IAAI;IAC1B,cAAc,QAAQ,OAAO;IAC9B;IACD;IAEL"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { c as Plugin, h as CollectionHook, l as PluginContext } from "./core-BO3b8jMg.js";
|
|
2
|
+
import { t as DynamicCore } from "./dynamic-CTYYdl7_.js";
|
|
3
|
+
import { NextConfig } from "next";
|
|
4
|
+
import { LoaderContext } from "webpack";
|
|
5
|
+
|
|
6
|
+
//#region src/plugins/loader/webpack.d.ts
|
|
7
|
+
interface WebpackLoaderOptions {
|
|
8
|
+
absoluteCompiledConfigPath: string;
|
|
9
|
+
configPath: string;
|
|
10
|
+
outDir: string;
|
|
11
|
+
isDev: boolean;
|
|
12
|
+
}
|
|
13
|
+
type WebpackLoader = (this: LoaderContext<WebpackLoaderOptions>, source: string) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Note: need to handle the `test` regex in Webpack config instead.
|
|
16
|
+
*/
|
|
17
|
+
declare function createWebpackLoader(loaderFactory: (core: DynamicCore) => Loader): WebpackLoader;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/plugins/loader/index.d.ts
|
|
20
|
+
type Awaitable<T> = T | Promise<T>;
|
|
21
|
+
interface CompilerOptions {
|
|
22
|
+
addDependency: (file: string) => void;
|
|
23
|
+
}
|
|
24
|
+
type LoaderEnvironment = "vite" | "bun" | "node";
|
|
25
|
+
interface Loader {
|
|
26
|
+
/**
|
|
27
|
+
* Transform input into JavaScript.
|
|
28
|
+
*
|
|
29
|
+
* Returns:
|
|
30
|
+
* - `LoaderOutput`: JavaScript code & source map.
|
|
31
|
+
* - `null`: skip the loader. Fallback to default behaviour if possible, otherwise the adapter will try workarounds.
|
|
32
|
+
*/
|
|
33
|
+
load: (input: LoaderInput) => Awaitable<LoaderOutput | null>;
|
|
34
|
+
bun?: {
|
|
35
|
+
/**
|
|
36
|
+
* 1. Bun doesn't allow `null` in loaders.
|
|
37
|
+
* 2. Bun requires sync result to support dynamic require().
|
|
38
|
+
*/
|
|
39
|
+
load?: (source: string, input: LoaderInput) => Awaitable<Bun.OnLoadResult>;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
interface LoaderInput {
|
|
43
|
+
development: boolean;
|
|
44
|
+
compiler: CompilerOptions;
|
|
45
|
+
filePath: string;
|
|
46
|
+
query: Record<string, string | string[] | undefined>;
|
|
47
|
+
getSource: () => string | Promise<string>;
|
|
48
|
+
}
|
|
49
|
+
interface LoaderOutput {
|
|
50
|
+
code: string;
|
|
51
|
+
map?: unknown;
|
|
52
|
+
/**
|
|
53
|
+
* only supported on Vite 8 at the moment, specify the output module type.
|
|
54
|
+
*
|
|
55
|
+
* on unsupported environments, it will be ignored.
|
|
56
|
+
*/
|
|
57
|
+
moduleType?: "js" | "json";
|
|
58
|
+
}
|
|
59
|
+
interface NextLoaderContext extends PluginContext {
|
|
60
|
+
getLoaderOptions: () => WebpackLoaderOptions;
|
|
61
|
+
}
|
|
62
|
+
interface LoaderConfig {
|
|
63
|
+
/** unique ID for loader, used to deduplicate loaders */
|
|
64
|
+
id?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Filter file paths, the input can be either a file URL or file path.
|
|
67
|
+
*
|
|
68
|
+
* Must take resource query into consideration.
|
|
69
|
+
*/
|
|
70
|
+
test?: RegExp;
|
|
71
|
+
/**
|
|
72
|
+
* @remarks it doesn't configure automatically for Next.js, you have to define the webpack/turbopack config in `configureNext()`.
|
|
73
|
+
*/
|
|
74
|
+
createLoader: (this: PluginContext, environment: LoaderEnvironment) => Promise<Loader>;
|
|
75
|
+
configureNext?: (this: NextLoaderContext, next: NextConfig) => NextConfig;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* a light layer for implementing loaders.
|
|
79
|
+
*/
|
|
80
|
+
declare function loaderPlugin(): Plugin;
|
|
81
|
+
interface LoaderHook {
|
|
82
|
+
loaders: LoaderConfig[];
|
|
83
|
+
}
|
|
84
|
+
declare const loaderHook: CollectionHook<LoaderHook, undefined>;
|
|
85
|
+
//#endregion
|
|
86
|
+
export { LoaderInput as a, loaderPlugin as c, createWebpackLoader as d, LoaderHook as i, WebpackLoader as l, Loader as n, LoaderOutput as o, LoaderConfig as r, loaderHook as s, CompilerOptions as t, WebpackLoaderOptions as u };
|
|
87
|
+
//# sourceMappingURL=index-Da88Sj8w.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Da88Sj8w.d.ts","names":[],"sources":["../src/plugins/loader/webpack.ts","../src/plugins/loader/index.ts"],"sourcesContent":[],"mappings":";;;;;;UAQiB,oBAAA;;;EAAA,MAAA,EAAA,MAAA;EAOL,KAAA,EAAA,OAAA;AAqBZ;AAA0D,KArB9C,aAAA,GAqB8C,CAAA,IAAA,EArBvB,aAqBuB,CArBT,oBAqBS,CAAA,EAAA,MAAA,EAAA,MAAA,EAAA,GAAA,IAAA;;;;iBAA1C,mBAAA,uBAA0C,gBAAgB,SAAS;;;KC7B9E,eAAe,IAAI,QAAQ;UAEf,eAAA;;ADDjB;AAOA,KCFK,iBAAA,GDEoB,MAAA,GAAwB,KAAA,GAAA,MAAA;AAqBjC,UCrBC,MAAA,CDqBD;EAA0C;;;;;;;EC7BrD,IAAA,EAAA,CAAA,KAAS,EAgBE,WAhBF,EAAA,GAgBkB,SAhBlB,CAgB4B,YAhB5B,GAAA,IAAA,CAAA;EAAM,GAAA,CAAA,EAAA;IAAY;;;AAEhC;IAIK,IAAA,CAAA,EAAA,CAAA,M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