@nuxtjs/mdc 0.16.0 → 0.17.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.
Files changed (66) hide show
  1. package/README.md +8 -8
  2. package/dist/config.d.mts +1 -1
  3. package/dist/module.d.mts +15 -3
  4. package/dist/module.json +3 -3
  5. package/dist/module.mjs +9 -4
  6. package/dist/runtime/components/MDC.vue +25 -33
  7. package/dist/runtime/components/MDC.vue.d.ts +140 -0
  8. package/dist/runtime/components/MDCCached.vue +117 -0
  9. package/dist/runtime/components/MDCCached.vue.d.ts +155 -0
  10. package/dist/runtime/components/MDCRenderer.vue +19 -13
  11. package/dist/runtime/components/MDCRenderer.vue.d.ts +11 -123
  12. package/dist/runtime/components/MDCSlot.vue.d.ts +2 -2
  13. package/dist/runtime/components/prose/ProseA.vue +5 -7
  14. package/dist/runtime/components/prose/ProseA.vue.d.ts +36 -0
  15. package/dist/runtime/components/prose/ProseBlockquote.vue.d.ts +12 -0
  16. package/dist/runtime/components/prose/ProseCode.vue.d.ts +12 -0
  17. package/dist/runtime/components/prose/ProseEm.vue.d.ts +12 -0
  18. package/dist/runtime/components/prose/ProseH1.vue +7 -7
  19. package/dist/runtime/components/prose/ProseH1.vue.d.ts +17 -0
  20. package/dist/runtime/components/prose/ProseH2.vue +7 -7
  21. package/dist/runtime/components/prose/ProseH2.vue.d.ts +17 -0
  22. package/dist/runtime/components/prose/ProseH3.vue +7 -7
  23. package/dist/runtime/components/prose/ProseH3.vue.d.ts +17 -0
  24. package/dist/runtime/components/prose/ProseH4.vue +7 -7
  25. package/dist/runtime/components/prose/ProseH4.vue.d.ts +17 -0
  26. package/dist/runtime/components/prose/ProseH5.vue +7 -7
  27. package/dist/runtime/components/prose/ProseH5.vue.d.ts +17 -0
  28. package/dist/runtime/components/prose/ProseH6.vue +7 -7
  29. package/dist/runtime/components/prose/ProseH6.vue.d.ts +17 -0
  30. package/dist/runtime/components/prose/ProseHr.vue.d.ts +2 -0
  31. package/dist/runtime/components/prose/ProseImg.vue +15 -18
  32. package/dist/runtime/components/prose/ProseImg.vue.d.ts +41 -0
  33. package/dist/runtime/components/prose/ProseLi.vue.d.ts +12 -0
  34. package/dist/runtime/components/prose/ProseOl.vue.d.ts +12 -0
  35. package/dist/runtime/components/prose/ProseP.vue.d.ts +12 -0
  36. package/dist/runtime/components/prose/ProsePre.vue +4 -4
  37. package/dist/runtime/components/prose/ProsePre.vue.d.ts +69 -0
  38. package/dist/runtime/components/prose/ProseScript.vue +4 -4
  39. package/dist/runtime/components/prose/ProseScript.vue.d.ts +14 -0
  40. package/dist/runtime/components/prose/ProseStrong.vue.d.ts +12 -0
  41. package/dist/runtime/components/prose/ProseTable.vue.d.ts +12 -0
  42. package/dist/runtime/components/prose/ProseTbody.vue.d.ts +12 -0
  43. package/dist/runtime/components/prose/ProseTd.vue.d.ts +12 -0
  44. package/dist/runtime/components/prose/ProseTh.vue.d.ts +12 -0
  45. package/dist/runtime/components/prose/ProseThead.vue.d.ts +12 -0
  46. package/dist/runtime/components/prose/ProseTr.vue.d.ts +12 -0
  47. package/dist/runtime/components/prose/ProseUl.vue.d.ts +12 -0
  48. package/dist/runtime/highlighter/shiki.d.ts +1 -1
  49. package/dist/runtime/highlighter/shiki.js +9 -6
  50. package/dist/runtime/index.d.ts +1 -0
  51. package/dist/runtime/index.js +1 -0
  52. package/dist/runtime/parser/cached.d.ts +2 -0
  53. package/dist/runtime/parser/cached.js +44 -0
  54. package/dist/runtime/parser/compiler.js +11 -9
  55. package/dist/runtime/parser/handlers/utils.js +6 -2
  56. package/dist/runtime/parser/index.js +9 -5
  57. package/dist/runtime/stringify/mdc-remark.js +63 -50
  58. package/dist/runtime/utils/slot.d.ts +1 -1
  59. package/dist/shared/{mdc.4762b8bc.d.ts → mdc.BkZUOs7X.d.mts} +2 -1
  60. package/dist/types.d.mts +5 -1
  61. package/package.json +32 -34
  62. package/dist/config.d.ts +0 -4
  63. package/dist/module.cjs +0 -5
  64. package/dist/module.d.ts +0 -570
  65. package/dist/shared/mdc.4762b8bc.d.mts +0 -66
  66. package/dist/types.d.ts +0 -1
@@ -6,6 +6,8 @@ import { visit } from "unist-util-visit";
6
6
  import { format } from "hast-util-format";
7
7
  import { computeHighlightRanges, refineCodeLanguage } from "./utils.js";
8
8
  const mdcRemarkElementType = "mdc-element";
9
+ const mdastTextComponentType = "textDirective";
10
+ const mdcTextComponentType = "textComponent";
9
11
  const own = {}.hasOwnProperty;
10
12
  export function mdcRemark(options) {
11
13
  return function(node, _file) {
@@ -27,6 +29,26 @@ export function mdcRemark(options) {
27
29
  ...options?.nodeHandlers
28
30
  }
29
31
  });
32
+ visit(mdast, (node2) => node2.type === mdastTextComponentType, (node2, index, parent) => {
33
+ node2.type = mdcTextComponentType;
34
+ if (node2.name === "binding") {
35
+ return;
36
+ }
37
+ if (index && parent && parent.children) {
38
+ if (index > 0 && parent.children[index - 1].type === "text") {
39
+ const text = parent.children[index - 1];
40
+ if (!["\n", " ", " "].includes(text.value.slice(-1))) {
41
+ text.value += " ";
42
+ }
43
+ }
44
+ if (index && index < parent.children.length - 1 && parent.children[index + 1].type === "text") {
45
+ const text = parent.children[index + 1];
46
+ if (!["\n", " ", " ", ",", "."].includes(text.value.slice(0, 1))) {
47
+ text.value = " " + text.value;
48
+ }
49
+ }
50
+ }
51
+ });
30
52
  return mdast;
31
53
  };
32
54
  }
@@ -64,6 +86,13 @@ const mdcRemarkNodeHandlers = {
64
86
  if (node.properties && node.properties.dataMdast === "ignore") {
65
87
  return;
66
88
  }
89
+ if (node.properties && (node.properties.className || node.properties["class-name"])) {
90
+ const pascal = Array.isArray(node.properties.className || "") ? node.properties.className : String(node.properties.className || "").split(" ");
91
+ const kebab = Array.isArray(node.properties["class-name"] || "") ? node.properties["class-name"] : String(node.properties["class-name"] || "").split(" ");
92
+ node.properties.class = [node.properties.class || "", ...pascal, ...kebab].filter(Boolean).join(" ");
93
+ Reflect.deleteProperty(node.properties, "className");
94
+ Reflect.deleteProperty(node.properties, "class-name");
95
+ }
67
96
  if (own.call(state.handlers, node.tagName)) {
68
97
  return state.handlers[node.tagName](state, node, parent) || void 0;
69
98
  }
@@ -72,10 +101,10 @@ const mdcRemarkNodeHandlers = {
72
101
  state.patch(node, result);
73
102
  return result;
74
103
  }
75
- const isInlineElement = (parent?.children || []).some((child) => child.type === "text") || ["p", "li"].includes(parent?.tagName);
104
+ const isInlineElement = (parent?.children || []).some((child) => child.type === "text") || ["p", "li", "strong", "em", "span"].includes(parent?.tagName);
76
105
  if (isInlineElement) {
77
106
  return {
78
- type: "textComponent",
107
+ type: mdastTextComponentType,
79
108
  name: node.tagName,
80
109
  attributes: node.properties,
81
110
  children: state.all(node)
@@ -145,48 +174,27 @@ const mdcRemarkHandlers = {
145
174
  meta
146
175
  };
147
176
  },
148
- binding: (state, node) => {
149
- return {
150
- type: "textComponent",
151
- name: "binding",
152
- attributes: node.properties,
153
- children: state.toFlow(state.all(node))
154
- };
155
- },
156
- span: (state, node) => {
157
- const result = {
158
- type: "textComponent",
159
- name: "span",
160
- attributes: node.properties,
161
- children: state.all(node)
162
- };
163
- state.patch(node, result);
164
- return result;
165
- },
166
- video: (state, node) => {
167
- return {
168
- type: "textComponent",
169
- name: "video",
170
- attributes: node.properties,
171
- children: state.toFlow(state.all(node))
172
- };
173
- },
174
- "nuxt-img": (state, node) => {
175
- return {
176
- type: "textComponent",
177
- name: "nuxt-img",
178
- attributes: node.properties,
179
- children: state.toFlow(state.all(node))
180
- };
181
- },
182
- "nuxt-picture": (state, node) => {
183
- return {
184
- type: "textComponent",
185
- name: "nuxt-picture",
186
- attributes: node.properties,
187
- children: state.toFlow(state.all(node))
188
- };
177
+ button: (state, node) => {
178
+ if (
179
+ // @ts-expect-error: custom type
180
+ node.children?.find((child) => child.type === mdcRemarkElementType) || node.children?.find((child) => child.type === "text" && child.value.includes("\n"))
181
+ ) {
182
+ return {
183
+ type: "containerComponent",
184
+ name: "button",
185
+ children: state.all(node),
186
+ attributes: node.properties
187
+ };
188
+ }
189
+ return createTextComponent("button")(state, node);
189
190
  },
191
+ span: createTextComponent("span"),
192
+ binding: createTextComponent("binding"),
193
+ iframe: createTextComponent("iframe"),
194
+ video: createTextComponent("video"),
195
+ "nuxt-img": createTextComponent("nuxt-img"),
196
+ "nuxt-picture": createTextComponent("nuxt-picture"),
197
+ br: createTextComponent("br"),
190
198
  table: (state, node) => {
191
199
  visit(node, (node2) => {
192
200
  if (node2.type === mdcRemarkElementType) {
@@ -243,12 +251,17 @@ const mdcRemarkHandlers = {
243
251
  };
244
252
  state.patch(node, result);
245
253
  return result;
246
- },
247
- br(state, node) {
248
- return {
249
- type: "textComponent",
250
- name: "br",
251
- attributes: node.properties
252
- };
253
254
  }
254
255
  };
256
+ function createTextComponent(name) {
257
+ return (state, node) => {
258
+ const result = {
259
+ type: mdastTextComponentType,
260
+ name,
261
+ attributes: node.properties,
262
+ children: state.all(node)
263
+ };
264
+ state.patch(node, result);
265
+ return result;
266
+ };
267
+ }
@@ -1,3 +1,3 @@
1
- export declare const renderSlot: (slots: Record<string, any>, name: string, props: any, ...rest: any[]) => import("@vue/runtime-core").VNode<import("@vue/runtime-core").RendererNode, import("@vue/runtime-core").RendererElement, {
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
  }>;
@@ -63,4 +63,5 @@ interface MdcConfig {
63
63
 
64
64
  declare function defineConfig(config: MdcConfig): MdcConfig;
65
65
 
66
- export { type Awaitable as A, type HighlighterOptions as H, type MdcConfig as M, type RehypeHighlightOption as R, type MdcThemeOptions as a, type HighlightResult as b, type Highlighter as c, defineConfig as d };
66
+ export { defineConfig as d };
67
+ export type { Awaitable as A, HighlighterOptions as H, MdcConfig as M, RehypeHighlightOption as R, MdcThemeOptions as a, HighlightResult as b, Highlighter as c };
package/dist/types.d.mts CHANGED
@@ -1 +1,5 @@
1
- export { type Awaitable, type HighlightResult, type Highlighter, type HighlighterOptions, type defineConfig } from './module.js'
1
+ export { type Awaitable, type HighlightResult, type Highlighter, type HighlighterOptions, type defineConfig } from './shared/mdc.BkZUOs7X.mjs'
2
+
3
+ export { type DefaultHighlightLangs, type MdcConfig, type MdcThemeOptions, type RehypeHighlightOption, default } from './module.mjs'
4
+
5
+ export { type Comment, type CommentData, type Content, type Data, type Doctype, type DoctypeData, type Element, type ElementContent, type ElementContentMap, type ElementData, type Literal, type Literals, type MDCComment, type MDCData, type MDCElement, type MDCNode, type MDCParseOptions, type MDCParserResult, type MDCRenderOptions, type MDCRoot, type MDCStringifyOptions, type MDCText, type ModuleOptions, type Node, type NodePosition, type Nodes, type Parent, type Parents, type Properties, type RehypePlugin, type RemarkPlugin, type Root, type RootContent, type RootContentMap, type RootData, type Text, type TextData, type Toc, type TocLink, type UnistPlugin } from './module.mjs'
package/package.json CHANGED
@@ -1,18 +1,14 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Nuxt MDC module",
5
5
  "repository": "nuxt-modules/mdc",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "exports": {
9
- ".": {
10
- "types": "./dist/module.d.ts",
11
- "import": "./dist/module.mjs",
12
- "require": "./dist/module.cjs"
13
- },
9
+ ".": "./dist/module.mjs",
14
10
  "./config": {
15
- "types": "./dist/config.d.ts",
11
+ "types": "./dist/config.d.mts",
16
12
  "import": "./dist/config.mjs",
17
13
  "require": "./dist/config.cjs"
18
14
  },
@@ -41,19 +37,19 @@
41
37
  "import": "./dist/runtime/*.js"
42
38
  }
43
39
  },
44
- "main": "./dist/module.cjs",
45
- "types": "./dist/types.d.ts",
40
+ "main": "./dist/module.mjs",
41
+ "types": "./dist/types.d.mts",
46
42
  "files": [
47
43
  "dist"
48
44
  ],
49
45
  "typesVersions": {
50
46
  "*": {
51
47
  "*": [
52
- "./dist/* ",
53
- "./dist/index.d.ts"
48
+ "./dist/*",
49
+ "./dist/index.d.mts"
54
50
  ],
55
51
  "config": [
56
- "./dist/config.d.ts"
52
+ "./dist/config.d.mts"
57
53
  ]
58
54
  }
59
55
  },
@@ -72,15 +68,17 @@
72
68
  "verify": "npm run dev:prepare && npm run lint && npm run test && npm run typecheck"
73
69
  },
74
70
  "dependencies": {
75
- "@nuxt/kit": "^3.16.0",
76
- "@shikijs/transformers": "^3.2.1",
71
+ "@nuxt/kit": "^3.16.2",
72
+ "@shikijs/langs": "^3.3.0",
73
+ "@shikijs/themes": "^3.3.0",
74
+ "@shikijs/transformers": "^3.3.0",
77
75
  "@types/hast": "^3.0.4",
78
76
  "@types/mdast": "^4.0.4",
79
77
  "@vue/compiler-core": "^3.5.13",
80
78
  "consola": "^3.4.2",
81
79
  "debug": "4.4.0",
82
80
  "defu": "^6.1.4",
83
- "destr": "^2.0.3",
81
+ "destr": "^2.0.5",
84
82
  "detab": "^3.0.2",
85
83
  "github-slugger": "^2.0.0",
86
84
  "hast-util-format": "^1.1.0",
@@ -88,25 +86,25 @@
88
86
  "hast-util-to-string": "^3.0.1",
89
87
  "mdast-util-to-hast": "^13.2.0",
90
88
  "micromark-util-sanitize-uri": "^2.0.1",
91
- "parse5": "^7.2.1",
89
+ "parse5": "^7.3.0",
92
90
  "pathe": "^2.0.3",
93
91
  "property-information": "^7.0.0",
94
92
  "rehype-external-links": "^3.0.0",
95
93
  "rehype-minify-whitespace": "^6.0.2",
96
94
  "rehype-raw": "^7.0.0",
97
- "rehype-remark": "^10.0.0",
95
+ "rehype-remark": "^10.0.1",
98
96
  "rehype-slug": "^6.0.0",
99
97
  "rehype-sort-attribute-values": "^5.0.1",
100
98
  "rehype-sort-attributes": "^5.0.1",
101
99
  "remark-emoji": "^5.0.1",
102
100
  "remark-gfm": "^4.0.1",
103
- "remark-mdc": "^3.5.3",
101
+ "remark-mdc": "v3.6.0",
104
102
  "remark-parse": "^11.0.0",
105
- "remark-rehype": "^11.1.1",
103
+ "remark-rehype": "^11.1.2",
106
104
  "remark-stringify": "^11.0.0",
107
105
  "scule": "^1.3.0",
108
- "shiki": "^3.2.1",
109
- "ufo": "^1.5.4",
106
+ "shiki": "^3.3.0",
107
+ "ufo": "^1.6.1",
110
108
  "unified": "^11.0.5",
111
109
  "unist-builder": "^4.0.0",
112
110
  "unist-util-visit": "^5.0.0",
@@ -114,26 +112,26 @@
114
112
  "vfile": "^6.0.3"
115
113
  },
116
114
  "devDependencies": {
117
- "@nuxt/devtools": "^2.3.0",
118
- "@nuxt/eslint-config": "^1.2.0",
119
- "@nuxt/module-builder": "^0.8.4",
120
- "@nuxt/schema": "^3.16.0",
115
+ "@nuxt/devtools": "^2.4.0",
116
+ "@nuxt/eslint-config": "^1.3.0",
117
+ "@nuxt/module-builder": "^1.0.1",
118
+ "@nuxt/schema": "^3.16.2",
121
119
  "@nuxt/test-utils": "^3.17.2",
122
- "@nuxt/ui": "^3.0.0",
120
+ "@nuxt/ui": "^3.0.2",
123
121
  "@nuxtjs/mdc": "link:.",
124
- "@types/node": "^22.13.10",
125
- "eslint": "^9.22.0",
126
- "nuxt": "^3.16.0",
122
+ "@types/node": "^22.14.1",
123
+ "eslint": "^9.25.1",
124
+ "nuxt": "^3.16.2",
127
125
  "rehype": "^13.0.2",
128
- "release-it": "^18.1.2",
129
- "typescript": "5.8.2",
130
- "vitest": "^3.0.9",
131
- "vue-tsc": "^2.2.8"
126
+ "release-it": "^19.0.1",
127
+ "typescript": "5.8.3",
128
+ "vitest": "^3.1.2",
129
+ "vue-tsc": "^2.2.10"
132
130
  },
133
131
  "resolutions": {
134
132
  "@nuxtjs/mdc": "workspace:*"
135
133
  },
136
- "packageManager": "pnpm@10.6.5",
134
+ "packageManager": "pnpm@10.9.0",
137
135
  "release-it": {
138
136
  "git": {
139
137
  "commitMessage": "chore(release): release v${version}"
package/dist/config.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export { d as defineConfig } from './shared/mdc.4762b8bc.js';
2
- import 'shiki';
3
- import 'unified';
4
- import 'hast';
package/dist/module.cjs DELETED
@@ -1,5 +0,0 @@
1
- module.exports = function(...args) {
2
- return import('./module.mjs').then(m => m.default.call(this, ...args))
3
- }
4
- const _meta = module.exports.meta = require('./module.json')
5
- module.exports.getMeta = () => Promise.resolve(_meta)