mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #13058 from e-cloud/types/enhanced-resolve
[Types/enhanced-resolve] upgrade to v3.0.0
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import resolve = require('enhanced-resolve');
|
||||
import { Context } from 'enhanced-resolve/lib/concord';
|
||||
import { ResolveResult } from 'enhanced-resolve/lib/common-types'
|
||||
import { ResolveResult, AbstractInputFileSystem } from 'enhanced-resolve/lib/common-types'
|
||||
import Resolver = require('enhanced-resolve/lib/Resolver')
|
||||
|
||||
resolve('lib', 'string', function (err) { });
|
||||
|
||||
let context: Context = {
|
||||
referrer: 'hi'
|
||||
let context = {
|
||||
issuer: 'hi'
|
||||
};
|
||||
|
||||
resolve(context, 'path', 'string', function () { });
|
||||
@@ -14,15 +13,12 @@ resolve(context, 'path', 'string', function () { });
|
||||
let resolver: Resolver
|
||||
resolver = resolve.ResolverFactory.createResolver({
|
||||
extensions: ['.js'],
|
||||
fileSystem: {}
|
||||
fileSystem: {} as AbstractInputFileSystem
|
||||
});
|
||||
|
||||
const nfs = new resolve.NodeJsInputFileSystem();
|
||||
|
||||
const snfs = new resolve.SyncNodeJsInputFileSystem();
|
||||
|
||||
const cfs = new resolve.CachedInputFileSystem(nfs, 4);
|
||||
const cfs2 = new resolve.CachedInputFileSystem(snfs, 4);
|
||||
|
||||
let result: ResolveResult
|
||||
|
||||
|
||||
Vendored
+86
-62
@@ -1,4 +1,4 @@
|
||||
// Type definitions for enhanced-resolve v2.3.0
|
||||
// Type definitions for enhanced-resolve v3.0.0
|
||||
// Project: http://github.com/webpack/enhanced-resolve.git
|
||||
// Definitions by: e-cloud <https://github.com/e-cloud>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -10,125 +10,149 @@ import fs = require('fs');
|
||||
import {
|
||||
ResolveResult,
|
||||
LoggingCallbackWrapper,
|
||||
ErrorCallback,
|
||||
CommonFileSystemMethod,
|
||||
BaseFileSystem,
|
||||
ResolverRequest
|
||||
} from './lib/common-types';
|
||||
import { Context } from './lib/concord';
|
||||
ResolverRequest,
|
||||
ResolveContext,
|
||||
AbstractInputFileSystem
|
||||
} from './lib/common-types'
|
||||
import { Dictionary } from './lib/concord'
|
||||
import Resolver = require('./lib/Resolver');
|
||||
import Tapable = require('tapable');
|
||||
|
||||
declare namespace Resolve {
|
||||
function sync(path: string, request: string): ResolveResult;
|
||||
function sync(context: Context, path: string, request: string): ResolveResult;
|
||||
function sync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
|
||||
function context(path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function context(context: Context, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function context(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
|
||||
namespace context {
|
||||
function sync(path: string, request: string): ResolveResult;
|
||||
function sync(context: Context, path: string, request: string): ResolveResult;
|
||||
function sync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
}
|
||||
|
||||
function loader(path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function loader(context: Context, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function loader(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
|
||||
namespace context {
|
||||
function sync(path: string, request: string): ResolveResult;
|
||||
function sync(context: Context, path: string, request: string): ResolveResult;
|
||||
function sync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
}
|
||||
|
||||
function create(path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function create(context: Context, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function create(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
|
||||
export namespace create {
|
||||
function sync(path: string, request: string): ResolveResult;
|
||||
function sync(context: Context, path: string, request: string): ResolveResult;
|
||||
function sync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
}
|
||||
|
||||
export namespace ResolverFactory {
|
||||
interface ResolverOption {
|
||||
modules?: string[];
|
||||
descriptionFiles?: string[];
|
||||
plugins?: any[];
|
||||
mainFields?: string[];
|
||||
alias?: AliasItem[] | Dictionary<string>;
|
||||
aliasFields?: string[];
|
||||
mainFiles?: string[];
|
||||
extensions: string[];
|
||||
enforceExtension?: boolean;
|
||||
moduleExtensions?: string[];
|
||||
enforceModuleExtension?: boolean;
|
||||
alias?: AliasItem[] | {};
|
||||
symlinks?: string[] | boolean;
|
||||
resolveToContext?: boolean;
|
||||
unsafeCache?: boolean | {};
|
||||
cachePredicate?: (val: ResolverRequest) => boolean;
|
||||
fileSystem: any;
|
||||
descriptionFiles?: string[];
|
||||
enforceExtension?: boolean;
|
||||
enforceModuleExtension?: boolean;
|
||||
extensions: string[];
|
||||
fileSystem: AbstractInputFileSystem;
|
||||
mainFields?: string[];
|
||||
mainFiles?: string[];
|
||||
moduleExtensions?: string[];
|
||||
modules?: string[];
|
||||
plugins?: Tapable.Plugin[];
|
||||
resolver?: Resolver;
|
||||
resolveToContext?: boolean;
|
||||
symlinks?: string[] | boolean;
|
||||
unsafeCache?: boolean | Dictionary<any>;
|
||||
useSyncFileSystemCalls?: boolean;
|
||||
}
|
||||
interface AliasItem {
|
||||
name: string;
|
||||
alias: string;
|
||||
name: string;
|
||||
onlyModule: boolean;
|
||||
}
|
||||
function createResolver(options: ResolverOption): Resolver;
|
||||
}
|
||||
|
||||
class NodeJsInputFileSystem {
|
||||
readdir(path: string, callback: (err: Error, files: string[]) => void): void;
|
||||
|
||||
isSync(): boolean;
|
||||
|
||||
stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: fs.Stats) => any): void;
|
||||
|
||||
readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
|
||||
readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
|
||||
readdir(path: string, callback: (err: Error, files: string[]) => void): void
|
||||
readFile(
|
||||
filename: string, encoding: string,
|
||||
callback: (err: NodeJS.ErrnoException, data: string) => void
|
||||
): void;
|
||||
readFile(
|
||||
filename: string, options: {
|
||||
encoding: string;
|
||||
flag?: string;
|
||||
}, callback: (err: NodeJS.ErrnoException, data: string) => void
|
||||
): void;
|
||||
readFile(
|
||||
filename: string, options: {
|
||||
flag?: string;
|
||||
}, callback: (err: NodeJS.ErrnoException, data: Buffer) => void
|
||||
): void;
|
||||
readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
|
||||
|
||||
readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void;
|
||||
}
|
||||
|
||||
class SyncNodeJsInputFileSystem {
|
||||
isSync(): boolean;
|
||||
statSync(path: string | Buffer): fs.Stats;
|
||||
|
||||
stat: CommonFileSystemMethod;
|
||||
readdir: CommonFileSystemMethod;
|
||||
readFile(path: string, encoding?: string, callback?: (err: NodeJS.ErrnoException, result: Buffer) => void): void;
|
||||
readFile(path: string, callback?: (err: NodeJS.ErrnoException, result: Buffer) => void): void;
|
||||
readlink: CommonFileSystemMethod;
|
||||
readdirSync(path: string): string[];
|
||||
|
||||
readFileSync(filename: string, encoding: string): string;
|
||||
readFileSync(
|
||||
filename: string, options: {
|
||||
encoding: string;
|
||||
flag?: string;
|
||||
}
|
||||
): string;
|
||||
readFileSync(
|
||||
filename: string, options?: {
|
||||
flag?: string;
|
||||
}
|
||||
): Buffer;
|
||||
|
||||
readlinkSync(path: string | Buffer): string;
|
||||
}
|
||||
|
||||
class CachedInputFileSystem {
|
||||
fileSystem: BaseFileSystem;
|
||||
_statStorage: Storage;
|
||||
_readdirStorage: Storage;
|
||||
_readFileStorage: Storage;
|
||||
_readJsonStorage: Storage;
|
||||
_readlinkStorage: Storage;
|
||||
_stat: CommonFileSystemMethod;
|
||||
_readdir: CommonFileSystemMethod;
|
||||
_readFile: CommonFileSystemMethod;
|
||||
_readJson: CommonFileSystemMethod;
|
||||
_readlink: CommonFileSystemMethod;
|
||||
fileSystem: AbstractInputFileSystem;
|
||||
|
||||
constructor(fileSystem: BaseFileSystem, duration: number);
|
||||
constructor(fileSystem: AbstractInputFileSystem, duration: number);
|
||||
|
||||
isSync(): boolean;
|
||||
stat?(path: string, callback: (err: NodeJS.ErrnoException, stats: fs.Stats) => void): void;
|
||||
|
||||
stat(path: string, callback: ErrorCallback): void;
|
||||
readdir?(path: string, callback: (err: NodeJS.ErrnoException, files: string[]) => void): void;
|
||||
|
||||
readdir(path: string, callback: ErrorCallback): void;
|
||||
readFile?(path: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
|
||||
|
||||
readFile(path: string, callback: ErrorCallback): void;
|
||||
readJson?(path: string, callback: (err: NodeJS.ErrnoException, data: any) => void): void;
|
||||
|
||||
readJson(path: string, callback: ErrorCallback): void;
|
||||
readlink?(path: string, callback: (err: NodeJS.ErrnoException, linkString: string) => void): void;
|
||||
|
||||
readlink(path: string, callback: ErrorCallback): void;
|
||||
statSync?(path: string | Buffer): fs.Stats;
|
||||
|
||||
readdirSync?(path: string): string[];
|
||||
|
||||
readFileSync?(filename: string, options?: { flag?: string; }): Buffer;
|
||||
|
||||
readlinkSync?(path: string | Buffer): string;
|
||||
|
||||
readJsonSync?(path: string): any;
|
||||
|
||||
purge(what?: string | string[]): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare function Resolve(path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
declare function Resolve(context: Context, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
declare function Resolve(
|
||||
context: ResolveContext,
|
||||
path: string,
|
||||
request: string,
|
||||
callback: LoggingCallbackWrapper
|
||||
): void;
|
||||
|
||||
export = Resolve;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import Resolver = require('./Resolver');
|
||||
declare class AliasFieldPlugin {
|
||||
source: string;
|
||||
field: string;
|
||||
source: string;
|
||||
target: string;
|
||||
|
||||
constructor(source: string, field: string, target: string);
|
||||
|
||||
+5
-5
@@ -1,13 +1,13 @@
|
||||
import Resolver = require('./Resolver');
|
||||
import Resolve = require('../');
|
||||
import Resolve = require('enhanced-resolve');
|
||||
|
||||
declare class AliasPlugin {
|
||||
source: string;
|
||||
options: Resolve.ResolverFactory.AliasItem;
|
||||
target: string;
|
||||
name: string;
|
||||
alias: string;
|
||||
name: string;
|
||||
onlyModule: boolean;
|
||||
options: Resolve.ResolverFactory.AliasItem;
|
||||
source: string;
|
||||
target: string;
|
||||
|
||||
constructor(source: string, options: Resolve.ResolverFactory.AliasItem, target: string);
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import Resolver = require('./Resolver');
|
||||
declare class AppendPlugin {
|
||||
source: string;
|
||||
appending: string;
|
||||
source: string;
|
||||
target: string;
|
||||
|
||||
constructor(source: string, appending: string, target: string);
|
||||
|
||||
+4
-2
@@ -1,10 +1,12 @@
|
||||
import Resolver = require('./Resolver');
|
||||
import { Dictionary } from './concord';
|
||||
|
||||
declare class ConcordExtensionsPlugin {
|
||||
options: Dictionary<any>;
|
||||
source: string;
|
||||
options: {};
|
||||
target: string;
|
||||
|
||||
constructor(source: string, options: {}, target: string);
|
||||
constructor(source: string, options: Dictionary<any>, target: string);
|
||||
|
||||
apply(resolver: Resolver): void;
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,10 +1,12 @@
|
||||
import Resolver = require('./Resolver');
|
||||
import { Dictionary } from './concord';
|
||||
|
||||
declare class ConcordMainPlugin {
|
||||
options: Dictionary<any>;
|
||||
source: string;
|
||||
options: {};
|
||||
target: string;
|
||||
|
||||
constructor(source: string, options: {}, target: string);
|
||||
constructor(source: string, options: Dictionary<any>, target: string);
|
||||
|
||||
apply(resolver: Resolver): void;
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,10 +1,12 @@
|
||||
import Resolver = require('./Resolver');
|
||||
import { Dictionary } from './concord';
|
||||
|
||||
declare class ConcordModulesPlugin {
|
||||
options: Dictionary<any>;
|
||||
source: string;
|
||||
options: {};
|
||||
target: string;
|
||||
|
||||
constructor(source: string, options: {}, target: string);
|
||||
constructor(source: string, options: Dictionary<any>, target: string);
|
||||
|
||||
apply(resolver: Resolver): void;
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,11 +1,13 @@
|
||||
import Resolver = require('./Resolver');
|
||||
|
||||
declare class DescriptionFilePlugin {
|
||||
filenames: string[];
|
||||
source: string;
|
||||
target: string;
|
||||
filenames: string[];
|
||||
|
||||
constructor(source: string, filenames: string[] | string, target: string);
|
||||
|
||||
apply(resolver: Resolver): void;
|
||||
}
|
||||
|
||||
export = DescriptionFilePlugin;
|
||||
|
||||
+19
-3
@@ -1,8 +1,24 @@
|
||||
import Resolver = require('./Resolver');
|
||||
import { Dictionary, Concord } from './concord';
|
||||
|
||||
export interface DescriptionFileData {
|
||||
concord?: Concord;
|
||||
browser?: Dictionary<string | boolean>;
|
||||
}
|
||||
|
||||
export interface LoadDescriptionFileResult {
|
||||
content: DescriptionFileData
|
||||
directory: string
|
||||
path: string
|
||||
}
|
||||
|
||||
declare function loadDescriptionFile(
|
||||
resolver: Resolver, directory: string, filenames: string[],
|
||||
callback: (...args: any[]) => any
|
||||
resolver: Resolver,
|
||||
directory: string,
|
||||
filenames: string[],
|
||||
callback: (err?: Error | null, result?: LoadDescriptionFileResult) => any
|
||||
): void;
|
||||
declare function getField(content: any, field: string): any;
|
||||
|
||||
declare function getField(content: Dictionary<any> | null, field: string): any;
|
||||
declare function cdUp(directory: string): string | null;
|
||||
export { loadDescriptionFile, getField, cdUp };
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import Resolver = require('./Resolver');
|
||||
declare class ModulesInHierachicDirectoriesPlugin {
|
||||
directories: string[];
|
||||
source: string;
|
||||
target: string;
|
||||
directories: string[];
|
||||
|
||||
constructor(source: string, directories: string[], target: string);
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import Resolver = require('./Resolver');
|
||||
declare class ModulesInRootPlugin {
|
||||
source: string;
|
||||
path: string;
|
||||
source: string;
|
||||
target: string;
|
||||
|
||||
constructor(source: string, path: string, target: string);
|
||||
|
||||
Vendored
+14
-6
@@ -1,15 +1,22 @@
|
||||
/// <reference types="tapable" />
|
||||
import Tapable = require('tapable');
|
||||
import { ResolveParseResult, ResolverRequest, LoggingCallbackWrapper, BaseFileSystem } from './common-types';
|
||||
import { Context } from './concord';
|
||||
import {
|
||||
ResolveParseResult,
|
||||
ResolveResult,
|
||||
ResolverRequest,
|
||||
LoggingCallbackWrapper,
|
||||
AbstractInputFileSystem,
|
||||
ResolveContext
|
||||
} from './common-types';
|
||||
|
||||
declare class Resolver extends Tapable {
|
||||
fileSystem: BaseFileSystem;
|
||||
fileSystem: AbstractInputFileSystem;
|
||||
|
||||
constructor(fileSystem: BaseFileSystem);
|
||||
constructor(fileSystem: AbstractInputFileSystem);
|
||||
|
||||
resolveSync(context: Context, path: string, request: string): null;
|
||||
resolveSync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
|
||||
resolve(context: Context, path: string, request: string, callback: LoggingCallbackWrapper): any;
|
||||
resolve(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): any;
|
||||
|
||||
doResolve(type: string, request: ResolverRequest, message: string | null, callback: LoggingCallbackWrapper): any;
|
||||
|
||||
@@ -23,4 +30,5 @@ declare class Resolver extends Tapable {
|
||||
|
||||
normalize(path: string): string;
|
||||
}
|
||||
|
||||
export = Resolver;
|
||||
|
||||
Vendored
+11
-11
@@ -1,29 +1,29 @@
|
||||
/// <reference types="node" />
|
||||
import { CommonFileSystemMethod } from './common-types';
|
||||
|
||||
import { CommonFileSystemMethod } from './common-types'
|
||||
import { Dictionary } from './concord'
|
||||
declare class Storage {
|
||||
duration: number;
|
||||
running: {
|
||||
[name: string]: ((...args: any[]) => any)[]
|
||||
};
|
||||
data: {
|
||||
[name: string]: any[]
|
||||
};
|
||||
levels: string[][];
|
||||
count: number;
|
||||
data: Dictionary<any>;
|
||||
duration: number;
|
||||
interval: NodeJS.Timer | null;
|
||||
levels: string[][];
|
||||
needTickCheck: boolean;
|
||||
nextTick: number | null;
|
||||
passive: boolean;
|
||||
running: Dictionary<Function[]>;
|
||||
|
||||
constructor(duration: number);
|
||||
|
||||
ensureTick(): void;
|
||||
|
||||
finished(name: string): void;
|
||||
finished(name: string, err: NodeJS.ErrnoException | null, result: any): void;
|
||||
|
||||
finishedSync(name: string, err: NodeJS.ErrnoException | null, result?: any): void;
|
||||
|
||||
provide(name: string, provider: CommonFileSystemMethod, callback: (...args: any[]) => any): any;
|
||||
|
||||
provideSync(name: string, provider: (name: string) => any): any;
|
||||
|
||||
tick(): true | undefined;
|
||||
|
||||
checkTicks(): void;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/// <reference types="node" />
|
||||
import fs = require('fs');
|
||||
import { AbstractInputFileSystem } from './common-types';
|
||||
|
||||
declare class SyncAsyncFileSystemDecorator {
|
||||
fs: AbstractInputFileSystem;
|
||||
|
||||
readdir?(path: string, callback: (err: NodeJS.ErrnoException | null, files?: string[]) => void): void;
|
||||
|
||||
readFile?(filename: string, callback: (err: NodeJS.ErrnoException | null, data?: Buffer) => void): void;
|
||||
|
||||
readJson?(path: string, callback: (err: NodeJS.ErrnoException | null, data?: any) => void): void;
|
||||
|
||||
readlink?(path: string, callback: (err: NodeJS.ErrnoException | null, linkString?: string) => void): void;
|
||||
|
||||
stat?(path: string, callback: (err: NodeJS.ErrnoException | null, stats?: fs.Stats) => void): void;
|
||||
|
||||
constructor(fs: AbstractInputFileSystem);
|
||||
}
|
||||
|
||||
export = SyncAsyncFileSystemDecorator;
|
||||
+10
-3
@@ -1,12 +1,19 @@
|
||||
import Resolver = require('./Resolver');
|
||||
import { ResolverRequest } from './common-types';
|
||||
import { Dictionary } from './concord';
|
||||
|
||||
declare class UnsafeCachePlugin {
|
||||
source: string;
|
||||
filterPredicate: (str: ResolverRequest) => boolean;
|
||||
cache: {};
|
||||
filterPredicate: (request: ResolverRequest) => boolean;
|
||||
cache: Dictionary<any>;
|
||||
target: string;
|
||||
|
||||
constructor(source: string, filterPredicate: (str: ResolverRequest) => boolean, cache: {}, target: string);
|
||||
constructor(
|
||||
source: string,
|
||||
filterPredicate: (request: ResolverRequest) => boolean,
|
||||
cache: Dictionary<any>,
|
||||
target: string
|
||||
);
|
||||
|
||||
apply(resolver: Resolver): void;
|
||||
}
|
||||
|
||||
+53
-25
@@ -1,5 +1,10 @@
|
||||
import { Context } from './concord';
|
||||
/// <reference types="node" />
|
||||
import { DescriptionFileData } from './DescriptionFileUtils';
|
||||
|
||||
import fs = require('fs');
|
||||
/**
|
||||
* Created by cloud on 16-11-4.
|
||||
*/
|
||||
export interface ResolveError extends Error {
|
||||
details: string;
|
||||
missing: string[];
|
||||
@@ -7,11 +12,15 @@ export interface ResolveError extends Error {
|
||||
}
|
||||
|
||||
export interface ResolveParseResult {
|
||||
request: string;
|
||||
query: string;
|
||||
module: boolean;
|
||||
directory: boolean;
|
||||
file: boolean;
|
||||
module: boolean;
|
||||
query: string;
|
||||
request: string;
|
||||
}
|
||||
|
||||
export interface ResolveContext {
|
||||
issuer?: string;
|
||||
}
|
||||
|
||||
export interface ResolveResult {
|
||||
@@ -20,21 +29,24 @@ export interface ResolveResult {
|
||||
}
|
||||
|
||||
export interface ResolverRequest {
|
||||
request: string;
|
||||
relativePath?: string;
|
||||
descriptionFileData?: any;
|
||||
descriptionFileRoot?: string;
|
||||
context: ResolveContext;
|
||||
descriptionFileData?: DescriptionFileData;
|
||||
descriptionFilePath?: string;
|
||||
context: Context;
|
||||
path: string;
|
||||
query?: string;
|
||||
descriptionFileRoot?: string;
|
||||
directory?: boolean;
|
||||
module?: boolean;
|
||||
path: string;
|
||||
query?: string;
|
||||
relativePath?: string;
|
||||
request: string;
|
||||
__innerRequest?: string;
|
||||
__innerRequest_request?: string;
|
||||
__innerRequest_relativePath?: string;
|
||||
}
|
||||
|
||||
export interface LoggingCallbackTools {
|
||||
log?(msg: string): void;
|
||||
stack?: string[];
|
||||
stack?: string[] | undefined;
|
||||
missing?: string[] | {
|
||||
push: (item: string) => void;
|
||||
};
|
||||
@@ -44,20 +56,36 @@ export interface LoggingCallbackWrapper extends LoggingCallbackTools {
|
||||
(err?: Error | null, ...args: any[]): any;
|
||||
}
|
||||
|
||||
export interface ErrorCallback {
|
||||
(err: Error | null, ...args: any[]): any;
|
||||
export interface ErrorCallback<T> {
|
||||
(err: T | null, ...args: any[]): any;
|
||||
}
|
||||
|
||||
export interface AbstractInputFileSystem {
|
||||
purge?(what?: string | string[]): void;
|
||||
readdir(path: string, callback: (err: NodeJS.ErrnoException, files: string[]) => void): void;
|
||||
readdirSync?(path: string): string[];
|
||||
readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
|
||||
readFile(
|
||||
filename: string, options: {
|
||||
encoding: string;
|
||||
flag?: string;
|
||||
}, callback: (err: NodeJS.ErrnoException, data: string) => void
|
||||
): void;
|
||||
readFile(
|
||||
filename: string, options: {
|
||||
flag?: string;
|
||||
}, callback: (err: NodeJS.ErrnoException, data: Buffer) => void
|
||||
): void;
|
||||
readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
|
||||
readFileSync?(filename: string): Buffer;
|
||||
readJson?(path: string, callback: (err: NodeJS.ErrnoException, data: any) => void): void;
|
||||
readJsonSync?(path: string): any;
|
||||
readlink(path: string, callback: (err: NodeJS.ErrnoException, linkString: string) => void): void;
|
||||
readlinkSync?(path: string): string;
|
||||
stat(path: string, callback: (err: NodeJS.ErrnoException, stats: fs.Stats) => void): void;
|
||||
statSync?(path: string): fs.Stats;
|
||||
}
|
||||
|
||||
export interface CommonFileSystemMethod {
|
||||
(name: string, callback: (err: Error | null, ...args: any[]) => void): void;
|
||||
}
|
||||
|
||||
export interface BaseFileSystem {
|
||||
stat: CommonFileSystemMethod;
|
||||
readdir?: CommonFileSystemMethod;
|
||||
readFile?(path: string, encoding: string, callback: ErrorCallback): void;
|
||||
readFile?(path: string, callback: ErrorCallback): void;
|
||||
readJson?: CommonFileSystemMethod;
|
||||
readlink?: CommonFileSystemMethod;
|
||||
isSync: () => boolean;
|
||||
(name: string, callback: (err: NodeJS.ErrnoException | null, ...args: any[]) => void): void;
|
||||
}
|
||||
|
||||
Vendored
+33
-21
@@ -1,38 +1,50 @@
|
||||
export interface Dictionary<T> {
|
||||
[key: string]: T;
|
||||
}
|
||||
|
||||
export interface Concord {
|
||||
'[server] main': string;
|
||||
extensions: string[];
|
||||
main: string;
|
||||
modules: Dictionary<string>;
|
||||
types: Dictionary<string>;
|
||||
}
|
||||
|
||||
export interface Type {
|
||||
type: string | null | undefined;
|
||||
features: string[];
|
||||
}
|
||||
|
||||
export interface Context {
|
||||
supportedResourceTypes?: string[];
|
||||
export interface ConcordContext {
|
||||
environments?: string[];
|
||||
referrer: string;
|
||||
referrer?: string;
|
||||
supportedResourceTypes?: string[];
|
||||
}
|
||||
|
||||
declare function parseType(type: string): Type;
|
||||
declare function isTypeMatched(baseType: string | Type, testedType: string | Type): boolean;
|
||||
declare function isResourceTypeSupported(context: Context, type: string): boolean | undefined;
|
||||
declare function isEnvironment(context: Context, env: string | Type): boolean | undefined;
|
||||
declare function isResourceTypeSupported(context: ConcordContext, type: string): boolean;
|
||||
declare function isEnvironment(context: ConcordContext, env: string | Type): boolean;
|
||||
declare function isGlobMatched(glob: string, relativePath: string): boolean;
|
||||
declare function isConditionMatched(context: Context, condition: string): boolean;
|
||||
declare function isKeyMatched(context: Context, key: string): string | boolean;
|
||||
declare function getField(context: Context, configuration: any, field: string): undefined;
|
||||
declare function getMain(context: Context, configuration: any): undefined;
|
||||
declare function getExtensions(context: Context, configuration: any): undefined;
|
||||
declare function matchModule(context: Context, configuration: any, request: string): any;
|
||||
declare function matchType(context: Context, configuration: any, relativePath: string): undefined;
|
||||
declare function isConditionMatched(context: ConcordContext, condition: string): boolean;
|
||||
declare function isKeyMatched(context: ConcordContext, key: string): string | boolean;
|
||||
declare function getField(context: ConcordContext, configuration: Concord, field: string): any;
|
||||
declare function getMain(context: ConcordContext, configuration: Concord): any;
|
||||
declare function getExtensions(context: ConcordContext, configuration: Concord): any;
|
||||
declare function matchModule(context: ConcordContext, configuration: Concord, request: string): any;
|
||||
declare function matchType(context: ConcordContext, configuration: Concord, relativePath: string): string | undefined;
|
||||
|
||||
export {
|
||||
parseType,
|
||||
isTypeMatched,
|
||||
isResourceTypeSupported,
|
||||
isEnvironment,
|
||||
isGlobMatched,
|
||||
isConditionMatched,
|
||||
isKeyMatched,
|
||||
getExtensions,
|
||||
getField,
|
||||
getMain,
|
||||
getExtensions,
|
||||
isConditionMatched,
|
||||
isEnvironment,
|
||||
isGlobMatched,
|
||||
isKeyMatched,
|
||||
isResourceTypeSupported,
|
||||
isTypeMatched,
|
||||
matchModule,
|
||||
matchType
|
||||
matchType,
|
||||
parseType
|
||||
};
|
||||
|
||||
@@ -26,6 +26,10 @@ import getPaths, { basename } from 'enhanced-resolve/lib/getPaths';
|
||||
|
||||
import { globToRegExp } from 'enhanced-resolve/lib/globToRegExp';
|
||||
|
||||
import Storage from 'enhanced-resolve/lib/Storage';
|
||||
|
||||
import { AbstractInputFileSystem } from 'enhanced-resolve/lib/common-types';
|
||||
|
||||
import JoinRequestPlugin = require('enhanced-resolve/lib/JoinRequestPlugin');
|
||||
|
||||
import LogInfoPlugin = require('enhanced-resolve/lib/LogInfoPlugin');
|
||||
@@ -48,8 +52,6 @@ import Resolver = require('enhanced-resolve/lib/Resolver');
|
||||
|
||||
import ResultPlugin = require('enhanced-resolve/lib/ResultPlugin');
|
||||
|
||||
import Storage from 'enhanced-resolve/lib/Storage'
|
||||
|
||||
import SymlinkPlugin = require('enhanced-resolve/lib/SymlinkPlugin');
|
||||
|
||||
import TryNextPlugin = require('enhanced-resolve/lib/TryNextPlugin');
|
||||
@@ -60,8 +62,6 @@ import UseFilePlugin = require('enhanced-resolve/lib/UseFilePlugin');
|
||||
|
||||
import resolve = require('../');
|
||||
|
||||
import { BaseFileSystem } from 'enhanced-resolve/lib/common-types'
|
||||
|
||||
const aplugin = new AliasFieldPlugin('a', 'b', 'c');
|
||||
|
||||
const aplugin2 = new AliasPlugin('a', {
|
||||
@@ -95,7 +95,7 @@ DescriptionFileUtils.cdUp('./lib');
|
||||
DescriptionFileUtils.getField({}, 'hi');
|
||||
DescriptionFileUtils.loadDescriptionFile(resolve.ResolverFactory.createResolver({
|
||||
extensions: [''],
|
||||
fileSystem: {}
|
||||
fileSystem: {} as AbstractInputFileSystem
|
||||
}), './lib', ['file'], function () { });
|
||||
|
||||
const dplugin1 = new DirectoryExistsPlugin('string', 'string');
|
||||
@@ -131,7 +131,7 @@ const nplugin = new NextPlugin('string', 'ap');
|
||||
|
||||
const pplugin = new ParsePlugin('string', 'ap');
|
||||
|
||||
const resolver = new Resolver({} as BaseFileSystem);
|
||||
const resolver = new Resolver({} as AbstractInputFileSystem);
|
||||
|
||||
const rplugin = new ResultPlugin('string');
|
||||
|
||||
|
||||
@@ -12,9 +12,41 @@
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"include": [
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"enhanced-resolve-tests.ts",
|
||||
"lib/*.ts"
|
||||
"./lib/AliasFieldPlugin.d.ts",
|
||||
"./lib/AliasPlugin.d.ts",
|
||||
"./lib/AppendPlugin.d.ts",
|
||||
"./lib/CloneBasenamePlugin.d.ts",
|
||||
"./lib/common-types.d.ts",
|
||||
"./lib/concord.d.ts",
|
||||
"./lib/ConcordExtensionsPlugin.d.ts",
|
||||
"./lib/ConcordMainPlugin.d.ts",
|
||||
"./lib/ConcordModulesPlugin.d.ts",
|
||||
"./lib/DescriptionFilePlugin.d.ts",
|
||||
"./lib/DescriptionFileUtils.d.ts",
|
||||
"./lib/DirectoryExistsPlugin.d.ts",
|
||||
"./lib/FileExistsPlugin.d.ts",
|
||||
"./lib/FileKindPlugin.d.ts",
|
||||
"./lib/getPaths.d.ts",
|
||||
"./lib/globToRegExp.d.ts",
|
||||
"./lib/JoinRequestPlugin.d.ts",
|
||||
"./lib/lib-tests.ts",
|
||||
"./lib/LogInfoPlugin.d.ts",
|
||||
"./lib/MainFieldPlugin.d.ts",
|
||||
"./lib/ModuleAppendPlugin.d.ts",
|
||||
"./lib/ModuleKindPlugin.d.ts",
|
||||
"./lib/ModulesInHierachicDirectoriesPlugin.d.ts",
|
||||
"./lib/ModulesInRootPlugin.d.ts",
|
||||
"./lib/NextPlugin.d.ts",
|
||||
"./lib/ParsePlugin.d.ts",
|
||||
"./lib/Resolver.d.ts",
|
||||
"./lib/ResultPlugin.d.ts",
|
||||
"./lib/Storage.d.ts",
|
||||
"./lib/SymlinkPlugin.d.ts",
|
||||
"./lib/TryNextPlugin.d.ts",
|
||||
"./lib/UnsafeCachePlugin.d.ts",
|
||||
"./lib/UseFilePlugin.d.ts"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user