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
package/dist/next/index.cjs
DELETED
|
@@ -1,502 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
let node_path = require("node:path");
|
|
29
|
-
node_path = __toESM(node_path);
|
|
30
|
-
let node_url = require("node:url");
|
|
31
|
-
let node_fs_promises = require("node:fs/promises");
|
|
32
|
-
node_fs_promises = __toESM(node_fs_promises);
|
|
33
|
-
let tinyglobby = require("tinyglobby");
|
|
34
|
-
|
|
35
|
-
//#region src/config/build.ts
|
|
36
|
-
/**
|
|
37
|
-
* @param config - either the default export or all exports of config file.
|
|
38
|
-
* @param workspace
|
|
39
|
-
*/
|
|
40
|
-
function buildConfig(config, workspace) {
|
|
41
|
-
const collections = /* @__PURE__ */ new Map();
|
|
42
|
-
const loaded = {};
|
|
43
|
-
let globalConfig;
|
|
44
|
-
if ("default" in config) {
|
|
45
|
-
globalConfig = config.default;
|
|
46
|
-
for (const [k, v] of Object.entries(config)) {
|
|
47
|
-
if (k === "default") continue;
|
|
48
|
-
globalConfig.collections ??= {};
|
|
49
|
-
globalConfig.collections[k] = v;
|
|
50
|
-
}
|
|
51
|
-
} else globalConfig = config;
|
|
52
|
-
if (globalConfig.collections) for (const [name, collection] of Object.entries(globalConfig.collections)) {
|
|
53
|
-
collection.init?.({
|
|
54
|
-
name,
|
|
55
|
-
workspace
|
|
56
|
-
});
|
|
57
|
-
collections.set(name, collection);
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
...globalConfig,
|
|
61
|
-
collections,
|
|
62
|
-
workspaces: Object.fromEntries(Object.entries(loaded.workspaces ?? {}).map(([key, value]) => {
|
|
63
|
-
return [key, {
|
|
64
|
-
dir: value.dir,
|
|
65
|
-
config: buildConfig(value.config, {
|
|
66
|
-
...value,
|
|
67
|
-
name: key
|
|
68
|
-
})
|
|
69
|
-
}];
|
|
70
|
-
}))
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/config/load-from-file.ts
|
|
76
|
-
async function compileConfig(core) {
|
|
77
|
-
const { build } = await import("esbuild");
|
|
78
|
-
const { configPath, outDir } = core.getOptions();
|
|
79
|
-
if ((await build({
|
|
80
|
-
entryPoints: [{
|
|
81
|
-
in: configPath,
|
|
82
|
-
out: "content.config"
|
|
83
|
-
}],
|
|
84
|
-
bundle: true,
|
|
85
|
-
outdir: outDir,
|
|
86
|
-
target: "node20",
|
|
87
|
-
write: true,
|
|
88
|
-
platform: "node",
|
|
89
|
-
format: "esm",
|
|
90
|
-
packages: "external",
|
|
91
|
-
outExtension: { ".js": ".mjs" },
|
|
92
|
-
allowOverwrite: true
|
|
93
|
-
})).errors.length > 0) throw new Error("failed to compile configuration file");
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Load config
|
|
97
|
-
*
|
|
98
|
-
* @param build - By default, it assumes the config file has been compiled. Set this `true` to compile the config first.
|
|
99
|
-
*/
|
|
100
|
-
async function loadConfig(core, build = false) {
|
|
101
|
-
if (build) await compileConfig(core);
|
|
102
|
-
const url = (0, node_url.pathToFileURL)(core.getCompiledConfigPath());
|
|
103
|
-
url.searchParams.set("hash", Date.now().toString());
|
|
104
|
-
return await import(url.href).then((loaded) => buildConfig(loaded));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/utils/async-cache.ts
|
|
109
|
-
/**
|
|
110
|
-
* cache for async resources, finished promises will be resolved into original value, otherwise wrapped with a promise.
|
|
111
|
-
*/
|
|
112
|
-
function createCache(store = /* @__PURE__ */ new Map()) {
|
|
113
|
-
return {
|
|
114
|
-
cached(key, fn) {
|
|
115
|
-
let cached = store.get(key);
|
|
116
|
-
if (cached) return cached;
|
|
117
|
-
cached = fn();
|
|
118
|
-
if (cached instanceof Promise) cached = cached.then((out) => {
|
|
119
|
-
if (store.has(key)) store.set(key, out);
|
|
120
|
-
return out;
|
|
121
|
-
});
|
|
122
|
-
store.set(key, cached);
|
|
123
|
-
return cached;
|
|
124
|
-
},
|
|
125
|
-
invalidate(key) {
|
|
126
|
-
store.delete(key);
|
|
127
|
-
},
|
|
128
|
-
$value() {
|
|
129
|
-
return this;
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/utils/code-generator.ts
|
|
136
|
-
function importInfo() {
|
|
137
|
-
return {
|
|
138
|
-
named: /* @__PURE__ */ new Map(),
|
|
139
|
-
namespaces: /* @__PURE__ */ new Set(),
|
|
140
|
-
isUsed: /* @__PURE__ */ new Set()
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Code generator (one instance per file)
|
|
145
|
-
*/
|
|
146
|
-
var CodeGenerator = class {
|
|
147
|
-
lines = [];
|
|
148
|
-
globCache;
|
|
149
|
-
importInfos = /* @__PURE__ */ new Map();
|
|
150
|
-
eagerImportId = 0;
|
|
151
|
-
options;
|
|
152
|
-
constructor({ target = "default", jsExtension = false, globCache = /* @__PURE__ */ new Map(), outDir = "" }) {
|
|
153
|
-
this.options = {
|
|
154
|
-
target,
|
|
155
|
-
jsExtension,
|
|
156
|
-
globCache,
|
|
157
|
-
outDir
|
|
158
|
-
};
|
|
159
|
-
this.globCache = createCache(globCache);
|
|
160
|
-
}
|
|
161
|
-
addNamespaceImport(namespace, specifier, types = false) {
|
|
162
|
-
const info = this.importInfos.get(specifier) ?? importInfo();
|
|
163
|
-
this.importInfos.set(specifier, info);
|
|
164
|
-
if (!types) info.isUsed.add(namespace);
|
|
165
|
-
info.namespaces.add(namespace);
|
|
166
|
-
}
|
|
167
|
-
addNamedImport(names, specifier, types = false) {
|
|
168
|
-
const info = this.importInfos.get(specifier) ?? importInfo();
|
|
169
|
-
this.importInfos.set(specifier, info);
|
|
170
|
-
for (const name of names) {
|
|
171
|
-
const [memberName, importName = memberName] = name.split(/\s+as\s+/, 2);
|
|
172
|
-
info.named.set(importName, memberName);
|
|
173
|
-
if (!types) info.isUsed.add(importName);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
push(...insert) {
|
|
177
|
-
this.lines.push(...insert);
|
|
178
|
-
}
|
|
179
|
-
async pushAsync(insert) {
|
|
180
|
-
for (const line of await Promise.all(insert)) {
|
|
181
|
-
if (line === void 0) continue;
|
|
182
|
-
this.lines.push(line);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
async generateGlobImport(patterns, options) {
|
|
186
|
-
if (this.options.target === "vite") return this.generateViteGlobImport(patterns, options);
|
|
187
|
-
return this.generateNodeGlobImport(patterns, options);
|
|
188
|
-
}
|
|
189
|
-
generateViteGlobImport(patterns, { base, ...rest }) {
|
|
190
|
-
patterns = (typeof patterns === "string" ? [patterns] : patterns).map(normalizeViteGlobPath);
|
|
191
|
-
return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify({
|
|
192
|
-
base: normalizeViteGlobPath(node_path.default.relative(this.options.outDir, base)),
|
|
193
|
-
...rest
|
|
194
|
-
}, null, 2)})`;
|
|
195
|
-
}
|
|
196
|
-
async generateNodeGlobImport(patterns, { base, eager = false, query = {}, import: importName }) {
|
|
197
|
-
const files = await this.globCache.cached(JSON.stringify({
|
|
198
|
-
patterns,
|
|
199
|
-
base
|
|
200
|
-
}), () => (0, tinyglobby.glob)(patterns, { cwd: base }));
|
|
201
|
-
let code = "{";
|
|
202
|
-
for (const item of files) {
|
|
203
|
-
const fullPath = node_path.default.join(base, item);
|
|
204
|
-
const searchParams = new URLSearchParams();
|
|
205
|
-
for (const [k, v] of Object.entries(query)) if (v !== void 0) searchParams.set(k, v);
|
|
206
|
-
const importPath = `${this.formatImportPath(fullPath)}?${searchParams.toString()}`;
|
|
207
|
-
if (eager) {
|
|
208
|
-
const name = `__fd_glob_${this.eagerImportId++}`;
|
|
209
|
-
this.lines.unshift(importName ? `import { ${importName} as ${name} } from ${JSON.stringify(importPath)}` : `import * as ${name} from ${JSON.stringify(importPath)}`);
|
|
210
|
-
code += `${JSON.stringify(item)}: ${name}, `;
|
|
211
|
-
} else {
|
|
212
|
-
let line = `${JSON.stringify(item)}: () => import(${JSON.stringify(importPath)})`;
|
|
213
|
-
if (importName) line += `.then(mod => mod.${importName})`;
|
|
214
|
-
code += `${line}, `;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
code += "}";
|
|
218
|
-
return code;
|
|
219
|
-
}
|
|
220
|
-
formatImportPath(file) {
|
|
221
|
-
const ext = node_path.default.extname(file);
|
|
222
|
-
let filename;
|
|
223
|
-
if (ext === ".ts") {
|
|
224
|
-
filename = file.substring(0, file.length - ext.length);
|
|
225
|
-
if (this.options.jsExtension) filename += ".js";
|
|
226
|
-
} else filename = file;
|
|
227
|
-
const importPath = slash(node_path.default.relative(this.options.outDir, filename));
|
|
228
|
-
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
229
|
-
}
|
|
230
|
-
toString() {
|
|
231
|
-
const final = ["// @ts-nocheck"];
|
|
232
|
-
if (this.options.target === "vite") final.push("/// <reference types=\"vite/client\" />");
|
|
233
|
-
for (const [specifier, info] of this.importInfos) {
|
|
234
|
-
const { namespaces, named, isUsed } = info;
|
|
235
|
-
for (const namespace of namespaces) final.push(isUsed.has(namespace) ? `import * as ${namespace} from "${specifier}";` : `import type * as ${namespace} from "${specifier}";`);
|
|
236
|
-
const namedImports = [];
|
|
237
|
-
for (const [importName, memberName] of named) {
|
|
238
|
-
const item = importName === memberName ? importName : `${memberName} as ${importName}`;
|
|
239
|
-
namedImports.push(isUsed.has(importName) ? item : `type ${item}`);
|
|
240
|
-
}
|
|
241
|
-
if (namedImports.length > 0) final.push(`import { ${namedImports.join(", ")} } from "${specifier}";`);
|
|
242
|
-
}
|
|
243
|
-
final.push(...this.lines);
|
|
244
|
-
return final.join("\n");
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
/**
|
|
248
|
-
* convert into POSIX & relative file paths, such that Vite can accept it.
|
|
249
|
-
*/
|
|
250
|
-
function normalizeViteGlobPath(file) {
|
|
251
|
-
file = slash(file);
|
|
252
|
-
if (file.startsWith("./")) return file;
|
|
253
|
-
if (file.startsWith("/")) return `.${file}`;
|
|
254
|
-
return `./${file}`;
|
|
255
|
-
}
|
|
256
|
-
function slash(path$2) {
|
|
257
|
-
if (path$2.startsWith("\\\\?\\")) return path$2;
|
|
258
|
-
return path$2.replaceAll("\\", "/");
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
//#endregion
|
|
262
|
-
//#region src/core.ts
|
|
263
|
-
async function getPlugins(pluginOptions) {
|
|
264
|
-
const plugins = [];
|
|
265
|
-
for (const option of await Promise.all(pluginOptions)) {
|
|
266
|
-
if (!option) continue;
|
|
267
|
-
if (Array.isArray(option)) plugins.push(...await getPlugins(option));
|
|
268
|
-
else plugins.push(option);
|
|
269
|
-
}
|
|
270
|
-
return plugins;
|
|
271
|
-
}
|
|
272
|
-
var Core = class Core {
|
|
273
|
-
workspaces = /* @__PURE__ */ new Map();
|
|
274
|
-
options;
|
|
275
|
-
plugins = [];
|
|
276
|
-
config;
|
|
277
|
-
static defaultOptions = {
|
|
278
|
-
configPath: "content.config.ts",
|
|
279
|
-
outDir: ".content"
|
|
280
|
-
};
|
|
281
|
-
/**
|
|
282
|
-
* Convenient cache store, reset when config changes.
|
|
283
|
-
*
|
|
284
|
-
* You can group namespaces in cache key with ":", like `my-plugin:data`
|
|
285
|
-
*/
|
|
286
|
-
cache = /* @__PURE__ */ new Map();
|
|
287
|
-
constructor(options) {
|
|
288
|
-
this.options = options;
|
|
289
|
-
}
|
|
290
|
-
async init({ config: newConfig }) {
|
|
291
|
-
this.config = await newConfig;
|
|
292
|
-
this.cache.clear();
|
|
293
|
-
this.workspaces.clear();
|
|
294
|
-
const loadedCollectionTypeIds = /* @__PURE__ */ new Set();
|
|
295
|
-
this.plugins = await getPlugins([
|
|
296
|
-
this.options.plugins,
|
|
297
|
-
this.config.plugins,
|
|
298
|
-
...this.config.collections.values().map(({ typeInfo }) => {
|
|
299
|
-
if (loadedCollectionTypeIds.has(typeInfo.id)) return false;
|
|
300
|
-
loadedCollectionTypeIds.add(typeInfo.id);
|
|
301
|
-
return typeInfo.plugins;
|
|
302
|
-
})
|
|
303
|
-
]);
|
|
304
|
-
const ctx = this.getPluginContext();
|
|
305
|
-
for (const plugin of this.plugins) {
|
|
306
|
-
const out = await plugin.config?.call(ctx, this.config);
|
|
307
|
-
if (out) this.config = out;
|
|
308
|
-
}
|
|
309
|
-
const { workspace, outDir } = this.options;
|
|
310
|
-
if (!workspace) await Promise.all(Object.entries(this.config.workspaces).map(async ([name, workspace$1]) => {
|
|
311
|
-
const child = new Core({
|
|
312
|
-
...this.options,
|
|
313
|
-
outDir: node_path.default.join(outDir, name),
|
|
314
|
-
workspace: {
|
|
315
|
-
name,
|
|
316
|
-
parent: this,
|
|
317
|
-
dir: workspace$1.dir
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
await child.init({ config: workspace$1.config });
|
|
321
|
-
this.workspaces.set(name, child);
|
|
322
|
-
}));
|
|
323
|
-
await Promise.all(this.config.collections.values().map(async (collection) => {
|
|
324
|
-
for (const plugin of this.plugins) await plugin.collection?.call(ctx, collection);
|
|
325
|
-
}));
|
|
326
|
-
}
|
|
327
|
-
getWorkspaces() {
|
|
328
|
-
return this.workspaces;
|
|
329
|
-
}
|
|
330
|
-
getOptions() {
|
|
331
|
-
return this.options;
|
|
332
|
-
}
|
|
333
|
-
getConfig() {
|
|
334
|
-
return this.config;
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* The file path of compiled config file, the file may not exist (e.g. on Vite, or still compiling)
|
|
338
|
-
*/
|
|
339
|
-
getCompiledConfigPath() {
|
|
340
|
-
return node_path.default.join(this.options.outDir, "content.config.mjs");
|
|
341
|
-
}
|
|
342
|
-
getPlugins(workspace = false) {
|
|
343
|
-
if (workspace) {
|
|
344
|
-
const plugins = [...this.plugins];
|
|
345
|
-
for (const workspace$1 of this.workspaces.values()) plugins.push(...workspace$1.plugins);
|
|
346
|
-
return plugins;
|
|
347
|
-
}
|
|
348
|
-
return this.plugins;
|
|
349
|
-
}
|
|
350
|
-
getCollections(workspace = false) {
|
|
351
|
-
const list = Array.from(this.config.collections.values());
|
|
352
|
-
if (workspace) for (const workspace$1 of this.workspaces.values()) list.push(...workspace$1.getCollections());
|
|
353
|
-
return list;
|
|
354
|
-
}
|
|
355
|
-
getCollection(name) {
|
|
356
|
-
return this.config.collections.get(name);
|
|
357
|
-
}
|
|
358
|
-
getPluginContext() {
|
|
359
|
-
return { core: this };
|
|
360
|
-
}
|
|
361
|
-
async initServer(server) {
|
|
362
|
-
const ctx = this.getPluginContext();
|
|
363
|
-
const promises = [];
|
|
364
|
-
for (const plugin of this.plugins) promises.push(plugin.configureServer?.call(ctx, server));
|
|
365
|
-
for (const workspace of this.workspaces.values()) promises.push(workspace.initServer(server));
|
|
366
|
-
await Promise.all(promises);
|
|
367
|
-
}
|
|
368
|
-
async emit(emitOptions = {}) {
|
|
369
|
-
const { workspace, outDir, emit: { target, jsExtension } = {} } = this.options;
|
|
370
|
-
const { filterPlugin, filterWorkspace, write = false } = emitOptions;
|
|
371
|
-
const start = performance.now();
|
|
372
|
-
const globCache = /* @__PURE__ */ new Map();
|
|
373
|
-
const ctx = {
|
|
374
|
-
...this.getPluginContext(),
|
|
375
|
-
createCodeGenerator: async (path$2, content) => {
|
|
376
|
-
const codegen = new CodeGenerator({
|
|
377
|
-
target,
|
|
378
|
-
outDir,
|
|
379
|
-
jsExtension,
|
|
380
|
-
globCache
|
|
381
|
-
});
|
|
382
|
-
await content({
|
|
383
|
-
core: this,
|
|
384
|
-
codegen,
|
|
385
|
-
workspace: workspace?.name
|
|
386
|
-
});
|
|
387
|
-
return {
|
|
388
|
-
path: path$2,
|
|
389
|
-
content: codegen.toString()
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
const added = /* @__PURE__ */ new Set();
|
|
394
|
-
const out = {
|
|
395
|
-
entries: [],
|
|
396
|
-
workspaces: {}
|
|
397
|
-
};
|
|
398
|
-
for (const li of await Promise.all(this.plugins.map((plugin) => {
|
|
399
|
-
if (filterPlugin && !filterPlugin(plugin) || !plugin.emit) return null;
|
|
400
|
-
return plugin.emit.call(ctx);
|
|
401
|
-
}))) {
|
|
402
|
-
if (!li) continue;
|
|
403
|
-
for (const item of li) {
|
|
404
|
-
if (added.has(item.path)) continue;
|
|
405
|
-
out.entries.push(item);
|
|
406
|
-
added.add(item.path);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
if (write) {
|
|
410
|
-
await Promise.all(out.entries.map(async (entry) => {
|
|
411
|
-
const file = node_path.default.join(outDir, entry.path);
|
|
412
|
-
await node_fs_promises.default.mkdir(node_path.default.dirname(file), { recursive: true });
|
|
413
|
-
await node_fs_promises.default.writeFile(file, entry.content);
|
|
414
|
-
}));
|
|
415
|
-
console.log(workspace ? `[MDX: ${workspace.name}] generated files in ${performance.now() - start}ms` : `[MDX] generated files in ${performance.now() - start}ms`);
|
|
416
|
-
}
|
|
417
|
-
await Promise.all(this.workspaces.entries().map(async ([name, workspace$1]) => {
|
|
418
|
-
if (filterWorkspace && !filterWorkspace(name)) return;
|
|
419
|
-
out.workspaces[name] = (await workspace$1.emit(emitOptions)).entries;
|
|
420
|
-
}));
|
|
421
|
-
return out;
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
//#endregion
|
|
426
|
-
//#region src/next/index.ts
|
|
427
|
-
async function createContent(nextOptions = {}) {
|
|
428
|
-
const core = createNextCore(applyDefaults(nextOptions));
|
|
429
|
-
await core.init({ config: loadConfig(core, true) });
|
|
430
|
-
if (process.env._FUMADOCS_MDX !== "1") {
|
|
431
|
-
process.env._FUMADOCS_MDX = "1";
|
|
432
|
-
await core.emit({ write: true });
|
|
433
|
-
await init(process.env.NODE_ENV === "development", core);
|
|
434
|
-
}
|
|
435
|
-
return (nextConfig = {}) => {
|
|
436
|
-
const ctx = core.getPluginContext();
|
|
437
|
-
for (const plugin of core.getPlugins(true)) nextConfig = plugin.next?.config?.call(ctx, nextConfig) ?? nextConfig;
|
|
438
|
-
return nextConfig;
|
|
439
|
-
};
|
|
440
|
-
}
|
|
441
|
-
async function init(dev, core) {
|
|
442
|
-
if (!dev) return;
|
|
443
|
-
const { FSWatcher } = await import("chokidar");
|
|
444
|
-
const { configPath, outDir } = core.getOptions();
|
|
445
|
-
const absoluteConfigPath = node_path.resolve(configPath);
|
|
446
|
-
let watcher;
|
|
447
|
-
async function devServer() {
|
|
448
|
-
if (watcher && !watcher.closed) await watcher.close();
|
|
449
|
-
watcher = new FSWatcher({
|
|
450
|
-
ignoreInitial: true,
|
|
451
|
-
persistent: true,
|
|
452
|
-
ignored: [outDir]
|
|
453
|
-
});
|
|
454
|
-
watcher.add(configPath);
|
|
455
|
-
for (const collection of core.getCollections(true)) {
|
|
456
|
-
const handler = collection.handlers.fs;
|
|
457
|
-
if (handler) watcher.add(handler.dir);
|
|
458
|
-
}
|
|
459
|
-
watcher.once("ready", () => {
|
|
460
|
-
console.log("[MDX] started dev server");
|
|
461
|
-
});
|
|
462
|
-
watcher.on("all", (_event, file) => {
|
|
463
|
-
if (node_path.resolve(file) === absoluteConfigPath) {
|
|
464
|
-
console.log("[MDX] restarting dev server");
|
|
465
|
-
watcher?.removeAllListeners();
|
|
466
|
-
(async () => {
|
|
467
|
-
await core.init({ config: loadConfig(core, true) });
|
|
468
|
-
await devServer();
|
|
469
|
-
await core.emit({ write: true });
|
|
470
|
-
})();
|
|
471
|
-
}
|
|
472
|
-
});
|
|
473
|
-
await core.initServer({ watcher });
|
|
474
|
-
}
|
|
475
|
-
process.on("exit", () => {
|
|
476
|
-
if (!watcher || watcher.closed) return;
|
|
477
|
-
console.log("[MDX] closing dev server");
|
|
478
|
-
watcher.close();
|
|
479
|
-
});
|
|
480
|
-
await devServer();
|
|
481
|
-
}
|
|
482
|
-
async function createStandaloneCore(options) {
|
|
483
|
-
const core = createNextCore(applyDefaults(options));
|
|
484
|
-
await core.init({ config: loadConfig(core, true) });
|
|
485
|
-
return core;
|
|
486
|
-
}
|
|
487
|
-
function applyDefaults(options) {
|
|
488
|
-
return {
|
|
489
|
-
outDir: options.outDir ?? Core.defaultOptions.outDir,
|
|
490
|
-
configPath: options.configPath ?? Core.defaultOptions.configPath
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
function createNextCore(options) {
|
|
494
|
-
return new Core({
|
|
495
|
-
outDir: options.outDir,
|
|
496
|
-
configPath: options.configPath
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
//#endregion
|
|
501
|
-
exports.createContent = createContent;
|
|
502
|
-
exports.createStandaloneCore = createStandaloneCore;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-CGIIJIcs.js","names":[],"sources":["../src/plugins/with-loader/node.ts"],"sourcesContent":["import type { LoadFnOutput, LoadHook } from \"node:module\";\nimport { fileURLToPath } from \"node:url\";\nimport fs from \"node:fs/promises\";\nimport type { Loader } from \"@/plugins/with-loader\";\n\nexport function toNode(test: RegExp | undefined, loader: Loader): LoadHook {\n return async (url, _context, nextLoad): Promise<LoadFnOutput> => {\n if (url.startsWith(\"file:///\") && (!test || test.test(url))) {\n const parsedUrl = new URL(url);\n const filePath = fileURLToPath(parsedUrl);\n\n const result = await loader.load({\n filePath,\n query: Object.fromEntries(parsedUrl.searchParams.entries()),\n async getSource() {\n return (await fs.readFile(filePath)).toString();\n },\n development: false,\n compiler: {\n addDependency() {},\n },\n });\n\n if (result) {\n return {\n source: result.code,\n format: \"module\",\n shortCircuit: true,\n };\n }\n }\n\n return nextLoad(url);\n };\n}\n"],"mappings":";;;;AAKA,SAAgB,OAAO,MAA0B,QAA0B;AACzE,QAAO,OAAO,KAAK,UAAU,aAAoC;AAC/D,MAAI,IAAI,WAAW,WAAW,KAAK,CAAC,QAAQ,KAAK,KAAK,IAAI,GAAG;GAC3D,MAAM,YAAY,IAAI,IAAI,IAAI;GAC9B,MAAM,WAAW,cAAc,UAAU;GAEzC,MAAM,SAAS,MAAM,OAAO,KAAK;IAC/B;IACA,OAAO,OAAO,YAAY,UAAU,aAAa,SAAS,CAAC;IAC3D,MAAM,YAAY;AAChB,aAAQ,MAAM,GAAG,SAAS,SAAS,EAAE,UAAU;;IAEjD,aAAa;IACb,UAAU,EACR,gBAAgB,IACjB;IACF,CAAC;AAEF,OAAI,OACF,QAAO;IACL,QAAQ,OAAO;IACf,QAAQ;IACR,cAAc;IACf;;AAIL,SAAO,SAAS,IAAI"}
|
package/dist/pipe-5cnvE6KY.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
//#region src/utils/pipe.ts
|
|
2
|
-
function pipe() {
|
|
3
|
-
const steps = [];
|
|
4
|
-
return {
|
|
5
|
-
run(data, ctx) {
|
|
6
|
-
for (const step of steps) data = step(data, ctx);
|
|
7
|
-
return data;
|
|
8
|
-
},
|
|
9
|
-
pipe(fn) {
|
|
10
|
-
steps.push(fn);
|
|
11
|
-
return this;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function asyncPipe() {
|
|
16
|
-
const steps = [];
|
|
17
|
-
return {
|
|
18
|
-
async run(data, ctx) {
|
|
19
|
-
for (const step of steps) data = await step(data, ctx);
|
|
20
|
-
return data;
|
|
21
|
-
},
|
|
22
|
-
pipe(fn) {
|
|
23
|
-
steps.push(fn);
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
export { pipe as n, asyncPipe as t };
|
|
31
|
-
//# sourceMappingURL=pipe-5cnvE6KY.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pipe-5cnvE6KY.js","names":["steps: ((data: Data, context: Context) => Data)[]","steps: ((data: Data, context: Context) => Awaitable<Data>)[]"],"sources":["../src/utils/pipe.ts"],"sourcesContent":["import type { Awaitable } from \"@/types\";\n\nexport interface Pipe<Data, Context = undefined> {\n /**\n * add a transformation step\n *\n * @returns the same pipe instance\n */\n pipe: (fn: (data: Data, context: Context) => Data) => Pipe<Data, Context>;\n run: (data: Data, context: Context) => Data;\n}\n\nexport interface AsyncPipe<Data, Context = undefined> {\n /**\n * add a transformation step\n *\n * @returns the same pipe instance\n */\n pipe: (\n fn: (data: Data, context: Context) => Awaitable<Data>,\n ) => AsyncPipe<Data, Context>;\n run: (data: Data, context: Context) => Awaitable<Data>;\n}\n\nexport function pipe<Data, Context>(): Pipe<Data, Context> {\n const steps: ((data: Data, context: Context) => Data)[] = [];\n return {\n run(data, ctx) {\n for (const step of steps) {\n data = step(data, ctx);\n }\n return data;\n },\n pipe(fn) {\n steps.push(fn);\n return this;\n },\n };\n}\n\nexport function asyncPipe<Data, Context>(): AsyncPipe<Data, Context> {\n const steps: ((data: Data, context: Context) => Awaitable<Data>)[] = [];\n return {\n async run(data, ctx) {\n for (const step of steps) {\n data = await step(data, ctx);\n }\n return data;\n },\n pipe(fn) {\n steps.push(fn);\n return this;\n },\n };\n}\n"],"mappings":";AAwBA,SAAgB,OAA2C;CACzD,MAAMA,QAAoD,EAAE;AAC5D,QAAO;EACL,IAAI,MAAM,KAAK;AACb,QAAK,MAAM,QAAQ,MACjB,QAAO,KAAK,MAAM,IAAI;AAExB,UAAO;;EAET,KAAK,IAAI;AACP,SAAM,KAAK,GAAG;AACd,UAAO;;EAEV;;AAGH,SAAgB,YAAqD;CACnE,MAAMC,QAA+D,EAAE;AACvE,QAAO;EACL,MAAM,IAAI,MAAM,KAAK;AACnB,QAAK,MAAM,QAAQ,MACjB,QAAO,MAAM,KAAK,MAAM,IAAI;AAE9B,UAAO;;EAET,KAAK,IAAI;AACP,SAAM,KAAK,GAAG;AACd,UAAO;;EAEV"}
|
package/dist/plugins/git.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","names":["client: VersionControlClient"],"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\";\n\nexport interface VersionControlFileData {\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 VersionControlHandler {\n /**\n * receive the version control client.\n */\n client: (context: { client: VersionControlClient }) => void | Promise<void>;\n}\n\nexport interface GitPluginOptions {\n /**\n * Filter the collections to include by names\n */\n filter?: (collection: string) => boolean;\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(options: GitPluginOptions = {}): Plugin {\n const { filter = () => true } = options;\n let client: VersionControlClient;\n\n return {\n name: \"git\",\n config() {\n const { workspace } = this.core.getOptions();\n const cwd = workspace ? path.resolve(workspace.dir) : process.cwd();\n\n client = createGitClient(cwd);\n },\n collection(collection) {\n if (!filter(collection.name)) return;\n\n const handler = collection.handlers[\"version-control\"];\n if (!handler) return;\n return handler.client({ client });\n },\n };\n}\n\nexport interface VersionControlClient {\n getFileData: (options: {\n filePath: string;\n }) => Promise<VersionControlFileData>;\n}\n\nfunction createGitClient(cwd: string): VersionControlClient {\n const cache = createCache<VersionControlFileData>();\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(\n \"git\",\n [\n \"log\",\n \"--diff-filter=A\",\n \"--follow\",\n \"--format=%ai\",\n \"-1\",\n relativePath,\n ],\n {\n nodeOptions: {\n cwd,\n },\n },\n ),\n ]);\n\n return {\n lastModified: mapDate(mod),\n creationDate: mapDate(create),\n };\n });\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAoCA,SAAwB,IAAI,UAA4B,EAAE,EAAU;CAClE,MAAM,EAAE,eAAe,SAAS;CAChC,IAAIA;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP,MAAM,EAAE,cAAc,KAAK,KAAK,YAAY;AAG5C,YAAS,gBAFG,YAAY,KAAK,QAAQ,UAAU,IAAI,GAAG,QAAQ,KAAK,CAEtC;;EAE/B,WAAW,YAAY;AACrB,OAAI,CAAC,OAAO,WAAW,KAAK,CAAE;GAE9B,MAAM,UAAU,WAAW,SAAS;AACpC,OAAI,CAAC,QAAS;AACd,UAAO,QAAQ,OAAO,EAAE,QAAQ,CAAC;;EAEpC;;AASH,SAAS,gBAAgB,KAAmC;CAC1D,MAAM,QAAQ,aAAqC;CAEnD,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,EACE,OACA;IACE;IACA;IACA;IACA;IACA;IACA;IACD,EACD,EACE,aAAa,EACX,KACD,EACF,CACF,CACF,CAAC;AAEF,UAAO;IACL,cAAc,QAAQ,IAAI;IAC1B,cAAc,QAAQ,OAAO;IAC9B;IACD;IAEL"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//#region src/plugins/with-loader/index.ts
|
|
2
|
-
/**
|
|
3
|
-
* a light layer for implementing loaders.
|
|
4
|
-
*
|
|
5
|
-
* @remarks it doesn't include Next.js, you have to define the webpack/turbopack config, and export the loaders on your own.
|
|
6
|
-
*/
|
|
7
|
-
function withLoader(plugin, { test, createLoader }) {
|
|
8
|
-
let loader;
|
|
9
|
-
return {
|
|
10
|
-
bun: { async build(build) {
|
|
11
|
-
const { toBun } = await import("../../bun-QKQnqgIi.js");
|
|
12
|
-
toBun(test, await (loader ??= createLoader.call(this, "bun")))(build);
|
|
13
|
-
} },
|
|
14
|
-
node: { async createLoad() {
|
|
15
|
-
const { toNode } = await import("../../node-CGIIJIcs.js");
|
|
16
|
-
return toNode(test, await (loader ??= createLoader.call(this, "node")));
|
|
17
|
-
} },
|
|
18
|
-
vite: { async createPlugin() {
|
|
19
|
-
const { toVite } = await import("../../vite-X-2Al8fq.js");
|
|
20
|
-
return toVite(plugin.name, test, await (loader ??= createLoader.call(this, "vite")));
|
|
21
|
-
} },
|
|
22
|
-
...plugin
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
export { withLoader };
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["loader: Promise<Loader> | undefined"],"sources":["../../../src/plugins/with-loader/index.ts"],"sourcesContent":["import type { Plugin, PluginContext } from \"@/core\";\n\ntype Awaitable<T> = T | Promise<T>;\n\nexport interface CompilerOptions {\n addDependency: (file: string) => void;\n}\n\ntype LoaderEnvironment = \"vite\" | \"bun\" | \"node\";\n\nexport interface Loader {\n /**\n * Transform input into JavaScript.\n *\n * Returns:\n * - `LoaderOutput`: JavaScript code & source map.\n * - `null`: skip the loader. Fallback to default behaviour if possible, otherwise the adapter will try workarounds.\n */\n load: (input: LoaderInput) => Awaitable<LoaderOutput | null>;\n\n bun?: {\n /**\n * 1. Bun doesn't allow `null` in loaders.\n * 2. Bun requires sync result to support dynamic require().\n */\n load?: (source: string, input: LoaderInput) => Awaitable<Bun.OnLoadResult>;\n };\n}\n\nexport interface LoaderInput {\n development: boolean;\n compiler: CompilerOptions;\n\n filePath: string;\n query: Record<string, string | string[] | undefined>;\n getSource: () => string | Promise<string>;\n}\n\nexport interface LoaderOutput {\n code: string;\n map?: unknown;\n}\n\nexport interface WithLoaderConfig {\n /**\n * Filter file paths, the input can be either a file URL or file path.\n *\n * Must take resource query into consideration.\n */\n test?: RegExp;\n\n createLoader: (\n this: PluginContext,\n environment: LoaderEnvironment,\n ) => Promise<Loader>;\n}\n\n/**\n * a light layer for implementing loaders.\n *\n * @remarks it doesn't include Next.js, you have to define the webpack/turbopack config, and export the loaders on your own.\n */\nexport function withLoader(\n plugin: Plugin,\n { test, createLoader }: WithLoaderConfig,\n): Plugin {\n let loader: Promise<Loader> | undefined;\n\n return {\n bun: {\n async build(build) {\n const { toBun } = await import(\"./bun\");\n toBun(test, await (loader ??= createLoader.call(this, \"bun\")))(build);\n },\n },\n node: {\n async createLoad() {\n const { toNode } = await import(\"./node\");\n return toNode(test, await (loader ??= createLoader.call(this, \"node\")));\n },\n },\n vite: {\n async createPlugin() {\n const { toVite } = await import(\"./vite\");\n return toVite(\n plugin.name,\n test,\n await (loader ??= createLoader.call(this, \"vite\")),\n );\n },\n },\n ...plugin,\n };\n}\n"],"mappings":";;;;;;AA8DA,SAAgB,WACd,QACA,EAAE,MAAM,gBACA;CACR,IAAIA;AAEJ,QAAO;EACL,KAAK,EACH,MAAM,MAAM,OAAO;GACjB,MAAM,EAAE,UAAU,MAAM,OAAO;AAC/B,SAAM,MAAM,OAAO,WAAW,aAAa,KAAK,MAAM,MAAM,EAAE,CAAC,MAAM;KAExE;EACD,MAAM,EACJ,MAAM,aAAa;GACjB,MAAM,EAAE,WAAW,MAAM,OAAO;AAChC,UAAO,OAAO,MAAM,OAAO,WAAW,aAAa,KAAK,MAAM,OAAO,EAAE;KAE1E;EACD,MAAM,EACJ,MAAM,eAAe;GACnB,MAAM,EAAE,WAAW,MAAM,OAAO;AAChC,UAAO,OACL,OAAO,MACP,MACA,OAAO,WAAW,aAAa,KAAK,MAAM,OAAO,EAClD;KAEJ;EACD,GAAG;EACJ"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { L as Loader, t as Core } from "../../core-Bkh-SI_3.js";
|
|
2
|
-
import { LoaderContext } from "webpack";
|
|
3
|
-
|
|
4
|
-
//#region src/plugins/with-loader/webpack.d.ts
|
|
5
|
-
type WebpackLoader = (this: LoaderContext<unknown>, source: string, callback: LoaderContext<unknown>["callback"]) => Promise<void>;
|
|
6
|
-
interface WebpackLoaderOptions {
|
|
7
|
-
absoluteCompiledConfigPath: string;
|
|
8
|
-
configPath: string;
|
|
9
|
-
outDir: string;
|
|
10
|
-
isDev: boolean;
|
|
11
|
-
}
|
|
12
|
-
declare function getCore(options: WebpackLoaderOptions): Core;
|
|
13
|
-
/**
|
|
14
|
-
* need to handle the `test` regex in Webpack config instead.
|
|
15
|
-
*/
|
|
16
|
-
declare function toWebpack(loader: Loader): WebpackLoader;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { WebpackLoader, WebpackLoaderOptions, getCore, toWebpack };
|
|
19
|
-
//# sourceMappingURL=webpack.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.d.ts","names":[],"sources":["../../../src/plugins/with-loader/webpack.ts"],"sourcesContent":[],"mappings":";;;;KAOY,aAAA,UACJ,kDAEI,uCACP;AAJO,UAMK,oBAAA,CANQ;EACjB,0BAAA,EAAA,MAAA;EAEI,UAAA,EAAA,MAAA;EACP,MAAA,EAAA,MAAA;EAAO,KAAA,EAAA,OAAA;AAEZ;AASgB,iBAAA,OAAA,CAAiB,OAAA,EAAA,oBAAoB,CAAA,EAAA,IAAA;AAUrD;;;iBAAgB,SAAA,SAAkB,SAAS"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import "../../code-generator-gPtrfZ6Q.js";
|
|
2
|
-
import { t as Core } from "../../core-ZuoVBkeg.js";
|
|
3
|
-
import { t as ValidationError } from "../../validation-BOJKRAp5.js";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { parse } from "node:querystring";
|
|
6
|
-
|
|
7
|
-
//#region src/plugins/with-loader/webpack.ts
|
|
8
|
-
let core;
|
|
9
|
-
function getCore(options) {
|
|
10
|
-
return core ??= new Core({
|
|
11
|
-
outDir: options.outDir,
|
|
12
|
-
configPath: options.configPath
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* need to handle the `test` regex in Webpack config instead.
|
|
17
|
-
*/
|
|
18
|
-
function toWebpack(loader) {
|
|
19
|
-
return async function(source, callback) {
|
|
20
|
-
try {
|
|
21
|
-
const result = await loader.load({
|
|
22
|
-
filePath: this.resourcePath,
|
|
23
|
-
query: parse(this.resourceQuery.slice(1)),
|
|
24
|
-
getSource() {
|
|
25
|
-
return source;
|
|
26
|
-
},
|
|
27
|
-
development: this.mode === "development",
|
|
28
|
-
compiler: this
|
|
29
|
-
});
|
|
30
|
-
if (result === null) callback(void 0, source);
|
|
31
|
-
else callback(void 0, result.code, result.map);
|
|
32
|
-
} catch (error) {
|
|
33
|
-
if (error instanceof ValidationError) return callback(new Error(await error.toStringFormatted()));
|
|
34
|
-
if (!(error instanceof Error)) throw error;
|
|
35
|
-
error.message = `${path.relative(this.context, this.resourcePath)}:${error.name}: ${error.message}`;
|
|
36
|
-
callback(error);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
export { getCore, toWebpack };
|
|
43
|
-
//# sourceMappingURL=webpack.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.js","names":["core: Core"],"sources":["../../../src/plugins/with-loader/webpack.ts"],"sourcesContent":["import type { LoaderContext } from \"webpack\";\nimport { parse } from \"node:querystring\";\nimport { ValidationError } from \"@/utils/validation\";\nimport path from \"node:path\";\nimport type { Loader } from \"@/plugins/with-loader\";\nimport { Core } from \"@/core\";\n\nexport type WebpackLoader = (\n this: LoaderContext<unknown>,\n source: string,\n callback: LoaderContext<unknown>[\"callback\"],\n) => Promise<void>;\n\nexport interface WebpackLoaderOptions {\n absoluteCompiledConfigPath: string;\n configPath: string;\n outDir: string;\n isDev: boolean;\n}\n\nlet core: Core;\n\nexport function getCore(options: WebpackLoaderOptions) {\n return (core ??= new Core({\n outDir: options.outDir,\n configPath: options.configPath,\n }));\n}\n\n/**\n * need to handle the `test` regex in Webpack config instead.\n */\nexport function toWebpack(loader: Loader): WebpackLoader {\n return async function (source, callback) {\n try {\n const result = await loader.load({\n filePath: this.resourcePath,\n query: parse(this.resourceQuery.slice(1)),\n getSource() {\n return source;\n },\n development: this.mode === \"development\",\n compiler: this,\n });\n\n if (result === null) {\n callback(undefined, source);\n } else {\n callback(undefined, result.code, result.map as string);\n }\n } catch (error) {\n if (error instanceof ValidationError) {\n return callback(new Error(await error.toStringFormatted()));\n }\n\n if (!(error instanceof Error)) throw error;\n\n const fpath = path.relative(this.context, this.resourcePath);\n error.message = `${fpath}:${error.name}: ${error.message}`;\n callback(error);\n }\n };\n}\n"],"mappings":";;;;;;;AAoBA,IAAIA;AAEJ,SAAgB,QAAQ,SAA+B;AACrD,QAAQ,SAAS,IAAI,KAAK;EACxB,QAAQ,QAAQ;EAChB,YAAY,QAAQ;EACrB,CAAC;;;;;AAMJ,SAAgB,UAAU,QAA+B;AACvD,QAAO,eAAgB,QAAQ,UAAU;AACvC,MAAI;GACF,MAAM,SAAS,MAAM,OAAO,KAAK;IAC/B,UAAU,KAAK;IACf,OAAO,MAAM,KAAK,cAAc,MAAM,EAAE,CAAC;IACzC,YAAY;AACV,YAAO;;IAET,aAAa,KAAK,SAAS;IAC3B,UAAU;IACX,CAAC;AAEF,OAAI,WAAW,KACb,UAAS,QAAW,OAAO;OAE3B,UAAS,QAAW,OAAO,MAAM,OAAO,IAAc;WAEjD,OAAO;AACd,OAAI,iBAAiB,gBACnB,QAAO,SAAS,IAAI,MAAM,MAAM,MAAM,mBAAmB,CAAC,CAAC;AAG7D,OAAI,EAAE,iBAAiB,OAAQ,OAAM;AAGrC,SAAM,UAAU,GADF,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACnC,GAAG,MAAM,KAAK,IAAI,MAAM;AACjD,YAAS,MAAM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"store-0LQ2PlH6.js","names":[],"sources":["../src/collections/runtime/store.ts"],"sourcesContent":["import type { Awaitable } from \"@/types\";\n\nexport interface CollectionStore<Id, Data> {\n /**\n * type-only operation to change data type, doesn't do any runtime transformation.\n */\n $data: <T>(_cast: (input: Data) => T) => CollectionStore<Id, T>;\n\n get: (id: Id) => Awaitable<Data | undefined>;\n list: () => Awaitable<Data[]>;\n\n /**\n * For typescript to infer data types, can be anything\n */\n $inferData: Data;\n}\n\nexport class SimpleCollectionStore<Data> implements CollectionStore<\n string,\n Data\n> {\n private readonly dataMap: Map<string, Data>;\n private readonly dataList: Data[];\n\n constructor(input: Map<string, Data>) {\n this.dataMap = input;\n this.dataList = Array.from(input.values());\n }\n\n get(id: string): Data | undefined {\n return this.dataMap.get(id);\n }\n\n list(): Data[] {\n return this.dataList;\n }\n\n $data<T>(_cast: (input: Data) => T): SimpleCollectionStore<T> {\n return this as unknown as SimpleCollectionStore<T>;\n }\n\n /**\n * in-place transformation on all data\n */\n transform<T>(fn: (input: Data) => T): SimpleCollectionStore<T> {\n this.dataList.length = 0;\n const dataMap = this.dataMap as unknown as Map<string, T>;\n const dataList = this.dataList as unknown as T[];\n\n for (const [k, v] of this.dataMap) {\n const updated = fn(v);\n dataMap.set(k, updated);\n dataList.push(updated);\n }\n\n return this as unknown as SimpleCollectionStore<T>;\n }\n\n get $inferData(): Data {\n return undefined as Data;\n }\n}\n"],"mappings":";AAiBA,IAAa,wBAAb,MAGE;CACA,AAAiB;CACjB,AAAiB;CAEjB,YAAY,OAA0B;AACpC,OAAK,UAAU;AACf,OAAK,WAAW,MAAM,KAAK,MAAM,QAAQ,CAAC;;CAG5C,IAAI,IAA8B;AAChC,SAAO,KAAK,QAAQ,IAAI,GAAG;;CAG7B,OAAe;AACb,SAAO,KAAK;;CAGd,MAAS,OAAqD;AAC5D,SAAO;;;;;CAMT,UAAa,IAAkD;AAC7D,OAAK,SAAS,SAAS;EACvB,MAAM,UAAU,KAAK;EACrB,MAAM,WAAW,KAAK;AAEtB,OAAK,MAAM,CAAC,GAAG,MAAM,KAAK,SAAS;GACjC,MAAM,UAAU,GAAG,EAAE;AACrB,WAAQ,IAAI,GAAG,QAAQ;AACvB,YAAS,KAAK,QAAQ;;AAGxB,SAAO;;CAGT,IAAI,aAAmB"}
|