@nuxtjs/mdc 0.4.0 → 0.5.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/module.d.mts +8 -1
- package/dist/module.d.ts +8 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +30 -13
- package/dist/runtime/parser/index.mjs +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +3 -3
package/dist/module.d.mts
CHANGED
|
@@ -32,6 +32,12 @@ interface ModuleOptions {
|
|
|
32
32
|
theme?: MdcThemeOptions;
|
|
33
33
|
/**
|
|
34
34
|
* Languages to be bundled loaded by Shiki
|
|
35
|
+
*
|
|
36
|
+
* All languages used has to be included in this list at build time, to create granular bundles.
|
|
37
|
+
*
|
|
38
|
+
* Unlike the `preload` option, when this option is provided, it will override the default languages.
|
|
39
|
+
*
|
|
40
|
+
* @default ['js','jsx','json','ts','tsx','vue','css','html','vue','bash','md','mdc','yaml']
|
|
35
41
|
*/
|
|
36
42
|
langs?: (BundledLanguage | LanguageRegistration)[];
|
|
37
43
|
/**
|
|
@@ -62,6 +68,7 @@ interface ModuleOptions {
|
|
|
62
68
|
};
|
|
63
69
|
}
|
|
64
70
|
|
|
71
|
+
declare const DefaultHighlightLangs: BundledLanguage[];
|
|
65
72
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
66
73
|
|
|
67
74
|
declare module '@nuxt/schema' {
|
|
@@ -92,4 +99,4 @@ declare module '@nuxt/schema' {
|
|
|
92
99
|
}
|
|
93
100
|
}
|
|
94
101
|
|
|
95
|
-
export { _default as default };
|
|
102
|
+
export { DefaultHighlightLangs, _default as default };
|
package/dist/module.d.ts
CHANGED
|
@@ -32,6 +32,12 @@ interface ModuleOptions {
|
|
|
32
32
|
theme?: MdcThemeOptions;
|
|
33
33
|
/**
|
|
34
34
|
* Languages to be bundled loaded by Shiki
|
|
35
|
+
*
|
|
36
|
+
* All languages used has to be included in this list at build time, to create granular bundles.
|
|
37
|
+
*
|
|
38
|
+
* Unlike the `preload` option, when this option is provided, it will override the default languages.
|
|
39
|
+
*
|
|
40
|
+
* @default ['js','jsx','json','ts','tsx','vue','css','html','vue','bash','md','mdc','yaml']
|
|
35
41
|
*/
|
|
36
42
|
langs?: (BundledLanguage | LanguageRegistration)[];
|
|
37
43
|
/**
|
|
@@ -62,6 +68,7 @@ interface ModuleOptions {
|
|
|
62
68
|
};
|
|
63
69
|
}
|
|
64
70
|
|
|
71
|
+
declare const DefaultHighlightLangs: BundledLanguage[];
|
|
65
72
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
66
73
|
|
|
67
74
|
declare module '@nuxt/schema' {
|
|
@@ -92,4 +99,4 @@ declare module '@nuxt/schema' {
|
|
|
92
99
|
}
|
|
93
100
|
}
|
|
94
101
|
|
|
95
|
-
export { _default as default };
|
|
102
|
+
export { DefaultHighlightLangs, _default as default };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -55,7 +55,8 @@ async function mdcConfigs({ options }) {
|
|
|
55
55
|
async function mdcHighlighter({
|
|
56
56
|
options: {
|
|
57
57
|
shikiPath,
|
|
58
|
-
options
|
|
58
|
+
options,
|
|
59
|
+
useWasmAssets
|
|
59
60
|
}
|
|
60
61
|
}) {
|
|
61
62
|
if (!options || !options.highlighter)
|
|
@@ -67,7 +68,14 @@ async function mdcHighlighter({
|
|
|
67
68
|
].find((file2) => existsSync(file2));
|
|
68
69
|
if (!file)
|
|
69
70
|
throw new Error(`[@nuxtjs/mdc] Could not find shiki highlighter: ${shikiPath}`);
|
|
70
|
-
|
|
71
|
+
let code = await fs.readFile(file, "utf-8");
|
|
72
|
+
if (useWasmAssets) {
|
|
73
|
+
code = code.replace(
|
|
74
|
+
/import\((['"])shiki\/wasm\1\)/,
|
|
75
|
+
// We can remove the .client condition once Vite supports WASM ESM import
|
|
76
|
+
"import.meta.client ? import('shiki/wasm') : import('shiki/onig.wasm')"
|
|
77
|
+
);
|
|
78
|
+
}
|
|
71
79
|
const { bundledLanguagesInfo } = await import('shiki/langs');
|
|
72
80
|
const langsMap = /* @__PURE__ */ new Map();
|
|
73
81
|
options.langs?.forEach((lang) => {
|
|
@@ -159,6 +167,21 @@ function processUnistPlugins(plugins) {
|
|
|
159
167
|
return { imports, definitions };
|
|
160
168
|
}
|
|
161
169
|
|
|
170
|
+
const DefaultHighlightLangs = [
|
|
171
|
+
"js",
|
|
172
|
+
"jsx",
|
|
173
|
+
"json",
|
|
174
|
+
"ts",
|
|
175
|
+
"tsx",
|
|
176
|
+
"vue",
|
|
177
|
+
"css",
|
|
178
|
+
"html",
|
|
179
|
+
"vue",
|
|
180
|
+
"bash",
|
|
181
|
+
"md",
|
|
182
|
+
"mdc",
|
|
183
|
+
"yaml"
|
|
184
|
+
];
|
|
162
185
|
const module = defineNuxtModule({
|
|
163
186
|
meta: {
|
|
164
187
|
name: "@nuxtjs/mdc",
|
|
@@ -266,7 +289,9 @@ const module = defineNuxtModule({
|
|
|
266
289
|
getContents: mdcHighlighter,
|
|
267
290
|
options: {
|
|
268
291
|
shikiPath: resolver.resolve("../dist/runtime/highlighter/shiki"),
|
|
269
|
-
options: options.highlight
|
|
292
|
+
options: options.highlight,
|
|
293
|
+
// When WASM support enabled in Nitro, we could use the .wasm file directly for Cloudflare Workers
|
|
294
|
+
useWasmAssets: !nuxt.options.dev && !!nuxt.options.nitro.experimental?.wasm
|
|
270
295
|
}
|
|
271
296
|
});
|
|
272
297
|
registerTemplate({
|
|
@@ -354,19 +379,11 @@ function resolveOptions(options) {
|
|
|
354
379
|
default: "github-light",
|
|
355
380
|
dark: "github-dark"
|
|
356
381
|
};
|
|
357
|
-
options.highlight.langs ||=
|
|
358
|
-
"js",
|
|
359
|
-
"ts",
|
|
360
|
-
"vue",
|
|
361
|
-
"css",
|
|
362
|
-
"html",
|
|
363
|
-
"vue",
|
|
364
|
-
"shell"
|
|
365
|
-
];
|
|
382
|
+
options.highlight.langs ||= DefaultHighlightLangs;
|
|
366
383
|
if (options.highlight.preload) {
|
|
367
384
|
options.highlight.langs.push(...options.highlight.preload || []);
|
|
368
385
|
}
|
|
369
386
|
}
|
|
370
387
|
}
|
|
371
388
|
|
|
372
|
-
export { module as default };
|
|
389
|
+
export { DefaultHighlightLangs, module as default };
|
|
@@ -27,7 +27,7 @@ export const parseMarkdown = async (md, inlineOptions = {}) => {
|
|
|
27
27
|
...generatedMdcConfigs || [],
|
|
28
28
|
...inlineOptions.configs || []
|
|
29
29
|
];
|
|
30
|
-
if (inlineOptions.highlight != null && inlineOptions.highlight != false && typeof inlineOptions.highlight.highlighter !== "function") {
|
|
30
|
+
if (inlineOptions.highlight != null && inlineOptions.highlight != false && inlineOptions.highlight.highlighter !== void 0 && typeof inlineOptions.highlight.highlighter !== "function") {
|
|
31
31
|
if (import.meta.dev)
|
|
32
32
|
console.warn("[@nuxtjs/mdc] `highlighter` passed to `parseMarkdown` is should be a function, but got " + JSON.stringify(inlineOptions.highlight.highlighter) + ", ignored.");
|
|
33
33
|
inlineOptions = {
|
package/dist/types.d.mts
CHANGED
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/mdc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Nuxt MDC module",
|
|
5
5
|
"repository": "nuxt-modules/mdc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@nuxt/kit": "^3.10.0",
|
|
54
|
-
"@shikijs/transformers": "^1.0.0-beta.
|
|
54
|
+
"@shikijs/transformers": "^1.0.0-beta.6",
|
|
55
55
|
"@types/hast": "^3.0.4",
|
|
56
56
|
"@types/mdast": "^4.0.3",
|
|
57
57
|
"@vue/compiler-core": "^3.4.15",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"remark-parse": "^11.0.0",
|
|
80
80
|
"remark-rehype": "^11.1.0",
|
|
81
81
|
"scule": "^1.2.0",
|
|
82
|
-
"shiki": "^1.0.0-beta.
|
|
82
|
+
"shiki": "^1.0.0-beta.6",
|
|
83
83
|
"ufo": "^1.3.2",
|
|
84
84
|
"unified": "^11.0.4",
|
|
85
85
|
"unist-builder": "^4.0.0",
|