unified
Advanced tools
Comparing version 11.0.2 to 11.0.3
@@ -118,5 +118,241 @@ import {CallableInstance} from './callable-instance.js' | ||
copy(): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>; | ||
/** | ||
* 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<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @overload | ||
* @param {Key} key | ||
* @returns {Data[Key]} | ||
* | ||
* @overload | ||
* @param {Key} key | ||
* @param {Data[Key]} value | ||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @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 extends keyof import("unified").Data>(): Data; | ||
/** | ||
* 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<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @overload | ||
* @param {Key} key | ||
* @returns {Data[Key]} | ||
* | ||
* @overload | ||
* @param {Key} key | ||
* @param {Data[Key]} value | ||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @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 extends keyof import("unified").Data>(dataset: Data): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>; | ||
/** | ||
* 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<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @overload | ||
* @param {Key} key | ||
* @returns {Data[Key]} | ||
* | ||
* @overload | ||
* @param {Key} key | ||
* @param {Data[Key]} value | ||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @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 extends keyof import("unified").Data>(key: Key): import("unified").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<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @overload | ||
* @param {Key} key | ||
* @returns {Data[Key]} | ||
* | ||
* @overload | ||
* @param {Key} key | ||
* @param {Data[Key]} value | ||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @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 extends keyof import("unified").Data>(key: Key, value: import("unified").Data[Key]): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>; | ||
@@ -156,3 +392,87 @@ /** | ||
parse(file?: Compatible | 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<VFileWithOutput<CompileResult>>} done | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {Compatible | undefined} [file] | ||
* @returns {Promise<VFileWithOutput<CompileResult>>} | ||
* | ||
* @param {Compatible | undefined} [file] | ||
* File (optional); typically `string` or `VFile`]; any value accepted as | ||
* `x` in `new VFile(x)`. | ||
* @param {ProcessCallback<VFileWithOutput<CompileResult>> | undefined} [done] | ||
* Callback (optional). | ||
* @returns {Promise<VFile> | 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 | undefined, done: ProcessCallback<VFileWithOutput<CompileResult>>): 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<VFileWithOutput<CompileResult>>} done | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {Compatible | undefined} [file] | ||
* @returns {Promise<VFileWithOutput<CompileResult>>} | ||
* | ||
* @param {Compatible | undefined} [file] | ||
* File (optional); typically `string` or `VFile`]; any value accepted as | ||
* `x` in `new VFile(x)`. | ||
* @param {ProcessCallback<VFileWithOutput<CompileResult>> | undefined} [done] | ||
* Callback (optional). | ||
* @returns {Promise<VFile> | 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 | undefined): Promise<VFileWithOutput<CompileResult>>; | ||
@@ -191,4 +511,118 @@ /** | ||
processSync(file?: Compatible | undefined): VFileWithOutput<CompileResult>; | ||
/** | ||
* 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<TailTree extends undefined ? Node : TailTree>} done | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {HeadTree extends undefined ? Node : HeadTree} tree | ||
* @param {Compatible | undefined} file | ||
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {HeadTree extends undefined ? Node : HeadTree} tree | ||
* @param {Compatible | undefined} [file] | ||
* @returns {Promise<TailTree extends undefined ? Node : TailTree>} | ||
* | ||
* @param {HeadTree extends undefined ? Node : HeadTree} tree | ||
* Tree to transform and inspect. | ||
* @param {( | ||
* RunCallback<TailTree extends undefined ? Node : TailTree> | | ||
* Compatible | ||
* )} [file] | ||
* File associated with `node` (optional); any value accepted as `x` in | ||
* `new VFile(x)`. | ||
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done] | ||
* Callback (optional). | ||
* @returns {Promise<TailTree extends undefined ? Node : TailTree> | 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<TailTree extends undefined ? Node : TailTree>): 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<TailTree extends undefined ? Node : TailTree>} done | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {HeadTree extends undefined ? Node : HeadTree} tree | ||
* @param {Compatible | undefined} file | ||
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {HeadTree extends undefined ? Node : HeadTree} tree | ||
* @param {Compatible | undefined} [file] | ||
* @returns {Promise<TailTree extends undefined ? Node : TailTree>} | ||
* | ||
* @param {HeadTree extends undefined ? Node : HeadTree} tree | ||
* Tree to transform and inspect. | ||
* @param {( | ||
* RunCallback<TailTree extends undefined ? Node : TailTree> | | ||
* Compatible | ||
* )} [file] | ||
* File associated with `node` (optional); any value accepted as `x` in | ||
* `new VFile(x)`. | ||
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done] | ||
* Callback (optional). | ||
* @returns {Promise<TailTree extends undefined ? Node : TailTree> | 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 | undefined, done: RunCallback<TailTree extends undefined ? Node : TailTree>): 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<TailTree extends undefined ? Node : TailTree>} done | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {HeadTree extends undefined ? Node : HeadTree} tree | ||
* @param {Compatible | undefined} file | ||
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {HeadTree extends undefined ? Node : HeadTree} tree | ||
* @param {Compatible | undefined} [file] | ||
* @returns {Promise<TailTree extends undefined ? Node : TailTree>} | ||
* | ||
* @param {HeadTree extends undefined ? Node : HeadTree} tree | ||
* Tree to transform and inspect. | ||
* @param {( | ||
* RunCallback<TailTree extends undefined ? Node : TailTree> | | ||
* Compatible | ||
* )} [file] | ||
* File associated with `node` (optional); any value accepted as `x` in | ||
* `new VFile(x)`. | ||
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done] | ||
* Callback (optional). | ||
* @returns {Promise<TailTree extends undefined ? Node : TailTree> | 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 | undefined): Promise<TailTree extends undefined ? Node : TailTree>; | ||
@@ -243,4 +677,175 @@ /** | ||
stringify(tree: CompileTree extends undefined ? Node : CompileTree, file?: Compatible | 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<unknown>} [Parameters=[]] | ||
* @template {Node | string | undefined} [Input=undefined] | ||
* @template [Output=Input] | ||
* | ||
* @overload | ||
* @param {Preset | null | undefined} [preset] | ||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @overload | ||
* @param {PluggableList} list | ||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @overload | ||
* @param {Plugin<Parameters, Input, Output>} plugin | ||
* @param {...(Parameters | [boolean])} parameters | ||
* @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>} | ||
* | ||
* @param {PluggableList | Plugin | Preset | null | undefined} value | ||
* Usable value. | ||
* @param {...unknown} parameters | ||
* Parameters, when a plugin is given as a usable value. | ||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* Current processor. | ||
*/ | ||
use<Parameters_2 extends unknown[] = [], Input extends string | import("unist").Node | undefined = undefined, Output = Input>(preset?: Preset | null | undefined): Processor<ParseTree, HeadTree, TailTree, CompileTree, 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<unknown>} [Parameters=[]] | ||
* @template {Node | string | undefined} [Input=undefined] | ||
* @template [Output=Input] | ||
* | ||
* @overload | ||
* @param {Preset | null | undefined} [preset] | ||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @overload | ||
* @param {PluggableList} list | ||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @overload | ||
* @param {Plugin<Parameters, Input, Output>} plugin | ||
* @param {...(Parameters | [boolean])} parameters | ||
* @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>} | ||
* | ||
* @param {PluggableList | Plugin | Preset | null | undefined} value | ||
* Usable value. | ||
* @param {...unknown} parameters | ||
* Parameters, when a plugin is given as a usable value. | ||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* Current processor. | ||
*/ | ||
use<Parameters_2 extends unknown[] = [], Input extends string | import("unist").Node | undefined = undefined, Output = Input>(list: PluggableList): Processor<ParseTree, HeadTree, TailTree, CompileTree, 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<unknown>} [Parameters=[]] | ||
* @template {Node | string | undefined} [Input=undefined] | ||
* @template [Output=Input] | ||
* | ||
* @overload | ||
* @param {Preset | null | undefined} [preset] | ||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @overload | ||
* @param {PluggableList} list | ||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* | ||
* @overload | ||
* @param {Plugin<Parameters, Input, Output>} plugin | ||
* @param {...(Parameters | [boolean])} parameters | ||
* @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>} | ||
* | ||
* @param {PluggableList | Plugin | Preset | null | undefined} value | ||
* Usable value. | ||
* @param {...unknown} parameters | ||
* Parameters, when a plugin is given as a usable value. | ||
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} | ||
* Current processor. | ||
*/ | ||
use<Parameters_2 extends unknown[] = [], Input extends string | import("unist").Node | undefined = undefined, Output = Input>(plugin: Plugin<Parameters_2, Input, Output>, ...parameters: Parameters_2 | [boolean]): UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>; | ||
@@ -247,0 +852,0 @@ } |
@@ -349,4 +349,4 @@ /** | ||
import structuredClone from '@ungap/structured-clone' | ||
import {bail} from 'bail' | ||
import extend from 'extend' | ||
import {ok as assert} from 'devlop' | ||
@@ -511,3 +511,3 @@ import isPlainObj from 'is-plain-obj' | ||
destination.data(structuredClone(this.namespace)) | ||
destination.data(extend(true, {}, this.namespace)) | ||
@@ -1120,6 +1120,3 @@ return destination | ||
if (result.settings) { | ||
namespace.settings = { | ||
...namespace.settings, | ||
...structuredClone(result.settings) | ||
} | ||
namespace.settings = extend(true, namespace.settings, result.settings) | ||
} | ||
@@ -1172,3 +1169,3 @@ } | ||
if (isPlainObj(currentPrimary) && isPlainObj(primary)) { | ||
primary = structuredClone({...currentPrimary, ...primary}) | ||
primary = extend(true, currentPrimary, primary) | ||
} | ||
@@ -1175,0 +1172,0 @@ |
{ | ||
"name": "unified", | ||
"version": "11.0.2", | ||
"version": "11.0.3", | ||
"description": "parse, inspect, transform, and serialize content through syntax trees", | ||
@@ -49,5 +49,5 @@ "license": "MIT", | ||
"@types/unist": "^3.0.0", | ||
"@ungap/structured-clone": "^1.0.0", | ||
"bail": "^2.0.0", | ||
"devlop": "^1.0.0", | ||
"extend": "^3.0.0", | ||
"is-plain-obj": "^4.0.0", | ||
@@ -58,6 +58,6 @@ "trough": "^2.0.0", | ||
"devDependencies": { | ||
"@types/extend": "^3.0.0", | ||
"@types/hast": "^3.0.0", | ||
"@types/mdast": "^4.0.0", | ||
"@types/node": "^20.0.0", | ||
"@types/ungap__structured-clone": "^0.3.0", | ||
"c8": "^8.0.0", | ||
@@ -67,3 +67,3 @@ "prettier": "^3.0.0", | ||
"remark-preset-wooorm": "^9.0.0", | ||
"tsd": "^0.28.0", | ||
"tsd": "^0.29.0", | ||
"type-coverage": "^2.0.0", | ||
@@ -70,0 +70,0 @@ "typescript": "^5.0.0", |
@@ -1669,3 +1669,3 @@ # [![unified][logo]][site] | ||
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=unified | ||
[size-badge]: https://img.shields.io/bundlejs/size/unified | ||
@@ -1672,0 +1672,0 @@ [size]: https://bundlejs.com/?q=unified |
141014
2394
+ Addedextend@^3.0.0
+ Addedextend@3.0.2(transitive)
- Removed@ungap/structured-clone@^1.0.0
- Removed@ungap/structured-clone@1.2.0(transitive)