@vxrn/mdx-rust 2.0.0-beta.33.1 → 2.0.0-beta.46.1
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/client.mjs +8 -6
- package/dist/client.mjs.map +1 -1
- package/dist/getAllFrontmatter.mjs +16 -17
- package/dist/getAllFrontmatter.mjs.map +1 -1
- package/dist/getHeadings.mjs +10 -8
- package/dist/getHeadings.mjs.map +1 -1
- package/dist/getMDX.mjs +50 -52
- package/dist/getMDX.mjs.map +1 -1
- package/dist/getMDXBySlug.mjs +13 -11
- package/dist/getMDXBySlug.mjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/processImageMeta.mjs +26 -29
- package/dist/processImageMeta.mjs.map +1 -1
- package/dist/slugPlugin.mjs +30 -21
- package/dist/slugPlugin.mjs.map +1 -1
- package/dist/tableWhitespacePlugin.mjs +21 -14
- package/dist/tableWhitespacePlugin.mjs.map +1 -1
- package/dist/types.mjs +0 -2
- package/dist/watchFile.mjs +3 -2
- package/dist/watchFile.mjs.map +1 -1
- package/package.json +2 -2
- package/types/getAllFrontmatter.d.ts.map +1 -1
- package/types/getHeadings.d.ts.map +1 -1
- package/types/getMDXBySlug.d.ts.map +1 -1
- package/types/slugPlugin.d.ts.map +1 -1
- package/types/tableWhitespacePlugin.d.ts.map +1 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/types.mjs.map +0 -1
package/dist/client.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as runtime from "react/jsx-runtime";
|
|
2
|
+
|
|
2
3
|
function getMDXComponent(code, globals = {}) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const fn = new Function(String(code));
|
|
5
|
+
const mod = fn({
|
|
6
|
+
...runtime,
|
|
7
|
+
...globals
|
|
8
|
+
});
|
|
9
|
+
return mod.default;
|
|
9
10
|
}
|
|
11
|
+
|
|
10
12
|
export { getMDXComponent };
|
|
11
13
|
//# sourceMappingURL=client.mjs.map
|
package/dist/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["client.js"],"sourcesContent":["import * as runtime from \"react/jsx-runtime\";\nfunction getMDXComponent(code, globals = {}) {\n const fn = new Function(String(code));\n const mod = fn({ ...runtime, ...globals });\n return mod.default;\n}\nexport {\n getMDXComponent\n};\n//# sourceMappingURL=client.js.map\n"],"mappings":";;;AACA,SAAS,gBAAgB,MAAM,UAAU,CAAC,GAAG;CAC3C,MAAM,KAAK,IAAI,SAAS,OAAO,IAAI,CAAC;CACpC,MAAM,MAAM,GAAG;EAAE,GAAG;EAAS,GAAG;CAAQ,CAAC;CACzC,OAAO,IAAI;AACb"}
|
|
@@ -4,23 +4,22 @@ import matter from "gray-matter";
|
|
|
4
4
|
import readingTime from "reading-time";
|
|
5
5
|
import { getHeadings } from "./getHeadings.mjs";
|
|
6
6
|
import { notifyFileRead } from "./watchFile.mjs";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
}).sort((a, b) => Number(new Date(b.publishedAt || "")) - Number(new Date(a.publishedAt || "")));
|
|
7
|
+
|
|
8
|
+
const getAllFrontmatter = (fromPath) => {
|
|
9
|
+
const paths = glob.sync(`${fromPath}/**/*.mdx`);
|
|
10
|
+
return paths.map((filePath) => {
|
|
11
|
+
notifyFileRead(filePath);
|
|
12
|
+
const source = fs.readFileSync(filePath, "utf8");
|
|
13
|
+
const { data, content } = matter(source);
|
|
14
|
+
const slug = filePath.replace(`${fromPath.replaceAll("\\", "/")}/`, "").replace(".mdx", "");
|
|
15
|
+
return {
|
|
16
|
+
...data,
|
|
17
|
+
slug,
|
|
18
|
+
headings: getHeadings(source),
|
|
19
|
+
readingTime: readingTime(content)
|
|
20
|
+
};
|
|
21
|
+
}).sort((a, b) => Number(new Date(b.publishedAt || "")) - Number(new Date(a.publishedAt || "")));
|
|
24
22
|
};
|
|
23
|
+
|
|
25
24
|
export { getAllFrontmatter };
|
|
26
25
|
//# sourceMappingURL=getAllFrontmatter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"file":"getAllFrontmatter.js","names":[],"sources":["getAllFrontmatter.js"],"sourcesContent":["import fs from \"node:fs\";\nimport glob from \"fast-glob\";\nimport matter from \"gray-matter\";\nimport readingTime from \"reading-time\";\nimport { getHeadings } from \"./getHeadings\";\nimport { notifyFileRead } from \"./watchFile\";\nconst getAllFrontmatter = (fromPath) => {\n const paths = glob.sync(`${fromPath}/**/*.mdx`);\n return paths.map((filePath) => {\n notifyFileRead(filePath);\n const source = fs.readFileSync(filePath, \"utf8\");\n const { data, content } = matter(source);\n const slug = filePath.replace(`${fromPath.replaceAll(\"\\\\\", \"/\")}/`, \"\").replace(\".mdx\", \"\");\n return {\n ...data,\n slug,\n headings: getHeadings(source),\n readingTime: readingTime(content)\n };\n }).sort(\n (a, b) => Number(new Date(b.publishedAt || \"\")) - Number(new Date(a.publishedAt || \"\"))\n );\n};\nexport {\n getAllFrontmatter\n};\n//# sourceMappingURL=getAllFrontmatter.js.map\n"],"mappings":";;;;;;;;AAMA,MAAM,qBAAqB,aAAa;CACtC,MAAM,QAAQ,KAAK,KAAK,GAAG,SAAS,UAAU;CAC9C,OAAO,MAAM,KAAK,aAAa;EAC7B,eAAe,QAAQ;EACvB,MAAM,SAAS,GAAG,aAAa,UAAU,MAAM;EAC/C,MAAM,EAAE,MAAM,YAAY,OAAO,MAAM;EACvC,MAAM,OAAO,SAAS,QAAQ,GAAG,SAAS,WAAW,MAAM,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,QAAQ,EAAE;EAC1F,OAAO;GACL,GAAG;GACH;GACA,UAAU,YAAY,MAAM;GAC5B,aAAa,YAAY,OAAO;EAClC;CACF,CAAC,CAAC,CAAC,MACA,GAAG,MAAM,OAAO,IAAI,KAAK,EAAE,eAAe,EAAE,CAAC,IAAI,OAAO,IAAI,KAAK,EAAE,eAAe,EAAE,CAAC,CACxF;AACF"}
|
package/dist/getHeadings.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import GithubSlugger from "github-slugger";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
|
|
3
|
+
const getTitle = (source) => source.replace(/^#+\s+/, "").replace(/<.*>/, " ");
|
|
4
|
+
const getHeadings = (source) => {
|
|
5
|
+
const slugger = new GithubSlugger();
|
|
6
|
+
return source.split("\n").filter((x) => x.startsWith("#")).map((x) => ({
|
|
7
|
+
title: getTitle(x),
|
|
8
|
+
priority: x.trim().split(" ")[0].length,
|
|
9
|
+
id: slugger.slug(getTitle(x))
|
|
10
|
+
}));
|
|
10
11
|
};
|
|
12
|
+
|
|
11
13
|
export { getHeadings };
|
|
12
14
|
//# sourceMappingURL=getHeadings.mjs.map
|
package/dist/getHeadings.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"getHeadings.js","names":[],"sources":["getHeadings.js"],"sourcesContent":["import GithubSlugger from \"github-slugger\";\nconst getTitle = (source) => source.replace(/^#+\\s+/, \"\").replace(/<.*>/, \" \");\nconst getHeadings = (source) => {\n const slugger = new GithubSlugger();\n return source.split(\"\\n\").filter((x) => x.startsWith(\"#\")).map((x) => ({\n title: getTitle(x),\n priority: x.trim().split(\" \")[0].length,\n id: slugger.slug(getTitle(x))\n }));\n};\nexport {\n getHeadings\n};\n//# sourceMappingURL=getHeadings.js.map\n"],"mappings":";;;AACA,MAAM,YAAY,WAAW,OAAO,QAAQ,UAAU,EAAE,CAAC,CAAC,QAAQ,QAAQ,GAAG;AAC7E,MAAM,eAAe,WAAW;CAC9B,MAAM,UAAU,IAAI,cAAc;CAClC,OAAO,OAAO,MAAM,IAAI,CAAC,CAAC,QAAQ,MAAM,EAAE,WAAW,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO;EACrE,OAAO,SAAS,CAAC;EACjB,UAAU,EAAE,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;EACjC,IAAI,QAAQ,KAAK,SAAS,CAAC,CAAC;CAC9B,EAAE;AACJ"}
|
package/dist/getMDX.mjs
CHANGED
|
@@ -6,61 +6,59 @@ import { getHeadings } from "./getHeadings.mjs";
|
|
|
6
6
|
import { processImageMeta } from "./processImageMeta.mjs";
|
|
7
7
|
import { slugPlugin } from "./slugPlugin.mjs";
|
|
8
8
|
import { tableWhitespacePlugin } from "./tableWhitespacePlugin.mjs";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const ecByKey = /* @__PURE__ */new Map();
|
|
9
|
+
|
|
10
|
+
const DEFAULT_EC = { themes: ["github-dark"] };
|
|
11
|
+
const ecByKey = /* @__PURE__ */ new Map();
|
|
13
12
|
function getExpressiveCode(opts) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
const key = (() => {
|
|
14
|
+
try {
|
|
15
|
+
return JSON.stringify(opts);
|
|
16
|
+
} catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
})();
|
|
20
|
+
if (key == null) return expressiveCode(opts);
|
|
21
|
+
let plugin = ecByKey.get(key);
|
|
22
|
+
if (!plugin) {
|
|
23
|
+
plugin = expressiveCode(opts);
|
|
24
|
+
ecByKey.set(key, plugin);
|
|
25
|
+
}
|
|
26
|
+
return plugin;
|
|
28
27
|
}
|
|
29
28
|
async function getMDX(source, options = {}) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
code
|
|
63
|
-
};
|
|
29
|
+
const { data, content } = matter(source);
|
|
30
|
+
const ec = options.expressiveCode === false ? [] : [getExpressiveCode(options.expressiveCode ?? DEFAULT_EC)];
|
|
31
|
+
const { code } = await mdxToJs(source, {
|
|
32
|
+
outputFormat: "function-body",
|
|
33
|
+
jsxImportSource: "react",
|
|
34
|
+
features: {
|
|
35
|
+
gfm: true,
|
|
36
|
+
smartPunctuation: true,
|
|
37
|
+
frontmatter: true
|
|
38
|
+
},
|
|
39
|
+
mdastPlugins: [...options.mdastPlugins ?? []],
|
|
40
|
+
hastPlugins: [
|
|
41
|
+
slugPlugin,
|
|
42
|
+
tableWhitespacePlugin,
|
|
43
|
+
...ec,
|
|
44
|
+
...options.hastPlugins ?? []
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
let imageMeta;
|
|
48
|
+
if (data.image && typeof data.image === "string") {
|
|
49
|
+
const meta = await processImageMeta(data.image, { publicDir: options.publicDir });
|
|
50
|
+
if (meta) imageMeta = meta;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
frontmatter: {
|
|
54
|
+
...data,
|
|
55
|
+
headings: getHeadings(source),
|
|
56
|
+
readingTime: readingTime(content),
|
|
57
|
+
imageMeta
|
|
58
|
+
},
|
|
59
|
+
code
|
|
60
|
+
};
|
|
64
61
|
}
|
|
62
|
+
|
|
65
63
|
export { getMDX };
|
|
66
64
|
//# sourceMappingURL=getMDX.mjs.map
|
package/dist/getMDX.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"file":"getMDX.js","names":[],"sources":["getMDX.js"],"sourcesContent":["import matter from \"gray-matter\";\nimport readingTime from \"reading-time\";\nimport { mdxToJs } from \"satteri\";\nimport expressiveCode from \"satteri-expressive-code\";\nimport { getHeadings } from \"./getHeadings\";\nimport { processImageMeta } from \"./processImageMeta\";\nimport { slugPlugin } from \"./slugPlugin\";\nimport { tableWhitespacePlugin } from \"./tableWhitespacePlugin\";\nconst DEFAULT_EC = { themes: [\"github-dark\"] };\nconst ecByKey = /* @__PURE__ */ new Map();\nfunction getExpressiveCode(opts) {\n const key = (() => {\n try {\n return JSON.stringify(opts);\n } catch {\n return null;\n }\n })();\n if (key == null) return expressiveCode(opts);\n let plugin = ecByKey.get(key);\n if (!plugin) {\n plugin = expressiveCode(opts);\n ecByKey.set(key, plugin);\n }\n return plugin;\n}\nasync function getMDX(source, options = {}) {\n const { data, content } = matter(source);\n const ec = options.expressiveCode === false ? [] : [getExpressiveCode(options.expressiveCode ?? DEFAULT_EC)];\n const { code } = await mdxToJs(source, {\n outputFormat: \"function-body\",\n jsxImportSource: \"react\",\n features: { gfm: true, smartPunctuation: true, frontmatter: true },\n mdastPlugins: [...options.mdastPlugins ?? []],\n hastPlugins: [\n slugPlugin,\n tableWhitespacePlugin,\n ...ec,\n ...options.hastPlugins ?? []\n ]\n });\n let imageMeta;\n if (data.image && typeof data.image === \"string\") {\n const meta = await processImageMeta(data.image, { publicDir: options.publicDir });\n if (meta) imageMeta = meta;\n }\n return {\n frontmatter: {\n ...data,\n headings: getHeadings(source),\n readingTime: readingTime(content),\n imageMeta\n },\n code\n };\n}\nexport {\n getMDX\n};\n//# sourceMappingURL=getMDX.js.map\n"],"mappings":";;;;;;;;;;AAQA,MAAM,aAAa,EAAE,QAAQ,CAAC,aAAa,EAAE;AAC7C,MAAM,0BAA0B,IAAI,IAAI;AACxC,SAAS,kBAAkB,MAAM;CAC/B,MAAM,aAAa;EACjB,IAAI;GACF,OAAO,KAAK,UAAU,IAAI;EAC5B,QAAQ;GACN,OAAO;EACT;CACF,EAAC,CAAE;CACH,IAAI,OAAO,MAAM,OAAO,eAAe,IAAI;CAC3C,IAAI,SAAS,QAAQ,IAAI,GAAG;CAC5B,IAAI,CAAC,QAAQ;EACX,SAAS,eAAe,IAAI;EAC5B,QAAQ,IAAI,KAAK,MAAM;CACzB;CACA,OAAO;AACT;AACA,eAAe,OAAO,QAAQ,UAAU,CAAC,GAAG;CAC1C,MAAM,EAAE,MAAM,YAAY,OAAO,MAAM;CACvC,MAAM,KAAK,QAAQ,mBAAmB,QAAQ,CAAC,IAAI,CAAC,kBAAkB,QAAQ,kBAAkB,UAAU,CAAC;CAC3G,MAAM,EAAE,SAAS,MAAM,QAAQ,QAAQ;EACrC,cAAc;EACd,iBAAiB;EACjB,UAAU;GAAE,KAAK;GAAM,kBAAkB;GAAM,aAAa;EAAK;EACjE,cAAc,CAAC,GAAG,QAAQ,gBAAgB,CAAC,CAAC;EAC5C,aAAa;GACX;GACA;GACA,GAAG;GACH,GAAG,QAAQ,eAAe,CAAC;EAC7B;CACF,CAAC;CACD,IAAI;CACJ,IAAI,KAAK,SAAS,OAAO,KAAK,UAAU,UAAU;EAChD,MAAM,OAAO,MAAM,iBAAiB,KAAK,OAAO,EAAE,WAAW,QAAQ,UAAU,CAAC;EAChF,IAAI,MAAM,YAAY;CACxB;CACA,OAAO;EACL,aAAa;GACX,GAAG;GACH,UAAU,YAAY,MAAM;GAC5B,aAAa,YAAY,OAAO;GAChC;EACF;EACA;CACF;AACF"}
|
package/dist/getMDXBySlug.mjs
CHANGED
|
@@ -3,20 +3,22 @@ import path from "node:path";
|
|
|
3
3
|
import compareVersions from "compare-versions";
|
|
4
4
|
import { getMDX } from "./getMDX.mjs";
|
|
5
5
|
import { notifyFileRead } from "./watchFile.mjs";
|
|
6
|
+
|
|
6
7
|
const getMDXBySlug = async (basePath, slug, options) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
let mdxPath = slug;
|
|
9
|
+
if (!slug.includes(".") && basePath.includes("components")) {
|
|
10
|
+
const versions = getAllVersionsFromPath(path.join(basePath, slug));
|
|
11
|
+
mdxPath += `/${versions[0]}`;
|
|
12
|
+
}
|
|
13
|
+
const filePath = path.join(basePath, `${mdxPath}.mdx`);
|
|
14
|
+
notifyFileRead(filePath);
|
|
15
|
+
const source = fs.readFileSync(filePath, "utf8");
|
|
16
|
+
return getMDX(source, options);
|
|
16
17
|
};
|
|
17
18
|
function getAllVersionsFromPath(fromPath) {
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
if (!fs.existsSync(fromPath)) return [];
|
|
20
|
+
return fs.readdirSync(fromPath).map((fileName) => fileName.replace(".mdx", "")).sort(compareVersions).reverse();
|
|
20
21
|
}
|
|
22
|
+
|
|
21
23
|
export { getAllVersionsFromPath, getMDXBySlug };
|
|
22
24
|
//# sourceMappingURL=getMDXBySlug.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"file":"getMDXBySlug.js","names":[],"sources":["getMDXBySlug.js"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport compareVersions from \"compare-versions\";\nimport { getMDX } from \"./getMDX\";\nimport { notifyFileRead } from \"./watchFile\";\nconst getMDXBySlug = async (basePath, slug, options) => {\n let mdxPath = slug;\n if (!slug.includes(\".\") && basePath.includes(\"components\")) {\n const versions = getAllVersionsFromPath(path.join(basePath, slug));\n mdxPath += `/${versions[0]}`;\n }\n const filePath = path.join(basePath, `${mdxPath}.mdx`);\n notifyFileRead(filePath);\n const source = fs.readFileSync(filePath, \"utf8\");\n return getMDX(source, options);\n};\nfunction getAllVersionsFromPath(fromPath) {\n if (!fs.existsSync(fromPath)) return [];\n return fs.readdirSync(fromPath).map((fileName) => fileName.replace(\".mdx\", \"\")).sort(compareVersions).reverse();\n}\nexport {\n getAllVersionsFromPath,\n getMDXBySlug\n};\n//# sourceMappingURL=getMDXBySlug.js.map\n"],"mappings":";;;;;;;AAKA,MAAM,eAAe,OAAO,UAAU,MAAM,YAAY;CACtD,IAAI,UAAU;CACd,IAAI,CAAC,KAAK,SAAS,GAAG,KAAK,SAAS,SAAS,YAAY,GAAG;EAC1D,MAAM,WAAW,uBAAuB,KAAK,KAAK,UAAU,IAAI,CAAC;EACjE,WAAW,IAAI,SAAS;CAC1B;CACA,MAAM,WAAW,KAAK,KAAK,UAAU,GAAG,QAAQ,KAAK;CACrD,eAAe,QAAQ;CACvB,MAAM,SAAS,GAAG,aAAa,UAAU,MAAM;CAC/C,OAAO,OAAO,QAAQ,OAAO;AAC/B;AACA,SAAS,uBAAuB,UAAU;CACxC,IAAI,CAAC,GAAG,WAAW,QAAQ,GAAG,OAAO,CAAC;CACtC,OAAO,GAAG,YAAY,QAAQ,CAAC,CAAC,KAAK,aAAa,SAAS,QAAQ,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,QAAQ;AAChH"}
|
package/dist/index.js
CHANGED
|
@@ -6,5 +6,5 @@ import { slugPlugin } from "./slugPlugin.mjs";
|
|
|
6
6
|
import { tableWhitespacePlugin } from "./tableWhitespacePlugin.mjs";
|
|
7
7
|
import { processImageMeta } from "./processImageMeta.mjs";
|
|
8
8
|
import { notifyFileRead } from "./watchFile.mjs";
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
export { getAllFrontmatter, getAllVersionsFromPath, getHeadings, getMDX, getMDXBySlug, notifyFileRead, processImageMeta, slugPlugin, tableWhitespacePlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -6,5 +6,5 @@ import { slugPlugin } from "./slugPlugin.mjs";
|
|
|
6
6
|
import { tableWhitespacePlugin } from "./tableWhitespacePlugin.mjs";
|
|
7
7
|
import { processImageMeta } from "./processImageMeta.mjs";
|
|
8
8
|
import { notifyFileRead } from "./watchFile.mjs";
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
export { getAllFrontmatter, getAllVersionsFromPath, getHeadings, getMDX, getMDXBySlug, notifyFileRead, processImageMeta, slugPlugin, tableWhitespacePlugin };
|
|
@@ -1,37 +1,34 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
|
+
|
|
3
4
|
async function getSharp() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
try {
|
|
6
|
+
const sharpModule = await import("sharp");
|
|
7
|
+
return sharpModule.default;
|
|
8
|
+
} catch {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
10
11
|
}
|
|
11
12
|
async function processImageMeta(imagePath, opts) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
blurDataURL
|
|
31
|
-
};
|
|
32
|
-
} catch {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
13
|
+
const publicDir = opts?.publicDir ?? "./public";
|
|
14
|
+
const filePath = imagePath.startsWith("/") ? resolve(publicDir, imagePath.slice(1)) : resolve(imagePath);
|
|
15
|
+
if (!existsSync(filePath)) return null;
|
|
16
|
+
const sharp = await getSharp();
|
|
17
|
+
if (!sharp) return null;
|
|
18
|
+
try {
|
|
19
|
+
const image = sharp(filePath);
|
|
20
|
+
const { width = 0, height = 0 } = await image.metadata();
|
|
21
|
+
const blurBuffer = await image.resize(10).blur().jpeg({ quality: 40 }).toBuffer();
|
|
22
|
+
const blurDataURL = `data:image/jpeg;base64,${blurBuffer.toString("base64")}`;
|
|
23
|
+
return {
|
|
24
|
+
width,
|
|
25
|
+
height,
|
|
26
|
+
blurDataURL
|
|
27
|
+
};
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
35
31
|
}
|
|
32
|
+
|
|
36
33
|
export { processImageMeta };
|
|
37
34
|
//# sourceMappingURL=processImageMeta.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"processImageMeta.js","names":[],"sources":["processImageMeta.js"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nasync function getSharp() {\n try {\n const sharpModule = await import(\"sharp\");\n return sharpModule.default;\n } catch {\n return null;\n }\n}\nasync function processImageMeta(imagePath, opts) {\n const publicDir = opts?.publicDir ?? \"./public\";\n const filePath = imagePath.startsWith(\"/\") ? resolve(publicDir, imagePath.slice(1)) : resolve(imagePath);\n if (!existsSync(filePath)) return null;\n const sharp = await getSharp();\n if (!sharp) return null;\n try {\n const image = sharp(filePath);\n const { width = 0, height = 0 } = await image.metadata();\n const blurBuffer = await image.resize(10).blur().jpeg({ quality: 40 }).toBuffer();\n const blurDataURL = `data:image/jpeg;base64,${blurBuffer.toString(\"base64\")}`;\n return { width, height, blurDataURL };\n } catch {\n return null;\n }\n}\nexport {\n processImageMeta\n};\n//# sourceMappingURL=processImageMeta.js.map\n"],"mappings":";;;;AAEA,eAAe,WAAW;CACxB,IAAI;EACF,MAAM,cAAc,MAAM,OAAO;EACjC,OAAO,YAAY;CACrB,QAAQ;EACN,OAAO;CACT;AACF;AACA,eAAe,iBAAiB,WAAW,MAAM;CAC/C,MAAM,YAAY,MAAM,aAAa;CACrC,MAAM,WAAW,UAAU,WAAW,GAAG,IAAI,QAAQ,WAAW,UAAU,MAAM,CAAC,CAAC,IAAI,QAAQ,SAAS;CACvG,IAAI,CAAC,WAAW,QAAQ,GAAG,OAAO;CAClC,MAAM,QAAQ,MAAM,SAAS;CAC7B,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI;EACF,MAAM,QAAQ,MAAM,QAAQ;EAC5B,MAAM,EAAE,QAAQ,GAAG,SAAS,MAAM,MAAM,MAAM,SAAS;EACvD,MAAM,aAAa,MAAM,MAAM,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC,SAAS;EAChF,MAAM,cAAc,0BAA0B,WAAW,SAAS,QAAQ;EAC1E,OAAO;GAAE;GAAO;GAAQ;EAAY;CACtC,QAAQ;EACN,OAAO;CACT;AACF"}
|
package/dist/slugPlugin.mjs
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
import GithubSlugger from "github-slugger";
|
|
2
2
|
import { defineHastPlugin } from "satteri";
|
|
3
|
+
|
|
3
4
|
function textOf(node) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
if (node.type === "text") return node.value || "";
|
|
6
|
+
if (node.children) return node.children.map(textOf).join("");
|
|
7
|
+
return "";
|
|
7
8
|
}
|
|
8
9
|
const slugPlugin = () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
const slugger = new GithubSlugger();
|
|
11
|
+
return defineHastPlugin({
|
|
12
|
+
name: "vxrn-heading-slugs",
|
|
13
|
+
element: {
|
|
14
|
+
filter: [
|
|
15
|
+
"h1",
|
|
16
|
+
"h2",
|
|
17
|
+
"h3",
|
|
18
|
+
"h4",
|
|
19
|
+
"h5",
|
|
20
|
+
"h6"
|
|
21
|
+
],
|
|
22
|
+
visit(node, ctx) {
|
|
23
|
+
if (node.properties?.id) return;
|
|
24
|
+
const id = slugger.slug(textOf(node));
|
|
25
|
+
ctx.replaceNode(node, {
|
|
26
|
+
...node,
|
|
27
|
+
properties: {
|
|
28
|
+
...node.properties,
|
|
29
|
+
id
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
27
35
|
};
|
|
36
|
+
|
|
28
37
|
export { slugPlugin };
|
|
29
38
|
//# sourceMappingURL=slugPlugin.mjs.map
|
package/dist/slugPlugin.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"slugPlugin.js","names":[],"sources":["slugPlugin.js"],"sourcesContent":["import GithubSlugger from \"github-slugger\";\nimport { defineHastPlugin } from \"satteri\";\nfunction textOf(node) {\n if (node.type === \"text\") return node.value || \"\";\n if (node.children) return node.children.map(textOf).join(\"\");\n return \"\";\n}\nconst slugPlugin = () => {\n const slugger = new GithubSlugger();\n return defineHastPlugin({\n name: \"vxrn-heading-slugs\",\n element: {\n filter: [\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"],\n visit(node, ctx) {\n if (node.properties?.id) return;\n const id = slugger.slug(textOf(node));\n ctx.replaceNode(node, {\n ...node,\n properties: { ...node.properties, id }\n });\n }\n }\n });\n};\nexport {\n slugPlugin\n};\n//# sourceMappingURL=slugPlugin.js.map\n"],"mappings":";;;;AAEA,SAAS,OAAO,MAAM;CACpB,IAAI,KAAK,SAAS,QAAQ,OAAO,KAAK,SAAS;CAC/C,IAAI,KAAK,UAAU,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,CAAC,KAAK,EAAE;CAC3D,OAAO;AACT;AACA,MAAM,mBAAmB;CACvB,MAAM,UAAU,IAAI,cAAc;CAClC,OAAO,iBAAiB;EACtB,MAAM;EACN,SAAS;GACP,QAAQ;IAAC;IAAM;IAAM;IAAM;IAAM;IAAM;GAAI;GAC3C,MAAM,MAAM,KAAK;IACf,IAAI,KAAK,YAAY,IAAI;IACzB,MAAM,KAAK,QAAQ,KAAK,OAAO,IAAI,CAAC;IACpC,IAAI,YAAY,MAAM;KACpB,GAAG;KACH,YAAY;MAAE,GAAG,KAAK;MAAY;KAAG;IACvC,CAAC;GACH;EACF;CACF,CAAC;AACH"}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import { defineHastPlugin } from "satteri";
|
|
2
|
+
|
|
2
3
|
const tableWhitespacePlugin = defineHastPlugin({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
name: "vxrn-strip-table-whitespace",
|
|
5
|
+
element: {
|
|
6
|
+
filter: [
|
|
7
|
+
"table",
|
|
8
|
+
"thead",
|
|
9
|
+
"tbody",
|
|
10
|
+
"tr"
|
|
11
|
+
],
|
|
12
|
+
visit(node, ctx) {
|
|
13
|
+
const children = node.children || [];
|
|
14
|
+
const cleaned = children.filter((c) => !(c.type === "text" && typeof c.value === "string" && c.value.trim() === ""));
|
|
15
|
+
if (cleaned.length !== children.length) {
|
|
16
|
+
ctx.replaceNode(node, {
|
|
17
|
+
...node,
|
|
18
|
+
children: cleaned
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
17
23
|
});
|
|
24
|
+
|
|
18
25
|
export { tableWhitespacePlugin };
|
|
19
26
|
//# sourceMappingURL=tableWhitespacePlugin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"tableWhitespacePlugin.js","names":[],"sources":["tableWhitespacePlugin.js"],"sourcesContent":["import { defineHastPlugin } from \"satteri\";\nconst tableWhitespacePlugin = defineHastPlugin({\n name: \"vxrn-strip-table-whitespace\",\n element: {\n filter: [\"table\", \"thead\", \"tbody\", \"tr\"],\n visit(node, ctx) {\n const children = node.children || [];\n const cleaned = children.filter(\n (c) => !(c.type === \"text\" && typeof c.value === \"string\" && c.value.trim() === \"\")\n );\n if (cleaned.length !== children.length) {\n ctx.replaceNode(node, { ...node, children: cleaned });\n }\n }\n }\n});\nexport {\n tableWhitespacePlugin\n};\n//# sourceMappingURL=tableWhitespacePlugin.js.map\n"],"mappings":";;;AACA,MAAM,wBAAwB,iBAAiB;CAC7C,MAAM;CACN,SAAS;EACP,QAAQ;GAAC;GAAS;GAAS;GAAS;EAAI;EACxC,MAAM,MAAM,KAAK;GACf,MAAM,WAAW,KAAK,YAAY,CAAC;GACnC,MAAM,UAAU,SAAS,QACtB,MAAM,EAAE,EAAE,SAAS,UAAU,OAAO,EAAE,UAAU,YAAY,EAAE,MAAM,KAAK,MAAM,GAClF;GACA,IAAI,QAAQ,WAAW,SAAS,QAAQ;IACtC,IAAI,YAAY,MAAM;KAAE,GAAG;KAAM,UAAU;IAAQ,CAAC;GACtD;EACF;CACF;AACF,CAAC"}
|
package/dist/types.mjs
CHANGED
package/dist/watchFile.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const WATCH_FILE_KEY = "__oneWatchFile";
|
|
2
2
|
function notifyFileRead(filePath) {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const watchFile = globalThis[WATCH_FILE_KEY];
|
|
4
|
+
if (watchFile) watchFile(filePath);
|
|
5
5
|
}
|
|
6
|
+
|
|
6
7
|
export { notifyFileRead };
|
|
7
8
|
//# sourceMappingURL=watchFile.mjs.map
|
package/dist/watchFile.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"watchFile.js","names":[],"sources":["watchFile.js"],"sourcesContent":["const WATCH_FILE_KEY = \"__oneWatchFile\";\nfunction notifyFileRead(filePath) {\n const watchFile = globalThis[WATCH_FILE_KEY];\n if (watchFile) watchFile(filePath);\n}\nexport {\n notifyFileRead\n};\n//# sourceMappingURL=watchFile.js.map\n"],"mappings":";AAAA,MAAM,iBAAiB;AACvB,SAAS,eAAe,UAAU;CAChC,MAAM,YAAY,WAAW;CAC7B,IAAI,WAAW,UAAU,QAAQ;AACnC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vxrn/mdx-rust",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.46.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "dist",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"react": "*"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@tamagui/build": "
|
|
51
|
+
"@tamagui/build": "3.0.0-beta.1309.1",
|
|
52
52
|
"react": "19.2.3"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAllFrontmatter.d.ts","sourceRoot":"","sources":["../src/getAllFrontmatter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAK1C,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"getAllFrontmatter.d.ts","sourceRoot":"","sources":["../src/getAllFrontmatter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAK1C,eAAO,MAAM,iBAAiB,aAAc,MAAM,KAAG,WAAW,EAqB/D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHeadings.d.ts","sourceRoot":"","sources":["../src/getHeadings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAMtC,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"getHeadings.d.ts","sourceRoot":"","sources":["../src/getHeadings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAMtC,eAAO,MAAM,WAAW,WAAY,MAAM,KAAG,OAAO,EAUnD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMDXBySlug.d.ts","sourceRoot":"","sources":["../src/getMDXBySlug.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAU,MAAM,UAAU,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"getMDXBySlug.d.ts","sourceRoot":"","sources":["../src/getMDXBySlug.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAU,MAAM,UAAU,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C,eAAO,MAAM,YAAY,aACb,MAAM,QACV,MAAM,YACF,aAAa,KACtB,OAAO,CAAC;IAAE,WAAW,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAapD,CAAA;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAOjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slugPlugin.d.ts","sourceRoot":"","sources":["../src/slugPlugin.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"slugPlugin.d.ts","sourceRoot":"","sources":["../src/slugPlugin.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,UAAU;;;QAKjB,MAAM;QACN,KAAK,OAAO,GAAG,OAAO,GAAG;;CAU9B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableWhitespacePlugin.d.ts","sourceRoot":"","sources":["../src/tableWhitespacePlugin.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"tableWhitespacePlugin.d.ts","sourceRoot":"","sources":["../src/tableWhitespacePlugin.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,qBAAqB;;;QAG9B,MAAM;QACN,KAAK,OAAO,GAAG,OAAO,GAAG;;CAW3B,CAAA"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getMDX","getAllVersionsFromPath","getMDXBySlug","getAllFrontmatter","getHeadings","slugPlugin","tableWhitespacePlugin","processImageMeta","notifyFileRead"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAkC;AAC3C,SAASC,sBAAA,EAAwBC,YAAA,QAAoB;AACrD,SAASC,iBAAA,QAAyB;AAClC,SAASC,WAAA,QAAmB;AAC5B,SAASC,UAAA,QAAkB;AAC3B,SAASC,qBAAA,QAA6B;AACtC,SAASC,gBAAA,QAAwB;AACjC,SAASC,cAAA,QAAsB","ignoreList":[]}
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getMDX","getAllVersionsFromPath","getMDXBySlug","getAllFrontmatter","getHeadings","slugPlugin","tableWhitespacePlugin","processImageMeta","notifyFileRead"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAkC;AAC3C,SAASC,sBAAA,EAAwBC,YAAA,QAAoB;AACrD,SAASC,iBAAA,QAAyB;AAClC,SAASC,WAAA,QAAmB;AAC5B,SAASC,UAAA,QAAkB;AAC3B,SAASC,qBAAA,QAA6B;AACtC,SAASC,gBAAA,QAAwB;AACjC,SAASC,cAAA,QAAsB","ignoreList":[]}
|
package/dist/types.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
|