docs:更新文档

This commit is contained in:
张益铭
2021-03-01 15:06:11 +08:00
parent 1542135ab0
commit 9064b372e8
5835 changed files with 904126 additions and 161722 deletions

1690
node_modules/rollup/dist/bin/rollup generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/rollup/dist/es/package.json generated vendored Normal file
View File

@@ -0,0 +1 @@
{"type":"module"}

11
node_modules/rollup/dist/es/rollup.browser.js generated vendored Normal file

File diff suppressed because one or more lines are too long

15
node_modules/rollup/dist/es/rollup.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
/*
@license
Rollup.js v2.33.1
Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
https://github.com/rollup/rollup
Released under the MIT License.
*/
export { version as VERSION, rollup, watch } from './shared/rollup.js';
import 'path';
import 'crypto';
import 'fs';
import 'events';

20041
node_modules/rollup/dist/es/shared/rollup.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

7331
node_modules/rollup/dist/es/shared/watch.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

25
node_modules/rollup/dist/loadConfigFile.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/*
@license
Rollup.js v2.33.1
Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
https://github.com/rollup/rollup
Released under the MIT License.
*/
'use strict';
require('./shared/rollup.js');
require('fs');
require('path');
require('./shared/mergeOptions.js');
var loadConfigFile_js = require('./shared/loadConfigFile.js');
require('crypto');
require('events');
require('url');
module.exports = loadConfigFile_js.loadAndParseConfigFile;
//# sourceMappingURL=loadConfigFile.js.map

11
node_modules/rollup/dist/rollup.browser.js generated vendored Normal file

File diff suppressed because one or more lines are too long

844
node_modules/rollup/dist/rollup.d.ts generated vendored Normal file
View File

@@ -0,0 +1,844 @@
export const VERSION: string;
export interface RollupError extends RollupLogProps {
parserError?: Error;
stack?: string;
watchFiles?: string[];
}
export interface RollupWarning extends RollupLogProps {
chunkName?: string;
cycle?: string[];
exporter?: string;
exportName?: string;
guess?: string;
importer?: string;
missing?: string;
modules?: string[];
names?: string[];
reexporter?: string;
source?: string;
sources?: string[];
}
export interface RollupLogProps {
code?: string;
frame?: string;
hook?: string;
id?: string;
loc?: {
column: number;
file?: string;
line: number;
};
message: string;
name?: string;
plugin?: string;
pluginCode?: string;
pos?: number;
url?: string;
}
export type SourceMapSegment =
| [number]
| [number, number, number, number]
| [number, number, number, number, number];
export interface ExistingDecodedSourceMap {
file?: string;
mappings: SourceMapSegment[][];
names: string[];
sourceRoot?: string;
sources: string[];
sourcesContent?: string[];
version: number;
}
export interface ExistingRawSourceMap {
file?: string;
mappings: string;
names: string[];
sourceRoot?: string;
sources: string[];
sourcesContent?: string[];
version: number;
}
export type DecodedSourceMapOrMissing =
| {
mappings?: never;
missing: true;
plugin: string;
}
| ExistingDecodedSourceMap;
export interface SourceMap {
file: string;
mappings: string;
names: string[];
sources: string[];
sourcesContent: string[];
version: number;
toString(): string;
toUrl(): string;
}
export type SourceMapInput = ExistingRawSourceMap | string | null | { mappings: '' };
type PartialNull<T> = {
[P in keyof T]: T[P] | null;
};
interface ModuleOptions {
meta: CustomPluginOptions;
moduleSideEffects: boolean | 'no-treeshake';
syntheticNamedExports: boolean | string;
}
export interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
ast?: AcornNode;
code: string;
map?: SourceMapInput;
}
export interface TransformModuleJSON extends Partial<PartialNull<ModuleOptions>> {
ast?: AcornNode;
code: string;
// note if plugins use new this.cache to opt-out auto transform cache
customTransformCache: boolean;
originalCode: string;
originalSourcemap: ExistingDecodedSourceMap | null;
resolvedIds?: ResolvedIdMap;
sourcemapChain: DecodedSourceMapOrMissing[];
transformDependencies: string[];
}
export interface ModuleJSON extends TransformModuleJSON {
alwaysRemovedCode: [number, number][];
ast: AcornNode;
dependencies: string[];
id: string;
transformFiles: EmittedFile[] | undefined;
}
export interface PluginCache {
delete(id: string): boolean;
get<T = any>(id: string): T;
has(id: string): boolean;
set<T = any>(id: string, value: T): void;
}
export interface MinimalPluginContext {
meta: PluginContextMeta;
}
export interface EmittedAsset {
fileName?: string;
name?: string;
source?: string | Uint8Array;
type: 'asset';
}
export interface EmittedChunk {
fileName?: string;
id: string;
implicitlyLoadedAfterOneOf?: string[];
importer?: string;
name?: string;
preserveSignature?: PreserveEntrySignaturesOption;
type: 'chunk';
}
export type EmittedFile = EmittedAsset | EmittedChunk;
export type EmitAsset = (name: string, source?: string | Uint8Array) => string;
export type EmitChunk = (id: string, options?: { name?: string }) => string;
export type EmitFile = (emittedFile: EmittedFile) => string;
interface ModuleInfo {
ast: AcornNode | null;
code: string | null;
dynamicallyImportedIds: readonly string[];
dynamicImporters: readonly string[];
hasModuleSideEffects: boolean | 'no-treeshake';
id: string;
implicitlyLoadedAfterOneOf: readonly string[];
implicitlyLoadedBefore: readonly string[];
importedIds: readonly string[];
importers: readonly string[];
isEntry: boolean;
isExternal: boolean;
meta: CustomPluginOptions;
syntheticNamedExports: boolean | string;
}
export type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
export interface CustomPluginOptions {
[plugin: string]: any;
}
export interface PluginContext extends MinimalPluginContext {
addWatchFile: (id: string) => void;
cache: PluginCache;
/** @deprecated Use `this.emitFile` instead */
emitAsset: EmitAsset;
/** @deprecated Use `this.emitFile` instead */
emitChunk: EmitChunk;
emitFile: EmitFile;
error: (err: RollupError | string, pos?: number | { column: number; line: number }) => never;
/** @deprecated Use `this.getFileName` instead */
getAssetFileName: (assetReferenceId: string) => string;
/** @deprecated Use `this.getFileName` instead */
getChunkFileName: (chunkReferenceId: string) => string;
getFileName: (fileReferenceId: string) => string;
getModuleIds: () => IterableIterator<string>;
getModuleInfo: GetModuleInfo;
getWatchFiles: () => string[];
/** @deprecated Use `this.resolve` instead */
isExternal: IsExternal;
/** @deprecated Use `this.getModuleIds` instead */
moduleIds: IterableIterator<string>;
parse: (input: string, options?: any) => AcornNode;
resolve: (
source: string,
importer?: string,
options?: { custom?: CustomPluginOptions; skipSelf?: boolean }
) => Promise<ResolvedId | null>;
/** @deprecated Use `this.resolve` instead */
resolveId: (source: string, importer?: string) => Promise<string | null>;
setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void;
}
export interface PluginContextMeta {
rollupVersion: string;
watchMode: boolean;
}
export interface ResolvedId extends ModuleOptions {
external: boolean;
id: string;
}
export interface ResolvedIdMap {
[key: string]: ResolvedId;
}
interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
external?: boolean;
id: string;
}
export type ResolveIdResult = string | false | null | undefined | PartialResolvedId;
export type ResolveIdHook = (
this: PluginContext,
source: string,
importer: string | undefined,
options: { custom?: CustomPluginOptions }
) => Promise<ResolveIdResult> | ResolveIdResult;
export type IsExternal = (
source: string,
importer: string | undefined,
isResolved: boolean
) => boolean;
export type IsPureModule = (id: string) => boolean | null | undefined;
export type HasModuleSideEffects = (id: string, external: boolean) => boolean;
type LoadResult = SourceDescription | string | null | undefined;
export type LoadHook = (this: PluginContext, id: string) => Promise<LoadResult> | LoadResult;
export interface TransformPluginContext extends PluginContext {
getCombinedSourcemap: () => SourceMap;
}
export type TransformResult = string | null | undefined | Partial<SourceDescription>;
export type TransformHook = (
this: TransformPluginContext,
code: string,
id: string
) => Promise<TransformResult> | TransformResult;
export type ModuleParsedHook = (this: PluginContext, info: ModuleInfo) => Promise<void> | void;
export type RenderChunkHook = (
this: PluginContext,
code: string,
chunk: RenderedChunk,
options: NormalizedOutputOptions
) =>
| Promise<{ code: string; map?: SourceMapInput } | null>
| { code: string; map?: SourceMapInput }
| string
| null;
export type ResolveDynamicImportHook = (
this: PluginContext,
specifier: string | AcornNode,
importer: string
) => Promise<ResolveIdResult> | ResolveIdResult;
export type ResolveImportMetaHook = (
this: PluginContext,
prop: string | null,
options: { chunkId: string; format: InternalModuleFormat; moduleId: string }
) => string | null | undefined;
export type ResolveAssetUrlHook = (
this: PluginContext,
options: {
assetFileName: string;
chunkId: string;
format: InternalModuleFormat;
moduleId: string;
relativeAssetPath: string;
}
) => string | null | undefined;
export type ResolveFileUrlHook = (
this: PluginContext,
options: {
assetReferenceId: string | null;
chunkId: string;
chunkReferenceId: string | null;
fileName: string;
format: InternalModuleFormat;
moduleId: string;
referenceId: string;
relativePath: string;
}
) => string | null | undefined;
export type AddonHookFunction = (this: PluginContext) => string | Promise<string>;
export type AddonHook = string | AddonHookFunction;
export type ChangeEvent = 'create' | 'update' | 'delete'
export type WatchChangeHook = (this: PluginContext, id: string, change: {event: ChangeEvent}) => void
/**
* use this type for plugin annotation
* @example
* ```ts
* interface Options {
* ...
* }
* const myPlugin: PluginImpl<Options> = (options = {}) => { ... }
* ```
*/
export type PluginImpl<O extends object = object> = (options?: O) => Plugin;
export interface OutputBundle {
[fileName: string]: OutputAsset | OutputChunk;
}
export interface FilePlaceholder {
type: 'placeholder';
}
export interface OutputBundleWithPlaceholders {
[fileName: string]: OutputAsset | OutputChunk | FilePlaceholder;
}
export interface PluginHooks extends OutputPluginHooks {
buildEnd: (this: PluginContext, err?: Error) => Promise<void> | void;
buildStart: (this: PluginContext, options: NormalizedInputOptions) => Promise<void> | void;
closeWatcher: (this: PluginContext) => void;
load: LoadHook;
moduleParsed: ModuleParsedHook;
options: (
this: MinimalPluginContext,
options: InputOptions
) => Promise<InputOptions | null | undefined> | InputOptions | null | undefined;
resolveDynamicImport: ResolveDynamicImportHook;
resolveId: ResolveIdHook;
transform: TransformHook;
watchChange: WatchChangeHook;
}
interface OutputPluginHooks {
augmentChunkHash: (this: PluginContext, chunk: PreRenderedChunk) => string | void;
generateBundle: (
this: PluginContext,
options: NormalizedOutputOptions,
bundle: OutputBundle,
isWrite: boolean
) => void | Promise<void>;
outputOptions: (this: PluginContext, options: OutputOptions) => OutputOptions | null | undefined;
renderChunk: RenderChunkHook;
renderDynamicImport: (
this: PluginContext,
options: {
customResolution: string | null;
format: InternalModuleFormat;
moduleId: string;
targetModuleId: string | null;
}
) => { left: string; right: string } | null | undefined;
renderError: (this: PluginContext, err?: Error) => Promise<void> | void;
renderStart: (
this: PluginContext,
outputOptions: NormalizedOutputOptions,
inputOptions: NormalizedInputOptions
) => Promise<void> | void;
/** @deprecated Use `resolveFileUrl` instead */
resolveAssetUrl: ResolveAssetUrlHook;
resolveFileUrl: ResolveFileUrlHook;
resolveImportMeta: ResolveImportMetaHook;
writeBundle: (
this: PluginContext,
options: NormalizedOutputOptions,
bundle: OutputBundle
) => void | Promise<void>;
}
export type AsyncPluginHooks =
| 'options'
| 'buildEnd'
| 'buildStart'
| 'generateBundle'
| 'load'
| 'moduleParsed'
| 'renderChunk'
| 'renderError'
| 'renderStart'
| 'resolveDynamicImport'
| 'resolveId'
| 'transform'
| 'writeBundle';
export type PluginValueHooks = 'banner' | 'footer' | 'intro' | 'outro';
export type SyncPluginHooks = Exclude<keyof PluginHooks, AsyncPluginHooks>;
export type FirstPluginHooks =
| 'load'
| 'renderDynamicImport'
| 'resolveAssetUrl'
| 'resolveDynamicImport'
| 'resolveFileUrl'
| 'resolveId'
| 'resolveImportMeta';
export type SequentialPluginHooks =
| 'augmentChunkHash'
| 'closeWatcher'
| 'generateBundle'
| 'options'
| 'outputOptions'
| 'renderChunk'
| 'transform'
| 'watchChange';
export type ParallelPluginHooks =
| 'banner'
| 'buildEnd'
| 'buildStart'
| 'footer'
| 'intro'
| 'moduleParsed'
| 'outro'
| 'renderError'
| 'renderStart'
| 'writeBundle';
interface OutputPluginValueHooks {
banner: AddonHook;
cacheKey: string;
footer: AddonHook;
intro: AddonHook;
outro: AddonHook;
}
export interface Plugin extends Partial<PluginHooks>, Partial<OutputPluginValueHooks> {
// for inter-plugin communication
api?: any;
name: string;
}
export interface OutputPlugin extends Partial<OutputPluginHooks>, Partial<OutputPluginValueHooks> {
name: string;
}
export interface TreeshakingOptions {
annotations?: boolean;
moduleSideEffects?: ModuleSideEffectsOption;
propertyReadSideEffects?: boolean;
/** @deprecated Use `moduleSideEffects` instead */
pureExternalModules?: PureModulesOption;
tryCatchDeoptimization?: boolean;
unknownGlobalSideEffects?: boolean;
}
export interface NormalizedTreeshakingOptions {
annotations: boolean;
moduleSideEffects: HasModuleSideEffects;
propertyReadSideEffects: boolean;
tryCatchDeoptimization: boolean;
unknownGlobalSideEffects: boolean;
}
interface GetManualChunkApi {
getModuleIds: () => IterableIterator<string>;
getModuleInfo: GetModuleInfo;
}
export type GetManualChunk = (id: string, api: GetManualChunkApi) => string | null | undefined;
export type ExternalOption =
| (string | RegExp)[]
| string
| RegExp
| ((
source: string,
importer: string | undefined,
isResolved: boolean
) => boolean | null | undefined);
export type PureModulesOption = boolean | string[] | IsPureModule;
export type GlobalsOption = { [name: string]: string } | ((name: string) => string);
export type InputOption = string | string[] | { [entryAlias: string]: string };
export type ManualChunksOption = { [chunkAlias: string]: string[] } | GetManualChunk;
export type ModuleSideEffectsOption = boolean | 'no-external' | string[] | HasModuleSideEffects;
export type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
export type SourcemapPathTransformOption = (
relativeSourcePath: string,
sourcemapPath: string
) => string;
export interface InputOptions {
acorn?: Object;
acornInjectPlugins?: Function | Function[];
cache?: false | RollupCache;
context?: string;
experimentalCacheExpiry?: number;
external?: ExternalOption;
/** @deprecated Use the "inlineDynamicImports" output option instead. */
inlineDynamicImports?: boolean;
input?: InputOption;
/** @deprecated Use the "manualChunks" output option instead. */
manualChunks?: ManualChunksOption;
moduleContext?: ((id: string) => string | null | undefined) | { [id: string]: string };
onwarn?: WarningHandlerWithDefault;
perf?: boolean;
plugins?: Plugin[];
preserveEntrySignatures?: PreserveEntrySignaturesOption;
/** @deprecated Use the "preserveModules" output option instead. */
preserveModules?: boolean;
preserveSymlinks?: boolean;
shimMissingExports?: boolean;
strictDeprecations?: boolean;
treeshake?: boolean | TreeshakingOptions;
watch?: WatcherOptions | false;
}
export interface NormalizedInputOptions {
acorn: Object;
acornInjectPlugins: Function[];
cache: false | undefined | RollupCache;
context: string;
experimentalCacheExpiry: number;
external: IsExternal;
/** @deprecated Use the "inlineDynamicImports" output option instead. */
inlineDynamicImports: boolean | undefined;
input: string[] | { [entryAlias: string]: string };
/** @deprecated Use the "manualChunks" output option instead. */
manualChunks: ManualChunksOption | undefined;
moduleContext: (id: string) => string;
onwarn: WarningHandler;
perf: boolean;
plugins: Plugin[];
preserveEntrySignatures: PreserveEntrySignaturesOption;
/** @deprecated Use the "preserveModules" output option instead. */
preserveModules: boolean | undefined;
preserveSymlinks: boolean;
shimMissingExports: boolean;
strictDeprecations: boolean;
treeshake: false | NormalizedTreeshakingOptions;
}
export type InternalModuleFormat = 'amd' | 'cjs' | 'es' | 'iife' | 'system' | 'umd';
export type ModuleFormat = InternalModuleFormat | 'commonjs' | 'esm' | 'module' | 'systemjs';
export type OptionsPaths = Record<string, string> | ((id: string) => string);
export type InteropType = boolean | 'auto' | 'esModule' | 'default' | 'defaultOnly';
export type GetInterop = (id: string | null) => InteropType;
export interface OutputOptions {
amd?: {
define?: string;
id?: string;
};
assetFileNames?: string | ((chunkInfo: PreRenderedAsset) => string);
banner?: string | (() => string | Promise<string>);
chunkFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
compact?: boolean;
// only required for bundle.write
dir?: string;
/** @deprecated Use the "renderDynamicImport" plugin hook instead. */
dynamicImportFunction?: string;
entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
esModule?: boolean;
exports?: 'default' | 'named' | 'none' | 'auto';
extend?: boolean;
externalLiveBindings?: boolean;
// only required for bundle.write
file?: string;
footer?: string | (() => string | Promise<string>);
format?: ModuleFormat;
freeze?: boolean;
globals?: GlobalsOption;
hoistTransitiveImports?: boolean;
indent?: string | boolean;
inlineDynamicImports?: boolean;
interop?: InteropType | GetInterop;
intro?: string | (() => string | Promise<string>);
manualChunks?: ManualChunksOption;
minifyInternalExports?: boolean;
name?: string;
namespaceToStringTag?: boolean;
noConflict?: boolean;
outro?: string | (() => string | Promise<string>);
paths?: OptionsPaths;
plugins?: OutputPlugin[];
preferConst?: boolean;
preserveModules?: boolean;
preserveModulesRoot?: string;
sourcemap?: boolean | 'inline' | 'hidden';
sourcemapExcludeSources?: boolean;
sourcemapFile?: string;
sourcemapPathTransform?: SourcemapPathTransformOption;
strict?: boolean;
systemNullSetters?: boolean;
}
export interface NormalizedOutputOptions {
amd: {
define: string;
id?: string;
};
assetFileNames: string | ((chunkInfo: PreRenderedAsset) => string);
banner: () => string | Promise<string>;
chunkFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
compact: boolean;
dir: string | undefined;
/** @deprecated Use the "renderDynamicImport" plugin hook instead. */
dynamicImportFunction: string | undefined;
entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
esModule: boolean;
exports: 'default' | 'named' | 'none' | 'auto';
extend: boolean;
externalLiveBindings: boolean;
file: string | undefined;
footer: () => string | Promise<string>;
format: InternalModuleFormat;
freeze: boolean;
globals: GlobalsOption;
hoistTransitiveImports: boolean;
indent: true | string;
inlineDynamicImports: boolean;
interop: GetInterop;
intro: () => string | Promise<string>;
manualChunks: ManualChunksOption;
minifyInternalExports: boolean;
name: string | undefined;
namespaceToStringTag: boolean;
noConflict: boolean;
outro: () => string | Promise<string>;
paths: OptionsPaths;
plugins: OutputPlugin[];
preferConst: boolean;
preserveModules: boolean;
preserveModulesRoot: string | undefined;
sourcemap: boolean | 'inline' | 'hidden';
sourcemapExcludeSources: boolean;
sourcemapFile: string | undefined;
sourcemapPathTransform: SourcemapPathTransformOption | undefined;
strict: boolean;
systemNullSetters: boolean;
}
export type WarningHandlerWithDefault = (
warning: RollupWarning,
defaultHandler: WarningHandler
) => void;
export type WarningHandler = (warning: RollupWarning) => void;
export interface SerializedTimings {
[label: string]: [number, number, number];
}
export interface PreRenderedAsset {
name: string | undefined;
source: string | Uint8Array;
type: 'asset';
}
export interface OutputAsset extends PreRenderedAsset {
fileName: string;
/** @deprecated Accessing "isAsset" on files in the bundle is deprecated, please use "type === \'asset\'" instead */
isAsset: true;
}
export interface RenderedModule {
originalLength: number;
removedExports: string[];
renderedExports: string[];
renderedLength: number;
}
export interface PreRenderedChunk {
exports: string[];
facadeModuleId: string | null;
isDynamicEntry: boolean;
isEntry: boolean;
isImplicitEntry: boolean;
modules: {
[id: string]: RenderedModule;
};
name: string;
type: 'chunk';
}
export interface RenderedChunk extends PreRenderedChunk {
code?: string;
dynamicImports: string[];
fileName: string;
implicitlyLoadedBefore: string[];
importedBindings: {
[imported: string]: string[];
};
imports: string[];
map?: SourceMap;
referencedFiles: string[];
}
export interface OutputChunk extends RenderedChunk {
code: string;
}
export interface SerializablePluginCache {
[key: string]: [number, any];
}
export interface RollupCache {
modules: ModuleJSON[];
plugins?: Record<string, SerializablePluginCache>;
}
export interface RollupOutput {
output: [OutputChunk, ...(OutputChunk | OutputAsset)[]];
}
export interface RollupBuild {
cache: RollupCache | undefined;
generate: (outputOptions: OutputOptions) => Promise<RollupOutput>;
getTimings?: () => SerializedTimings;
watchFiles: string[];
write: (options: OutputOptions) => Promise<RollupOutput>;
}
export interface RollupOptions extends InputOptions {
// This is included for compatibility with config files but ignored by rollup.rollup
output?: OutputOptions | OutputOptions[];
}
export interface MergedRollupOptions extends InputOptions {
output: OutputOptions[];
}
export function rollup(options: RollupOptions): Promise<RollupBuild>;
export interface ChokidarOptions {
alwaysStat?: boolean;
atomic?: boolean | number;
awaitWriteFinish?:
| {
pollInterval?: number;
stabilityThreshold?: number;
}
| boolean;
binaryInterval?: number;
cwd?: string;
depth?: number;
disableGlobbing?: boolean;
followSymlinks?: boolean;
ignored?: any;
ignoreInitial?: boolean;
ignorePermissionErrors?: boolean;
interval?: number;
persistent?: boolean;
useFsEvents?: boolean;
usePolling?: boolean;
}
export interface WatcherOptions {
buildDelay?: number;
chokidar?: ChokidarOptions;
clearScreen?: boolean;
exclude?: string | RegExp | (string | RegExp)[];
include?: string | RegExp | (string | RegExp)[];
skipWrite?: boolean;
}
export interface RollupWatchOptions extends InputOptions {
output?: OutputOptions | OutputOptions[];
watch?: WatcherOptions | false;
}
interface TypedEventEmitter<T extends {[event: string]: (...args: any) => any}> {
addListener<K extends keyof T>(event: K, listener: T[K]): this;
emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): boolean;
eventNames(): Array<keyof T>;
getMaxListeners(): number;
listenerCount(type: keyof T): number;
listeners<K extends keyof T>(event: K): Array<T[K]>;
off<K extends keyof T>(event: K, listener: T[K]): this;
on<K extends keyof T>(event: K, listener: T[K]): this;
once<K extends keyof T>(event: K, listener: T[K]): this;
prependListener<K extends keyof T>(event: K, listener: T[K]): this;
prependOnceListener<K extends keyof T>(event: K, listener: T[K]): this;
rawListeners<K extends keyof T>(event: K): Array<T[K]>;
removeAllListeners<K extends keyof T>(event?: K): this;
removeListener<K extends keyof T>(event: K, listener: T[K]): this;
setMaxListeners(n: number): this;
}
export type RollupWatcherEvent =
| { code: 'START' }
| { code: 'BUNDLE_START'; input?: InputOption; output: readonly string[] }
| {
code: 'BUNDLE_END';
duration: number;
input?: InputOption;
output: readonly string[];
result: RollupBuild;
}
| { code: 'END' }
| { code: 'ERROR'; error: RollupError };
export interface RollupWatcher
extends TypedEventEmitter<{
change: (id: string, change: {event: ChangeEvent}) => void;
close: () => void;
event: (event: RollupWatcherEvent) => void;
restart: () => void;
}> {
close(): void;
}
export function watch(config: RollupWatchOptions | RollupWatchOptions[]): RollupWatcher;
interface AcornNode {
end: number;
start: number;
type: string;
}

26
node_modules/rollup/dist/rollup.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
/*
@license
Rollup.js v2.33.1
Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
https://github.com/rollup/rollup
Released under the MIT License.
*/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var rollup = require('./shared/rollup.js');
require('fs');
require('path');
require('crypto');
require('events');
exports.VERSION = rollup.version;
exports.rollup = rollup.rollup;
exports.watch = rollup.watch;
//# sourceMappingURL=rollup.js.map

6402
node_modules/rollup/dist/shared/index.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

560
node_modules/rollup/dist/shared/loadConfigFile.js generated vendored Normal file
View File

@@ -0,0 +1,560 @@
/*
@license
Rollup.js v2.33.1
Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
https://github.com/rollup/rollup
Released under the MIT License.
*/
'use strict';
var rollup = require('./rollup.js');
var fs = require('fs');
var sysPath = require('path');
var mergeOptions = require('./mergeOptions.js');
var url = require('url');
let enabled =
!("NO_COLOR" in process.env) &&
("FORCE_COLOR" in process.env ||
process.platform === "win32" ||
(process.stdout != null &&
process.stdout.isTTY &&
process.env.TERM &&
process.env.TERM !== "dumb"));
const raw = (open, close, searchRegex, replaceValue) => (s) =>
enabled
? open +
(~(s += "").indexOf(close, 4) // skip opening \x1b[
? s.replace(searchRegex, replaceValue)
: s) +
close
: s;
const init = (open, close) => {
return raw(
`\x1b[${open}m`,
`\x1b[${close}m`,
new RegExp(`\\x1b\\[${close}m`, "g"),
`\x1b[${open}m`
)
};
const options = Object.defineProperty({}, "enabled", {
get: () => enabled,
set: (value) => (enabled = value),
});
const bold = raw("\x1b[1m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[1m");
const dim = raw("\x1b[2m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[2m");
const underline = init(4, 24);
const red = init(31, 39);
const green = init(32, 39);
const yellow = init(33, 39);
const cyan = init(36, 39);
const gray = init(90, 39);
// @see https://no-color.org
// @see https://www.npmjs.com/package/chalk
if (process.env.FORCE_COLOR === '0' || process.env.NO_COLOR) {
options.enabled = false;
}
// log to stderr to keep `rollup main.js > bundle.js` from breaking
const stderr = console.error.bind(console);
function handleError(err, recover = false) {
let description = err.message || err;
if (err.name)
description = `${err.name}: ${description}`;
const message = (err.plugin ? `(plugin ${err.plugin}) ${description}` : description) || err;
stderr(bold(red(`[!] ${bold(message.toString())}`)));
if (err.url) {
stderr(cyan(err.url));
}
if (err.loc) {
stderr(`${rollup.relativeId((err.loc.file || err.id))} (${err.loc.line}:${err.loc.column})`);
}
else if (err.id) {
stderr(rollup.relativeId(err.id));
}
if (err.frame) {
stderr(dim(err.frame));
}
if (err.stack) {
stderr(dim(err.stack));
}
stderr('');
if (!recover)
process.exit(1);
}
function batchWarnings() {
let count = 0;
let deferredWarnings = new Map();
let warningOccurred = false;
return {
get count() {
return count;
},
get warningOccurred() {
return warningOccurred;
},
add: (warning) => {
count += 1;
warningOccurred = true;
if (warning.code in deferredHandlers) {
rollup.getOrCreate(deferredWarnings, warning.code, () => []).push(warning);
}
else if (warning.code in immediateHandlers) {
immediateHandlers[warning.code](warning);
}
else {
title(warning.message);
if (warning.url)
info(warning.url);
const id = (warning.loc && warning.loc.file) || warning.id;
if (id) {
const loc = warning.loc
? `${rollup.relativeId(id)}: (${warning.loc.line}:${warning.loc.column})`
: rollup.relativeId(id);
stderr(bold(rollup.relativeId(loc)));
}
if (warning.frame)
info(warning.frame);
}
},
flush: () => {
if (count === 0)
return;
const codes = Array.from(deferredWarnings.keys()).sort((a, b) => deferredWarnings.get(b).length - deferredWarnings.get(a).length);
for (const code of codes) {
deferredHandlers[code](deferredWarnings.get(code));
}
deferredWarnings = new Map();
count = 0;
}
};
}
const immediateHandlers = {
UNKNOWN_OPTION: warning => {
title(`You have passed an unrecognized option`);
stderr(warning.message);
},
MISSING_NODE_BUILTINS: warning => {
title(`Missing shims for Node.js built-ins`);
const detail = warning.modules.length === 1
? `'${warning.modules[0]}'`
: `${warning
.modules.slice(0, -1)
.map((name) => `'${name}'`)
.join(', ')} and '${warning.modules.slice(-1)}'`;
stderr(`Creating a browser bundle that depends on ${detail}. You might need to include https://github.com/ionic-team/rollup-plugin-node-polyfills`);
}
};
const deferredHandlers = {
CIRCULAR_DEPENDENCY(warnings) {
title(`Circular dependenc${warnings.length > 1 ? 'ies' : 'y'}`);
const displayed = warnings.length > 5 ? warnings.slice(0, 3) : warnings;
for (const warning of displayed) {
stderr(warning.cycle.join(' -> '));
}
if (warnings.length > displayed.length) {
stderr(`...and ${warnings.length - displayed.length} more`);
}
},
EMPTY_BUNDLE(warnings) {
title(`Generated${warnings.length === 1 ? ' an' : ''} empty ${warnings.length > 1 ? 'chunks' : 'chunk'}`);
stderr(warnings.map(warning => warning.chunkName).join(', '));
},
EVAL(warnings) {
title('Use of eval is strongly discouraged');
info('https://rollupjs.org/guide/en/#avoiding-eval');
showTruncatedWarnings(warnings);
},
MISSING_EXPORT(warnings) {
title('Missing exports');
info('https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module');
for (const warning of warnings) {
stderr(bold(warning.importer));
stderr(`${warning.missing} is not exported by ${warning.exporter}`);
stderr(gray(warning.frame));
}
},
MISSING_GLOBAL_NAME(warnings) {
title(`Missing global variable ${warnings.length > 1 ? 'names' : 'name'}`);
stderr(`Use output.globals to specify browser global variable names corresponding to external modules`);
for (const warning of warnings) {
stderr(`${bold(warning.source)} (guessing '${warning.guess}')`);
}
},
MIXED_EXPORTS: warnings => {
title('Mixing named and default exports');
info(`https://rollupjs.org/guide/en/#outputexports`);
stderr(bold('The following entry modules are using named and default exports together:'));
const displayedWarnings = warnings.length > 5 ? warnings.slice(0, 3) : warnings;
for (const warning of displayedWarnings) {
stderr(rollup.relativeId(warning.id));
}
if (displayedWarnings.length < warnings.length) {
stderr(`...and ${warnings.length - displayedWarnings.length} other entry modules`);
}
stderr(`\nConsumers of your bundle will have to use chunk['default'] to access their default export, which may not be what you want. Use \`output.exports: 'named'\` to disable this warning`);
},
NAMESPACE_CONFLICT(warnings) {
title(`Conflicting re-exports`);
for (const warning of warnings) {
stderr(`${bold(rollup.relativeId(warning.reexporter))} re-exports '${warning.name}' from both ${rollup.relativeId(warning.sources[0])} and ${rollup.relativeId(warning.sources[1])} (will be ignored)`);
}
},
NON_EXISTENT_EXPORT(warnings) {
title(`Import of non-existent ${warnings.length > 1 ? 'exports' : 'export'}`);
showTruncatedWarnings(warnings);
},
PLUGIN_WARNING(warnings) {
var _a;
const nestedByPlugin = nest(warnings, 'plugin');
for (const { key: plugin, items } of nestedByPlugin) {
const nestedByMessage = nest(items, 'message');
let lastUrl = '';
for (const { key: message, items } of nestedByMessage) {
title(`Plugin ${plugin}: ${message}`);
for (const warning of items) {
if (warning.url && warning.url !== lastUrl)
info((lastUrl = warning.url));
const id = warning.id || ((_a = warning.loc) === null || _a === void 0 ? void 0 : _a.file);
if (id) {
let loc = rollup.relativeId(id);
if (warning.loc) {
loc += `: (${warning.loc.line}:${warning.loc.column})`;
}
stderr(bold(loc));
}
if (warning.frame)
info(warning.frame);
}
}
}
},
SOURCEMAP_BROKEN(warnings) {
title(`Broken sourcemap`);
info('https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect');
const plugins = Array.from(new Set(warnings.map(w => w.plugin).filter(Boolean)));
const detail = plugins.length > 1
? ` (such as ${plugins
.slice(0, -1)
.map(p => `'${p}'`)
.join(', ')} and '${plugins.slice(-1)}')`
: ` (such as '${plugins[0]}')`;
stderr(`Plugins that transform code${detail} should generate accompanying sourcemaps`);
},
THIS_IS_UNDEFINED(warnings) {
title('`this` has been rewritten to `undefined`');
info('https://rollupjs.org/guide/en/#error-this-is-undefined');
showTruncatedWarnings(warnings);
},
UNRESOLVED_IMPORT(warnings) {
title('Unresolved dependencies');
info('https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency');
const dependencies = new Map();
for (const warning of warnings) {
rollup.getOrCreate(dependencies, warning.source, () => []).push(warning.importer);
}
for (const dependency of dependencies.keys()) {
const importers = dependencies.get(dependency);
stderr(`${bold(dependency)} (imported by ${importers.join(', ')})`);
}
},
UNUSED_EXTERNAL_IMPORT(warnings) {
title('Unused external imports');
for (const warning of warnings) {
stderr(`${warning.names} imported from external module '${warning.source}' but never used`);
}
}
};
function title(str) {
stderr(bold(yellow(`(!) ${str}`)));
}
function info(url) {
stderr(gray(url));
}
function nest(array, prop) {
const nested = [];
const lookup = new Map();
for (const item of array) {
const key = item[prop];
rollup.getOrCreate(lookup, key, () => {
const items = {
items: [],
key
};
nested.push(items);
return items;
}).items.push(item);
}
return nested;
}
function showTruncatedWarnings(warnings) {
const nestedByModule = nest(warnings, 'id');
const displayedByModule = nestedByModule.length > 5 ? nestedByModule.slice(0, 3) : nestedByModule;
for (const { key: id, items } of displayedByModule) {
stderr(bold(rollup.relativeId(id)));
stderr(gray(items[0].frame));
if (items.length > 1) {
stderr(`...and ${items.length - 1} other ${items.length > 2 ? 'occurrences' : 'occurrence'}`);
}
}
if (nestedByModule.length > displayedByModule.length) {
stderr(`\n...and ${nestedByModule.length - displayedByModule.length} other files`);
}
}
const stdinName = '-';
let stdinResult = null;
function stdinPlugin(arg) {
const suffix = typeof arg == 'string' && arg.length ? '.' + arg : '';
return {
name: 'stdin',
resolveId(id) {
if (id === stdinName) {
return id + suffix;
}
},
load(id) {
if (id === stdinName || id.startsWith(stdinName + '.')) {
return stdinResult || (stdinResult = readStdin());
}
}
};
}
function readStdin() {
return new Promise((resolve, reject) => {
const chunks = [];
process.stdin.setEncoding('utf8');
process.stdin
.on('data', chunk => chunks.push(chunk))
.on('end', () => {
const result = chunks.join('');
resolve(result);
})
.on('error', err => {
reject(err);
});
});
}
function waitForInputPlugin() {
return {
name: 'wait-for-input',
async buildStart(options) {
const inputSpecifiers = Array.isArray(options.input)
? options.input
: Object.keys(options.input);
let lastAwaitedSpecifier = null;
checkSpecifiers: while (true) {
for (const specifier of inputSpecifiers) {
if ((await this.resolve(specifier)) === null) {
if (lastAwaitedSpecifier !== specifier) {
stderr(`waiting for input ${bold(specifier)}...`);
lastAwaitedSpecifier = specifier;
}
await new Promise(resolve => setTimeout(resolve, 500));
continue checkSpecifiers;
}
}
break;
}
}
};
}
function addCommandPluginsToInputOptions(inputOptions, command) {
if (command.stdin !== false) {
inputOptions.plugins.push(stdinPlugin(command.stdin));
}
if (command.waitForBundleInput === true) {
inputOptions.plugins.push(waitForInputPlugin());
}
const commandPlugin = command.plugin;
if (commandPlugin) {
const plugins = Array.isArray(commandPlugin) ? commandPlugin : [commandPlugin];
for (const plugin of plugins) {
if (/[={}]/.test(plugin)) {
// -p plugin=value
// -p "{transform(c,i){...}}"
loadAndRegisterPlugin(inputOptions, plugin);
}
else {
// split out plugins joined by commas
// -p node-resolve,commonjs,buble
plugin.split(',').forEach((plugin) => loadAndRegisterPlugin(inputOptions, plugin));
}
}
}
}
function loadAndRegisterPlugin(inputOptions, pluginText) {
let plugin = null;
let pluginArg = undefined;
if (pluginText[0] === '{') {
// -p "{transform(c,i){...}}"
plugin = new Function('return ' + pluginText);
}
else {
const match = pluginText.match(/^([@.\/\\\w|^{}-]+)(=(.*))?$/);
if (match) {
// -p plugin
// -p plugin=arg
pluginText = match[1];
pluginArg = new Function('return ' + match[3])();
}
else {
throw new Error(`Invalid --plugin argument format: ${JSON.stringify(pluginText)}`);
}
if (!/^\.|^rollup-plugin-|[@\/\\]/.test(pluginText)) {
// Try using plugin prefix variations first if applicable.
// Prefix order is significant - left has higher precedence.
for (const prefix of ['@rollup/plugin-', 'rollup-plugin-']) {
try {
plugin = require(prefix + pluginText);
break;
}
catch (ex) {
// if this does not work, we try requiring the actual name below
}
}
}
if (!plugin) {
try {
if (pluginText[0] == '.')
pluginText = sysPath.resolve(pluginText);
plugin = require(pluginText);
}
catch (ex) {
throw new Error(`Cannot load plugin "${pluginText}": ${ex.message}.`);
}
}
}
// some plugins do not use `module.exports` for their entry point,
// in which case we try the named default export and the plugin name
if (typeof plugin === 'object') {
plugin = plugin.default || plugin[getCamelizedPluginBaseName(pluginText)];
}
if (!plugin) {
throw new Error(`Cannot find entry for plugin "${pluginText}". The plugin needs to export a function either as "default" or "${getCamelizedPluginBaseName(pluginText)}" for Rollup to recognize it.`);
}
inputOptions.plugins.push(typeof plugin === 'function' ? plugin.call(plugin, pluginArg) : plugin);
}
function getCamelizedPluginBaseName(pluginText) {
var _a;
return (((_a = pluginText.match(/(@rollup\/plugin-|rollup-plugin-)(.+)$/)) === null || _a === void 0 ? void 0 : _a[2]) || pluginText)
.split(/[\\/]/)
.slice(-1)[0]
.split('.')[0]
.split('-')
.map((part, index) => (index === 0 || !part ? part : part[0].toUpperCase() + part.slice(1)))
.join('');
}
function supportsNativeESM() {
return Number(/^v(\d+)/.exec(process.version)[1]) >= 13;
}
async function loadAndParseConfigFile(fileName, commandOptions = {}) {
const configs = await loadConfigFile(fileName, commandOptions);
const warnings = batchWarnings();
try {
const normalizedConfigs = configs.map(config => {
const options = mergeOptions.mergeOptions(config, commandOptions, warnings.add);
addCommandPluginsToInputOptions(options, commandOptions);
return options;
});
return { options: normalizedConfigs, warnings };
}
catch (err) {
warnings.flush();
throw err;
}
}
async function loadConfigFile(fileName, commandOptions) {
const extension = sysPath.extname(fileName);
const configFileExport = extension === '.mjs' && supportsNativeESM()
? (await import(url.pathToFileURL(fileName).href)).default
: extension === '.cjs'
? getDefaultFromCjs(require(fileName))
: await getDefaultFromTranspiledConfigFile(fileName, commandOptions.silent);
return getConfigList(configFileExport, commandOptions);
}
function getDefaultFromCjs(namespace) {
return namespace.__esModule ? namespace.default : namespace;
}
async function getDefaultFromTranspiledConfigFile(fileName, silent) {
const warnings = batchWarnings();
const bundle = await rollup.rollup({
external: (id) => (id[0] !== '.' && !sysPath.isAbsolute(id)) || id.slice(-5, id.length) === '.json',
input: fileName,
onwarn: warnings.add,
treeshake: false
});
if (!silent && warnings.count > 0) {
stderr(bold(`loaded ${rollup.relativeId(fileName)} with warnings`));
warnings.flush();
}
const { output: [{ code }] } = await bundle.generate({
exports: 'named',
format: 'cjs'
});
return loadConfigFromBundledFile(fileName, code);
}
async function loadConfigFromBundledFile(fileName, bundledCode) {
const resolvedFileName = fs.realpathSync(fileName);
const extension = sysPath.extname(resolvedFileName);
const defaultLoader = require.extensions[extension];
require.extensions[extension] = (module, requiredFileName) => {
if (requiredFileName === resolvedFileName) {
module._compile(bundledCode, requiredFileName);
}
else {
defaultLoader(module, requiredFileName);
}
};
delete require.cache[resolvedFileName];
try {
const config = getDefaultFromCjs(require(fileName));
require.extensions[extension] = defaultLoader;
return config;
}
catch (err) {
if (err.code === 'ERR_REQUIRE_ESM') {
return rollup.error({
code: 'TRANSPILED_ESM_CONFIG',
message: `While loading the Rollup configuration from "${rollup.relativeId(fileName)}", Node tried to require an ES module from a CommonJS file, which is not supported. A common cause is if there is a package.json file with "type": "module" in the same folder. You can try to fix this by changing the extension of your configuration file to ".cjs" or ".mjs" depending on the content, which will prevent Rollup from trying to preprocess the file but rather hand it to Node directly.`,
url: 'https://rollupjs.org/guide/en/#using-untranspiled-config-files'
});
}
throw err;
}
}
async function getConfigList(configFileExport, commandOptions) {
const config = await (typeof configFileExport === 'function'
? configFileExport(commandOptions)
: configFileExport);
if (Object.keys(config).length === 0) {
return rollup.error({
code: 'MISSING_CONFIG',
message: 'Config file must export an options object, or an array of options objects',
url: 'https://rollupjs.org/guide/en/#configuration-files'
});
}
return Array.isArray(config) ? config : [config];
}
exports.addCommandPluginsToInputOptions = addCommandPluginsToInputOptions;
exports.batchWarnings = batchWarnings;
exports.bold = bold;
exports.cyan = cyan;
exports.green = green;
exports.handleError = handleError;
exports.loadAndParseConfigFile = loadAndParseConfigFile;
exports.stderr = stderr;
exports.stdinName = stdinName;
exports.underline = underline;
//# sourceMappingURL=loadConfigFile.js.map

170
node_modules/rollup/dist/shared/mergeOptions.js generated vendored Normal file
View File

@@ -0,0 +1,170 @@
/*
@license
Rollup.js v2.33.1
Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
https://github.com/rollup/rollup
Released under the MIT License.
*/
'use strict';
var rollup = require('./rollup.js');
const commandAliases = {
c: 'config',
d: 'dir',
e: 'external',
f: 'format',
g: 'globals',
h: 'help',
i: 'input',
m: 'sourcemap',
n: 'name',
o: 'file',
p: 'plugin',
v: 'version',
w: 'watch'
};
function mergeOptions(config, rawCommandOptions = { external: [], globals: undefined }, defaultOnWarnHandler = rollup.defaultOnWarn) {
const command = getCommandOptions(rawCommandOptions);
const inputOptions = mergeInputOptions(config, command, defaultOnWarnHandler);
const warn = inputOptions.onwarn;
if (command.output) {
Object.assign(command, command.output);
}
const outputOptionsArray = rollup.ensureArray(config.output);
if (outputOptionsArray.length === 0)
outputOptionsArray.push({});
const outputOptions = outputOptionsArray.map(singleOutputOptions => mergeOutputOptions(singleOutputOptions, command, warn));
rollup.warnUnknownOptions(command, Object.keys(inputOptions).concat(Object.keys(outputOptions[0]).filter(option => option !== 'sourcemapPathTransform'), Object.keys(commandAliases), 'config', 'environment', 'plugin', 'silent', 'failAfterWarnings', 'stdin', 'waitForBundleInput'), 'CLI flags', warn, /^_$|output$|config/);
inputOptions.output = outputOptions;
return inputOptions;
}
function getCommandOptions(rawCommandOptions) {
const external = rawCommandOptions.external && typeof rawCommandOptions.external === 'string'
? rawCommandOptions.external.split(',')
: [];
return {
...rawCommandOptions,
external,
globals: typeof rawCommandOptions.globals === 'string'
? rawCommandOptions.globals.split(',').reduce((globals, globalDefinition) => {
const [id, variableName] = globalDefinition.split(':');
globals[id] = variableName;
if (external.indexOf(id) === -1) {
external.push(id);
}
return globals;
}, Object.create(null))
: undefined
};
}
function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
const getOption = (name) => { var _a; return (_a = overrides[name]) !== null && _a !== void 0 ? _a : config[name]; };
const inputOptions = {
acorn: getOption('acorn'),
acornInjectPlugins: config.acornInjectPlugins,
cache: config.cache,
context: getOption('context'),
experimentalCacheExpiry: getOption('experimentalCacheExpiry'),
external: getExternal(config, overrides),
inlineDynamicImports: getOption('inlineDynamicImports'),
input: getOption('input') || [],
manualChunks: getOption('manualChunks'),
moduleContext: getOption('moduleContext'),
onwarn: getOnWarn(config, defaultOnWarnHandler),
perf: getOption('perf'),
plugins: rollup.ensureArray(config.plugins),
preserveEntrySignatures: getOption('preserveEntrySignatures'),
preserveModules: getOption('preserveModules'),
preserveSymlinks: getOption('preserveSymlinks'),
shimMissingExports: getOption('shimMissingExports'),
strictDeprecations: getOption('strictDeprecations'),
treeshake: getObjectOption(config, overrides, 'treeshake'),
watch: getWatch(config, overrides, 'watch')
};
rollup.warnUnknownOptions(config, Object.keys(inputOptions), 'input options', inputOptions.onwarn, /^output$/);
return inputOptions;
}
const getExternal = (config, overrides) => {
const configExternal = config.external;
return typeof configExternal === 'function'
? (source, importer, isResolved) => configExternal(source, importer, isResolved) || overrides.external.indexOf(source) !== -1
: rollup.ensureArray(configExternal).concat(overrides.external);
};
const getOnWarn = (config, defaultOnWarnHandler) => config.onwarn
? warning => config.onwarn(warning, defaultOnWarnHandler)
: defaultOnWarnHandler;
const getObjectOption = (config, overrides, name) => {
const commandOption = normalizeObjectOptionValue(overrides[name]);
const configOption = normalizeObjectOptionValue(config[name]);
if (commandOption !== undefined) {
return commandOption && { ...configOption, ...commandOption };
}
return configOption;
};
const getWatch = (config, overrides, name) => config.watch !== false && getObjectOption(config, overrides, name);
const normalizeObjectOptionValue = (optionValue) => {
if (!optionValue) {
return optionValue;
}
if (Array.isArray(optionValue)) {
return optionValue.reduce((result, value) => value && result && { ...result, ...value }, {});
}
if (typeof optionValue !== 'object') {
return {};
}
return optionValue;
};
function mergeOutputOptions(config, overrides, warn) {
const getOption = (name) => { var _a; return (_a = overrides[name]) !== null && _a !== void 0 ? _a : config[name]; };
const outputOptions = {
amd: getObjectOption(config, overrides, 'amd'),
assetFileNames: getOption('assetFileNames'),
banner: getOption('banner'),
chunkFileNames: getOption('chunkFileNames'),
compact: getOption('compact'),
dir: getOption('dir'),
dynamicImportFunction: getOption('dynamicImportFunction'),
entryFileNames: getOption('entryFileNames'),
esModule: getOption('esModule'),
exports: getOption('exports'),
extend: getOption('extend'),
externalLiveBindings: getOption('externalLiveBindings'),
file: getOption('file'),
footer: getOption('footer'),
format: getOption('format'),
freeze: getOption('freeze'),
globals: getOption('globals'),
hoistTransitiveImports: getOption('hoistTransitiveImports'),
indent: getOption('indent'),
inlineDynamicImports: getOption('inlineDynamicImports'),
interop: getOption('interop'),
intro: getOption('intro'),
manualChunks: getOption('manualChunks'),
minifyInternalExports: getOption('minifyInternalExports'),
name: getOption('name'),
namespaceToStringTag: getOption('namespaceToStringTag'),
noConflict: getOption('noConflict'),
outro: getOption('outro'),
paths: getOption('paths'),
plugins: rollup.ensureArray(config.plugins),
preferConst: getOption('preferConst'),
preserveModules: getOption('preserveModules'),
preserveModulesRoot: getOption('preserveModulesRoot'),
sourcemap: getOption('sourcemap'),
sourcemapExcludeSources: getOption('sourcemapExcludeSources'),
sourcemapFile: getOption('sourcemapFile'),
sourcemapPathTransform: getOption('sourcemapPathTransform'),
strict: getOption('strict'),
systemNullSetters: getOption('systemNullSetters')
};
rollup.warnUnknownOptions(config, Object.keys(outputOptions), 'output options', warn);
return outputOptions;
}
exports.commandAliases = commandAliases;
exports.mergeOptions = mergeOptions;
//# sourceMappingURL=mergeOptions.js.map

20062
node_modules/rollup/dist/shared/rollup.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

441
node_modules/rollup/dist/shared/watch-cli.js generated vendored Normal file
View File

@@ -0,0 +1,441 @@
/*
@license
Rollup.js v2.33.1
Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
https://github.com/rollup/rollup
Released under the MIT License.
*/
'use strict';
var cli = require('../bin/rollup');
var rollup = require('./rollup.js');
require('util');
var fs = require('fs');
require('path');
require('./mergeOptions.js');
var loadConfigFile_js = require('./loadConfigFile.js');
require('crypto');
var require$$0 = require('events');
require('module');
require('url');
var index = require('./index.js');
require('stream');
require('os');
var assert = require('assert');
var timeZone = date => {
const offset = (date || new Date()).getTimezoneOffset();
const absOffset = Math.abs(offset);
const hours = Math.floor(absOffset / 60);
const minutes = absOffset % 60;
const minutesOut = minutes > 0 ? ':' + ('0' + minutes).slice(-2) : '';
return (offset < 0 ? '+' : '-') + hours + minutesOut;
};
const dateTime = options => {
options = Object.assign({
date: new Date(),
local: true,
showTimeZone: false,
showMilliseconds: false
}, options);
let {date} = options;
if (options.local) {
// Offset the date so it will return the correct value when getting the ISO string
date = new Date(date.getTime() - (date.getTimezoneOffset() * 60000));
}
let end = '';
if (options.showTimeZone) {
end = ' UTC' + (options.local ? timeZone(date) : '');
}
if (options.showMilliseconds && date.getUTCMilliseconds() > 0) {
end = ` ${date.getUTCMilliseconds()}ms${end}`;
}
return date
.toISOString()
.replace(/T/, ' ')
.replace(/\..+/, end);
};
var dateTime_1 = dateTime;
// TODO: Remove this for the next major release
var _default = dateTime;
dateTime_1.default = _default;
var signals = rollup.createCommonjsModule(function (module) {
// This is not the set of all possible signals.
//
// It IS, however, the set of all signals that trigger
// an exit on either Linux or BSD systems. Linux is a
// superset of the signal names supported on BSD, and
// the unknown signals just fail to register, so we can
// catch that easily enough.
//
// Don't bother with SIGKILL. It's uncatchable, which
// means that we can't fire any callbacks anyway.
//
// If a user does happen to register a handler on a non-
// fatal signal like SIGWINCH or something, and then
// exit, it'll end up firing `process.emit('exit')`, so
// the handler will be fired anyway.
//
// SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
// artificially, inherently leave the process in a
// state from which it is not safe to try and enter JS
// listeners.
module.exports = [
'SIGABRT',
'SIGALRM',
'SIGHUP',
'SIGINT',
'SIGTERM'
];
if (process.platform !== 'win32') {
module.exports.push(
'SIGVTALRM',
'SIGXCPU',
'SIGXFSZ',
'SIGUSR2',
'SIGTRAP',
'SIGSYS',
'SIGQUIT',
'SIGIOT'
// should detect profiler and enable/disable accordingly.
// see #21
// 'SIGPROF'
);
}
if (process.platform === 'linux') {
module.exports.push(
'SIGIO',
'SIGPOLL',
'SIGPWR',
'SIGSTKFLT',
'SIGUNUSED'
);
}
});
// Note: since nyc uses this module to output coverage, any lines
// that are in the direct sync flow of nyc's outputCoverage are
// ignored, since we can never get coverage for them.
var signals$1 = signals;
var isWin = /^win/i.test(process.platform);
var EE = require$$0;
/* istanbul ignore if */
if (typeof EE !== 'function') {
EE = EE.EventEmitter;
}
var emitter;
if (process.__signal_exit_emitter__) {
emitter = process.__signal_exit_emitter__;
} else {
emitter = process.__signal_exit_emitter__ = new EE();
emitter.count = 0;
emitter.emitted = {};
}
// Because this emitter is a global, we have to check to see if a
// previous version of this library failed to enable infinite listeners.
// I know what you're about to say. But literally everything about
// signal-exit is a compromise with evil. Get used to it.
if (!emitter.infinite) {
emitter.setMaxListeners(Infinity);
emitter.infinite = true;
}
var signalExit = function (cb, opts) {
assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
if (loaded === false) {
load();
}
var ev = 'exit';
if (opts && opts.alwaysLast) {
ev = 'afterexit';
}
var remove = function () {
emitter.removeListener(ev, cb);
if (emitter.listeners('exit').length === 0 &&
emitter.listeners('afterexit').length === 0) {
unload();
}
};
emitter.on(ev, cb);
return remove
};
var unload_1 = unload;
function unload () {
if (!loaded) {
return
}
loaded = false;
signals$1.forEach(function (sig) {
try {
process.removeListener(sig, sigListeners[sig]);
} catch (er) {}
});
process.emit = originalProcessEmit;
process.reallyExit = originalProcessReallyExit;
emitter.count -= 1;
}
function emit (event, code, signal) {
if (emitter.emitted[event]) {
return
}
emitter.emitted[event] = true;
emitter.emit(event, code, signal);
}
// { <signal>: <listener fn>, ... }
var sigListeners = {};
signals$1.forEach(function (sig) {
sigListeners[sig] = function listener () {
// If there are no other listeners, an exit is coming!
// Simplest way: remove us and then re-send the signal.
// We know that this will kill the process, so we can
// safely emit now.
var listeners = process.listeners(sig);
if (listeners.length === emitter.count) {
unload();
emit('exit', null, sig);
/* istanbul ignore next */
emit('afterexit', null, sig);
/* istanbul ignore next */
if (isWin && sig === 'SIGHUP') {
// "SIGHUP" throws an `ENOSYS` error on Windows,
// so use a supported signal instead
sig = 'SIGINT';
}
process.kill(process.pid, sig);
}
};
});
var signals_1 = function () {
return signals$1
};
var load_1 = load;
var loaded = false;
function load () {
if (loaded) {
return
}
loaded = true;
// This is the number of onSignalExit's that are in play.
// It's important so that we can count the correct number of
// listeners on signals, and don't wait for the other one to
// handle it instead of us.
emitter.count += 1;
signals$1 = signals$1.filter(function (sig) {
try {
process.on(sig, sigListeners[sig]);
return true
} catch (er) {
return false
}
});
process.emit = processEmit;
process.reallyExit = processReallyExit;
}
var originalProcessReallyExit = process.reallyExit;
function processReallyExit (code) {
process.exitCode = code || 0;
emit('exit', process.exitCode, null);
/* istanbul ignore next */
emit('afterexit', process.exitCode, null);
/* istanbul ignore next */
originalProcessReallyExit.call(process, process.exitCode);
}
var originalProcessEmit = process.emit;
function processEmit (ev, arg) {
if (ev === 'exit') {
if (arg !== undefined) {
process.exitCode = arg;
}
var ret = originalProcessEmit.apply(this, arguments);
emit('exit', process.exitCode, null);
/* istanbul ignore next */
emit('afterexit', process.exitCode, null);
return ret
} else {
return originalProcessEmit.apply(this, arguments)
}
}
signalExit.unload = unload_1;
signalExit.signals = signals_1;
signalExit.load = load_1;
const CLEAR_SCREEN = '\u001Bc';
function getResetScreen(configs, allowClearScreen) {
let clearScreen = allowClearScreen;
for (const config of configs) {
if (config.watch && config.watch.clearScreen === false) {
clearScreen = false;
}
}
if (clearScreen) {
return (heading) => loadConfigFile_js.stderr(CLEAR_SCREEN + heading);
}
let firstRun = true;
return (heading) => {
if (firstRun) {
loadConfigFile_js.stderr(heading);
firstRun = false;
}
};
}
async function watch(command) {
process.env.ROLLUP_WATCH = 'true';
const isTTY = process.stderr.isTTY;
const silent = command.silent;
let configs;
let warnings;
let watcher;
let configWatcher;
const configFile = command.config ? cli.getConfigPath(command.config) : null;
signalExit(close);
process.on('uncaughtException', close);
if (!process.stdin.isTTY) {
process.stdin.on('end', close);
process.stdin.resume();
}
if (configFile) {
let reloadingConfig = false;
let aborted = false;
let configFileData = null;
configWatcher = index.chokidar.watch(configFile).on('change', () => reloadConfigFile());
await reloadConfigFile();
async function reloadConfigFile() {
try {
const newConfigFileData = fs.readFileSync(configFile, 'utf-8');
if (newConfigFileData === configFileData) {
return;
}
if (reloadingConfig) {
aborted = true;
return;
}
if (configFileData) {
loadConfigFile_js.stderr(`\nReloading updated config...`);
}
configFileData = newConfigFileData;
reloadingConfig = true;
({ options: configs, warnings } = await loadConfigFile_js.loadAndParseConfigFile(configFile, command));
reloadingConfig = false;
if (aborted) {
aborted = false;
reloadConfigFile();
}
else {
if (watcher) {
watcher.close();
}
start(configs);
}
}
catch (err) {
configs = [];
reloadingConfig = false;
loadConfigFile_js.handleError(err, true);
}
}
}
else {
({ options: configs, warnings } = await cli.loadConfigFromCommand(command));
start(configs);
}
// tslint:disable-next-line:no-unnecessary-type-assertion
const resetScreen = getResetScreen(configs, isTTY);
function start(configs) {
try {
watcher = rollup.watch(configs);
}
catch (err) {
return loadConfigFile_js.handleError(err);
}
watcher.on('event', event => {
switch (event.code) {
case 'ERROR':
warnings.flush();
loadConfigFile_js.handleError(event.error, true);
break;
case 'START':
if (!silent) {
resetScreen(loadConfigFile_js.underline(`rollup v${rollup.version}`));
}
break;
case 'BUNDLE_START':
if (!silent) {
let input = event.input;
if (typeof input !== 'string') {
input = Array.isArray(input)
? input.join(', ')
: Object.keys(input)
.map(key => input[key])
.join(', ');
}
loadConfigFile_js.stderr(loadConfigFile_js.cyan(`bundles ${loadConfigFile_js.bold(input)}${loadConfigFile_js.bold(event.output.map(rollup.relativeId).join(', '))}...`));
}
break;
case 'BUNDLE_END':
warnings.flush();
if (!silent)
loadConfigFile_js.stderr(loadConfigFile_js.green(`created ${loadConfigFile_js.bold(event.output.map(rollup.relativeId).join(', '))} in ${loadConfigFile_js.bold(cli.prettyMs(event.duration))}`));
if (event.result && event.result.getTimings) {
cli.printTimings(event.result.getTimings());
}
break;
case 'END':
if (!silent && isTTY) {
loadConfigFile_js.stderr(`\n[${dateTime_1()}] waiting for changes...`);
}
}
});
}
function close(code) {
process.removeListener('uncaughtException', close);
// removing a non-existent listener is a no-op
process.stdin.removeListener('end', close);
if (watcher)
watcher.close();
if (configWatcher)
configWatcher.close();
if (code) {
process.exit(code);
}
}
}
exports.watch = watch;
//# sourceMappingURL=watch-cli.js.map

807
node_modules/rollup/dist/shared/watch.js generated vendored Normal file
View File

@@ -0,0 +1,807 @@
/*
@license
Rollup.js v2.33.1
Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
https://github.com/rollup/rollup
Released under the MIT License.
*/
'use strict';
var rollup = require('./rollup.js');
var util = require('util');
require('fs');
var sysPath = require('path');
var mergeOptions = require('./mergeOptions.js');
require('crypto');
require('events');
var index = require('./index.js');
require('stream');
var require$$1 = require('os');
const isEmptyString = val => typeof val === 'string' && (val === '' || val === './');
/**
* Returns an array of strings that match one or more glob patterns.
*
* ```js
* const mm = require('micromatch');
* // mm(list, patterns[, options]);
*
* console.log(mm(['a.js', 'a.txt'], ['*.js']));
* //=> [ 'a.js' ]
* ```
* @param {String|Array<string>} list List of strings to match.
* @param {String|Array<string>} patterns One or more glob patterns to use for matching.
* @param {Object} options See available [options](#options)
* @return {Array} Returns an array of matches
* @summary false
* @api public
*/
const micromatch = (list, patterns, options) => {
patterns = [].concat(patterns);
list = [].concat(list);
let omit = new Set();
let keep = new Set();
let items = new Set();
let negatives = 0;
let onResult = state => {
items.add(state.output);
if (options && options.onResult) {
options.onResult(state);
}
};
for (let i = 0; i < patterns.length; i++) {
let isMatch = index.picomatch(String(patterns[i]), { ...options, onResult }, true);
let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
if (negated) negatives++;
for (let item of list) {
let matched = isMatch(item, true);
let match = negated ? !matched.isMatch : matched.isMatch;
if (!match) continue;
if (negated) {
omit.add(matched.output);
} else {
omit.delete(matched.output);
keep.add(matched.output);
}
}
}
let result = negatives === patterns.length ? [...items] : [...keep];
let matches = result.filter(item => !omit.has(item));
if (options && matches.length === 0) {
if (options.failglob === true) {
throw new Error(`No matches found for "${patterns.join(', ')}"`);
}
if (options.nonull === true || options.nullglob === true) {
return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns;
}
}
return matches;
};
/**
* Backwards compatibility
*/
micromatch.match = micromatch;
/**
* Returns a matcher function from the given glob `pattern` and `options`.
* The returned function takes a string to match as its only argument and returns
* true if the string is a match.
*
* ```js
* const mm = require('micromatch');
* // mm.matcher(pattern[, options]);
*
* const isMatch = mm.matcher('*.!(*a)');
* console.log(isMatch('a.a')); //=> false
* console.log(isMatch('a.b')); //=> true
* ```
* @param {String} `pattern` Glob pattern
* @param {Object} `options`
* @return {Function} Returns a matcher function.
* @api public
*/
micromatch.matcher = (pattern, options) => index.picomatch(pattern, options);
/**
* Returns true if **any** of the given glob `patterns` match the specified `string`.
*
* ```js
* const mm = require('micromatch');
* // mm.isMatch(string, patterns[, options]);
*
* console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
* console.log(mm.isMatch('a.a', 'b.*')); //=> false
* ```
* @param {String} str The string to test.
* @param {String|Array} patterns One or more glob patterns to use for matching.
* @param {Object} [options] See available [options](#options).
* @return {Boolean} Returns true if any patterns match `str`
* @api public
*/
micromatch.isMatch = (str, patterns, options) => index.picomatch(patterns, options)(str);
/**
* Backwards compatibility
*/
micromatch.any = micromatch.isMatch;
/**
* Returns a list of strings that _**do not match any**_ of the given `patterns`.
*
* ```js
* const mm = require('micromatch');
* // mm.not(list, patterns[, options]);
*
* console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
* //=> ['b.b', 'c.c']
* ```
* @param {Array} `list` Array of strings to match.
* @param {String|Array} `patterns` One or more glob pattern to use for matching.
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Array} Returns an array of strings that **do not match** the given patterns.
* @api public
*/
micromatch.not = (list, patterns, options = {}) => {
patterns = [].concat(patterns).map(String);
let result = new Set();
let items = [];
let onResult = state => {
if (options.onResult) options.onResult(state);
items.push(state.output);
};
let matches = micromatch(list, patterns, { ...options, onResult });
for (let item of items) {
if (!matches.includes(item)) {
result.add(item);
}
}
return [...result];
};
/**
* Returns true if the given `string` contains the given pattern. Similar
* to [.isMatch](#isMatch) but the pattern can match any part of the string.
*
* ```js
* var mm = require('micromatch');
* // mm.contains(string, pattern[, options]);
*
* console.log(mm.contains('aa/bb/cc', '*b'));
* //=> true
* console.log(mm.contains('aa/bb/cc', '*d'));
* //=> false
* ```
* @param {String} `str` The string to match.
* @param {String|Array} `patterns` Glob pattern to use for matching.
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Boolean} Returns true if the patter matches any part of `str`.
* @api public
*/
micromatch.contains = (str, pattern, options) => {
if (typeof str !== 'string') {
throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
}
if (Array.isArray(pattern)) {
return pattern.some(p => micromatch.contains(str, p, options));
}
if (typeof pattern === 'string') {
if (isEmptyString(str) || isEmptyString(pattern)) {
return false;
}
if (str.includes(pattern) || (str.startsWith('./') && str.slice(2).includes(pattern))) {
return true;
}
}
return micromatch.isMatch(str, pattern, { ...options, contains: true });
};
/**
* Filter the keys of the given object with the given `glob` pattern
* and `options`. Does not attempt to match nested keys. If you need this feature,
* use [glob-object][] instead.
*
* ```js
* const mm = require('micromatch');
* // mm.matchKeys(object, patterns[, options]);
*
* const obj = { aa: 'a', ab: 'b', ac: 'c' };
* console.log(mm.matchKeys(obj, '*b'));
* //=> { ab: 'b' }
* ```
* @param {Object} `object` The object with keys to filter.
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Object} Returns an object with only keys that match the given patterns.
* @api public
*/
micromatch.matchKeys = (obj, patterns, options) => {
if (!index.utils.isObject(obj)) {
throw new TypeError('Expected the first argument to be an object');
}
let keys = micromatch(Object.keys(obj), patterns, options);
let res = {};
for (let key of keys) res[key] = obj[key];
return res;
};
/**
* Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
*
* ```js
* const mm = require('micromatch');
* // mm.some(list, patterns[, options]);
*
* console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
* // true
* console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
* // false
* ```
* @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Boolean} Returns true if any patterns match `str`
* @api public
*/
micromatch.some = (list, patterns, options) => {
let items = [].concat(list);
for (let pattern of [].concat(patterns)) {
let isMatch = index.picomatch(String(pattern), options);
if (items.some(item => isMatch(item))) {
return true;
}
}
return false;
};
/**
* Returns true if every string in the given `list` matches
* any of the given glob `patterns`.
*
* ```js
* const mm = require('micromatch');
* // mm.every(list, patterns[, options]);
*
* console.log(mm.every('foo.js', ['foo.js']));
* // true
* console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
* // true
* console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
* // false
* console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
* // false
* ```
* @param {String|Array} `list` The string or array of strings to test.
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Boolean} Returns true if any patterns match `str`
* @api public
*/
micromatch.every = (list, patterns, options) => {
let items = [].concat(list);
for (let pattern of [].concat(patterns)) {
let isMatch = index.picomatch(String(pattern), options);
if (!items.every(item => isMatch(item))) {
return false;
}
}
return true;
};
/**
* Returns true if **all** of the given `patterns` match
* the specified string.
*
* ```js
* const mm = require('micromatch');
* // mm.all(string, patterns[, options]);
*
* console.log(mm.all('foo.js', ['foo.js']));
* // true
*
* console.log(mm.all('foo.js', ['*.js', '!foo.js']));
* // false
*
* console.log(mm.all('foo.js', ['*.js', 'foo.js']));
* // true
*
* console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
* // true
* ```
* @param {String|Array} `str` The string to test.
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Boolean} Returns true if any patterns match `str`
* @api public
*/
micromatch.all = (str, patterns, options) => {
if (typeof str !== 'string') {
throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
}
return [].concat(patterns).every(p => index.picomatch(p, options)(str));
};
/**
* Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
*
* ```js
* const mm = require('micromatch');
* // mm.capture(pattern, string[, options]);
*
* console.log(mm.capture('test/*.js', 'test/foo.js'));
* //=> ['foo']
* console.log(mm.capture('test/*.js', 'foo/bar.css'));
* //=> null
* ```
* @param {String} `glob` Glob pattern to use for matching.
* @param {String} `input` String to match
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Boolean} Returns an array of captures if the input matches the glob pattern, otherwise `null`.
* @api public
*/
micromatch.capture = (glob, input, options) => {
let posix = index.utils.isWindows(options);
let regex = index.picomatch.makeRe(String(glob), { ...options, capture: true });
let match = regex.exec(posix ? index.utils.toPosixSlashes(input) : input);
if (match) {
return match.slice(1).map(v => v === void 0 ? '' : v);
}
};
/**
* Create a regular expression from the given glob `pattern`.
*
* ```js
* const mm = require('micromatch');
* // mm.makeRe(pattern[, options]);
*
* console.log(mm.makeRe('*.js'));
* //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
* ```
* @param {String} `pattern` A glob pattern to convert to regex.
* @param {Object} `options`
* @return {RegExp} Returns a regex created from the given pattern.
* @api public
*/
micromatch.makeRe = (...args) => index.picomatch.makeRe(...args);
/**
* Scan a glob pattern to separate the pattern into segments. Used
* by the [split](#split) method.
*
* ```js
* const mm = require('micromatch');
* const state = mm.scan(pattern[, options]);
* ```
* @param {String} `pattern`
* @param {Object} `options`
* @return {Object} Returns an object with
* @api public
*/
micromatch.scan = (...args) => index.picomatch.scan(...args);
/**
* Parse a glob pattern to create the source string for a regular
* expression.
*
* ```js
* const mm = require('micromatch');
* const state = mm(pattern[, options]);
* ```
* @param {String} `glob`
* @param {Object} `options`
* @return {Object} Returns an object with useful properties and output to be used as regex source string.
* @api public
*/
micromatch.parse = (patterns, options) => {
let res = [];
for (let pattern of [].concat(patterns || [])) {
for (let str of index.braces_1(String(pattern), options)) {
res.push(index.picomatch.parse(str, options));
}
}
return res;
};
/**
* Process the given brace `pattern`.
*
* ```js
* const { braces } = require('micromatch');
* console.log(braces('foo/{a,b,c}/bar'));
* //=> [ 'foo/(a|b|c)/bar' ]
*
* console.log(braces('foo/{a,b,c}/bar', { expand: true }));
* //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ]
* ```
* @param {String} `pattern` String with brace pattern to process.
* @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options.
* @return {Array}
* @api public
*/
micromatch.braces = (pattern, options) => {
if (typeof pattern !== 'string') throw new TypeError('Expected a string');
if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) {
return [pattern];
}
return index.braces_1(pattern, options);
};
/**
* Expand braces
*/
micromatch.braceExpand = (pattern, options) => {
if (typeof pattern !== 'string') throw new TypeError('Expected a string');
return micromatch.braces(pattern, { ...options, expand: true });
};
/**
* Expose micromatch
*/
var micromatch_1 = micromatch;
function ensureArray(thing) {
if (Array.isArray(thing))
return thing;
if (thing == undefined)
return [];
return [thing];
}
function getMatcherString(id, resolutionBase) {
if (resolutionBase === false) {
return id;
}
return sysPath.resolve(...(typeof resolutionBase === 'string' ? [resolutionBase, id] : [id]));
}
const createFilter = function createFilter(include, exclude, options) {
const resolutionBase = options && options.resolve;
const getMatcher = (id) => {
return id instanceof RegExp
? id
: {
test: micromatch_1.matcher(getMatcherString(id, resolutionBase)
.split(sysPath.sep)
.join('/'), { dot: true })
};
};
const includeMatchers = ensureArray(include).map(getMatcher);
const excludeMatchers = ensureArray(exclude).map(getMatcher);
return function (id) {
if (typeof id !== 'string')
return false;
if (/\0/.test(id))
return false;
id = id.split(sysPath.sep).join('/');
for (let i = 0; i < excludeMatchers.length; ++i) {
const matcher = excludeMatchers[i];
if (matcher.test(id))
return false;
}
for (let i = 0; i < includeMatchers.length; ++i) {
const matcher = includeMatchers[i];
if (matcher.test(id))
return true;
}
return !includeMatchers.length;
};
};
class FileWatcher {
constructor(task, chokidarOptions) {
this.transformWatchers = new Map();
this.chokidarOptions = chokidarOptions;
this.task = task;
this.watcher = this.createWatcher(null);
}
close() {
this.watcher.close();
for (const watcher of this.transformWatchers.values()) {
watcher.close();
}
}
unwatch(id) {
this.watcher.unwatch(id);
const transformWatcher = this.transformWatchers.get(id);
if (transformWatcher) {
this.transformWatchers.delete(id);
transformWatcher.close();
}
}
watch(id, isTransformDependency) {
if (isTransformDependency) {
const watcher = this.transformWatchers.get(id) || this.createWatcher(id);
watcher.add(id);
this.transformWatchers.set(id, watcher);
}
else {
this.watcher.add(id);
}
}
createWatcher(transformWatcherId) {
const task = this.task;
const isLinux = require$$1.platform() === 'linux';
const isTransformDependency = transformWatcherId !== null;
const handleChange = (id, event) => {
const changedId = transformWatcherId || id;
if (isLinux) {
// unwatching and watching fixes an issue with chokidar where on certain systems,
// a file that was unlinked and immediately recreated would create a change event
// but then no longer any further events
watcher.unwatch(changedId);
watcher.add(changedId);
}
task.invalidate(changedId, { isTransformDependency, event });
};
const watcher = index.chokidar
.watch([], this.chokidarOptions)
.on('add', id => handleChange(id, 'create'))
.on('change', id => handleChange(id, 'update'))
.on('unlink', id => handleChange(id, 'delete'));
return watcher;
}
}
const eventsRewrites = {
create: {
create: 'buggy',
delete: null,
update: 'create',
},
delete: {
create: 'update',
delete: 'buggy',
update: 'buggy',
},
update: {
create: 'buggy',
delete: 'delete',
update: 'update',
}
};
class Watcher {
constructor(configs, emitter) {
this.buildDelay = 0;
this.buildTimeout = null;
this.invalidatedIds = new Map();
this.rerun = false;
this.emitter = emitter;
emitter.close = this.close.bind(this);
this.tasks = configs.map(config => new Task(this, config));
this.buildDelay = configs.reduce((buildDelay, { watch }) => watch && typeof watch.buildDelay === 'number'
? Math.max(buildDelay, watch.buildDelay)
: buildDelay, this.buildDelay);
this.running = true;
process.nextTick(() => this.run());
}
close() {
if (this.buildTimeout)
clearTimeout(this.buildTimeout);
for (const task of this.tasks) {
task.close();
}
this.emitter.emit('close');
this.emitter.removeAllListeners();
}
invalidate(file) {
if (file) {
const prevEvent = this.invalidatedIds.get(file.id);
const event = prevEvent
? eventsRewrites[prevEvent][file.event]
: file.event;
if (event === 'buggy') {
//TODO: throws or warn? Currently just ignore, uses new event
this.invalidatedIds.set(file.id, file.event);
}
else if (event === null) {
this.invalidatedIds.delete(file.id);
}
else {
this.invalidatedIds.set(file.id, event);
}
}
if (this.running) {
this.rerun = true;
return;
}
if (this.buildTimeout)
clearTimeout(this.buildTimeout);
this.buildTimeout = setTimeout(() => {
this.buildTimeout = null;
for (const [id, event] of this.invalidatedIds.entries()) {
this.emitter.emit('change', id, { event });
}
this.invalidatedIds.clear();
this.emitter.emit('restart');
this.run();
}, this.buildDelay);
}
async run() {
this.running = true;
this.emitter.emit('event', {
code: 'START'
});
try {
for (const task of this.tasks) {
await task.run();
}
this.running = false;
this.emitter.emit('event', {
code: 'END'
});
}
catch (error) {
this.running = false;
this.emitter.emit('event', {
code: 'ERROR',
error
});
}
if (this.rerun) {
this.rerun = false;
this.invalidate();
}
}
}
class Task {
constructor(watcher, config) {
this.cache = { modules: [] };
this.watchFiles = [];
this.invalidated = true;
this.watcher = watcher;
this.closed = false;
this.watched = new Set();
this.skipWrite = config.watch && !!config.watch.skipWrite;
this.options = mergeOptions.mergeOptions(config);
this.outputs = this.options.output;
this.outputFiles = this.outputs.map(output => {
if (output.file || output.dir)
return sysPath.resolve(output.file || output.dir);
return undefined;
});
const watchOptions = this.options.watch || {};
this.filter = createFilter(watchOptions.include, watchOptions.exclude);
this.fileWatcher = new FileWatcher(this, {
...watchOptions.chokidar,
disableGlobbing: true,
ignoreInitial: true
});
}
close() {
this.closed = true;
this.fileWatcher.close();
}
invalidate(id, details) {
this.invalidated = true;
if (details.isTransformDependency) {
for (const module of this.cache.modules) {
if (module.transformDependencies.indexOf(id) === -1)
continue;
// effective invalidation
module.originalCode = null;
}
}
this.watcher.invalidate({ id, event: details.event });
}
async run() {
if (!this.invalidated)
return;
this.invalidated = false;
const options = {
...this.options,
cache: this.cache
};
const start = Date.now();
this.watcher.emitter.emit('event', {
code: 'BUNDLE_START',
input: this.options.input,
output: this.outputFiles
});
try {
const result = await rollup.rollupInternal(options, this.watcher.emitter);
if (this.closed) {
return;
}
this.updateWatchedFiles(result);
this.skipWrite || (await Promise.all(this.outputs.map(output => result.write(output))));
this.watcher.emitter.emit('event', {
code: 'BUNDLE_END',
duration: Date.now() - start,
input: this.options.input,
output: this.outputFiles,
result
});
}
catch (error) {
if (this.closed) {
return;
}
if (Array.isArray(error.watchFiles)) {
for (const id of error.watchFiles) {
this.watchFile(id);
}
}
if (error.id) {
this.cache.modules = this.cache.modules.filter(module => module.id !== error.id);
}
throw error;
}
}
updateWatchedFiles(result) {
const previouslyWatched = this.watched;
this.watched = new Set();
this.watchFiles = result.watchFiles;
this.cache = result.cache;
for (const id of this.watchFiles) {
this.watchFile(id);
}
for (const module of this.cache.modules) {
for (const depId of module.transformDependencies) {
this.watchFile(depId, true);
}
}
for (const id of previouslyWatched) {
if (!this.watched.has(id)) {
this.fileWatcher.unwatch(id);
}
}
}
watchFile(id, isTransformDependency = false) {
if (!this.filter(id))
return;
this.watched.add(id);
if (this.outputFiles.some(file => file === id)) {
throw new Error('Cannot import the generated bundle');
}
// this is necessary to ensure that any 'renamed' files
// continue to be watched following an error
this.fileWatcher.watch(id, isTransformDependency);
}
}
exports.Task = Task;
exports.Watcher = Watcher;
//# sourceMappingURL=watch.js.map