@storyblok/astro 1.2.0 → 2.0.1

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.
@@ -0,0 +1,936 @@
1
+ export const VERSION: string;
2
+
3
+ // utils
4
+ type NullValue = null | undefined | void;
5
+ type MaybeArray<T> = T | T[];
6
+ type MaybePromise<T> = T | Promise<T>;
7
+
8
+ type PartialNull<T> = {
9
+ [P in keyof T]: T[P] | null;
10
+ };
11
+
12
+ export interface RollupError extends RollupLog {
13
+ name?: string;
14
+ stack?: string;
15
+ watchFiles?: string[];
16
+ }
17
+
18
+ export type RollupWarning = RollupLog;
19
+
20
+ export interface RollupLog {
21
+ binding?: string;
22
+ cause?: Error;
23
+ code?: string;
24
+ exporter?: string;
25
+ frame?: string;
26
+ hook?: string;
27
+ id?: string;
28
+ ids?: string[];
29
+ loc?: {
30
+ column: number;
31
+ file?: string;
32
+ line: number;
33
+ };
34
+ message: string;
35
+ names?: string[];
36
+ plugin?: string;
37
+ pluginCode?: string;
38
+ pos?: number;
39
+ reexporter?: string;
40
+ stack?: string;
41
+ url?: string;
42
+ }
43
+
44
+ export type SourceMapSegment =
45
+ | [number]
46
+ | [number, number, number, number]
47
+ | [number, number, number, number, number];
48
+
49
+ export interface ExistingDecodedSourceMap {
50
+ file?: string;
51
+ mappings: SourceMapSegment[][];
52
+ names: string[];
53
+ sourceRoot?: string;
54
+ sources: string[];
55
+ sourcesContent?: string[];
56
+ version: number;
57
+ }
58
+
59
+ export interface ExistingRawSourceMap {
60
+ file?: string;
61
+ mappings: string;
62
+ names: string[];
63
+ sourceRoot?: string;
64
+ sources: string[];
65
+ sourcesContent?: string[];
66
+ version: number;
67
+ }
68
+
69
+ export type DecodedSourceMapOrMissing =
70
+ | {
71
+ mappings?: never;
72
+ missing: true;
73
+ plugin: string;
74
+ }
75
+ | ExistingDecodedSourceMap;
76
+
77
+ export interface SourceMap {
78
+ file: string;
79
+ mappings: string;
80
+ names: string[];
81
+ sources: string[];
82
+ sourcesContent: string[];
83
+ version: number;
84
+ toString(): string;
85
+ toUrl(): string;
86
+ }
87
+
88
+ export type SourceMapInput = ExistingRawSourceMap | string | null | { mappings: '' };
89
+
90
+ interface ModuleOptions {
91
+ assertions: Record<string, string>;
92
+ meta: CustomPluginOptions;
93
+ moduleSideEffects: boolean | 'no-treeshake';
94
+ syntheticNamedExports: boolean | string;
95
+ }
96
+
97
+ export interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
98
+ ast?: AcornNode;
99
+ code: string;
100
+ map?: SourceMapInput;
101
+ }
102
+
103
+ export interface TransformModuleJSON {
104
+ ast?: AcornNode;
105
+ code: string;
106
+ // note if plugins use new this.cache to opt-out auto transform cache
107
+ customTransformCache: boolean;
108
+ originalCode: string;
109
+ originalSourcemap: ExistingDecodedSourceMap | null;
110
+ sourcemapChain: DecodedSourceMapOrMissing[];
111
+ transformDependencies: string[];
112
+ }
113
+
114
+ export interface ModuleJSON extends TransformModuleJSON, ModuleOptions {
115
+ ast: AcornNode;
116
+ dependencies: string[];
117
+ id: string;
118
+ resolvedIds: ResolvedIdMap;
119
+ transformFiles: EmittedFile[] | undefined;
120
+ }
121
+
122
+ export interface PluginCache {
123
+ delete(id: string): boolean;
124
+ get<T = any>(id: string): T;
125
+ has(id: string): boolean;
126
+ set<T = any>(id: string, value: T): void;
127
+ }
128
+
129
+ export interface MinimalPluginContext {
130
+ meta: PluginContextMeta;
131
+ }
132
+
133
+ export interface EmittedAsset {
134
+ fileName?: string;
135
+ name?: string;
136
+ source?: string | Uint8Array;
137
+ type: 'asset';
138
+ }
139
+
140
+ export interface EmittedChunk {
141
+ fileName?: string;
142
+ id: string;
143
+ implicitlyLoadedAfterOneOf?: string[];
144
+ importer?: string;
145
+ name?: string;
146
+ preserveSignature?: PreserveEntrySignaturesOption;
147
+ type: 'chunk';
148
+ }
149
+
150
+ export type EmittedFile = EmittedAsset | EmittedChunk;
151
+
152
+ export type EmitFile = (emittedFile: EmittedFile) => string;
153
+
154
+ interface ModuleInfo extends ModuleOptions {
155
+ ast: AcornNode | null;
156
+ code: string | null;
157
+ dynamicImporters: readonly string[];
158
+ dynamicallyImportedIdResolutions: readonly ResolvedId[];
159
+ dynamicallyImportedIds: readonly string[];
160
+ exportedBindings: Record<string, string[]> | null;
161
+ exports: string[] | null;
162
+ hasDefaultExport: boolean | null;
163
+ /** @deprecated Use `moduleSideEffects` instead */
164
+ hasModuleSideEffects: boolean | 'no-treeshake';
165
+ id: string;
166
+ implicitlyLoadedAfterOneOf: readonly string[];
167
+ implicitlyLoadedBefore: readonly string[];
168
+ importedIdResolutions: readonly ResolvedId[];
169
+ importedIds: readonly string[];
170
+ importers: readonly string[];
171
+ isEntry: boolean;
172
+ isExternal: boolean;
173
+ isIncluded: boolean | null;
174
+ }
175
+
176
+ export type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
177
+
178
+ export interface CustomPluginOptions {
179
+ [plugin: string]: any;
180
+ }
181
+
182
+ export interface PluginContext extends MinimalPluginContext {
183
+ addWatchFile: (id: string) => void;
184
+ cache: PluginCache;
185
+ emitFile: EmitFile;
186
+ error: (error: RollupError | string, pos?: number | { column: number; line: number }) => never;
187
+ getFileName: (fileReferenceId: string) => string;
188
+ getModuleIds: () => IterableIterator<string>;
189
+ getModuleInfo: GetModuleInfo;
190
+ getWatchFiles: () => string[];
191
+ load: (
192
+ options: { id: string; resolveDependencies?: boolean } & Partial<PartialNull<ModuleOptions>>
193
+ ) => Promise<ModuleInfo>;
194
+ /** @deprecated Use `this.getModuleIds` instead */
195
+ moduleIds: IterableIterator<string>;
196
+ parse: (input: string, options?: any) => AcornNode;
197
+ resolve: (
198
+ source: string,
199
+ importer?: string,
200
+ options?: {
201
+ assertions?: Record<string, string>;
202
+ custom?: CustomPluginOptions;
203
+ isEntry?: boolean;
204
+ skipSelf?: boolean;
205
+ }
206
+ ) => Promise<ResolvedId | null>;
207
+ setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
208
+ warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void;
209
+ }
210
+
211
+ export interface PluginContextMeta {
212
+ rollupVersion: string;
213
+ watchMode: boolean;
214
+ }
215
+
216
+ export interface ResolvedId extends ModuleOptions {
217
+ external: boolean | 'absolute';
218
+ id: string;
219
+ }
220
+
221
+ export interface ResolvedIdMap {
222
+ [key: string]: ResolvedId;
223
+ }
224
+
225
+ interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
226
+ external?: boolean | 'absolute' | 'relative';
227
+ id: string;
228
+ }
229
+
230
+ export type ResolveIdResult = string | NullValue | false | PartialResolvedId;
231
+
232
+ export type ResolveIdHook = (
233
+ this: PluginContext,
234
+ source: string,
235
+ importer: string | undefined,
236
+ options: { assertions: Record<string, string>; custom?: CustomPluginOptions; isEntry: boolean }
237
+ ) => ResolveIdResult;
238
+
239
+ export type ShouldTransformCachedModuleHook = (
240
+ this: PluginContext,
241
+ options: {
242
+ ast: AcornNode;
243
+ code: string;
244
+ id: string;
245
+ meta: CustomPluginOptions;
246
+ moduleSideEffects: boolean | 'no-treeshake';
247
+ resolvedSources: ResolvedIdMap;
248
+ syntheticNamedExports: boolean | string;
249
+ }
250
+ ) => boolean;
251
+
252
+ export type IsExternal = (
253
+ source: string,
254
+ importer: string | undefined,
255
+ isResolved: boolean
256
+ ) => boolean;
257
+
258
+ export type IsPureModule = (id: string) => boolean | NullValue;
259
+
260
+ export type HasModuleSideEffects = (id: string, external: boolean) => boolean;
261
+
262
+ export type LoadResult = SourceDescription | string | NullValue;
263
+
264
+ export type LoadHook = (this: PluginContext, id: string) => LoadResult;
265
+
266
+ export interface TransformPluginContext extends PluginContext {
267
+ getCombinedSourcemap: () => SourceMap;
268
+ }
269
+
270
+ export type TransformResult = string | NullValue | Partial<SourceDescription>;
271
+
272
+ export type TransformHook = (
273
+ this: TransformPluginContext,
274
+ code: string,
275
+ id: string
276
+ ) => TransformResult;
277
+
278
+ export type ModuleParsedHook = (this: PluginContext, info: ModuleInfo) => void;
279
+
280
+ export type RenderChunkHook = (
281
+ this: PluginContext,
282
+ code: string,
283
+ chunk: RenderedChunk,
284
+ options: NormalizedOutputOptions,
285
+ meta: { chunks: Record<string, RenderedChunk> }
286
+ ) => { code: string; map?: SourceMapInput } | string | NullValue;
287
+
288
+ export type ResolveDynamicImportHook = (
289
+ this: PluginContext,
290
+ specifier: string | AcornNode,
291
+ importer: string,
292
+ options: { assertions: Record<string, string> }
293
+ ) => ResolveIdResult;
294
+
295
+ export type ResolveImportMetaHook = (
296
+ this: PluginContext,
297
+ property: string | null,
298
+ options: { chunkId: string; format: InternalModuleFormat; moduleId: string }
299
+ ) => string | NullValue;
300
+
301
+ export type ResolveFileUrlHook = (
302
+ this: PluginContext,
303
+ options: {
304
+ chunkId: string;
305
+ fileName: string;
306
+ format: InternalModuleFormat;
307
+ moduleId: string;
308
+ referenceId: string;
309
+ relativePath: string;
310
+ }
311
+ ) => string | NullValue;
312
+
313
+ export type AddonHookFunction = (
314
+ this: PluginContext,
315
+ chunk: RenderedChunk
316
+ ) => string | Promise<string>;
317
+ export type AddonHook = string | AddonHookFunction;
318
+
319
+ export type ChangeEvent = 'create' | 'update' | 'delete';
320
+ export type WatchChangeHook = (
321
+ this: PluginContext,
322
+ id: string,
323
+ change: { event: ChangeEvent }
324
+ ) => void;
325
+
326
+ /**
327
+ * use this type for plugin annotation
328
+ * @example
329
+ * ```ts
330
+ * interface Options {
331
+ * ...
332
+ * }
333
+ * const myPlugin: PluginImpl<Options> = (options = {}) => { ... }
334
+ * ```
335
+ */
336
+ // eslint-disable-next-line @typescript-eslint/ban-types
337
+ export type PluginImpl<O extends object = object> = (options?: O) => Plugin;
338
+
339
+ export interface OutputBundle {
340
+ [fileName: string]: OutputAsset | OutputChunk;
341
+ }
342
+
343
+ export interface FunctionPluginHooks {
344
+ augmentChunkHash: (this: PluginContext, chunk: RenderedChunk) => string | void;
345
+ buildEnd: (this: PluginContext, error?: Error) => void;
346
+ buildStart: (this: PluginContext, options: NormalizedInputOptions) => void;
347
+ closeBundle: (this: PluginContext) => void;
348
+ closeWatcher: (this: PluginContext) => void;
349
+ generateBundle: (
350
+ this: PluginContext,
351
+ options: NormalizedOutputOptions,
352
+ bundle: OutputBundle,
353
+ isWrite: boolean
354
+ ) => void;
355
+ load: LoadHook;
356
+ moduleParsed: ModuleParsedHook;
357
+ options: (this: MinimalPluginContext, options: InputOptions) => InputOptions | NullValue;
358
+ outputOptions: (this: PluginContext, options: OutputOptions) => OutputOptions | NullValue;
359
+ renderChunk: RenderChunkHook;
360
+ renderDynamicImport: (
361
+ this: PluginContext,
362
+ options: {
363
+ customResolution: string | null;
364
+ format: InternalModuleFormat;
365
+ moduleId: string;
366
+ targetModuleId: string | null;
367
+ }
368
+ ) => { left: string; right: string } | NullValue;
369
+ renderError: (this: PluginContext, error?: Error) => void;
370
+ renderStart: (
371
+ this: PluginContext,
372
+ outputOptions: NormalizedOutputOptions,
373
+ inputOptions: NormalizedInputOptions
374
+ ) => void;
375
+ resolveDynamicImport: ResolveDynamicImportHook;
376
+ resolveFileUrl: ResolveFileUrlHook;
377
+ resolveId: ResolveIdHook;
378
+ resolveImportMeta: ResolveImportMetaHook;
379
+ shouldTransformCachedModule: ShouldTransformCachedModuleHook;
380
+ transform: TransformHook;
381
+ watchChange: WatchChangeHook;
382
+ writeBundle: (
383
+ this: PluginContext,
384
+ options: NormalizedOutputOptions,
385
+ bundle: OutputBundle
386
+ ) => void;
387
+ }
388
+
389
+ export type OutputPluginHooks =
390
+ | 'augmentChunkHash'
391
+ | 'generateBundle'
392
+ | 'outputOptions'
393
+ | 'renderChunk'
394
+ | 'renderDynamicImport'
395
+ | 'renderError'
396
+ | 'renderStart'
397
+ | 'resolveFileUrl'
398
+ | 'resolveImportMeta'
399
+ | 'writeBundle';
400
+
401
+ export type InputPluginHooks = Exclude<keyof FunctionPluginHooks, OutputPluginHooks>;
402
+
403
+ export type SyncPluginHooks =
404
+ | 'augmentChunkHash'
405
+ | 'outputOptions'
406
+ | 'renderDynamicImport'
407
+ | 'resolveFileUrl'
408
+ | 'resolveImportMeta';
409
+
410
+ export type AsyncPluginHooks = Exclude<keyof FunctionPluginHooks, SyncPluginHooks>;
411
+
412
+ export type FirstPluginHooks =
413
+ | 'load'
414
+ | 'renderDynamicImport'
415
+ | 'resolveDynamicImport'
416
+ | 'resolveFileUrl'
417
+ | 'resolveId'
418
+ | 'resolveImportMeta'
419
+ | 'shouldTransformCachedModule';
420
+
421
+ export type SequentialPluginHooks =
422
+ | 'augmentChunkHash'
423
+ | 'generateBundle'
424
+ | 'options'
425
+ | 'outputOptions'
426
+ | 'renderChunk'
427
+ | 'transform';
428
+
429
+ export type ParallelPluginHooks = Exclude<
430
+ keyof FunctionPluginHooks | AddonHooks,
431
+ FirstPluginHooks | SequentialPluginHooks
432
+ >;
433
+
434
+ export type AddonHooks = 'banner' | 'footer' | 'intro' | 'outro';
435
+
436
+ type MakeAsync<Function_> = Function_ extends (
437
+ this: infer This,
438
+ ...parameters: infer Arguments
439
+ ) => infer Return
440
+ ? (this: This, ...parameters: Arguments) => Return | Promise<Return>
441
+ : never;
442
+
443
+ // eslint-disable-next-line @typescript-eslint/ban-types
444
+ type ObjectHook<T, O = {}> = T | ({ handler: T; order?: 'pre' | 'post' | null } & O);
445
+
446
+ export type PluginHooks = {
447
+ [K in keyof FunctionPluginHooks]: ObjectHook<
448
+ K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K],
449
+ // eslint-disable-next-line @typescript-eslint/ban-types
450
+ K extends ParallelPluginHooks ? { sequential?: boolean } : {}
451
+ >;
452
+ };
453
+
454
+ export interface OutputPlugin
455
+ extends Partial<{ [K in OutputPluginHooks]: PluginHooks[K] }>,
456
+ Partial<{ [K in AddonHooks]: ObjectHook<AddonHook> }> {
457
+ cacheKey?: string;
458
+ name: string;
459
+ }
460
+
461
+ export interface Plugin extends OutputPlugin, Partial<PluginHooks> {
462
+ // for inter-plugin communication
463
+ api?: any;
464
+ }
465
+
466
+ type TreeshakingPreset = 'smallest' | 'safest' | 'recommended';
467
+
468
+ export interface NormalizedTreeshakingOptions {
469
+ annotations: boolean;
470
+ correctVarValueBeforeDeclaration: boolean;
471
+ manualPureFunctions: readonly string[];
472
+ moduleSideEffects: HasModuleSideEffects;
473
+ propertyReadSideEffects: boolean | 'always';
474
+ tryCatchDeoptimization: boolean;
475
+ unknownGlobalSideEffects: boolean;
476
+ }
477
+
478
+ export interface TreeshakingOptions
479
+ extends Partial<Omit<NormalizedTreeshakingOptions, 'moduleSideEffects'>> {
480
+ moduleSideEffects?: ModuleSideEffectsOption;
481
+ preset?: TreeshakingPreset;
482
+ }
483
+
484
+ interface ManualChunkMeta {
485
+ getModuleIds: () => IterableIterator<string>;
486
+ getModuleInfo: GetModuleInfo;
487
+ }
488
+ export type GetManualChunk = (id: string, meta: ManualChunkMeta) => string | NullValue;
489
+
490
+ export type ExternalOption =
491
+ | (string | RegExp)[]
492
+ | string
493
+ | RegExp
494
+ | ((source: string, importer: string | undefined, isResolved: boolean) => boolean | NullValue);
495
+ export type PureModulesOption = boolean | string[] | IsPureModule;
496
+ export type GlobalsOption = { [name: string]: string } | ((name: string) => string);
497
+ export type InputOption = string | string[] | { [entryAlias: string]: string };
498
+ export type ManualChunksOption = { [chunkAlias: string]: string[] } | GetManualChunk;
499
+ export type ModuleSideEffectsOption = boolean | 'no-external' | string[] | HasModuleSideEffects;
500
+ export type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
501
+ export type SourcemapPathTransformOption = (
502
+ relativeSourcePath: string,
503
+ sourcemapPath: string
504
+ ) => string;
505
+
506
+ export type InputPluginOption = MaybePromise<Plugin | NullValue | false | InputPluginOption[]>;
507
+
508
+ export interface InputOptions {
509
+ acorn?: Record<string, unknown>;
510
+ acornInjectPlugins?: (() => unknown)[] | (() => unknown);
511
+ cache?: false | RollupCache;
512
+ context?: string;
513
+ experimentalCacheExpiry?: number;
514
+ external?: ExternalOption;
515
+ /** @deprecated Use the "inlineDynamicImports" output option instead. */
516
+ inlineDynamicImports?: boolean;
517
+ input?: InputOption;
518
+ makeAbsoluteExternalsRelative?: boolean | 'ifRelativeSource';
519
+ /** @deprecated Use the "manualChunks" output option instead. */
520
+ manualChunks?: ManualChunksOption;
521
+ maxParallelFileOps?: number;
522
+ /** @deprecated Use the "maxParallelFileOps" option instead. */
523
+ maxParallelFileReads?: number;
524
+ moduleContext?: ((id: string) => string | NullValue) | { [id: string]: string };
525
+ onwarn?: WarningHandlerWithDefault;
526
+ perf?: boolean;
527
+ plugins?: InputPluginOption;
528
+ preserveEntrySignatures?: PreserveEntrySignaturesOption;
529
+ /** @deprecated Use the "preserveModules" output option instead. */
530
+ preserveModules?: boolean;
531
+ preserveSymlinks?: boolean;
532
+ shimMissingExports?: boolean;
533
+ strictDeprecations?: boolean;
534
+ treeshake?: boolean | TreeshakingPreset | TreeshakingOptions;
535
+ watch?: WatcherOptions | false;
536
+ }
537
+
538
+ export interface InputOptionsWithPlugins extends InputOptions {
539
+ plugins: Plugin[];
540
+ }
541
+
542
+ export interface NormalizedInputOptions {
543
+ acorn: Record<string, unknown>;
544
+ acornInjectPlugins: (() => unknown)[];
545
+ cache: false | undefined | RollupCache;
546
+ context: string;
547
+ experimentalCacheExpiry: number;
548
+ external: IsExternal;
549
+ /** @deprecated Use the "inlineDynamicImports" output option instead. */
550
+ inlineDynamicImports: boolean | undefined;
551
+ input: string[] | { [entryAlias: string]: string };
552
+ makeAbsoluteExternalsRelative: boolean | 'ifRelativeSource';
553
+ /** @deprecated Use the "manualChunks" output option instead. */
554
+ manualChunks: ManualChunksOption | undefined;
555
+ maxParallelFileOps: number;
556
+ /** @deprecated Use the "maxParallelFileOps" option instead. */
557
+ maxParallelFileReads: number;
558
+ moduleContext: (id: string) => string;
559
+ onwarn: WarningHandler;
560
+ perf: boolean;
561
+ plugins: Plugin[];
562
+ preserveEntrySignatures: PreserveEntrySignaturesOption;
563
+ /** @deprecated Use the "preserveModules" output option instead. */
564
+ preserveModules: boolean | undefined;
565
+ preserveSymlinks: boolean;
566
+ shimMissingExports: boolean;
567
+ strictDeprecations: boolean;
568
+ treeshake: false | NormalizedTreeshakingOptions;
569
+ }
570
+
571
+ export type InternalModuleFormat = 'amd' | 'cjs' | 'es' | 'iife' | 'system' | 'umd';
572
+
573
+ export type ModuleFormat = InternalModuleFormat | 'commonjs' | 'esm' | 'module' | 'systemjs';
574
+
575
+ type GeneratedCodePreset = 'es5' | 'es2015';
576
+
577
+ interface NormalizedGeneratedCodeOptions {
578
+ arrowFunctions: boolean;
579
+ constBindings: boolean;
580
+ objectShorthand: boolean;
581
+ reservedNamesAsProps: boolean;
582
+ symbols: boolean;
583
+ }
584
+
585
+ interface GeneratedCodeOptions extends Partial<NormalizedGeneratedCodeOptions> {
586
+ preset?: GeneratedCodePreset;
587
+ }
588
+
589
+ export type OptionsPaths = Record<string, string> | ((id: string) => string);
590
+
591
+ export type InteropType = 'compat' | 'auto' | 'esModule' | 'default' | 'defaultOnly';
592
+
593
+ export type GetInterop = (id: string | null) => InteropType;
594
+
595
+ export type AmdOptions = (
596
+ | {
597
+ autoId?: false;
598
+ id: string;
599
+ }
600
+ | {
601
+ autoId: true;
602
+ basePath?: string;
603
+ id?: undefined;
604
+ }
605
+ | {
606
+ autoId?: false;
607
+ id?: undefined;
608
+ }
609
+ ) & {
610
+ define?: string;
611
+ forceJsExtensionForImports?: boolean;
612
+ };
613
+
614
+ export type NormalizedAmdOptions = (
615
+ | {
616
+ autoId: false;
617
+ id?: string;
618
+ }
619
+ | {
620
+ autoId: true;
621
+ basePath: string;
622
+ }
623
+ ) & {
624
+ define: string;
625
+ forceJsExtensionForImports: boolean;
626
+ };
627
+
628
+ type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
629
+
630
+ type OutputPluginOption = MaybePromise<OutputPlugin | NullValue | false | OutputPluginOption[]>;
631
+
632
+ export interface OutputOptions {
633
+ amd?: AmdOptions;
634
+ assetFileNames?: string | ((chunkInfo: PreRenderedAsset) => string);
635
+ banner?: string | AddonFunction;
636
+ chunkFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
637
+ compact?: boolean;
638
+ // only required for bundle.write
639
+ dir?: string;
640
+ /** @deprecated Use the "renderDynamicImport" plugin hook instead. */
641
+ dynamicImportFunction?: string;
642
+ dynamicImportInCjs?: boolean;
643
+ entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
644
+ esModule?: boolean | 'if-default-prop';
645
+ experimentalMinChunkSize?: number;
646
+ exports?: 'default' | 'named' | 'none' | 'auto';
647
+ extend?: boolean;
648
+ externalImportAssertions?: boolean;
649
+ externalLiveBindings?: boolean;
650
+ // only required for bundle.write
651
+ file?: string;
652
+ footer?: string | AddonFunction;
653
+ format?: ModuleFormat;
654
+ freeze?: boolean;
655
+ generatedCode?: GeneratedCodePreset | GeneratedCodeOptions;
656
+ globals?: GlobalsOption;
657
+ hoistTransitiveImports?: boolean;
658
+ indent?: string | boolean;
659
+ inlineDynamicImports?: boolean;
660
+ interop?: InteropType | GetInterop;
661
+ intro?: string | AddonFunction;
662
+ manualChunks?: ManualChunksOption;
663
+ minifyInternalExports?: boolean;
664
+ name?: string;
665
+ /** @deprecated Use "generatedCode.symbols" instead. */
666
+ namespaceToStringTag?: boolean;
667
+ noConflict?: boolean;
668
+ outro?: string | AddonFunction;
669
+ paths?: OptionsPaths;
670
+ plugins?: OutputPluginOption;
671
+ /** @deprecated Use "generatedCode.constBindings" instead. */
672
+ preferConst?: boolean;
673
+ preserveModules?: boolean;
674
+ preserveModulesRoot?: string;
675
+ sanitizeFileName?: boolean | ((fileName: string) => string);
676
+ sourcemap?: boolean | 'inline' | 'hidden';
677
+ sourcemapBaseUrl?: string;
678
+ sourcemapExcludeSources?: boolean;
679
+ sourcemapFile?: string;
680
+ sourcemapPathTransform?: SourcemapPathTransformOption;
681
+ strict?: boolean;
682
+ systemNullSetters?: boolean;
683
+ validate?: boolean;
684
+ }
685
+
686
+ export interface NormalizedOutputOptions {
687
+ amd: NormalizedAmdOptions;
688
+ assetFileNames: string | ((chunkInfo: PreRenderedAsset) => string);
689
+ banner: AddonFunction;
690
+ chunkFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
691
+ compact: boolean;
692
+ dir: string | undefined;
693
+ /** @deprecated Use the "renderDynamicImport" plugin hook instead. */
694
+ dynamicImportFunction: string | undefined;
695
+ dynamicImportInCjs: boolean;
696
+ entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
697
+ esModule: boolean | 'if-default-prop';
698
+ experimentalMinChunkSize: number;
699
+ exports: 'default' | 'named' | 'none' | 'auto';
700
+ extend: boolean;
701
+ externalImportAssertions: boolean;
702
+ externalLiveBindings: boolean;
703
+ file: string | undefined;
704
+ footer: AddonFunction;
705
+ format: InternalModuleFormat;
706
+ freeze: boolean;
707
+ generatedCode: NormalizedGeneratedCodeOptions;
708
+ globals: GlobalsOption;
709
+ hoistTransitiveImports: boolean;
710
+ indent: true | string;
711
+ inlineDynamicImports: boolean;
712
+ interop: GetInterop;
713
+ intro: AddonFunction;
714
+ manualChunks: ManualChunksOption;
715
+ minifyInternalExports: boolean;
716
+ name: string | undefined;
717
+ /** @deprecated Use "generatedCode.symbols" instead. */
718
+ namespaceToStringTag: boolean;
719
+ noConflict: boolean;
720
+ outro: AddonFunction;
721
+ paths: OptionsPaths;
722
+ plugins: OutputPlugin[];
723
+ /** @deprecated Use "generatedCode.constBindings" instead. */
724
+ preferConst: boolean;
725
+ preserveModules: boolean;
726
+ preserveModulesRoot: string | undefined;
727
+ sanitizeFileName: (fileName: string) => string;
728
+ sourcemap: boolean | 'inline' | 'hidden';
729
+ sourcemapBaseUrl: string | undefined;
730
+ sourcemapExcludeSources: boolean;
731
+ sourcemapFile: string | undefined;
732
+ sourcemapPathTransform: SourcemapPathTransformOption | undefined;
733
+ strict: boolean;
734
+ systemNullSetters: boolean;
735
+ validate: boolean;
736
+ }
737
+
738
+ export type WarningHandlerWithDefault = (
739
+ warning: RollupWarning,
740
+ defaultHandler: WarningHandler
741
+ ) => void;
742
+ export type WarningHandler = (warning: RollupWarning) => void;
743
+
744
+ export interface SerializedTimings {
745
+ [label: string]: [number, number, number];
746
+ }
747
+
748
+ export interface PreRenderedAsset {
749
+ name: string | undefined;
750
+ source: string | Uint8Array;
751
+ type: 'asset';
752
+ }
753
+
754
+ export interface OutputAsset extends PreRenderedAsset {
755
+ fileName: string;
756
+ }
757
+
758
+ export interface RenderedModule {
759
+ code: string | null;
760
+ originalLength: number;
761
+ removedExports: string[];
762
+ renderedExports: string[];
763
+ renderedLength: number;
764
+ }
765
+
766
+ export interface PreRenderedChunk {
767
+ exports: string[];
768
+ facadeModuleId: string | null;
769
+ isDynamicEntry: boolean;
770
+ isEntry: boolean;
771
+ isImplicitEntry: boolean;
772
+ moduleIds: string[];
773
+ name: string;
774
+ type: 'chunk';
775
+ }
776
+
777
+ export interface RenderedChunk extends PreRenderedChunk {
778
+ dynamicImports: string[];
779
+ fileName: string;
780
+ implicitlyLoadedBefore: string[];
781
+ importedBindings: {
782
+ [imported: string]: string[];
783
+ };
784
+ imports: string[];
785
+ modules: {
786
+ [id: string]: RenderedModule;
787
+ };
788
+ referencedFiles: string[];
789
+ }
790
+
791
+ export interface OutputChunk extends RenderedChunk {
792
+ code: string;
793
+ map: SourceMap | null;
794
+ }
795
+
796
+ export interface SerializablePluginCache {
797
+ [key: string]: [number, any];
798
+ }
799
+
800
+ export interface RollupCache {
801
+ modules: ModuleJSON[];
802
+ plugins?: Record<string, SerializablePluginCache>;
803
+ }
804
+
805
+ export interface RollupOutput {
806
+ output: [OutputChunk, ...(OutputChunk | OutputAsset)[]];
807
+ }
808
+
809
+ export interface RollupBuild {
810
+ cache: RollupCache | undefined;
811
+ close: () => Promise<void>;
812
+ closed: boolean;
813
+ generate: (outputOptions: OutputOptions) => Promise<RollupOutput>;
814
+ getTimings?: () => SerializedTimings;
815
+ watchFiles: string[];
816
+ write: (options: OutputOptions) => Promise<RollupOutput>;
817
+ }
818
+
819
+ export interface RollupOptions extends InputOptions {
820
+ // This is included for compatibility with config files but ignored by rollup.rollup
821
+ output?: OutputOptions | OutputOptions[];
822
+ }
823
+
824
+ export interface MergedRollupOptions extends InputOptionsWithPlugins {
825
+ output: OutputOptions[];
826
+ }
827
+
828
+ export function rollup(options: RollupOptions): Promise<RollupBuild>;
829
+
830
+ export interface ChokidarOptions {
831
+ alwaysStat?: boolean;
832
+ atomic?: boolean | number;
833
+ awaitWriteFinish?:
834
+ | {
835
+ pollInterval?: number;
836
+ stabilityThreshold?: number;
837
+ }
838
+ | boolean;
839
+ binaryInterval?: number;
840
+ cwd?: string;
841
+ depth?: number;
842
+ disableGlobbing?: boolean;
843
+ followSymlinks?: boolean;
844
+ ignoreInitial?: boolean;
845
+ ignorePermissionErrors?: boolean;
846
+ ignored?: any;
847
+ interval?: number;
848
+ persistent?: boolean;
849
+ useFsEvents?: boolean;
850
+ usePolling?: boolean;
851
+ }
852
+
853
+ export type RollupWatchHooks = 'onError' | 'onStart' | 'onBundleStart' | 'onBundleEnd' | 'onEnd';
854
+
855
+ export interface WatcherOptions {
856
+ buildDelay?: number;
857
+ chokidar?: ChokidarOptions;
858
+ clearScreen?: boolean;
859
+ exclude?: string | RegExp | (string | RegExp)[];
860
+ include?: string | RegExp | (string | RegExp)[];
861
+ skipWrite?: boolean;
862
+ }
863
+
864
+ export interface RollupWatchOptions extends InputOptions {
865
+ output?: OutputOptions | OutputOptions[];
866
+ watch?: WatcherOptions | false;
867
+ }
868
+
869
+ export type AwaitedEventListener<
870
+ T extends { [event: string]: (...parameters: any) => any },
871
+ K extends keyof T
872
+ > = (...parameters: Parameters<T[K]>) => void | Promise<void>;
873
+
874
+ export interface AwaitingEventEmitter<T extends { [event: string]: (...parameters: any) => any }> {
875
+ close(): Promise<void>;
876
+ emit<K extends keyof T>(event: K, ...parameters: Parameters<T[K]>): Promise<unknown>;
877
+ /**
878
+ * Removes an event listener.
879
+ */
880
+ off<K extends keyof T>(event: K, listener: AwaitedEventListener<T, K>): this;
881
+ /**
882
+ * Registers an event listener that will be awaited before Rollup continues.
883
+ * All listeners will be awaited in parallel while rejections are tracked via
884
+ * Promise.all.
885
+ */
886
+ on<K extends keyof T>(event: K, listener: AwaitedEventListener<T, K>): this;
887
+ /**
888
+ * Registers an event listener that will be awaited before Rollup continues.
889
+ * All listeners will be awaited in parallel while rejections are tracked via
890
+ * Promise.all.
891
+ * Listeners are removed automatically when removeListenersForCurrentRun is
892
+ * called, which happens automatically after each run.
893
+ */
894
+ onCurrentRun<K extends keyof T>(
895
+ event: K,
896
+ listener: (...parameters: Parameters<T[K]>) => Promise<ReturnType<T[K]>>
897
+ ): this;
898
+ removeAllListeners(): this;
899
+ removeListenersForCurrentRun(): this;
900
+ }
901
+
902
+ export type RollupWatcherEvent =
903
+ | { code: 'START' }
904
+ | { code: 'BUNDLE_START'; input?: InputOption; output: readonly string[] }
905
+ | {
906
+ code: 'BUNDLE_END';
907
+ duration: number;
908
+ input?: InputOption;
909
+ output: readonly string[];
910
+ result: RollupBuild;
911
+ }
912
+ | { code: 'END' }
913
+ | { code: 'ERROR'; error: RollupError; result: RollupBuild | null };
914
+
915
+ export type RollupWatcher = AwaitingEventEmitter<{
916
+ change: (id: string, change: { event: ChangeEvent }) => void;
917
+ close: () => void;
918
+ event: (event: RollupWatcherEvent) => void;
919
+ restart: () => void;
920
+ }>;
921
+
922
+ export function watch(config: RollupWatchOptions | RollupWatchOptions[]): RollupWatcher;
923
+
924
+ interface AcornNode {
925
+ end: number;
926
+ start: number;
927
+ type: string;
928
+ }
929
+
930
+ export function defineConfig(options: RollupOptions): RollupOptions;
931
+ export function defineConfig(options: RollupOptions[]): RollupOptions[];
932
+ export function defineConfig(optionsFunction: RollupOptionsFunction): RollupOptionsFunction;
933
+
934
+ export type RollupOptionsFunction = (
935
+ commandLineArguments: Record<string, any>
936
+ ) => MaybePromise<RollupOptions | RollupOptions[]>;