@nuxtjs/mdc 0.7.1 → 0.8.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.
Files changed (79) hide show
  1. package/README.md +1 -1
  2. package/dist/config.d.mts +45 -1
  3. package/dist/config.d.ts +45 -1
  4. package/dist/module.d.mts +3 -3
  5. package/dist/module.d.ts +3 -3
  6. package/dist/module.json +2 -2
  7. package/dist/module.mjs +2 -2
  8. package/dist/runtime/components/MDC.vue +1 -1
  9. package/dist/runtime/components/MDCRenderer.vue.d.ts +1 -1
  10. package/dist/runtime/components/prose/ProseH1.vue +1 -1
  11. package/dist/runtime/components/prose/ProseH2.vue +1 -1
  12. package/dist/runtime/components/prose/ProseH3.vue +1 -1
  13. package/dist/runtime/components/prose/ProseH4.vue +1 -1
  14. package/dist/runtime/components/prose/ProseH5.vue +1 -1
  15. package/dist/runtime/components/prose/ProseH6.vue +1 -1
  16. package/dist/runtime/highlighter/rehype-nuxt.d.ts +1 -1
  17. package/dist/runtime/highlighter/{rehype-nuxt.mjs → rehype-nuxt.js} +1 -1
  18. package/dist/runtime/highlighter/rehype.d.ts +1 -1
  19. package/dist/runtime/highlighter/shiki.d.ts +2 -2
  20. package/dist/runtime/index.d.ts +4 -4
  21. package/dist/runtime/index.js +4 -0
  22. package/dist/runtime/parser/compiler.d.ts +1 -1
  23. package/dist/runtime/parser/{compiler.mjs → compiler.js} +1 -1
  24. package/dist/runtime/parser/handlers/{code.mjs → code.js} +1 -2
  25. package/dist/runtime/parser/handlers/{html.mjs → html.js} +1 -1
  26. package/dist/runtime/parser/handlers/index.d.ts +9 -9
  27. package/dist/runtime/parser/handlers/index.js +22 -0
  28. package/dist/runtime/parser/handlers/{paragraph.mjs → paragraph.js} +2 -2
  29. package/dist/runtime/parser/handlers/{utils.mjs → utils.js} +4 -4
  30. package/dist/runtime/parser/index.d.ts +1 -1
  31. package/dist/runtime/parser/{index.mjs → index.js} +5 -5
  32. package/dist/runtime/parser/options.d.ts +1 -1
  33. package/dist/runtime/parser/{options.mjs → options.js} +1 -1
  34. package/dist/runtime/parser/toc.d.ts +1 -1
  35. package/dist/runtime/parser/{toc.mjs → toc.js} +1 -1
  36. package/dist/runtime/parser/utils/plugins.d.ts +1 -1
  37. package/dist/runtime/utils/ast.d.ts +1 -1
  38. package/dist/runtime/utils/node.d.ts +1 -1
  39. package/dist/runtime/utils/slot.d.ts +1 -1
  40. package/dist/runtime/utils/{slot.mjs → slot.js} +1 -1
  41. package/dist/runtime/utils/{ssrSlot.mjs → ssrSlot.js} +1 -1
  42. package/dist/shared/mdc.a6f76af4.d.mts +9 -0
  43. package/dist/shared/mdc.a6f76af4.d.ts +9 -0
  44. package/dist/types.d.mts +11 -2
  45. package/dist/types.d.ts +11 -2
  46. package/package.json +24 -20
  47. package/dist/runtime/highlighter/types.d.ts +0 -14
  48. package/dist/runtime/highlighter/types.mjs +0 -0
  49. package/dist/runtime/index.mjs +0 -4
  50. package/dist/runtime/parser/handlers/index.mjs +0 -22
  51. package/dist/runtime/types/config.d.ts +0 -44
  52. package/dist/runtime/types/config.mjs +0 -0
  53. package/dist/runtime/types/hast.d.ts +0 -255
  54. package/dist/runtime/types/hast.mjs +0 -0
  55. package/dist/runtime/types/index.d.ts +0 -3
  56. package/dist/runtime/types/index.mjs +0 -3
  57. package/dist/runtime/types/parser.d.ts +0 -41
  58. package/dist/runtime/types/parser.mjs +0 -0
  59. package/dist/runtime/types/toc.d.ts +0 -12
  60. package/dist/runtime/types/toc.mjs +0 -0
  61. package/dist/runtime/types/tree.d.ts +0 -23
  62. package/dist/runtime/types/tree.mjs +0 -0
  63. package/dist/runtime/types/unist.d.ts +0 -107
  64. package/dist/runtime/types/unist.mjs +0 -0
  65. /package/dist/runtime/highlighter/{event-handler.mjs → event-handler.js} +0 -0
  66. /package/dist/runtime/highlighter/{rehype.mjs → rehype.js} +0 -0
  67. /package/dist/runtime/highlighter/{shiki.mjs → shiki.js} +0 -0
  68. /package/dist/runtime/parser/handlers/{containerComponent.mjs → containerComponent.js} +0 -0
  69. /package/dist/runtime/parser/handlers/{emphasis.mjs → emphasis.js} +0 -0
  70. /package/dist/runtime/parser/handlers/{image.mjs → image.js} +0 -0
  71. /package/dist/runtime/parser/handlers/{inlineCode.mjs → inlineCode.js} +0 -0
  72. /package/dist/runtime/parser/handlers/{link.mjs → link.js} +0 -0
  73. /package/dist/runtime/parser/handlers/{list.mjs → list.js} +0 -0
  74. /package/dist/runtime/parser/handlers/{strong.mjs → strong.js} +0 -0
  75. /package/dist/runtime/parser/utils/{html-tags-list.mjs → html-tags-list.js} +0 -0
  76. /package/dist/runtime/parser/utils/{plugins.mjs → plugins.js} +0 -0
  77. /package/dist/runtime/parser/utils/{props.mjs → props.js} +0 -0
  78. /package/dist/runtime/utils/{ast.mjs → ast.js} +0 -0
  79. /package/dist/runtime/utils/{node.mjs → node.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
- "version": "0.7.1",
3
+ "version": "0.8.1",
4
4
  "description": "Nuxt MDC module",
5
5
  "repository": "nuxt-modules/mdc",
6
6
  "license": "MIT",
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "./runtime": {
20
20
  "types": "./dist/runtime/index.d.ts",
21
- "import": "./dist/runtime/index.mjs"
21
+ "import": "./dist/runtime/index.js"
22
22
  },
23
23
  "./dist/runtime": {
24
24
  "types": "./dist/runtime/index.d.ts",
25
- "import": "./dist/runtime/index.mjs"
25
+ "import": "./dist/runtime/index.js"
26
26
  },
27
27
  "./runtime/components/*": {
28
28
  "types": "./dist/runtime/components/*.d.ts",
@@ -34,11 +34,11 @@
34
34
  },
35
35
  "./runtime/*": {
36
36
  "types": "./dist/runtime/*.d.ts",
37
- "import": "./dist/runtime/*.mjs"
37
+ "import": "./dist/runtime/*.js"
38
38
  },
39
39
  "./dist/runtime/*": {
40
40
  "types": "./dist/runtime/*.d.ts",
41
- "import": "./dist/runtime/*.mjs"
41
+ "import": "./dist/runtime/*.js"
42
42
  }
43
43
  },
44
44
  "main": "./dist/module.cjs",
@@ -66,23 +66,24 @@
66
66
  "dev:docs": "nuxi dev docs",
67
67
  "release": "release-it",
68
68
  "lint": "eslint .",
69
+ "typecheck": "nuxt typecheck",
69
70
  "test": "vitest run",
70
71
  "test:watch": "vitest watch"
71
72
  },
72
73
  "dependencies": {
73
- "@nuxt/kit": "^3.11.2",
74
- "@shikijs/transformers": "^1.5.2",
74
+ "@nuxt/kit": "^3.12.1",
75
+ "@shikijs/transformers": "^1.6.4",
75
76
  "@types/hast": "^3.0.4",
76
77
  "@types/mdast": "^4.0.4",
77
78
  "@vue/compiler-core": "^3.4.27",
78
79
  "consola": "^3.2.3",
79
- "debug": "^4.3.4",
80
+ "debug": "^4.3.5",
80
81
  "defu": "^6.1.4",
81
82
  "destr": "^2.0.3",
82
83
  "detab": "^3.0.2",
83
84
  "github-slugger": "^2.0.0",
84
85
  "hast-util-to-string": "^3.0.0",
85
- "mdast-util-to-hast": "^13.1.0",
86
+ "mdast-util-to-hast": "^13.2.0",
86
87
  "micromark-util-sanitize-uri": "^2.0.0",
87
88
  "ohash": "^1.1.3",
88
89
  "parse5": "^7.1.2",
@@ -93,13 +94,13 @@
93
94
  "rehype-slug": "^6.0.0",
94
95
  "rehype-sort-attribute-values": "^5.0.0",
95
96
  "rehype-sort-attributes": "^5.0.0",
96
- "remark-emoji": "^4.0.1",
97
+ "remark-emoji": "^5.0.0",
97
98
  "remark-gfm": "^4.0.0",
98
99
  "remark-mdc": "^3.2.1",
99
100
  "remark-parse": "^11.0.0",
100
101
  "remark-rehype": "^11.1.0",
101
102
  "scule": "^1.3.0",
102
- "shiki": "^1.5.2",
103
+ "shiki": "^1.6.4",
103
104
  "ufo": "^1.5.3",
104
105
  "unified": "^11.0.4",
105
106
  "unist-builder": "^4.0.0",
@@ -108,19 +109,22 @@
108
109
  },
109
110
  "devDependencies": {
110
111
  "@nuxt/devtools": "latest",
111
- "@nuxt/eslint-config": "^0.3.12",
112
- "@nuxt/module-builder": "^0.6.0",
113
- "@nuxt/schema": "^3.11.2",
114
- "@nuxt/test-utils": "^3.13.0",
112
+ "@nuxt/eslint-config": "^0.3.13",
113
+ "@nuxt/module-builder": "^0.7.1",
114
+ "@nuxt/schema": "^3.12.1",
115
+ "@nuxt/test-utils": "^3.13.1",
115
116
  "@nuxt/ui": "^2.16.0",
116
- "@types/node": "^20.12.12",
117
+ "@types/node": "^20.14.2",
117
118
  "changelogen": "^0.5.5",
118
- "eslint": "^9.2.0",
119
- "nuxt": "^3.11.2",
119
+ "eslint": "^9.4.0",
120
+ "nuxt": "^3.12.1",
120
121
  "rehype": "^13.0.1",
121
- "release-it": "^17.2.1",
122
- "vitest": "^1.6.0"
122
+ "release-it": "^17.3.0",
123
+ "typescript": "^5.4.5",
124
+ "vitest": "^1.6.0",
125
+ "vue-tsc": "^2.0.19"
123
126
  },
127
+ "packageManager": "pnpm@9.3.0",
124
128
  "release-it": {
125
129
  "git": {
126
130
  "commitMessage": "chore(release): release v${version}"
@@ -1,14 +0,0 @@
1
- import type { ElementContent } from 'hast';
2
- import type { BuiltinTheme } from 'shiki';
3
- export type MdcThemeOptions = BuiltinTheme | string | Record<string, BuiltinTheme | string>;
4
- export interface HighlighterOptions {
5
- highlights?: number[];
6
- meta?: string;
7
- }
8
- export interface HighlightResult {
9
- tree: ElementContent[];
10
- className?: string;
11
- style?: string;
12
- inlineStyle?: string;
13
- }
14
- export type Highlighter = (code: string, lang: string, theme: MdcThemeOptions, options: Partial<HighlighterOptions>) => Promise<HighlightResult>;
File without changes
@@ -1,4 +0,0 @@
1
- export { parseMarkdown, createMarkdownParser } from "./parser/index.mjs";
2
- export { rehypeHighlight } from "./highlighter/rehype.mjs";
3
- export { createShikiHighlighter } from "./highlighter/shiki.mjs";
4
- export * from "./utils/node.mjs";
@@ -1,22 +0,0 @@
1
- import emphasis from "./emphasis.mjs";
2
- import code from "./code.mjs";
3
- import html from "./html.mjs";
4
- import link from "./link.mjs";
5
- import list from "./list.mjs";
6
- import paragraph from "./paragraph.mjs";
7
- import image from "./image.mjs";
8
- import strong from "./strong.mjs";
9
- import inlineCode from "./inlineCode.mjs";
10
- import containerComponent from "./containerComponent.mjs";
11
- export default {
12
- emphasis,
13
- code,
14
- link,
15
- paragraph,
16
- html,
17
- list,
18
- image,
19
- strong,
20
- inlineCode,
21
- containerComponent
22
- };
@@ -1,44 +0,0 @@
1
- import type { Highlighter, HighlighterCore, ShikiTransformer } from 'shiki';
2
- import type { Processor } from 'unified';
3
- import type { MdcThemeOptions, HighlighterOptions } from '../highlighter/types';
4
- export type Awaitable<T> = T | Promise<T>;
5
- export interface MdcConfig {
6
- /**
7
- * Hooks for the unified markdown pipeline
8
- */
9
- unified?: {
10
- /**
11
- * Custom setup for unified processor before other plugins
12
- */
13
- pre?: (processor: Processor) => Awaitable<void | Processor>;
14
- /**
15
- * Custom setup for unified processor after remark but before rehype
16
- */
17
- remark?: (processor: Processor) => Awaitable<void | Processor>;
18
- /**
19
- * Custom setup for unified processor after rehype
20
- */
21
- rehype?: (processor: Processor) => Awaitable<void | Processor>;
22
- /**
23
- * Custom setup for unified processor after all plugins
24
- */
25
- post?: (processor: Processor) => Awaitable<void | Processor>;
26
- };
27
- /**
28
- * Custom hightlighter, available when `highlighter` is set to `custom`
29
- */
30
- highlighter?: Highlighter;
31
- /**
32
- * Hooks for shiki
33
- */
34
- shiki?: {
35
- /**
36
- * Get transformers for shiki
37
- */
38
- transformers?: ShikiTransformer[] | ((code: string, lang: string, theme: MdcThemeOptions, options: Partial<HighlighterOptions>) => Awaitable<ShikiTransformer[]>);
39
- /**
40
- * Custom setup for shiki instance, only called once on server or client
41
- */
42
- setup?: (highlighter: HighlighterCore) => Awaitable<void>;
43
- };
44
- }
File without changes
@@ -1,255 +0,0 @@
1
- import type { Data as UnistData, Literal as UnistLiteral, Node as UnistNode, Parent as UnistParent } from './unist';
2
- /**
3
- * Info associated with hast nodes by the ecosystem.
4
- *
5
- * This space is guaranteed to never be specified by unist or hast.
6
- * But you can use it in utilities and plugins to store data.
7
- *
8
- * This type can be augmented to register custom data.
9
- * For example:
10
- *
11
- * ```ts
12
- * declare module 'hast' {
13
- * interface Data {
14
- * // `someNode.data.myId` is typed as `number | undefined`
15
- * myId?: number | undefined
16
- * }
17
- * }
18
- * ```
19
- */
20
- export interface Data extends UnistData {
21
- }
22
- /**
23
- * Info associated with an element.
24
- */
25
- export interface Properties {
26
- [PropertyName: string]: boolean | number | string | null | undefined | Array<string | number>;
27
- }
28
- /**
29
- * Union of registered hast nodes that can occur in {@link Element}.
30
- *
31
- * To register mote custom hast nodes, add them to {@link ElementContentMap}.
32
- * They will be automatically added here.
33
- */
34
- export type ElementContent = ElementContentMap[keyof ElementContentMap];
35
- /**
36
- * Registry of all hast nodes that can occur as children of {@link Element}.
37
- *
38
- * For a union of all {@link Element} children, see {@link ElementContent}.
39
- */
40
- export interface ElementContentMap {
41
- comment: Comment;
42
- element: Element;
43
- text: Text;
44
- }
45
- /**
46
- * Union of registered hast nodes that can occur in {@link Root}.
47
- *
48
- * To register custom hast nodes, add them to {@link RootContentMap}.
49
- * They will be automatically added here.
50
- */
51
- export type RootContent = RootContentMap[keyof RootContentMap];
52
- /**
53
- * Registry of all hast nodes that can occur as children of {@link Root}.
54
- *
55
- * > 👉 **Note**: {@link Root} does not need to be an entire document.
56
- * > it can also be a fragment.
57
- *
58
- * For a union of all {@link Root} children, see {@link RootContent}.
59
- */
60
- export interface RootContentMap {
61
- comment: Comment;
62
- doctype: Doctype;
63
- element: Element;
64
- text: Text;
65
- }
66
- /**
67
- * Union of registered hast nodes that can occur in {@link Root}.
68
- *
69
- * @deprecated Use {@link RootContent} instead.
70
- */
71
- export type Content = RootContent;
72
- /**
73
- * Union of registered hast literals.
74
- *
75
- * To register custom hast nodes, add them to {@link RootContentMap} and other
76
- * places where relevant.
77
- * They will be automatically added here.
78
- */
79
- export type Literals = Extract<Nodes, UnistLiteral>;
80
- /**
81
- * Union of registered hast nodes.
82
- *
83
- * To register custom hast nodes, add them to {@link RootContentMap} and other
84
- * places where relevant.
85
- * They will be automatically added here.
86
- */
87
- export type Nodes = Root | RootContent;
88
- /**
89
- * Union of registered hast parents.
90
- *
91
- * To register custom hast nodes, add them to {@link RootContentMap} and other
92
- * places where relevant.
93
- * They will be automatically added here.
94
- */
95
- export type Parents = Extract<Nodes, UnistParent>;
96
- /**
97
- * Abstract hast node.
98
- *
99
- * This interface is supposed to be extended.
100
- * If you can use {@link Literal} or {@link Parent}, you should.
101
- * But for example in HTML, a `Doctype` is neither literal nor parent, but
102
- * still a node.
103
- *
104
- * To register custom hast nodes, add them to {@link RootContentMap} and other
105
- * places where relevant (such as {@link ElementContentMap}).
106
- *
107
- * For a union of all registered hast nodes, see {@link Nodes}.
108
- */
109
- export interface Node extends UnistNode {
110
- /**
111
- * Info from the ecosystem.
112
- */
113
- data?: Data | undefined;
114
- }
115
- /**
116
- * Abstract hast node that contains the smallest possible value.
117
- *
118
- * This interface is supposed to be extended if you make custom hast nodes.
119
- *
120
- * For a union of all registered hast literals, see {@link Literals}.
121
- */
122
- export interface Literal extends Node {
123
- /**
124
- * Plain-text value.
125
- */
126
- value: string;
127
- }
128
- /**
129
- * Abstract hast node that contains other hast nodes (*children*).
130
- *
131
- * This interface is supposed to be extended if you make custom hast nodes.
132
- *
133
- * For a union of all registered hast parents, see {@link Parents}.
134
- */
135
- export interface Parent extends Node {
136
- /**
137
- * List of children.
138
- */
139
- children: RootContent[];
140
- }
141
- /**
142
- * HTML comment.
143
- */
144
- export interface Comment extends Literal {
145
- /**
146
- * Node type of HTML comments in hast.
147
- */
148
- type: 'comment';
149
- /**
150
- * Data associated with the comment.
151
- */
152
- data?: CommentData | undefined;
153
- }
154
- /**
155
- * Info associated with hast comments by the ecosystem.
156
- */
157
- export interface CommentData extends Data {
158
- }
159
- /**
160
- * HTML document type.
161
- */
162
- export interface Doctype extends UnistNode {
163
- /**
164
- * Node type of HTML document types in hast.
165
- */
166
- type: 'doctype';
167
- /**
168
- * Data associated with the doctype.
169
- */
170
- data?: DoctypeData | undefined;
171
- }
172
- /**
173
- * Info associated with hast doctypes by the ecosystem.
174
- */
175
- export interface DoctypeData extends Data {
176
- }
177
- /**
178
- * HTML element.
179
- */
180
- export interface Element extends Parent {
181
- /**
182
- * Node type of elements.
183
- */
184
- type: 'element';
185
- /**
186
- * Tag name (such as `'body'`) of the element.
187
- */
188
- tagName: string;
189
- /**
190
- * Info associated with the element.
191
- */
192
- properties: Properties;
193
- /**
194
- * Children of element.
195
- */
196
- children: ElementContent[];
197
- /**
198
- * When the `tagName` field is `'template'`, a `content` field can be
199
- * present.
200
- */
201
- content?: Root | undefined;
202
- /**
203
- * Data associated with the element.
204
- */
205
- data?: ElementData | undefined;
206
- }
207
- /**
208
- * Info associated with hast elements by the ecosystem.
209
- */
210
- export interface ElementData extends Data {
211
- }
212
- /**
213
- * Document fragment or a whole document.
214
- *
215
- * Should be used as the root of a tree and must not be used as a child.
216
- *
217
- * Can also be used as the value for the content field on a `'template'` element.
218
- */
219
- export interface Root extends Parent {
220
- /**
221
- * Node type of hast root.
222
- */
223
- type: 'root';
224
- /**
225
- * Children of root.
226
- */
227
- children: RootContent[];
228
- /**
229
- * Data associated with the hast root.
230
- */
231
- data?: RootData | undefined;
232
- }
233
- /**
234
- * Info associated with hast root nodes by the ecosystem.
235
- */
236
- export interface RootData extends Data {
237
- }
238
- /**
239
- * HTML character data (plain text).
240
- */
241
- export interface Text extends Literal {
242
- /**
243
- * Node type of HTML character data (plain text) in hast.
244
- */
245
- type: 'text';
246
- /**
247
- * Data associated with the text.
248
- */
249
- data?: TextData | undefined;
250
- }
251
- /**
252
- * Info associated with hast texts by the ecosystem.
253
- */
254
- export interface TextData extends Data {
255
- }
File without changes
@@ -1,3 +0,0 @@
1
- export * from './tree';
2
- export * from './parser';
3
- export * from './toc';
@@ -1,3 +0,0 @@
1
- export * from "./tree.mjs";
2
- export * from "./parser.mjs";
3
- export * from "./toc.mjs";
@@ -1,41 +0,0 @@
1
- import type { Options as RehypeOption } from 'remark-rehype';
2
- import type { RehypeHighlightOption } from '../highlighter/rehype';
3
- import type { MdcConfig } from './config';
4
- import type { MDCData, MDCRoot } from './tree';
5
- import type { Toc } from './toc';
6
- export interface RemarkPlugin {
7
- instance?: any;
8
- options?: Array<any> | Record<string, any>;
9
- }
10
- export interface RehypePlugin {
11
- instance?: any;
12
- options?: Array<any> | Record<string, any>;
13
- }
14
- export interface MDCParseOptions {
15
- remark?: {
16
- plugins?: Record<string, false | RemarkPlugin>;
17
- };
18
- rehype?: {
19
- options?: RehypeOption;
20
- plugins?: Record<string, false | RehypePlugin>;
21
- };
22
- highlight?: RehypeHighlightOption | false;
23
- toc?: {
24
- /**
25
- * Maximum heading depth to include in the table of contents.
26
- */
27
- depth?: number;
28
- searchDepth?: number;
29
- };
30
- keepComments?: boolean;
31
- /**
32
- * Inline mdc.config.ts
33
- */
34
- configs?: MdcConfig[];
35
- }
36
- export interface MDCParserResult {
37
- data: MDCData;
38
- body: MDCRoot;
39
- excerpt: MDCRoot | undefined;
40
- toc: Toc | undefined;
41
- }
File without changes
@@ -1,12 +0,0 @@
1
- export interface TocLink {
2
- id: string;
3
- text: string;
4
- depth: number;
5
- children?: TocLink[];
6
- }
7
- export interface Toc {
8
- title: string;
9
- depth: number;
10
- searchDepth: number;
11
- links: TocLink[];
12
- }
File without changes
@@ -1,23 +0,0 @@
1
- export type MDCText = {
2
- type: 'text';
3
- value: string;
4
- };
5
- export type MDCComment = {
6
- type: 'comment';
7
- value: string;
8
- };
9
- export type MDCElement = {
10
- type: 'element';
11
- tag: string;
12
- props: Record<string, any> | undefined;
13
- children: Array<MDCElement | MDCText | MDCComment>;
14
- };
15
- export type MDCNode = MDCElement | MDCText | MDCComment;
16
- export type MDCRoot = {
17
- type: 'root';
18
- children: Array<MDCNode>;
19
- };
20
- export interface MDCData extends Record<string, any> {
21
- title: string;
22
- description: string;
23
- }
File without changes
@@ -1,107 +0,0 @@
1
- /**
2
- * Info associated with nodes by the ecosystem.
3
- *
4
- * This space is guaranteed to never be specified by unist or specifications
5
- * implementing unist.
6
- * But you can use it in utilities and plugins to store data.
7
- *
8
- * This type can be augmented to register custom data.
9
- * For example:
10
- *
11
- * ```ts
12
- * declare module 'unist' {
13
- * interface Data {
14
- * // `someNode.data.myId` is typed as `number | undefined`
15
- * myId?: number | undefined
16
- * }
17
- * }
18
- * ```
19
- */
20
- export interface Data {
21
- }
22
- /**
23
- * One place in a source file.
24
- */
25
- export interface Point {
26
- /**
27
- * Line in a source file (1-indexed integer).
28
- */
29
- line: number;
30
- /**
31
- * Column in a source file (1-indexed integer).
32
- */
33
- column: number;
34
- /**
35
- * Character in a source file (0-indexed integer).
36
- */
37
- offset?: number | undefined;
38
- }
39
- /**
40
- * Position of a node in a source document.
41
- *
42
- * A position is a range between two points.
43
- */
44
- export interface Position {
45
- /**
46
- * Place of the first character of the parsed source region.
47
- */
48
- start: Point;
49
- /**
50
- * Place of the first character after the parsed source region.
51
- */
52
- end: Point;
53
- }
54
- /**
55
- * Abstract unist node that contains the smallest possible value.
56
- *
57
- * This interface is supposed to be extended.
58
- *
59
- * For example, in HTML, a `text` node is a leaf that contains text.
60
- */
61
- export interface Literal extends Node {
62
- /**
63
- * Plain value.
64
- */
65
- value: unknown;
66
- }
67
- /**
68
- * Abstract unist node.
69
- *
70
- * The syntactic unit in unist syntax trees are called nodes.
71
- *
72
- * This interface is supposed to be extended.
73
- * If you can use {@link Literal} or {@link Parent}, you should.
74
- * But for example in markdown, a `thematicBreak` (`***`), is neither literal
75
- * nor parent, but still a node.
76
- */
77
- export interface Node {
78
- /**
79
- * Node type.
80
- */
81
- type: string;
82
- /**
83
- * Info from the ecosystem.
84
- */
85
- data?: Data | undefined;
86
- /**
87
- * Position of a node in a source document.
88
- *
89
- * Nodes that are generated (not in the original source document) must not
90
- * have a position.
91
- */
92
- position?: Position | undefined;
93
- }
94
- /**
95
- * Abstract unist node that contains other nodes (*children*).
96
- *
97
- * This interface is supposed to be extended.
98
- *
99
- * For example, in XML, an element is a parent of different things, such as
100
- * comments, text, and further elements.
101
- */
102
- export interface Parent extends Node {
103
- /**
104
- * List of children.
105
- */
106
- children: Node[];
107
- }
File without changes