import { transformAsync } from '@babel/core'; import * as unist from 'unist'; import { Node as Node$2, Point as Point$2, Position as Position$2, Data as Data$6 } from 'unist'; import * as hast from 'hast'; import { ElementContent as ElementContent$1, Properties, Literal, Data as Data$4, Parent as Parent$1 } from 'hast'; import * as mdast from 'mdast'; import { Parent, BlockContent, DefinitionContent, Data as Data$5, PhrasingContent, Literal as Literal$1 } from 'mdast'; import { Program } from 'estree-jsx'; /** * Message. */ declare class VFileMessage extends Error { constructor(reason: string, options?: Options$5 | null | undefined) constructor( reason: string, parent: Node$1 | NodeLike$1 | null | undefined, origin?: string | null | undefined ) constructor( reason: string, place: Point$1 | Position$1 | null | undefined, origin?: string | null | undefined ) constructor(reason: string, origin?: string | null | undefined) constructor( cause: Error | VFileMessage, parent: Node$1 | NodeLike$1 | null | undefined, origin?: string | null | undefined ) constructor( cause: Error | VFileMessage, place: Point$1 | Position$1 | null | undefined, origin?: string | null | undefined ) constructor(cause: Error | VFileMessage, origin?: string | null | undefined) /** * Stack of ancestor nodes surrounding the message. * * @type {Array | undefined} */ ancestors: Array | 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$1 | Position$1 | 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 | undefined} */ expected: Array | 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 Node$1 = unist.Node type Point$1 = unist.Point type Position$1 = unist.Position type NodeLike$1 = object & { type: string position?: Position$1 | undefined } /** * Configuration. */ type Options$5 = { /** * Stack of (inclusive) ancestor nodes surrounding the message (optional). */ ancestors?: Array | null | undefined /** * Original error cause of the message (optional). */ cause?: Error | null | undefined /** * Place of message (optional). */ place?: Point$1 | Position$1 | 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$4 = Options$5 declare class VFile$1 { /** * 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$3; /** * List of file paths the file moved between. * * The first is the original path and the last is the current path. * * @type {Array} */ history: Array; /** * List of messages associated with the file. * * @type {Array} */ messages: Array; /** * Raw value. * * @type {Value} */ value: Value$1; /** * 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} basename * Basename. * @returns {undefined} * Nothing. */ set basename(basename: string); /** * Get the basename (including extname) (example: `'index.min.js'`). * * @returns {string | undefined} * Basename. */ get basename(): string | undefined; /** * Set the full path (example: `'~/index.min.js'`). * * Cannot be nullified. * You can set a file URL (a `URL` object with a `file:` protocol) which will * be turned into a path with `url.fileURLToPath`. * * @param {URL | string} path * Path. * @returns {undefined} * Nothing. */ set path(path: string | URL); /** * Get the full path (example: `'~/index.min.js'`). * * @returns {string} * Path. */ get path(): string; /** * Set the parent path (example: `'~'`). * * Cannot be set if there’s no `path` yet. * * @param {string | undefined} dirname * Dirname. * @returns {undefined} * Nothing. */ set dirname(dirname: string | undefined); /** * Get the parent path (example: `'~'`). * * @returns {string | undefined} * Dirname. */ get dirname(): string | undefined; /** * Set the extname (including dot) (example: `'.js'`). * * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'` * on windows). * Cannot be set if there’s no `path` yet. * * @param {string | undefined} extname * Extname. * @returns {undefined} * Nothing. */ set extname(extname: string | undefined); /** * Get the extname (including dot) (example: `'.js'`). * * @returns {string | undefined} * Extname. */ get extname(): string | undefined; /** * Set the stem (basename w/o extname) (example: `'index.min'`). * * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'` * on windows). * Cannot be nullified (use `file.path = file.dirname` instead). * * @param {string} stem * Stem. * @returns {undefined} * Nothing. */ set stem(stem: string); /** * Get the stem (basename w/o extname) (example: `'index.min'`). * * @returns {string | undefined} * Stem. */ get stem(): string | undefined; /** * Create a fatal message for `reason` associated with the file. * * The `fatal` field of the message is set to `true` (error; file not usable) * and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {never} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {never} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {never} * Never. * @throws {VFileMessage} * Message. */ fail(reason: string, options?: Options$4 | null | undefined): never; /** * Create a fatal message for `reason` associated with the file. * * The `fatal` field of the message is set to `true` (error; file not usable) * and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {never} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {never} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {never} * Never. * @throws {VFileMessage} * Message. */ fail(reason: string, parent: Node$2 | NodeLike | null | undefined, origin?: string | null | undefined): never; /** * Create a fatal message for `reason` associated with the file. * * The `fatal` field of the message is set to `true` (error; file not usable) * and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {never} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {never} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {never} * Never. * @throws {VFileMessage} * Message. */ fail(reason: string, place: Point$2 | Position$2 | null | undefined, origin?: string | null | undefined): never; /** * Create a fatal message for `reason` associated with the file. * * The `fatal` field of the message is set to `true` (error; file not usable) * and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {never} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {never} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {never} * Never. * @throws {VFileMessage} * Message. */ fail(reason: string, origin?: string | null | undefined): never; /** * Create a fatal message for `reason` associated with the file. * * The `fatal` field of the message is set to `true` (error; file not usable) * and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {never} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {never} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {never} * Never. * @throws {VFileMessage} * Message. */ fail(cause: Error | VFileMessage, parent: Node$2 | NodeLike | null | undefined, origin?: string | null | undefined): never; /** * Create a fatal message for `reason` associated with the file. * * The `fatal` field of the message is set to `true` (error; file not usable) * and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {never} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {never} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {never} * Never. * @throws {VFileMessage} * Message. */ fail(cause: Error | VFileMessage, place: Point$2 | Position$2 | null | undefined, origin?: string | null | undefined): never; /** * Create a fatal message for `reason` associated with the file. * * The `fatal` field of the message is set to `true` (error; file not usable) * and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {never} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {never} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {never} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {never} * Never. * @throws {VFileMessage} * Message. */ fail(cause: Error | VFileMessage, origin?: string | null | undefined): never; /** * Create an info message for `reason` associated with the file. * * The `fatal` field of the message is set to `undefined` (info; change * likely not needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ info(reason: string, options?: Options$4 | null | undefined): VFileMessage; /** * Create an info message for `reason` associated with the file. * * The `fatal` field of the message is set to `undefined` (info; change * likely not needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ info(reason: string, parent: Node$2 | NodeLike | null | undefined, origin?: string | null | undefined): VFileMessage; /** * Create an info message for `reason` associated with the file. * * The `fatal` field of the message is set to `undefined` (info; change * likely not needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ info(reason: string, place: Point$2 | Position$2 | null | undefined, origin?: string | null | undefined): VFileMessage; /** * Create an info message for `reason` associated with the file. * * The `fatal` field of the message is set to `undefined` (info; change * likely not needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ info(reason: string, origin?: string | null | undefined): VFileMessage; /** * Create an info message for `reason` associated with the file. * * The `fatal` field of the message is set to `undefined` (info; change * likely not needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ info(cause: Error | VFileMessage, parent: Node$2 | NodeLike | null | undefined, origin?: string | null | undefined): VFileMessage; /** * Create an info message for `reason` associated with the file. * * The `fatal` field of the message is set to `undefined` (info; change * likely not needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ info(cause: Error | VFileMessage, place: Point$2 | Position$2 | null | undefined, origin?: string | null | undefined): VFileMessage; /** * Create an info message for `reason` associated with the file. * * The `fatal` field of the message is set to `undefined` (info; change * likely not needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ info(cause: Error | VFileMessage, origin?: string | null | undefined): VFileMessage; /** * Create a message for `reason` associated with the file. * * The `fatal` field of the message is set to `false` (warning; change may be * needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ message(reason: string, options?: Options$4 | null | undefined): VFileMessage; /** * Create a message for `reason` associated with the file. * * The `fatal` field of the message is set to `false` (warning; change may be * needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ message(reason: string, parent: Node$2 | NodeLike | null | undefined, origin?: string | null | undefined): VFileMessage; /** * Create a message for `reason` associated with the file. * * The `fatal` field of the message is set to `false` (warning; change may be * needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ message(reason: string, place: Point$2 | Position$2 | null | undefined, origin?: string | null | undefined): VFileMessage; /** * Create a message for `reason` associated with the file. * * The `fatal` field of the message is set to `false` (warning; change may be * needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ message(reason: string, origin?: string | null | undefined): VFileMessage; /** * Create a message for `reason` associated with the file. * * The `fatal` field of the message is set to `false` (warning; change may be * needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ message(cause: Error | VFileMessage, parent: Node$2 | NodeLike | null | undefined, origin?: string | null | undefined): VFileMessage; /** * Create a message for `reason` associated with the file. * * The `fatal` field of the message is set to `false` (warning; change may be * needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ message(cause: Error | VFileMessage, place: Point$2 | Position$2 | null | undefined, origin?: string | null | undefined): VFileMessage; /** * Create a message for `reason` associated with the file. * * The `fatal` field of the message is set to `false` (warning; change may be * needed) and the `file` field is set to the current file path. * The message is added to the `messages` field on `file`. * * > 🪦 **Note**: also has obsolete signatures. * * @overload * @param {string} reason * @param {MessageOptions | null | undefined} [options] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {string} reason * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Node | NodeLike | null | undefined} parent * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {Point | Position | null | undefined} place * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @overload * @param {Error | VFileMessage} cause * @param {string | null | undefined} [origin] * @returns {VFileMessage} * * @param {Error | VFileMessage | string} causeOrReason * Reason for message, should use markdown. * @param {Node | NodeLike | MessageOptions | 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 {VFileMessage} * Message. */ message(cause: Error | VFileMessage, origin?: string | null | undefined): VFileMessage; /** * Serialize the file. * * > **Note**: which encodings are supported depends on the engine. * > For info on Node.js, see: * > . * * @param {string | null | undefined} [encoding='utf8'] * Character encoding to understand `value` as when it’s a `Uint8Array` * (default: `'utf-8'`). * @returns {string} * Serialized file. */ toString(encoding?: string | null | undefined): string; } type NodeLike = object & { type: string; position?: Position$2 | undefined; }; // See: declare const emptyObjectSymbol$2: unique symbol /** * Things that can be passed to the constructor. */ type Compatible$2 = Options$3 | URL | VFile$1 | Value$1 /** * Raw source map. * * See: * . */ 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 /** * An array of contents of the original source files. */ sourcesContent?: Array | undefined /** * The URL root from which all sources are relative. */ sourceRoot?: string | undefined /** * An array of URLs to the original source files. */ sources: Array /** * 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 { [emptyObjectSymbol$2]?: never } /** * Custom info. * * Known attributes can be added to {@linkcode DataMap} */ type Data$3 = Record & Partial /** * Configuration. */ interface Options$3 { /** * 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$3 | 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 | 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$1 | null | undefined } /** * Contents of the file. * * Can either be text or a `Uint8Array` structure. */ type Value$1 = Uint8Array | string // See: declare const emptyObjectSymbol$1: unique symbol /** * Interface of known results from compilers. * * Normally, compilers result in text ({@link Value `Value`} of `vfile`). * When you compile to something else, such as a React node (as in, * `rehype-react`), you can augment this interface to include that type. * * ```ts * import type {ReactNode} from 'somewhere' * * declare module 'unified' { * interface CompileResultMap { * // Register a new result (value is used, key should match it). * ReactNode: ReactNode * } * } * * export {} // You may not need this, but it makes sure the file is a module. * ``` * * Use {@link CompileResults `CompileResults`} to access the values. */ interface CompileResultMap$1 { // Note: if `Value` from `VFile` is changed, this should too. Uint8Array: Uint8Array string: string } /** * Interface of known data that can be supported by all plugins. * * Typically, options can be given to a specific plugin, but sometimes it makes * sense to have information shared with several plugins. * For example, a list of HTML elements that are self-closing, which is needed * during all phases. * * To type this, do something like: * * ```ts * declare module 'unified' { * interface Data { * htmlVoidElements?: Array | undefined * } * } * * export {} // You may not need this, but it makes sure the file is a module. * ``` */ interface Data$2 { settings?: Settings$2 | undefined } /** * Interface of known extra options, that can be supported by parser and * compilers. * * This exists so that users can use packages such as `remark`, which configure * both parsers and compilers (in this case `remark-parse` and * `remark-stringify`), and still provide options for them. * * When you make parsers or compilers, that could be packaged up together, * you should support `this.data('settings')` as input and merge it with * explicitly passed `options`. * Then, to type it, using `remark-stringify` as an example, do something like: * * ```ts * declare module 'unified' { * interface Settings { * bullet: '*' | '+' | '-' * // … * } * } * * export {} // You may not need this, but it makes sure the file is a module. * ``` */ interface Settings$2 { [emptyObjectSymbol$1]?: never } type Middleware = (...input: Array) => any /** * Call all middleware. */ type Run = (...input: Array) => void /** * Add `fn` (middleware) to the list. */ type Use = (fn: Middleware) => Pipeline$1 /** * Middleware. */ type Pipeline$1 = { run: Run use: Use } declare const CallableInstance: new (property: string | symbol) => (...parameters: Parameters_1) => Result; /** * @template {Node | undefined} [ParseTree=undefined] * Output of `parse` (optional). * @template {Node | undefined} [HeadTree=undefined] * Input for `run` (optional). * @template {Node | undefined} [TailTree=undefined] * Output for `run` (optional). * @template {Node | undefined} [CompileTree=undefined] * Input of `stringify` (optional). * @template {CompileResults | undefined} [CompileResult=undefined] * Output of `stringify` (optional). * @extends {CallableInstance<[], Processor>} */ declare class Processor extends CallableInstance<[], Processor> { /** * Create a processor. */ constructor(); /** * Compiler to use (deprecated). * * @deprecated * Use `compiler` instead. * @type {( * Compiler< * CompileTree extends undefined ? Node : CompileTree, * CompileResult extends undefined ? CompileResults : CompileResult * > | * undefined * )} */ Compiler: (Compiler | undefined); /** * Parser to use (deprecated). * * @deprecated * Use `parser` instead. * @type {( * Parser | * undefined * )} */ Parser: (Parser | undefined); /** * Internal list of configured plugins. * * @deprecated * This is a private internal property and should not be used. * @type {Array>>} */ attachers: Array<[plugin: Plugin, ...parameters: unknown[]]>; /** * Compiler to use. * * @type {( * Compiler< * CompileTree extends undefined ? Node : CompileTree, * CompileResult extends undefined ? CompileResults : CompileResult * > | * undefined * )} */ compiler: (Compiler | undefined); /** * Internal state to track where we are while freezing. * * @deprecated * This is a private internal property and should not be used. * @type {number} */ freezeIndex: number; /** * Internal state to track whether we’re frozen. * * @deprecated * This is a private internal property and should not be used. * @type {boolean | undefined} */ frozen: boolean | undefined; /** * Internal state. * * @deprecated * This is a private internal property and should not be used. * @type {Data} */ namespace: Data$1; /** * Parser to use. * * @type {( * Parser | * undefined * )} */ parser: (Parser | undefined); /** * Internal list of configured transformers. * * @deprecated * This is a private internal property and should not be used. * @type {Pipeline} */ transformers: Pipeline; /** * Copy a processor. * * @deprecated * This is a private internal method and should not be used. * @returns {Processor} * New *unfrozen* processor ({@link Processor `Processor`}) that is * configured to work the same as its ancestor. * When the descendant processor is configured in the future it does not * affect the ancestral processor. */ copy(): Processor; /** * Configure the processor with info available to all plugins. * Information is stored in an object. * * Typically, options can be given to a specific plugin, but sometimes it * makes sense to have information shared with several plugins. * For example, a list of HTML elements that are self-closing, which is * needed during all phases. * * > 👉 **Note**: setting information cannot occur on *frozen* processors. * > Call the processor first to create a new unfrozen processor. * * > 👉 **Note**: to register custom data in TypeScript, augment the * > {@link Data `Data`} interface. * * @example * This example show how to get and set info: * * ```js * import {unified} from 'unified' * * const processor = unified().data('alpha', 'bravo') * * processor.data('alpha') // => 'bravo' * * processor.data() // => {alpha: 'bravo'} * * processor.data({charlie: 'delta'}) * * processor.data() // => {charlie: 'delta'} * ``` * * @template {keyof Data} Key * * @overload * @returns {Data} * * @overload * @param {Data} dataset * @returns {Processor} * * @overload * @param {Key} key * @returns {Data[Key]} * * @overload * @param {Key} key * @param {Data[Key]} value * @returns {Processor} * * @param {Data | Key} [key] * Key to get or set, or entire dataset to set, or nothing to get the * entire dataset (optional). * @param {Data[Key]} [value] * Value to set (optional). * @returns {unknown} * The current processor when setting, the value at `key` when getting, or * the entire dataset when getting without key. */ data(): Data$1; /** * Configure the processor with info available to all plugins. * Information is stored in an object. * * Typically, options can be given to a specific plugin, but sometimes it * makes sense to have information shared with several plugins. * For example, a list of HTML elements that are self-closing, which is * needed during all phases. * * > 👉 **Note**: setting information cannot occur on *frozen* processors. * > Call the processor first to create a new unfrozen processor. * * > 👉 **Note**: to register custom data in TypeScript, augment the * > {@link Data `Data`} interface. * * @example * This example show how to get and set info: * * ```js * import {unified} from 'unified' * * const processor = unified().data('alpha', 'bravo') * * processor.data('alpha') // => 'bravo' * * processor.data() // => {alpha: 'bravo'} * * processor.data({charlie: 'delta'}) * * processor.data() // => {charlie: 'delta'} * ``` * * @template {keyof Data} Key * * @overload * @returns {Data} * * @overload * @param {Data} dataset * @returns {Processor} * * @overload * @param {Key} key * @returns {Data[Key]} * * @overload * @param {Key} key * @param {Data[Key]} value * @returns {Processor} * * @param {Data | Key} [key] * Key to get or set, or entire dataset to set, or nothing to get the * entire dataset (optional). * @param {Data[Key]} [value] * Value to set (optional). * @returns {unknown} * The current processor when setting, the value at `key` when getting, or * the entire dataset when getting without key. */ data(dataset: Data$1): Processor; /** * Configure the processor with info available to all plugins. * Information is stored in an object. * * Typically, options can be given to a specific plugin, but sometimes it * makes sense to have information shared with several plugins. * For example, a list of HTML elements that are self-closing, which is * needed during all phases. * * > 👉 **Note**: setting information cannot occur on *frozen* processors. * > Call the processor first to create a new unfrozen processor. * * > 👉 **Note**: to register custom data in TypeScript, augment the * > {@link Data `Data`} interface. * * @example * This example show how to get and set info: * * ```js * import {unified} from 'unified' * * const processor = unified().data('alpha', 'bravo') * * processor.data('alpha') // => 'bravo' * * processor.data() // => {alpha: 'bravo'} * * processor.data({charlie: 'delta'}) * * processor.data() // => {charlie: 'delta'} * ``` * * @template {keyof Data} Key * * @overload * @returns {Data} * * @overload * @param {Data} dataset * @returns {Processor} * * @overload * @param {Key} key * @returns {Data[Key]} * * @overload * @param {Key} key * @param {Data[Key]} value * @returns {Processor} * * @param {Data | Key} [key] * Key to get or set, or entire dataset to set, or nothing to get the * entire dataset (optional). * @param {Data[Key]} [value] * Value to set (optional). * @returns {unknown} * The current processor when setting, the value at `key` when getting, or * the entire dataset when getting without key. */ data(key: Key): Data[Key]; /** * Configure the processor with info available to all plugins. * Information is stored in an object. * * Typically, options can be given to a specific plugin, but sometimes it * makes sense to have information shared with several plugins. * For example, a list of HTML elements that are self-closing, which is * needed during all phases. * * > 👉 **Note**: setting information cannot occur on *frozen* processors. * > Call the processor first to create a new unfrozen processor. * * > 👉 **Note**: to register custom data in TypeScript, augment the * > {@link Data `Data`} interface. * * @example * This example show how to get and set info: * * ```js * import {unified} from 'unified' * * const processor = unified().data('alpha', 'bravo') * * processor.data('alpha') // => 'bravo' * * processor.data() // => {alpha: 'bravo'} * * processor.data({charlie: 'delta'}) * * processor.data() // => {charlie: 'delta'} * ``` * * @template {keyof Data} Key * * @overload * @returns {Data} * * @overload * @param {Data} dataset * @returns {Processor} * * @overload * @param {Key} key * @returns {Data[Key]} * * @overload * @param {Key} key * @param {Data[Key]} value * @returns {Processor} * * @param {Data | Key} [key] * Key to get or set, or entire dataset to set, or nothing to get the * entire dataset (optional). * @param {Data[Key]} [value] * Value to set (optional). * @returns {unknown} * The current processor when setting, the value at `key` when getting, or * the entire dataset when getting without key. */ data(key: Key, value: Data[Key]): Processor; /** * Freeze a processor. * * Frozen processors are meant to be extended and not to be configured * directly. * * When a processor is frozen it cannot be unfrozen. * New processors working the same way can be created by calling the * processor. * * It’s possible to freeze processors explicitly by calling `.freeze()`. * Processors freeze automatically when `.parse()`, `.run()`, `.runSync()`, * `.stringify()`, `.process()`, or `.processSync()` are called. * * @returns {Processor} * The current processor. */ freeze(): Processor; /** * Parse text to a syntax tree. * * > 👉 **Note**: `parse` freezes the processor if not already *frozen*. * * > 👉 **Note**: `parse` performs the parse phase, not the run phase or other * > phases. * * @param {Compatible | undefined} [file] * file to parse (optional); typically `string` or `VFile`; any value * accepted as `x` in `new VFile(x)`. * @returns {ParseTree extends undefined ? Node : ParseTree} * Syntax tree representing `file`. */ parse(file?: Compatible$1 | undefined): ParseTree extends undefined ? Node : ParseTree; /** * Process the given file as configured on the processor. * * > 👉 **Note**: `process` freezes the processor if not already *frozen*. * * > 👉 **Note**: `process` performs the parse, run, and stringify phases. * * @overload * @param {Compatible | undefined} file * @param {ProcessCallback>} done * @returns {undefined} * * @overload * @param {Compatible | undefined} [file] * @returns {Promise>} * * @param {Compatible | undefined} [file] * File (optional); typically `string` or `VFile`]; any value accepted as * `x` in `new VFile(x)`. * @param {ProcessCallback> | undefined} [done] * Callback (optional). * @returns {Promise | undefined} * Nothing if `done` is given. * Otherwise a promise, rejected with a fatal error or resolved with the * processed file. * * The parsed, transformed, and compiled value is available at * `file.value` (see note). * * > 👉 **Note**: unified typically compiles by serializing: most * > compilers return `string` (or `Uint8Array`). * > Some compilers, such as the one configured with * > [`rehype-react`][rehype-react], return other values (in this case, a * > React tree). * > If you’re using a compiler that doesn’t serialize, expect different * > result values. * > * > To register custom results in TypeScript, add them to * > {@link CompileResultMap `CompileResultMap`}. * * [rehype-react]: https://github.com/rehypejs/rehype-react */ process(file: Compatible$1 | undefined, done: ProcessCallback>): undefined; /** * Process the given file as configured on the processor. * * > 👉 **Note**: `process` freezes the processor if not already *frozen*. * * > 👉 **Note**: `process` performs the parse, run, and stringify phases. * * @overload * @param {Compatible | undefined} file * @param {ProcessCallback>} done * @returns {undefined} * * @overload * @param {Compatible | undefined} [file] * @returns {Promise>} * * @param {Compatible | undefined} [file] * File (optional); typically `string` or `VFile`]; any value accepted as * `x` in `new VFile(x)`. * @param {ProcessCallback> | undefined} [done] * Callback (optional). * @returns {Promise | undefined} * Nothing if `done` is given. * Otherwise a promise, rejected with a fatal error or resolved with the * processed file. * * The parsed, transformed, and compiled value is available at * `file.value` (see note). * * > 👉 **Note**: unified typically compiles by serializing: most * > compilers return `string` (or `Uint8Array`). * > Some compilers, such as the one configured with * > [`rehype-react`][rehype-react], return other values (in this case, a * > React tree). * > If you’re using a compiler that doesn’t serialize, expect different * > result values. * > * > To register custom results in TypeScript, add them to * > {@link CompileResultMap `CompileResultMap`}. * * [rehype-react]: https://github.com/rehypejs/rehype-react */ process(file?: Compatible$1 | undefined): Promise>; /** * Process the given file as configured on the processor. * * An error is thrown if asynchronous transforms are configured. * * > 👉 **Note**: `processSync` freezes the processor if not already *frozen*. * * > 👉 **Note**: `processSync` performs the parse, run, and stringify phases. * * @param {Compatible | undefined} [file] * File (optional); typically `string` or `VFile`; any value accepted as * `x` in `new VFile(x)`. * @returns {VFileWithOutput} * The processed file. * * The parsed, transformed, and compiled value is available at * `file.value` (see note). * * > 👉 **Note**: unified typically compiles by serializing: most * > compilers return `string` (or `Uint8Array`). * > Some compilers, such as the one configured with * > [`rehype-react`][rehype-react], return other values (in this case, a * > React tree). * > If you’re using a compiler that doesn’t serialize, expect different * > result values. * > * > To register custom results in TypeScript, add them to * > {@link CompileResultMap `CompileResultMap`}. * * [rehype-react]: https://github.com/rehypejs/rehype-react */ processSync(file?: Compatible$1 | undefined): VFileWithOutput; /** * Run *transformers* on a syntax tree. * * > 👉 **Note**: `run` freezes the processor if not already *frozen*. * * > 👉 **Note**: `run` performs the run phase, not other phases. * * @overload * @param {HeadTree extends undefined ? Node : HeadTree} tree * @param {RunCallback} done * @returns {undefined} * * @overload * @param {HeadTree extends undefined ? Node : HeadTree} tree * @param {Compatible | undefined} file * @param {RunCallback} done * @returns {undefined} * * @overload * @param {HeadTree extends undefined ? Node : HeadTree} tree * @param {Compatible | undefined} [file] * @returns {Promise} * * @param {HeadTree extends undefined ? Node : HeadTree} tree * Tree to transform and inspect. * @param {( * RunCallback | * Compatible * )} [file] * File associated with `node` (optional); any value accepted as `x` in * `new VFile(x)`. * @param {RunCallback} [done] * Callback (optional). * @returns {Promise | undefined} * Nothing if `done` is given. * Otherwise, a promise rejected with a fatal error or resolved with the * transformed tree. */ run(tree: HeadTree extends undefined ? Node : HeadTree, done: RunCallback): undefined; /** * Run *transformers* on a syntax tree. * * > 👉 **Note**: `run` freezes the processor if not already *frozen*. * * > 👉 **Note**: `run` performs the run phase, not other phases. * * @overload * @param {HeadTree extends undefined ? Node : HeadTree} tree * @param {RunCallback} done * @returns {undefined} * * @overload * @param {HeadTree extends undefined ? Node : HeadTree} tree * @param {Compatible | undefined} file * @param {RunCallback} done * @returns {undefined} * * @overload * @param {HeadTree extends undefined ? Node : HeadTree} tree * @param {Compatible | undefined} [file] * @returns {Promise} * * @param {HeadTree extends undefined ? Node : HeadTree} tree * Tree to transform and inspect. * @param {( * RunCallback | * Compatible * )} [file] * File associated with `node` (optional); any value accepted as `x` in * `new VFile(x)`. * @param {RunCallback} [done] * Callback (optional). * @returns {Promise | undefined} * Nothing if `done` is given. * Otherwise, a promise rejected with a fatal error or resolved with the * transformed tree. */ run(tree: HeadTree extends undefined ? Node : HeadTree, file: Compatible$1 | undefined, done: RunCallback): undefined; /** * Run *transformers* on a syntax tree. * * > 👉 **Note**: `run` freezes the processor if not already *frozen*. * * > 👉 **Note**: `run` performs the run phase, not other phases. * * @overload * @param {HeadTree extends undefined ? Node : HeadTree} tree * @param {RunCallback} done * @returns {undefined} * * @overload * @param {HeadTree extends undefined ? Node : HeadTree} tree * @param {Compatible | undefined} file * @param {RunCallback} done * @returns {undefined} * * @overload * @param {HeadTree extends undefined ? Node : HeadTree} tree * @param {Compatible | undefined} [file] * @returns {Promise} * * @param {HeadTree extends undefined ? Node : HeadTree} tree * Tree to transform and inspect. * @param {( * RunCallback | * Compatible * )} [file] * File associated with `node` (optional); any value accepted as `x` in * `new VFile(x)`. * @param {RunCallback} [done] * Callback (optional). * @returns {Promise | undefined} * Nothing if `done` is given. * Otherwise, a promise rejected with a fatal error or resolved with the * transformed tree. */ run(tree: HeadTree extends undefined ? Node : HeadTree, file?: Compatible$1 | undefined): Promise; /** * Run *transformers* on a syntax tree. * * An error is thrown if asynchronous transforms are configured. * * > 👉 **Note**: `runSync` freezes the processor if not already *frozen*. * * > 👉 **Note**: `runSync` performs the run phase, not other phases. * * @param {HeadTree extends undefined ? Node : HeadTree} tree * Tree to transform and inspect. * @param {Compatible | undefined} [file] * File associated with `node` (optional); any value accepted as `x` in * `new VFile(x)`. * @returns {TailTree extends undefined ? Node : TailTree} * Transformed tree. */ runSync(tree: HeadTree extends undefined ? Node : HeadTree, file?: Compatible$1 | undefined): TailTree extends undefined ? Node : TailTree; /** * Compile a syntax tree. * * > 👉 **Note**: `stringify` freezes the processor if not already *frozen*. * * > 👉 **Note**: `stringify` performs the stringify phase, not the run phase * > or other phases. * * @param {CompileTree extends undefined ? Node : CompileTree} tree * Tree to compile. * @param {Compatible | undefined} [file] * File associated with `node` (optional); any value accepted as `x` in * `new VFile(x)`. * @returns {CompileResult extends undefined ? Value : CompileResult} * Textual representation of the tree (see note). * * > 👉 **Note**: unified typically compiles by serializing: most compilers * > return `string` (or `Uint8Array`). * > Some compilers, such as the one configured with * > [`rehype-react`][rehype-react], return other values (in this case, a * > React tree). * > If you’re using a compiler that doesn’t serialize, expect different * > result values. * > * > To register custom results in TypeScript, add them to * > {@link CompileResultMap `CompileResultMap`}. * * [rehype-react]: https://github.com/rehypejs/rehype-react */ stringify(tree: CompileTree extends undefined ? Node : CompileTree, file?: Compatible$1 | undefined): CompileResult extends undefined ? Value : CompileResult; /** * Configure the processor to use a plugin, a list of usable values, or a * preset. * * If the processor is already using a plugin, the previous plugin * configuration is changed based on the options that are passed in. * In other words, the plugin is not added a second time. * * > 👉 **Note**: `use` cannot be called on *frozen* processors. * > Call the processor first to create a new unfrozen processor. * * @example * There are many ways to pass plugins to `.use()`. * This example gives an overview: * * ```js * import {unified} from 'unified' * * unified() * // Plugin with options: * .use(pluginA, {x: true, y: true}) * // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`): * .use(pluginA, {y: false, z: true}) * // Plugins: * .use([pluginB, pluginC]) * // Two plugins, the second with options: * .use([pluginD, [pluginE, {}]]) * // Preset with plugins and settings: * .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}}) * // Settings only: * .use({settings: {position: false}}) * ``` * * @template {Array} [Parameters=[]] * @template {Node | string | undefined} [Input=undefined] * @template [Output=Input] * * @overload * @param {Preset | null | undefined} [preset] * @returns {Processor} * * @overload * @param {PluggableList} list * @returns {Processor} * * @overload * @param {Plugin} plugin * @param {...(Parameters | [boolean])} parameters * @returns {UsePlugin} * * @param {PluggableList | Plugin | Preset | null | undefined} value * Usable value. * @param {...unknown} parameters * Parameters, when a plugin is given as a usable value. * @returns {Processor} * Current processor. */ use(preset?: Preset | null | undefined): Processor; /** * Configure the processor to use a plugin, a list of usable values, or a * preset. * * If the processor is already using a plugin, the previous plugin * configuration is changed based on the options that are passed in. * In other words, the plugin is not added a second time. * * > 👉 **Note**: `use` cannot be called on *frozen* processors. * > Call the processor first to create a new unfrozen processor. * * @example * There are many ways to pass plugins to `.use()`. * This example gives an overview: * * ```js * import {unified} from 'unified' * * unified() * // Plugin with options: * .use(pluginA, {x: true, y: true}) * // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`): * .use(pluginA, {y: false, z: true}) * // Plugins: * .use([pluginB, pluginC]) * // Two plugins, the second with options: * .use([pluginD, [pluginE, {}]]) * // Preset with plugins and settings: * .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}}) * // Settings only: * .use({settings: {position: false}}) * ``` * * @template {Array} [Parameters=[]] * @template {Node | string | undefined} [Input=undefined] * @template [Output=Input] * * @overload * @param {Preset | null | undefined} [preset] * @returns {Processor} * * @overload * @param {PluggableList} list * @returns {Processor} * * @overload * @param {Plugin} plugin * @param {...(Parameters | [boolean])} parameters * @returns {UsePlugin} * * @param {PluggableList | Plugin | Preset | null | undefined} value * Usable value. * @param {...unknown} parameters * Parameters, when a plugin is given as a usable value. * @returns {Processor} * Current processor. */ use(list: PluggableList): Processor; /** * Configure the processor to use a plugin, a list of usable values, or a * preset. * * If the processor is already using a plugin, the previous plugin * configuration is changed based on the options that are passed in. * In other words, the plugin is not added a second time. * * > 👉 **Note**: `use` cannot be called on *frozen* processors. * > Call the processor first to create a new unfrozen processor. * * @example * There are many ways to pass plugins to `.use()`. * This example gives an overview: * * ```js * import {unified} from 'unified' * * unified() * // Plugin with options: * .use(pluginA, {x: true, y: true}) * // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`): * .use(pluginA, {y: false, z: true}) * // Plugins: * .use([pluginB, pluginC]) * // Two plugins, the second with options: * .use([pluginD, [pluginE, {}]]) * // Preset with plugins and settings: * .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}}) * // Settings only: * .use({settings: {position: false}}) * ``` * * @template {Array} [Parameters=[]] * @template {Node | string | undefined} [Input=undefined] * @template [Output=Input] * * @overload * @param {Preset | null | undefined} [preset] * @returns {Processor} * * @overload * @param {PluggableList} list * @returns {Processor} * * @overload * @param {Plugin} plugin * @param {...(Parameters | [boolean])} parameters * @returns {UsePlugin} * * @param {PluggableList | Plugin | Preset | null | undefined} value * Usable value. * @param {...unknown} parameters * Parameters, when a plugin is given as a usable value. * @returns {Processor} * Current processor. */ use(plugin: Plugin, ...parameters: Parameters_2 | [boolean]): UsePlugin; } type Pipeline = Pipeline$1; type Node = unist.Node; type Compatible$1 = Compatible$2; type Value = Value$1; type CompileResultMap = CompileResultMap$1; type Data$1 = Data$2; type Settings$1 = Settings$2; /** * Acceptable results from compilers. * * To register custom results, add them to * {@link CompileResultMap `CompileResultMap`}. */ type CompileResults = CompileResultMap[keyof CompileResultMap]; /** * A **compiler** handles the compiling of a syntax tree to something else * (in most cases, text) (TypeScript type). * * It is used in the stringify phase and called with a {@link Node `Node`} * and {@link VFile `VFile`} representation of the document to compile. * It should return the textual representation of the given tree (typically * `string`). * * > 👉 **Note**: unified typically compiles by serializing: most compilers * > return `string` (or `Uint8Array`). * > Some compilers, such as the one configured with * > [`rehype-react`][rehype-react], return other values (in this case, a * > React tree). * > If you’re using a compiler that doesn’t serialize, expect different * > result values. * > * > To register custom results in TypeScript, add them to * > {@link CompileResultMap `CompileResultMap`}. * * [rehype-react]: https://github.com/rehypejs/rehype-react */ type Compiler = (tree: Tree, file: VFile$1) => Result; /** * A **parser** handles the parsing of text to a syntax tree. * * It is used in the parse phase and is called with a `string` and * {@link VFile `VFile`} of the document to parse. * It must return the syntax tree representation of the given file * ({@link Node `Node`}). */ type Parser = (document: string, file: VFile$1) => Tree; /** * Union of the different ways to add plugins and settings. */ type Pluggable = (Plugin, any, any> | PluginTuple, any, any> | Preset); /** * List of plugins and presets. */ type PluggableList = Array; /** * Single plugin. * * Plugins configure the processors they are applied on in the following * ways: * * * they change the processor, such as the parser, the compiler, or by * configuring data * * they specify how to handle trees and files * * In practice, they are functions that can receive options and configure the * processor (`this`). * * > 👉 **Note**: plugins are called when the processor is *frozen*, not when * > they are applied. */ type Plugin = (this: Processor, ...parameters: PluginParameters) => Input extends string ? Output extends Node | undefined ? undefined | void : never : Output extends CompileResults ? Input extends Node | undefined ? undefined | void : never : Transformer | undefined | void; /** * Tuple of a plugin and its configuration. * * The first item is a plugin, the rest are its parameters. */ type PluginTuple = ([ plugin: Plugin, ...parameters: TupleParameters ]); /** * Sharable configuration. * * They can contain plugins and settings. */ type Preset = { /** * List of plugins and presets (optional). */ plugins?: PluggableList | undefined; /** * Shared settings for parsers and compilers (optional). */ settings?: Settings$1 | undefined; }; /** * Callback called when the process is done. * * Called with either an error or a result. */ type ProcessCallback = (error?: Error | undefined, file?: File | undefined) => undefined; /** * Callback called when transformers are done. * * Called with either an error or results. */ type RunCallback = (error?: Error | undefined, tree?: Tree | undefined, file?: VFile$1 | undefined) => undefined; /** * Callback passed to transforms. * * If the signature of a `transformer` accepts a third argument, the * transformer may perform asynchronous operations, and must call it. */ type TransformCallback = (error?: Error | undefined, tree?: Output | undefined, file?: VFile$1 | undefined) => undefined; /** * Transformers handle syntax trees and files. * * They are functions that are called each time a syntax tree and file are * passed through the run phase. * When an error occurs in them (either because it’s thrown, returned, * rejected, or passed to `next`), the process stops. * * The run phase is handled by [`trough`][trough], see its documentation for * the exact semantics of these functions. * * > 👉 **Note**: you should likely ignore `next`: don’t accept it. * > it supports callback-style async work. * > But promises are likely easier to reason about. * * [trough]: https://github.com/wooorm/trough#function-fninput-next */ type Transformer = (tree: Input, file: VFile$1, next: TransformCallback) => (Promise | Promise | // For some reason this is needed separately. Output | Error | undefined | void); /** * Create a processor based on the input/output of a {@link Plugin plugin}. */ type UsePlugin = (Input extends string ? Output extends Node | undefined ? Processor : Processor : Output extends CompileResults ? Input extends Node | undefined ? Processor : Processor : Input extends Node | undefined ? Output extends Node | undefined ? Processor : Processor : Processor); /** * Type to generate a {@link VFile `VFile`} corresponding to a compiler result. * * If a result that is not acceptable on a `VFile` is used, that will * be stored on the `result` field of {@link VFile `VFile`}. */ type VFileWithOutput = (Result extends Value | undefined ? VFile$1 : VFile$1 & { result: Result; }); // See: declare const emptyObjectSymbol: unique symbol /** * Interface of known data that can be supported by all plugins. * * Typically, options can be given to a specific plugin, but sometimes it makes * sense to have information shared with several plugins. * For example, a list of HTML elements that are self-closing, which is needed * during all phases. * * To type this, do something like: * * ```ts * declare module 'unified' { * interface Data { * htmlVoidElements?: Array | undefined * } * } * * export {} // You may not need this, but it makes sure the file is a module. * ``` */ interface Data { settings?: Settings | undefined } /** * Interface of known extra options, that can be supported by parser and * compilers. * * This exists so that users can use packages such as `remark`, which configure * both parsers and compilers (in this case `remark-parse` and * `remark-stringify`), and still provide options for them. * * When you make parsers or compilers, that could be packaged up together, * you should support `this.data('settings')` as input and merge it with * explicitly passed `options`. * Then, to type it, using `remark-stringify` as an example, do something like: * * ```ts * declare module 'unified' { * interface Settings { * bullet: '*' | '+' | '-' * // … * } * } * * export {} // You may not need this, but it makes sure the file is a module. * ``` */ interface Settings { [emptyObjectSymbol]?: never } // Type definitions for source-map 0.7 // Project: https://github.com/mozilla/source-map // Definitions by: Morten Houston Ludvigsen , // Ron Buckton , // John Vilk // Definitions: https://github.com/mozilla/source-map type SourceMapUrl = string; interface StartOfSourceMap { file?: string; sourceRoot?: string; skipValidation?: boolean; } interface RawSourceMap { version: number; sources: string[]; names: string[]; sourceRoot?: string; sourcesContent?: string[]; mappings: string; file: string; } interface RawIndexMap extends StartOfSourceMap { version: number; sections: RawSection[]; } interface RawSection { offset: Position; map: RawSourceMap; } interface Position { line: number; column: number; } interface NullablePosition { line: number | null; column: number | null; lastColumn: number | null; } interface MappedPosition { source: string; line: number; column: number; name?: string; } interface NullableMappedPosition { source: string | null; line: number | null; column: number | null; name: string | null; } interface MappingItem { source: string; generatedLine: number; generatedColumn: number; originalLine: number; originalColumn: number; name: string; } interface Mapping { generated: Position; original: Position; source: string; name?: string; } interface SourceMapConsumerConstructor { prototype: SourceMapConsumer; GENERATED_ORDER: number; ORIGINAL_ORDER: number; GREATEST_LOWER_BOUND: number; LEAST_UPPER_BOUND: number; new (rawSourceMap: RawSourceMap, sourceMapUrl?: SourceMapUrl): Promise; new (rawSourceMap: RawIndexMap, sourceMapUrl?: SourceMapUrl): Promise; new (rawSourceMap: RawSourceMap | RawIndexMap | string, sourceMapUrl?: SourceMapUrl): Promise; /** * Create a BasicSourceMapConsumer from a SourceMapGenerator. * * @param sourceMap * The source map that will be consumed. */ fromSourceMap(sourceMap: SourceMapGenerator$1, sourceMapUrl?: SourceMapUrl): Promise; /** * Construct a new `SourceMapConsumer` from `rawSourceMap` and `sourceMapUrl` * (see the `SourceMapConsumer` constructor for details. Then, invoke the `async * function f(SourceMapConsumer) -> T` with the newly constructed consumer, wait * for `f` to complete, call `destroy` on the consumer, and return `f`'s return * value. * * You must not use the consumer after `f` completes! * * By using `with`, you do not have to remember to manually call `destroy` on * the consumer, since it will be called automatically once `f` completes. * * ```js * const xSquared = await SourceMapConsumer.with( * myRawSourceMap, * null, * async function (consumer) { * // Use `consumer` inside here and don't worry about remembering * // to call `destroy`. * * const x = await whatever(consumer); * return x * x; * } * ); * * // You may not use that `consumer` anymore out here; it has * // been destroyed. But you can use `xSquared`. * console.log(xSquared); * ``` */ with(rawSourceMap: RawSourceMap | RawIndexMap | string, sourceMapUrl: SourceMapUrl | null | undefined, callback: (consumer: BasicSourceMapConsumer | IndexedSourceMapConsumer) => Promise | T): Promise; } interface SourceMapConsumer { /** * Compute the last column for each generated mapping. The last column is * inclusive. */ computeColumnSpans(): void; /** * Returns the original source, line, and column information for the generated * source's line and column positions provided. The only argument is an object * with the following properties: * * - line: The line number in the generated source. * - column: The column number in the generated source. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the * closest element that is smaller than or greater than the one we are * searching for, respectively, if the exact element cannot be found. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'. * * and an object is returned with the following properties: * * - source: The original source file, or null. * - line: The line number in the original source, or null. * - column: The column number in the original source, or null. * - name: The original identifier, or null. */ originalPositionFor(generatedPosition: Position & { bias?: number }): NullableMappedPosition; /** * Returns the generated line and column information for the original source, * line, and column positions provided. The only argument is an object with * the following properties: * * - source: The filename of the original source. * - line: The line number in the original source. * - column: The column number in the original source. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the * closest element that is smaller than or greater than the one we are * searching for, respectively, if the exact element cannot be found. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'. * * and an object is returned with the following properties: * * - line: The line number in the generated source, or null. * - column: The column number in the generated source, or null. */ generatedPositionFor(originalPosition: MappedPosition & { bias?: number }): NullablePosition; /** * Returns all generated line and column information for the original source, * line, and column provided. If no column is provided, returns all mappings * corresponding to a either the line we are searching for or the next * closest line that has any mappings. Otherwise, returns all mappings * corresponding to the given line and either the column we are searching for * or the next closest column that has any offsets. * * The only argument is an object with the following properties: * * - source: The filename of the original source. * - line: The line number in the original source. * - column: Optional. the column number in the original source. * * and an array of objects is returned, each with the following properties: * * - line: The line number in the generated source, or null. * - column: The column number in the generated source, or null. */ allGeneratedPositionsFor(originalPosition: MappedPosition): NullablePosition[]; /** * Return true if we have the source content for every source in the source * map, false otherwise. */ hasContentsOfAllSources(): boolean; /** * Returns the original source content. The only argument is the url of the * original source file. Returns null if no original source content is * available. */ sourceContentFor(source: string, returnNullOnMissing?: boolean): string | null; /** * Iterate over each mapping between an original source/line/column and a * generated line/column in this source map. * * @param callback * The function that is called with each mapping. * @param context * Optional. If specified, this object will be the value of `this` every * time that `aCallback` is called. * @param order * Either `SourceMapConsumer.GENERATED_ORDER` or * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to * iterate over the mappings sorted by the generated file's line/column * order or the original's source/line/column order, respectively. Defaults to * `SourceMapConsumer.GENERATED_ORDER`. */ eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void; /** * Free this source map consumer's associated wasm data that is manually-managed. * Alternatively, you can use SourceMapConsumer.with to avoid needing to remember to call destroy. */ destroy(): void; } declare const SourceMapConsumer: SourceMapConsumerConstructor; interface BasicSourceMapConsumerConstructor { prototype: BasicSourceMapConsumer; new (rawSourceMap: RawSourceMap | string): Promise; /** * Create a BasicSourceMapConsumer from a SourceMapGenerator. * * @param sourceMap * The source map that will be consumed. */ fromSourceMap(sourceMap: SourceMapGenerator$1): Promise; } interface BasicSourceMapConsumer extends SourceMapConsumer { file: string; sourceRoot: string; sources: string[]; sourcesContent: string[]; } declare const BasicSourceMapConsumer: BasicSourceMapConsumerConstructor; interface IndexedSourceMapConsumerConstructor { prototype: IndexedSourceMapConsumer; new (rawSourceMap: RawIndexMap | string): Promise; } interface IndexedSourceMapConsumer extends SourceMapConsumer { sources: string[]; } declare const IndexedSourceMapConsumer: IndexedSourceMapConsumerConstructor; declare class SourceMapGenerator$1 { constructor(startOfSourceMap?: StartOfSourceMap); /** * Creates a new SourceMapGenerator based on a SourceMapConsumer * * @param sourceMapConsumer The SourceMap. */ static fromSourceMap(sourceMapConsumer: SourceMapConsumer): SourceMapGenerator$1; /** * Add a single mapping from original source line and column to the generated * source's line and column for this source map being created. The mapping * object should have the following properties: * * - generated: An object with the generated line and column positions. * - original: An object with the original line and column positions. * - source: The original source file (relative to the sourceRoot). * - name: An optional original token name for this mapping. */ addMapping(mapping: Mapping): void; /** * Set the source content for a source file. */ setSourceContent(sourceFile: string, sourceContent: string): void; /** * Applies the mappings of a sub-source-map for a specific source file to the * source map being generated. Each mapping to the supplied source file is * rewritten using the supplied source map. Note: The resolution for the * resulting mappings is the minimium of this map and the supplied map. * * @param sourceMapConsumer The source map to be applied. * @param sourceFile Optional. The filename of the source file. * If omitted, SourceMapConsumer's file property will be used. * @param sourceMapPath Optional. The dirname of the path to the source map * to be applied. If relative, it is relative to the SourceMapConsumer. * This parameter is needed when the two source maps aren't in the same * directory, and the source map to be applied contains relative source * paths. If so, those relative source paths need to be rewritten * relative to the SourceMapGenerator. */ applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void; toString(): string; toJSON(): RawSourceMap; } type HastElementContent = hast.ElementContent; type HastNodes = hast.Nodes; type HastProperties = hast.Properties; type MdastDefinition = mdast.Definition; type MdastFootnoteDefinition = mdast.FootnoteDefinition; type MdastNodes = mdast.Nodes; type MdastParents = mdast.Parents; type FootnoteBackContentTemplate$1 = FootnoteBackContentTemplate; type FootnoteBackLabelTemplate$1 = FootnoteBackLabelTemplate; /** * Handle a node. */ type Handler = (state: State$1, node: any, parent: MdastParents | undefined) => Array | HastElementContent | undefined; /** * Handle nodes. */ type Handlers = Partial>; /** * Configuration (optional). */ type Options$2 = { /** * Whether to persist raw HTML in markdown in the hast tree (default: * `false`). */ allowDangerousHtml?: boolean | null | undefined; /** * Prefix to use before the `id` property on footnotes to prevent them from * *clobbering* (default: `'user-content-'`). * * Pass `''` for trusted markdown and when you are careful with * polyfilling. * You could pass a different prefix. * * DOM clobbering is this: * * ```html *

* * ``` * * The above example shows that elements are made available by browsers, by * their ID, on the `window` object. * This is a security risk because you might be expecting some other variable * at that place. * It can also break polyfills. * Using a prefix solves these problems. */ clobberPrefix?: string | null | undefined; /** * Content of the backreference back to references (default: `defaultFootnoteBackContent`). * * The default value is: * * ```js * function defaultFootnoteBackContent(_, rereferenceIndex) { * const result = [{type: 'text', value: '↩'}] * * if (rereferenceIndex > 1) { * result.push({ * type: 'element', * tagName: 'sup', * properties: {}, * children: [{type: 'text', value: String(rereferenceIndex)}] * }) * } * * return result * } * ``` * * This content is used in the `a` element of each backreference (the `↩` * links). */ footnoteBackContent?: FootnoteBackContentTemplate$1 | string | null | undefined; /** * Label to describe the backreference back to references (default: * `defaultFootnoteBackLabel`). * * The default value is: * * ```js * function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) { * return ( * 'Back to reference ' + * (referenceIndex + 1) + * (rereferenceIndex > 1 ? '-' + rereferenceIndex : '') * ) * } * ``` * * Change it when the markdown is not in English. * * This label is used in the `ariaLabel` property on each backreference * (the `↩` links). * It affects users of assistive technology. */ footnoteBackLabel?: FootnoteBackLabelTemplate$1 | string | null | undefined; /** * Textual label to use for the footnotes section (default: `'Footnotes'`). * * Change it when the markdown is not in English. * * This label is typically hidden visually (assuming a `sr-only` CSS class * is defined that does that) and so affects screen readers only. * If you do have such a class, but want to show this section to everyone, * pass different properties with the `footnoteLabelProperties` option. */ footnoteLabel?: string | null | undefined; /** * Properties to use on the footnote label (default: `{className: * ['sr-only']}`). * * Change it to show the label and add other properties. * * This label is typically hidden visually (assuming an `sr-only` CSS class * is defined that does that) and so affects screen readers only. * If you do have such a class, but want to show this section to everyone, * pass an empty string. * You can also add different properties. * * > 👉 **Note**: `id: 'footnote-label'` is always added, because footnote * > calls use it with `aria-describedby` to provide an accessible label. */ footnoteLabelProperties?: HastProperties | null | undefined; /** * HTML tag name to use for the footnote label element (default: `'h2'`). * * Change it to match your document structure. * * This label is typically hidden visually (assuming a `sr-only` CSS class * is defined that does that) and so affects screen readers only. * If you do have such a class, but want to show this section to everyone, * pass different properties with the `footnoteLabelProperties` option. */ footnoteLabelTagName?: string | null | undefined; /** * Extra handlers for nodes (optional). */ handlers?: Handlers | null | undefined; /** * List of custom mdast node types to pass through (keep) in hast (note that * the node itself is passed, but eventual children are transformed) * (optional). */ passThrough?: Array | null | undefined; /** * Handler for all unknown nodes (optional). */ unknownHandler?: Handler | null | undefined; }; /** * Info passed around. */ type State$1 = { /** * Transform the children of an mdast parent to hast. */ all: (node: MdastNodes) => Array; /** * Honor the `data` of `from`, and generate an element instead of `node`. */ applyData: (from: MdastNodes, to: Type) => hast.Element | Type; /** * Definitions by their identifier. */ definitionById: Map; /** * Footnote definitions by their identifier. */ footnoteById: Map; /** * Counts for how often the same footnote was called. */ footnoteCounts: Map; /** * Identifiers of order when footnote calls first appear in tree order. */ footnoteOrder: Array; /** * Applied handlers. */ handlers: Handlers; /** * Transform an mdast node to hast. */ one: (node: MdastNodes, parent: MdastParents | undefined) => Array | HastElementContent | undefined; /** * Configuration. */ options: Options$2; /** * Copy a node’s positional info. */ patch: (from: MdastNodes, node: HastNodes) => undefined; /** * Wrap `nodes` with line endings between each node, adds initial/final line endings when `loose`. */ wrap: (nodes: Type_1[], loose?: boolean | undefined) => (hast.Text | Type_1)[]; }; type ElementContent = hast.ElementContent; /** * Generate content for the backreference dynamically. * * For the following markdown: * * ```markdown * Alpha[^micromark], bravo[^micromark], and charlie[^remark]. * * [^remark]: things about remark * [^micromark]: things about micromark * ``` * * This function will be called with: * * * `0` and `0` for the backreference from `things about micromark` to * `alpha`, as it is the first used definition, and the first call to it * * `0` and `1` for the backreference from `things about micromark` to * `bravo`, as it is the first used definition, and the second call to it * * `1` and `0` for the backreference from `things about remark` to * `charlie`, as it is the second used definition */ type FootnoteBackContentTemplate = (referenceIndex: number, rereferenceIndex: number) => Array | ElementContent | string; /** * Generate a back label dynamically. * * For the following markdown: * * ```markdown * Alpha[^micromark], bravo[^micromark], and charlie[^remark]. * * [^remark]: things about remark * [^micromark]: things about micromark * ``` * * This function will be called with: * * * `0` and `0` for the backreference from `things about micromark` to * `alpha`, as it is the first used definition, and the first call to it * * `0` and `1` for the backreference from `things about micromark` to * `bravo`, as it is the first used definition, and the second call to it * * `1` and `0` for the backreference from `things about remark` to * `charlie`, as it is the second used definition */ type FootnoteBackLabelTemplate = (referenceIndex: number, rereferenceIndex: number) => string; /** * Raw string of HTML embedded into HTML AST. */ interface Raw$1 extends Literal { /** * Node type of raw. */ type: 'raw' /** * Data associated with the hast raw. */ data?: RawData$1 | undefined } /** * Info associated with hast raw nodes by the ecosystem. */ interface RawData$1 extends Data$4 {} // Register nodes in content. declare module 'hast' { interface ElementContentMap { /** * Raw string of HTML embedded into HTML AST. */ raw: Raw$1 } interface RootContentMap { /** * Raw string of HTML embedded into HTML AST. */ raw: Raw$1 } } // Register data on mdast. declare module 'mdast' { interface Data { /** * Field supported by `mdast-util-to-hast` to signal that a node should * result in something with these children. * * When this is defined, when a parent is created, these children will * be used. */ hChildren?: ElementContent$1[] | undefined /** * Field supported by `mdast-util-to-hast` to signal that a node should * result in a particular element, instead of its default behavior. * * When this is defined, an element with the given tag name is created. * For example, when setting `hName` to `'b'`, a `` element is created. */ hName?: string | undefined /** * Field supported by `mdast-util-to-hast` to signal that a node should * result in an element with these properties. * * When this is defined, when an element is created, these properties will * be used. */ hProperties?: Properties | undefined } } /** * Raw string of HTML embedded into HTML AST. */ interface Raw extends Literal { /** * Node type of raw. */ type: 'raw' /** * Data associated with the hast raw. */ data?: RawData | undefined } /** * Info associated with hast raw nodes by the ecosystem. */ interface RawData extends Data$4 {} // Register nodes in content. declare module 'hast' { interface ElementContentMap { /** * Raw string of HTML embedded into HTML AST. */ raw: Raw } interface RootContentMap { /** * Raw string of HTML embedded into HTML AST. */ raw: Raw } } // Register data on mdast. declare module 'mdast' { interface Data { /** * Field supported by `mdast-util-to-hast` to signal that a node should * result in something with these children. * * When this is defined, when a parent is created, these children will * be used. */ hChildren?: ElementContent$1[] | undefined /** * Field supported by `mdast-util-to-hast` to signal that a node should * result in a particular element, instead of its default behavior. * * When this is defined, an element with the given tag name is created. * For example, when setting `hName` to `'b'`, a `` element is created. */ hName?: string | undefined /** * Field supported by `mdast-util-to-hast` to signal that a node should * result in an element with these properties. * * When this is defined, when an element is created, these properties will * be used. */ hProperties?: Properties | undefined } } type Options$1 = Options$2; type Options = Options$1; // Expose node types. /** * MDX JSX attribute value set to an expression. * * ```markdown * > | * ^^^ * ``` */ interface MdxJsxAttributeValueExpression$1 extends Node$2 { /** * Node type. */ type: 'mdxJsxAttributeValueExpression' /** * Value. */ value: string /** * Data associated with the mdast MDX JSX attribute value expression. */ data?: MdxJsxAttributeValueExpressionData$1 | undefined } /** * Info associated with mdast MDX JSX attribute value expression nodes by the * ecosystem. */ interface MdxJsxAttributeValueExpressionData$1 extends Data$6 { /** * Program node from estree. */ estree?: Program | null | undefined } /** * MDX JSX attribute as an expression. * * ```markdown * > | * ^^^^^^ * ``` */ interface MdxJsxExpressionAttribute$2 extends Node$2 { /** * Node type. */ type: 'mdxJsxExpressionAttribute' /** * Value. */ value: string /** * Data associated with the mdast MDX JSX expression attributes. */ data?: MdxJsxExpressionAttributeData$1 | undefined } /** * Info associated with mdast MDX JSX expression attribute nodes by the * ecosystem. */ interface MdxJsxExpressionAttributeData$1 extends Data$6 { /** * Program node from estree. */ estree?: Program | null | undefined } /** * MDX JSX attribute with a key. * * ```markdown * > | * ^^^^^ * ``` */ interface MdxJsxAttribute$2 extends Node$2 { /** * Node type. */ type: 'mdxJsxAttribute' /** * Attribute name. */ name: string /** * Attribute value. */ value?: MdxJsxAttributeValueExpression$1 | string | null | undefined /** * Data associated with the mdast MDX JSX attribute. */ data?: MdxJsxAttributeData$1 | undefined } /** * Info associated with mdast MDX JSX attribute nodes by the * ecosystem. */ interface MdxJsxAttributeData$1 extends Data$6 {} /** * MDX JSX element node, occurring in flow (block). */ interface MdxJsxFlowElement$1 extends Parent { /** * Node type. */ type: 'mdxJsxFlowElement' /** * MDX JSX element name (`null` for fragments). */ name: string | null /** * MDX JSX element attributes. */ attributes: Array /** * Content. */ children: Array /** * Data associated with the mdast MDX JSX elements (flow). */ data?: MdxJsxFlowElementData$1 | undefined } /** * Info associated with mdast MDX JSX element (flow) nodes by the * ecosystem. */ interface MdxJsxFlowElementData$1 extends Data$5 {} /** * MDX JSX element node, occurring in text (phrasing). */ interface MdxJsxTextElement$1 extends Parent { /** * Node type. */ type: 'mdxJsxTextElement' /** * MDX JSX element name (`null` for fragments). */ name: string | null /** * MDX JSX element attributes. */ attributes: Array /** * Content. */ children: PhrasingContent[] /** * Data associated with the mdast MDX JSX elements (text). */ data?: MdxJsxTextElementData$1 | undefined } /** * Info associated with mdast MDX JSX element (text) nodes by the * ecosystem. */ interface MdxJsxTextElementData$1 extends Data$5 {} /** * MDX JSX element node, occurring in flow (block), for hast. */ interface MdxJsxFlowElementHast$1 extends Parent$1 { /** * Node type. */ type: 'mdxJsxFlowElement' /** * MDX JSX element name (`null` for fragments). */ name: string | null /** * MDX JSX element attributes. */ attributes: Array /** * Content. */ children: ElementContent$1[] /** * Data associated with the hast MDX JSX elements (flow). */ data?: MdxJsxFlowElementHastData$1 | undefined } /** * Info associated with hast MDX JSX element (flow) nodes by the * ecosystem. */ interface MdxJsxFlowElementHastData$1 extends Data$4 {} /** * MDX JSX element node, occurring in text (phrasing), for hast. */ interface MdxJsxTextElementHast$1 extends Parent$1 { /** * Node type. */ type: 'mdxJsxTextElement' /** * MDX JSX element name (`null` for fragments). */ name: string | null /** * MDX JSX element attributes. */ attributes: Array /** * Content. */ children: ElementContent$1[] /** * Data associated with the hast MDX JSX elements (text). */ data?: MdxJsxTextElementHastData$1 | undefined } /** * Info associated with hast MDX JSX element (text) nodes by the * ecosystem. */ interface MdxJsxTextElementHastData$1 extends Data$4 {} // Add nodes to mdast content. declare module 'mdast' { interface BlockContentMap { /** * MDX JSX element node, occurring in flow (block). */ mdxJsxFlowElement: MdxJsxFlowElement$1 } interface PhrasingContentMap { /** * MDX JSX element node, occurring in text (phrasing). */ mdxJsxTextElement: MdxJsxTextElement$1 } interface RootContentMap { /** * MDX JSX element node, occurring in flow (block). */ mdxJsxFlowElement: MdxJsxFlowElement$1 /** * MDX JSX element node, occurring in text (phrasing). */ mdxJsxTextElement: MdxJsxTextElement$1 } } // Add nodes to hast content. declare module 'hast' { interface ElementContentMap { /** * MDX JSX element node, occurring in text (phrasing). */ mdxJsxTextElement: MdxJsxTextElementHast$1 /** * MDX JSX element node, occurring in flow (block). */ mdxJsxFlowElement: MdxJsxFlowElementHast$1 } interface RootContentMap { /** * MDX JSX element node, occurring in text (phrasing). */ mdxJsxTextElement: MdxJsxTextElementHast$1 /** * MDX JSX element node, occurring in flow (block). */ mdxJsxFlowElement: MdxJsxFlowElementHast$1 } } // Add custom data tracked to turn markdown into a tree. declare module 'mdast-util-from-markdown' { interface CompileData { /** * Current MDX JSX tag. */ mdxJsxTag?: Tag | undefined /** * Current stack of open MDX JSX tags. */ mdxJsxTagStack?: Tag[] | undefined } } // Add custom data tracked to turn a syntax tree into markdown. declare module 'mdast-util-to-markdown' { interface ConstructNameMap { /** * Whole JSX element, in flow. * * ```markdown * > | * ^^^^^ * ``` */ mdxJsxFlowElement: 'mdxJsxFlowElement' /** * Whole JSX element, in text. * * ```markdown * > | a . * ^^^^^ * ``` */ mdxJsxTextElement: 'mdxJsxTextElement' } } declare module 'micromark-util-types' { interface TokenTypeMap { listItem: 'listItem' } interface Token { _spread?: boolean } } // Note: this file is authored manually, not generated from `index.js`. /** * A character code. * * This is often the same as what `String#charCodeAt()` yields but micromark * adds meaning to certain other values. * * `null` represents the end of the input stream (called eof). * Negative integers are used instead of certain sequences of characters (such * as line endings and tabs). */ type Code = number | null /** * A chunk is either a character code or a slice of a buffer in the form of a * string. * * Chunks are used because strings are more efficient storage that character * codes, but limited in what they can represent. */ type Chunk = Code | string /** * Enumeration of the content types. * * Technically `document` is also a content type, which includes containers * (lists, block quotes) and flow. * As `ContentType` is used on tokens to define the type of subcontent but * `document` is the highest level of content, so it’s not listed here. * * Containers in markdown come from the margin and include more constructs * on the lines that define them. * Take for example a block quote with a paragraph inside it (such as * `> asd`). * * `flow` represents the sections, such as headings, code, and content, which * is also parsed per line * An example is HTML, which has a certain starting condition (such as * `