@xyd-js/content 0.1.0-build.171

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.
Files changed (97) hide show
  1. package/CHANGELOG.md +2174 -0
  2. package/ISSUES.md +1 -0
  3. package/LICENSE +21 -0
  4. package/README.md +3 -0
  5. package/TODO.md +2 -0
  6. package/dist/index.d.ts +28 -0
  7. package/dist/index.js +1625 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/md.d.ts +72 -0
  10. package/dist/md.js +23508 -0
  11. package/dist/md.js.map +1 -0
  12. package/dist/mdToc-NBBxMJ4l.d.ts +12 -0
  13. package/dist/vite.d.ts +1066 -0
  14. package/dist/vite.js +20156 -0
  15. package/dist/vite.js.map +1 -0
  16. package/package.json +67 -0
  17. package/packages/md/index.ts +25 -0
  18. package/packages/md/plugins/component-directives/index.ts +3 -0
  19. package/packages/md/plugins/component-directives/mdComponentDirective.ts +577 -0
  20. package/packages/md/plugins/component-directives/types.ts +1 -0
  21. package/packages/md/plugins/component-directives/utils.ts +27 -0
  22. package/packages/md/plugins/composer/__fixtures__/1.single-example/input.md +7 -0
  23. package/packages/md/plugins/composer/__fixtures__/1.single-example/output.json +63 -0
  24. package/packages/md/plugins/composer/__fixtures__/2.single-example-with-name/input.md +7 -0
  25. package/packages/md/plugins/composer/__fixtures__/2.single-example-with-name/output.json +63 -0
  26. package/packages/md/plugins/composer/__fixtures__/3.multiple-examples/input.md +15 -0
  27. package/packages/md/plugins/composer/__fixtures__/3.multiple-examples/output.json +122 -0
  28. package/packages/md/plugins/composer/__fixtures__/4.example-groups/input.md +23 -0
  29. package/packages/md/plugins/composer/__fixtures__/4.example-groups/output.json +184 -0
  30. package/packages/md/plugins/composer/__tests__/mdComposer.test.ts +41 -0
  31. package/packages/md/plugins/composer/__tests__/testHelpers.ts +48 -0
  32. package/packages/md/plugins/composer/index.ts +1 -0
  33. package/packages/md/plugins/composer/mdComposer.ts +146 -0
  34. package/packages/md/plugins/developer-writing/index.ts +3 -0
  35. package/packages/md/plugins/developer-writing/mdCodeRehype.ts +81 -0
  36. package/packages/md/plugins/functions/__fixtures__/external.ts +4 -0
  37. package/packages/md/plugins/functions/__fixtures__/test-include.md +31 -0
  38. package/packages/md/plugins/functions/__fixtures__/test.js +11 -0
  39. package/packages/md/plugins/functions/__fixtures__/test.py +9 -0
  40. package/packages/md/plugins/functions/__fixtures__/test.ts +18 -0
  41. package/packages/md/plugins/functions/__tests__/mdFunctionImportCode.test.ts +314 -0
  42. package/packages/md/plugins/functions/__tests__/mdFunctionInclude.test.ts +44 -0
  43. package/packages/md/plugins/functions/__tests__/parseFunctionCall.test.ts +70 -0
  44. package/packages/md/plugins/functions/__tests__/testHelpers.ts +95 -0
  45. package/packages/md/plugins/functions/index.ts +15 -0
  46. package/packages/md/plugins/functions/mdFunctionChangelog.ts +135 -0
  47. package/packages/md/plugins/functions/mdFunctionImportCode.ts +92 -0
  48. package/packages/md/plugins/functions/mdFunctionInclude.ts +119 -0
  49. package/packages/md/plugins/functions/mdFunctionUniform.ts +79 -0
  50. package/packages/md/plugins/functions/types.ts +9 -0
  51. package/packages/md/plugins/functions/uniformProcessor.ts +349 -0
  52. package/packages/md/plugins/functions/utils.ts +457 -0
  53. package/packages/md/plugins/index.ts +125 -0
  54. package/packages/md/plugins/mdCode.ts +16 -0
  55. package/packages/md/plugins/mdHeadingId.ts +47 -0
  56. package/packages/md/plugins/mdImage.test.ts +59 -0
  57. package/packages/md/plugins/mdImage.ts +55 -0
  58. package/packages/md/plugins/mdImageRehype.ts +13 -0
  59. package/packages/md/plugins/mdPage.ts +35 -0
  60. package/packages/md/plugins/mdThemeSettings.ts +34 -0
  61. package/packages/md/plugins/mdToc.ts +229 -0
  62. package/packages/md/plugins/meta/index.ts +1 -0
  63. package/packages/md/plugins/meta/mdMeta.ts +198 -0
  64. package/packages/md/plugins/output-variables/__fixtures__/1.simple/input.md +22 -0
  65. package/packages/md/plugins/output-variables/__fixtures__/1.simple/output.json +191 -0
  66. package/packages/md/plugins/output-variables/__fixtures__/2.multiple-vars/input.md +21 -0
  67. package/packages/md/plugins/output-variables/__fixtures__/2.multiple-vars/output.json +127 -0
  68. package/packages/md/plugins/output-variables/__tests__/index.test.ts +28 -0
  69. package/packages/md/plugins/output-variables/__tests__/testHelpers.ts +36 -0
  70. package/packages/md/plugins/output-variables/index.ts +1 -0
  71. package/packages/md/plugins/output-variables/lib/const.ts +4 -0
  72. package/packages/md/plugins/output-variables/lib/factoryAttributes.ts +350 -0
  73. package/packages/md/plugins/output-variables/lib/factoryLabel.ts +135 -0
  74. package/packages/md/plugins/output-variables/lib/factoryName.ts +59 -0
  75. package/packages/md/plugins/output-variables/lib/index.ts +21 -0
  76. package/packages/md/plugins/output-variables/lib/outputVarsContainer.ts +328 -0
  77. package/packages/md/plugins/output-variables/lib/util.ts +494 -0
  78. package/packages/md/plugins/output-variables/remarkOutputVars.ts +22 -0
  79. package/packages/md/plugins/recmaOverrideComponents.ts +74 -0
  80. package/packages/md/plugins/rehypeHeading.ts +58 -0
  81. package/packages/md/plugins/types.ts +15 -0
  82. package/packages/md/plugins/utils/componentLike.ts +76 -0
  83. package/packages/md/plugins/utils/index.ts +2 -0
  84. package/packages/md/plugins/utils/injectCodeMeta.ts +59 -0
  85. package/packages/md/plugins/utils/mdParameters.test.ts +114 -0
  86. package/packages/md/plugins/utils/mdParameters.ts +249 -0
  87. package/packages/md/plugins/utils/mdastTypes.ts +42 -0
  88. package/packages/md/search/index.ts +257 -0
  89. package/packages/md/search/types.ts +36 -0
  90. package/packages/vite/index.ts +20 -0
  91. package/src/fs.ts +81 -0
  92. package/src/index.ts +7 -0
  93. package/src/navigation.ts +147 -0
  94. package/src/types.ts +8 -0
  95. package/tsconfig.json +49 -0
  96. package/tsup.config.ts +32 -0
  97. package/vitest.config.ts +17 -0
package/dist/vite.d.ts ADDED
@@ -0,0 +1,1066 @@
1
+ import * as estree from 'estree';
2
+ import { Settings } from '@xyd-js/core';
3
+ import { R as RemarkMdxTocOptions } from './mdToc-NBBxMJ4l.js';
4
+
5
+ declare module 'estree' {
6
+ export interface Decorator extends estree.BaseNode {
7
+ type: 'Decorator';
8
+ expression: estree.Expression;
9
+ }
10
+ interface PropertyDefinition {
11
+ decorators: estree.Decorator[];
12
+ }
13
+ interface MethodDefinition {
14
+ decorators: estree.Decorator[];
15
+ }
16
+ interface BaseClass {
17
+ decorators: estree.Decorator[];
18
+ }
19
+ }
20
+
21
+ // utils
22
+ type NullValue = null | undefined | void;
23
+ type MaybeArray<T> = T | T[];
24
+ type MaybePromise<T> = T | Promise<T>;
25
+
26
+ type PartialNull<T> = {
27
+ [P in keyof T]: T[P] | null;
28
+ };
29
+
30
+ interface RollupError extends RollupLog {
31
+ name?: string;
32
+ stack?: string;
33
+ watchFiles?: string[];
34
+ }
35
+
36
+ interface RollupLog {
37
+ binding?: string;
38
+ cause?: unknown;
39
+ code?: string;
40
+ exporter?: string;
41
+ frame?: string;
42
+ hook?: string;
43
+ id?: string;
44
+ ids?: string[];
45
+ loc?: {
46
+ column: number;
47
+ file?: string;
48
+ line: number;
49
+ };
50
+ message: string;
51
+ meta?: any;
52
+ names?: string[];
53
+ plugin?: string;
54
+ pluginCode?: unknown;
55
+ pos?: number;
56
+ reexporter?: string;
57
+ stack?: string;
58
+ url?: string;
59
+ }
60
+
61
+ type LogLevel = 'warn' | 'info' | 'debug';
62
+ type LogLevelOption = LogLevel | 'silent';
63
+
64
+ type SourceMapSegment =
65
+ | [number]
66
+ | [number, number, number, number]
67
+ | [number, number, number, number, number];
68
+
69
+ interface ExistingDecodedSourceMap {
70
+ file?: string;
71
+ readonly mappings: SourceMapSegment[][];
72
+ names: string[];
73
+ sourceRoot?: string;
74
+ sources: string[];
75
+ sourcesContent?: string[];
76
+ version: number;
77
+ x_google_ignoreList?: number[];
78
+ }
79
+
80
+ interface ExistingRawSourceMap {
81
+ file?: string;
82
+ mappings: string;
83
+ names: string[];
84
+ sourceRoot?: string;
85
+ sources: string[];
86
+ sourcesContent?: string[];
87
+ version: number;
88
+ x_google_ignoreList?: number[];
89
+ }
90
+
91
+ type DecodedSourceMapOrMissing =
92
+ | {
93
+ missing: true;
94
+ plugin: string;
95
+ }
96
+ | (ExistingDecodedSourceMap & { missing?: false });
97
+
98
+ interface SourceMap {
99
+ file: string;
100
+ mappings: string;
101
+ names: string[];
102
+ sources: string[];
103
+ sourcesContent?: string[];
104
+ version: number;
105
+ debugId?: string;
106
+ toString(): string;
107
+ toUrl(): string;
108
+ }
109
+
110
+ type SourceMapInput = ExistingRawSourceMap | string | null | { mappings: '' };
111
+
112
+ interface ModuleOptions {
113
+ attributes: Record<string, string>;
114
+ meta: CustomPluginOptions;
115
+ moduleSideEffects: boolean | 'no-treeshake';
116
+ syntheticNamedExports: boolean | string;
117
+ }
118
+
119
+ interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
120
+ ast?: ProgramNode;
121
+ code: string;
122
+ map?: SourceMapInput;
123
+ }
124
+
125
+ interface TransformModuleJSON {
126
+ ast?: ProgramNode;
127
+ code: string;
128
+ // note if plugins use new this.cache to opt-out auto transform cache
129
+ customTransformCache: boolean;
130
+ originalCode: string;
131
+ originalSourcemap: ExistingDecodedSourceMap | null;
132
+ sourcemapChain: DecodedSourceMapOrMissing[];
133
+ transformDependencies: string[];
134
+ }
135
+
136
+ interface ModuleJSON extends TransformModuleJSON, ModuleOptions {
137
+ ast: ProgramNode;
138
+ dependencies: string[];
139
+ id: string;
140
+ resolvedIds: ResolvedIdMap;
141
+ transformFiles: EmittedFile[] | undefined;
142
+ }
143
+
144
+ interface PluginCache {
145
+ delete(id: string): boolean;
146
+ get<T = any>(id: string): T;
147
+ has(id: string): boolean;
148
+ set<T = any>(id: string, value: T): void;
149
+ }
150
+
151
+ type LoggingFunction = (log: RollupLog | string | (() => RollupLog | string)) => void;
152
+
153
+ interface MinimalPluginContext {
154
+ debug: LoggingFunction;
155
+ error: (error: RollupError | string) => never;
156
+ info: LoggingFunction;
157
+ meta: PluginContextMeta;
158
+ warn: LoggingFunction;
159
+ }
160
+
161
+ interface EmittedAsset {
162
+ fileName?: string;
163
+ name?: string;
164
+ needsCodeReference?: boolean;
165
+ originalFileName?: string | null;
166
+ source?: string | Uint8Array;
167
+ type: 'asset';
168
+ }
169
+
170
+ interface EmittedChunk {
171
+ fileName?: string;
172
+ id: string;
173
+ implicitlyLoadedAfterOneOf?: string[];
174
+ importer?: string;
175
+ name?: string;
176
+ preserveSignature?: PreserveEntrySignaturesOption;
177
+ type: 'chunk';
178
+ }
179
+
180
+ interface EmittedPrebuiltChunk {
181
+ code: string;
182
+ exports?: string[];
183
+ fileName: string;
184
+ map?: SourceMap;
185
+ sourcemapFileName?: string;
186
+ type: 'prebuilt-chunk';
187
+ }
188
+
189
+ type EmittedFile = EmittedAsset | EmittedChunk | EmittedPrebuiltChunk;
190
+
191
+ type EmitFile = (emittedFile: EmittedFile) => string;
192
+
193
+ interface ModuleInfo extends ModuleOptions {
194
+ ast: ProgramNode | null;
195
+ code: string | null;
196
+ dynamicImporters: readonly string[];
197
+ dynamicallyImportedIdResolutions: readonly ResolvedId[];
198
+ dynamicallyImportedIds: readonly string[];
199
+ exportedBindings: Record<string, string[]> | null;
200
+ exports: string[] | null;
201
+ hasDefaultExport: boolean | null;
202
+ id: string;
203
+ implicitlyLoadedAfterOneOf: readonly string[];
204
+ implicitlyLoadedBefore: readonly string[];
205
+ importedIdResolutions: readonly ResolvedId[];
206
+ importedIds: readonly string[];
207
+ importers: readonly string[];
208
+ isEntry: boolean;
209
+ isExternal: boolean;
210
+ isIncluded: boolean | null;
211
+ }
212
+
213
+ type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
214
+
215
+ // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style -- this is an interface so that it can be extended by plugins
216
+ interface CustomPluginOptions {
217
+ [plugin: string]: any;
218
+ }
219
+
220
+ type LoggingFunctionWithPosition = (
221
+ log: RollupLog | string | (() => RollupLog | string),
222
+ pos?: number | { column: number; line: number }
223
+ ) => void;
224
+
225
+ type ParseAst = (
226
+ input: string,
227
+ options?: { allowReturnOutsideFunction?: boolean; jsx?: boolean }
228
+ ) => ProgramNode;
229
+
230
+ // declare AbortSignal here for environments without DOM lib or @types/node
231
+ declare global {
232
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
233
+ interface AbortSignal {}
234
+ }
235
+
236
+ interface PluginContext extends MinimalPluginContext {
237
+ addWatchFile: (id: string) => void;
238
+ cache: PluginCache;
239
+ debug: LoggingFunction;
240
+ emitFile: EmitFile;
241
+ error: (error: RollupError | string) => never;
242
+ fs: RollupFsModule;
243
+ getFileName: (fileReferenceId: string) => string;
244
+ getModuleIds: () => IterableIterator<string>;
245
+ getModuleInfo: GetModuleInfo;
246
+ getWatchFiles: () => string[];
247
+ info: LoggingFunction;
248
+ load: (
249
+ options: { id: string; resolveDependencies?: boolean } & Partial<PartialNull<ModuleOptions>>
250
+ ) => Promise<ModuleInfo>;
251
+ parse: ParseAst;
252
+ resolve: (
253
+ source: string,
254
+ importer?: string,
255
+ options?: {
256
+ attributes?: Record<string, string>;
257
+ custom?: CustomPluginOptions;
258
+ isEntry?: boolean;
259
+ skipSelf?: boolean;
260
+ }
261
+ ) => Promise<ResolvedId | null>;
262
+ setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
263
+ warn: LoggingFunction;
264
+ }
265
+
266
+ interface PluginContextMeta {
267
+ rollupVersion: string;
268
+ watchMode: boolean;
269
+ }
270
+
271
+ type StringOrRegExp = string | RegExp;
272
+
273
+ type StringFilter<Value = StringOrRegExp> =
274
+ | MaybeArray<Value>
275
+ | {
276
+ include?: MaybeArray<Value>;
277
+ exclude?: MaybeArray<Value>;
278
+ };
279
+
280
+ interface HookFilter {
281
+ id?: StringFilter;
282
+ code?: StringFilter;
283
+ }
284
+
285
+ interface ResolvedId extends ModuleOptions {
286
+ external: boolean | 'absolute';
287
+ id: string;
288
+ resolvedBy: string;
289
+ }
290
+
291
+ type ResolvedIdMap = Record<string, ResolvedId>;
292
+
293
+ interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
294
+ external?: boolean | 'absolute' | 'relative';
295
+ id: string;
296
+ resolvedBy?: string;
297
+ }
298
+
299
+ type ResolveIdResult = string | NullValue | false | PartialResolvedId;
300
+
301
+ type ResolveIdHook = (
302
+ this: PluginContext,
303
+ source: string,
304
+ importer: string | undefined,
305
+ options: { attributes: Record<string, string>; custom?: CustomPluginOptions; isEntry: boolean }
306
+ ) => ResolveIdResult;
307
+
308
+ type ShouldTransformCachedModuleHook = (
309
+ this: PluginContext,
310
+ options: {
311
+ ast: ProgramNode;
312
+ code: string;
313
+ id: string;
314
+ meta: CustomPluginOptions;
315
+ moduleSideEffects: boolean | 'no-treeshake';
316
+ resolvedSources: ResolvedIdMap;
317
+ syntheticNamedExports: boolean | string;
318
+ }
319
+ ) => boolean | NullValue;
320
+
321
+ type IsExternal = (
322
+ source: string,
323
+ importer: string | undefined,
324
+ isResolved: boolean
325
+ ) => boolean;
326
+
327
+ type HasModuleSideEffects = (id: string, external: boolean) => boolean;
328
+
329
+ type LoadResult = SourceDescription | string | NullValue;
330
+
331
+ type LoadHook = (this: PluginContext, id: string) => LoadResult;
332
+
333
+ interface TransformPluginContext extends PluginContext {
334
+ debug: LoggingFunctionWithPosition;
335
+ error: (error: RollupError | string, pos?: number | { column: number; line: number }) => never;
336
+ getCombinedSourcemap: () => SourceMap;
337
+ info: LoggingFunctionWithPosition;
338
+ warn: LoggingFunctionWithPosition;
339
+ }
340
+
341
+ type TransformResult = string | NullValue | Partial<SourceDescription>;
342
+
343
+ type TransformHook = (
344
+ this: TransformPluginContext,
345
+ code: string,
346
+ id: string
347
+ ) => TransformResult;
348
+
349
+ type ModuleParsedHook = (this: PluginContext, info: ModuleInfo) => void;
350
+
351
+ type RenderChunkHook = (
352
+ this: PluginContext,
353
+ code: string,
354
+ chunk: RenderedChunk,
355
+ options: NormalizedOutputOptions,
356
+ meta: { chunks: Record<string, RenderedChunk> }
357
+ ) => { code: string; map?: SourceMapInput } | string | NullValue;
358
+
359
+ type ResolveDynamicImportHook = (
360
+ this: PluginContext,
361
+ specifier: string | AstNode,
362
+ importer: string,
363
+ options: { attributes: Record<string, string> }
364
+ ) => ResolveIdResult;
365
+
366
+ type ResolveImportMetaHook = (
367
+ this: PluginContext,
368
+ property: string | null,
369
+ options: { chunkId: string; format: InternalModuleFormat; moduleId: string }
370
+ ) => string | NullValue;
371
+
372
+ type ResolveFileUrlHook = (
373
+ this: PluginContext,
374
+ options: {
375
+ chunkId: string;
376
+ fileName: string;
377
+ format: InternalModuleFormat;
378
+ moduleId: string;
379
+ referenceId: string;
380
+ relativePath: string;
381
+ }
382
+ ) => string | NullValue;
383
+
384
+ type AddonHookFunction = (
385
+ this: PluginContext,
386
+ chunk: RenderedChunk
387
+ ) => string | Promise<string>;
388
+ type AddonHook = string | AddonHookFunction;
389
+
390
+ type ChangeEvent = 'create' | 'update' | 'delete';
391
+ type WatchChangeHook = (
392
+ this: PluginContext,
393
+ id: string,
394
+ change: { event: ChangeEvent }
395
+ ) => void;
396
+
397
+ type OutputBundle = Record<string, OutputAsset | OutputChunk>;
398
+
399
+ type PreRenderedChunkWithFileName = PreRenderedChunk & { fileName: string };
400
+
401
+ interface ImportedInternalChunk {
402
+ type: 'internal';
403
+ fileName: string;
404
+ resolvedImportPath: string;
405
+ chunk: PreRenderedChunk;
406
+ }
407
+
408
+ interface ImportedExternalChunk {
409
+ type: 'external';
410
+ fileName: string;
411
+ resolvedImportPath: string;
412
+ }
413
+
414
+ type DynamicImportTargetChunk = ImportedInternalChunk | ImportedExternalChunk;
415
+
416
+ interface FunctionPluginHooks {
417
+ augmentChunkHash: (this: PluginContext, chunk: RenderedChunk) => string | void;
418
+ buildEnd: (this: PluginContext, error?: Error) => void;
419
+ buildStart: (this: PluginContext, options: NormalizedInputOptions) => void;
420
+ closeBundle: (this: PluginContext, error?: Error) => void;
421
+ closeWatcher: (this: PluginContext) => void;
422
+ generateBundle: (
423
+ this: PluginContext,
424
+ options: NormalizedOutputOptions,
425
+ bundle: OutputBundle,
426
+ isWrite: boolean
427
+ ) => void;
428
+ load: LoadHook;
429
+ moduleParsed: ModuleParsedHook;
430
+ onLog: (this: MinimalPluginContext, level: LogLevel, log: RollupLog) => boolean | NullValue;
431
+ options: (this: MinimalPluginContext, options: InputOptions) => InputOptions | NullValue;
432
+ outputOptions: (this: PluginContext, options: OutputOptions) => OutputOptions | NullValue;
433
+ renderChunk: RenderChunkHook;
434
+ renderDynamicImport: (
435
+ this: PluginContext,
436
+ options: {
437
+ customResolution: string | null;
438
+ format: InternalModuleFormat;
439
+ moduleId: string;
440
+ targetModuleId: string | null;
441
+ chunk: PreRenderedChunkWithFileName;
442
+ targetChunk: PreRenderedChunkWithFileName | null;
443
+ getTargetChunkImports: () => DynamicImportTargetChunk[] | null;
444
+ }
445
+ ) => { left: string; right: string } | NullValue;
446
+ renderError: (this: PluginContext, error?: Error) => void;
447
+ renderStart: (
448
+ this: PluginContext,
449
+ outputOptions: NormalizedOutputOptions,
450
+ inputOptions: NormalizedInputOptions
451
+ ) => void;
452
+ resolveDynamicImport: ResolveDynamicImportHook;
453
+ resolveFileUrl: ResolveFileUrlHook;
454
+ resolveId: ResolveIdHook;
455
+ resolveImportMeta: ResolveImportMetaHook;
456
+ shouldTransformCachedModule: ShouldTransformCachedModuleHook;
457
+ transform: TransformHook;
458
+ watchChange: WatchChangeHook;
459
+ writeBundle: (
460
+ this: PluginContext,
461
+ options: NormalizedOutputOptions,
462
+ bundle: OutputBundle
463
+ ) => void;
464
+ }
465
+
466
+ type OutputPluginHooks =
467
+ | 'augmentChunkHash'
468
+ | 'generateBundle'
469
+ | 'outputOptions'
470
+ | 'renderChunk'
471
+ | 'renderDynamicImport'
472
+ | 'renderError'
473
+ | 'renderStart'
474
+ | 'resolveFileUrl'
475
+ | 'resolveImportMeta'
476
+ | 'writeBundle';
477
+
478
+ type SyncPluginHooks =
479
+ | 'augmentChunkHash'
480
+ | 'onLog'
481
+ | 'outputOptions'
482
+ | 'renderDynamicImport'
483
+ | 'resolveFileUrl'
484
+ | 'resolveImportMeta';
485
+
486
+ type AsyncPluginHooks = Exclude<keyof FunctionPluginHooks, SyncPluginHooks>;
487
+
488
+ type FirstPluginHooks =
489
+ | 'load'
490
+ | 'renderDynamicImport'
491
+ | 'resolveDynamicImport'
492
+ | 'resolveFileUrl'
493
+ | 'resolveId'
494
+ | 'resolveImportMeta'
495
+ | 'shouldTransformCachedModule';
496
+
497
+ type SequentialPluginHooks =
498
+ | 'augmentChunkHash'
499
+ | 'generateBundle'
500
+ | 'onLog'
501
+ | 'options'
502
+ | 'outputOptions'
503
+ | 'renderChunk'
504
+ | 'transform';
505
+
506
+ type ParallelPluginHooks = Exclude<
507
+ keyof FunctionPluginHooks | AddonHooks,
508
+ FirstPluginHooks | SequentialPluginHooks
509
+ >;
510
+
511
+ type AddonHooks = 'banner' | 'footer' | 'intro' | 'outro';
512
+
513
+ type MakeAsync<Function_> = Function_ extends (
514
+ this: infer This,
515
+ ...parameters: infer Arguments
516
+ ) => infer Return
517
+ ? (this: This, ...parameters: Arguments) => Return | Promise<Return>
518
+ : never;
519
+
520
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
521
+ type ObjectHook<T, O = {}> = T | ({ handler: T; order?: 'pre' | 'post' | null } & O);
522
+
523
+ type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends 'transform'
524
+ ? { filter?: HookFilter }
525
+ : K extends 'load'
526
+ ? { filter?: Pick<HookFilter, 'id'> }
527
+ : K extends 'resolveId'
528
+ ? { filter?: { id?: StringFilter<RegExp> } }
529
+ : // eslint-disable-next-line @typescript-eslint/no-empty-object-type
530
+ {};
531
+
532
+ type PluginHooks = {
533
+ [K in keyof FunctionPluginHooks]: ObjectHook<
534
+ K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K],
535
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
536
+ HookFilterExtension<K> & (K extends ParallelPluginHooks ? { sequential?: boolean } : {})
537
+ >;
538
+ };
539
+
540
+ interface OutputPlugin
541
+ extends Partial<{ [K in OutputPluginHooks]: PluginHooks[K] }>,
542
+ Partial<Record<AddonHooks, ObjectHook<AddonHook>>> {
543
+ cacheKey?: string;
544
+ name: string;
545
+ version?: string;
546
+ }
547
+
548
+ interface Plugin<A = any> extends OutputPlugin, Partial<PluginHooks> {
549
+ // for inter-plugin communication
550
+ api?: A;
551
+ }
552
+
553
+ type JsxPreset = 'react' | 'react-jsx' | 'preserve' | 'preserve-react';
554
+
555
+ type NormalizedJsxOptions =
556
+ | NormalizedJsxPreserveOptions
557
+ | NormalizedJsxClassicOptions
558
+ | NormalizedJsxAutomaticOptions;
559
+
560
+ interface NormalizedJsxPreserveOptions {
561
+ factory: string | null;
562
+ fragment: string | null;
563
+ importSource: string | null;
564
+ mode: 'preserve';
565
+ }
566
+
567
+ interface NormalizedJsxClassicOptions {
568
+ factory: string;
569
+ fragment: string;
570
+ importSource: string | null;
571
+ mode: 'classic';
572
+ }
573
+
574
+ interface NormalizedJsxAutomaticOptions {
575
+ factory: string;
576
+ importSource: string | null;
577
+ jsxImportSource: string;
578
+ mode: 'automatic';
579
+ }
580
+
581
+ type JsxOptions = Partial<NormalizedJsxOptions> & {
582
+ preset?: JsxPreset;
583
+ };
584
+
585
+ type TreeshakingPreset = 'smallest' | 'safest' | 'recommended';
586
+
587
+ interface NormalizedTreeshakingOptions {
588
+ annotations: boolean;
589
+ correctVarValueBeforeDeclaration: boolean;
590
+ manualPureFunctions: readonly string[];
591
+ moduleSideEffects: HasModuleSideEffects;
592
+ propertyReadSideEffects: boolean | 'always';
593
+ tryCatchDeoptimization: boolean;
594
+ unknownGlobalSideEffects: boolean;
595
+ }
596
+
597
+ interface TreeshakingOptions
598
+ extends Partial<Omit<NormalizedTreeshakingOptions, 'moduleSideEffects'>> {
599
+ moduleSideEffects?: ModuleSideEffectsOption;
600
+ preset?: TreeshakingPreset;
601
+ }
602
+
603
+ interface ManualChunkMeta {
604
+ getModuleIds: () => IterableIterator<string>;
605
+ getModuleInfo: GetModuleInfo;
606
+ }
607
+
608
+ type GetManualChunk = (id: string, meta: ManualChunkMeta) => string | NullValue;
609
+
610
+ type ExternalOption =
611
+ | (string | RegExp)[]
612
+ | string
613
+ | RegExp
614
+ | ((source: string, importer: string | undefined, isResolved: boolean) => boolean | NullValue);
615
+
616
+ type GlobalsOption = Record<string, string> | ((name: string) => string);
617
+
618
+ type InputOption = string | string[] | Record<string, string>;
619
+
620
+ type ManualChunksOption = Record<string, string[]> | GetManualChunk;
621
+
622
+ type LogHandlerWithDefault = (
623
+ level: LogLevel,
624
+ log: RollupLog,
625
+ defaultHandler: LogOrStringHandler
626
+ ) => void;
627
+
628
+ type LogOrStringHandler = (level: LogLevel | 'error', log: RollupLog | string) => void;
629
+
630
+ type LogHandler = (level: LogLevel, log: RollupLog) => void;
631
+
632
+ type ModuleSideEffectsOption = boolean | 'no-external' | string[] | HasModuleSideEffects;
633
+
634
+ type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
635
+
636
+ type SourcemapPathTransformOption = (
637
+ relativeSourcePath: string,
638
+ sourcemapPath: string
639
+ ) => string;
640
+
641
+ type SourcemapIgnoreListOption = (
642
+ relativeSourcePath: string,
643
+ sourcemapPath: string
644
+ ) => boolean;
645
+
646
+ type InputPluginOption = MaybePromise<Plugin | NullValue | false | InputPluginOption[]>;
647
+
648
+ interface InputOptions {
649
+ cache?: boolean | RollupCache;
650
+ context?: string;
651
+ experimentalCacheExpiry?: number;
652
+ experimentalLogSideEffects?: boolean;
653
+ external?: ExternalOption;
654
+ fs?: RollupFsModule;
655
+ input?: InputOption;
656
+ jsx?: false | JsxPreset | JsxOptions;
657
+ logLevel?: LogLevelOption;
658
+ makeAbsoluteExternalsRelative?: boolean | 'ifRelativeSource';
659
+ maxParallelFileOps?: number;
660
+ moduleContext?: ((id: string) => string | NullValue) | Record<string, string>;
661
+ onLog?: LogHandlerWithDefault;
662
+ onwarn?: WarningHandlerWithDefault;
663
+ perf?: boolean;
664
+ plugins?: InputPluginOption;
665
+ preserveEntrySignatures?: PreserveEntrySignaturesOption;
666
+ preserveSymlinks?: boolean;
667
+ shimMissingExports?: boolean;
668
+ strictDeprecations?: boolean;
669
+ treeshake?: boolean | TreeshakingPreset | TreeshakingOptions;
670
+ watch?: WatcherOptions | false;
671
+ }
672
+
673
+ interface NormalizedInputOptions {
674
+ cache: false | undefined | RollupCache;
675
+ context: string;
676
+ experimentalCacheExpiry: number;
677
+ experimentalLogSideEffects: boolean;
678
+ external: IsExternal;
679
+ fs: RollupFsModule;
680
+ input: string[] | Record<string, string>;
681
+ jsx: false | NormalizedJsxOptions;
682
+ logLevel: LogLevelOption;
683
+ makeAbsoluteExternalsRelative: boolean | 'ifRelativeSource';
684
+ maxParallelFileOps: number;
685
+ moduleContext: (id: string) => string;
686
+ onLog: LogHandler;
687
+ perf: boolean;
688
+ plugins: Plugin[];
689
+ preserveEntrySignatures: PreserveEntrySignaturesOption;
690
+ preserveSymlinks: boolean;
691
+ shimMissingExports: boolean;
692
+ strictDeprecations: boolean;
693
+ treeshake: false | NormalizedTreeshakingOptions;
694
+ }
695
+
696
+ type InternalModuleFormat = 'amd' | 'cjs' | 'es' | 'iife' | 'system' | 'umd';
697
+ type ImportAttributesKey = 'with' | 'assert';
698
+
699
+ type ModuleFormat = InternalModuleFormat | 'commonjs' | 'esm' | 'module' | 'systemjs';
700
+
701
+ type GeneratedCodePreset = 'es5' | 'es2015';
702
+
703
+ interface NormalizedGeneratedCodeOptions {
704
+ arrowFunctions: boolean;
705
+ constBindings: boolean;
706
+ objectShorthand: boolean;
707
+ reservedNamesAsProps: boolean;
708
+ symbols: boolean;
709
+ }
710
+
711
+ interface GeneratedCodeOptions extends Partial<NormalizedGeneratedCodeOptions> {
712
+ preset?: GeneratedCodePreset;
713
+ }
714
+
715
+ type OptionsPaths = Record<string, string> | ((id: string) => string);
716
+
717
+ type InteropType = 'compat' | 'auto' | 'esModule' | 'default' | 'defaultOnly';
718
+
719
+ type GetInterop = (id: string | null) => InteropType;
720
+
721
+ type AmdOptions = (
722
+ | {
723
+ autoId?: false;
724
+ id: string;
725
+ }
726
+ | {
727
+ autoId: true;
728
+ basePath?: string;
729
+ id?: undefined;
730
+ }
731
+ | {
732
+ autoId?: false;
733
+ id?: undefined;
734
+ }
735
+ ) & {
736
+ define?: string;
737
+ forceJsExtensionForImports?: boolean;
738
+ };
739
+
740
+ type NormalizedAmdOptions = (
741
+ | {
742
+ autoId: false;
743
+ id?: string;
744
+ }
745
+ | {
746
+ autoId: true;
747
+ basePath: string;
748
+ }
749
+ ) & {
750
+ define: string;
751
+ forceJsExtensionForImports: boolean;
752
+ };
753
+
754
+ type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
755
+
756
+ type OutputPluginOption = MaybePromise<OutputPlugin | NullValue | false | OutputPluginOption[]>;
757
+
758
+ type HashCharacters = 'base64' | 'base36' | 'hex';
759
+
760
+ interface OutputOptions {
761
+ amd?: AmdOptions;
762
+ assetFileNames?: string | ((chunkInfo: PreRenderedAsset) => string);
763
+ banner?: string | AddonFunction;
764
+ chunkFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
765
+ compact?: boolean;
766
+ // only required for bundle.write
767
+ dir?: string;
768
+ dynamicImportInCjs?: boolean;
769
+ entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
770
+ esModule?: boolean | 'if-default-prop';
771
+ experimentalMinChunkSize?: number;
772
+ exports?: 'default' | 'named' | 'none' | 'auto';
773
+ extend?: boolean;
774
+ /** @deprecated Use "externalImportAttributes" instead. */
775
+ externalImportAssertions?: boolean;
776
+ externalImportAttributes?: boolean;
777
+ externalLiveBindings?: boolean;
778
+ // only required for bundle.write
779
+ file?: string;
780
+ footer?: string | AddonFunction;
781
+ format?: ModuleFormat;
782
+ freeze?: boolean;
783
+ generatedCode?: GeneratedCodePreset | GeneratedCodeOptions;
784
+ globals?: GlobalsOption;
785
+ hashCharacters?: HashCharacters;
786
+ hoistTransitiveImports?: boolean;
787
+ importAttributesKey?: ImportAttributesKey;
788
+ indent?: string | boolean;
789
+ inlineDynamicImports?: boolean;
790
+ interop?: InteropType | GetInterop;
791
+ intro?: string | AddonFunction;
792
+ manualChunks?: ManualChunksOption;
793
+ minifyInternalExports?: boolean;
794
+ name?: string;
795
+ noConflict?: boolean;
796
+ outro?: string | AddonFunction;
797
+ paths?: OptionsPaths;
798
+ plugins?: OutputPluginOption;
799
+ preserveModules?: boolean;
800
+ preserveModulesRoot?: string;
801
+ reexportProtoFromExternal?: boolean;
802
+ sanitizeFileName?: boolean | ((fileName: string) => string);
803
+ sourcemap?: boolean | 'inline' | 'hidden';
804
+ sourcemapBaseUrl?: string;
805
+ sourcemapExcludeSources?: boolean;
806
+ sourcemapFile?: string;
807
+ sourcemapFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
808
+ sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption;
809
+ sourcemapPathTransform?: SourcemapPathTransformOption;
810
+ sourcemapDebugIds?: boolean;
811
+ strict?: boolean;
812
+ systemNullSetters?: boolean;
813
+ validate?: boolean;
814
+ virtualDirname?: string;
815
+ }
816
+
817
+ interface NormalizedOutputOptions {
818
+ amd: NormalizedAmdOptions;
819
+ assetFileNames: string | ((chunkInfo: PreRenderedAsset) => string);
820
+ banner: AddonFunction;
821
+ chunkFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
822
+ compact: boolean;
823
+ dir: string | undefined;
824
+ dynamicImportInCjs: boolean;
825
+ entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
826
+ esModule: boolean | 'if-default-prop';
827
+ experimentalMinChunkSize: number;
828
+ exports: 'default' | 'named' | 'none' | 'auto';
829
+ extend: boolean;
830
+ /** @deprecated Use "externalImportAttributes" instead. */
831
+ externalImportAssertions: boolean;
832
+ externalImportAttributes: boolean;
833
+ externalLiveBindings: boolean;
834
+ file: string | undefined;
835
+ footer: AddonFunction;
836
+ format: InternalModuleFormat;
837
+ freeze: boolean;
838
+ generatedCode: NormalizedGeneratedCodeOptions;
839
+ globals: GlobalsOption;
840
+ hashCharacters: HashCharacters;
841
+ hoistTransitiveImports: boolean;
842
+ importAttributesKey: ImportAttributesKey;
843
+ indent: true | string;
844
+ inlineDynamicImports: boolean;
845
+ interop: GetInterop;
846
+ intro: AddonFunction;
847
+ manualChunks: ManualChunksOption;
848
+ minifyInternalExports: boolean;
849
+ name: string | undefined;
850
+ noConflict: boolean;
851
+ outro: AddonFunction;
852
+ paths: OptionsPaths;
853
+ plugins: OutputPlugin[];
854
+ preserveModules: boolean;
855
+ preserveModulesRoot: string | undefined;
856
+ reexportProtoFromExternal: boolean;
857
+ sanitizeFileName: (fileName: string) => string;
858
+ sourcemap: boolean | 'inline' | 'hidden';
859
+ sourcemapBaseUrl: string | undefined;
860
+ sourcemapExcludeSources: boolean;
861
+ sourcemapFile: string | undefined;
862
+ sourcemapFileNames: string | ((chunkInfo: PreRenderedChunk) => string) | undefined;
863
+ sourcemapIgnoreList: SourcemapIgnoreListOption;
864
+ sourcemapPathTransform: SourcemapPathTransformOption | undefined;
865
+ sourcemapDebugIds: boolean;
866
+ strict: boolean;
867
+ systemNullSetters: boolean;
868
+ validate: boolean;
869
+ virtualDirname: string;
870
+ }
871
+
872
+ type WarningHandlerWithDefault = (
873
+ warning: RollupLog,
874
+ defaultHandler: LoggingFunction
875
+ ) => void;
876
+
877
+ interface PreRenderedAsset {
878
+ /** @deprecated Use "names" instead. */
879
+ name: string | undefined;
880
+ names: string[];
881
+ /** @deprecated Use "originalFileNames" instead. */
882
+ originalFileName: string | null;
883
+ originalFileNames: string[];
884
+ source: string | Uint8Array;
885
+ type: 'asset';
886
+ }
887
+
888
+ interface OutputAsset extends PreRenderedAsset {
889
+ fileName: string;
890
+ needsCodeReference: boolean;
891
+ }
892
+
893
+ interface RenderedModule {
894
+ readonly code: string | null;
895
+ originalLength: number;
896
+ removedExports: string[];
897
+ renderedExports: string[];
898
+ renderedLength: number;
899
+ }
900
+
901
+ interface PreRenderedChunk {
902
+ exports: string[];
903
+ facadeModuleId: string | null;
904
+ isDynamicEntry: boolean;
905
+ isEntry: boolean;
906
+ isImplicitEntry: boolean;
907
+ moduleIds: string[];
908
+ name: string;
909
+ type: 'chunk';
910
+ }
911
+
912
+ interface RenderedChunk extends PreRenderedChunk {
913
+ dynamicImports: string[];
914
+ fileName: string;
915
+ implicitlyLoadedBefore: string[];
916
+ importedBindings: Record<string, string[]>;
917
+ imports: string[];
918
+ modules: Record<string, RenderedModule>;
919
+ referencedFiles: string[];
920
+ }
921
+
922
+ interface OutputChunk extends RenderedChunk {
923
+ code: string;
924
+ map: SourceMap | null;
925
+ sourcemapFileName: string | null;
926
+ preliminaryFileName: string;
927
+ }
928
+
929
+ type SerializablePluginCache = Record<string, [number, any]>;
930
+
931
+ interface RollupCache {
932
+ modules: ModuleJSON[];
933
+ plugins?: Record<string, SerializablePluginCache>;
934
+ }
935
+
936
+ interface ChokidarOptions {
937
+ alwaysStat?: boolean;
938
+ atomic?: boolean | number;
939
+ awaitWriteFinish?:
940
+ | {
941
+ pollInterval?: number;
942
+ stabilityThreshold?: number;
943
+ }
944
+ | boolean;
945
+ binaryInterval?: number;
946
+ cwd?: string;
947
+ depth?: number;
948
+ disableGlobbing?: boolean;
949
+ followSymlinks?: boolean;
950
+ ignoreInitial?: boolean;
951
+ ignorePermissionErrors?: boolean;
952
+ ignored?: any;
953
+ interval?: number;
954
+ persistent?: boolean;
955
+ useFsEvents?: boolean;
956
+ usePolling?: boolean;
957
+ }
958
+
959
+ interface WatcherOptions {
960
+ allowInputInsideOutputPath?: boolean;
961
+ buildDelay?: number;
962
+ chokidar?: ChokidarOptions;
963
+ clearScreen?: boolean;
964
+ exclude?: string | RegExp | (string | RegExp)[];
965
+ include?: string | RegExp | (string | RegExp)[];
966
+ skipWrite?: boolean;
967
+ onInvalidate?: (id: string) => void;
968
+ }
969
+
970
+ interface AstNodeLocation {
971
+ end: number;
972
+ start: number;
973
+ }
974
+
975
+ type OmittedEstreeKeys =
976
+ | 'loc'
977
+ | 'range'
978
+ | 'leadingComments'
979
+ | 'trailingComments'
980
+ | 'innerComments'
981
+ | 'comments';
982
+ type RollupAstNode<T> = Omit<T, OmittedEstreeKeys> & AstNodeLocation;
983
+
984
+ type ProgramNode = RollupAstNode<estree.Program>;
985
+ type AstNode = RollupAstNode<estree.Node>;
986
+
987
+ interface RollupFsModule {
988
+ appendFile(
989
+ path: string,
990
+ data: string | Uint8Array,
991
+ options?: { encoding?: BufferEncoding | null; mode?: string | number; flag?: string | number }
992
+ ): Promise<void>;
993
+
994
+ copyFile(source: string, destination: string, mode?: string | number): Promise<void>;
995
+
996
+ mkdir(path: string, options?: { recursive?: boolean; mode?: string | number }): Promise<void>;
997
+
998
+ mkdtemp(prefix: string): Promise<string>;
999
+
1000
+ readdir(path: string, options?: { withFileTypes?: false }): Promise<string[]>;
1001
+ readdir(path: string, options?: { withFileTypes: true }): Promise<RollupDirectoryEntry[]>;
1002
+
1003
+ readFile(
1004
+ path: string,
1005
+ options?: { encoding?: null; flag?: string | number; signal?: AbortSignal }
1006
+ ): Promise<Uint8Array>;
1007
+ readFile(
1008
+ path: string,
1009
+ options?: { encoding: BufferEncoding; flag?: string | number; signal?: AbortSignal }
1010
+ ): Promise<string>;
1011
+
1012
+ realpath(path: string): Promise<string>;
1013
+
1014
+ rename(oldPath: string, newPath: string): Promise<void>;
1015
+
1016
+ rmdir(path: string, options?: { recursive?: boolean }): Promise<void>;
1017
+
1018
+ stat(path: string): Promise<RollupFileStats>;
1019
+
1020
+ lstat(path: string): Promise<RollupFileStats>;
1021
+
1022
+ unlink(path: string): Promise<void>;
1023
+
1024
+ writeFile(
1025
+ path: string,
1026
+ data: string | Uint8Array,
1027
+ options?: { encoding?: BufferEncoding | null; mode?: string | number; flag?: string | number }
1028
+ ): Promise<void>;
1029
+ }
1030
+
1031
+ type BufferEncoding =
1032
+ | 'ascii'
1033
+ | 'utf8'
1034
+ | 'utf16le'
1035
+ | 'ucs2'
1036
+ | 'base64'
1037
+ | 'base64url'
1038
+ | 'latin1'
1039
+ | 'binary'
1040
+ | 'hex';
1041
+
1042
+ interface RollupDirectoryEntry {
1043
+ isFile(): boolean;
1044
+ isDirectory(): boolean;
1045
+ isSymbolicLink(): boolean;
1046
+ name: string;
1047
+ }
1048
+
1049
+ interface RollupFileStats {
1050
+ isFile(): boolean;
1051
+ isDirectory(): boolean;
1052
+ isSymbolicLink(): boolean;
1053
+ size: number;
1054
+ mtime: Date;
1055
+ ctime: Date;
1056
+ atime: Date;
1057
+ birthtime: Date;
1058
+ }
1059
+
1060
+ interface VitePluginInterface {
1061
+ toc: RemarkMdxTocOptions;
1062
+ settings: Settings;
1063
+ }
1064
+ declare function vitePlugins(options: VitePluginInterface): Promise<Plugin[]>;
1065
+
1066
+ export { type VitePluginInterface, vitePlugins };