@xyd-js/content 0.1.0-xyd.4 → 0.1.0-xyd.5

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/index.d.ts CHANGED
@@ -1,1733 +1,8 @@
1
- import * as mdast from 'mdast';
2
- import * as remark_mdx_frontmatter from 'remark-mdx-frontmatter';
3
- import * as unified from 'unified';
4
- import remarkFrontmatter from 'remark-frontmatter';
5
- import remarkGfm from 'remark-gfm';
1
+ import { Sidebar, PageFrontMatter, Header } from '@xyd-js/core';
6
2
 
7
3
  declare function compileBySlug(slug: string, mdx: boolean): Promise<string>;
8
4
 
9
- // ## Interfaces
5
+ declare function pageFrontMatters(navigation: Sidebar[]): Promise<PageFrontMatter>;
6
+ declare function filterNavigationByLevels(headers: Header[], slug: string): (nav: Sidebar) => boolean;
10
7
 
11
- /**
12
- * Info associated with nodes by the ecosystem.
13
- *
14
- * This space is guaranteed to never be specified by unist or specifications
15
- * implementing unist.
16
- * But you can use it in utilities and plugins to store data.
17
- *
18
- * This type can be augmented to register custom data.
19
- * For example:
20
- *
21
- * ```ts
22
- * declare module 'unist' {
23
- * interface Data {
24
- * // `someNode.data.myId` is typed as `number | undefined`
25
- * myId?: number | undefined
26
- * }
27
- * }
28
- * ```
29
- */
30
- interface Data {}
31
-
32
- /**
33
- * One place in a source file.
34
- */
35
- interface Point {
36
- /**
37
- * Line in a source file (1-indexed integer).
38
- */
39
- line: number;
40
-
41
- /**
42
- * Column in a source file (1-indexed integer).
43
- */
44
- column: number;
45
- /**
46
- * Character in a source file (0-indexed integer).
47
- */
48
- offset?: number | undefined;
49
- }
50
-
51
- /**
52
- * Position of a node in a source document.
53
- *
54
- * A position is a range between two points.
55
- */
56
- interface Position$1 {
57
- /**
58
- * Place of the first character of the parsed source region.
59
- */
60
- start: Point;
61
-
62
- /**
63
- * Place of the first character after the parsed source region.
64
- */
65
- end: Point;
66
- }
67
-
68
- /**
69
- * Abstract unist node.
70
- *
71
- * The syntactic unit in unist syntax trees are called nodes.
72
- *
73
- * This interface is supposed to be extended.
74
- * If you can use {@link Literal} or {@link Parent}, you should.
75
- * But for example in markdown, a `thematicBreak` (`***`), is neither literal
76
- * nor parent, but still a node.
77
- */
78
- interface Node$1 {
79
- /**
80
- * Node type.
81
- */
82
- type: string;
83
-
84
- /**
85
- * Info from the ecosystem.
86
- */
87
- data?: Data | undefined;
88
-
89
- /**
90
- * Position of a node in a source document.
91
- *
92
- * Nodes that are generated (not in the original source document) must not
93
- * have a position.
94
- */
95
- position?: Position$1 | undefined;
96
- }
97
-
98
- type CustomTag = {
99
- name: RegExp;
100
- depth: (name: string) => number;
101
- };
102
- interface RemarkMdxTocOptions {
103
- name?: string;
104
- customTags?: CustomTag[];
105
- minDepth?: number;
106
- }
107
-
108
- declare function mdxOptions(toc: RemarkMdxTocOptions): {
109
- remarkPlugins: (unified.Plugin<[], Node$1, Node$1> | typeof remarkFrontmatter | unified.Plugin<[(remark_mdx_frontmatter.RemarkMdxFrontmatterOptions | undefined)?], mdast.Root, mdast.Root> | typeof remarkGfm)[];
110
- rehypePlugins: never[];
111
- };
112
-
113
- // This definition file follows a somewhat unusual format. ESTree allows
114
- // runtime type checks based on the `type` parameter. In order to explain this
115
- // to typescript we want to use discriminated union types:
116
- // https://github.com/Microsoft/TypeScript/pull/9163
117
- //
118
- // For ESTree this is a bit tricky because the high level interfaces like
119
- // Node or Function are pulling double duty. We want to pass common fields down
120
- // to the interfaces that extend them (like Identifier or
121
- // ArrowFunctionExpression), but you can't extend a type union or enforce
122
- // common fields on them. So we've split the high level interfaces into two
123
- // types, a base type which passes down inherited fields, and a type union of
124
- // all types which extend the base type. Only the type union is exported, and
125
- // the union is how other types refer to the collection of inheriting types.
126
- //
127
- // This makes the definitions file here somewhat more difficult to maintain,
128
- // but it has the notable advantage of making ESTree much easier to use as
129
- // an end user.
130
-
131
- interface BaseNodeWithoutComments {
132
- // Every leaf interface that extends BaseNode must specify a type property.
133
- // The type property should be a string literal. For example, Identifier
134
- // has: `type: "Identifier"`
135
- type: string;
136
- loc?: SourceLocation | null | undefined;
137
- range?: [number, number] | undefined;
138
- }
139
-
140
- interface BaseNode extends BaseNodeWithoutComments {
141
- leadingComments?: Comment[] | undefined;
142
- trailingComments?: Comment[] | undefined;
143
- }
144
-
145
- interface NodeMap {
146
- AssignmentProperty: AssignmentProperty;
147
- CatchClause: CatchClause;
148
- Class: Class;
149
- ClassBody: ClassBody;
150
- Expression: Expression;
151
- Function: Function;
152
- Identifier: Identifier;
153
- Literal: Literal;
154
- MethodDefinition: MethodDefinition;
155
- ModuleDeclaration: ModuleDeclaration;
156
- ModuleSpecifier: ModuleSpecifier;
157
- Pattern: Pattern;
158
- PrivateIdentifier: PrivateIdentifier;
159
- Program: Program;
160
- Property: Property;
161
- PropertyDefinition: PropertyDefinition;
162
- SpreadElement: SpreadElement;
163
- Statement: Statement;
164
- Super: Super;
165
- SwitchCase: SwitchCase;
166
- TemplateElement: TemplateElement;
167
- VariableDeclarator: VariableDeclarator;
168
- }
169
-
170
- type Node = NodeMap[keyof NodeMap];
171
-
172
- interface Comment extends BaseNodeWithoutComments {
173
- type: "Line" | "Block";
174
- value: string;
175
- }
176
-
177
- interface SourceLocation {
178
- source?: string | null | undefined;
179
- start: Position;
180
- end: Position;
181
- }
182
-
183
- interface Position {
184
- /** >= 1 */
185
- line: number;
186
- /** >= 0 */
187
- column: number;
188
- }
189
-
190
- interface Program extends BaseNode {
191
- type: "Program";
192
- sourceType: "script" | "module";
193
- body: Array<Directive | Statement | ModuleDeclaration>;
194
- comments?: Comment[] | undefined;
195
- }
196
-
197
- interface Directive extends BaseNode {
198
- type: "ExpressionStatement";
199
- expression: Literal;
200
- directive: string;
201
- }
202
-
203
- interface BaseFunction extends BaseNode {
204
- params: Pattern[];
205
- generator?: boolean | undefined;
206
- async?: boolean | undefined;
207
- // The body is either BlockStatement or Expression because arrow functions
208
- // can have a body that's either. FunctionDeclarations and
209
- // FunctionExpressions have only BlockStatement bodies.
210
- body: BlockStatement | Expression;
211
- }
212
-
213
- type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
214
-
215
- type Statement =
216
- | ExpressionStatement
217
- | BlockStatement
218
- | StaticBlock
219
- | EmptyStatement
220
- | DebuggerStatement
221
- | WithStatement
222
- | ReturnStatement
223
- | LabeledStatement
224
- | BreakStatement
225
- | ContinueStatement
226
- | IfStatement
227
- | SwitchStatement
228
- | ThrowStatement
229
- | TryStatement
230
- | WhileStatement
231
- | DoWhileStatement
232
- | ForStatement
233
- | ForInStatement
234
- | ForOfStatement
235
- | Declaration;
236
-
237
- interface BaseStatement extends BaseNode {}
238
-
239
- interface EmptyStatement extends BaseStatement {
240
- type: "EmptyStatement";
241
- }
242
-
243
- interface BlockStatement extends BaseStatement {
244
- type: "BlockStatement";
245
- body: Statement[];
246
- innerComments?: Comment[] | undefined;
247
- }
248
-
249
- interface StaticBlock extends Omit<BlockStatement, "type"> {
250
- type: "StaticBlock";
251
- }
252
-
253
- interface ExpressionStatement extends BaseStatement {
254
- type: "ExpressionStatement";
255
- expression: Expression;
256
- }
257
-
258
- interface IfStatement extends BaseStatement {
259
- type: "IfStatement";
260
- test: Expression;
261
- consequent: Statement;
262
- alternate?: Statement | null | undefined;
263
- }
264
-
265
- interface LabeledStatement extends BaseStatement {
266
- type: "LabeledStatement";
267
- label: Identifier;
268
- body: Statement;
269
- }
270
-
271
- interface BreakStatement extends BaseStatement {
272
- type: "BreakStatement";
273
- label?: Identifier | null | undefined;
274
- }
275
-
276
- interface ContinueStatement extends BaseStatement {
277
- type: "ContinueStatement";
278
- label?: Identifier | null | undefined;
279
- }
280
-
281
- interface WithStatement extends BaseStatement {
282
- type: "WithStatement";
283
- object: Expression;
284
- body: Statement;
285
- }
286
-
287
- interface SwitchStatement extends BaseStatement {
288
- type: "SwitchStatement";
289
- discriminant: Expression;
290
- cases: SwitchCase[];
291
- }
292
-
293
- interface ReturnStatement extends BaseStatement {
294
- type: "ReturnStatement";
295
- argument?: Expression | null | undefined;
296
- }
297
-
298
- interface ThrowStatement extends BaseStatement {
299
- type: "ThrowStatement";
300
- argument: Expression;
301
- }
302
-
303
- interface TryStatement extends BaseStatement {
304
- type: "TryStatement";
305
- block: BlockStatement;
306
- handler?: CatchClause | null | undefined;
307
- finalizer?: BlockStatement | null | undefined;
308
- }
309
-
310
- interface WhileStatement extends BaseStatement {
311
- type: "WhileStatement";
312
- test: Expression;
313
- body: Statement;
314
- }
315
-
316
- interface DoWhileStatement extends BaseStatement {
317
- type: "DoWhileStatement";
318
- body: Statement;
319
- test: Expression;
320
- }
321
-
322
- interface ForStatement extends BaseStatement {
323
- type: "ForStatement";
324
- init?: VariableDeclaration | Expression | null | undefined;
325
- test?: Expression | null | undefined;
326
- update?: Expression | null | undefined;
327
- body: Statement;
328
- }
329
-
330
- interface BaseForXStatement extends BaseStatement {
331
- left: VariableDeclaration | Pattern;
332
- right: Expression;
333
- body: Statement;
334
- }
335
-
336
- interface ForInStatement extends BaseForXStatement {
337
- type: "ForInStatement";
338
- }
339
-
340
- interface DebuggerStatement extends BaseStatement {
341
- type: "DebuggerStatement";
342
- }
343
-
344
- type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
345
-
346
- interface BaseDeclaration extends BaseStatement {}
347
-
348
- interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
349
- type: "FunctionDeclaration";
350
- /** It is null when a function declaration is a part of the `export default function` statement */
351
- id: Identifier | null;
352
- body: BlockStatement;
353
- }
354
-
355
- interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
356
- id: Identifier;
357
- }
358
-
359
- interface VariableDeclaration extends BaseDeclaration {
360
- type: "VariableDeclaration";
361
- declarations: VariableDeclarator[];
362
- kind: "var" | "let" | "const";
363
- }
364
-
365
- interface VariableDeclarator extends BaseNode {
366
- type: "VariableDeclarator";
367
- id: Pattern;
368
- init?: Expression | null | undefined;
369
- }
370
-
371
- interface ExpressionMap {
372
- ArrayExpression: ArrayExpression;
373
- ArrowFunctionExpression: ArrowFunctionExpression;
374
- AssignmentExpression: AssignmentExpression;
375
- AwaitExpression: AwaitExpression;
376
- BinaryExpression: BinaryExpression;
377
- CallExpression: CallExpression;
378
- ChainExpression: ChainExpression;
379
- ClassExpression: ClassExpression;
380
- ConditionalExpression: ConditionalExpression;
381
- FunctionExpression: FunctionExpression;
382
- Identifier: Identifier;
383
- ImportExpression: ImportExpression;
384
- Literal: Literal;
385
- LogicalExpression: LogicalExpression;
386
- MemberExpression: MemberExpression;
387
- MetaProperty: MetaProperty;
388
- NewExpression: NewExpression;
389
- ObjectExpression: ObjectExpression;
390
- SequenceExpression: SequenceExpression;
391
- TaggedTemplateExpression: TaggedTemplateExpression;
392
- TemplateLiteral: TemplateLiteral;
393
- ThisExpression: ThisExpression;
394
- UnaryExpression: UnaryExpression;
395
- UpdateExpression: UpdateExpression;
396
- YieldExpression: YieldExpression;
397
- }
398
-
399
- type Expression = ExpressionMap[keyof ExpressionMap];
400
-
401
- interface BaseExpression extends BaseNode {}
402
-
403
- type ChainElement = SimpleCallExpression | MemberExpression;
404
-
405
- interface ChainExpression extends BaseExpression {
406
- type: "ChainExpression";
407
- expression: ChainElement;
408
- }
409
-
410
- interface ThisExpression extends BaseExpression {
411
- type: "ThisExpression";
412
- }
413
-
414
- interface ArrayExpression extends BaseExpression {
415
- type: "ArrayExpression";
416
- elements: Array<Expression | SpreadElement | null>;
417
- }
418
-
419
- interface ObjectExpression extends BaseExpression {
420
- type: "ObjectExpression";
421
- properties: Array<Property | SpreadElement>;
422
- }
423
-
424
- interface PrivateIdentifier extends BaseNode {
425
- type: "PrivateIdentifier";
426
- name: string;
427
- }
428
-
429
- interface Property extends BaseNode {
430
- type: "Property";
431
- key: Expression | PrivateIdentifier;
432
- value: Expression | Pattern; // Could be an AssignmentProperty
433
- kind: "init" | "get" | "set";
434
- method: boolean;
435
- shorthand: boolean;
436
- computed: boolean;
437
- }
438
-
439
- interface PropertyDefinition extends BaseNode {
440
- type: "PropertyDefinition";
441
- key: Expression | PrivateIdentifier;
442
- value?: Expression | null | undefined;
443
- computed: boolean;
444
- static: boolean;
445
- }
446
-
447
- interface FunctionExpression extends BaseFunction, BaseExpression {
448
- id?: Identifier | null | undefined;
449
- type: "FunctionExpression";
450
- body: BlockStatement;
451
- }
452
-
453
- interface SequenceExpression extends BaseExpression {
454
- type: "SequenceExpression";
455
- expressions: Expression[];
456
- }
457
-
458
- interface UnaryExpression extends BaseExpression {
459
- type: "UnaryExpression";
460
- operator: UnaryOperator;
461
- prefix: true;
462
- argument: Expression;
463
- }
464
-
465
- interface BinaryExpression extends BaseExpression {
466
- type: "BinaryExpression";
467
- operator: BinaryOperator;
468
- left: Expression | PrivateIdentifier;
469
- right: Expression;
470
- }
471
-
472
- interface AssignmentExpression extends BaseExpression {
473
- type: "AssignmentExpression";
474
- operator: AssignmentOperator;
475
- left: Pattern | MemberExpression;
476
- right: Expression;
477
- }
478
-
479
- interface UpdateExpression extends BaseExpression {
480
- type: "UpdateExpression";
481
- operator: UpdateOperator;
482
- argument: Expression;
483
- prefix: boolean;
484
- }
485
-
486
- interface LogicalExpression extends BaseExpression {
487
- type: "LogicalExpression";
488
- operator: LogicalOperator;
489
- left: Expression;
490
- right: Expression;
491
- }
492
-
493
- interface ConditionalExpression extends BaseExpression {
494
- type: "ConditionalExpression";
495
- test: Expression;
496
- alternate: Expression;
497
- consequent: Expression;
498
- }
499
-
500
- interface BaseCallExpression extends BaseExpression {
501
- callee: Expression | Super;
502
- arguments: Array<Expression | SpreadElement>;
503
- }
504
- type CallExpression = SimpleCallExpression | NewExpression;
505
-
506
- interface SimpleCallExpression extends BaseCallExpression {
507
- type: "CallExpression";
508
- optional: boolean;
509
- }
510
-
511
- interface NewExpression extends BaseCallExpression {
512
- type: "NewExpression";
513
- }
514
-
515
- interface MemberExpression extends BaseExpression, BasePattern {
516
- type: "MemberExpression";
517
- object: Expression | Super;
518
- property: Expression | PrivateIdentifier;
519
- computed: boolean;
520
- optional: boolean;
521
- }
522
-
523
- type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
524
-
525
- interface BasePattern extends BaseNode {}
526
-
527
- interface SwitchCase extends BaseNode {
528
- type: "SwitchCase";
529
- test?: Expression | null | undefined;
530
- consequent: Statement[];
531
- }
532
-
533
- interface CatchClause extends BaseNode {
534
- type: "CatchClause";
535
- param: Pattern | null;
536
- body: BlockStatement;
537
- }
538
-
539
- interface Identifier extends BaseNode, BaseExpression, BasePattern {
540
- type: "Identifier";
541
- name: string;
542
- }
543
-
544
- type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
545
-
546
- interface SimpleLiteral extends BaseNode, BaseExpression {
547
- type: "Literal";
548
- value: string | boolean | number | null;
549
- raw?: string | undefined;
550
- }
551
-
552
- interface RegExpLiteral extends BaseNode, BaseExpression {
553
- type: "Literal";
554
- value?: RegExp | null | undefined;
555
- regex: {
556
- pattern: string;
557
- flags: string;
558
- };
559
- raw?: string | undefined;
560
- }
561
-
562
- interface BigIntLiteral extends BaseNode, BaseExpression {
563
- type: "Literal";
564
- value?: bigint | null | undefined;
565
- bigint: string;
566
- raw?: string | undefined;
567
- }
568
-
569
- type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
570
-
571
- type BinaryOperator =
572
- | "=="
573
- | "!="
574
- | "==="
575
- | "!=="
576
- | "<"
577
- | "<="
578
- | ">"
579
- | ">="
580
- | "<<"
581
- | ">>"
582
- | ">>>"
583
- | "+"
584
- | "-"
585
- | "*"
586
- | "/"
587
- | "%"
588
- | "**"
589
- | "|"
590
- | "^"
591
- | "&"
592
- | "in"
593
- | "instanceof";
594
-
595
- type LogicalOperator = "||" | "&&" | "??";
596
-
597
- type AssignmentOperator =
598
- | "="
599
- | "+="
600
- | "-="
601
- | "*="
602
- | "/="
603
- | "%="
604
- | "**="
605
- | "<<="
606
- | ">>="
607
- | ">>>="
608
- | "|="
609
- | "^="
610
- | "&="
611
- | "||="
612
- | "&&="
613
- | "??=";
614
-
615
- type UpdateOperator = "++" | "--";
616
-
617
- interface ForOfStatement extends BaseForXStatement {
618
- type: "ForOfStatement";
619
- await: boolean;
620
- }
621
-
622
- interface Super extends BaseNode {
623
- type: "Super";
624
- }
625
-
626
- interface SpreadElement extends BaseNode {
627
- type: "SpreadElement";
628
- argument: Expression;
629
- }
630
-
631
- interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
632
- type: "ArrowFunctionExpression";
633
- expression: boolean;
634
- body: BlockStatement | Expression;
635
- }
636
-
637
- interface YieldExpression extends BaseExpression {
638
- type: "YieldExpression";
639
- argument?: Expression | null | undefined;
640
- delegate: boolean;
641
- }
642
-
643
- interface TemplateLiteral extends BaseExpression {
644
- type: "TemplateLiteral";
645
- quasis: TemplateElement[];
646
- expressions: Expression[];
647
- }
648
-
649
- interface TaggedTemplateExpression extends BaseExpression {
650
- type: "TaggedTemplateExpression";
651
- tag: Expression;
652
- quasi: TemplateLiteral;
653
- }
654
-
655
- interface TemplateElement extends BaseNode {
656
- type: "TemplateElement";
657
- tail: boolean;
658
- value: {
659
- /** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
660
- cooked?: string | null | undefined;
661
- raw: string;
662
- };
663
- }
664
-
665
- interface AssignmentProperty extends Property {
666
- value: Pattern;
667
- kind: "init";
668
- method: boolean; // false
669
- }
670
-
671
- interface ObjectPattern extends BasePattern {
672
- type: "ObjectPattern";
673
- properties: Array<AssignmentProperty | RestElement>;
674
- }
675
-
676
- interface ArrayPattern extends BasePattern {
677
- type: "ArrayPattern";
678
- elements: Array<Pattern | null>;
679
- }
680
-
681
- interface RestElement extends BasePattern {
682
- type: "RestElement";
683
- argument: Pattern;
684
- }
685
-
686
- interface AssignmentPattern extends BasePattern {
687
- type: "AssignmentPattern";
688
- left: Pattern;
689
- right: Expression;
690
- }
691
-
692
- type Class = ClassDeclaration | ClassExpression;
693
- interface BaseClass extends BaseNode {
694
- superClass?: Expression | null | undefined;
695
- body: ClassBody;
696
- }
697
-
698
- interface ClassBody extends BaseNode {
699
- type: "ClassBody";
700
- body: Array<MethodDefinition | PropertyDefinition | StaticBlock>;
701
- }
702
-
703
- interface MethodDefinition extends BaseNode {
704
- type: "MethodDefinition";
705
- key: Expression | PrivateIdentifier;
706
- value: FunctionExpression;
707
- kind: "constructor" | "method" | "get" | "set";
708
- computed: boolean;
709
- static: boolean;
710
- }
711
-
712
- interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
713
- type: "ClassDeclaration";
714
- /** It is null when a class declaration is a part of the `export default class` statement */
715
- id: Identifier | null;
716
- }
717
-
718
- interface ClassDeclaration extends MaybeNamedClassDeclaration {
719
- id: Identifier;
720
- }
721
-
722
- interface ClassExpression extends BaseClass, BaseExpression {
723
- type: "ClassExpression";
724
- id?: Identifier | null | undefined;
725
- }
726
-
727
- interface MetaProperty extends BaseExpression {
728
- type: "MetaProperty";
729
- meta: Identifier;
730
- property: Identifier;
731
- }
732
-
733
- type ModuleDeclaration =
734
- | ImportDeclaration
735
- | ExportNamedDeclaration
736
- | ExportDefaultDeclaration
737
- | ExportAllDeclaration;
738
- interface BaseModuleDeclaration extends BaseNode {}
739
-
740
- type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
741
- interface BaseModuleSpecifier extends BaseNode {
742
- local: Identifier;
743
- }
744
-
745
- interface ImportDeclaration extends BaseModuleDeclaration {
746
- type: "ImportDeclaration";
747
- specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
748
- source: Literal;
749
- }
750
-
751
- interface ImportSpecifier extends BaseModuleSpecifier {
752
- type: "ImportSpecifier";
753
- imported: Identifier | Literal;
754
- }
755
-
756
- interface ImportExpression extends BaseExpression {
757
- type: "ImportExpression";
758
- source: Expression;
759
- }
760
-
761
- interface ImportDefaultSpecifier extends BaseModuleSpecifier {
762
- type: "ImportDefaultSpecifier";
763
- }
764
-
765
- interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
766
- type: "ImportNamespaceSpecifier";
767
- }
768
-
769
- interface ExportNamedDeclaration extends BaseModuleDeclaration {
770
- type: "ExportNamedDeclaration";
771
- declaration?: Declaration | null | undefined;
772
- specifiers: ExportSpecifier[];
773
- source?: Literal | null | undefined;
774
- }
775
-
776
- interface ExportSpecifier extends Omit<BaseModuleSpecifier, "local"> {
777
- type: "ExportSpecifier";
778
- local: Identifier | Literal;
779
- exported: Identifier | Literal;
780
- }
781
-
782
- interface ExportDefaultDeclaration extends BaseModuleDeclaration {
783
- type: "ExportDefaultDeclaration";
784
- declaration: MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | Expression;
785
- }
786
-
787
- interface ExportAllDeclaration extends BaseModuleDeclaration {
788
- type: "ExportAllDeclaration";
789
- exported: Identifier | Literal | null;
790
- source: Literal;
791
- }
792
-
793
- interface AwaitExpression extends BaseExpression {
794
- type: "AwaitExpression";
795
- argument: Expression;
796
- }
797
-
798
- declare module 'estree' {
799
- export interface Decorator extends BaseNode {
800
- type: 'Decorator';
801
- expression: Expression;
802
- }
803
- interface PropertyDefinition {
804
- decorators: undefined[];
805
- }
806
- interface MethodDefinition {
807
- decorators: undefined[];
808
- }
809
- interface BaseClass {
810
- decorators: undefined[];
811
- }
812
- }
813
-
814
- // utils
815
- type NullValue = null | undefined | void;
816
- type MaybePromise<T> = T | Promise<T>;
817
-
818
- type PartialNull<T> = {
819
- [P in keyof T]: T[P] | null;
820
- };
821
-
822
- interface RollupError extends RollupLog {
823
- name?: string;
824
- stack?: string;
825
- watchFiles?: string[];
826
- }
827
-
828
- interface RollupLog {
829
- binding?: string;
830
- cause?: unknown;
831
- code?: string;
832
- exporter?: string;
833
- frame?: string;
834
- hook?: string;
835
- id?: string;
836
- ids?: string[];
837
- loc?: {
838
- column: number;
839
- file?: string;
840
- line: number;
841
- };
842
- message: string;
843
- meta?: any;
844
- names?: string[];
845
- plugin?: string;
846
- pluginCode?: unknown;
847
- pos?: number;
848
- reexporter?: string;
849
- stack?: string;
850
- url?: string;
851
- }
852
-
853
- type LogLevel = 'warn' | 'info' | 'debug';
854
- type LogLevelOption = LogLevel | 'silent';
855
-
856
- type SourceMapSegment =
857
- | [number]
858
- | [number, number, number, number]
859
- | [number, number, number, number, number];
860
-
861
- interface ExistingDecodedSourceMap {
862
- file?: string;
863
- readonly mappings: SourceMapSegment[][];
864
- names: string[];
865
- sourceRoot?: string;
866
- sources: string[];
867
- sourcesContent?: string[];
868
- version: number;
869
- x_google_ignoreList?: number[];
870
- }
871
-
872
- interface ExistingRawSourceMap {
873
- file?: string;
874
- mappings: string;
875
- names: string[];
876
- sourceRoot?: string;
877
- sources: string[];
878
- sourcesContent?: string[];
879
- version: number;
880
- x_google_ignoreList?: number[];
881
- }
882
-
883
- type DecodedSourceMapOrMissing =
884
- | {
885
- missing: true;
886
- plugin: string;
887
- }
888
- | (ExistingDecodedSourceMap & { missing?: false });
889
-
890
- interface SourceMap {
891
- file: string;
892
- mappings: string;
893
- names: string[];
894
- sources: string[];
895
- sourcesContent?: string[];
896
- version: number;
897
- debugId?: string;
898
- toString(): string;
899
- toUrl(): string;
900
- }
901
-
902
- type SourceMapInput = ExistingRawSourceMap | string | null | { mappings: '' };
903
-
904
- interface ModuleOptions {
905
- attributes: Record<string, string>;
906
- meta: CustomPluginOptions;
907
- moduleSideEffects: boolean | 'no-treeshake';
908
- syntheticNamedExports: boolean | string;
909
- }
910
-
911
- interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
912
- ast?: ProgramNode;
913
- code: string;
914
- map?: SourceMapInput;
915
- }
916
-
917
- interface TransformModuleJSON {
918
- ast?: ProgramNode;
919
- code: string;
920
- // note if plugins use new this.cache to opt-out auto transform cache
921
- customTransformCache: boolean;
922
- originalCode: string;
923
- originalSourcemap: ExistingDecodedSourceMap | null;
924
- sourcemapChain: DecodedSourceMapOrMissing[];
925
- transformDependencies: string[];
926
- }
927
-
928
- interface ModuleJSON extends TransformModuleJSON, ModuleOptions {
929
- ast: ProgramNode;
930
- dependencies: string[];
931
- id: string;
932
- resolvedIds: ResolvedIdMap;
933
- transformFiles: EmittedFile[] | undefined;
934
- }
935
-
936
- interface PluginCache {
937
- delete(id: string): boolean;
938
- get<T = any>(id: string): T;
939
- has(id: string): boolean;
940
- set<T = any>(id: string, value: T): void;
941
- }
942
-
943
- type LoggingFunction = (log: RollupLog | string | (() => RollupLog | string)) => void;
944
-
945
- interface MinimalPluginContext {
946
- debug: LoggingFunction;
947
- error: (error: RollupError | string) => never;
948
- info: LoggingFunction;
949
- meta: PluginContextMeta;
950
- warn: LoggingFunction;
951
- }
952
-
953
- interface EmittedAsset {
954
- fileName?: string;
955
- name?: string;
956
- needsCodeReference?: boolean;
957
- originalFileName?: string | null;
958
- source?: string | Uint8Array;
959
- type: 'asset';
960
- }
961
-
962
- interface EmittedChunk {
963
- fileName?: string;
964
- id: string;
965
- implicitlyLoadedAfterOneOf?: string[];
966
- importer?: string;
967
- name?: string;
968
- preserveSignature?: PreserveEntrySignaturesOption;
969
- type: 'chunk';
970
- }
971
-
972
- interface EmittedPrebuiltChunk {
973
- code: string;
974
- exports?: string[];
975
- fileName: string;
976
- map?: SourceMap;
977
- sourcemapFileName?: string;
978
- type: 'prebuilt-chunk';
979
- }
980
-
981
- type EmittedFile = EmittedAsset | EmittedChunk | EmittedPrebuiltChunk;
982
-
983
- type EmitFile = (emittedFile: EmittedFile) => string;
984
-
985
- interface ModuleInfo extends ModuleOptions {
986
- ast: ProgramNode | null;
987
- code: string | null;
988
- dynamicImporters: readonly string[];
989
- dynamicallyImportedIdResolutions: readonly ResolvedId[];
990
- dynamicallyImportedIds: readonly string[];
991
- exportedBindings: Record<string, string[]> | null;
992
- exports: string[] | null;
993
- hasDefaultExport: boolean | null;
994
- id: string;
995
- implicitlyLoadedAfterOneOf: readonly string[];
996
- implicitlyLoadedBefore: readonly string[];
997
- importedIdResolutions: readonly ResolvedId[];
998
- importedIds: readonly string[];
999
- importers: readonly string[];
1000
- isEntry: boolean;
1001
- isExternal: boolean;
1002
- isIncluded: boolean | null;
1003
- }
1004
-
1005
- type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
1006
-
1007
- type CustomPluginOptions = Record<string, any>;
1008
-
1009
- type LoggingFunctionWithPosition = (
1010
- log: RollupLog | string | (() => RollupLog | string),
1011
- pos?: number | { column: number; line: number }
1012
- ) => void;
1013
-
1014
- type ParseAst = (
1015
- input: string,
1016
- options?: { allowReturnOutsideFunction?: boolean; jsx?: boolean }
1017
- ) => ProgramNode;
1018
-
1019
- // declare AbortSignal here for environments without DOM lib or @types/node
1020
- declare global {
1021
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
1022
- interface AbortSignal {}
1023
- }
1024
-
1025
- interface PluginContext extends MinimalPluginContext {
1026
- addWatchFile: (id: string) => void;
1027
- cache: PluginCache;
1028
- debug: LoggingFunction;
1029
- emitFile: EmitFile;
1030
- error: (error: RollupError | string) => never;
1031
- getFileName: (fileReferenceId: string) => string;
1032
- getModuleIds: () => IterableIterator<string>;
1033
- getModuleInfo: GetModuleInfo;
1034
- getWatchFiles: () => string[];
1035
- info: LoggingFunction;
1036
- load: (
1037
- options: { id: string; resolveDependencies?: boolean } & Partial<PartialNull<ModuleOptions>>
1038
- ) => Promise<ModuleInfo>;
1039
- parse: ParseAst;
1040
- resolve: (
1041
- source: string,
1042
- importer?: string,
1043
- options?: {
1044
- attributes?: Record<string, string>;
1045
- custom?: CustomPluginOptions;
1046
- isEntry?: boolean;
1047
- skipSelf?: boolean;
1048
- }
1049
- ) => Promise<ResolvedId | null>;
1050
- setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
1051
- warn: LoggingFunction;
1052
- }
1053
-
1054
- interface PluginContextMeta {
1055
- rollupVersion: string;
1056
- watchMode: boolean;
1057
- }
1058
-
1059
- interface ResolvedId extends ModuleOptions {
1060
- external: boolean | 'absolute';
1061
- id: string;
1062
- resolvedBy: string;
1063
- }
1064
-
1065
- type ResolvedIdMap = Record<string, ResolvedId>;
1066
-
1067
- interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
1068
- external?: boolean | 'absolute' | 'relative';
1069
- id: string;
1070
- resolvedBy?: string;
1071
- }
1072
-
1073
- type ResolveIdResult = string | NullValue | false | PartialResolvedId;
1074
-
1075
- type ResolveIdHook = (
1076
- this: PluginContext,
1077
- source: string,
1078
- importer: string | undefined,
1079
- options: { attributes: Record<string, string>; custom?: CustomPluginOptions; isEntry: boolean }
1080
- ) => ResolveIdResult;
1081
-
1082
- type ShouldTransformCachedModuleHook = (
1083
- this: PluginContext,
1084
- options: {
1085
- ast: ProgramNode;
1086
- code: string;
1087
- id: string;
1088
- meta: CustomPluginOptions;
1089
- moduleSideEffects: boolean | 'no-treeshake';
1090
- resolvedSources: ResolvedIdMap;
1091
- syntheticNamedExports: boolean | string;
1092
- }
1093
- ) => boolean | NullValue;
1094
-
1095
- type IsExternal = (
1096
- source: string,
1097
- importer: string | undefined,
1098
- isResolved: boolean
1099
- ) => boolean;
1100
-
1101
- type HasModuleSideEffects = (id: string, external: boolean) => boolean;
1102
-
1103
- type LoadResult = SourceDescription | string | NullValue;
1104
-
1105
- type LoadHook = (this: PluginContext, id: string) => LoadResult;
1106
-
1107
- interface TransformPluginContext extends PluginContext {
1108
- debug: LoggingFunctionWithPosition;
1109
- error: (error: RollupError | string, pos?: number | { column: number; line: number }) => never;
1110
- getCombinedSourcemap: () => SourceMap;
1111
- info: LoggingFunctionWithPosition;
1112
- warn: LoggingFunctionWithPosition;
1113
- }
1114
-
1115
- type TransformResult = string | NullValue | Partial<SourceDescription>;
1116
-
1117
- type TransformHook = (
1118
- this: TransformPluginContext,
1119
- code: string,
1120
- id: string
1121
- ) => TransformResult;
1122
-
1123
- type ModuleParsedHook = (this: PluginContext, info: ModuleInfo) => void;
1124
-
1125
- type RenderChunkHook = (
1126
- this: PluginContext,
1127
- code: string,
1128
- chunk: RenderedChunk,
1129
- options: NormalizedOutputOptions,
1130
- meta: { chunks: Record<string, RenderedChunk> }
1131
- ) => { code: string; map?: SourceMapInput } | string | NullValue;
1132
-
1133
- type ResolveDynamicImportHook = (
1134
- this: PluginContext,
1135
- specifier: string | AstNode,
1136
- importer: string,
1137
- options: { attributes: Record<string, string> }
1138
- ) => ResolveIdResult;
1139
-
1140
- type ResolveImportMetaHook = (
1141
- this: PluginContext,
1142
- property: string | null,
1143
- options: { chunkId: string; format: InternalModuleFormat; moduleId: string }
1144
- ) => string | NullValue;
1145
-
1146
- type ResolveFileUrlHook = (
1147
- this: PluginContext,
1148
- options: {
1149
- chunkId: string;
1150
- fileName: string;
1151
- format: InternalModuleFormat;
1152
- moduleId: string;
1153
- referenceId: string;
1154
- relativePath: string;
1155
- }
1156
- ) => string | NullValue;
1157
-
1158
- type AddonHookFunction = (
1159
- this: PluginContext,
1160
- chunk: RenderedChunk
1161
- ) => string | Promise<string>;
1162
- type AddonHook = string | AddonHookFunction;
1163
-
1164
- type ChangeEvent = 'create' | 'update' | 'delete';
1165
- type WatchChangeHook = (
1166
- this: PluginContext,
1167
- id: string,
1168
- change: { event: ChangeEvent }
1169
- ) => void;
1170
-
1171
- type OutputBundle = Record<string, OutputAsset | OutputChunk>;
1172
-
1173
- interface FunctionPluginHooks {
1174
- augmentChunkHash: (this: PluginContext, chunk: RenderedChunk) => string | void;
1175
- buildEnd: (this: PluginContext, error?: Error) => void;
1176
- buildStart: (this: PluginContext, options: NormalizedInputOptions) => void;
1177
- closeBundle: (this: PluginContext) => void;
1178
- closeWatcher: (this: PluginContext) => void;
1179
- generateBundle: (
1180
- this: PluginContext,
1181
- options: NormalizedOutputOptions,
1182
- bundle: OutputBundle,
1183
- isWrite: boolean
1184
- ) => void;
1185
- load: LoadHook;
1186
- moduleParsed: ModuleParsedHook;
1187
- onLog: (this: MinimalPluginContext, level: LogLevel, log: RollupLog) => boolean | NullValue;
1188
- options: (this: MinimalPluginContext, options: InputOptions) => InputOptions | NullValue;
1189
- outputOptions: (this: PluginContext, options: OutputOptions) => OutputOptions | NullValue;
1190
- renderChunk: RenderChunkHook;
1191
- renderDynamicImport: (
1192
- this: PluginContext,
1193
- options: {
1194
- customResolution: string | null;
1195
- format: InternalModuleFormat;
1196
- moduleId: string;
1197
- targetModuleId: string | null;
1198
- }
1199
- ) => { left: string; right: string } | NullValue;
1200
- renderError: (this: PluginContext, error?: Error) => void;
1201
- renderStart: (
1202
- this: PluginContext,
1203
- outputOptions: NormalizedOutputOptions,
1204
- inputOptions: NormalizedInputOptions
1205
- ) => void;
1206
- resolveDynamicImport: ResolveDynamicImportHook;
1207
- resolveFileUrl: ResolveFileUrlHook;
1208
- resolveId: ResolveIdHook;
1209
- resolveImportMeta: ResolveImportMetaHook;
1210
- shouldTransformCachedModule: ShouldTransformCachedModuleHook;
1211
- transform: TransformHook;
1212
- watchChange: WatchChangeHook;
1213
- writeBundle: (
1214
- this: PluginContext,
1215
- options: NormalizedOutputOptions,
1216
- bundle: OutputBundle
1217
- ) => void;
1218
- }
1219
-
1220
- type OutputPluginHooks =
1221
- | 'augmentChunkHash'
1222
- | 'generateBundle'
1223
- | 'outputOptions'
1224
- | 'renderChunk'
1225
- | 'renderDynamicImport'
1226
- | 'renderError'
1227
- | 'renderStart'
1228
- | 'resolveFileUrl'
1229
- | 'resolveImportMeta'
1230
- | 'writeBundle';
1231
-
1232
- type SyncPluginHooks =
1233
- | 'augmentChunkHash'
1234
- | 'onLog'
1235
- | 'outputOptions'
1236
- | 'renderDynamicImport'
1237
- | 'resolveFileUrl'
1238
- | 'resolveImportMeta';
1239
-
1240
- type AsyncPluginHooks = Exclude<keyof FunctionPluginHooks, SyncPluginHooks>;
1241
-
1242
- type FirstPluginHooks =
1243
- | 'load'
1244
- | 'renderDynamicImport'
1245
- | 'resolveDynamicImport'
1246
- | 'resolveFileUrl'
1247
- | 'resolveId'
1248
- | 'resolveImportMeta'
1249
- | 'shouldTransformCachedModule';
1250
-
1251
- type SequentialPluginHooks =
1252
- | 'augmentChunkHash'
1253
- | 'generateBundle'
1254
- | 'onLog'
1255
- | 'options'
1256
- | 'outputOptions'
1257
- | 'renderChunk'
1258
- | 'transform';
1259
-
1260
- type ParallelPluginHooks = Exclude<
1261
- keyof FunctionPluginHooks | AddonHooks,
1262
- FirstPluginHooks | SequentialPluginHooks
1263
- >;
1264
-
1265
- type AddonHooks = 'banner' | 'footer' | 'intro' | 'outro';
1266
-
1267
- type MakeAsync<Function_> = Function_ extends (
1268
- this: infer This,
1269
- ...parameters: infer Arguments
1270
- ) => infer Return
1271
- ? (this: This, ...parameters: Arguments) => Return | Promise<Return>
1272
- : never;
1273
-
1274
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
1275
- type ObjectHook<T, O = {}> = T | ({ handler: T; order?: 'pre' | 'post' | null } & O);
1276
-
1277
- type PluginHooks = {
1278
- [K in keyof FunctionPluginHooks]: ObjectHook<
1279
- K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K],
1280
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
1281
- K extends ParallelPluginHooks ? { sequential?: boolean } : {}
1282
- >;
1283
- };
1284
-
1285
- interface OutputPlugin
1286
- extends Partial<{ [K in OutputPluginHooks]: PluginHooks[K] }>,
1287
- Partial<Record<AddonHooks, ObjectHook<AddonHook>>> {
1288
- cacheKey?: string;
1289
- name: string;
1290
- version?: string;
1291
- }
1292
-
1293
- interface Plugin<A = any> extends OutputPlugin, Partial<PluginHooks> {
1294
- // for inter-plugin communication
1295
- api?: A;
1296
- }
1297
-
1298
- type JsxPreset = 'react' | 'react-jsx' | 'preserve' | 'preserve-react';
1299
-
1300
- type NormalizedJsxOptions =
1301
- | NormalizedJsxPreserveOptions
1302
- | NormalizedJsxClassicOptions
1303
- | NormalizedJsxAutomaticOptions;
1304
-
1305
- interface NormalizedJsxPreserveOptions {
1306
- factory: string | null;
1307
- fragment: string | null;
1308
- importSource: string | null;
1309
- mode: 'preserve';
1310
- }
1311
-
1312
- interface NormalizedJsxClassicOptions {
1313
- factory: string;
1314
- fragment: string;
1315
- importSource: string | null;
1316
- mode: 'classic';
1317
- }
1318
-
1319
- interface NormalizedJsxAutomaticOptions {
1320
- factory: string;
1321
- importSource: string | null;
1322
- jsxImportSource: string;
1323
- mode: 'automatic';
1324
- }
1325
-
1326
- type JsxOptions = Partial<NormalizedJsxOptions> & {
1327
- preset?: JsxPreset;
1328
- };
1329
-
1330
- type TreeshakingPreset = 'smallest' | 'safest' | 'recommended';
1331
-
1332
- interface NormalizedTreeshakingOptions {
1333
- annotations: boolean;
1334
- correctVarValueBeforeDeclaration: boolean;
1335
- manualPureFunctions: readonly string[];
1336
- moduleSideEffects: HasModuleSideEffects;
1337
- propertyReadSideEffects: boolean | 'always';
1338
- tryCatchDeoptimization: boolean;
1339
- unknownGlobalSideEffects: boolean;
1340
- }
1341
-
1342
- interface TreeshakingOptions
1343
- extends Partial<Omit<NormalizedTreeshakingOptions, 'moduleSideEffects'>> {
1344
- moduleSideEffects?: ModuleSideEffectsOption;
1345
- preset?: TreeshakingPreset;
1346
- }
1347
-
1348
- interface ManualChunkMeta {
1349
- getModuleIds: () => IterableIterator<string>;
1350
- getModuleInfo: GetModuleInfo;
1351
- }
1352
-
1353
- type GetManualChunk = (id: string, meta: ManualChunkMeta) => string | NullValue;
1354
-
1355
- type ExternalOption =
1356
- | (string | RegExp)[]
1357
- | string
1358
- | RegExp
1359
- | ((source: string, importer: string | undefined, isResolved: boolean) => boolean | NullValue);
1360
-
1361
- type GlobalsOption = Record<string, string> | ((name: string) => string);
1362
-
1363
- type InputOption = string | string[] | Record<string, string>;
1364
-
1365
- type ManualChunksOption = Record<string, string[]> | GetManualChunk;
1366
-
1367
- type LogHandlerWithDefault = (
1368
- level: LogLevel,
1369
- log: RollupLog,
1370
- defaultHandler: LogOrStringHandler
1371
- ) => void;
1372
-
1373
- type LogOrStringHandler = (level: LogLevel | 'error', log: RollupLog | string) => void;
1374
-
1375
- type LogHandler = (level: LogLevel, log: RollupLog) => void;
1376
-
1377
- type ModuleSideEffectsOption = boolean | 'no-external' | string[] | HasModuleSideEffects;
1378
-
1379
- type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
1380
-
1381
- type SourcemapPathTransformOption = (
1382
- relativeSourcePath: string,
1383
- sourcemapPath: string
1384
- ) => string;
1385
-
1386
- type SourcemapIgnoreListOption = (
1387
- relativeSourcePath: string,
1388
- sourcemapPath: string
1389
- ) => boolean;
1390
-
1391
- type InputPluginOption = MaybePromise<Plugin | NullValue | false | InputPluginOption[]>;
1392
-
1393
- interface InputOptions {
1394
- cache?: boolean | RollupCache;
1395
- context?: string;
1396
- experimentalCacheExpiry?: number;
1397
- experimentalLogSideEffects?: boolean;
1398
- external?: ExternalOption;
1399
- input?: InputOption;
1400
- jsx?: false | JsxPreset | JsxOptions;
1401
- logLevel?: LogLevelOption;
1402
- makeAbsoluteExternalsRelative?: boolean | 'ifRelativeSource';
1403
- maxParallelFileOps?: number;
1404
- moduleContext?: ((id: string) => string | NullValue) | Record<string, string>;
1405
- onLog?: LogHandlerWithDefault;
1406
- onwarn?: WarningHandlerWithDefault;
1407
- perf?: boolean;
1408
- plugins?: InputPluginOption;
1409
- preserveEntrySignatures?: PreserveEntrySignaturesOption;
1410
- preserveSymlinks?: boolean;
1411
- shimMissingExports?: boolean;
1412
- strictDeprecations?: boolean;
1413
- treeshake?: boolean | TreeshakingPreset | TreeshakingOptions;
1414
- watch?: WatcherOptions | false;
1415
- }
1416
-
1417
- interface NormalizedInputOptions {
1418
- cache: false | undefined | RollupCache;
1419
- context: string;
1420
- experimentalCacheExpiry: number;
1421
- experimentalLogSideEffects: boolean;
1422
- external: IsExternal;
1423
- input: string[] | Record<string, string>;
1424
- jsx: false | NormalizedJsxOptions;
1425
- logLevel: LogLevelOption;
1426
- makeAbsoluteExternalsRelative: boolean | 'ifRelativeSource';
1427
- maxParallelFileOps: number;
1428
- moduleContext: (id: string) => string;
1429
- onLog: LogHandler;
1430
- perf: boolean;
1431
- plugins: Plugin[];
1432
- preserveEntrySignatures: PreserveEntrySignaturesOption;
1433
- preserveSymlinks: boolean;
1434
- shimMissingExports: boolean;
1435
- strictDeprecations: boolean;
1436
- treeshake: false | NormalizedTreeshakingOptions;
1437
- }
1438
-
1439
- type InternalModuleFormat = 'amd' | 'cjs' | 'es' | 'iife' | 'system' | 'umd';
1440
- type ImportAttributesKey = 'with' | 'assert';
1441
-
1442
- type ModuleFormat = InternalModuleFormat | 'commonjs' | 'esm' | 'module' | 'systemjs';
1443
-
1444
- type GeneratedCodePreset = 'es5' | 'es2015';
1445
-
1446
- interface NormalizedGeneratedCodeOptions {
1447
- arrowFunctions: boolean;
1448
- constBindings: boolean;
1449
- objectShorthand: boolean;
1450
- reservedNamesAsProps: boolean;
1451
- symbols: boolean;
1452
- }
1453
-
1454
- interface GeneratedCodeOptions extends Partial<NormalizedGeneratedCodeOptions> {
1455
- preset?: GeneratedCodePreset;
1456
- }
1457
-
1458
- type OptionsPaths = Record<string, string> | ((id: string) => string);
1459
-
1460
- type InteropType = 'compat' | 'auto' | 'esModule' | 'default' | 'defaultOnly';
1461
-
1462
- type GetInterop = (id: string | null) => InteropType;
1463
-
1464
- type AmdOptions = (
1465
- | {
1466
- autoId?: false;
1467
- id: string;
1468
- }
1469
- | {
1470
- autoId: true;
1471
- basePath?: string;
1472
- id?: undefined;
1473
- }
1474
- | {
1475
- autoId?: false;
1476
- id?: undefined;
1477
- }
1478
- ) & {
1479
- define?: string;
1480
- forceJsExtensionForImports?: boolean;
1481
- };
1482
-
1483
- type NormalizedAmdOptions = (
1484
- | {
1485
- autoId: false;
1486
- id?: string;
1487
- }
1488
- | {
1489
- autoId: true;
1490
- basePath: string;
1491
- }
1492
- ) & {
1493
- define: string;
1494
- forceJsExtensionForImports: boolean;
1495
- };
1496
-
1497
- type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
1498
-
1499
- type OutputPluginOption = MaybePromise<OutputPlugin | NullValue | false | OutputPluginOption[]>;
1500
-
1501
- type HashCharacters = 'base64' | 'base36' | 'hex';
1502
-
1503
- interface OutputOptions {
1504
- amd?: AmdOptions;
1505
- assetFileNames?: string | ((chunkInfo: PreRenderedAsset) => string);
1506
- banner?: string | AddonFunction;
1507
- chunkFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
1508
- compact?: boolean;
1509
- // only required for bundle.write
1510
- dir?: string;
1511
- dynamicImportInCjs?: boolean;
1512
- entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
1513
- esModule?: boolean | 'if-default-prop';
1514
- experimentalMinChunkSize?: number;
1515
- exports?: 'default' | 'named' | 'none' | 'auto';
1516
- extend?: boolean;
1517
- /** @deprecated Use "externalImportAttributes" instead. */
1518
- externalImportAssertions?: boolean;
1519
- externalImportAttributes?: boolean;
1520
- externalLiveBindings?: boolean;
1521
- // only required for bundle.write
1522
- file?: string;
1523
- footer?: string | AddonFunction;
1524
- format?: ModuleFormat;
1525
- freeze?: boolean;
1526
- generatedCode?: GeneratedCodePreset | GeneratedCodeOptions;
1527
- globals?: GlobalsOption;
1528
- hashCharacters?: HashCharacters;
1529
- hoistTransitiveImports?: boolean;
1530
- importAttributesKey?: ImportAttributesKey;
1531
- indent?: string | boolean;
1532
- inlineDynamicImports?: boolean;
1533
- interop?: InteropType | GetInterop;
1534
- intro?: string | AddonFunction;
1535
- manualChunks?: ManualChunksOption;
1536
- minifyInternalExports?: boolean;
1537
- name?: string;
1538
- noConflict?: boolean;
1539
- outro?: string | AddonFunction;
1540
- paths?: OptionsPaths;
1541
- plugins?: OutputPluginOption;
1542
- preserveModules?: boolean;
1543
- preserveModulesRoot?: string;
1544
- reexportProtoFromExternal?: boolean;
1545
- sanitizeFileName?: boolean | ((fileName: string) => string);
1546
- sourcemap?: boolean | 'inline' | 'hidden';
1547
- sourcemapBaseUrl?: string;
1548
- sourcemapExcludeSources?: boolean;
1549
- sourcemapFile?: string;
1550
- sourcemapFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
1551
- sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption;
1552
- sourcemapPathTransform?: SourcemapPathTransformOption;
1553
- sourcemapDebugIds?: boolean;
1554
- strict?: boolean;
1555
- systemNullSetters?: boolean;
1556
- validate?: boolean;
1557
- virtualDirname?: string;
1558
- }
1559
-
1560
- interface NormalizedOutputOptions {
1561
- amd: NormalizedAmdOptions;
1562
- assetFileNames: string | ((chunkInfo: PreRenderedAsset) => string);
1563
- banner: AddonFunction;
1564
- chunkFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
1565
- compact: boolean;
1566
- dir: string | undefined;
1567
- dynamicImportInCjs: boolean;
1568
- entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
1569
- esModule: boolean | 'if-default-prop';
1570
- experimentalMinChunkSize: number;
1571
- exports: 'default' | 'named' | 'none' | 'auto';
1572
- extend: boolean;
1573
- /** @deprecated Use "externalImportAttributes" instead. */
1574
- externalImportAssertions: boolean;
1575
- externalImportAttributes: boolean;
1576
- externalLiveBindings: boolean;
1577
- file: string | undefined;
1578
- footer: AddonFunction;
1579
- format: InternalModuleFormat;
1580
- freeze: boolean;
1581
- generatedCode: NormalizedGeneratedCodeOptions;
1582
- globals: GlobalsOption;
1583
- hashCharacters: HashCharacters;
1584
- hoistTransitiveImports: boolean;
1585
- importAttributesKey: ImportAttributesKey;
1586
- indent: true | string;
1587
- inlineDynamicImports: boolean;
1588
- interop: GetInterop;
1589
- intro: AddonFunction;
1590
- manualChunks: ManualChunksOption;
1591
- minifyInternalExports: boolean;
1592
- name: string | undefined;
1593
- noConflict: boolean;
1594
- outro: AddonFunction;
1595
- paths: OptionsPaths;
1596
- plugins: OutputPlugin[];
1597
- preserveModules: boolean;
1598
- preserveModulesRoot: string | undefined;
1599
- reexportProtoFromExternal: boolean;
1600
- sanitizeFileName: (fileName: string) => string;
1601
- sourcemap: boolean | 'inline' | 'hidden';
1602
- sourcemapBaseUrl: string | undefined;
1603
- sourcemapExcludeSources: boolean;
1604
- sourcemapFile: string | undefined;
1605
- sourcemapFileNames: string | ((chunkInfo: PreRenderedChunk) => string) | undefined;
1606
- sourcemapIgnoreList: SourcemapIgnoreListOption;
1607
- sourcemapPathTransform: SourcemapPathTransformOption | undefined;
1608
- sourcemapDebugIds: boolean;
1609
- strict: boolean;
1610
- systemNullSetters: boolean;
1611
- validate: boolean;
1612
- virtualDirname: string;
1613
- }
1614
-
1615
- type WarningHandlerWithDefault = (
1616
- warning: RollupLog,
1617
- defaultHandler: LoggingFunction
1618
- ) => void;
1619
-
1620
- interface PreRenderedAsset {
1621
- /** @deprecated Use "names" instead. */
1622
- name: string | undefined;
1623
- names: string[];
1624
- /** @deprecated Use "originalFileNames" instead. */
1625
- originalFileName: string | null;
1626
- originalFileNames: string[];
1627
- source: string | Uint8Array;
1628
- type: 'asset';
1629
- }
1630
-
1631
- interface OutputAsset extends PreRenderedAsset {
1632
- fileName: string;
1633
- needsCodeReference: boolean;
1634
- }
1635
-
1636
- interface RenderedModule {
1637
- readonly code: string | null;
1638
- originalLength: number;
1639
- removedExports: string[];
1640
- renderedExports: string[];
1641
- renderedLength: number;
1642
- }
1643
-
1644
- interface PreRenderedChunk {
1645
- exports: string[];
1646
- facadeModuleId: string | null;
1647
- isDynamicEntry: boolean;
1648
- isEntry: boolean;
1649
- isImplicitEntry: boolean;
1650
- moduleIds: string[];
1651
- name: string;
1652
- type: 'chunk';
1653
- }
1654
-
1655
- interface RenderedChunk extends PreRenderedChunk {
1656
- dynamicImports: string[];
1657
- fileName: string;
1658
- implicitlyLoadedBefore: string[];
1659
- importedBindings: Record<string, string[]>;
1660
- imports: string[];
1661
- modules: Record<string, RenderedModule>;
1662
- referencedFiles: string[];
1663
- }
1664
-
1665
- interface OutputChunk extends RenderedChunk {
1666
- code: string;
1667
- map: SourceMap | null;
1668
- sourcemapFileName: string | null;
1669
- preliminaryFileName: string;
1670
- }
1671
-
1672
- type SerializablePluginCache = Record<string, [number, any]>;
1673
-
1674
- interface RollupCache {
1675
- modules: ModuleJSON[];
1676
- plugins?: Record<string, SerializablePluginCache>;
1677
- }
1678
-
1679
- interface ChokidarOptions {
1680
- alwaysStat?: boolean;
1681
- atomic?: boolean | number;
1682
- awaitWriteFinish?:
1683
- | {
1684
- pollInterval?: number;
1685
- stabilityThreshold?: number;
1686
- }
1687
- | boolean;
1688
- binaryInterval?: number;
1689
- cwd?: string;
1690
- depth?: number;
1691
- disableGlobbing?: boolean;
1692
- followSymlinks?: boolean;
1693
- ignoreInitial?: boolean;
1694
- ignorePermissionErrors?: boolean;
1695
- ignored?: any;
1696
- interval?: number;
1697
- persistent?: boolean;
1698
- useFsEvents?: boolean;
1699
- usePolling?: boolean;
1700
- }
1701
-
1702
- interface WatcherOptions {
1703
- buildDelay?: number;
1704
- chokidar?: ChokidarOptions;
1705
- clearScreen?: boolean;
1706
- exclude?: string | RegExp | (string | RegExp)[];
1707
- include?: string | RegExp | (string | RegExp)[];
1708
- skipWrite?: boolean;
1709
- }
1710
-
1711
- interface AstNodeLocation {
1712
- end: number;
1713
- start: number;
1714
- }
1715
-
1716
- type OmittedEstreeKeys =
1717
- | 'loc'
1718
- | 'range'
1719
- | 'leadingComments'
1720
- | 'trailingComments'
1721
- | 'innerComments'
1722
- | 'comments';
1723
- type RollupAstNode<T> = Omit<T, OmittedEstreeKeys> & AstNodeLocation;
1724
-
1725
- type ProgramNode = RollupAstNode<Program>;
1726
- type AstNode = RollupAstNode<Node>;
1727
-
1728
- interface VitePluginInterface {
1729
- toc: RemarkMdxTocOptions;
1730
- }
1731
- declare function vitePlugins(options: VitePluginInterface): Plugin[];
1732
-
1733
- export { compileBySlug, mdxOptions, vitePlugins };
8
+ export { compileBySlug, filterNavigationByLevels, pageFrontMatters };