fuma-content 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/async-cache-BM9Yf4Nw.js +29 -0
- package/dist/async-cache-BM9Yf4Nw.js.map +1 -0
- package/dist/bin.d.ts +1 -1
- package/dist/bin.js +21 -14
- package/dist/bin.js.map +1 -0
- package/dist/build-D8A5ByFk.js +42 -0
- package/dist/build-D8A5ByFk.js.map +1 -0
- package/dist/build-mdx-C1PZsGp2.js +395 -0
- package/dist/build-mdx-C1PZsGp2.js.map +1 -0
- package/dist/build-mdx-DFndaVbS.js +4 -0
- package/dist/bun/index.d.ts +6 -13
- package/dist/bun/index.d.ts.map +1 -0
- package/dist/bun/index.js +23 -34
- package/dist/bun/index.js.map +1 -0
- package/dist/bun-QKQnqgIi.js +35 -0
- package/dist/bun-QKQnqgIi.js.map +1 -0
- package/dist/code-generator-gPtrfZ6Q.js +133 -0
- package/dist/code-generator-gPtrfZ6Q.js.map +1 -0
- package/dist/collections/handlers/fs.d.ts +2 -10
- package/dist/collections/handlers/fs.js +28 -6
- package/dist/collections/handlers/fs.js.map +1 -0
- package/dist/collections/index.d.ts +2 -10
- package/dist/collections/index.js +16 -6
- package/dist/collections/index.js.map +1 -0
- package/dist/collections/mdx/loader-webpack.d.ts +6 -14
- package/dist/collections/mdx/loader-webpack.d.ts.map +1 -0
- package/dist/collections/mdx/loader-webpack.js +23 -36
- package/dist/collections/mdx/loader-webpack.js.map +1 -0
- package/dist/collections/mdx/runtime-browser.d.ts +27 -37
- package/dist/collections/mdx/runtime-browser.d.ts.map +1 -0
- package/dist/collections/mdx/runtime-browser.js +57 -70
- package/dist/collections/mdx/runtime-browser.js.map +1 -0
- package/dist/collections/mdx/runtime-dynamic.d.ts +22 -30
- package/dist/collections/mdx/runtime-dynamic.d.ts.map +1 -0
- package/dist/collections/mdx/runtime-dynamic.js +63 -85
- package/dist/collections/mdx/runtime-dynamic.js.map +1 -0
- package/dist/collections/mdx/runtime.d.ts +31 -52
- package/dist/collections/mdx/runtime.d.ts.map +1 -0
- package/dist/collections/mdx/runtime.js +24 -34
- package/dist/collections/mdx/runtime.js.map +1 -0
- package/dist/collections/mdx.d.ts +2 -10
- package/dist/collections/mdx.js +240 -284
- package/dist/collections/mdx.js.map +1 -0
- package/dist/collections/meta/loader-webpack.d.ts +6 -14
- package/dist/collections/meta/loader-webpack.d.ts.map +1 -0
- package/dist/collections/meta/loader-webpack.js +25 -39
- package/dist/collections/meta/loader-webpack.js.map +1 -0
- package/dist/collections/meta/runtime.d.ts +7 -15
- package/dist/collections/meta/runtime.d.ts.map +1 -0
- package/dist/collections/meta/runtime.js +9 -15
- package/dist/collections/meta/runtime.js.map +1 -0
- package/dist/collections/meta.d.ts +2 -10
- package/dist/collections/meta.js +128 -164
- package/dist/collections/meta.js.map +1 -0
- package/dist/collections/runtime/file-store.d.ts +17 -14
- package/dist/collections/runtime/file-store.d.ts.map +1 -0
- package/dist/collections/runtime/file-store.js +30 -6
- package/dist/collections/runtime/file-store.js.map +1 -0
- package/dist/collections/runtime/store.d.ts +3 -28
- package/dist/collections/runtime/store.js +3 -6
- package/dist/config/index.d.ts +2 -10
- package/dist/config/index.js +6 -5
- package/dist/config/index.js.map +1 -0
- package/dist/core-Bkh-SI_3.d.ts +561 -0
- package/dist/core-Bkh-SI_3.d.ts.map +1 -0
- package/dist/core-ZuoVBkeg.js +170 -0
- package/dist/core-ZuoVBkeg.js.map +1 -0
- package/dist/dynamic-B40uAtdo.js +28 -0
- package/dist/dynamic-B40uAtdo.js.map +1 -0
- package/dist/fuma-matter-O4fA6nSx.js +27 -0
- package/dist/fuma-matter-O4fA6nSx.js.map +1 -0
- package/dist/index.d.ts +13 -16
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -8
- package/dist/load-from-file-1f4WaHsf.js +38 -0
- package/dist/load-from-file-1f4WaHsf.js.map +1 -0
- package/dist/load-from-file-BTNnBu6f.js +3 -0
- package/dist/loader-80abXEHx.js +4 -0
- package/dist/loader-BFhPyg3z.js +4 -0
- package/dist/loader-CXnMFuyE.js +80 -0
- package/dist/loader-CXnMFuyE.js.map +1 -0
- package/dist/loader-gk94iHf5.js +66 -0
- package/dist/loader-gk94iHf5.js.map +1 -0
- package/dist/next/index.cjs +459 -551
- package/dist/next/index.d.ts +16 -22
- package/dist/next/index.d.ts.map +1 -0
- package/dist/next/index.js +71 -89
- package/dist/next/index.js.map +1 -0
- package/dist/node/loader.d.ts +4 -2
- package/dist/node/loader.d.ts.map +1 -0
- package/dist/node/loader.js +32 -44
- package/dist/node/loader.js.map +1 -0
- package/dist/node-CGIIJIcs.js +31 -0
- package/dist/node-CGIIJIcs.js.map +1 -0
- package/dist/pipe-5cnvE6KY.js +31 -0
- package/dist/pipe-5cnvE6KY.js.map +1 -0
- package/dist/plugins/git.d.ts +2 -10
- package/dist/plugins/git.js +57 -65
- package/dist/plugins/git.js.map +1 -0
- package/dist/plugins/json-schema.d.ts +2 -10
- package/dist/plugins/json-schema.js +60 -58
- package/dist/plugins/json-schema.js.map +1 -0
- package/dist/plugins/with-loader/index.d.ts +2 -61
- package/dist/plugins/with-loader/index.js +28 -6
- package/dist/plugins/with-loader/index.js.map +1 -0
- package/dist/plugins/with-loader/webpack.d.ts +10 -18
- package/dist/plugins/with-loader/webpack.d.ts.map +1 -0
- package/dist/plugins/with-loader/webpack.js +43 -12
- package/dist/plugins/with-loader/webpack.js.map +1 -0
- package/dist/store-0LQ2PlH6.js +37 -0
- package/dist/store-0LQ2PlH6.js.map +1 -0
- package/dist/store-DEjYYF6a.d.ts +31 -0
- package/dist/store-DEjYYF6a.d.ts.map +1 -0
- package/dist/validation-BOJKRAp5.js +28 -0
- package/dist/validation-BOJKRAp5.js.map +1 -0
- package/dist/vite/index.d.ts +22 -28
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +37 -52
- package/dist/vite/index.js.map +1 -0
- package/dist/vite-X-2Al8fq.js +32 -0
- package/dist/vite-X-2Al8fq.js.map +1 -0
- package/package.json +7 -6
- package/dist/build-mdx-I4NROXCF.js +0 -8
- package/dist/bun-DMNX4PBC.js +0 -40
- package/dist/chunk-3VQS3KSP.js +0 -39
- package/dist/chunk-BTRE6MOX.js +0 -16
- package/dist/chunk-E4HRKSP4.js +0 -24
- package/dist/chunk-ERBMAQYP.js +0 -33
- package/dist/chunk-GGL4EF6H.js +0 -38
- package/dist/chunk-JBZTQ55D.js +0 -30
- package/dist/chunk-KH5GT2Y5.js +0 -104
- package/dist/chunk-LUM7SIZN.js +0 -40
- package/dist/chunk-MT7RY65Y.js +0 -167
- package/dist/chunk-NRZ4GE5O.js +0 -207
- package/dist/chunk-OQQNA7L7.js +0 -412
- package/dist/chunk-OUJENWQ4.js +0 -45
- package/dist/chunk-RMSV4HP6.js +0 -85
- package/dist/chunk-RXR7OL76.js +0 -37
- package/dist/chunk-VWJKRQZR.js +0 -19
- package/dist/chunk-W6HENTK7.js +0 -44
- package/dist/chunk-XR5N6ZXJ.js +0 -50
- package/dist/core-Bo8KaWQz.d.ts +0 -411
- package/dist/load-from-file-HL2VEY3M.js +0 -7
- package/dist/loader-NFSL6P5I.js +0 -7
- package/dist/loader-T756NSCS.js +0 -7
- package/dist/node-DCMYL4DL.js +0 -34
- package/dist/vite-QCUPZHHB.js +0 -32
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/utils/async-cache.ts
|
|
2
|
+
/**
|
|
3
|
+
* cache for async resources, finished promises will be resolved into original value, otherwise wrapped with a promise.
|
|
4
|
+
*/
|
|
5
|
+
function createCache(store = /* @__PURE__ */ new Map()) {
|
|
6
|
+
return {
|
|
7
|
+
cached(key, fn) {
|
|
8
|
+
let cached = store.get(key);
|
|
9
|
+
if (cached) return cached;
|
|
10
|
+
cached = fn();
|
|
11
|
+
if (cached instanceof Promise) cached = cached.then((out) => {
|
|
12
|
+
if (store.has(key)) store.set(key, out);
|
|
13
|
+
return out;
|
|
14
|
+
});
|
|
15
|
+
store.set(key, cached);
|
|
16
|
+
return cached;
|
|
17
|
+
},
|
|
18
|
+
invalidate(key) {
|
|
19
|
+
store.delete(key);
|
|
20
|
+
},
|
|
21
|
+
$value() {
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { createCache as t };
|
|
29
|
+
//# sourceMappingURL=async-cache-BM9Yf4Nw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-cache-BM9Yf4Nw.js","names":[],"sources":["../src/utils/async-cache.ts"],"sourcesContent":["export interface AsyncCache<V> {\n cached: (key: string, fn: () => V | Promise<V>) => V | Promise<V>;\n $value: <T>() => AsyncCache<T>;\n invalidate: (key: string) => void;\n}\n\n/**\n * cache for async resources, finished promises will be resolved into original value, otherwise wrapped with a promise.\n */\nexport function createCache<V>(\n store = new Map<string, V | Promise<V>>(),\n): AsyncCache<V> {\n return {\n cached(key, fn) {\n let cached = store.get(key);\n if (cached) return cached;\n\n cached = fn();\n if (cached instanceof Promise) {\n cached = cached.then((out) => {\n // replace with resolved if still exists\n if (store.has(key)) {\n store.set(key, out);\n }\n\n return out;\n });\n }\n store.set(key, cached);\n return cached;\n },\n invalidate(key) {\n store.delete(key);\n },\n $value<T>() {\n return this as unknown as AsyncCache<T>;\n },\n };\n}\n"],"mappings":";;;;AASA,SAAgB,YACd,wBAAQ,IAAI,KAA6B,EAC1B;AACf,QAAO;EACL,OAAO,KAAK,IAAI;GACd,IAAI,SAAS,MAAM,IAAI,IAAI;AAC3B,OAAI,OAAQ,QAAO;AAEnB,YAAS,IAAI;AACb,OAAI,kBAAkB,QACpB,UAAS,OAAO,MAAM,QAAQ;AAE5B,QAAI,MAAM,IAAI,IAAI,CAChB,OAAM,IAAI,KAAK,IAAI;AAGrB,WAAO;KACP;AAEJ,SAAM,IAAI,KAAK,OAAO;AACtB,UAAO;;EAET,WAAW,KAAK;AACd,SAAM,OAAO,IAAI;;EAEnB,SAAY;AACV,UAAO;;EAEV"}
|
package/dist/bin.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { };
|
package/dist/bin.js
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
import { existsSync } from "fs";
|
|
4
|
+
//#region src/bin.ts
|
|
5
5
|
async function start() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
const [configPath, outDir] = process.argv.slice(2);
|
|
7
|
+
if (existsSync("next.config.js") || existsSync("next.config.mjs") || existsSync("next.config.mts") || existsSync("next.config.ts")) {
|
|
8
|
+
const { createStandaloneCore } = await import("./next/index.js");
|
|
9
|
+
await (await createStandaloneCore({
|
|
10
|
+
configPath,
|
|
11
|
+
outDir
|
|
12
|
+
})).emit({ write: true });
|
|
13
|
+
} else {
|
|
14
|
+
const { createStandaloneCore } = await import("./vite/index.js");
|
|
15
|
+
await (await createStandaloneCore({
|
|
16
|
+
configPath,
|
|
17
|
+
outDir
|
|
18
|
+
})).emit({ write: true });
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
|
-
|
|
21
|
+
start();
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { };
|
|
25
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { existsSync } from \"node:fs\";\n\nasync function start() {\n const [configPath, outDir] = process.argv.slice(2);\n const isNext =\n existsSync(\"next.config.js\") ||\n existsSync(\"next.config.mjs\") ||\n existsSync(\"next.config.mts\") ||\n existsSync(\"next.config.ts\");\n\n if (isNext) {\n const { createStandaloneCore } = await import(\"./next\");\n const core = await createStandaloneCore({ configPath, outDir });\n await core.emit({ write: true });\n } else {\n const { createStandaloneCore } = await import(\"./vite\");\n const core = await createStandaloneCore({ configPath, outDir });\n await core.emit({ write: true });\n }\n}\n\nvoid start();\n"],"mappings":";;;;AAIA,eAAe,QAAQ;CACrB,MAAM,CAAC,YAAY,UAAU,QAAQ,KAAK,MAAM,EAAE;AAOlD,KALE,WAAW,iBAAiB,IAC5B,WAAW,kBAAkB,IAC7B,WAAW,kBAAkB,IAC7B,WAAW,iBAAiB,EAElB;EACV,MAAM,EAAE,yBAAyB,MAAM,OAAO;AAE9C,SADa,MAAM,qBAAqB;GAAE;GAAY;GAAQ,CAAC,EACpD,KAAK,EAAE,OAAO,MAAM,CAAC;QAC3B;EACL,MAAM,EAAE,yBAAyB,MAAM,OAAO;AAE9C,SADa,MAAM,qBAAqB;GAAE;GAAY;GAAQ,CAAC,EACpD,KAAK,EAAE,OAAO,MAAM,CAAC;;;AAI/B,OAAO"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/config/build.ts
|
|
2
|
+
/**
|
|
3
|
+
* @param config - either the default export or all exports of config file.
|
|
4
|
+
* @param workspace
|
|
5
|
+
*/
|
|
6
|
+
function buildConfig(config, workspace) {
|
|
7
|
+
const collections = /* @__PURE__ */ new Map();
|
|
8
|
+
const loaded = {};
|
|
9
|
+
let globalConfig;
|
|
10
|
+
if ("default" in config) {
|
|
11
|
+
globalConfig = config.default;
|
|
12
|
+
for (const [k, v] of Object.entries(config)) {
|
|
13
|
+
if (k === "default") continue;
|
|
14
|
+
globalConfig.collections ??= {};
|
|
15
|
+
globalConfig.collections[k] = v;
|
|
16
|
+
}
|
|
17
|
+
} else globalConfig = config;
|
|
18
|
+
if (globalConfig.collections) for (const [name, collection] of Object.entries(globalConfig.collections)) {
|
|
19
|
+
collection.init?.({
|
|
20
|
+
name,
|
|
21
|
+
workspace
|
|
22
|
+
});
|
|
23
|
+
collections.set(name, collection);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
...globalConfig,
|
|
27
|
+
collections,
|
|
28
|
+
workspaces: Object.fromEntries(Object.entries(loaded.workspaces ?? {}).map(([key, value]) => {
|
|
29
|
+
return [key, {
|
|
30
|
+
dir: value.dir,
|
|
31
|
+
config: buildConfig(value.config, {
|
|
32
|
+
...value,
|
|
33
|
+
name: key
|
|
34
|
+
})
|
|
35
|
+
}];
|
|
36
|
+
}))
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { buildConfig as t };
|
|
42
|
+
//# sourceMappingURL=build-D8A5ByFk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-D8A5ByFk.js","names":["loaded: GlobalConfig","globalConfig: GlobalConfig"],"sources":["../src/config/build.ts"],"sourcesContent":["import type { GlobalConfig, WorkspaceConfig } from \"@/config/index\";\nimport type { Collection } from \"@/collections\";\n\nexport interface LoadedConfig extends Omit<\n GlobalConfig,\n \"workspaces\" | \"collections\"\n> {\n collections: Map<string, Collection>;\n workspaces: Record<\n string,\n {\n dir: string;\n config: LoadedConfig;\n }\n >;\n}\n\n/**\n * @param config - either the default export or all exports of config file.\n * @param workspace\n */\nexport function buildConfig(\n config: Record<string, unknown>,\n workspace?: WorkspaceConfig,\n): LoadedConfig {\n const collections = new Map<string, Collection>();\n const loaded: GlobalConfig = {};\n let globalConfig: GlobalConfig;\n\n if (\"default\" in config) {\n globalConfig = config.default as GlobalConfig;\n for (const [k, v] of Object.entries(config)) {\n if (k === \"default\") continue;\n\n globalConfig.collections ??= {};\n globalConfig.collections[k] = v as Collection;\n }\n } else {\n globalConfig = config as GlobalConfig;\n }\n\n if (globalConfig.collections) {\n for (const [name, collection] of Object.entries(globalConfig.collections)) {\n collection.init?.({ name, workspace });\n collections.set(name, collection);\n }\n }\n\n return {\n ...globalConfig,\n collections,\n workspaces: Object.fromEntries(\n Object.entries(loaded.workspaces ?? {}).map(([key, value]) => {\n return [\n key,\n {\n dir: value.dir,\n config: buildConfig(value.config as Record<string, unknown>, {\n ...value,\n name: key,\n }),\n },\n ];\n }),\n ),\n };\n}\n"],"mappings":";;;;;AAqBA,SAAgB,YACd,QACA,WACc;CACd,MAAM,8BAAc,IAAI,KAAyB;CACjD,MAAMA,SAAuB,EAAE;CAC/B,IAAIC;AAEJ,KAAI,aAAa,QAAQ;AACvB,iBAAe,OAAO;AACtB,OAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,OAAO,EAAE;AAC3C,OAAI,MAAM,UAAW;AAErB,gBAAa,gBAAgB,EAAE;AAC/B,gBAAa,YAAY,KAAK;;OAGhC,gBAAe;AAGjB,KAAI,aAAa,YACf,MAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,aAAa,YAAY,EAAE;AACzE,aAAW,OAAO;GAAE;GAAM;GAAW,CAAC;AACtC,cAAY,IAAI,MAAM,WAAW;;AAIrC,QAAO;EACL,GAAG;EACH;EACA,YAAY,OAAO,YACjB,OAAO,QAAQ,OAAO,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW;AAC5D,UAAO,CACL,KACA;IACE,KAAK,MAAM;IACX,QAAQ,YAAY,MAAM,QAAmC;KAC3D,GAAG;KACH,MAAM;KACP,CAAC;IACH,CACF;IACD,CACH;EACF"}
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { t as createCache } from "./async-cache-BM9Yf4Nw.js";
|
|
2
|
+
import { t as fumaMatter } from "./fuma-matter-O4fA6nSx.js";
|
|
3
|
+
import * as path$1 from "node:path";
|
|
4
|
+
import * as fs$1 from "node:fs/promises";
|
|
5
|
+
import { createProcessor } from "@mdx-js/mdx";
|
|
6
|
+
import { VFile } from "vfile";
|
|
7
|
+
import { unified } from "unified";
|
|
8
|
+
import { visit } from "unist-util-visit";
|
|
9
|
+
import { toMarkdown } from "mdast-util-to-markdown";
|
|
10
|
+
import { valueToEstree } from "estree-util-value-to-estree";
|
|
11
|
+
import { removePosition } from "unist-util-remove-position";
|
|
12
|
+
import remarkMdx from "remark-mdx";
|
|
13
|
+
|
|
14
|
+
//#region src/collections/mdx/remark-unravel.ts
|
|
15
|
+
function remarkMarkAndUnravel() {
|
|
16
|
+
return (tree) => {
|
|
17
|
+
visit(tree, (node, index, parent) => {
|
|
18
|
+
let offset = -1;
|
|
19
|
+
let all = true;
|
|
20
|
+
let oneOrMore = false;
|
|
21
|
+
if (parent && typeof index === "number" && node.type === "paragraph") {
|
|
22
|
+
const children = node.children;
|
|
23
|
+
while (++offset < children.length) {
|
|
24
|
+
const child = children[offset];
|
|
25
|
+
if (child.type === "mdxJsxTextElement" || child.type === "mdxTextExpression") oneOrMore = true;
|
|
26
|
+
else if (child.type === "text" && child.value.trim().length === 0) {} else {
|
|
27
|
+
all = false;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (all && oneOrMore) {
|
|
32
|
+
offset = -1;
|
|
33
|
+
const newChildren = [];
|
|
34
|
+
while (++offset < children.length) {
|
|
35
|
+
const child = children[offset];
|
|
36
|
+
if (child.type === "mdxJsxTextElement") child.type = "mdxJsxFlowElement";
|
|
37
|
+
if (child.type === "mdxTextExpression") child.type = "mdxFlowExpression";
|
|
38
|
+
if (child.type === "text" && /^[\t\r\n ]+$/.test(String(child.value))) {} else newChildren.push(child);
|
|
39
|
+
}
|
|
40
|
+
parent.children.splice(index, 1, ...newChildren);
|
|
41
|
+
return index;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/collections/mdx/mdast-utils.ts
|
|
50
|
+
function flattenNode(node) {
|
|
51
|
+
if ("children" in node) return node.children.map((child) => flattenNode(child)).join("");
|
|
52
|
+
if ("value" in node) return node.value;
|
|
53
|
+
return "";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/collections/mdx/remark-include.ts
|
|
58
|
+
const ElementLikeTypes = [
|
|
59
|
+
"mdxJsxFlowElement",
|
|
60
|
+
"mdxJsxTextElement",
|
|
61
|
+
"containerDirective",
|
|
62
|
+
"textDirective",
|
|
63
|
+
"leafDirective"
|
|
64
|
+
];
|
|
65
|
+
function isElementLike(node) {
|
|
66
|
+
return ElementLikeTypes.includes(node.type);
|
|
67
|
+
}
|
|
68
|
+
function parseElementAttributes(element) {
|
|
69
|
+
if (Array.isArray(element.attributes)) {
|
|
70
|
+
const attributes = {};
|
|
71
|
+
for (const attr of element.attributes) if (attr.type === "mdxJsxAttribute" && (typeof attr.value === "string" || attr.value === null)) attributes[attr.name] = attr.value;
|
|
72
|
+
return attributes;
|
|
73
|
+
}
|
|
74
|
+
return element.attributes ?? {};
|
|
75
|
+
}
|
|
76
|
+
function parseSpecifier(specifier) {
|
|
77
|
+
const idx = specifier.lastIndexOf("#");
|
|
78
|
+
if (idx === -1) return { file: specifier };
|
|
79
|
+
return {
|
|
80
|
+
file: specifier.slice(0, idx),
|
|
81
|
+
section: specifier.slice(idx + 1)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function extractSection(root, section) {
|
|
85
|
+
let nodes;
|
|
86
|
+
let capturingHeadingContent = false;
|
|
87
|
+
visit(root, (node) => {
|
|
88
|
+
if (node.type === "heading") {
|
|
89
|
+
if (capturingHeadingContent) return false;
|
|
90
|
+
if (node.data?.hProperties?.id === section) {
|
|
91
|
+
capturingHeadingContent = true;
|
|
92
|
+
nodes = [node];
|
|
93
|
+
return "skip";
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (capturingHeadingContent) {
|
|
98
|
+
nodes?.push(node);
|
|
99
|
+
return "skip";
|
|
100
|
+
}
|
|
101
|
+
if (isElementLike(node) && node.name === "section") {
|
|
102
|
+
if (parseElementAttributes(node).id === section) {
|
|
103
|
+
nodes = node.children;
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
if (nodes) return {
|
|
109
|
+
type: "root",
|
|
110
|
+
children: nodes
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const REGION_MARKERS = [
|
|
114
|
+
{
|
|
115
|
+
start: /^\s*\/\/\s*#?region\b\s*(.*?)\s*$/,
|
|
116
|
+
end: /^\s*\/\/\s*#?endregion\b\s*(.*?)\s*$/
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
start: /^\s*<!--\s*#?region\b\s*(.*?)\s*-->/,
|
|
120
|
+
end: /^\s*<!--\s*#?endregion\b\s*(.*?)\s*-->/
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
start: /^\s*\/\*\s*#region\b\s*(.*?)\s*\*\//,
|
|
124
|
+
end: /^\s*\/\*\s*#endregion\b\s*(.*?)\s*\*\//
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
start: /^\s*#[rR]egion\b\s*(.*?)\s*$/,
|
|
128
|
+
end: /^\s*#[eE]nd ?[rR]egion\b\s*(.*?)\s*$/
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
start: /^\s*#\s*#?region\b\s*(.*?)\s*$/,
|
|
132
|
+
end: /^\s*#\s*#?endregion\b\s*(.*?)\s*$/
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
start: /^\s*(?:--|::|@?REM)\s*#region\b\s*(.*?)\s*$/,
|
|
136
|
+
end: /^\s*(?:--|::|@?REM)\s*#endregion\b\s*(.*?)\s*$/
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
start: /^\s*#pragma\s+region\b\s*(.*?)\s*$/,
|
|
140
|
+
end: /^\s*#pragma\s+endregion\b\s*(.*?)\s*$/
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
start: /^\s*\(\*\s*#region\b\s*(.*?)\s*\*\)/,
|
|
144
|
+
end: /^\s*\(\*\s*#endregion\b\s*(.*?)\s*\*\)/
|
|
145
|
+
}
|
|
146
|
+
];
|
|
147
|
+
function dedent(lines) {
|
|
148
|
+
const minIndent = lines.reduce((min, line) => {
|
|
149
|
+
const match = line.match(/^(\s*)\S/);
|
|
150
|
+
return match ? Math.min(min, match[1].length) : min;
|
|
151
|
+
}, Infinity);
|
|
152
|
+
return minIndent === Infinity ? lines.join("\n") : lines.map((l) => l.slice(minIndent)).join("\n");
|
|
153
|
+
}
|
|
154
|
+
function extractCodeRegion(content, regionName) {
|
|
155
|
+
const lines = content.split("\n");
|
|
156
|
+
for (let i = 0; i < lines.length; i++) for (const re of REGION_MARKERS) {
|
|
157
|
+
let match = re.start.exec(lines[i]);
|
|
158
|
+
if (match?.[1] !== regionName) continue;
|
|
159
|
+
let depth = 1;
|
|
160
|
+
const extractedLines = [];
|
|
161
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
162
|
+
match = re.start.exec(lines[j]);
|
|
163
|
+
if (match) {
|
|
164
|
+
depth++;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
match = re.end.exec(lines[j]);
|
|
168
|
+
if (match) {
|
|
169
|
+
if (match[1] === regionName) depth = 0;
|
|
170
|
+
else if (match[1] === "") depth--;
|
|
171
|
+
else continue;
|
|
172
|
+
if (depth > 0) continue;
|
|
173
|
+
return dedent(extractedLines);
|
|
174
|
+
} else extractedLines.push(lines[j]);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
throw new Error(`Region "${regionName}" not found`);
|
|
178
|
+
}
|
|
179
|
+
function remarkInclude({ preprocess = [] } = {}) {
|
|
180
|
+
const TagName = "include";
|
|
181
|
+
const preprocessor = unified().use(remarkMarkAndUnravel).use(preprocess);
|
|
182
|
+
const embedContent = async (targetPath, heading, params, parent) => {
|
|
183
|
+
const { _getProcessor = () => this, _compiler } = parent.data;
|
|
184
|
+
let content;
|
|
185
|
+
try {
|
|
186
|
+
content = (await fs$1.readFile(targetPath)).toString();
|
|
187
|
+
} catch (e) {
|
|
188
|
+
throw new Error(`failed to read file ${targetPath}\n${e instanceof Error ? e.message : String(e)}`, { cause: e });
|
|
189
|
+
}
|
|
190
|
+
const ext = path$1.extname(targetPath);
|
|
191
|
+
_compiler?.addDependency(targetPath);
|
|
192
|
+
if (params.lang || ext !== ".md" && ext !== ".mdx") return {
|
|
193
|
+
type: "code",
|
|
194
|
+
lang: params.lang ?? ext.slice(1),
|
|
195
|
+
meta: params.meta,
|
|
196
|
+
value: heading ? extractCodeRegion(content, heading) : content,
|
|
197
|
+
data: {}
|
|
198
|
+
};
|
|
199
|
+
const parser = await _getProcessor(ext === ".mdx" ? "mdx" : "md");
|
|
200
|
+
const parsed = fumaMatter(content);
|
|
201
|
+
const targetFile = new VFile({
|
|
202
|
+
path: targetPath,
|
|
203
|
+
value: parsed.content,
|
|
204
|
+
data: {
|
|
205
|
+
...parent.data,
|
|
206
|
+
frontmatter: parsed.data
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
let mdast = await preprocessor.run(parser.parse(targetFile), targetFile);
|
|
210
|
+
if (heading) {
|
|
211
|
+
const extracted = extractSection(mdast, heading);
|
|
212
|
+
if (!extracted) throw new Error(`Cannot find section ${heading} in ${targetPath}, make sure you have encapsulated the section in a <section id="${heading}"> tag, or a :::section directive with remark-directive configured.`);
|
|
213
|
+
mdast = extracted;
|
|
214
|
+
}
|
|
215
|
+
await update(mdast, targetFile);
|
|
216
|
+
return mdast;
|
|
217
|
+
};
|
|
218
|
+
async function update(tree, file) {
|
|
219
|
+
const queue = [];
|
|
220
|
+
visit(tree, ElementLikeTypes, (_node, _, parent) => {
|
|
221
|
+
const node = _node;
|
|
222
|
+
if (node.name !== TagName) return;
|
|
223
|
+
const specifier = flattenNode(node);
|
|
224
|
+
if (specifier.length === 0) return "skip";
|
|
225
|
+
const attributes = parseElementAttributes(node);
|
|
226
|
+
const { file: relativePath, section } = parseSpecifier(specifier);
|
|
227
|
+
const targetPath = path$1.resolve("cwd" in attributes ? file.cwd : file.dirname ?? "", relativePath);
|
|
228
|
+
queue.push(embedContent(targetPath, section, attributes, file).then((replace) => {
|
|
229
|
+
Object.assign(parent && parent.type === "paragraph" ? parent : node, replace);
|
|
230
|
+
}));
|
|
231
|
+
return "skip";
|
|
232
|
+
});
|
|
233
|
+
await Promise.all(queue);
|
|
234
|
+
}
|
|
235
|
+
return async (tree, file) => {
|
|
236
|
+
await update(tree, file);
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/collections/mdx/remark-postprocess.ts
|
|
242
|
+
/**
|
|
243
|
+
* - collect references
|
|
244
|
+
* - write frontmatter (auto-title & description)
|
|
245
|
+
*/
|
|
246
|
+
function remarkPostprocess({ _format, includeProcessedMarkdown = false, includeMDAST = false, extractLinkReferences = false, valueToExport = [] }) {
|
|
247
|
+
let _stringifyProcessor;
|
|
248
|
+
const getStringifyProcessor = () => {
|
|
249
|
+
return _stringifyProcessor ??= _format === "mdx" ? this : this().use(remarkMdx).freeze();
|
|
250
|
+
};
|
|
251
|
+
return (tree, file) => {
|
|
252
|
+
const frontmatter = file.data.frontmatter ??= {};
|
|
253
|
+
if (!frontmatter.title) visit(tree, "heading", (node) => {
|
|
254
|
+
if (node.depth === 1) {
|
|
255
|
+
frontmatter.title = flattenNode(node);
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
file.data["mdx-export"] ??= [];
|
|
260
|
+
file.data["mdx-export"].push({
|
|
261
|
+
name: "frontmatter",
|
|
262
|
+
value: frontmatter
|
|
263
|
+
});
|
|
264
|
+
if (extractLinkReferences) {
|
|
265
|
+
const urls = [];
|
|
266
|
+
visit(tree, "link", (node) => {
|
|
267
|
+
urls.push({ href: node.url });
|
|
268
|
+
return "skip";
|
|
269
|
+
});
|
|
270
|
+
file.data["mdx-export"].push({
|
|
271
|
+
name: "extractedReferences",
|
|
272
|
+
value: urls
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
if (includeProcessedMarkdown) {
|
|
276
|
+
const processor = getStringifyProcessor();
|
|
277
|
+
const markdown = toMarkdown(tree, {
|
|
278
|
+
...processor.data("settings"),
|
|
279
|
+
extensions: processor.data("toMarkdownExtensions") || []
|
|
280
|
+
});
|
|
281
|
+
file.data["mdx-export"].push({
|
|
282
|
+
name: "_markdown",
|
|
283
|
+
value: markdown
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
if (includeMDAST) {
|
|
287
|
+
const options = includeMDAST === true ? {} : includeMDAST;
|
|
288
|
+
const mdast = JSON.stringify(options.removePosition ? removePosition(structuredClone(tree)) : tree);
|
|
289
|
+
file.data["mdx-export"].push({
|
|
290
|
+
name: "_mdast",
|
|
291
|
+
value: mdast
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
for (const { name, value } of file.data["mdx-export"]) tree.children.unshift(getMdastExport(name, value));
|
|
295
|
+
file.data["mdx-export"] = [];
|
|
296
|
+
for (const name of valueToExport) {
|
|
297
|
+
if (!(name in file.data)) continue;
|
|
298
|
+
tree.children.unshift(getMdastExport(name, file.data[name]));
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* MDX.js first converts javascript (with esm support) into mdast nodes with remark-mdx, then handle the other remark plugins
|
|
304
|
+
*
|
|
305
|
+
* Therefore, if we want to inject an export, we must convert the object into AST, then add the mdast node
|
|
306
|
+
*/
|
|
307
|
+
function getMdastExport(name, value) {
|
|
308
|
+
return {
|
|
309
|
+
type: "mdxjsEsm",
|
|
310
|
+
value: "",
|
|
311
|
+
data: { estree: {
|
|
312
|
+
type: "Program",
|
|
313
|
+
sourceType: "module",
|
|
314
|
+
body: [{
|
|
315
|
+
type: "ExportNamedDeclaration",
|
|
316
|
+
specifiers: [],
|
|
317
|
+
attributes: [],
|
|
318
|
+
source: null,
|
|
319
|
+
declaration: {
|
|
320
|
+
type: "VariableDeclaration",
|
|
321
|
+
kind: "let",
|
|
322
|
+
declarations: [{
|
|
323
|
+
type: "VariableDeclarator",
|
|
324
|
+
id: {
|
|
325
|
+
type: "Identifier",
|
|
326
|
+
name
|
|
327
|
+
},
|
|
328
|
+
init: valueToEstree(value)
|
|
329
|
+
}]
|
|
330
|
+
}
|
|
331
|
+
}]
|
|
332
|
+
} }
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/collections/mdx/remark-preprocess.ts
|
|
338
|
+
function remarkPreprocess(options) {
|
|
339
|
+
return async (tree, file) => {
|
|
340
|
+
if (file.data._preprocessed) return;
|
|
341
|
+
file.data._preprocessed = true;
|
|
342
|
+
if (options?.preprocessor) return await options.preprocessor.run(tree);
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/collections/mdx/build-mdx.ts
|
|
348
|
+
async function buildMDX(core, collection, { filePath, frontmatter, source, _compiler, environment, isDevelopment }) {
|
|
349
|
+
const handler = collection?.handlers.mdx;
|
|
350
|
+
const processorCache = createCache(core.cache).$value();
|
|
351
|
+
function getProcessor(format) {
|
|
352
|
+
const key = `build-mdx:${collection?.name ?? "global"}:${format}`;
|
|
353
|
+
return processorCache.cached(key, async () => {
|
|
354
|
+
const mdxOptions = await handler?.getMDXOptions?.(environment);
|
|
355
|
+
const preprocessPlugin = [remarkPreprocess, handler?.preprocess];
|
|
356
|
+
const postprocessOptions = {
|
|
357
|
+
_format: format,
|
|
358
|
+
...handler?.postprocess
|
|
359
|
+
};
|
|
360
|
+
const remarkIncludeOptions = { preprocess: [preprocessPlugin] };
|
|
361
|
+
return createProcessor({
|
|
362
|
+
outputFormat: "program",
|
|
363
|
+
development: isDevelopment,
|
|
364
|
+
...mdxOptions,
|
|
365
|
+
remarkPlugins: [
|
|
366
|
+
preprocessPlugin,
|
|
367
|
+
[remarkInclude, remarkIncludeOptions],
|
|
368
|
+
...mdxOptions?.remarkPlugins ?? [],
|
|
369
|
+
[remarkPostprocess, postprocessOptions]
|
|
370
|
+
],
|
|
371
|
+
format
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
let vfile = new VFile({
|
|
376
|
+
value: source,
|
|
377
|
+
path: filePath,
|
|
378
|
+
cwd: handler?.cwd,
|
|
379
|
+
data: {
|
|
380
|
+
frontmatter,
|
|
381
|
+
_compiler,
|
|
382
|
+
_getProcessor: getProcessor
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
if (collection && handler) vfile = await handler.vfile.run(vfile, {
|
|
386
|
+
collection,
|
|
387
|
+
filePath,
|
|
388
|
+
source
|
|
389
|
+
});
|
|
390
|
+
return (await getProcessor(filePath.endsWith(".mdx") ? "mdx" : "md")).process(vfile);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
//#endregion
|
|
394
|
+
export { buildMDX as t };
|
|
395
|
+
//# sourceMappingURL=build-mdx-C1PZsGp2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-mdx-C1PZsGp2.js","names":["newChildren: RootContent[]","ElementLikeTypes: ElementLikeContent[\"type\"][]","attributes: Record<string, string | null>","nodes: RootContent[] | undefined","extractedLines: string[]","content: string","fs","path","queue: Promise<void>[]","_stringifyProcessor: Processor | undefined","urls: ExtractedReference[]","postprocessOptions: PostprocessOptions","remarkIncludeOptions: RemarkIncludeOptions"],"sources":["../src/collections/mdx/remark-unravel.ts","../src/collections/mdx/mdast-utils.ts","../src/collections/mdx/remark-include.ts","../src/collections/mdx/remark-postprocess.ts","../src/collections/mdx/remark-preprocess.ts","../src/collections/mdx/build-mdx.ts"],"sourcesContent":["// from internal remark plugins in https://github.com/mdx-js/mdx/blob/main/packages/mdx/lib/plugin/remark-mark-and-unravel.js\n// we need to ensure consistency with MDX.js when parsing embed content in `remark-include`\nimport { visit } from \"unist-util-visit\";\nimport type { Transformer } from \"unified\";\nimport type { Root, RootContent } from \"mdast\";\n\nexport function remarkMarkAndUnravel(): Transformer<Root, Root> {\n return (tree) => {\n visit(tree, (node, index, parent) => {\n let offset = -1;\n let all = true;\n let oneOrMore = false;\n\n if (parent && typeof index === \"number\" && node.type === \"paragraph\") {\n const children = node.children;\n\n while (++offset < children.length) {\n const child = children[offset];\n\n if (\n child.type === \"mdxJsxTextElement\" ||\n child.type === \"mdxTextExpression\"\n ) {\n oneOrMore = true;\n } else if (child.type === \"text\" && child.value.trim().length === 0) {\n // Empty.\n } else {\n all = false;\n break;\n }\n }\n\n if (all && oneOrMore) {\n offset = -1;\n const newChildren: RootContent[] = [];\n\n while (++offset < children.length) {\n const child = children[offset];\n\n if (child.type === \"mdxJsxTextElement\") {\n // @ts-expect-error: mutate because it is faster; content model is fine.\n child.type = \"mdxJsxFlowElement\";\n }\n\n if (child.type === \"mdxTextExpression\") {\n // @ts-expect-error: mutate because it is faster; content model is fine.\n child.type = \"mdxFlowExpression\";\n }\n\n if (\n child.type === \"text\" &&\n /^[\\t\\r\\n ]+$/.test(String(child.value))\n ) {\n // Empty.\n } else {\n newChildren.push(child);\n }\n }\n\n parent.children.splice(index, 1, ...newChildren);\n return index;\n }\n }\n });\n };\n}\n","import type { RootContent } from \"mdast\";\n\nexport function flattenNode(node: RootContent): string {\n if (\"children\" in node)\n return node.children.map((child) => flattenNode(child)).join(\"\");\n\n if (\"value\" in node) return node.value;\n\n return \"\";\n}\n","import {\n type PluggableList,\n type Processor,\n type Transformer,\n unified,\n} from \"unified\";\nimport { visit } from \"unist-util-visit\";\nimport type { Code, Node, Root, RootContent } from \"mdast\";\nimport * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\nimport { fumaMatter } from \"@/utils/fuma-matter\";\nimport type { MdxJsxFlowElement, MdxJsxTextElement } from \"mdast-util-mdx-jsx\";\nimport { VFile } from \"vfile\";\nimport type { Directives } from \"mdast-util-directive\";\nimport { remarkMarkAndUnravel } from \"@/collections/mdx/remark-unravel\";\nimport { flattenNode } from \"./mdast-utils\";\n\nexport interface Params {\n lang?: string;\n meta?: string;\n}\n\nconst ElementLikeTypes: ElementLikeContent[\"type\"][] = [\n \"mdxJsxFlowElement\",\n \"mdxJsxTextElement\",\n \"containerDirective\",\n \"textDirective\",\n \"leafDirective\",\n];\ntype ElementLikeContent = MdxJsxFlowElement | MdxJsxTextElement | Directives;\n\nfunction isElementLike(node: Node): node is ElementLikeContent {\n return ElementLikeTypes.includes(node.type as ElementLikeContent[\"type\"]);\n}\n\nfunction parseElementAttributes(\n element: ElementLikeContent,\n): Record<string, string | null | undefined> {\n if (Array.isArray(element.attributes)) {\n const attributes: Record<string, string | null> = {};\n\n for (const attr of element.attributes) {\n if (\n attr.type === \"mdxJsxAttribute\" &&\n (typeof attr.value === \"string\" || attr.value === null)\n ) {\n attributes[attr.name] = attr.value;\n }\n }\n\n return attributes;\n }\n\n return element.attributes ?? {};\n}\n\nfunction parseSpecifier(specifier: string): {\n file: string;\n section?: string;\n} {\n const idx = specifier.lastIndexOf(\"#\");\n if (idx === -1) return { file: specifier };\n\n return {\n file: specifier.slice(0, idx),\n section: specifier.slice(idx + 1),\n };\n}\n\nfunction extractSection(root: Root, section: string): Root | undefined {\n let nodes: RootContent[] | undefined;\n let capturingHeadingContent = false;\n\n visit(root, (node) => {\n if (node.type === \"heading\") {\n if (capturingHeadingContent) {\n return false;\n }\n\n if (node.data?.hProperties?.id === section) {\n capturingHeadingContent = true;\n nodes = [node];\n return \"skip\";\n }\n\n return;\n }\n\n if (capturingHeadingContent) {\n nodes?.push(node as RootContent);\n return \"skip\";\n }\n\n if (isElementLike(node) && node.name === \"section\") {\n const attributes = parseElementAttributes(node);\n\n if (attributes.id === section) {\n nodes = node.children;\n return false;\n }\n }\n });\n\n if (nodes)\n return {\n type: \"root\",\n children: nodes,\n };\n}\n\n// region marker regexes\nconst REGION_MARKERS = [\n {\n start: /^\\s*\\/\\/\\s*#?region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*\\/\\/\\s*#?endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*<!--\\s*#?region\\b\\s*(.*?)\\s*-->/,\n end: /^\\s*<!--\\s*#?endregion\\b\\s*(.*?)\\s*-->/,\n },\n {\n start: /^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\//,\n end: /^\\s*\\/\\*\\s*#endregion\\b\\s*(.*?)\\s*\\*\\//,\n },\n {\n start: /^\\s*#[rR]egion\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#[eE]nd ?[rR]egion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*#\\s*#?region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#\\s*#?endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*(?:--|::|@?REM)\\s*#region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*(?:--|::|@?REM)\\s*#endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*#pragma\\s+region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#pragma\\s+endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*\\(\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\)/,\n end: /^\\s*\\(\\*\\s*#endregion\\b\\s*(.*?)\\s*\\*\\)/,\n },\n];\n\nfunction dedent(lines: string[]): string {\n const minIndent = lines.reduce((min, line) => {\n const match = line.match(/^(\\s*)\\S/);\n return match ? Math.min(min, match[1].length) : min;\n }, Infinity);\n\n return minIndent === Infinity\n ? lines.join(\"\\n\")\n : lines.map((l) => l.slice(minIndent)).join(\"\\n\");\n}\n\nfunction extractCodeRegion(content: string, regionName: string): string {\n const lines = content.split(\"\\n\");\n\n for (let i = 0; i < lines.length; i++) {\n for (const re of REGION_MARKERS) {\n let match = re.start.exec(lines[i]);\n if (match?.[1] !== regionName) continue;\n\n let depth = 1;\n const extractedLines: string[] = [];\n for (let j = i + 1; j < lines.length; j++) {\n match = re.start.exec(lines[j]);\n if (match) {\n depth++;\n continue;\n }\n\n match = re.end.exec(lines[j]);\n if (match) {\n if (match[1] === regionName) depth = 0;\n else if (match[1] === \"\") depth--;\n else continue;\n\n if (depth > 0) continue;\n return dedent(extractedLines);\n } else {\n extractedLines.push(lines[j]);\n }\n }\n }\n }\n throw new Error(`Region \"${regionName}\" not found`);\n}\n\nexport interface RemarkIncludeOptions {\n /**\n * remark plugins to preprocess the MDAST tree before scanning headings/sections.\n *\n * e.g. parse headings before extraction.\n */\n preprocess?: PluggableList;\n}\n\nexport function remarkInclude(\n this: Processor,\n { preprocess = [] }: RemarkIncludeOptions = {},\n): Transformer<Root, Root> {\n const TagName = \"include\";\n const preprocessor = unified().use(remarkMarkAndUnravel).use(preprocess);\n\n const embedContent = async (\n targetPath: string,\n heading: string | undefined,\n params: Params,\n parent: VFile,\n ) => {\n const { _getProcessor = () => this, _compiler } = parent.data;\n let content: string;\n try {\n content = (await fs.readFile(targetPath)).toString();\n } catch (e) {\n throw new Error(\n `failed to read file ${targetPath}\\n${e instanceof Error ? e.message : String(e)}`,\n { cause: e },\n );\n }\n\n const ext = path.extname(targetPath);\n _compiler?.addDependency(targetPath);\n if (params.lang || (ext !== \".md\" && ext !== \".mdx\")) {\n const lang = params.lang ?? ext.slice(1);\n\n return {\n type: \"code\",\n lang,\n meta: params.meta,\n value: heading ? extractCodeRegion(content, heading) : content,\n data: {},\n } satisfies Code;\n }\n\n const parser = await _getProcessor(ext === \".mdx\" ? \"mdx\" : \"md\");\n const parsed = fumaMatter(content);\n const targetFile = new VFile({\n path: targetPath,\n value: parsed.content,\n data: {\n ...parent.data,\n frontmatter: parsed.data as Record<string, unknown>,\n },\n });\n\n let mdast = await preprocessor.run(\n parser.parse(targetFile) as Root,\n targetFile,\n );\n\n if (heading) {\n const extracted = extractSection(mdast, heading);\n if (!extracted)\n throw new Error(\n `Cannot find section ${heading} in ${targetPath}, make sure you have encapsulated the section in a <section id=\"${heading}\"> tag, or a :::section directive with remark-directive configured.`,\n );\n\n mdast = extracted;\n }\n\n await update(mdast, targetFile);\n return mdast;\n };\n\n async function update(tree: Root, file: VFile) {\n const queue: Promise<void>[] = [];\n\n visit(tree, ElementLikeTypes, (_node, _, parent) => {\n const node = _node as ElementLikeContent;\n if (node.name !== TagName) return;\n\n const specifier = flattenNode(node);\n if (specifier.length === 0) return \"skip\";\n\n const attributes = parseElementAttributes(node);\n const { file: relativePath, section } = parseSpecifier(specifier);\n const targetPath = path.resolve(\n \"cwd\" in attributes ? file.cwd : (file.dirname ?? \"\"),\n relativePath,\n );\n\n queue.push(\n embedContent(targetPath, section, attributes, file).then((replace) => {\n Object.assign(\n parent && parent.type === \"paragraph\" ? parent : node,\n replace,\n );\n }),\n );\n\n return \"skip\";\n });\n\n await Promise.all(queue);\n }\n\n return async (tree, file) => {\n await update(tree, file);\n };\n}\n","import type { Processor, Transformer } from \"unified\";\nimport type { Root, RootContent } from \"mdast\";\nimport { visit } from \"unist-util-visit\";\nimport { toMarkdown } from \"mdast-util-to-markdown\";\nimport { valueToEstree } from \"estree-util-value-to-estree\";\nimport { removePosition } from \"unist-util-remove-position\";\nimport remarkMdx from \"remark-mdx\";\nimport { flattenNode } from \"./mdast-utils\";\n\nexport interface ExtractedReference {\n href: string;\n}\n\nexport interface PostprocessOptions {\n _format: \"md\" | \"mdx\";\n\n /**\n * Properties to export from `vfile.data`\n */\n valueToExport?: string[];\n\n /**\n * stringify MDAST and export via `_markdown`.\n */\n includeProcessedMarkdown?: boolean;\n\n /**\n * extract link references, export via `extractedReferences`.\n */\n extractLinkReferences?: boolean;\n\n /**\n * store MDAST and export via `_mdast`.\n */\n includeMDAST?:\n | boolean\n | {\n removePosition?: boolean;\n };\n}\n\n/**\n * - collect references\n * - write frontmatter (auto-title & description)\n */\nexport function remarkPostprocess(\n this: Processor,\n {\n _format,\n includeProcessedMarkdown = false,\n includeMDAST = false,\n extractLinkReferences = false,\n valueToExport = [],\n }: PostprocessOptions,\n): Transformer<Root, Root> {\n let _stringifyProcessor: Processor | undefined;\n const getStringifyProcessor = () => {\n return (_stringifyProcessor ??=\n _format === \"mdx\"\n ? this\n : // force Markdown processor to stringify MDX nodes\n this().use(remarkMdx).freeze());\n };\n\n return (tree, file) => {\n const frontmatter = (file.data.frontmatter ??= {});\n if (!frontmatter.title) {\n visit(tree, \"heading\", (node) => {\n if (node.depth === 1) {\n frontmatter.title = flattenNode(node);\n return false;\n }\n });\n }\n\n file.data[\"mdx-export\"] ??= [];\n file.data[\"mdx-export\"].push({\n name: \"frontmatter\",\n value: frontmatter,\n });\n\n if (extractLinkReferences) {\n const urls: ExtractedReference[] = [];\n\n visit(tree, \"link\", (node) => {\n urls.push({\n href: node.url,\n });\n return \"skip\";\n });\n\n file.data[\"mdx-export\"].push({\n name: \"extractedReferences\",\n value: urls,\n });\n }\n\n if (includeProcessedMarkdown) {\n const processor = getStringifyProcessor();\n const markdown = toMarkdown(tree, {\n ...processor.data(\"settings\"),\n // from https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/lib/index.js\n extensions: processor.data(\"toMarkdownExtensions\") || [],\n });\n\n file.data[\"mdx-export\"].push({\n name: \"_markdown\",\n value: markdown,\n });\n }\n\n if (includeMDAST) {\n const options = includeMDAST === true ? {} : includeMDAST;\n const mdast = JSON.stringify(\n options.removePosition ? removePosition(structuredClone(tree)) : tree,\n );\n\n file.data[\"mdx-export\"].push({\n name: \"_mdast\",\n value: mdast,\n });\n }\n\n for (const { name, value } of file.data[\"mdx-export\"]) {\n tree.children.unshift(getMdastExport(name, value));\n }\n\n // reset the data to reduce memory usage\n file.data[\"mdx-export\"] = [];\n\n for (const name of valueToExport) {\n if (!(name in file.data)) continue;\n\n tree.children.unshift(getMdastExport(name, file.data[name]));\n }\n };\n}\n\n/**\n * MDX.js first converts javascript (with esm support) into mdast nodes with remark-mdx, then handle the other remark plugins\n *\n * Therefore, if we want to inject an export, we must convert the object into AST, then add the mdast node\n */\nfunction getMdastExport(name: string, value: unknown): RootContent {\n return {\n type: \"mdxjsEsm\",\n value: \"\",\n data: {\n estree: {\n type: \"Program\",\n sourceType: \"module\",\n body: [\n {\n type: \"ExportNamedDeclaration\",\n specifiers: [],\n attributes: [],\n source: null,\n declaration: {\n type: \"VariableDeclaration\",\n kind: \"let\",\n declarations: [\n {\n type: \"VariableDeclarator\",\n id: {\n type: \"Identifier\",\n name,\n },\n init: valueToEstree(value),\n },\n ],\n },\n },\n ],\n },\n },\n };\n}\n","import type { Processor, Transformer } from \"unified\";\nimport type { Root } from \"mdast\";\n\nexport interface PreprocessOptions {\n preprocessor?: Processor<Root>;\n}\n\ndeclare module \"vfile\" {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- extend data map\n interface DataMap {\n _preprocessed?: boolean;\n }\n}\n\nexport function remarkPreprocess(\n options?: PreprocessOptions,\n): Transformer<Root, Root> {\n return async (tree, file) => {\n if (file.data._preprocessed) return;\n file.data._preprocessed = true;\n\n if (options?.preprocessor) {\n return (await options.preprocessor.run(tree)) as Root;\n }\n };\n}\n","import { createProcessor } from \"@mdx-js/mdx\";\nimport { VFile } from \"vfile\";\nimport {\n remarkInclude,\n type RemarkIncludeOptions,\n} from \"@/collections/mdx/remark-include\";\nimport {\n type PostprocessOptions,\n remarkPostprocess,\n} from \"@/collections/mdx/remark-postprocess\";\nimport type { Core } from \"@/core\";\nimport { remarkPreprocess } from \"@/collections/mdx/remark-preprocess\";\nimport type { Pluggable } from \"unified\";\nimport type { Collection } from \"@/collections\";\nimport { createCache } from \"@/utils/async-cache\";\nimport type { CompilerOptions } from \"@/plugins/with-loader\";\nimport type { FC } from \"react\";\nimport type { MDXProps } from \"mdx/types\";\n\ntype MDXProcessor = ReturnType<typeof createProcessor>;\n\ninterface BuildMDXOptions {\n /**\n * Specify a file path for source\n */\n filePath: string;\n source: string;\n frontmatter?: Record<string, unknown>;\n\n environment: \"bundler\" | \"runtime\";\n isDevelopment: boolean;\n _compiler?: CompilerOptions;\n}\n\nexport interface FumaContentDataMap {\n /**\n * [Fuma Content] raw frontmatter, you can modify it\n */\n frontmatter?: Record<string, unknown>;\n\n /**\n * [Fuma Content] additional ESM exports to write\n */\n \"mdx-export\"?: { name: string; value: unknown }[];\n\n /**\n * [Fuma Content] The compiler object from loader\n */\n _compiler?: CompilerOptions;\n\n /**\n * [Fuma Content] get internal processor, do not use this on user land.\n */\n _getProcessor?: (\n format: \"md\" | \"mdx\",\n ) => MDXProcessor | Promise<MDXProcessor>;\n}\n\ndeclare module \"vfile\" {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- extend data map\n interface DataMap extends FumaContentDataMap {}\n}\n\nexport type CompiledMDX<Frontmatter = Record<string, unknown>> = {\n frontmatter: Frontmatter;\n} & CompiledMDXData &\n Record<string, unknown>;\n\nexport interface CompiledMDXData {\n default: FC<MDXProps>;\n\n /**\n * Enable from `postprocess` option.\n */\n _markdown?: string;\n /**\n * Enable from `postprocess` option.\n */\n _mdast?: string;\n}\n\nexport async function buildMDX(\n core: Core,\n collection: Collection | undefined,\n {\n filePath,\n frontmatter,\n source,\n _compiler,\n environment,\n isDevelopment,\n }: BuildMDXOptions,\n): Promise<VFile> {\n const handler = collection?.handlers.mdx;\n const processorCache = createCache(core.cache).$value<MDXProcessor>();\n\n function getProcessor(format: \"md\" | \"mdx\") {\n const key = `build-mdx:${collection?.name ?? \"global\"}:${format}`;\n\n return processorCache.cached(key, async () => {\n const mdxOptions = await handler?.getMDXOptions?.(environment);\n const preprocessPlugin = [\n remarkPreprocess,\n handler?.preprocess,\n ] satisfies Pluggable;\n const postprocessOptions: PostprocessOptions = {\n _format: format,\n ...handler?.postprocess,\n };\n const remarkIncludeOptions: RemarkIncludeOptions = {\n preprocess: [preprocessPlugin],\n };\n\n return createProcessor({\n outputFormat: \"program\",\n development: isDevelopment,\n ...mdxOptions,\n remarkPlugins: [\n preprocessPlugin,\n [remarkInclude, remarkIncludeOptions],\n ...(mdxOptions?.remarkPlugins ?? []),\n [remarkPostprocess, postprocessOptions],\n ],\n format,\n });\n });\n }\n\n let vfile = new VFile({\n value: source,\n path: filePath,\n cwd: handler?.cwd,\n data: {\n frontmatter,\n _compiler,\n _getProcessor: getProcessor,\n },\n });\n\n if (collection && handler) {\n vfile = await handler.vfile.run(vfile, {\n collection,\n filePath,\n source,\n });\n }\n\n return (await getProcessor(filePath.endsWith(\".mdx\") ? \"mdx\" : \"md\")).process(\n vfile,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAMA,SAAgB,uBAAgD;AAC9D,SAAQ,SAAS;AACf,QAAM,OAAO,MAAM,OAAO,WAAW;GACnC,IAAI,SAAS;GACb,IAAI,MAAM;GACV,IAAI,YAAY;AAEhB,OAAI,UAAU,OAAO,UAAU,YAAY,KAAK,SAAS,aAAa;IACpE,MAAM,WAAW,KAAK;AAEtB,WAAO,EAAE,SAAS,SAAS,QAAQ;KACjC,MAAM,QAAQ,SAAS;AAEvB,SACE,MAAM,SAAS,uBACf,MAAM,SAAS,oBAEf,aAAY;cACH,MAAM,SAAS,UAAU,MAAM,MAAM,MAAM,CAAC,WAAW,GAAG,QAE9D;AACL,YAAM;AACN;;;AAIJ,QAAI,OAAO,WAAW;AACpB,cAAS;KACT,MAAMA,cAA6B,EAAE;AAErC,YAAO,EAAE,SAAS,SAAS,QAAQ;MACjC,MAAM,QAAQ,SAAS;AAEvB,UAAI,MAAM,SAAS,oBAEjB,OAAM,OAAO;AAGf,UAAI,MAAM,SAAS,oBAEjB,OAAM,OAAO;AAGf,UACE,MAAM,SAAS,UACf,eAAe,KAAK,OAAO,MAAM,MAAM,CAAC,EACxC,OAGA,aAAY,KAAK,MAAM;;AAI3B,YAAO,SAAS,OAAO,OAAO,GAAG,GAAG,YAAY;AAChD,YAAO;;;IAGX;;;;;;AC7DN,SAAgB,YAAY,MAA2B;AACrD,KAAI,cAAc,KAChB,QAAO,KAAK,SAAS,KAAK,UAAU,YAAY,MAAM,CAAC,CAAC,KAAK,GAAG;AAElE,KAAI,WAAW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A,YACA,EACE,UACA,aACA,QACA,WACA,aACA,iBAEc;CAChB,MAAM,UAAU,YAAY,SAAS;CACrC,MAAM,iBAAiB,YAAY,KAAK,MAAM,CAAC,QAAsB;CAErE,SAAS,aAAa,QAAsB;EAC1C,MAAM,MAAM,aAAa,YAAY,QAAQ,SAAS,GAAG;AAEzD,SAAO,eAAe,OAAO,KAAK,YAAY;GAC5C,MAAM,aAAa,MAAM,SAAS,gBAAgB,YAAY;GAC9D,MAAM,mBAAmB,CACvB,kBACA,SAAS,WACV;GACD,MAAMC,qBAAyC;IAC7C,SAAS;IACT,GAAG,SAAS;IACb;GACD,MAAMC,uBAA6C,EACjD,YAAY,CAAC,iBAAiB,EAC/B;AAED,UAAO,gBAAgB;IACrB,cAAc;IACd,aAAa;IACb,GAAG;IACH,eAAe;KACb;KACA,CAAC,eAAe,qBAAqB;KACrC,GAAI,YAAY,iBAAiB,EAAE;KACnC,CAAC,mBAAmB,mBAAmB;KACxC;IACD;IACD,CAAC;IACF;;CAGJ,IAAI,QAAQ,IAAI,MAAM;EACpB,OAAO;EACP,MAAM;EACN,KAAK,SAAS;EACd,MAAM;GACJ;GACA;GACA,eAAe;GAChB;EACF,CAAC;AAEF,KAAI,cAAc,QAChB,SAAQ,MAAM,QAAQ,MAAM,IAAI,OAAO;EACrC;EACA;EACA;EACD,CAAC;AAGJ,SAAQ,MAAM,aAAa,SAAS,SAAS,OAAO,GAAG,QAAQ,KAAK,EAAE,QACpE,MACD"}
|
package/dist/bun/index.d.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import 'chokidar';
|
|
4
|
-
import '@mdx-js/mdx';
|
|
5
|
-
import 'vfile';
|
|
6
|
-
import '@standard-schema/spec';
|
|
7
|
-
import 'unified';
|
|
8
|
-
import 'mdast';
|
|
9
|
-
import 'vite';
|
|
10
|
-
import 'next';
|
|
11
|
-
import 'node:module';
|
|
1
|
+
import { n as CoreOptions } from "../core-Bkh-SI_3.js";
|
|
2
|
+
import { BunPlugin } from "bun";
|
|
12
3
|
|
|
4
|
+
//#region src/bun/index.d.ts
|
|
13
5
|
type ContentPluginOptions = Partial<CoreOptions>;
|
|
14
6
|
declare function createContentPlugin(options?: ContentPluginOptions): BunPlugin;
|
|
15
|
-
|
|
16
|
-
export {
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ContentPluginOptions, createContentPlugin };
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/bun/index.ts"],"sourcesContent":[],"mappings":";;;;KAKY,oBAAA,GAAuB,QAAQ;iBAE3B,mBAAA,WACL,uBACR"}
|