@sanity/agent-directives 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-dts/index.d.ts +22 -4
- package/dist/_chunks-dts/index.d.ts.map +1 -1
- package/dist/_chunks-es/formatters.js +75 -0
- package/dist/_chunks-es/formatters.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -50
- package/dist/index.js.map +1 -1
- package/dist/lib/formatters.d.ts +2 -2
- package/dist/lib/formatters.js +2 -1
- package/dist/lib/react.d.ts +4 -1075
- package/dist/lib/react.d.ts.map +1 -1
- package/dist/lib/react.js +4 -3
- package/dist/lib/react.js.map +1 -1
- package/dist/lib/{string.d.ts → server.d.ts} +36 -2
- package/dist/lib/server.d.ts.map +1 -0
- package/dist/lib/{string.js → server.js} +28 -8
- package/dist/lib/server.js.map +1 -0
- package/dist/lib/streaming.d.ts +139 -0
- package/dist/lib/streaming.d.ts.map +1 -0
- package/dist/lib/streaming.js +185 -0
- package/dist/lib/streaming.js.map +1 -0
- package/package.json +12 -6
- package/dist/lib/string.d.ts.map +0 -1
- package/dist/lib/string.js.map +0 -1
package/dist/lib/react.d.ts
CHANGED
|
@@ -1,1087 +1,16 @@
|
|
|
1
1
|
import { a as DirectiveName, i as DefineDirectiveOptions, o as DirectivePropsMap } from "../_chunks-dts/index.js";
|
|
2
2
|
import { ComponentType, ReactNode } from "react";
|
|
3
|
-
import
|
|
4
|
-
import { VFile } from "vfile";
|
|
5
|
-
import * as unist26 from "unist";
|
|
3
|
+
import { Processor } from "unified";
|
|
6
4
|
import { Node } from "unist";
|
|
7
|
-
import * as trough0 from "trough";
|
|
8
|
-
declare const CallableInstance: new <Parameters extends unknown[], Result>(property: string | symbol) => (...parameters: Parameters) => Result;
|
|
9
|
-
/**
|
|
10
|
-
* @template {Node | undefined} [ParseTree=undefined]
|
|
11
|
-
* Output of `parse` (optional).
|
|
12
|
-
* @template {Node | undefined} [HeadTree=undefined]
|
|
13
|
-
* Input for `run` (optional).
|
|
14
|
-
* @template {Node | undefined} [TailTree=undefined]
|
|
15
|
-
* Output for `run` (optional).
|
|
16
|
-
* @template {Node | undefined} [CompileTree=undefined]
|
|
17
|
-
* Input of `stringify` (optional).
|
|
18
|
-
* @template {CompileResults | undefined} [CompileResult=undefined]
|
|
19
|
-
* Output of `stringify` (optional).
|
|
20
|
-
* @extends {CallableInstance<[], Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>>}
|
|
21
|
-
*/
|
|
22
|
-
declare class Processor<ParseTree extends unist26.Node | undefined = undefined, HeadTree extends unist26.Node | undefined = undefined, TailTree extends unist26.Node | undefined = undefined, CompileTree extends unist26.Node | undefined = undefined, CompileResult extends CompileResults | undefined = undefined> extends CallableInstance<[], Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>> {
|
|
23
|
-
/**
|
|
24
|
-
* Create a processor.
|
|
25
|
-
*/
|
|
26
|
-
constructor();
|
|
27
|
-
/**
|
|
28
|
-
* Compiler to use (deprecated).
|
|
29
|
-
*
|
|
30
|
-
* @deprecated
|
|
31
|
-
* Use `compiler` instead.
|
|
32
|
-
* @type {(
|
|
33
|
-
* Compiler<
|
|
34
|
-
* CompileTree extends undefined ? Node : CompileTree,
|
|
35
|
-
* CompileResult extends undefined ? CompileResults : CompileResult
|
|
36
|
-
* > |
|
|
37
|
-
* undefined
|
|
38
|
-
* )}
|
|
39
|
-
*/
|
|
40
|
-
Compiler: (Compiler<CompileTree extends undefined ? Node$1 : CompileTree, CompileResult extends undefined ? CompileResults : CompileResult> | undefined);
|
|
41
|
-
/**
|
|
42
|
-
* Parser to use (deprecated).
|
|
43
|
-
*
|
|
44
|
-
* @deprecated
|
|
45
|
-
* Use `parser` instead.
|
|
46
|
-
* @type {(
|
|
47
|
-
* Parser<ParseTree extends undefined ? Node : ParseTree> |
|
|
48
|
-
* undefined
|
|
49
|
-
* )}
|
|
50
|
-
*/
|
|
51
|
-
Parser: (Parser<ParseTree extends undefined ? Node$1 : ParseTree> | undefined);
|
|
52
|
-
/**
|
|
53
|
-
* Internal list of configured plugins.
|
|
54
|
-
*
|
|
55
|
-
* @deprecated
|
|
56
|
-
* This is a private internal property and should not be used.
|
|
57
|
-
* @type {Array<PluginTuple<Array<unknown>>>}
|
|
58
|
-
*/
|
|
59
|
-
attachers: Array<[plugin: Plugin<unknown[], undefined, undefined>, ...parameters: unknown[]]>;
|
|
60
|
-
/**
|
|
61
|
-
* Compiler to use.
|
|
62
|
-
*
|
|
63
|
-
* @type {(
|
|
64
|
-
* Compiler<
|
|
65
|
-
* CompileTree extends undefined ? Node : CompileTree,
|
|
66
|
-
* CompileResult extends undefined ? CompileResults : CompileResult
|
|
67
|
-
* > |
|
|
68
|
-
* undefined
|
|
69
|
-
* )}
|
|
70
|
-
*/
|
|
71
|
-
compiler: (Compiler<CompileTree extends undefined ? Node$1 : CompileTree, CompileResult extends undefined ? CompileResults : CompileResult> | undefined);
|
|
72
|
-
/**
|
|
73
|
-
* Internal state to track where we are while freezing.
|
|
74
|
-
*
|
|
75
|
-
* @deprecated
|
|
76
|
-
* This is a private internal property and should not be used.
|
|
77
|
-
* @type {number}
|
|
78
|
-
*/
|
|
79
|
-
freezeIndex: number;
|
|
80
|
-
/**
|
|
81
|
-
* Internal state to track whether we’re frozen.
|
|
82
|
-
*
|
|
83
|
-
* @deprecated
|
|
84
|
-
* This is a private internal property and should not be used.
|
|
85
|
-
* @type {boolean | undefined}
|
|
86
|
-
*/
|
|
87
|
-
frozen: boolean | undefined;
|
|
88
|
-
/**
|
|
89
|
-
* Internal state.
|
|
90
|
-
*
|
|
91
|
-
* @deprecated
|
|
92
|
-
* This is a private internal property and should not be used.
|
|
93
|
-
* @type {Data}
|
|
94
|
-
*/
|
|
95
|
-
namespace: Data$1;
|
|
96
|
-
/**
|
|
97
|
-
* Parser to use.
|
|
98
|
-
*
|
|
99
|
-
* @type {(
|
|
100
|
-
* Parser<ParseTree extends undefined ? Node : ParseTree> |
|
|
101
|
-
* undefined
|
|
102
|
-
* )}
|
|
103
|
-
*/
|
|
104
|
-
parser: (Parser<ParseTree extends undefined ? Node$1 : ParseTree> | undefined);
|
|
105
|
-
/**
|
|
106
|
-
* Internal list of configured transformers.
|
|
107
|
-
*
|
|
108
|
-
* @deprecated
|
|
109
|
-
* This is a private internal property and should not be used.
|
|
110
|
-
* @type {Pipeline}
|
|
111
|
-
*/
|
|
112
|
-
transformers: Pipeline;
|
|
113
|
-
/**
|
|
114
|
-
* Copy a processor.
|
|
115
|
-
*
|
|
116
|
-
* @deprecated
|
|
117
|
-
* This is a private internal method and should not be used.
|
|
118
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
119
|
-
* New *unfrozen* processor ({@linkcode Processor}) that is
|
|
120
|
-
* configured to work the same as its ancestor.
|
|
121
|
-
* When the descendant processor is configured in the future it does not
|
|
122
|
-
* affect the ancestral processor.
|
|
123
|
-
*/
|
|
124
|
-
copy(): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>;
|
|
125
|
-
/**
|
|
126
|
-
* Configure the processor with info available to all plugins.
|
|
127
|
-
* Information is stored in an object.
|
|
128
|
-
*
|
|
129
|
-
* Typically, options can be given to a specific plugin, but sometimes it
|
|
130
|
-
* makes sense to have information shared with several plugins.
|
|
131
|
-
* For example, a list of HTML elements that are self-closing, which is
|
|
132
|
-
* needed during all phases.
|
|
133
|
-
*
|
|
134
|
-
* > **Note**: setting information cannot occur on *frozen* processors.
|
|
135
|
-
* > Call the processor first to create a new unfrozen processor.
|
|
136
|
-
*
|
|
137
|
-
* > **Note**: to register custom data in TypeScript, augment the
|
|
138
|
-
* > {@linkcode Data} interface.
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* This example show how to get and set info:
|
|
142
|
-
*
|
|
143
|
-
* ```js
|
|
144
|
-
* import {unified} from 'unified'
|
|
145
|
-
*
|
|
146
|
-
* const processor = unified().data('alpha', 'bravo')
|
|
147
|
-
*
|
|
148
|
-
* processor.data('alpha') // => 'bravo'
|
|
149
|
-
*
|
|
150
|
-
* processor.data() // => {alpha: 'bravo'}
|
|
151
|
-
*
|
|
152
|
-
* processor.data({charlie: 'delta'})
|
|
153
|
-
*
|
|
154
|
-
* processor.data() // => {charlie: 'delta'}
|
|
155
|
-
* ```
|
|
156
|
-
*
|
|
157
|
-
* @template {keyof Data} Key
|
|
158
|
-
*
|
|
159
|
-
* @overload
|
|
160
|
-
* @returns {Data}
|
|
161
|
-
*
|
|
162
|
-
* @overload
|
|
163
|
-
* @param {Data} dataset
|
|
164
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
165
|
-
*
|
|
166
|
-
* @overload
|
|
167
|
-
* @param {Key} key
|
|
168
|
-
* @returns {Data[Key]}
|
|
169
|
-
*
|
|
170
|
-
* @overload
|
|
171
|
-
* @param {Key} key
|
|
172
|
-
* @param {Data[Key]} value
|
|
173
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
174
|
-
*
|
|
175
|
-
* @param {Data | Key} [key]
|
|
176
|
-
* Key to get or set, or entire dataset to set, or nothing to get the
|
|
177
|
-
* entire dataset (optional).
|
|
178
|
-
* @param {Data[Key]} [value]
|
|
179
|
-
* Value to set (optional).
|
|
180
|
-
* @returns {unknown}
|
|
181
|
-
* The current processor when setting, the value at `key` when getting, or
|
|
182
|
-
* the entire dataset when getting without key.
|
|
183
|
-
*/
|
|
184
|
-
data<Key extends keyof Data>(): Data$1;
|
|
185
|
-
/**
|
|
186
|
-
* Configure the processor with info available to all plugins.
|
|
187
|
-
* Information is stored in an object.
|
|
188
|
-
*
|
|
189
|
-
* Typically, options can be given to a specific plugin, but sometimes it
|
|
190
|
-
* makes sense to have information shared with several plugins.
|
|
191
|
-
* For example, a list of HTML elements that are self-closing, which is
|
|
192
|
-
* needed during all phases.
|
|
193
|
-
*
|
|
194
|
-
* > **Note**: setting information cannot occur on *frozen* processors.
|
|
195
|
-
* > Call the processor first to create a new unfrozen processor.
|
|
196
|
-
*
|
|
197
|
-
* > **Note**: to register custom data in TypeScript, augment the
|
|
198
|
-
* > {@linkcode Data} interface.
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* This example show how to get and set info:
|
|
202
|
-
*
|
|
203
|
-
* ```js
|
|
204
|
-
* import {unified} from 'unified'
|
|
205
|
-
*
|
|
206
|
-
* const processor = unified().data('alpha', 'bravo')
|
|
207
|
-
*
|
|
208
|
-
* processor.data('alpha') // => 'bravo'
|
|
209
|
-
*
|
|
210
|
-
* processor.data() // => {alpha: 'bravo'}
|
|
211
|
-
*
|
|
212
|
-
* processor.data({charlie: 'delta'})
|
|
213
|
-
*
|
|
214
|
-
* processor.data() // => {charlie: 'delta'}
|
|
215
|
-
* ```
|
|
216
|
-
*
|
|
217
|
-
* @template {keyof Data} Key
|
|
218
|
-
*
|
|
219
|
-
* @overload
|
|
220
|
-
* @returns {Data}
|
|
221
|
-
*
|
|
222
|
-
* @overload
|
|
223
|
-
* @param {Data} dataset
|
|
224
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
225
|
-
*
|
|
226
|
-
* @overload
|
|
227
|
-
* @param {Key} key
|
|
228
|
-
* @returns {Data[Key]}
|
|
229
|
-
*
|
|
230
|
-
* @overload
|
|
231
|
-
* @param {Key} key
|
|
232
|
-
* @param {Data[Key]} value
|
|
233
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
234
|
-
*
|
|
235
|
-
* @param {Data | Key} [key]
|
|
236
|
-
* Key to get or set, or entire dataset to set, or nothing to get the
|
|
237
|
-
* entire dataset (optional).
|
|
238
|
-
* @param {Data[Key]} [value]
|
|
239
|
-
* Value to set (optional).
|
|
240
|
-
* @returns {unknown}
|
|
241
|
-
* The current processor when setting, the value at `key` when getting, or
|
|
242
|
-
* the entire dataset when getting without key.
|
|
243
|
-
*/
|
|
244
|
-
data<Key extends keyof Data>(dataset: Data$1): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>;
|
|
245
|
-
/**
|
|
246
|
-
* Configure the processor with info available to all plugins.
|
|
247
|
-
* Information is stored in an object.
|
|
248
|
-
*
|
|
249
|
-
* Typically, options can be given to a specific plugin, but sometimes it
|
|
250
|
-
* makes sense to have information shared with several plugins.
|
|
251
|
-
* For example, a list of HTML elements that are self-closing, which is
|
|
252
|
-
* needed during all phases.
|
|
253
|
-
*
|
|
254
|
-
* > **Note**: setting information cannot occur on *frozen* processors.
|
|
255
|
-
* > Call the processor first to create a new unfrozen processor.
|
|
256
|
-
*
|
|
257
|
-
* > **Note**: to register custom data in TypeScript, augment the
|
|
258
|
-
* > {@linkcode Data} interface.
|
|
259
|
-
*
|
|
260
|
-
* @example
|
|
261
|
-
* This example show how to get and set info:
|
|
262
|
-
*
|
|
263
|
-
* ```js
|
|
264
|
-
* import {unified} from 'unified'
|
|
265
|
-
*
|
|
266
|
-
* const processor = unified().data('alpha', 'bravo')
|
|
267
|
-
*
|
|
268
|
-
* processor.data('alpha') // => 'bravo'
|
|
269
|
-
*
|
|
270
|
-
* processor.data() // => {alpha: 'bravo'}
|
|
271
|
-
*
|
|
272
|
-
* processor.data({charlie: 'delta'})
|
|
273
|
-
*
|
|
274
|
-
* processor.data() // => {charlie: 'delta'}
|
|
275
|
-
* ```
|
|
276
|
-
*
|
|
277
|
-
* @template {keyof Data} Key
|
|
278
|
-
*
|
|
279
|
-
* @overload
|
|
280
|
-
* @returns {Data}
|
|
281
|
-
*
|
|
282
|
-
* @overload
|
|
283
|
-
* @param {Data} dataset
|
|
284
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
285
|
-
*
|
|
286
|
-
* @overload
|
|
287
|
-
* @param {Key} key
|
|
288
|
-
* @returns {Data[Key]}
|
|
289
|
-
*
|
|
290
|
-
* @overload
|
|
291
|
-
* @param {Key} key
|
|
292
|
-
* @param {Data[Key]} value
|
|
293
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
294
|
-
*
|
|
295
|
-
* @param {Data | Key} [key]
|
|
296
|
-
* Key to get or set, or entire dataset to set, or nothing to get the
|
|
297
|
-
* entire dataset (optional).
|
|
298
|
-
* @param {Data[Key]} [value]
|
|
299
|
-
* Value to set (optional).
|
|
300
|
-
* @returns {unknown}
|
|
301
|
-
* The current processor when setting, the value at `key` when getting, or
|
|
302
|
-
* the entire dataset when getting without key.
|
|
303
|
-
*/
|
|
304
|
-
data<Key extends keyof Data>(key: Key): Data[Key];
|
|
305
|
-
/**
|
|
306
|
-
* Configure the processor with info available to all plugins.
|
|
307
|
-
* Information is stored in an object.
|
|
308
|
-
*
|
|
309
|
-
* Typically, options can be given to a specific plugin, but sometimes it
|
|
310
|
-
* makes sense to have information shared with several plugins.
|
|
311
|
-
* For example, a list of HTML elements that are self-closing, which is
|
|
312
|
-
* needed during all phases.
|
|
313
|
-
*
|
|
314
|
-
* > **Note**: setting information cannot occur on *frozen* processors.
|
|
315
|
-
* > Call the processor first to create a new unfrozen processor.
|
|
316
|
-
*
|
|
317
|
-
* > **Note**: to register custom data in TypeScript, augment the
|
|
318
|
-
* > {@linkcode Data} interface.
|
|
319
|
-
*
|
|
320
|
-
* @example
|
|
321
|
-
* This example show how to get and set info:
|
|
322
|
-
*
|
|
323
|
-
* ```js
|
|
324
|
-
* import {unified} from 'unified'
|
|
325
|
-
*
|
|
326
|
-
* const processor = unified().data('alpha', 'bravo')
|
|
327
|
-
*
|
|
328
|
-
* processor.data('alpha') // => 'bravo'
|
|
329
|
-
*
|
|
330
|
-
* processor.data() // => {alpha: 'bravo'}
|
|
331
|
-
*
|
|
332
|
-
* processor.data({charlie: 'delta'})
|
|
333
|
-
*
|
|
334
|
-
* processor.data() // => {charlie: 'delta'}
|
|
335
|
-
* ```
|
|
336
|
-
*
|
|
337
|
-
* @template {keyof Data} Key
|
|
338
|
-
*
|
|
339
|
-
* @overload
|
|
340
|
-
* @returns {Data}
|
|
341
|
-
*
|
|
342
|
-
* @overload
|
|
343
|
-
* @param {Data} dataset
|
|
344
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
345
|
-
*
|
|
346
|
-
* @overload
|
|
347
|
-
* @param {Key} key
|
|
348
|
-
* @returns {Data[Key]}
|
|
349
|
-
*
|
|
350
|
-
* @overload
|
|
351
|
-
* @param {Key} key
|
|
352
|
-
* @param {Data[Key]} value
|
|
353
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
354
|
-
*
|
|
355
|
-
* @param {Data | Key} [key]
|
|
356
|
-
* Key to get or set, or entire dataset to set, or nothing to get the
|
|
357
|
-
* entire dataset (optional).
|
|
358
|
-
* @param {Data[Key]} [value]
|
|
359
|
-
* Value to set (optional).
|
|
360
|
-
* @returns {unknown}
|
|
361
|
-
* The current processor when setting, the value at `key` when getting, or
|
|
362
|
-
* the entire dataset when getting without key.
|
|
363
|
-
*/
|
|
364
|
-
data<Key extends keyof Data>(key: Key, value: Data[Key]): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>;
|
|
365
|
-
/**
|
|
366
|
-
* Freeze a processor.
|
|
367
|
-
*
|
|
368
|
-
* Frozen processors are meant to be extended and not to be configured
|
|
369
|
-
* directly.
|
|
370
|
-
*
|
|
371
|
-
* When a processor is frozen it cannot be unfrozen.
|
|
372
|
-
* New processors working the same way can be created by calling the
|
|
373
|
-
* processor.
|
|
374
|
-
*
|
|
375
|
-
* It’s possible to freeze processors explicitly by calling `.freeze()`.
|
|
376
|
-
* Processors freeze automatically when `.parse()`, `.run()`, `.runSync()`,
|
|
377
|
-
* `.stringify()`, `.process()`, or `.processSync()` are called.
|
|
378
|
-
*
|
|
379
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
380
|
-
* The current processor.
|
|
381
|
-
*/
|
|
382
|
-
freeze(): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>;
|
|
383
|
-
/**
|
|
384
|
-
* Parse text to a syntax tree.
|
|
385
|
-
*
|
|
386
|
-
* > **Note**: `parse` freezes the processor if not already *frozen*.
|
|
387
|
-
*
|
|
388
|
-
* > **Note**: `parse` performs the parse phase, not the run phase or other
|
|
389
|
-
* > phases.
|
|
390
|
-
*
|
|
391
|
-
* @param {Compatible | undefined} [file]
|
|
392
|
-
* file to parse (optional); typically `string` or `VFile`; any value
|
|
393
|
-
* accepted as `x` in `new VFile(x)`.
|
|
394
|
-
* @returns {ParseTree extends undefined ? Node : ParseTree}
|
|
395
|
-
* Syntax tree representing `file`.
|
|
396
|
-
*/
|
|
397
|
-
parse(file?: Compatible | undefined): ParseTree extends undefined ? Node$1 : ParseTree;
|
|
398
|
-
/**
|
|
399
|
-
* Process the given file as configured on the processor.
|
|
400
|
-
*
|
|
401
|
-
* > **Note**: `process` freezes the processor if not already *frozen*.
|
|
402
|
-
*
|
|
403
|
-
* > **Note**: `process` performs the parse, run, and stringify phases.
|
|
404
|
-
*
|
|
405
|
-
* @overload
|
|
406
|
-
* @param {Compatible | undefined} file
|
|
407
|
-
* @param {ProcessCallback<VFileWithOutput<CompileResult>>} done
|
|
408
|
-
* @returns {undefined}
|
|
409
|
-
*
|
|
410
|
-
* @overload
|
|
411
|
-
* @param {Compatible | undefined} [file]
|
|
412
|
-
* @returns {Promise<VFileWithOutput<CompileResult>>}
|
|
413
|
-
*
|
|
414
|
-
* @param {Compatible | undefined} [file]
|
|
415
|
-
* File (optional); typically `string` or `VFile`]; any value accepted as
|
|
416
|
-
* `x` in `new VFile(x)`.
|
|
417
|
-
* @param {ProcessCallback<VFileWithOutput<CompileResult>> | undefined} [done]
|
|
418
|
-
* Callback (optional).
|
|
419
|
-
* @returns {Promise<VFile> | undefined}
|
|
420
|
-
* Nothing if `done` is given.
|
|
421
|
-
* Otherwise a promise, rejected with a fatal error or resolved with the
|
|
422
|
-
* processed file.
|
|
423
|
-
*
|
|
424
|
-
* The parsed, transformed, and compiled value is available at
|
|
425
|
-
* `file.value` (see note).
|
|
426
|
-
*
|
|
427
|
-
* > **Note**: unified typically compiles by serializing: most
|
|
428
|
-
* > compilers return `string` (or `Uint8Array`).
|
|
429
|
-
* > Some compilers, such as the one configured with
|
|
430
|
-
* > [`rehype-react`][rehype-react], return other values (in this case, a
|
|
431
|
-
* > React tree).
|
|
432
|
-
* > If you’re using a compiler that doesn’t serialize, expect different
|
|
433
|
-
* > result values.
|
|
434
|
-
* >
|
|
435
|
-
* > To register custom results in TypeScript, add them to
|
|
436
|
-
* > {@linkcode CompileResultMap}.
|
|
437
|
-
*
|
|
438
|
-
* [rehype-react]: https://github.com/rehypejs/rehype-react
|
|
439
|
-
*/
|
|
440
|
-
process(file: Compatible | undefined, done: ProcessCallback<VFileWithOutput<CompileResult>>): undefined;
|
|
441
|
-
/**
|
|
442
|
-
* Process the given file as configured on the processor.
|
|
443
|
-
*
|
|
444
|
-
* > **Note**: `process` freezes the processor if not already *frozen*.
|
|
445
|
-
*
|
|
446
|
-
* > **Note**: `process` performs the parse, run, and stringify phases.
|
|
447
|
-
*
|
|
448
|
-
* @overload
|
|
449
|
-
* @param {Compatible | undefined} file
|
|
450
|
-
* @param {ProcessCallback<VFileWithOutput<CompileResult>>} done
|
|
451
|
-
* @returns {undefined}
|
|
452
|
-
*
|
|
453
|
-
* @overload
|
|
454
|
-
* @param {Compatible | undefined} [file]
|
|
455
|
-
* @returns {Promise<VFileWithOutput<CompileResult>>}
|
|
456
|
-
*
|
|
457
|
-
* @param {Compatible | undefined} [file]
|
|
458
|
-
* File (optional); typically `string` or `VFile`]; any value accepted as
|
|
459
|
-
* `x` in `new VFile(x)`.
|
|
460
|
-
* @param {ProcessCallback<VFileWithOutput<CompileResult>> | undefined} [done]
|
|
461
|
-
* Callback (optional).
|
|
462
|
-
* @returns {Promise<VFile> | undefined}
|
|
463
|
-
* Nothing if `done` is given.
|
|
464
|
-
* Otherwise a promise, rejected with a fatal error or resolved with the
|
|
465
|
-
* processed file.
|
|
466
|
-
*
|
|
467
|
-
* The parsed, transformed, and compiled value is available at
|
|
468
|
-
* `file.value` (see note).
|
|
469
|
-
*
|
|
470
|
-
* > **Note**: unified typically compiles by serializing: most
|
|
471
|
-
* > compilers return `string` (or `Uint8Array`).
|
|
472
|
-
* > Some compilers, such as the one configured with
|
|
473
|
-
* > [`rehype-react`][rehype-react], return other values (in this case, a
|
|
474
|
-
* > React tree).
|
|
475
|
-
* > If you’re using a compiler that doesn’t serialize, expect different
|
|
476
|
-
* > result values.
|
|
477
|
-
* >
|
|
478
|
-
* > To register custom results in TypeScript, add them to
|
|
479
|
-
* > {@linkcode CompileResultMap}.
|
|
480
|
-
*
|
|
481
|
-
* [rehype-react]: https://github.com/rehypejs/rehype-react
|
|
482
|
-
*/
|
|
483
|
-
process(file?: Compatible | undefined): Promise<VFileWithOutput<CompileResult>>;
|
|
484
|
-
/**
|
|
485
|
-
* Process the given file as configured on the processor.
|
|
486
|
-
*
|
|
487
|
-
* An error is thrown if asynchronous transforms are configured.
|
|
488
|
-
*
|
|
489
|
-
* > **Note**: `processSync` freezes the processor if not already *frozen*.
|
|
490
|
-
*
|
|
491
|
-
* > **Note**: `processSync` performs the parse, run, and stringify phases.
|
|
492
|
-
*
|
|
493
|
-
* @param {Compatible | undefined} [file]
|
|
494
|
-
* File (optional); typically `string` or `VFile`; any value accepted as
|
|
495
|
-
* `x` in `new VFile(x)`.
|
|
496
|
-
* @returns {VFileWithOutput<CompileResult>}
|
|
497
|
-
* The processed file.
|
|
498
|
-
*
|
|
499
|
-
* The parsed, transformed, and compiled value is available at
|
|
500
|
-
* `file.value` (see note).
|
|
501
|
-
*
|
|
502
|
-
* > **Note**: unified typically compiles by serializing: most
|
|
503
|
-
* > compilers return `string` (or `Uint8Array`).
|
|
504
|
-
* > Some compilers, such as the one configured with
|
|
505
|
-
* > [`rehype-react`][rehype-react], return other values (in this case, a
|
|
506
|
-
* > React tree).
|
|
507
|
-
* > If you’re using a compiler that doesn’t serialize, expect different
|
|
508
|
-
* > result values.
|
|
509
|
-
* >
|
|
510
|
-
* > To register custom results in TypeScript, add them to
|
|
511
|
-
* > {@linkcode CompileResultMap}.
|
|
512
|
-
*
|
|
513
|
-
* [rehype-react]: https://github.com/rehypejs/rehype-react
|
|
514
|
-
*/
|
|
515
|
-
processSync(file?: Compatible | undefined): VFileWithOutput<CompileResult>;
|
|
516
|
-
/**
|
|
517
|
-
* Run *transformers* on a syntax tree.
|
|
518
|
-
*
|
|
519
|
-
* > **Note**: `run` freezes the processor if not already *frozen*.
|
|
520
|
-
*
|
|
521
|
-
* > **Note**: `run` performs the run phase, not other phases.
|
|
522
|
-
*
|
|
523
|
-
* @overload
|
|
524
|
-
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
525
|
-
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
|
526
|
-
* @returns {undefined}
|
|
527
|
-
*
|
|
528
|
-
* @overload
|
|
529
|
-
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
530
|
-
* @param {Compatible | undefined} file
|
|
531
|
-
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
|
532
|
-
* @returns {undefined}
|
|
533
|
-
*
|
|
534
|
-
* @overload
|
|
535
|
-
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
536
|
-
* @param {Compatible | undefined} [file]
|
|
537
|
-
* @returns {Promise<TailTree extends undefined ? Node : TailTree>}
|
|
538
|
-
*
|
|
539
|
-
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
540
|
-
* Tree to transform and inspect.
|
|
541
|
-
* @param {(
|
|
542
|
-
* RunCallback<TailTree extends undefined ? Node : TailTree> |
|
|
543
|
-
* Compatible
|
|
544
|
-
* )} [file]
|
|
545
|
-
* File associated with `node` (optional); any value accepted as `x` in
|
|
546
|
-
* `new VFile(x)`.
|
|
547
|
-
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done]
|
|
548
|
-
* Callback (optional).
|
|
549
|
-
* @returns {Promise<TailTree extends undefined ? Node : TailTree> | undefined}
|
|
550
|
-
* Nothing if `done` is given.
|
|
551
|
-
* Otherwise, a promise rejected with a fatal error or resolved with the
|
|
552
|
-
* transformed tree.
|
|
553
|
-
*/
|
|
554
|
-
run(tree: HeadTree extends undefined ? Node$1 : HeadTree, done: RunCallback<TailTree extends undefined ? Node$1 : TailTree>): undefined;
|
|
555
|
-
/**
|
|
556
|
-
* Run *transformers* on a syntax tree.
|
|
557
|
-
*
|
|
558
|
-
* > **Note**: `run` freezes the processor if not already *frozen*.
|
|
559
|
-
*
|
|
560
|
-
* > **Note**: `run` performs the run phase, not other phases.
|
|
561
|
-
*
|
|
562
|
-
* @overload
|
|
563
|
-
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
564
|
-
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
|
565
|
-
* @returns {undefined}
|
|
566
|
-
*
|
|
567
|
-
* @overload
|
|
568
|
-
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
569
|
-
* @param {Compatible | undefined} file
|
|
570
|
-
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
|
571
|
-
* @returns {undefined}
|
|
572
|
-
*
|
|
573
|
-
* @overload
|
|
574
|
-
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
575
|
-
* @param {Compatible | undefined} [file]
|
|
576
|
-
* @returns {Promise<TailTree extends undefined ? Node : TailTree>}
|
|
577
|
-
*
|
|
578
|
-
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
579
|
-
* Tree to transform and inspect.
|
|
580
|
-
* @param {(
|
|
581
|
-
* RunCallback<TailTree extends undefined ? Node : TailTree> |
|
|
582
|
-
* Compatible
|
|
583
|
-
* )} [file]
|
|
584
|
-
* File associated with `node` (optional); any value accepted as `x` in
|
|
585
|
-
* `new VFile(x)`.
|
|
586
|
-
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done]
|
|
587
|
-
* Callback (optional).
|
|
588
|
-
* @returns {Promise<TailTree extends undefined ? Node : TailTree> | undefined}
|
|
589
|
-
* Nothing if `done` is given.
|
|
590
|
-
* Otherwise, a promise rejected with a fatal error or resolved with the
|
|
591
|
-
* transformed tree.
|
|
592
|
-
*/
|
|
593
|
-
run(tree: HeadTree extends undefined ? Node$1 : HeadTree, file: Compatible | undefined, done: RunCallback<TailTree extends undefined ? Node$1 : TailTree>): undefined;
|
|
594
|
-
/**
|
|
595
|
-
* Run *transformers* on a syntax tree.
|
|
596
|
-
*
|
|
597
|
-
* > **Note**: `run` freezes the processor if not already *frozen*.
|
|
598
|
-
*
|
|
599
|
-
* > **Note**: `run` performs the run phase, not other phases.
|
|
600
|
-
*
|
|
601
|
-
* @overload
|
|
602
|
-
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
603
|
-
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
|
604
|
-
* @returns {undefined}
|
|
605
|
-
*
|
|
606
|
-
* @overload
|
|
607
|
-
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
608
|
-
* @param {Compatible | undefined} file
|
|
609
|
-
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
|
610
|
-
* @returns {undefined}
|
|
611
|
-
*
|
|
612
|
-
* @overload
|
|
613
|
-
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
614
|
-
* @param {Compatible | undefined} [file]
|
|
615
|
-
* @returns {Promise<TailTree extends undefined ? Node : TailTree>}
|
|
616
|
-
*
|
|
617
|
-
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
618
|
-
* Tree to transform and inspect.
|
|
619
|
-
* @param {(
|
|
620
|
-
* RunCallback<TailTree extends undefined ? Node : TailTree> |
|
|
621
|
-
* Compatible
|
|
622
|
-
* )} [file]
|
|
623
|
-
* File associated with `node` (optional); any value accepted as `x` in
|
|
624
|
-
* `new VFile(x)`.
|
|
625
|
-
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done]
|
|
626
|
-
* Callback (optional).
|
|
627
|
-
* @returns {Promise<TailTree extends undefined ? Node : TailTree> | undefined}
|
|
628
|
-
* Nothing if `done` is given.
|
|
629
|
-
* Otherwise, a promise rejected with a fatal error or resolved with the
|
|
630
|
-
* transformed tree.
|
|
631
|
-
*/
|
|
632
|
-
run(tree: HeadTree extends undefined ? Node$1 : HeadTree, file?: Compatible | undefined): Promise<TailTree extends undefined ? Node$1 : TailTree>;
|
|
633
|
-
/**
|
|
634
|
-
* Run *transformers* on a syntax tree.
|
|
635
|
-
*
|
|
636
|
-
* An error is thrown if asynchronous transforms are configured.
|
|
637
|
-
*
|
|
638
|
-
* > **Note**: `runSync` freezes the processor if not already *frozen*.
|
|
639
|
-
*
|
|
640
|
-
* > **Note**: `runSync` performs the run phase, not other phases.
|
|
641
|
-
*
|
|
642
|
-
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
643
|
-
* Tree to transform and inspect.
|
|
644
|
-
* @param {Compatible | undefined} [file]
|
|
645
|
-
* File associated with `node` (optional); any value accepted as `x` in
|
|
646
|
-
* `new VFile(x)`.
|
|
647
|
-
* @returns {TailTree extends undefined ? Node : TailTree}
|
|
648
|
-
* Transformed tree.
|
|
649
|
-
*/
|
|
650
|
-
runSync(tree: HeadTree extends undefined ? Node$1 : HeadTree, file?: Compatible | undefined): TailTree extends undefined ? Node$1 : TailTree;
|
|
651
|
-
/**
|
|
652
|
-
* Compile a syntax tree.
|
|
653
|
-
*
|
|
654
|
-
* > **Note**: `stringify` freezes the processor if not already *frozen*.
|
|
655
|
-
*
|
|
656
|
-
* > **Note**: `stringify` performs the stringify phase, not the run phase
|
|
657
|
-
* > or other phases.
|
|
658
|
-
*
|
|
659
|
-
* @param {CompileTree extends undefined ? Node : CompileTree} tree
|
|
660
|
-
* Tree to compile.
|
|
661
|
-
* @param {Compatible | undefined} [file]
|
|
662
|
-
* File associated with `node` (optional); any value accepted as `x` in
|
|
663
|
-
* `new VFile(x)`.
|
|
664
|
-
* @returns {CompileResult extends undefined ? Value : CompileResult}
|
|
665
|
-
* Textual representation of the tree (see note).
|
|
666
|
-
*
|
|
667
|
-
* > **Note**: unified typically compiles by serializing: most compilers
|
|
668
|
-
* > return `string` (or `Uint8Array`).
|
|
669
|
-
* > Some compilers, such as the one configured with
|
|
670
|
-
* > [`rehype-react`][rehype-react], return other values (in this case, a
|
|
671
|
-
* > React tree).
|
|
672
|
-
* > If you’re using a compiler that doesn’t serialize, expect different
|
|
673
|
-
* > result values.
|
|
674
|
-
* >
|
|
675
|
-
* > To register custom results in TypeScript, add them to
|
|
676
|
-
* > {@linkcode CompileResultMap}.
|
|
677
|
-
*
|
|
678
|
-
* [rehype-react]: https://github.com/rehypejs/rehype-react
|
|
679
|
-
*/
|
|
680
|
-
stringify(tree: CompileTree extends undefined ? Node$1 : CompileTree, file?: Compatible | undefined): CompileResult extends undefined ? Value : CompileResult;
|
|
681
|
-
/**
|
|
682
|
-
* Configure the processor to use a plugin, a list of usable values, or a
|
|
683
|
-
* preset.
|
|
684
|
-
*
|
|
685
|
-
* If the processor is already using a plugin, the previous plugin
|
|
686
|
-
* configuration is changed based on the options that are passed in.
|
|
687
|
-
* In other words, the plugin is not added a second time.
|
|
688
|
-
*
|
|
689
|
-
* > **Note**: `use` cannot be called on *frozen* processors.
|
|
690
|
-
* > Call the processor first to create a new unfrozen processor.
|
|
691
|
-
*
|
|
692
|
-
* @example
|
|
693
|
-
* There are many ways to pass plugins to `.use()`.
|
|
694
|
-
* This example gives an overview:
|
|
695
|
-
*
|
|
696
|
-
* ```js
|
|
697
|
-
* import {unified} from 'unified'
|
|
698
|
-
*
|
|
699
|
-
* unified()
|
|
700
|
-
* // Plugin with options:
|
|
701
|
-
* .use(pluginA, {x: true, y: true})
|
|
702
|
-
* // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`):
|
|
703
|
-
* .use(pluginA, {y: false, z: true})
|
|
704
|
-
* // Plugins:
|
|
705
|
-
* .use([pluginB, pluginC])
|
|
706
|
-
* // Two plugins, the second with options:
|
|
707
|
-
* .use([pluginD, [pluginE, {}]])
|
|
708
|
-
* // Preset with plugins and settings:
|
|
709
|
-
* .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}})
|
|
710
|
-
* // Settings only:
|
|
711
|
-
* .use({settings: {position: false}})
|
|
712
|
-
* ```
|
|
713
|
-
*
|
|
714
|
-
* @template {Array<unknown>} [Parameters=[]]
|
|
715
|
-
* @template {Node | string | undefined} [Input=undefined]
|
|
716
|
-
* @template [Output=Input]
|
|
717
|
-
*
|
|
718
|
-
* @overload
|
|
719
|
-
* @param {Preset | null | undefined} [preset]
|
|
720
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
721
|
-
*
|
|
722
|
-
* @overload
|
|
723
|
-
* @param {PluggableList} list
|
|
724
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
725
|
-
*
|
|
726
|
-
* @overload
|
|
727
|
-
* @param {Plugin<Parameters, Input, Output>} plugin
|
|
728
|
-
* @param {...(Parameters | [boolean])} parameters
|
|
729
|
-
* @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>}
|
|
730
|
-
*
|
|
731
|
-
* @param {PluggableList | Plugin | Preset | null | undefined} value
|
|
732
|
-
* Usable value.
|
|
733
|
-
* @param {...unknown} parameters
|
|
734
|
-
* Parameters, when a plugin is given as a usable value.
|
|
735
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
736
|
-
* Current processor.
|
|
737
|
-
*/
|
|
738
|
-
use<Parameters_1 extends unknown[] = [], Input extends string | unist26.Node | undefined = undefined, Output = Input>(preset?: Preset | null | undefined): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>;
|
|
739
|
-
/**
|
|
740
|
-
* Configure the processor to use a plugin, a list of usable values, or a
|
|
741
|
-
* preset.
|
|
742
|
-
*
|
|
743
|
-
* If the processor is already using a plugin, the previous plugin
|
|
744
|
-
* configuration is changed based on the options that are passed in.
|
|
745
|
-
* In other words, the plugin is not added a second time.
|
|
746
|
-
*
|
|
747
|
-
* > **Note**: `use` cannot be called on *frozen* processors.
|
|
748
|
-
* > Call the processor first to create a new unfrozen processor.
|
|
749
|
-
*
|
|
750
|
-
* @example
|
|
751
|
-
* There are many ways to pass plugins to `.use()`.
|
|
752
|
-
* This example gives an overview:
|
|
753
|
-
*
|
|
754
|
-
* ```js
|
|
755
|
-
* import {unified} from 'unified'
|
|
756
|
-
*
|
|
757
|
-
* unified()
|
|
758
|
-
* // Plugin with options:
|
|
759
|
-
* .use(pluginA, {x: true, y: true})
|
|
760
|
-
* // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`):
|
|
761
|
-
* .use(pluginA, {y: false, z: true})
|
|
762
|
-
* // Plugins:
|
|
763
|
-
* .use([pluginB, pluginC])
|
|
764
|
-
* // Two plugins, the second with options:
|
|
765
|
-
* .use([pluginD, [pluginE, {}]])
|
|
766
|
-
* // Preset with plugins and settings:
|
|
767
|
-
* .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}})
|
|
768
|
-
* // Settings only:
|
|
769
|
-
* .use({settings: {position: false}})
|
|
770
|
-
* ```
|
|
771
|
-
*
|
|
772
|
-
* @template {Array<unknown>} [Parameters=[]]
|
|
773
|
-
* @template {Node | string | undefined} [Input=undefined]
|
|
774
|
-
* @template [Output=Input]
|
|
775
|
-
*
|
|
776
|
-
* @overload
|
|
777
|
-
* @param {Preset | null | undefined} [preset]
|
|
778
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
779
|
-
*
|
|
780
|
-
* @overload
|
|
781
|
-
* @param {PluggableList} list
|
|
782
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
783
|
-
*
|
|
784
|
-
* @overload
|
|
785
|
-
* @param {Plugin<Parameters, Input, Output>} plugin
|
|
786
|
-
* @param {...(Parameters | [boolean])} parameters
|
|
787
|
-
* @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>}
|
|
788
|
-
*
|
|
789
|
-
* @param {PluggableList | Plugin | Preset | null | undefined} value
|
|
790
|
-
* Usable value.
|
|
791
|
-
* @param {...unknown} parameters
|
|
792
|
-
* Parameters, when a plugin is given as a usable value.
|
|
793
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
794
|
-
* Current processor.
|
|
795
|
-
*/
|
|
796
|
-
use<Parameters_1 extends unknown[] = [], Input extends string | unist26.Node | undefined = undefined, Output = Input>(list: PluggableList): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>;
|
|
797
|
-
/**
|
|
798
|
-
* Configure the processor to use a plugin, a list of usable values, or a
|
|
799
|
-
* preset.
|
|
800
|
-
*
|
|
801
|
-
* If the processor is already using a plugin, the previous plugin
|
|
802
|
-
* configuration is changed based on the options that are passed in.
|
|
803
|
-
* In other words, the plugin is not added a second time.
|
|
804
|
-
*
|
|
805
|
-
* > **Note**: `use` cannot be called on *frozen* processors.
|
|
806
|
-
* > Call the processor first to create a new unfrozen processor.
|
|
807
|
-
*
|
|
808
|
-
* @example
|
|
809
|
-
* There are many ways to pass plugins to `.use()`.
|
|
810
|
-
* This example gives an overview:
|
|
811
|
-
*
|
|
812
|
-
* ```js
|
|
813
|
-
* import {unified} from 'unified'
|
|
814
|
-
*
|
|
815
|
-
* unified()
|
|
816
|
-
* // Plugin with options:
|
|
817
|
-
* .use(pluginA, {x: true, y: true})
|
|
818
|
-
* // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`):
|
|
819
|
-
* .use(pluginA, {y: false, z: true})
|
|
820
|
-
* // Plugins:
|
|
821
|
-
* .use([pluginB, pluginC])
|
|
822
|
-
* // Two plugins, the second with options:
|
|
823
|
-
* .use([pluginD, [pluginE, {}]])
|
|
824
|
-
* // Preset with plugins and settings:
|
|
825
|
-
* .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}})
|
|
826
|
-
* // Settings only:
|
|
827
|
-
* .use({settings: {position: false}})
|
|
828
|
-
* ```
|
|
829
|
-
*
|
|
830
|
-
* @template {Array<unknown>} [Parameters=[]]
|
|
831
|
-
* @template {Node | string | undefined} [Input=undefined]
|
|
832
|
-
* @template [Output=Input]
|
|
833
|
-
*
|
|
834
|
-
* @overload
|
|
835
|
-
* @param {Preset | null | undefined} [preset]
|
|
836
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
837
|
-
*
|
|
838
|
-
* @overload
|
|
839
|
-
* @param {PluggableList} list
|
|
840
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
841
|
-
*
|
|
842
|
-
* @overload
|
|
843
|
-
* @param {Plugin<Parameters, Input, Output>} plugin
|
|
844
|
-
* @param {...(Parameters | [boolean])} parameters
|
|
845
|
-
* @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>}
|
|
846
|
-
*
|
|
847
|
-
* @param {PluggableList | Plugin | Preset | null | undefined} value
|
|
848
|
-
* Usable value.
|
|
849
|
-
* @param {...unknown} parameters
|
|
850
|
-
* Parameters, when a plugin is given as a usable value.
|
|
851
|
-
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
852
|
-
* Current processor.
|
|
853
|
-
*/
|
|
854
|
-
use<Parameters_1 extends unknown[] = [], Input extends string | unist26.Node | undefined = undefined, Output = Input>(plugin: Plugin<Parameters_1, Input, Output>, ...parameters: Parameters_1 | [boolean]): UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>;
|
|
855
|
-
}
|
|
856
|
-
type Pipeline = trough0.Pipeline;
|
|
857
|
-
type Node$1 = unist26.Node;
|
|
858
|
-
type Compatible = vfile1.Compatible;
|
|
859
|
-
type Value = vfile1.Value;
|
|
860
|
-
type CompileResultMap$1 = CompileResultMap;
|
|
861
|
-
type Data$1 = Data;
|
|
862
|
-
type Settings$1 = Settings;
|
|
863
|
-
/**
|
|
864
|
-
* Acceptable results from compilers.
|
|
865
|
-
*
|
|
866
|
-
* To register custom results, add them to
|
|
867
|
-
* {@linkcode CompileResultMap }.
|
|
868
|
-
*/
|
|
869
|
-
type CompileResults = CompileResultMap$1[keyof CompileResultMap$1];
|
|
870
|
-
/**
|
|
871
|
-
* A **compiler** handles the compiling of a syntax tree to something else
|
|
872
|
-
* (in most cases, text) (TypeScript type).
|
|
873
|
-
*
|
|
874
|
-
* It is used in the stringify phase and called with a {@linkcode Node }
|
|
875
|
-
* and {@linkcode VFile } representation of the document to compile.
|
|
876
|
-
* It should return the textual representation of the given tree (typically
|
|
877
|
-
* `string`).
|
|
878
|
-
*
|
|
879
|
-
* > **Note**: unified typically compiles by serializing: most compilers
|
|
880
|
-
* > return `string` (or `Uint8Array`).
|
|
881
|
-
* > Some compilers, such as the one configured with
|
|
882
|
-
* > [`rehype-react`][rehype-react], return other values (in this case, a
|
|
883
|
-
* > React tree).
|
|
884
|
-
* > If you’re using a compiler that doesn’t serialize, expect different
|
|
885
|
-
* > result values.
|
|
886
|
-
* >
|
|
887
|
-
* > To register custom results in TypeScript, add them to
|
|
888
|
-
* > {@linkcode CompileResultMap }.
|
|
889
|
-
*
|
|
890
|
-
* [rehype-react]: https://github.com/rehypejs/rehype-react
|
|
891
|
-
*/
|
|
892
|
-
type Compiler<Tree extends unist26.Node = unist26.Node, Result extends CompileResults = CompileResults> = (tree: Tree, file: VFile) => Result;
|
|
893
|
-
/**
|
|
894
|
-
* A **parser** handles the parsing of text to a syntax tree.
|
|
895
|
-
*
|
|
896
|
-
* It is used in the parse phase and is called with a `string` and
|
|
897
|
-
* {@linkcode VFile } of the document to parse.
|
|
898
|
-
* It must return the syntax tree representation of the given file
|
|
899
|
-
* ({@linkcode Node }).
|
|
900
|
-
*/
|
|
901
|
-
type Parser<Tree extends unist26.Node = unist26.Node> = (document: string, file: VFile) => Tree;
|
|
902
|
-
/**
|
|
903
|
-
* Union of the different ways to add plugins and settings.
|
|
904
|
-
*/
|
|
905
|
-
type Pluggable = (Plugin<Array<any>, any, any> | PluginTuple<Array<any>, any, any> | Preset);
|
|
906
|
-
/**
|
|
907
|
-
* List of plugins and presets.
|
|
908
|
-
*/
|
|
909
|
-
type PluggableList = Array<Pluggable>;
|
|
910
|
-
/**
|
|
911
|
-
* Single plugin.
|
|
912
|
-
*
|
|
913
|
-
* Plugins configure the processors they are applied on in the following
|
|
914
|
-
* ways:
|
|
915
|
-
*
|
|
916
|
-
* * they change the processor, such as the parser, the compiler, or by
|
|
917
|
-
* configuring data
|
|
918
|
-
* * they specify how to handle trees and files
|
|
919
|
-
*
|
|
920
|
-
* In practice, they are functions that can receive options and configure the
|
|
921
|
-
* processor (`this`).
|
|
922
|
-
*
|
|
923
|
-
* > **Note**: plugins are called when the processor is *frozen*, not when
|
|
924
|
-
* > they are applied.
|
|
925
|
-
*/
|
|
926
|
-
type Plugin<PluginParameters extends unknown[] = [], Input extends string | unist26.Node | undefined = unist26.Node, Output = Input> = ((this: Processor, ...parameters: PluginParameters) => Input extends string ? Output extends Node$1 | undefined ? undefined | void : never : Output extends CompileResults ? Input extends Node$1 | undefined ? undefined | void : never : Transformer<Input extends Node$1 ? Input : Node$1, Output extends Node$1 ? Output : Node$1> | undefined | void);
|
|
927
|
-
/**
|
|
928
|
-
* Tuple of a plugin and its configuration.
|
|
929
|
-
*
|
|
930
|
-
* The first item is a plugin, the rest are its parameters.
|
|
931
|
-
*/
|
|
932
|
-
type PluginTuple<TupleParameters extends unknown[] = [], Input extends string | unist26.Node | undefined = undefined, Output = undefined> = ([plugin: Plugin<TupleParameters, Input, Output>, ...parameters: TupleParameters]);
|
|
933
|
-
/**
|
|
934
|
-
* Sharable configuration.
|
|
935
|
-
*
|
|
936
|
-
* They can contain plugins and settings.
|
|
937
|
-
*/
|
|
938
|
-
type Preset = {
|
|
939
|
-
/**
|
|
940
|
-
* List of plugins and presets (optional).
|
|
941
|
-
*/
|
|
942
|
-
plugins?: PluggableList | undefined;
|
|
943
|
-
/**
|
|
944
|
-
* Shared settings for parsers and compilers (optional).
|
|
945
|
-
*/
|
|
946
|
-
settings?: Settings$1 | undefined;
|
|
947
|
-
};
|
|
948
|
-
/**
|
|
949
|
-
* Callback called when the process is done.
|
|
950
|
-
*
|
|
951
|
-
* Called with either an error or a result.
|
|
952
|
-
*/
|
|
953
|
-
type ProcessCallback<File extends VFile = VFile> = (error?: Error | undefined, file?: File | undefined) => undefined;
|
|
954
|
-
/**
|
|
955
|
-
* Callback called when transformers are done.
|
|
956
|
-
*
|
|
957
|
-
* Called with either an error or results.
|
|
958
|
-
*/
|
|
959
|
-
type RunCallback<Tree extends unist26.Node = unist26.Node> = (error?: Error | undefined, tree?: Tree | undefined, file?: VFile | undefined) => undefined;
|
|
960
|
-
/**
|
|
961
|
-
* Callback passed to transforms.
|
|
962
|
-
*
|
|
963
|
-
* If the signature of a `transformer` accepts a third argument, the
|
|
964
|
-
* transformer may perform asynchronous operations, and must call it.
|
|
965
|
-
*/
|
|
966
|
-
type TransformCallback<Output extends unist26.Node = unist26.Node> = (error?: Error | undefined, tree?: Output | undefined, file?: VFile | undefined) => undefined;
|
|
967
|
-
/**
|
|
968
|
-
* Transformers handle syntax trees and files.
|
|
969
|
-
*
|
|
970
|
-
* They are functions that are called each time a syntax tree and file are
|
|
971
|
-
* passed through the run phase.
|
|
972
|
-
* When an error occurs in them (either because it’s thrown, returned,
|
|
973
|
-
* rejected, or passed to `next`), the process stops.
|
|
974
|
-
*
|
|
975
|
-
* The run phase is handled by [`trough`][trough], see its documentation for
|
|
976
|
-
* the exact semantics of these functions.
|
|
977
|
-
*
|
|
978
|
-
* > **Note**: you should likely ignore `next`: don’t accept it.
|
|
979
|
-
* > it supports callback-style async work.
|
|
980
|
-
* > But promises are likely easier to reason about.
|
|
981
|
-
*
|
|
982
|
-
* [trough]: https://github.com/wooorm/trough#function-fninput-next
|
|
983
|
-
*/
|
|
984
|
-
type Transformer<Input extends unist26.Node = unist26.Node, Output extends unist26.Node = Input> = (tree: Input, file: VFile, next: TransformCallback<Output>) => (Promise<Output | undefined | void> | Promise<never> | // For some reason this is needed separately.
|
|
985
|
-
Output | Error | undefined | void);
|
|
986
|
-
/**
|
|
987
|
-
* Create a processor based on the input/output of a {@link Plugin plugin}.
|
|
988
|
-
*/
|
|
989
|
-
type UsePlugin<ParseTree extends unist26.Node | undefined, HeadTree extends unist26.Node | undefined, TailTree extends unist26.Node | undefined, CompileTree extends unist26.Node | undefined, CompileResult extends CompileResults | undefined, Input extends string | unist26.Node | undefined, Output> = (Input extends string ? Output extends Node$1 | undefined ? Processor<Output extends undefined ? ParseTree : Output, HeadTree, TailTree, CompileTree, CompileResult> : Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> : Output extends CompileResults ? Input extends Node$1 | undefined ? Processor<ParseTree, HeadTree, TailTree, Input extends undefined ? CompileTree : Input, Output extends undefined ? CompileResult : Output> : Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> : Input extends Node$1 | undefined ? Output extends Node$1 | undefined ? Processor<ParseTree, HeadTree extends undefined ? Input : HeadTree, Output extends undefined ? TailTree : Output, CompileTree, CompileResult> : Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> : Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>);
|
|
990
|
-
/**
|
|
991
|
-
* Type to generate a {@linkcode VFile } corresponding to a compiler result.
|
|
992
|
-
*
|
|
993
|
-
* If a result that is not acceptable on a `VFile` is used, that will
|
|
994
|
-
* be stored on the `result` field of {@linkcode VFile }.
|
|
995
|
-
*/
|
|
996
|
-
type VFileWithOutput<Result extends CompileResults | undefined> = (Result extends Value | undefined ? VFile : VFile & {
|
|
997
|
-
result: Result;
|
|
998
|
-
});
|
|
999
|
-
// See: <https://github.com/sindresorhus/type-fest/blob/main/source/empty-object.d.ts>
|
|
1000
|
-
declare const emptyObjectSymbol: unique symbol;
|
|
1001
|
-
/**
|
|
1002
|
-
* Interface of known results from compilers.
|
|
1003
|
-
*
|
|
1004
|
-
* Normally, compilers result in text ({@linkcode Value} of `vfile`).
|
|
1005
|
-
* When you compile to something else, such as a React node (as in,
|
|
1006
|
-
* `rehype-react`), you can augment this interface to include that type.
|
|
1007
|
-
*
|
|
1008
|
-
* ```ts
|
|
1009
|
-
* import type {ReactNode} from 'somewhere'
|
|
1010
|
-
*
|
|
1011
|
-
* declare module 'unified' {
|
|
1012
|
-
* interface CompileResultMap {
|
|
1013
|
-
* // Register a new result (value is used, key should match it).
|
|
1014
|
-
* ReactNode: ReactNode
|
|
1015
|
-
* }
|
|
1016
|
-
* }
|
|
1017
|
-
*
|
|
1018
|
-
* export {} // You may not need this, but it makes sure the file is a module.
|
|
1019
|
-
* ```
|
|
1020
|
-
*
|
|
1021
|
-
* Use {@linkcode CompileResults} to access the values.
|
|
1022
|
-
*/
|
|
1023
|
-
interface CompileResultMap {
|
|
1024
|
-
// Note: if `Value` from `VFile` is changed, this should too.
|
|
1025
|
-
Uint8Array: Uint8Array;
|
|
1026
|
-
string: string;
|
|
1027
|
-
}
|
|
1028
|
-
/**
|
|
1029
|
-
* Interface of known data that can be supported by all plugins.
|
|
1030
|
-
*
|
|
1031
|
-
* Typically, options can be given to a specific plugin, but sometimes it makes
|
|
1032
|
-
* sense to have information shared with several plugins.
|
|
1033
|
-
* For example, a list of HTML elements that are self-closing, which is needed
|
|
1034
|
-
* during all phases.
|
|
1035
|
-
*
|
|
1036
|
-
* To type this, do something like:
|
|
1037
|
-
*
|
|
1038
|
-
* ```ts
|
|
1039
|
-
* declare module 'unified' {
|
|
1040
|
-
* interface Data {
|
|
1041
|
-
* htmlVoidElements?: Array<string> | undefined
|
|
1042
|
-
* }
|
|
1043
|
-
* }
|
|
1044
|
-
*
|
|
1045
|
-
* export {} // You may not need this, but it makes sure the file is a module.
|
|
1046
|
-
* ```
|
|
1047
|
-
*/
|
|
1048
|
-
interface Data {
|
|
1049
|
-
settings?: Settings | undefined;
|
|
1050
|
-
}
|
|
1051
|
-
/**
|
|
1052
|
-
* Interface of known extra options, that can be supported by parser and
|
|
1053
|
-
* compilers.
|
|
1054
|
-
*
|
|
1055
|
-
* This exists so that users can use packages such as `remark`, which configure
|
|
1056
|
-
* both parsers and compilers (in this case `remark-parse` and
|
|
1057
|
-
* `remark-stringify`), and still provide options for them.
|
|
1058
|
-
*
|
|
1059
|
-
* When you make parsers or compilers, that could be packaged up together,
|
|
1060
|
-
* you should support `this.data('settings')` as input and merge it with
|
|
1061
|
-
* explicitly passed `options`.
|
|
1062
|
-
* Then, to type it, using `remark-stringify` as an example, do something like:
|
|
1063
|
-
*
|
|
1064
|
-
* ```ts
|
|
1065
|
-
* declare module 'unified' {
|
|
1066
|
-
* interface Settings {
|
|
1067
|
-
* bullet: '*' | '+' | '-'
|
|
1068
|
-
* // …
|
|
1069
|
-
* }
|
|
1070
|
-
* }
|
|
1071
|
-
*
|
|
1072
|
-
* export {} // You may not need this, but it makes sure the file is a module.
|
|
1073
|
-
* ```
|
|
1074
|
-
*/
|
|
1075
|
-
interface Settings {
|
|
1076
|
-
[emptyObjectSymbol]?: never;
|
|
1077
|
-
}
|
|
1078
5
|
type DirectiveProps<T extends DirectiveName> = DirectivePropsMap[T];
|
|
1079
6
|
interface NodeProps {
|
|
1080
7
|
node?: {
|
|
1081
8
|
properties?: Record<string, unknown>;
|
|
1082
9
|
};
|
|
1083
10
|
}
|
|
1084
|
-
type DirectiveRenderProps<TName extends DirectiveName, TApplication = undefined, TRequiresApplication extends boolean = true> = DirectiveProps<TName> &
|
|
11
|
+
type DirectiveRenderProps<TName extends DirectiveName, TApplication = undefined, TRequiresApplication extends boolean = true> = DirectiveProps<TName> & {
|
|
12
|
+
isInline: boolean;
|
|
13
|
+
} & (TRequiresApplication extends true ? TApplication extends undefined ? {} : {
|
|
1085
14
|
application: TApplication;
|
|
1086
15
|
} : {});
|
|
1087
16
|
type DirectiveComponentProps<TName extends DirectiveName> = DirectiveProps<TName> & {
|