UNPKG

velite

Version:

Turns Markdown / MDX, YAML, JSON, or other files into app's data layer with type-safe schema.

2,013 lines (1,895 loc) β€’ 261 kB
import * as unist from 'unist'; import { Node as Node$3, Data as Data$8, Point, Position, Parent as Parent$2 } from 'unist'; import { CompileOptions } from '@mdx-js/mdx'; // ## Interfaces /** * Info associated with hast nodes by the ecosystem. * * This space is guaranteed to never be specified by unist or hast. * But you can use it in utilities and plugins to store data. * * This type can be augmented to register custom data. * For example: * * ```ts * declare module 'hast' { * interface Data { * // `someNode.data.myId` is typed as `number | undefined` * myId?: number | undefined * } * } * ``` */ interface Data$7 extends Data$8 {} /** * Info associated with an element. */ interface Properties { [PropertyName: string]: boolean | number | string | null | undefined | Array<string | number>; } // ## Content maps /** * Union of registered hast nodes that can occur in {@link Element}. * * To register mote custom hast nodes, add them to {@link ElementContentMap}. * They will be automatically added here. */ type ElementContent = ElementContentMap[keyof ElementContentMap]; /** * Registry of all hast nodes that can occur as children of {@link Element}. * * For a union of all {@link Element} children, see {@link ElementContent}. */ interface ElementContentMap { comment: Comment; element: Element; text: Text$1; } /** * Union of registered hast nodes that can occur in {@link Root}. * * To register custom hast nodes, add them to {@link RootContentMap}. * They will be automatically added here. */ type RootContent$1 = RootContentMap$1[keyof RootContentMap$1]; /** * Registry of all hast nodes that can occur as children of {@link Root}. * * > πŸ‘‰ **Note**: {@link Root} does not need to be an entire document. * > it can also be a fragment. * * For a union of all {@link Root} children, see {@link RootContent}. */ interface RootContentMap$1 { comment: Comment; doctype: Doctype; element: Element; text: Text$1; } /** * Union of registered hast nodes. * * To register custom hast nodes, add them to {@link RootContentMap} and other * places where relevant. * They will be automatically added here. */ type Nodes = Root$1 | RootContent$1; // ## Abstract nodes /** * Abstract hast node. * * This interface is supposed to be extended. * If you can use {@link Literal} or {@link Parent}, you should. * But for example in HTML, a `Doctype` is neither literal nor parent, but * still a node. * * To register custom hast nodes, add them to {@link RootContentMap} and other * places where relevant (such as {@link ElementContentMap}). * * For a union of all registered hast nodes, see {@link Nodes}. */ interface Node$2 extends Node$3 { /** * Info from the ecosystem. */ data?: Data$7 | undefined; } /** * Abstract hast node that contains the smallest possible value. * * This interface is supposed to be extended if you make custom hast nodes. * * For a union of all registered hast literals, see {@link Literals}. */ interface Literal$1 extends Node$2 { /** * Plain-text value. */ value: string; } /** * Abstract hast node that contains other hast nodes (*children*). * * This interface is supposed to be extended if you make custom hast nodes. * * For a union of all registered hast parents, see {@link Parents}. */ interface Parent$1 extends Node$2 { /** * List of children. */ children: RootContent$1[]; } // ## Concrete nodes /** * HTML comment. */ interface Comment extends Literal$1 { /** * Node type of HTML comments in hast. */ type: "comment"; /** * Data associated with the comment. */ data?: CommentData | undefined; } /** * Info associated with hast comments by the ecosystem. */ interface CommentData extends Data$7 {} /** * HTML document type. */ interface Doctype extends Node$3 { /** * Node type of HTML document types in hast. */ type: "doctype"; /** * Data associated with the doctype. */ data?: DoctypeData | undefined; } /** * Info associated with hast doctypes by the ecosystem. */ interface DoctypeData extends Data$7 {} /** * HTML element. */ interface Element extends Parent$1 { /** * Node type of elements. */ type: "element"; /** * Tag name (such as `'body'`) of the element. */ tagName: string; /** * Info associated with the element. */ properties: Properties; /** * Children of element. */ children: ElementContent[]; /** * When the `tagName` field is `'template'`, a `content` field can be * present. */ content?: Root$1 | undefined; /** * Data associated with the element. */ data?: ElementData | undefined; } /** * Info associated with hast elements by the ecosystem. */ interface ElementData extends Data$7 {} /** * Document fragment or a whole document. * * Should be used as the root of a tree and must not be used as a child. * * Can also be used as the value for the content field on a `'template'` element. */ interface Root$1 extends Parent$1 { /** * Node type of hast root. */ type: "root"; /** * Children of root. */ children: RootContent$1[]; /** * Data associated with the hast root. */ data?: RootData$1 | undefined; } /** * Info associated with hast root nodes by the ecosystem. */ interface RootData$1 extends Data$7 {} /** * HTML character data (plain text). */ interface Text$1 extends Literal$1 { /** * Node type of HTML character data (plain text) in hast. */ type: "text"; /** * Data associated with the text. */ data?: TextData$1 | undefined; } /** * Info associated with hast texts by the ecosystem. */ interface TextData$1 extends Data$7 {} // ## Enumeration /** * How phrasing content is aligned * ({@link https://drafts.csswg.org/css-text/ | [CSSTEXT]}). * * * `'left'`: See the * {@link https://drafts.csswg.org/css-text/#valdef-text-align-left | left} * value of the `text-align` CSS property * * `'right'`: See the * {@link https://drafts.csswg.org/css-text/#valdef-text-align-right | right} * value of the `text-align` CSS property * * `'center'`: See the * {@link https://drafts.csswg.org/css-text/#valdef-text-align-center | center} * value of the `text-align` CSS property * * `null`: phrasing content is aligned as defined by the host environment * * Used in GFM tables. */ type AlignType = "center" | "left" | "right" | null; /** * Explicitness of a reference. * * `'shortcut'`: the reference is implicit, its identifier inferred from its * content * `'collapsed'`: the reference is explicit, its identifier inferred from its * content * `'full'`: the reference is explicit, its identifier explicitly set */ type ReferenceType = "shortcut" | "collapsed" | "full"; // ## Mixin /** * Node with a fallback. */ interface Alternative { /** * Equivalent content for environments that cannot represent the node as * intended. */ alt?: string | null | undefined; } /** * Internal relation from one node to another. * * Whether the value of `identifier` is expected to be a unique identifier or * not depends on the type of node including the Association. * An example of this is that they should be unique on {@link Definition}, * whereas multiple {@link LinkReference}s can be non-unique to be associated * with one definition. */ interface Association { /** * Relation of association. * * `identifier` is a source value: character escapes and character * references are not parsed. * * It can match another node. * * Its value must be normalized. * To normalize a value, collapse markdown whitespace (`[\t\n\r ]+`) to a space, * trim the optional initial and/or final space, and perform Unicode-aware * case-folding. */ identifier: string; /** * Relation of association, in parsed form. * * `label` is a `string` value: it works just like `title` on {@link Link} * or a `lang` on {@link Code}: character escapes and character references * are parsed. * * It can match another node. */ label?: string | null | undefined; } /** * Marker that is associated to another node. */ interface Reference extends Association { /** * Explicitness of the reference. */ referenceType: ReferenceType; } /** * Reference to resource. */ interface Resource { /** * URL to the referenced resource. */ url: string; /** * Advisory information for the resource, such as would be appropriate for * a tooltip. */ title?: string | null | undefined; } // ## Interfaces /** * Info associated with mdast nodes by the ecosystem. * * This space is guaranteed to never be specified by unist or mdast. * But you can use it in utilities and plugins to store data. * * This type can be augmented to register custom data. * For example: * * ```ts * declare module 'mdast' { * interface Data { * // `someNode.data.myId` is typed as `number | undefined` * myId?: number | undefined * } * } * ``` */ interface Data$6 extends Data$8 {} // ## Content maps /** * Union of registered mdast nodes that can occur where block content is * expected. * * To register custom mdast nodes, add them to {@link BlockContentMap}. * They will be automatically added here. */ type BlockContent = BlockContentMap[keyof BlockContentMap]; /** * Registry of all mdast nodes that can occur where {@link BlockContent} is * expected. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface BlockContentMap { * // Allow using MDX ESM nodes defined by `remark-mdx`. * mdxjsEsm: MdxjsEsm; * } * } * ``` * * For a union of all block content, see {@link RootContent}. */ interface BlockContentMap { blockquote: Blockquote; code: Code; heading: Heading$1; html: Html; list: List; paragraph: Paragraph; table: Table; thematicBreak: ThematicBreak; } /** * Union of registered mdast nodes that can occur where definition content is * expected. * * To register custom mdast nodes, add them to {@link DefinitionContentMap}. * They will be automatically added here. */ type DefinitionContent = DefinitionContentMap[keyof DefinitionContentMap]; /** * Registry of all mdast nodes that can occur where {@link DefinitionContent} * is expected. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface DefinitionContentMap { * custom: Custom; * } * } * ``` * * For a union of all definition content, see {@link RootContent}. */ interface DefinitionContentMap { definition: Definition; footnoteDefinition: FootnoteDefinition; } /** * Union of registered mdast nodes that can occur where list content is * expected. * * To register custom mdast nodes, add them to {@link ListContentMap}. * They will be automatically added here. */ type ListContent = ListContentMap[keyof ListContentMap]; /** * Registry of all mdast nodes that can occur where {@link ListContent} * is expected. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface ListContentMap { * custom: Custom; * } * } * ``` * * For a union of all list content, see {@link RootContent}. */ interface ListContentMap { listItem: ListItem; } /** * Union of registered mdast nodes that can occur where phrasing content is * expected. * * To register custom mdast nodes, add them to {@link PhrasingContentMap}. * They will be automatically added here. */ type PhrasingContent = PhrasingContentMap[keyof PhrasingContentMap]; /** * Registry of all mdast nodes that can occur where {@link PhrasingContent} * is expected. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface PhrasingContentMap { * // Allow using MDX JSX (text) nodes defined by `remark-mdx`. * mdxJsxTextElement: MDXJSXTextElement; * } * } * ``` * * For a union of all phrasing content, see {@link RootContent}. */ interface PhrasingContentMap { break: Break; delete: Delete; emphasis: Emphasis; footnoteReference: FootnoteReference; html: Html; image: Image$1; imageReference: ImageReference; inlineCode: InlineCode; link: Link; linkReference: LinkReference; strong: Strong; text: Text; } /** * Union of registered mdast nodes that can occur in {@link Root}. * * To register custom mdast nodes, add them to {@link RootContentMap}. * They will be automatically added here. */ type RootContent = RootContentMap[keyof RootContentMap]; /** * Registry of all mdast nodes that can occur as children of {@link Root}. * * > **Note**: {@link Root} does not need to be an entire document. * > it can also be a fragment. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface RootContentMap { * // Allow using toml nodes defined by `remark-frontmatter`. * toml: TOML; * } * } * ``` * * For a union of all {@link Root} children, see {@link RootContent}. */ interface RootContentMap { blockquote: Blockquote; break: Break; code: Code; definition: Definition; delete: Delete; emphasis: Emphasis; footnoteDefinition: FootnoteDefinition; footnoteReference: FootnoteReference; heading: Heading$1; html: Html; image: Image$1; imageReference: ImageReference; inlineCode: InlineCode; link: Link; linkReference: LinkReference; list: List; listItem: ListItem; paragraph: Paragraph; strong: Strong; table: Table; tableCell: TableCell; tableRow: TableRow; text: Text; thematicBreak: ThematicBreak; yaml: Yaml; } /** * Union of registered mdast nodes that can occur where row content is * expected. * * To register custom mdast nodes, add them to {@link RowContentMap}. * They will be automatically added here. */ type RowContent = RowContentMap[keyof RowContentMap]; /** * Registry of all mdast nodes that can occur where {@link RowContent} * is expected. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface RowContentMap { * custom: Custom; * } * } * ``` * * For a union of all row content, see {@link RootContent}. */ interface RowContentMap { tableCell: TableCell; } /** * Union of registered mdast nodes that can occur where table content is * expected. * * To register custom mdast nodes, add them to {@link TableContentMap}. * They will be automatically added here. */ type TableContent = TableContentMap[keyof TableContentMap]; /** * Registry of all mdast nodes that can occur where {@link TableContent} * is expected. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface TableContentMap { * custom: Custom; * } * } * ``` * * For a union of all table content, see {@link RootContent}. */ interface TableContentMap { tableRow: TableRow; } // ## Abstract nodes /** * Abstract mdast node that contains the smallest possible value. * * This interface is supposed to be extended if you make custom mdast nodes. * * For a union of all registered mdast literals, see {@link Literals}. */ interface Literal extends Node$1 { /** * Plain-text value. */ value: string; } /** * Abstract mdast node. * * This interface is supposed to be extended. * If you can use {@link Literal} or {@link Parent}, you should. * But for example in markdown, a thematic break (`***`) is neither literal nor * parent, but still a node. * * To register custom mdast nodes, add them to {@link RootContentMap} and other * places where relevant (such as {@link ElementContentMap}). * * For a union of all registered mdast nodes, see {@link Nodes}. */ interface Node$1 extends Node$3 { /** * Info from the ecosystem. */ data?: Data$6 | undefined; } /** * Abstract mdast node that contains other mdast nodes (*children*). * * This interface is supposed to be extended if you make custom mdast nodes. * * For a union of all registered mdast parents, see {@link Parents}. */ interface Parent extends Node$1 { /** * List of children. */ children: RootContent[]; } // ## Concrete nodes /** * Markdown block quote. */ interface Blockquote extends Parent { /** * Node type of mdast block quote. */ type: "blockquote"; /** * Children of block quote. */ children: Array<BlockContent | DefinitionContent>; /** * Data associated with the mdast block quote. */ data?: BlockquoteData | undefined; } /** * Info associated with mdast block quote nodes by the ecosystem. */ interface BlockquoteData extends Data$6 {} /** * Markdown break. */ interface Break extends Node$1 { /** * Node type of mdast break. */ type: "break"; /** * Data associated with the mdast break. */ data?: BreakData | undefined; } /** * Info associated with mdast break nodes by the ecosystem. */ interface BreakData extends Data$6 {} /** * Markdown code (flow) (block). */ interface Code extends Literal { /** * Node type of mdast code (flow). */ type: "code"; /** * Language of computer code being marked up. */ lang?: string | null | undefined; /** * Custom information relating to the node. * * If the lang field is present, a meta field can be present. */ meta?: string | null | undefined; /** * Data associated with the mdast code (flow). */ data?: CodeData | undefined; } /** * Info associated with mdast code (flow) (block) nodes by the ecosystem. */ interface CodeData extends Data$6 {} /** * Markdown definition. */ interface Definition extends Node$1, Association, Resource { /** * Node type of mdast definition. */ type: "definition"; /** * Data associated with the mdast definition. */ data?: DefinitionData | undefined; } /** * Info associated with mdast definition nodes by the ecosystem. */ interface DefinitionData extends Data$6 {} /** * Markdown GFM delete (strikethrough). */ interface Delete extends Parent { /** * Node type of mdast GFM delete. */ type: "delete"; /** * Children of GFM delete. */ children: PhrasingContent[]; /** * Data associated with the mdast GFM delete. */ data?: DeleteData | undefined; } /** * Info associated with mdast GFM delete nodes by the ecosystem. */ interface DeleteData extends Data$6 {} /** * Markdown emphasis. */ interface Emphasis extends Parent { /** * Node type of mdast emphasis. */ type: "emphasis"; /** * Children of emphasis. */ children: PhrasingContent[]; /** * Data associated with the mdast emphasis. */ data?: EmphasisData | undefined; } /** * Info associated with mdast emphasis nodes by the ecosystem. */ interface EmphasisData extends Data$6 {} /** * Markdown GFM footnote definition. */ interface FootnoteDefinition extends Parent, Association { /** * Node type of mdast GFM footnote definition. */ type: "footnoteDefinition"; /** * Children of GFM footnote definition. */ children: Array<BlockContent | DefinitionContent>; /** * Data associated with the mdast GFM footnote definition. */ data?: FootnoteDefinitionData | undefined; } /** * Info associated with mdast GFM footnote definition nodes by the ecosystem. */ interface FootnoteDefinitionData extends Data$6 {} /** * Markdown GFM footnote reference. */ interface FootnoteReference extends Association, Node$1 { /** * Node type of mdast GFM footnote reference. */ type: "footnoteReference"; /** * Data associated with the mdast GFM footnote reference. */ data?: FootnoteReferenceData | undefined; } /** * Info associated with mdast GFM footnote reference nodes by the ecosystem. */ interface FootnoteReferenceData extends Data$6 {} /** * Markdown heading. */ interface Heading$1 extends Parent { /** * Node type of mdast heading. */ type: "heading"; /** * Heading rank. * * A value of `1` is said to be the highest rank and `6` the lowest. */ depth: 1 | 2 | 3 | 4 | 5 | 6; /** * Children of heading. */ children: PhrasingContent[]; /** * Data associated with the mdast heading. */ data?: HeadingData | undefined; } /** * Info associated with mdast heading nodes by the ecosystem. */ interface HeadingData extends Data$6 {} /** * Markdown HTML. */ interface Html extends Literal { /** * Node type of mdast HTML. */ type: "html"; /** * Data associated with the mdast HTML. */ data?: HtmlData | undefined; } /** * Info associated with mdast HTML nodes by the ecosystem. */ interface HtmlData extends Data$6 {} /** * Markdown image. */ interface Image$1 extends Alternative, Node$1, Resource { /** * Node type of mdast image. */ type: "image"; /** * Data associated with the mdast image. */ data?: ImageData | undefined; } /** * Info associated with mdast image nodes by the ecosystem. */ interface ImageData extends Data$6 {} /** * Markdown image reference. */ interface ImageReference extends Alternative, Node$1, Reference { /** * Node type of mdast image reference. */ type: "imageReference"; /** * Data associated with the mdast image reference. */ data?: ImageReferenceData | undefined; } /** * Info associated with mdast image reference nodes by the ecosystem. */ interface ImageReferenceData extends Data$6 {} /** * Markdown code (text) (inline). */ interface InlineCode extends Literal { /** * Node type of mdast code (text). */ type: "inlineCode"; /** * Data associated with the mdast code (text). */ data?: InlineCodeData | undefined; } /** * Info associated with mdast code (text) (inline) nodes by the ecosystem. */ interface InlineCodeData extends Data$6 {} /** * Markdown link. */ interface Link extends Parent, Resource { /** * Node type of mdast link. */ type: "link"; /** * Children of link. */ children: PhrasingContent[]; /** * Data associated with the mdast link. */ data?: LinkData | undefined; } /** * Info associated with mdast link nodes by the ecosystem. */ interface LinkData extends Data$6 {} /** * Markdown link reference. */ interface LinkReference extends Parent, Reference { /** * Node type of mdast link reference. */ type: "linkReference"; /** * Children of link reference. */ children: PhrasingContent[]; /** * Data associated with the mdast link reference. */ data?: LinkReferenceData | undefined; } /** * Info associated with mdast link reference nodes by the ecosystem. */ interface LinkReferenceData extends Data$6 {} /** * Markdown list. */ interface List extends Parent { /** * Node type of mdast list. */ type: "list"; /** * Whether the items have been intentionally ordered (when `true`), or that * the order of items is not important (when `false` or not present). */ ordered?: boolean | null | undefined; /** * The starting number of the list, when the `ordered` field is `true`. */ start?: number | null | undefined; /** * Whether one or more of the children are separated with a blank line from * its siblings (when `true`), or not (when `false` or not present). */ spread?: boolean | null | undefined; /** * Children of list. */ children: ListContent[]; /** * Data associated with the mdast list. */ data?: ListData | undefined; } /** * Info associated with mdast list nodes by the ecosystem. */ interface ListData extends Data$6 {} /** * Markdown list item. */ interface ListItem extends Parent { /** * Node type of mdast list item. */ type: "listItem"; /** * Whether the item is a tasklist item (when `boolean`). * * When `true`, the item is complete. * When `false`, the item is incomplete. */ checked?: boolean | null | undefined; /** * Whether one or more of the children are separated with a blank line from * its siblings (when `true`), or not (when `false` or not present). */ spread?: boolean | null | undefined; /** * Children of list item. */ children: Array<BlockContent | DefinitionContent>; /** * Data associated with the mdast list item. */ data?: ListItemData | undefined; } /** * Info associated with mdast list item nodes by the ecosystem. */ interface ListItemData extends Data$6 {} /** * Markdown paragraph. */ interface Paragraph extends Parent { /** * Node type of mdast paragraph. */ type: "paragraph"; /** * Children of paragraph. */ children: PhrasingContent[]; /** * Data associated with the mdast paragraph. */ data?: ParagraphData | undefined; } /** * Info associated with mdast paragraph nodes by the ecosystem. */ interface ParagraphData extends Data$6 {} /** * Document fragment or a whole document. * * Should be used as the root of a tree and must not be used as a child. */ interface Root extends Parent { /** * Node type of mdast root. */ type: "root"; /** * Data associated with the mdast root. */ data?: RootData | undefined; } /** * Info associated with mdast root nodes by the ecosystem. */ interface RootData extends Data$6 {} /** * Markdown strong. */ interface Strong extends Parent { /** * Node type of mdast strong. */ type: "strong"; /** * Children of strong. */ children: PhrasingContent[]; /** * Data associated with the mdast strong. */ data?: StrongData | undefined; } /** * Info associated with mdast strong nodes by the ecosystem. */ interface StrongData extends Data$6 {} /** * Markdown GFM table. */ interface Table extends Parent { /** * Node type of mdast GFM table. */ type: "table"; /** * How cells in columns are aligned. */ align?: AlignType[] | null | undefined; /** * Children of GFM table. */ children: TableContent[]; /** * Data associated with the mdast GFM table. */ data?: TableData | undefined; } /** * Info associated with mdast GFM table nodes by the ecosystem. */ interface TableData extends Data$6 {} /** * Markdown GFM table row. */ interface TableRow extends Parent { /** * Node type of mdast GFM table row. */ type: "tableRow"; /** * Children of GFM table row. */ children: RowContent[]; /** * Data associated with the mdast GFM table row. */ data?: TableRowData | undefined; } /** * Info associated with mdast GFM table row nodes by the ecosystem. */ interface TableRowData extends Data$6 {} /** * Markdown GFM table cell. */ interface TableCell extends Parent { /** * Node type of mdast GFM table cell. */ type: "tableCell"; /** * Children of GFM table cell. */ children: PhrasingContent[]; /** * Data associated with the mdast GFM table cell. */ data?: TableCellData | undefined; } /** * Info associated with mdast GFM table cell nodes by the ecosystem. */ interface TableCellData extends Data$6 {} /** * Markdown text. */ interface Text extends Literal { /** * Node type of mdast text. */ type: "text"; /** * Data associated with the mdast text. */ data?: TextData | undefined; } /** * Info associated with mdast text nodes by the ecosystem. */ interface TextData extends Data$6 {} /** * Markdown thematic break (horizontal rule). */ interface ThematicBreak extends Node$1 { /** * Node type of mdast thematic break. */ type: "thematicBreak"; /** * Data associated with the mdast thematic break. */ data?: ThematicBreakData | undefined; } /** * Info associated with mdast thematic break nodes by the ecosystem. */ interface ThematicBreakData extends Data$6 {} /** * Markdown YAML. */ interface Yaml extends Literal { /** * Node type of mdast YAML. */ type: "yaml"; /** * Data associated with the mdast YAML. */ data?: YamlData | undefined; } /** * Info associated with mdast YAML nodes by the ecosystem. */ interface YamlData extends Data$6 {} /** * Message. */ declare class VFileMessage extends Error { /** * Create a message for `reason`. * * > πŸͺ¦ **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {Options | null | undefined} [options] * @returns * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace] * Configuration (optional). * @param {string | null | undefined} [origin] * Place in code where the message originates (example: * `'my-package:my-rule'` or `'my-rule'`). * @returns * Instance of `VFileMessage`. */ constructor(reason: string, options?: Options$6 | null | undefined); /** * Create a message for `reason`. * * > πŸͺ¦ **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {Options | null | undefined} [options] * @returns * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace] * Configuration (optional). * @param {string | null | undefined} [origin] * Place in code where the message originates (example: * `'my-package:my-rule'` or `'my-rule'`). * @returns * Instance of `VFileMessage`. */ constructor(reason: string, parent: Node$3 | NodeLike$1 | null | undefined, origin?: string | null | undefined); /** * Create a message for `reason`. * * > πŸͺ¦ **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {Options | null | undefined} [options] * @returns * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace] * Configuration (optional). * @param {string | null | undefined} [origin] * Place in code where the message originates (example: * `'my-package:my-rule'` or `'my-rule'`). * @returns * Instance of `VFileMessage`. */ constructor(reason: string, place: Point | Position | null | undefined, origin?: string | null | undefined); /** * Create a message for `reason`. * * > πŸͺ¦ **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {Options | null | undefined} [options] * @returns * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace] * Configuration (optional). * @param {string | null | undefined} [origin] * Place in code where the message originates (example: * `'my-package:my-rule'` or `'my-rule'`). * @returns * Instance of `VFileMessage`. */ constructor(reason: string, origin?: string | null | undefined); /** * Create a message for `reason`. * * > πŸͺ¦ **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {Options | null | undefined} [options] * @returns * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace] * Configuration (optional). * @param {string | null | undefined} [origin] * Place in code where the message originates (example: * `'my-package:my-rule'` or `'my-rule'`). * @returns * Instance of `VFileMessage`. */ constructor(cause: Error | VFileMessage, parent: Node$3 | NodeLike$1 | null | undefined, origin?: string | null | undefined); /** * Create a message for `reason`. * * > πŸͺ¦ **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {Options | null | undefined} [options] * @returns * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace] * Configuration (optional). * @param {string | null | undefined} [origin] * Place in code where the message originates (example: * `'my-package:my-rule'` or `'my-rule'`). * @returns * Instance of `VFileMessage`. */ constructor(cause: Error | VFileMessage, place: Point | Position | null | undefined, origin?: string | null | undefined); /** * Create a message for `reason`. * * > πŸͺ¦ **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {Options | null | undefined} [options] * @returns * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | Options | Point | Position | string | null | undefined} [optionsOrParentOrPlace] * Configuration (optional). * @param {string | null | undefined} [origin] * Place in code where the message originates (example: * `'my-package:my-rule'` or `'my-rule'`). * @returns * Instance of `VFileMessage`. */ constructor(cause: Error | VFileMessage, origin?: string | null | undefined); /** * Stack of ancestor nodes surrounding the message. * * @type {Array<Node> | undefined} */ ancestors: Array<Node$3> | undefined; /** * Starting column of message. * * @type {number | undefined} */ column: number | undefined; /** * State of problem. * * * `true` β€” error, file not usable * * `false` β€” warning, change may be needed * * `undefined` β€” change likely not needed * * @type {boolean | null | undefined} */ fatal: boolean | null | undefined; /** * Path of a file (used throughout the `VFile` ecosystem). * * @type {string | undefined} */ file: string | undefined; /** * Starting line of error. * * @type {number | undefined} */ line: number | undefined; /** * Place of message. * * @type {Point | Position | undefined} */ place: Point | Position | undefined; /** * Reason for message, should use markdown. * * @type {string} */ reason: string; /** * Category of message (example: `'my-rule'`). * * @type {string | undefined} */ ruleId: string | undefined; /** * Namespace of message (example: `'my-package'`). * * @type {string | undefined} */ source: string | undefined; /** * Specify the source value that’s being reported, which is deemed * incorrect. * * @type {string | undefined} */ actual: string | undefined; /** * Suggest acceptable values that can be used instead of `actual`. * * @type {Array<string> | undefined} */ expected: Array<string> | undefined; /** * Long form description of the message (you should use markdown). * * @type {string | undefined} */ note: string | undefined; /** * Link to docs for the message. * * > πŸ‘‰ **Note**: this must be an absolute URL that can be passed as `x` * > to `new URL(x)`. * * @type {string | undefined} */ url: string | undefined; } type NodeLike$1 = object & { type: string; position?: Position | undefined; }; /** * Configuration. */ type Options$6 = { /** * Stack of (inclusive) ancestor nodes surrounding the message (optional). */ ancestors?: Array<Node$3> | null | undefined; /** * Original error cause of the message (optional). */ cause?: Error | null | undefined; /** * Place of message (optional). */ place?: Point | Position | null | undefined; /** * Category of message (optional, example: `'my-rule'`). */ ruleId?: string | null | undefined; /** * Namespace of who sent the message (optional, example: `'my-package'`). */ source?: string | null | undefined; }; type Options$5 = Options$6; // See: <https://github.com/sindresorhus/type-fest/blob/main/source/empty-object.d.ts> declare const emptyObjectSymbol$4: unique symbol /** * Things that can be passed to the constructor. */ type Compatible$2 = Options$4 | URL | VFile | Value$2 /** * Raw source map. * * See: * <https://github.com/mozilla/source-map/blob/60adcb0/source-map.d.ts#L15-L23>. */ interface Map$1 { /** * The generated file this source map is associated with. */ file: string /** * A string of base64 VLQs which contain the actual mappings. */ mappings: string /** * An array of identifiers which can be referenced by individual mappings. */ names: Array<string> /** * An array of contents of the original source files. */ sourcesContent?: Array<string> | undefined /** * The URL root from which all sources are relative. */ sourceRoot?: string | undefined /** * An array of URLs to the original source files. */ sources: Array<string> /** * Which version of the source map spec this map is following. */ version: number } /** * This map registers the type of the `data` key of a `VFile`. * * This type can be augmented to register custom `data` types. * * @example * declare module 'vfile' { * interface DataMap { * // `file.data.name` is typed as `string` * name: string * } * } */ interface DataMap$2 { [emptyObjectSymbol$4]?: never } /** * Custom info. * * Known attributes can be added to {@linkcode DataMap} */ type Data$5 = Record<string, unknown> & Partial<DataMap$2> /** * Configuration. */ interface Options$4 { /** * Arbitrary fields that will be shallow copied over to the new file. */ [key: string]: unknown /** * Set `basename` (name). */ basename?: string | null | undefined /** * Set `cwd` (working directory). */ cwd?: string | null | undefined /** * Set `data` (associated info). */ data?: Data$5 | null | undefined /** * Set `dirname` (path w/o basename). */ dirname?: string | null | undefined /** * Set `extname` (extension with dot). */ extname?: string | null | undefined /** * Set `history` (paths the file moved between). */ history?: Array<string> | null | undefined /** * Set `path` (current path). */ path?: URL | string | null | undefined /** * Set `stem` (name without extension). */ stem?: string | null | undefined /** * Set `value` (the contents of the file). */ value?: Value$2 | null | undefined } /** * Contents of the file. * * Can either be text or a `Uint8Array` structure. */ type Value$2 = Uint8Array | string declare class VFile { /** * Create a new virtual file. * * `options` is treated as: * * * `string` or `Uint8Array` β€” `{value: options}` * * `URL` β€” `{path: options}` * * `VFile` β€” shallow copies its data over to the new file * * `object` β€” all fields are shallow copied over to the new file * * Path related fields are set in the following order (least specific to * most specific): `history`, `path`, `basename`, `stem`, `extname`, * `dirname`. * * You cannot set `dirname` or `extname` without setting either `history`, * `path`, `basename`, or `stem` too. * * @param {Compatible | null | undefined} [value] * File value. * @returns * New instance. */ constructor(value?: Compatible$2 | null | undefined); /** * Base of `path` (default: `process.cwd()` or `'/'` in browsers). * * @type {string} */ cwd: string; /** * Place to store custom info (default: `{}`). * * It’s OK to store custom data directly on the file but moving it to * `data` is recommended. * * @type {Data} */ data: Data$5; /** * List of file paths the file moved between. * * The first is the original path and the last is the current path. * * @type {Array<string>} */ history: Array<string>; /** * List of messages associated with the file. * * @type {Array<VFileMessage>} */ messages: Array<VFileMessage>; /** * Raw value. * * @type {Value} */ value: Value$2; /** * Source map. * * This type is equivalent to the `RawSourceMap` type from the `source-map` * module. * * @type {Map | null | undefined} */ map: Map$1 | null | undefined; /** * Custom, non-string, compiled, representation. * * This is used by unified to store non-string results. * One example is when turning markdown into React nodes. * * @type {unknown} */ result: unknown; /** * Whether a file was saved to disk. * * This is used by vfile reporters. * * @type {boolean} */ stored: boolean; /** * Set basename (including extname) (`'index.min.js'`). * * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'` * on windows). * Cannot be nullified (use `file.path = file.dirname` instead). * * @param {string