@nuxtjs/mdc 0.8.3 → 0.9.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/module.d.mts +18 -14
- package/dist/module.d.ts +18 -14
- package/dist/module.json +2 -2
- package/dist/module.mjs +18 -11
- package/dist/runtime/components/MDC.vue +1 -1
- package/dist/runtime/components/MDCRenderer.vue +3 -6
- package/dist/runtime/components/MDCRenderer.vue.d.ts +310 -8
- package/dist/runtime/components/MDCSlot.vue +1 -1
- package/dist/runtime/components/MDCSlot.vue.d.ts +6 -6
- package/dist/runtime/components/prose/ProseA.vue +3 -3
- package/dist/runtime/components/prose/ProseH1.vue +2 -2
- package/dist/runtime/components/prose/ProseH2.vue +3 -3
- package/dist/runtime/components/prose/ProseH3.vue +3 -3
- package/dist/runtime/components/prose/ProseH4.vue +3 -3
- package/dist/runtime/components/prose/ProseH5.vue +3 -3
- package/dist/runtime/components/prose/ProseH6.vue +3 -3
- package/dist/runtime/components/prose/ProseImg.vue +6 -6
- package/dist/runtime/highlighter/event-handler.js +1 -1
- package/dist/runtime/highlighter/shiki.d.ts +3 -2
- package/dist/runtime/highlighter/shiki.js +27 -20
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/parser/handlers/code.d.ts +1 -1
- package/dist/runtime/parser/handlers/containerComponent.d.ts +1 -1
- package/dist/runtime/parser/handlers/emphasis.d.ts +1 -1
- package/dist/runtime/parser/handlers/html.d.ts +1 -1
- package/dist/runtime/parser/handlers/image.d.ts +1 -1
- package/dist/runtime/parser/handlers/inlineCode.d.ts +1 -1
- package/dist/runtime/parser/handlers/link.d.ts +1 -1
- package/dist/runtime/parser/handlers/list.d.ts +1 -1
- package/dist/runtime/parser/handlers/paragraph.d.ts +1 -1
- package/dist/runtime/parser/handlers/strong.d.ts +1 -1
- package/dist/runtime/parser/index.js +1 -1
- package/dist/runtime/utils/slot.d.ts +1 -1
- package/package.json +29 -29
package/dist/module.d.mts
CHANGED
|
@@ -122,6 +122,15 @@ interface ModuleOptions {
|
|
|
122
122
|
* Additional themes to be bundled loaded by Shiki
|
|
123
123
|
*/
|
|
124
124
|
themes?: (BundledTheme | ThemeRegistrationAny)[];
|
|
125
|
+
/**
|
|
126
|
+
* Engine to be used for Shiki
|
|
127
|
+
*
|
|
128
|
+
* Note that the `javascript` engine still in experimental, use with caution.
|
|
129
|
+
*
|
|
130
|
+
* @see https://shiki.style/guide/regex-engines
|
|
131
|
+
* @default 'oniguruma'
|
|
132
|
+
*/
|
|
133
|
+
shikiEngine?: 'oniguruma' | 'javascript';
|
|
125
134
|
/**
|
|
126
135
|
* Preloaded languages that will be available for highlighting code blocks.
|
|
127
136
|
*
|
|
@@ -134,6 +143,7 @@ interface ModuleOptions {
|
|
|
134
143
|
* @default false
|
|
135
144
|
*/
|
|
136
145
|
wrapperStyle?: boolean | string;
|
|
146
|
+
noApiRoute?: boolean;
|
|
137
147
|
} | false;
|
|
138
148
|
headings?: {
|
|
139
149
|
anchorLinks?: {
|
|
@@ -167,6 +177,7 @@ interface ModuleOptions {
|
|
|
167
177
|
* ```
|
|
168
178
|
*/
|
|
169
179
|
interface Data$1 {
|
|
180
|
+
[key: string]: unknown;
|
|
170
181
|
}
|
|
171
182
|
/**
|
|
172
183
|
* One place in a source file.
|
|
@@ -273,8 +284,7 @@ interface Parent$1 extends Node$1 {
|
|
|
273
284
|
* }
|
|
274
285
|
* ```
|
|
275
286
|
*/
|
|
276
|
-
|
|
277
|
-
}
|
|
287
|
+
type Data = Data$1;
|
|
278
288
|
/**
|
|
279
289
|
* Info associated with an element.
|
|
280
290
|
*/
|
|
@@ -410,8 +420,7 @@ interface Comment extends Literal {
|
|
|
410
420
|
/**
|
|
411
421
|
* Info associated with hast comments by the ecosystem.
|
|
412
422
|
*/
|
|
413
|
-
|
|
414
|
-
}
|
|
423
|
+
type CommentData = Data;
|
|
415
424
|
/**
|
|
416
425
|
* HTML document type.
|
|
417
426
|
*/
|
|
@@ -428,8 +437,7 @@ interface Doctype extends Node$1 {
|
|
|
428
437
|
/**
|
|
429
438
|
* Info associated with hast doctypes by the ecosystem.
|
|
430
439
|
*/
|
|
431
|
-
|
|
432
|
-
}
|
|
440
|
+
type DoctypeData = Data;
|
|
433
441
|
/**
|
|
434
442
|
* HTML element.
|
|
435
443
|
*/
|
|
@@ -463,8 +471,7 @@ interface Element extends Parent {
|
|
|
463
471
|
/**
|
|
464
472
|
* Info associated with hast elements by the ecosystem.
|
|
465
473
|
*/
|
|
466
|
-
|
|
467
|
-
}
|
|
474
|
+
type ElementData = Data;
|
|
468
475
|
/**
|
|
469
476
|
* Document fragment or a whole document.
|
|
470
477
|
*
|
|
@@ -489,8 +496,7 @@ interface Root extends Parent {
|
|
|
489
496
|
/**
|
|
490
497
|
* Info associated with hast root nodes by the ecosystem.
|
|
491
498
|
*/
|
|
492
|
-
|
|
493
|
-
}
|
|
499
|
+
type RootData = Data;
|
|
494
500
|
/**
|
|
495
501
|
* HTML character data (plain text).
|
|
496
502
|
*/
|
|
@@ -507,11 +513,10 @@ interface Text extends Literal {
|
|
|
507
513
|
/**
|
|
508
514
|
* Info associated with hast texts by the ecosystem.
|
|
509
515
|
*/
|
|
510
|
-
|
|
511
|
-
}
|
|
516
|
+
type TextData = Data;
|
|
512
517
|
|
|
513
518
|
declare const DefaultHighlightLangs: BundledLanguage[];
|
|
514
|
-
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
519
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
515
520
|
|
|
516
521
|
declare module '@nuxt/schema' {
|
|
517
522
|
interface NuxtHooks {
|
|
@@ -524,7 +529,6 @@ declare module '@nuxt/schema' {
|
|
|
524
529
|
map: Record<string, string>;
|
|
525
530
|
};
|
|
526
531
|
headings: ModuleOptions['headings'];
|
|
527
|
-
useNuxtImage?: boolean;
|
|
528
532
|
};
|
|
529
533
|
}
|
|
530
534
|
interface ConfigSchema {
|
package/dist/module.d.ts
CHANGED
|
@@ -122,6 +122,15 @@ interface ModuleOptions {
|
|
|
122
122
|
* Additional themes to be bundled loaded by Shiki
|
|
123
123
|
*/
|
|
124
124
|
themes?: (BundledTheme | ThemeRegistrationAny)[];
|
|
125
|
+
/**
|
|
126
|
+
* Engine to be used for Shiki
|
|
127
|
+
*
|
|
128
|
+
* Note that the `javascript` engine still in experimental, use with caution.
|
|
129
|
+
*
|
|
130
|
+
* @see https://shiki.style/guide/regex-engines
|
|
131
|
+
* @default 'oniguruma'
|
|
132
|
+
*/
|
|
133
|
+
shikiEngine?: 'oniguruma' | 'javascript';
|
|
125
134
|
/**
|
|
126
135
|
* Preloaded languages that will be available for highlighting code blocks.
|
|
127
136
|
*
|
|
@@ -134,6 +143,7 @@ interface ModuleOptions {
|
|
|
134
143
|
* @default false
|
|
135
144
|
*/
|
|
136
145
|
wrapperStyle?: boolean | string;
|
|
146
|
+
noApiRoute?: boolean;
|
|
137
147
|
} | false;
|
|
138
148
|
headings?: {
|
|
139
149
|
anchorLinks?: {
|
|
@@ -167,6 +177,7 @@ interface ModuleOptions {
|
|
|
167
177
|
* ```
|
|
168
178
|
*/
|
|
169
179
|
interface Data$1 {
|
|
180
|
+
[key: string]: unknown;
|
|
170
181
|
}
|
|
171
182
|
/**
|
|
172
183
|
* One place in a source file.
|
|
@@ -273,8 +284,7 @@ interface Parent$1 extends Node$1 {
|
|
|
273
284
|
* }
|
|
274
285
|
* ```
|
|
275
286
|
*/
|
|
276
|
-
|
|
277
|
-
}
|
|
287
|
+
type Data = Data$1;
|
|
278
288
|
/**
|
|
279
289
|
* Info associated with an element.
|
|
280
290
|
*/
|
|
@@ -410,8 +420,7 @@ interface Comment extends Literal {
|
|
|
410
420
|
/**
|
|
411
421
|
* Info associated with hast comments by the ecosystem.
|
|
412
422
|
*/
|
|
413
|
-
|
|
414
|
-
}
|
|
423
|
+
type CommentData = Data;
|
|
415
424
|
/**
|
|
416
425
|
* HTML document type.
|
|
417
426
|
*/
|
|
@@ -428,8 +437,7 @@ interface Doctype extends Node$1 {
|
|
|
428
437
|
/**
|
|
429
438
|
* Info associated with hast doctypes by the ecosystem.
|
|
430
439
|
*/
|
|
431
|
-
|
|
432
|
-
}
|
|
440
|
+
type DoctypeData = Data;
|
|
433
441
|
/**
|
|
434
442
|
* HTML element.
|
|
435
443
|
*/
|
|
@@ -463,8 +471,7 @@ interface Element extends Parent {
|
|
|
463
471
|
/**
|
|
464
472
|
* Info associated with hast elements by the ecosystem.
|
|
465
473
|
*/
|
|
466
|
-
|
|
467
|
-
}
|
|
474
|
+
type ElementData = Data;
|
|
468
475
|
/**
|
|
469
476
|
* Document fragment or a whole document.
|
|
470
477
|
*
|
|
@@ -489,8 +496,7 @@ interface Root extends Parent {
|
|
|
489
496
|
/**
|
|
490
497
|
* Info associated with hast root nodes by the ecosystem.
|
|
491
498
|
*/
|
|
492
|
-
|
|
493
|
-
}
|
|
499
|
+
type RootData = Data;
|
|
494
500
|
/**
|
|
495
501
|
* HTML character data (plain text).
|
|
496
502
|
*/
|
|
@@ -507,11 +513,10 @@ interface Text extends Literal {
|
|
|
507
513
|
/**
|
|
508
514
|
* Info associated with hast texts by the ecosystem.
|
|
509
515
|
*/
|
|
510
|
-
|
|
511
|
-
}
|
|
516
|
+
type TextData = Data;
|
|
512
517
|
|
|
513
518
|
declare const DefaultHighlightLangs: BundledLanguage[];
|
|
514
|
-
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
519
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
515
520
|
|
|
516
521
|
declare module '@nuxt/schema' {
|
|
517
522
|
interface NuxtHooks {
|
|
@@ -524,7 +529,6 @@ declare module '@nuxt/schema' {
|
|
|
524
529
|
map: Record<string, string>;
|
|
525
530
|
};
|
|
526
531
|
headings: ModuleOptions['headings'];
|
|
527
|
-
useNuxtImage?: boolean;
|
|
528
532
|
};
|
|
529
533
|
}
|
|
530
534
|
interface ConfigSchema {
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs$1, { existsSync } from 'node:fs';
|
|
2
|
-
import { extendViteConfig, useNitro, defineNuxtModule, createResolver, addServerHandler, addComponent, addImports, addServerImports, addComponentsDir,
|
|
2
|
+
import { extendViteConfig, useNitro, defineNuxtModule, createResolver, addServerHandler, addComponent, addImports, addServerImports, addComponentsDir, addTemplate } from '@nuxt/kit';
|
|
3
3
|
import { defu } from 'defu';
|
|
4
4
|
import { resolve } from 'pathe';
|
|
5
5
|
import fs from 'node:fs/promises';
|
|
@@ -97,8 +97,12 @@ async function mdcHighlighter({
|
|
|
97
97
|
...typeof options?.theme === "string" ? [options?.theme] : Object.values(options?.theme || {}),
|
|
98
98
|
...options?.themes || []
|
|
99
99
|
]));
|
|
100
|
+
const {
|
|
101
|
+
shikiEngine = "oniguruma"
|
|
102
|
+
} = options;
|
|
100
103
|
return [
|
|
101
104
|
"import { getMdcConfigs } from '#mdc-configs'",
|
|
105
|
+
shikiEngine === "javascript" ? "import { createJavaScriptRegexEngine } from 'shiki/engine/javascript'" : "import { createWasmOnigEngine } from 'shiki/engine/oniguruma'",
|
|
102
106
|
code,
|
|
103
107
|
"const bundledLangs = {",
|
|
104
108
|
...Array.from(langsMap.entries()).map(([name, lang]) => typeof lang === "string" ? JSON.stringify(name) + `: () => import('shiki/langs/${lang}.mjs'),` : JSON.stringify(name) + ": " + JSON.stringify(lang) + ","),
|
|
@@ -110,7 +114,8 @@ async function mdcHighlighter({
|
|
|
110
114
|
theme: options.theme,
|
|
111
115
|
wrapperStyle: options.wrapperStyle
|
|
112
116
|
}),
|
|
113
|
-
"const
|
|
117
|
+
shikiEngine === "javascript" ? "const engine = createJavaScriptRegexEngine({ forgiving: true })" : `const engine = createWasmOnigEngine(() => import('shiki/wasm'))`,
|
|
118
|
+
"const highlighter = createShikiHighlighter({ bundledLangs, bundledThemes, options, getMdcConfigs, engine })",
|
|
114
119
|
"export default highlighter"
|
|
115
120
|
].join("\n");
|
|
116
121
|
}
|
|
@@ -248,10 +253,12 @@ const module = defineNuxtModule({
|
|
|
248
253
|
});
|
|
249
254
|
if (options.highlight) {
|
|
250
255
|
addWasmSupport(nuxt);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
256
|
+
if (options.highlight?.noApiRoute !== true) {
|
|
257
|
+
addServerHandler({
|
|
258
|
+
route: "/api/_mdc/highlight",
|
|
259
|
+
handler: resolver.resolve("./runtime/highlighter/event-handler")
|
|
260
|
+
});
|
|
261
|
+
}
|
|
255
262
|
options.rehypePlugins ||= {};
|
|
256
263
|
options.rehypePlugins.highlight ||= {};
|
|
257
264
|
options.rehypePlugins.highlight.src ||= await resolver.resolvePath("./runtime/highlighter/rehype-nuxt");
|
|
@@ -322,11 +329,10 @@ const module = defineNuxtModule({
|
|
|
322
329
|
global: true
|
|
323
330
|
});
|
|
324
331
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
332
|
+
addTemplate({
|
|
333
|
+
filename: "mdc-image-component.mjs",
|
|
334
|
+
getContents: ({ app }) => app.components.some((c) => c.pascalName === "NuxtImg" && !c.filePath.includes("nuxt/dist/app")) ? 'export { NuxtImg } from "#components"' : 'export default "img"'
|
|
335
|
+
});
|
|
330
336
|
extendViteConfig((config) => {
|
|
331
337
|
const include = [
|
|
332
338
|
"remark-gfm",
|
|
@@ -393,6 +399,7 @@ function resolveOptions(options) {
|
|
|
393
399
|
default: "github-light",
|
|
394
400
|
dark: "github-dark"
|
|
395
401
|
};
|
|
402
|
+
options.highlight.shikiEngine ||= "oniguruma";
|
|
396
403
|
options.highlight.langs ||= DefaultHighlightLangs;
|
|
397
404
|
if (options.highlight.preload) {
|
|
398
405
|
options.highlight.langs.push(...options.highlight.preload || []);
|
|
@@ -29,7 +29,7 @@ export default defineComponent({
|
|
|
29
29
|
default: () => ({})
|
|
30
30
|
},
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Class(es) to bind to the component
|
|
33
33
|
*/
|
|
34
34
|
class: {
|
|
35
35
|
type: [String, Object],
|
|
@@ -234,11 +234,8 @@ function propsToDataRxBind(key, value, data, documentMeta) {
|
|
|
234
234
|
return data;
|
|
235
235
|
}
|
|
236
236
|
const resolveVueComponent = (component) => {
|
|
237
|
-
if (
|
|
238
|
-
|
|
239
|
-
if (typeof componentFn === "object") {
|
|
240
|
-
return componentFn;
|
|
241
|
-
}
|
|
237
|
+
if (typeof component === "string") {
|
|
238
|
+
return htmlTags.includes(component) ? component : resolveComponent(pascalCase(component), false);
|
|
242
239
|
}
|
|
243
240
|
return component;
|
|
244
241
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PropType, DefineComponent } from 'vue';
|
|
2
2
|
import type { MDCRoot } from '@nuxtjs/mdc';
|
|
3
|
-
declare const _default: DefineComponent<{
|
|
3
|
+
declare const _default: DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
4
|
/**
|
|
5
5
|
* Content to render
|
|
6
6
|
*/
|
|
@@ -16,7 +16,7 @@ declare const _default: DefineComponent<{
|
|
|
16
16
|
default: () => {};
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Class(es) to bind to the component
|
|
20
20
|
*/
|
|
21
21
|
class: {
|
|
22
22
|
type: (ObjectConstructor | StringConstructor)[];
|
|
@@ -51,11 +51,11 @@ declare const _default: DefineComponent<{
|
|
|
51
51
|
type: (BooleanConstructor | StringConstructor)[];
|
|
52
52
|
default: boolean;
|
|
53
53
|
};
|
|
54
|
-
}
|
|
54
|
+
}>, {
|
|
55
55
|
tags: any;
|
|
56
56
|
contentKey: import("vue").ComputedRef<string>;
|
|
57
|
-
route:
|
|
58
|
-
},
|
|
57
|
+
route: any;
|
|
58
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
59
59
|
/**
|
|
60
60
|
* Content to render
|
|
61
61
|
*/
|
|
@@ -71,7 +71,7 @@ declare const _default: DefineComponent<{
|
|
|
71
71
|
default: () => {};
|
|
72
72
|
};
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
74
|
+
* Class(es) to bind to the component
|
|
75
75
|
*/
|
|
76
76
|
class: {
|
|
77
77
|
type: (ObjectConstructor | StringConstructor)[];
|
|
@@ -106,12 +106,314 @@ declare const _default: DefineComponent<{
|
|
|
106
106
|
type: (BooleanConstructor | StringConstructor)[];
|
|
107
107
|
default: boolean;
|
|
108
108
|
};
|
|
109
|
-
}
|
|
109
|
+
}>> & Readonly<{}>, {
|
|
110
110
|
data: Record<string, any>;
|
|
111
111
|
class: string | Record<string, any>;
|
|
112
112
|
tag: string | boolean;
|
|
113
113
|
prose: boolean;
|
|
114
114
|
components: Record<string, string | DefineComponent<any, any, any>>;
|
|
115
115
|
unwrap: string | boolean;
|
|
116
|
-
}, {}>;
|
|
116
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
117
117
|
export default _default;
|
|
118
|
+
declare module 'vue' {
|
|
119
|
+
interface GlobalComponents {
|
|
120
|
+
}
|
|
121
|
+
interface GlobalDirectives {
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
declare global {
|
|
125
|
+
const __VLS_intrinsicElements: __VLS_IntrinsicElements;
|
|
126
|
+
const __VLS_directiveBindingRestFields: {
|
|
127
|
+
instance: null;
|
|
128
|
+
oldValue: null;
|
|
129
|
+
modifiers: any;
|
|
130
|
+
dir: any;
|
|
131
|
+
};
|
|
132
|
+
const __VLS_unref: typeof import('vue').unref;
|
|
133
|
+
const __VLS_nativeElements: {
|
|
134
|
+
a: HTMLAnchorElement;
|
|
135
|
+
abbr: HTMLElement;
|
|
136
|
+
address: HTMLElement;
|
|
137
|
+
area: HTMLAreaElement;
|
|
138
|
+
article: HTMLElement;
|
|
139
|
+
aside: HTMLElement;
|
|
140
|
+
audio: HTMLAudioElement;
|
|
141
|
+
b: HTMLElement;
|
|
142
|
+
base: HTMLBaseElement;
|
|
143
|
+
bdi: HTMLElement;
|
|
144
|
+
bdo: HTMLElement;
|
|
145
|
+
blockquote: HTMLQuoteElement;
|
|
146
|
+
body: HTMLBodyElement;
|
|
147
|
+
br: HTMLBRElement;
|
|
148
|
+
button: HTMLButtonElement;
|
|
149
|
+
canvas: HTMLCanvasElement;
|
|
150
|
+
caption: HTMLTableCaptionElement;
|
|
151
|
+
cite: HTMLElement;
|
|
152
|
+
code: HTMLElement;
|
|
153
|
+
col: HTMLTableColElement;
|
|
154
|
+
colgroup: HTMLTableColElement;
|
|
155
|
+
data: HTMLDataElement;
|
|
156
|
+
datalist: HTMLDataListElement;
|
|
157
|
+
dd: HTMLElement;
|
|
158
|
+
del: HTMLModElement;
|
|
159
|
+
details: HTMLDetailsElement;
|
|
160
|
+
dfn: HTMLElement;
|
|
161
|
+
dialog: HTMLDialogElement;
|
|
162
|
+
div: HTMLDivElement;
|
|
163
|
+
dl: HTMLDListElement;
|
|
164
|
+
dt: HTMLElement;
|
|
165
|
+
em: HTMLElement;
|
|
166
|
+
embed: HTMLEmbedElement;
|
|
167
|
+
fieldset: HTMLFieldSetElement;
|
|
168
|
+
figcaption: HTMLElement;
|
|
169
|
+
figure: HTMLElement;
|
|
170
|
+
footer: HTMLElement;
|
|
171
|
+
form: HTMLFormElement;
|
|
172
|
+
h1: HTMLHeadingElement;
|
|
173
|
+
h2: HTMLHeadingElement;
|
|
174
|
+
h3: HTMLHeadingElement;
|
|
175
|
+
h4: HTMLHeadingElement;
|
|
176
|
+
h5: HTMLHeadingElement;
|
|
177
|
+
h6: HTMLHeadingElement;
|
|
178
|
+
head: HTMLHeadElement;
|
|
179
|
+
header: HTMLElement;
|
|
180
|
+
hgroup: HTMLElement;
|
|
181
|
+
hr: HTMLHRElement;
|
|
182
|
+
html: HTMLHtmlElement;
|
|
183
|
+
i: HTMLElement;
|
|
184
|
+
iframe: HTMLIFrameElement;
|
|
185
|
+
img: HTMLImageElement;
|
|
186
|
+
input: HTMLInputElement;
|
|
187
|
+
ins: HTMLModElement;
|
|
188
|
+
kbd: HTMLElement;
|
|
189
|
+
label: HTMLLabelElement;
|
|
190
|
+
legend: HTMLLegendElement;
|
|
191
|
+
li: HTMLLIElement;
|
|
192
|
+
link: HTMLLinkElement;
|
|
193
|
+
main: HTMLElement;
|
|
194
|
+
map: HTMLMapElement;
|
|
195
|
+
mark: HTMLElement;
|
|
196
|
+
menu: HTMLMenuElement;
|
|
197
|
+
meta: HTMLMetaElement;
|
|
198
|
+
meter: HTMLMeterElement;
|
|
199
|
+
nav: HTMLElement;
|
|
200
|
+
noscript: HTMLElement;
|
|
201
|
+
object: HTMLObjectElement;
|
|
202
|
+
ol: HTMLOListElement;
|
|
203
|
+
optgroup: HTMLOptGroupElement;
|
|
204
|
+
option: HTMLOptionElement;
|
|
205
|
+
output: HTMLOutputElement;
|
|
206
|
+
p: HTMLParagraphElement;
|
|
207
|
+
picture: HTMLPictureElement;
|
|
208
|
+
pre: HTMLPreElement;
|
|
209
|
+
progress: HTMLProgressElement;
|
|
210
|
+
q: HTMLQuoteElement;
|
|
211
|
+
rp: HTMLElement;
|
|
212
|
+
rt: HTMLElement;
|
|
213
|
+
ruby: HTMLElement;
|
|
214
|
+
s: HTMLElement;
|
|
215
|
+
samp: HTMLElement;
|
|
216
|
+
script: HTMLScriptElement;
|
|
217
|
+
search: HTMLElement;
|
|
218
|
+
section: HTMLElement;
|
|
219
|
+
select: HTMLSelectElement;
|
|
220
|
+
slot: HTMLSlotElement;
|
|
221
|
+
small: HTMLElement;
|
|
222
|
+
source: HTMLSourceElement;
|
|
223
|
+
span: HTMLSpanElement;
|
|
224
|
+
strong: HTMLElement;
|
|
225
|
+
style: HTMLStyleElement;
|
|
226
|
+
sub: HTMLElement;
|
|
227
|
+
summary: HTMLElement;
|
|
228
|
+
sup: HTMLElement;
|
|
229
|
+
table: HTMLTableElement;
|
|
230
|
+
tbody: HTMLTableSectionElement;
|
|
231
|
+
td: HTMLTableCellElement;
|
|
232
|
+
template: HTMLTemplateElement;
|
|
233
|
+
textarea: HTMLTextAreaElement;
|
|
234
|
+
tfoot: HTMLTableSectionElement;
|
|
235
|
+
th: HTMLTableCellElement;
|
|
236
|
+
thead: HTMLTableSectionElement;
|
|
237
|
+
time: HTMLTimeElement;
|
|
238
|
+
title: HTMLTitleElement;
|
|
239
|
+
tr: HTMLTableRowElement;
|
|
240
|
+
track: HTMLTrackElement;
|
|
241
|
+
u: HTMLElement;
|
|
242
|
+
ul: HTMLUListElement;
|
|
243
|
+
var: HTMLElement;
|
|
244
|
+
video: HTMLVideoElement;
|
|
245
|
+
wbr: HTMLElement;
|
|
246
|
+
animate: SVGAnimateElement;
|
|
247
|
+
animateMotion: SVGAnimateMotionElement;
|
|
248
|
+
animateTransform: SVGAnimateTransformElement;
|
|
249
|
+
circle: SVGCircleElement;
|
|
250
|
+
clipPath: SVGClipPathElement;
|
|
251
|
+
defs: SVGDefsElement;
|
|
252
|
+
desc: SVGDescElement;
|
|
253
|
+
ellipse: SVGEllipseElement;
|
|
254
|
+
feBlend: SVGFEBlendElement;
|
|
255
|
+
feColorMatrix: SVGFEColorMatrixElement;
|
|
256
|
+
feComponentTransfer: SVGFEComponentTransferElement;
|
|
257
|
+
feComposite: SVGFECompositeElement;
|
|
258
|
+
feConvolveMatrix: SVGFEConvolveMatrixElement;
|
|
259
|
+
feDiffuseLighting: SVGFEDiffuseLightingElement;
|
|
260
|
+
feDisplacementMap: SVGFEDisplacementMapElement;
|
|
261
|
+
feDistantLight: SVGFEDistantLightElement;
|
|
262
|
+
feDropShadow: SVGFEDropShadowElement;
|
|
263
|
+
feFlood: SVGFEFloodElement;
|
|
264
|
+
feFuncA: SVGFEFuncAElement;
|
|
265
|
+
feFuncB: SVGFEFuncBElement;
|
|
266
|
+
feFuncG: SVGFEFuncGElement;
|
|
267
|
+
feFuncR: SVGFEFuncRElement;
|
|
268
|
+
feGaussianBlur: SVGFEGaussianBlurElement;
|
|
269
|
+
feImage: SVGFEImageElement;
|
|
270
|
+
feMerge: SVGFEMergeElement;
|
|
271
|
+
feMergeNode: SVGFEMergeNodeElement;
|
|
272
|
+
feMorphology: SVGFEMorphologyElement;
|
|
273
|
+
feOffset: SVGFEOffsetElement;
|
|
274
|
+
fePointLight: SVGFEPointLightElement;
|
|
275
|
+
feSpecularLighting: SVGFESpecularLightingElement;
|
|
276
|
+
feSpotLight: SVGFESpotLightElement;
|
|
277
|
+
feTile: SVGFETileElement;
|
|
278
|
+
feTurbulence: SVGFETurbulenceElement;
|
|
279
|
+
filter: SVGFilterElement;
|
|
280
|
+
foreignObject: SVGForeignObjectElement;
|
|
281
|
+
g: SVGGElement;
|
|
282
|
+
image: SVGImageElement;
|
|
283
|
+
line: SVGLineElement;
|
|
284
|
+
linearGradient: SVGLinearGradientElement;
|
|
285
|
+
marker: SVGMarkerElement;
|
|
286
|
+
mask: SVGMaskElement;
|
|
287
|
+
metadata: SVGMetadataElement;
|
|
288
|
+
mpath: SVGMPathElement;
|
|
289
|
+
path: SVGPathElement;
|
|
290
|
+
pattern: SVGPatternElement;
|
|
291
|
+
polygon: SVGPolygonElement;
|
|
292
|
+
polyline: SVGPolylineElement;
|
|
293
|
+
radialGradient: SVGRadialGradientElement;
|
|
294
|
+
rect: SVGRectElement;
|
|
295
|
+
set: SVGSetElement;
|
|
296
|
+
stop: SVGStopElement;
|
|
297
|
+
svg: SVGSVGElement;
|
|
298
|
+
switch: SVGSwitchElement;
|
|
299
|
+
symbol: SVGSymbolElement;
|
|
300
|
+
text: SVGTextElement;
|
|
301
|
+
textPath: SVGTextPathElement;
|
|
302
|
+
tspan: SVGTSpanElement;
|
|
303
|
+
use: SVGUseElement;
|
|
304
|
+
view: SVGViewElement;
|
|
305
|
+
};
|
|
306
|
+
type __VLS_IntrinsicElements = import('vue/jsx-runtime').JSX.IntrinsicElements;
|
|
307
|
+
type __VLS_Element = import('vue/jsx-runtime').JSX.Element;
|
|
308
|
+
type __VLS_GlobalComponents = import('vue').GlobalComponents & Pick<typeof import('vue'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;
|
|
309
|
+
type __VLS_GlobalDirectives = import('vue').GlobalDirectives;
|
|
310
|
+
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
|
|
311
|
+
type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
|
|
312
|
+
type __VLS_unknownDirective = (arg1: unknown, arg2: unknown, arg3: unknown, arg4: unknown) => void;
|
|
313
|
+
type __VLS_WithComponent<N0 extends string, LocalComponents, N1 extends string, N2 extends string, N3 extends string> = N1 extends keyof LocalComponents ? N1 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : {
|
|
314
|
+
[K in N0]: LocalComponents[N1];
|
|
315
|
+
} : N2 extends keyof LocalComponents ? N2 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : {
|
|
316
|
+
[K in N0]: LocalComponents[N2];
|
|
317
|
+
} : N3 extends keyof LocalComponents ? N3 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : {
|
|
318
|
+
[K in N0]: LocalComponents[N3];
|
|
319
|
+
} : N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : {
|
|
320
|
+
[K in N0]: __VLS_GlobalComponents[N1];
|
|
321
|
+
} : N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : {
|
|
322
|
+
[K in N0]: __VLS_GlobalComponents[N2];
|
|
323
|
+
} : N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : {
|
|
324
|
+
[K in N0]: __VLS_GlobalComponents[N3];
|
|
325
|
+
} : {
|
|
326
|
+
[K in N0]: unknown;
|
|
327
|
+
};
|
|
328
|
+
type __VLS_FunctionalComponentProps<T, K> = '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends {
|
|
329
|
+
__ctx?: {
|
|
330
|
+
props?: infer P;
|
|
331
|
+
};
|
|
332
|
+
} ? NonNullable<P> : never : T extends (props: infer P, ...args: any) => any ? P : {};
|
|
333
|
+
type __VLS_IsFunction<T, K> = K extends keyof T ? __VLS_IsAny<T[K]> extends false ? unknown extends T[K] ? false : true : false : false;
|
|
334
|
+
type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
|
|
335
|
+
type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R ? U extends T ? never : __VLS_OverloadUnionInner<T, Pick<T, keyof T> & U & ((...args: A) => R)> | ((...args: A) => R) : never;
|
|
336
|
+
type __VLS_OverloadUnion<T> = Exclude<__VLS_OverloadUnionInner<(() => never) & T>, T extends () => never ? never : () => never>;
|
|
337
|
+
type __VLS_ConstructorOverloads<T> = __VLS_OverloadUnion<T> extends infer F ? F extends (event: infer E, ...args: infer A) => any ? {
|
|
338
|
+
[K in E & string]: (...args: A) => void;
|
|
339
|
+
} : never : never;
|
|
340
|
+
type __VLS_NormalizeEmits<T> = __VLS_PrettifyGlobal<__VLS_UnionToIntersection<__VLS_ConstructorOverloads<T> & {
|
|
341
|
+
[K in keyof T]: T[K] extends any[] ? {
|
|
342
|
+
(...args: T[K]): void;
|
|
343
|
+
} : never;
|
|
344
|
+
}>>;
|
|
345
|
+
type __VLS_PrettifyGlobal<T> = {
|
|
346
|
+
[K in keyof T]: T[K];
|
|
347
|
+
} & {};
|
|
348
|
+
function __VLS_getVForSourceType(source: number): [number, number, number][];
|
|
349
|
+
function __VLS_getVForSourceType(source: string): [string, number, number][];
|
|
350
|
+
function __VLS_getVForSourceType<T extends any[]>(source: T): [
|
|
351
|
+
item: T[number],
|
|
352
|
+
key: number,
|
|
353
|
+
index: number
|
|
354
|
+
][];
|
|
355
|
+
function __VLS_getVForSourceType<T extends {
|
|
356
|
+
[Symbol.iterator](): Iterator<any>;
|
|
357
|
+
}>(source: T): [
|
|
358
|
+
item: T extends {
|
|
359
|
+
[Symbol.iterator](): Iterator<infer T1>;
|
|
360
|
+
} ? T1 : never,
|
|
361
|
+
key: number,
|
|
362
|
+
index: undefined
|
|
363
|
+
][];
|
|
364
|
+
function __VLS_getVForSourceType<T extends number | {
|
|
365
|
+
[Symbol.iterator](): Iterator<any>;
|
|
366
|
+
}>(source: T): [
|
|
367
|
+
item: number | (Exclude<T, number> extends {
|
|
368
|
+
[Symbol.iterator](): Iterator<infer T1>;
|
|
369
|
+
} ? T1 : never),
|
|
370
|
+
key: number,
|
|
371
|
+
index: undefined
|
|
372
|
+
][];
|
|
373
|
+
function __VLS_getVForSourceType<T>(source: T): [
|
|
374
|
+
item: T[keyof T],
|
|
375
|
+
key: keyof T,
|
|
376
|
+
index: number
|
|
377
|
+
][];
|
|
378
|
+
function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
|
|
379
|
+
function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
|
|
380
|
+
function __VLS_directiveAsFunction<T extends import('vue').Directive>(dir: T): T extends (...args: any) => any ? T | __VLS_unknownDirective : NonNullable<(T & Record<string, __VLS_unknownDirective>)['created' | 'beforeMount' | 'mounted' | 'beforeUpdate' | 'updated' | 'beforeUnmount' | 'unmounted']>;
|
|
381
|
+
function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K;
|
|
382
|
+
function __VLS_makeOptional<T>(t: T): {
|
|
383
|
+
[K in keyof T]?: T[K];
|
|
384
|
+
};
|
|
385
|
+
function __VLS_nonNullable<T>(t: T): T extends null | undefined ? never : T;
|
|
386
|
+
function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K): T extends new (...args: any) => any ? (props: (K extends {
|
|
387
|
+
$props: infer Props;
|
|
388
|
+
} ? Props : any) & Record<string, unknown>, ctx?: any) => __VLS_Element & {
|
|
389
|
+
__ctx?: {
|
|
390
|
+
attrs?: any;
|
|
391
|
+
slots?: K extends {
|
|
392
|
+
$slots: infer Slots;
|
|
393
|
+
} ? Slots : any;
|
|
394
|
+
emit?: K extends {
|
|
395
|
+
$emit: infer Emit;
|
|
396
|
+
} ? Emit : any;
|
|
397
|
+
} & {
|
|
398
|
+
props?: (K extends {
|
|
399
|
+
$props: infer Props;
|
|
400
|
+
} ? Props : any) & Record<string, unknown>;
|
|
401
|
+
expose?(exposed: K): void;
|
|
402
|
+
};
|
|
403
|
+
} : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T> : T extends (...args: any) => any ? T : (_: {} & Record<string, unknown>, ctx?: any) => {
|
|
404
|
+
__ctx?: {
|
|
405
|
+
attrs?: any;
|
|
406
|
+
expose?: any;
|
|
407
|
+
slots?: any;
|
|
408
|
+
emit?: any;
|
|
409
|
+
props?: {} & Record<string, unknown>;
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
function __VLS_elementAsFunction<T>(tag: T, endTag?: T): (_: T & Record<string, unknown>) => void;
|
|
413
|
+
function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
|
|
414
|
+
function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): NonNullable<__VLS_PickNotAny<'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends {
|
|
415
|
+
__ctx?: infer Ctx;
|
|
416
|
+
} ? Ctx : never : any, T extends (props: any, ctx: infer Ctx) => any ? Ctx : any>>;
|
|
417
|
+
function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
|
|
418
|
+
function __VLS_tryAsConstant<const T>(t: T): T;
|
|
419
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { Slot } from 'vue';
|
|
|
2
2
|
/**
|
|
3
3
|
* MDCSlot component
|
|
4
4
|
*/
|
|
5
|
-
declare const _default: import("vue").DefineComponent<{
|
|
5
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
6
6
|
name: {
|
|
7
7
|
type: StringConstructor;
|
|
8
8
|
default: string;
|
|
@@ -23,11 +23,11 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
23
23
|
type: FunctionConstructor;
|
|
24
24
|
default: undefined;
|
|
25
25
|
};
|
|
26
|
-
}
|
|
26
|
+
}>, {
|
|
27
27
|
fallbackSlot: Slot<any> | undefined;
|
|
28
28
|
tags: import("vue").ComputedRef<string[]>;
|
|
29
29
|
parent: import("vue").ComponentInternalInstance | null;
|
|
30
|
-
},
|
|
30
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
31
31
|
name: {
|
|
32
32
|
type: StringConstructor;
|
|
33
33
|
default: string;
|
|
@@ -48,9 +48,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
48
48
|
type: FunctionConstructor;
|
|
49
49
|
default: undefined;
|
|
50
50
|
};
|
|
51
|
-
}
|
|
52
|
-
name: string;
|
|
51
|
+
}>> & Readonly<{}>, {
|
|
53
52
|
unwrap: string | boolean;
|
|
53
|
+
name: string;
|
|
54
54
|
use: Function;
|
|
55
|
-
}, {}>;
|
|
55
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
56
56
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<NuxtLink
|
|
3
|
-
:href="href"
|
|
4
|
-
:target="target"
|
|
3
|
+
:href="props.href"
|
|
4
|
+
:target="props.target"
|
|
5
5
|
>
|
|
6
6
|
<slot />
|
|
7
7
|
</NuxtLink>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<script setup lang="ts">
|
|
11
11
|
import type { PropType } from 'vue'
|
|
12
12
|
|
|
13
|
-
defineProps({
|
|
13
|
+
const props = defineProps({
|
|
14
14
|
href: {
|
|
15
15
|
type: String,
|
|
16
16
|
default: ''
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<component
|
|
3
|
-
:is="
|
|
3
|
+
:is="ImageComponent"
|
|
4
4
|
:src="refinedSrc"
|
|
5
|
-
:alt="alt"
|
|
6
|
-
:width="width"
|
|
7
|
-
:height="height"
|
|
5
|
+
:alt="props.alt"
|
|
6
|
+
:width="props.width"
|
|
7
|
+
:height="props.height"
|
|
8
8
|
/>
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
11
|
<script setup lang="ts">
|
|
12
12
|
import { withTrailingSlash, withLeadingSlash, joinURL } from 'ufo'
|
|
13
|
-
import { useRuntimeConfig, computed
|
|
13
|
+
import { useRuntimeConfig, computed } from '#imports'
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
import ImageComponent from '#build/mdc-image-component.mjs'
|
|
16
16
|
|
|
17
17
|
const props = defineProps({
|
|
18
18
|
src: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { eventHandler, getQuery } from "h3";
|
|
2
|
-
import highlighter from "#mdc-highlighter";
|
|
3
2
|
export default eventHandler(async (event) => {
|
|
4
3
|
const { code, lang, theme: themeString, options: optionsStr } = getQuery(event);
|
|
5
4
|
const theme = JSON.parse(themeString);
|
|
6
5
|
const options = optionsStr ? JSON.parse(optionsStr) : {};
|
|
6
|
+
const highlighter = await import("#mdc-highlighter").then((m) => m.default);
|
|
7
7
|
return await highlighter(code, lang, theme, options);
|
|
8
8
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LanguageInput, ThemeInput } from 'shiki';
|
|
1
|
+
import type { LanguageInput, ThemeInput, RegexEngine } from 'shiki';
|
|
2
2
|
import type { MdcConfig, Highlighter } from '@nuxtjs/mdc';
|
|
3
3
|
export interface CreateShikiHighlighterOptions {
|
|
4
4
|
themes?: ThemeInput[];
|
|
@@ -9,5 +9,6 @@ export interface CreateShikiHighlighterOptions {
|
|
|
9
9
|
wrapperStyle?: string;
|
|
10
10
|
};
|
|
11
11
|
getMdcConfigs?: () => Promise<MdcConfig[]>;
|
|
12
|
+
engine?: RegexEngine | Promise<RegexEngine>;
|
|
12
13
|
}
|
|
13
|
-
export declare function createShikiHighlighter({ langs, themes, bundledLangs, bundledThemes, getMdcConfigs, options: shikiOptions }?: CreateShikiHighlighterOptions): Highlighter;
|
|
14
|
+
export declare function createShikiHighlighter({ langs, themes, bundledLangs, bundledThemes, getMdcConfigs, options: shikiOptions, engine }?: CreateShikiHighlighterOptions): Highlighter;
|
|
@@ -1,30 +1,37 @@
|
|
|
1
|
-
import { createHighlighterCore, addClassToHast, isSpecialLang, isSpecialTheme } from "shiki/core";
|
|
2
|
-
import {
|
|
3
|
-
transformerNotationDiff,
|
|
4
|
-
transformerNotationErrorLevel,
|
|
5
|
-
transformerNotationFocus,
|
|
6
|
-
transformerNotationHighlight
|
|
7
|
-
} from "@shikijs/transformers";
|
|
8
1
|
export function createShikiHighlighter({
|
|
9
2
|
langs = [],
|
|
10
3
|
themes = [],
|
|
11
4
|
bundledLangs = {},
|
|
12
5
|
bundledThemes = {},
|
|
13
6
|
getMdcConfigs,
|
|
14
|
-
options: shikiOptions
|
|
7
|
+
options: shikiOptions,
|
|
8
|
+
engine
|
|
15
9
|
} = {}) {
|
|
16
10
|
let shiki;
|
|
17
11
|
let configs;
|
|
18
12
|
async function _getShiki() {
|
|
13
|
+
const { createHighlighterCore, addClassToHast, isSpecialLang, isSpecialTheme } = await import("shiki/core");
|
|
14
|
+
const { transformerNotationDiff, transformerNotationErrorLevel, transformerNotationFocus, transformerNotationHighlight } = await import("@shikijs/transformers");
|
|
19
15
|
const shiki2 = await createHighlighterCore({
|
|
20
16
|
langs,
|
|
21
17
|
themes,
|
|
22
|
-
|
|
18
|
+
engine
|
|
23
19
|
});
|
|
24
20
|
for await (const config of await getConfigs()) {
|
|
25
21
|
await config.shiki?.setup?.(shiki2);
|
|
26
22
|
}
|
|
27
|
-
return
|
|
23
|
+
return {
|
|
24
|
+
shiki: shiki2,
|
|
25
|
+
addClassToHast,
|
|
26
|
+
isSpecialLang,
|
|
27
|
+
isSpecialTheme,
|
|
28
|
+
transformers: [
|
|
29
|
+
transformerNotationDiff(),
|
|
30
|
+
transformerNotationErrorLevel(),
|
|
31
|
+
transformerNotationFocus(),
|
|
32
|
+
transformerNotationHighlight()
|
|
33
|
+
]
|
|
34
|
+
};
|
|
28
35
|
}
|
|
29
36
|
async function getShiki() {
|
|
30
37
|
if (!shiki) {
|
|
@@ -38,14 +45,14 @@ export function createShikiHighlighter({
|
|
|
38
45
|
}
|
|
39
46
|
return configs;
|
|
40
47
|
}
|
|
41
|
-
const baseTransformers = [
|
|
42
|
-
transformerNotationDiff(),
|
|
43
|
-
transformerNotationFocus(),
|
|
44
|
-
transformerNotationHighlight(),
|
|
45
|
-
transformerNotationErrorLevel()
|
|
46
|
-
];
|
|
47
48
|
const highlighter = async (code, lang, theme, options = {}) => {
|
|
48
|
-
const
|
|
49
|
+
const {
|
|
50
|
+
shiki: shiki2,
|
|
51
|
+
addClassToHast,
|
|
52
|
+
isSpecialLang,
|
|
53
|
+
isSpecialTheme,
|
|
54
|
+
transformers: baseTransformers
|
|
55
|
+
} = await getShiki();
|
|
49
56
|
const codeToHastOptions = {
|
|
50
57
|
defaultColor: false,
|
|
51
58
|
meta: {
|
|
@@ -59,14 +66,14 @@ export function createShikiHighlighter({
|
|
|
59
66
|
lang = "vue";
|
|
60
67
|
codeToHastOptions.grammarContextCode = "<template>";
|
|
61
68
|
}
|
|
62
|
-
const themesObject = typeof theme === "string" ? { default: theme } : theme || {};
|
|
69
|
+
const themesObject = { ...typeof theme === "string" ? { default: theme } : theme || {} };
|
|
63
70
|
const loadedThemes = shiki2.getLoadedThemes();
|
|
64
71
|
const loadedLanguages = shiki2.getLoadedLanguages();
|
|
65
72
|
if (typeof lang === "string" && !loadedLanguages.includes(lang) && !isSpecialLang(lang)) {
|
|
66
73
|
if (bundledLangs[lang]) {
|
|
67
74
|
await shiki2.loadLanguage(bundledLangs[lang]);
|
|
68
75
|
} else {
|
|
69
|
-
if (
|
|
76
|
+
if (process.dev) {
|
|
70
77
|
console.warn(`[@nuxtjs/mdc] Language "${lang}" is not loaded to the Shiki highlighter, fallback to plain text. Add the language to "mdc.highlight.langs" to fix this.`);
|
|
71
78
|
}
|
|
72
79
|
lang = "text";
|
|
@@ -77,7 +84,7 @@ export function createShikiHighlighter({
|
|
|
77
84
|
if (bundledThemes[theme2]) {
|
|
78
85
|
await shiki2.loadTheme(bundledThemes[theme2]);
|
|
79
86
|
} else {
|
|
80
|
-
if (
|
|
87
|
+
if (process.dev) {
|
|
81
88
|
console.warn(`[@nuxtjs/mdc] Theme "${theme2}" is not loaded to the Shiki highlighter. Add the theme to "mdc.highlight.themes" to fix this.`);
|
|
82
89
|
}
|
|
83
90
|
themesObject[color] = "none";
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { parseMarkdown, createMarkdownParser } from './parser.js';
|
|
1
|
+
export { parseMarkdown, createMarkdownParser } from './parser/index.js';
|
|
2
2
|
export { rehypeHighlight } from './highlighter/rehype.js';
|
|
3
3
|
export { createShikiHighlighter } from './highlighter/shiki.js';
|
|
4
4
|
export * from './utils/node.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { State } from 'mdast-util-to-hast';
|
|
2
2
|
import type { Element } from 'hast';
|
|
3
3
|
import type { Paragraph } from 'mdast';
|
|
4
4
|
export default function paragraph(state: State, node: Paragraph): Element | import("hast").ElementContent[];
|
|
@@ -28,7 +28,7 @@ export const createMarkdownParser = async (inlineOptions = {}) => {
|
|
|
28
28
|
...inlineOptions.configs || []
|
|
29
29
|
];
|
|
30
30
|
if (inlineOptions.highlight != null && inlineOptions.highlight != false && inlineOptions.highlight.highlighter !== void 0 && typeof inlineOptions.highlight.highlighter !== "function") {
|
|
31
|
-
if (
|
|
31
|
+
if (process.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 = {
|
|
34
34
|
...inlineOptions,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const renderSlot: (slots: Record<string, any>, name: string, props: any, ...rest: any[]) => import("vue
|
|
1
|
+
export declare const renderSlot: (slots: Record<string, any>, name: string, props: any, ...rest: any[]) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/mdc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Nuxt MDC module",
|
|
5
5
|
"repository": "nuxt-modules/mdc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -71,37 +71,37 @@
|
|
|
71
71
|
"test:watch": "vitest watch"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@nuxt/kit": "^3.
|
|
75
|
-
"@shikijs/transformers": "^1.
|
|
74
|
+
"@nuxt/kit": "^3.13.2",
|
|
75
|
+
"@shikijs/transformers": "^1.22.0",
|
|
76
76
|
"@types/hast": "^3.0.4",
|
|
77
77
|
"@types/mdast": "^4.0.4",
|
|
78
|
-
"@vue/compiler-core": "^3.
|
|
78
|
+
"@vue/compiler-core": "^3.5.12",
|
|
79
79
|
"consola": "^3.2.3",
|
|
80
|
-
"debug": "^4.3.
|
|
80
|
+
"debug": "^4.3.7",
|
|
81
81
|
"defu": "^6.1.4",
|
|
82
82
|
"destr": "^2.0.3",
|
|
83
83
|
"detab": "^3.0.2",
|
|
84
84
|
"github-slugger": "^2.0.0",
|
|
85
|
-
"hast-util-to-string": "^3.0.
|
|
85
|
+
"hast-util-to-string": "^3.0.1",
|
|
86
86
|
"mdast-util-to-hast": "^13.2.0",
|
|
87
87
|
"micromark-util-sanitize-uri": "^2.0.0",
|
|
88
|
-
"ohash": "^1.1.
|
|
89
|
-
"parse5": "^7.
|
|
88
|
+
"ohash": "^1.1.4",
|
|
89
|
+
"parse5": "^7.2.0",
|
|
90
90
|
"pathe": "^1.1.2",
|
|
91
91
|
"property-information": "^6.5.0",
|
|
92
92
|
"rehype-external-links": "^3.0.0",
|
|
93
93
|
"rehype-raw": "^7.0.0",
|
|
94
94
|
"rehype-slug": "^6.0.0",
|
|
95
|
-
"rehype-sort-attribute-values": "^5.0.
|
|
96
|
-
"rehype-sort-attributes": "^5.0.
|
|
97
|
-
"remark-emoji": "^5.0.
|
|
95
|
+
"rehype-sort-attribute-values": "^5.0.1",
|
|
96
|
+
"rehype-sort-attributes": "^5.0.1",
|
|
97
|
+
"remark-emoji": "^5.0.1",
|
|
98
98
|
"remark-gfm": "^4.0.0",
|
|
99
99
|
"remark-mdc": "^3.2.1",
|
|
100
100
|
"remark-parse": "^11.0.0",
|
|
101
|
-
"remark-rehype": "^11.1.
|
|
101
|
+
"remark-rehype": "^11.1.1",
|
|
102
102
|
"scule": "^1.3.0",
|
|
103
|
-
"shiki": "^1.
|
|
104
|
-
"ufo": "^1.5.
|
|
103
|
+
"shiki": "^1.22.0",
|
|
104
|
+
"ufo": "^1.5.4",
|
|
105
105
|
"unified": "^11.0.5",
|
|
106
106
|
"unist-builder": "^4.0.0",
|
|
107
107
|
"unist-util-visit": "^5.0.0",
|
|
@@ -109,23 +109,23 @@
|
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
111
|
"@nuxt/devtools": "latest",
|
|
112
|
-
"@nuxt/eslint-config": "^0.
|
|
113
|
-
"@nuxt/module-builder": "^0.8.
|
|
114
|
-
"@nuxt/schema": "^3.
|
|
115
|
-
"@nuxt/test-utils": "^3.
|
|
116
|
-
"@nuxt/ui": "^2.
|
|
112
|
+
"@nuxt/eslint-config": "^0.6.0",
|
|
113
|
+
"@nuxt/module-builder": "^0.8.4",
|
|
114
|
+
"@nuxt/schema": "^3.13.2",
|
|
115
|
+
"@nuxt/test-utils": "^3.14.3",
|
|
116
|
+
"@nuxt/ui": "^2.18.7",
|
|
117
117
|
"@nuxtjs/mdc": "link:.",
|
|
118
|
-
"@types/node": "^
|
|
119
|
-
"changelogen": "^0.5.
|
|
120
|
-
"eslint": "^9.
|
|
121
|
-
"nuxt": "^3.
|
|
122
|
-
"rehype": "^13.0.
|
|
123
|
-
"release-it": "^17.
|
|
124
|
-
"typescript": "^5.
|
|
125
|
-
"vitest": "^1.
|
|
126
|
-
"vue-tsc": "^2.
|
|
118
|
+
"@types/node": "^22.7.5",
|
|
119
|
+
"changelogen": "^0.5.7",
|
|
120
|
+
"eslint": "^9.12.0",
|
|
121
|
+
"nuxt": "^3.13.2",
|
|
122
|
+
"rehype": "^13.0.2",
|
|
123
|
+
"release-it": "^17.9.0",
|
|
124
|
+
"typescript": "^5.6.3",
|
|
125
|
+
"vitest": "^2.1.3",
|
|
126
|
+
"vue-tsc": "^2.1.6"
|
|
127
127
|
},
|
|
128
|
-
"packageManager": "pnpm@9.
|
|
128
|
+
"packageManager": "pnpm@9.12.1",
|
|
129
129
|
"release-it": {
|
|
130
130
|
"git": {
|
|
131
131
|
"commitMessage": "chore(release): release v${version}"
|