mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-05 07:32:18 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
33
web/node_modules/tsconfig-paths/lib/config-loader.d.ts
generated
vendored
Normal file
33
web/node_modules/tsconfig-paths/lib/config-loader.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
import * as TsConfigLoader from "./tsconfig-loader";
|
||||
export interface ExplicitParams {
|
||||
baseUrl: string;
|
||||
paths: {
|
||||
[key: string]: Array<string>;
|
||||
};
|
||||
mainFields?: Array<string>;
|
||||
addMatchAll?: boolean;
|
||||
}
|
||||
export declare type TsConfigLoader = (params: TsConfigLoader.TsConfigLoaderParams) => TsConfigLoader.TsConfigLoaderResult;
|
||||
export interface ConfigLoaderParams {
|
||||
cwd: string;
|
||||
explicitParams?: ExplicitParams;
|
||||
tsConfigLoader?: TsConfigLoader;
|
||||
}
|
||||
export interface ConfigLoaderSuccessResult {
|
||||
resultType: "success";
|
||||
configFileAbsolutePath: string;
|
||||
baseUrl: string;
|
||||
absoluteBaseUrl: string;
|
||||
paths: {
|
||||
[key: string]: Array<string>;
|
||||
};
|
||||
mainFields?: Array<string>;
|
||||
addMatchAll?: boolean;
|
||||
}
|
||||
export interface ConfigLoaderFailResult {
|
||||
resultType: "failed";
|
||||
message: string;
|
||||
}
|
||||
export declare type ConfigLoaderResult = ConfigLoaderSuccessResult | ConfigLoaderFailResult;
|
||||
export declare function loadConfig(cwd?: string): ConfigLoaderResult;
|
||||
export declare function configLoader({ cwd, explicitParams, tsConfigLoader, }: ConfigLoaderParams): ConfigLoaderResult;
|
55
web/node_modules/tsconfig-paths/lib/config-loader.js
generated
vendored
Normal file
55
web/node_modules/tsconfig-paths/lib/config-loader.js
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var TsConfigLoader = require("./tsconfig-loader");
|
||||
var path = require("path");
|
||||
var options_1 = require("./options");
|
||||
function loadConfig(cwd) {
|
||||
if (cwd === void 0) { cwd = options_1.options.cwd; }
|
||||
return configLoader({ cwd: cwd });
|
||||
}
|
||||
exports.loadConfig = loadConfig;
|
||||
function configLoader(_a) {
|
||||
var cwd = _a.cwd, explicitParams = _a.explicitParams, _b = _a.tsConfigLoader, tsConfigLoader = _b === void 0 ? TsConfigLoader.tsConfigLoader : _b;
|
||||
if (explicitParams) {
|
||||
// tslint:disable-next-line:no-shadowed-variable
|
||||
var absoluteBaseUrl_1 = path.isAbsolute(explicitParams.baseUrl)
|
||||
? explicitParams.baseUrl
|
||||
: path.join(cwd, explicitParams.baseUrl);
|
||||
return {
|
||||
resultType: "success",
|
||||
configFileAbsolutePath: "",
|
||||
baseUrl: explicitParams.baseUrl,
|
||||
absoluteBaseUrl: absoluteBaseUrl_1,
|
||||
paths: explicitParams.paths,
|
||||
mainFields: explicitParams.mainFields,
|
||||
addMatchAll: explicitParams.addMatchAll,
|
||||
};
|
||||
}
|
||||
// Load tsconfig and create path matching function
|
||||
var loadResult = tsConfigLoader({
|
||||
cwd: cwd,
|
||||
getEnv: function (key) { return process.env[key]; },
|
||||
});
|
||||
if (!loadResult.tsConfigPath) {
|
||||
return {
|
||||
resultType: "failed",
|
||||
message: "Couldn't find tsconfig.json",
|
||||
};
|
||||
}
|
||||
if (!loadResult.baseUrl) {
|
||||
return {
|
||||
resultType: "failed",
|
||||
message: "Missing baseUrl in compilerOptions",
|
||||
};
|
||||
}
|
||||
var tsConfigDir = path.dirname(loadResult.tsConfigPath);
|
||||
var absoluteBaseUrl = path.join(tsConfigDir, loadResult.baseUrl);
|
||||
return {
|
||||
resultType: "success",
|
||||
configFileAbsolutePath: loadResult.tsConfigPath,
|
||||
baseUrl: loadResult.baseUrl,
|
||||
absoluteBaseUrl: absoluteBaseUrl,
|
||||
paths: loadResult.paths || {},
|
||||
};
|
||||
}
|
||||
exports.configLoader = configLoader;
|
33
web/node_modules/tsconfig-paths/lib/filesystem.d.ts
generated
vendored
Normal file
33
web/node_modules/tsconfig-paths/lib/filesystem.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* Typing for the fields of package.json we care about
|
||||
*/
|
||||
export interface PackageJson {
|
||||
[key: string]: string;
|
||||
}
|
||||
/**
|
||||
* A function that json from a file
|
||||
*/
|
||||
export interface ReadJsonSync {
|
||||
(packageJsonPath: string): any | undefined;
|
||||
}
|
||||
export interface FileExistsSync {
|
||||
(name: string): boolean;
|
||||
}
|
||||
export interface FileExistsAsync {
|
||||
(path: string, callback: (err?: Error, exists?: boolean) => void): void;
|
||||
}
|
||||
export interface ReadJsonAsyncCallback {
|
||||
(err?: Error, content?: any): void;
|
||||
}
|
||||
export interface ReadJsonAsync {
|
||||
(path: string, callback: ReadJsonAsyncCallback): void;
|
||||
}
|
||||
export declare function fileExistsSync(path: string): boolean;
|
||||
/**
|
||||
* Reads package.json from disk
|
||||
* @param file Path to package.json
|
||||
*/
|
||||
export declare function readJsonFromDiskSync(packageJsonPath: string): any | undefined;
|
||||
export declare function readJsonFromDiskAsync(path: string, callback: (err?: Error, content?: any) => void): void;
|
||||
export declare function fileExistsAsync(path2: string, callback2: (err?: Error, exists?: boolean) => void): void;
|
||||
export declare function removeExtension(path: string): string;
|
53
web/node_modules/tsconfig-paths/lib/filesystem.js
generated
vendored
Normal file
53
web/node_modules/tsconfig-paths/lib/filesystem.js
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var fs = require("fs");
|
||||
function fileExistsSync(path) {
|
||||
try {
|
||||
var stats = fs.statSync(path);
|
||||
return stats.isFile();
|
||||
}
|
||||
catch (err) {
|
||||
// If error, assume file did not exist
|
||||
return false;
|
||||
}
|
||||
}
|
||||
exports.fileExistsSync = fileExistsSync;
|
||||
/**
|
||||
* Reads package.json from disk
|
||||
* @param file Path to package.json
|
||||
*/
|
||||
// tslint:disable-next-line:no-any
|
||||
function readJsonFromDiskSync(packageJsonPath) {
|
||||
if (!fs.existsSync(packageJsonPath)) {
|
||||
return undefined;
|
||||
}
|
||||
return require(packageJsonPath);
|
||||
}
|
||||
exports.readJsonFromDiskSync = readJsonFromDiskSync;
|
||||
function readJsonFromDiskAsync(path,
|
||||
// tslint:disable-next-line:no-any
|
||||
callback) {
|
||||
fs.readFile(path, "utf8", function (err, result) {
|
||||
// If error, assume file did not exist
|
||||
if (err || !result) {
|
||||
return callback();
|
||||
}
|
||||
var json = JSON.parse(result);
|
||||
return callback(undefined, json);
|
||||
});
|
||||
}
|
||||
exports.readJsonFromDiskAsync = readJsonFromDiskAsync;
|
||||
function fileExistsAsync(path2, callback2) {
|
||||
fs.stat(path2, function (err, stats) {
|
||||
if (err) {
|
||||
// If error assume file does not exist
|
||||
return callback2(undefined, false);
|
||||
}
|
||||
callback2(undefined, stats ? stats.isFile() : false);
|
||||
});
|
||||
}
|
||||
exports.fileExistsAsync = fileExistsAsync;
|
||||
function removeExtension(path) {
|
||||
return path.substring(0, path.lastIndexOf(".")) || path;
|
||||
}
|
||||
exports.removeExtension = removeExtension;
|
5
web/node_modules/tsconfig-paths/lib/index.d.ts
generated
vendored
Normal file
5
web/node_modules/tsconfig-paths/lib/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
export { createMatchPath, matchFromAbsolutePaths, MatchPath, } from "./match-path-sync";
|
||||
export { createMatchPathAsync, matchFromAbsolutePathsAsync, MatchPathAsync, } from "./match-path-async";
|
||||
export { register } from "./register";
|
||||
export { loadConfig, ConfigLoaderResult, ConfigLoaderSuccessResult, ConfigLoaderFailResult, } from "./config-loader";
|
||||
export { ReadJsonSync, ReadJsonAsync, FileExistsSync, FileExistsAsync, } from "./filesystem";
|
13
web/node_modules/tsconfig-paths/lib/index.js
generated
vendored
Normal file
13
web/node_modules/tsconfig-paths/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// register is used from register.js in root dir
|
||||
var match_path_sync_1 = require("./match-path-sync");
|
||||
exports.createMatchPath = match_path_sync_1.createMatchPath;
|
||||
exports.matchFromAbsolutePaths = match_path_sync_1.matchFromAbsolutePaths;
|
||||
var match_path_async_1 = require("./match-path-async");
|
||||
exports.createMatchPathAsync = match_path_async_1.createMatchPathAsync;
|
||||
exports.matchFromAbsolutePathsAsync = match_path_async_1.matchFromAbsolutePathsAsync;
|
||||
var register_1 = require("./register");
|
||||
exports.register = register_1.register;
|
||||
var config_loader_1 = require("./config-loader");
|
||||
exports.loadConfig = config_loader_1.loadConfig;
|
17
web/node_modules/tsconfig-paths/lib/mapping-entry.d.ts
generated
vendored
Normal file
17
web/node_modules/tsconfig-paths/lib/mapping-entry.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
export interface MappingEntry {
|
||||
readonly pattern: string;
|
||||
readonly paths: ReadonlyArray<string>;
|
||||
}
|
||||
export interface Paths {
|
||||
readonly [key: string]: ReadonlyArray<string>;
|
||||
}
|
||||
/**
|
||||
* Converts an absolute baseUrl and paths to an array of absolute mapping entries.
|
||||
* The array is sorted by longest prefix.
|
||||
* Having an array with entries allows us to keep a sorting order rather than
|
||||
* sort by keys each time we use the mappings.
|
||||
* @param absoluteBaseUrl
|
||||
* @param paths
|
||||
* @param addMatchAll
|
||||
*/
|
||||
export declare function getAbsoluteMappingEntries(absoluteBaseUrl: string, paths: Paths, addMatchAll: boolean): ReadonlyArray<MappingEntry>;
|
51
web/node_modules/tsconfig-paths/lib/mapping-entry.js
generated
vendored
Normal file
51
web/node_modules/tsconfig-paths/lib/mapping-entry.js
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var path = require("path");
|
||||
/**
|
||||
* Converts an absolute baseUrl and paths to an array of absolute mapping entries.
|
||||
* The array is sorted by longest prefix.
|
||||
* Having an array with entries allows us to keep a sorting order rather than
|
||||
* sort by keys each time we use the mappings.
|
||||
* @param absoluteBaseUrl
|
||||
* @param paths
|
||||
* @param addMatchAll
|
||||
*/
|
||||
function getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll) {
|
||||
// Resolve all paths to absolute form once here, and sort them by
|
||||
// longest prefix once here, this saves time on each request later.
|
||||
// We need to put them in an array to preserve the sorting order.
|
||||
var sortedKeys = sortByLongestPrefix(Object.keys(paths));
|
||||
var absolutePaths = [];
|
||||
for (var _i = 0, sortedKeys_1 = sortedKeys; _i < sortedKeys_1.length; _i++) {
|
||||
var key = sortedKeys_1[_i];
|
||||
absolutePaths.push({
|
||||
pattern: key,
|
||||
paths: paths[key].map(function (pathToResolve) {
|
||||
return path.join(absoluteBaseUrl, pathToResolve);
|
||||
}),
|
||||
});
|
||||
}
|
||||
// If there is no match-all path specified in the paths section of tsconfig, then try to match
|
||||
// all paths relative to baseUrl, this is how typescript works.
|
||||
if (!paths["*"] && addMatchAll) {
|
||||
absolutePaths.push({
|
||||
pattern: "*",
|
||||
paths: [absoluteBaseUrl.replace(/\/$/, "") + "/*"],
|
||||
});
|
||||
}
|
||||
return absolutePaths;
|
||||
}
|
||||
exports.getAbsoluteMappingEntries = getAbsoluteMappingEntries;
|
||||
/**
|
||||
* Sort path patterns.
|
||||
* If a module name can be matched with multiple patterns then pattern with the longest prefix will be picked.
|
||||
*/
|
||||
function sortByLongestPrefix(arr) {
|
||||
return arr
|
||||
.concat()
|
||||
.sort(function (a, b) { return getPrefixLength(b) - getPrefixLength(a); });
|
||||
}
|
||||
function getPrefixLength(pattern) {
|
||||
var prefixLength = pattern.indexOf("*");
|
||||
return pattern.substr(0, prefixLength).length;
|
||||
}
|
21
web/node_modules/tsconfig-paths/lib/match-path-async.d.ts
generated
vendored
Normal file
21
web/node_modules/tsconfig-paths/lib/match-path-async.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
import * as MappingEntry from "./mapping-entry";
|
||||
import * as Filesystem from "./filesystem";
|
||||
/**
|
||||
* Function that can match a path async
|
||||
*/
|
||||
export interface MatchPathAsync {
|
||||
(requestedModule: string, readJson: Filesystem.ReadJsonAsync | undefined, fileExists: Filesystem.FileExistsAsync | undefined, extensions: ReadonlyArray<string> | undefined, callback: MatchPathAsyncCallback): void;
|
||||
}
|
||||
export interface MatchPathAsyncCallback {
|
||||
(err?: Error, path?: string): void;
|
||||
}
|
||||
/**
|
||||
* See the sync version for docs.
|
||||
*/
|
||||
export declare function createMatchPathAsync(absoluteBaseUrl: string, paths: {
|
||||
[key: string]: Array<string>;
|
||||
}, mainFields?: string[], addMatchAll?: boolean): MatchPathAsync;
|
||||
/**
|
||||
* See the sync version for docs.
|
||||
*/
|
||||
export declare function matchFromAbsolutePathsAsync(absolutePathMappings: ReadonlyArray<MappingEntry.MappingEntry>, requestedModule: string, readJson: Filesystem.ReadJsonAsync | undefined, fileExists: Filesystem.FileExistsAsync | undefined, extensions: ReadonlyArray<string> | undefined, callback: MatchPathAsyncCallback, mainFields?: string[]): void;
|
113
web/node_modules/tsconfig-paths/lib/match-path-async.js
generated
vendored
Normal file
113
web/node_modules/tsconfig-paths/lib/match-path-async.js
generated
vendored
Normal file
|
@ -0,0 +1,113 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var path = require("path");
|
||||
var TryPath = require("./try-path");
|
||||
var MappingEntry = require("./mapping-entry");
|
||||
var Filesystem = require("./filesystem");
|
||||
/**
|
||||
* See the sync version for docs.
|
||||
*/
|
||||
function createMatchPathAsync(absoluteBaseUrl, paths, mainFields, addMatchAll) {
|
||||
if (mainFields === void 0) { mainFields = ["main"]; }
|
||||
if (addMatchAll === void 0) { addMatchAll = true; }
|
||||
var absolutePaths = MappingEntry.getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll);
|
||||
return function (requestedModule, readJson, fileExists, extensions, callback) {
|
||||
return matchFromAbsolutePathsAsync(absolutePaths, requestedModule, readJson, fileExists, extensions, callback, mainFields);
|
||||
};
|
||||
}
|
||||
exports.createMatchPathAsync = createMatchPathAsync;
|
||||
/**
|
||||
* See the sync version for docs.
|
||||
*/
|
||||
function matchFromAbsolutePathsAsync(absolutePathMappings, requestedModule, readJson, fileExists, extensions, callback, mainFields) {
|
||||
if (readJson === void 0) { readJson = Filesystem.readJsonFromDiskAsync; }
|
||||
if (fileExists === void 0) { fileExists = Filesystem.fileExistsAsync; }
|
||||
if (extensions === void 0) { extensions = Object.keys(require.extensions); }
|
||||
if (mainFields === void 0) { mainFields = ["main"]; }
|
||||
var tryPaths = TryPath.getPathsToTry(extensions, absolutePathMappings, requestedModule);
|
||||
if (!tryPaths) {
|
||||
return callback();
|
||||
}
|
||||
findFirstExistingPath(tryPaths, readJson, fileExists, callback, 0, mainFields);
|
||||
}
|
||||
exports.matchFromAbsolutePathsAsync = matchFromAbsolutePathsAsync;
|
||||
function findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExistsAsync, doneCallback, index) {
|
||||
if (index === void 0) { index = 0; }
|
||||
if (index >= mainFields.length) {
|
||||
return doneCallback(undefined, undefined);
|
||||
}
|
||||
var tryNext = function () {
|
||||
return findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExistsAsync, doneCallback, index + 1);
|
||||
};
|
||||
var mainFieldMapping = packageJson[mainFields[index]];
|
||||
if (typeof mainFieldMapping !== "string") {
|
||||
// Skip mappings that are not pointers to replacement files
|
||||
return tryNext();
|
||||
}
|
||||
var mappedFilePath = path.join(path.dirname(packageJsonPath), mainFieldMapping);
|
||||
fileExistsAsync(mappedFilePath, function (err, exists) {
|
||||
if (err) {
|
||||
return doneCallback(err);
|
||||
}
|
||||
if (exists) {
|
||||
return doneCallback(undefined, mappedFilePath);
|
||||
}
|
||||
return tryNext();
|
||||
});
|
||||
}
|
||||
// Recursive loop to probe for physical files
|
||||
function findFirstExistingPath(tryPaths, readJson, fileExists, doneCallback, index, mainFields) {
|
||||
if (index === void 0) { index = 0; }
|
||||
if (mainFields === void 0) { mainFields = ["main"]; }
|
||||
var tryPath = tryPaths[index];
|
||||
if (tryPath.type === "file" ||
|
||||
tryPath.type === "extension" ||
|
||||
tryPath.type === "index") {
|
||||
fileExists(tryPath.path, function (err, exists) {
|
||||
if (err) {
|
||||
return doneCallback(err);
|
||||
}
|
||||
if (exists) {
|
||||
// Not sure why we don't just return the full path? Why strip it?
|
||||
return doneCallback(undefined, TryPath.getStrippedPath(tryPath));
|
||||
}
|
||||
if (index === tryPaths.length - 1) {
|
||||
return doneCallback();
|
||||
}
|
||||
// Continue with the next path
|
||||
return findFirstExistingPath(tryPaths, readJson, fileExists, doneCallback, index + 1, mainFields);
|
||||
});
|
||||
}
|
||||
else if (tryPath.type === "package") {
|
||||
readJson(tryPath.path, function (err, packageJson) {
|
||||
if (err) {
|
||||
return doneCallback(err);
|
||||
}
|
||||
if (packageJson) {
|
||||
return findFirstExistingMainFieldMappedFile(packageJson, mainFields, tryPath.path, fileExists, function (mainFieldErr, mainFieldMappedFile) {
|
||||
if (mainFieldErr) {
|
||||
return doneCallback(mainFieldErr);
|
||||
}
|
||||
if (mainFieldMappedFile) {
|
||||
// Not sure why we don't just return the full path? Why strip it?
|
||||
return doneCallback(undefined, Filesystem.removeExtension(mainFieldMappedFile));
|
||||
}
|
||||
// No field in package json was a valid option. Continue with the next path.
|
||||
return findFirstExistingPath(tryPaths, readJson, fileExists, doneCallback, index + 1, mainFields);
|
||||
});
|
||||
}
|
||||
// This is async code, we need to return unconditionally, otherwise the code still falls
|
||||
// through and keeps recursing. While this might work in general, libraries that use neo-async
|
||||
// like Webpack will actually not allow you to call the same callback twice.
|
||||
//
|
||||
// An example of where this caused issues:
|
||||
// https://github.com/dividab/tsconfig-paths-webpack-plugin/issues/11
|
||||
//
|
||||
// Continue with the next path
|
||||
return findFirstExistingPath(tryPaths, readJson, fileExists, doneCallback, index + 1, mainFields);
|
||||
});
|
||||
}
|
||||
else {
|
||||
TryPath.exhaustiveTypeException(tryPath.type);
|
||||
}
|
||||
}
|
30
web/node_modules/tsconfig-paths/lib/match-path-sync.d.ts
generated
vendored
Normal file
30
web/node_modules/tsconfig-paths/lib/match-path-sync.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
import * as Filesystem from "./filesystem";
|
||||
import * as MappingEntry from "./mapping-entry";
|
||||
/**
|
||||
* Function that can match a path
|
||||
*/
|
||||
export interface MatchPath {
|
||||
(requestedModule: string, readJson?: Filesystem.ReadJsonSync, fileExists?: (name: string) => boolean, extensions?: ReadonlyArray<string>): string | undefined;
|
||||
}
|
||||
/**
|
||||
* Creates a function that can resolve paths according to tsconfig paths property.
|
||||
* @param absoluteBaseUrl Absolute version of baseUrl as specified in tsconfig.
|
||||
* @param paths The paths as specified in tsconfig.
|
||||
* @param mainFields A list of package.json field names to try when resolving module files.
|
||||
* @param addMatchAll Add a match-all "*" rule if none is present
|
||||
* @returns a function that can resolve paths.
|
||||
*/
|
||||
export declare function createMatchPath(absoluteBaseUrl: string, paths: {
|
||||
[key: string]: Array<string>;
|
||||
}, mainFields?: string[], addMatchAll?: boolean): MatchPath;
|
||||
/**
|
||||
* Finds a path from tsconfig that matches a module load request.
|
||||
* @param absolutePathMappings The paths to try as specified in tsconfig but resolved to absolute form.
|
||||
* @param requestedModule The required module name.
|
||||
* @param readJson Function that can read json from a path (useful for testing).
|
||||
* @param fileExists Function that checks for existence of a file at a path (useful for testing).
|
||||
* @param extensions File extensions to probe for (useful for testing).
|
||||
* @param mainFields A list of package.json field names to try when resolving module files.
|
||||
* @returns the found path, or undefined if no path was found.
|
||||
*/
|
||||
export declare function matchFromAbsolutePaths(absolutePathMappings: ReadonlyArray<MappingEntry.MappingEntry>, requestedModule: string, readJson?: Filesystem.ReadJsonSync, fileExists?: Filesystem.FileExistsSync, extensions?: Array<string>, mainFields?: string[]): string | undefined;
|
87
web/node_modules/tsconfig-paths/lib/match-path-sync.js
generated
vendored
Normal file
87
web/node_modules/tsconfig-paths/lib/match-path-sync.js
generated
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var path = require("path");
|
||||
var Filesystem = require("./filesystem");
|
||||
var MappingEntry = require("./mapping-entry");
|
||||
var TryPath = require("./try-path");
|
||||
/**
|
||||
* Creates a function that can resolve paths according to tsconfig paths property.
|
||||
* @param absoluteBaseUrl Absolute version of baseUrl as specified in tsconfig.
|
||||
* @param paths The paths as specified in tsconfig.
|
||||
* @param mainFields A list of package.json field names to try when resolving module files.
|
||||
* @param addMatchAll Add a match-all "*" rule if none is present
|
||||
* @returns a function that can resolve paths.
|
||||
*/
|
||||
function createMatchPath(absoluteBaseUrl, paths, mainFields, addMatchAll) {
|
||||
if (mainFields === void 0) { mainFields = ["main"]; }
|
||||
if (addMatchAll === void 0) { addMatchAll = true; }
|
||||
var absolutePaths = MappingEntry.getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll);
|
||||
return function (requestedModule, readJson, fileExists, extensions) {
|
||||
return matchFromAbsolutePaths(absolutePaths, requestedModule, readJson, fileExists, extensions, mainFields);
|
||||
};
|
||||
}
|
||||
exports.createMatchPath = createMatchPath;
|
||||
/**
|
||||
* Finds a path from tsconfig that matches a module load request.
|
||||
* @param absolutePathMappings The paths to try as specified in tsconfig but resolved to absolute form.
|
||||
* @param requestedModule The required module name.
|
||||
* @param readJson Function that can read json from a path (useful for testing).
|
||||
* @param fileExists Function that checks for existence of a file at a path (useful for testing).
|
||||
* @param extensions File extensions to probe for (useful for testing).
|
||||
* @param mainFields A list of package.json field names to try when resolving module files.
|
||||
* @returns the found path, or undefined if no path was found.
|
||||
*/
|
||||
function matchFromAbsolutePaths(absolutePathMappings, requestedModule, readJson, fileExists, extensions, mainFields) {
|
||||
if (readJson === void 0) { readJson = Filesystem.readJsonFromDiskSync; }
|
||||
if (fileExists === void 0) { fileExists = Filesystem.fileExistsSync; }
|
||||
if (extensions === void 0) { extensions = Object.keys(require.extensions); }
|
||||
if (mainFields === void 0) { mainFields = ["main"]; }
|
||||
var tryPaths = TryPath.getPathsToTry(extensions, absolutePathMappings, requestedModule);
|
||||
if (!tryPaths) {
|
||||
return undefined;
|
||||
}
|
||||
return findFirstExistingPath(tryPaths, readJson, fileExists, mainFields);
|
||||
}
|
||||
exports.matchFromAbsolutePaths = matchFromAbsolutePaths;
|
||||
function findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExists) {
|
||||
for (var index = 0; index < mainFields.length; index++) {
|
||||
var mainFieldName = mainFields[index];
|
||||
var candidateMapping = packageJson[mainFieldName];
|
||||
if (candidateMapping && typeof candidateMapping === "string") {
|
||||
var candidateFilePath = path.join(path.dirname(packageJsonPath), candidateMapping);
|
||||
if (fileExists(candidateFilePath)) {
|
||||
return candidateFilePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function findFirstExistingPath(tryPaths, readJson, fileExists, mainFields) {
|
||||
if (readJson === void 0) { readJson = Filesystem.readJsonFromDiskSync; }
|
||||
if (mainFields === void 0) { mainFields = ["main"]; }
|
||||
for (var _i = 0, tryPaths_1 = tryPaths; _i < tryPaths_1.length; _i++) {
|
||||
var tryPath = tryPaths_1[_i];
|
||||
if (tryPath.type === "file" ||
|
||||
tryPath.type === "extension" ||
|
||||
tryPath.type === "index") {
|
||||
if (fileExists(tryPath.path)) {
|
||||
// Not sure why we don't just return the full path? Why strip it?
|
||||
return TryPath.getStrippedPath(tryPath);
|
||||
}
|
||||
}
|
||||
else if (tryPath.type === "package") {
|
||||
var packageJson = readJson(tryPath.path);
|
||||
if (packageJson) {
|
||||
var mainFieldMappedFile = findFirstExistingMainFieldMappedFile(packageJson, mainFields, tryPath.path, fileExists);
|
||||
if (mainFieldMappedFile) {
|
||||
// Not sure why we don't just return the full path? Why strip it?
|
||||
return Filesystem.removeExtension(mainFieldMappedFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
TryPath.exhaustiveTypeException(tryPath.type);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
4
web/node_modules/tsconfig-paths/lib/options.d.ts
generated
vendored
Normal file
4
web/node_modules/tsconfig-paths/lib/options.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
export interface Options {
|
||||
cwd: string;
|
||||
}
|
||||
export declare const options: Options;
|
13
web/node_modules/tsconfig-paths/lib/options.js
generated
vendored
Normal file
13
web/node_modules/tsconfig-paths/lib/options.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var minimist = require("minimist");
|
||||
var argv = minimist(process.argv.slice(2), {
|
||||
string: ["project"],
|
||||
alias: {
|
||||
project: ["P"],
|
||||
},
|
||||
});
|
||||
var project = argv && argv.project;
|
||||
exports.options = {
|
||||
cwd: project || process.cwd(),
|
||||
};
|
6
web/node_modules/tsconfig-paths/lib/register.d.ts
generated
vendored
Normal file
6
web/node_modules/tsconfig-paths/lib/register.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { ExplicitParams } from "./config-loader";
|
||||
/**
|
||||
* Installs a custom module load function that can adhere to paths in tsconfig.
|
||||
* Returns a function to undo paths registration.
|
||||
*/
|
||||
export declare function register(explicitParams: ExplicitParams): () => void;
|
82
web/node_modules/tsconfig-paths/lib/register.js
generated
vendored
Normal file
82
web/node_modules/tsconfig-paths/lib/register.js
generated
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var match_path_sync_1 = require("./match-path-sync");
|
||||
var config_loader_1 = require("./config-loader");
|
||||
var options_1 = require("./options");
|
||||
var noOp = function () { return void 0; };
|
||||
function getCoreModules(builtinModules) {
|
||||
builtinModules = builtinModules || [
|
||||
"assert",
|
||||
"buffer",
|
||||
"child_process",
|
||||
"cluster",
|
||||
"crypto",
|
||||
"dgram",
|
||||
"dns",
|
||||
"domain",
|
||||
"events",
|
||||
"fs",
|
||||
"http",
|
||||
"https",
|
||||
"net",
|
||||
"os",
|
||||
"path",
|
||||
"punycode",
|
||||
"querystring",
|
||||
"readline",
|
||||
"stream",
|
||||
"string_decoder",
|
||||
"tls",
|
||||
"tty",
|
||||
"url",
|
||||
"util",
|
||||
"v8",
|
||||
"vm",
|
||||
"zlib",
|
||||
];
|
||||
var coreModules = {};
|
||||
for (var _i = 0, builtinModules_1 = builtinModules; _i < builtinModules_1.length; _i++) {
|
||||
var module_1 = builtinModules_1[_i];
|
||||
coreModules[module_1] = true;
|
||||
}
|
||||
return coreModules;
|
||||
}
|
||||
/**
|
||||
* Installs a custom module load function that can adhere to paths in tsconfig.
|
||||
* Returns a function to undo paths registration.
|
||||
*/
|
||||
function register(explicitParams) {
|
||||
var configLoaderResult = config_loader_1.configLoader({
|
||||
cwd: options_1.options.cwd,
|
||||
explicitParams: explicitParams,
|
||||
});
|
||||
if (configLoaderResult.resultType === "failed") {
|
||||
console.warn(configLoaderResult.message + ". tsconfig-paths will be skipped");
|
||||
return noOp;
|
||||
}
|
||||
var matchPath = match_path_sync_1.createMatchPath(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll);
|
||||
// Patch node's module loading
|
||||
// tslint:disable-next-line:no-require-imports variable-name
|
||||
var Module = require("module");
|
||||
var originalResolveFilename = Module._resolveFilename;
|
||||
var coreModules = getCoreModules(Module.builtinModules);
|
||||
// tslint:disable-next-line:no-any
|
||||
Module._resolveFilename = function (request, _parent) {
|
||||
var isCoreModule = coreModules.hasOwnProperty(request);
|
||||
if (!isCoreModule) {
|
||||
var found = matchPath(request);
|
||||
if (found) {
|
||||
var modifiedArguments = [found].concat([].slice.call(arguments, 1)); // Passes all arguments. Even those that is not specified above.
|
||||
// tslint:disable-next-line:no-invalid-this
|
||||
return originalResolveFilename.apply(this, modifiedArguments);
|
||||
}
|
||||
}
|
||||
// tslint:disable-next-line:no-invalid-this
|
||||
return originalResolveFilename.apply(this, arguments);
|
||||
};
|
||||
return function () {
|
||||
// Return node's module loading to original state.
|
||||
Module._resolveFilename = originalResolveFilename;
|
||||
};
|
||||
}
|
||||
exports.register = register;
|
15
web/node_modules/tsconfig-paths/lib/try-path.d.ts
generated
vendored
Normal file
15
web/node_modules/tsconfig-paths/lib/try-path.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { MappingEntry } from "./mapping-entry";
|
||||
export interface TryPath {
|
||||
readonly type: "file" | "extension" | "index" | "package";
|
||||
readonly path: string;
|
||||
}
|
||||
/**
|
||||
* Builds a list of all physical paths to try by:
|
||||
* 1. Check for file named exactly as request.
|
||||
* 2. Check for files named as request ending in any of the extensions.
|
||||
* 3. Check for file specified in package.json's main property.
|
||||
* 4. Check for files named as request ending in "index" with any of the extensions.
|
||||
*/
|
||||
export declare function getPathsToTry(extensions: ReadonlyArray<string>, absolutePathMappings: ReadonlyArray<MappingEntry>, requestedModule: string): ReadonlyArray<TryPath> | undefined;
|
||||
export declare function getStrippedPath(tryPath: TryPath): string;
|
||||
export declare function exhaustiveTypeException(check: never): never;
|
91
web/node_modules/tsconfig-paths/lib/try-path.js
generated
vendored
Normal file
91
web/node_modules/tsconfig-paths/lib/try-path.js
generated
vendored
Normal file
|
@ -0,0 +1,91 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var path = require("path");
|
||||
var path_1 = require("path");
|
||||
var filesystem_1 = require("./filesystem");
|
||||
/**
|
||||
* Builds a list of all physical paths to try by:
|
||||
* 1. Check for file named exactly as request.
|
||||
* 2. Check for files named as request ending in any of the extensions.
|
||||
* 3. Check for file specified in package.json's main property.
|
||||
* 4. Check for files named as request ending in "index" with any of the extensions.
|
||||
*/
|
||||
function getPathsToTry(extensions, absolutePathMappings, requestedModule) {
|
||||
if (!absolutePathMappings ||
|
||||
!requestedModule ||
|
||||
requestedModule[0] === "." ||
|
||||
requestedModule[0] === path.sep) {
|
||||
return undefined;
|
||||
}
|
||||
var pathsToTry = [];
|
||||
for (var _i = 0, absolutePathMappings_1 = absolutePathMappings; _i < absolutePathMappings_1.length; _i++) {
|
||||
var entry = absolutePathMappings_1[_i];
|
||||
var starMatch = entry.pattern === requestedModule
|
||||
? ""
|
||||
: matchStar(entry.pattern, requestedModule);
|
||||
if (starMatch !== undefined) {
|
||||
var _loop_1 = function (physicalPathPattern) {
|
||||
var physicalPath = physicalPathPattern.replace("*", starMatch);
|
||||
pathsToTry.push({ type: "file", path: physicalPath });
|
||||
pathsToTry.push.apply(pathsToTry, extensions.map(function (e) { return ({ type: "extension", path: physicalPath + e }); }));
|
||||
pathsToTry.push({
|
||||
type: "package",
|
||||
path: path.join(physicalPath, "/package.json"),
|
||||
});
|
||||
var indexPath = path.join(physicalPath, "/index");
|
||||
pathsToTry.push.apply(pathsToTry, extensions.map(function (e) { return ({ type: "index", path: indexPath + e }); }));
|
||||
};
|
||||
for (var _a = 0, _b = entry.paths; _a < _b.length; _a++) {
|
||||
var physicalPathPattern = _b[_a];
|
||||
_loop_1(physicalPathPattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pathsToTry.length === 0 ? undefined : pathsToTry;
|
||||
}
|
||||
exports.getPathsToTry = getPathsToTry;
|
||||
// Not sure why we don't just return the full found path?
|
||||
function getStrippedPath(tryPath) {
|
||||
return tryPath.type === "index"
|
||||
? path_1.dirname(tryPath.path)
|
||||
: tryPath.type === "file"
|
||||
? tryPath.path
|
||||
: tryPath.type === "extension"
|
||||
? filesystem_1.removeExtension(tryPath.path)
|
||||
: tryPath.type === "package"
|
||||
? tryPath.path
|
||||
: exhaustiveTypeException(tryPath.type);
|
||||
}
|
||||
exports.getStrippedPath = getStrippedPath;
|
||||
function exhaustiveTypeException(check) {
|
||||
throw new Error("Unknown type " + check);
|
||||
}
|
||||
exports.exhaustiveTypeException = exhaustiveTypeException;
|
||||
/**
|
||||
* Matches pattern with a single star against search.
|
||||
* Star must match at least one character to be considered a match.
|
||||
* @param patttern for example "foo*"
|
||||
* @param search for example "fooawesomebar"
|
||||
* @returns the part of search that * matches, or undefined if no match.
|
||||
*/
|
||||
function matchStar(pattern, search) {
|
||||
if (search.length < pattern.length) {
|
||||
return undefined;
|
||||
}
|
||||
if (pattern === "*") {
|
||||
return search;
|
||||
}
|
||||
var star = pattern.indexOf("*");
|
||||
if (star === -1) {
|
||||
return undefined;
|
||||
}
|
||||
var part1 = pattern.substring(0, star);
|
||||
var part2 = pattern.substring(star + 1);
|
||||
if (search.substr(0, star) !== part1) {
|
||||
return undefined;
|
||||
}
|
||||
if (search.substr(search.length - part2.length) !== part2) {
|
||||
return undefined;
|
||||
}
|
||||
return search.substr(star, search.length - part2.length);
|
||||
}
|
28
web/node_modules/tsconfig-paths/lib/tsconfig-loader.d.ts
generated
vendored
Normal file
28
web/node_modules/tsconfig-paths/lib/tsconfig-loader.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Typing for the parts of tsconfig that we care about
|
||||
*/
|
||||
export interface Tsconfig {
|
||||
extends?: string;
|
||||
compilerOptions?: {
|
||||
baseUrl?: string;
|
||||
paths?: {
|
||||
[key: string]: Array<string>;
|
||||
};
|
||||
strict?: boolean;
|
||||
};
|
||||
}
|
||||
export interface TsConfigLoaderResult {
|
||||
tsConfigPath: string | undefined;
|
||||
baseUrl: string | undefined;
|
||||
paths: {
|
||||
[key: string]: Array<string>;
|
||||
} | undefined;
|
||||
}
|
||||
export interface TsConfigLoaderParams {
|
||||
getEnv: (key: string) => string | undefined;
|
||||
cwd: string;
|
||||
loadSync?(cwd: string, filename?: string): TsConfigLoaderResult;
|
||||
}
|
||||
export declare function tsConfigLoader({ getEnv, cwd, loadSync, }: TsConfigLoaderParams): TsConfigLoaderResult;
|
||||
export declare function walkForTsConfig(directory: string, existsSync?: (path: string) => boolean): string | undefined;
|
||||
export declare function loadTsconfig(configFilePath: string, existsSync?: (path: string) => boolean, readFileSync?: (filename: string) => string): Tsconfig | undefined;
|
103
web/node_modules/tsconfig-paths/lib/tsconfig-loader.js
generated
vendored
Normal file
103
web/node_modules/tsconfig-paths/lib/tsconfig-loader.js
generated
vendored
Normal file
|
@ -0,0 +1,103 @@
|
|||
"use strict";
|
||||
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
// tslint:disable:no-require-imports
|
||||
var JSON5 = require("json5");
|
||||
var StripBom = require("strip-bom");
|
||||
function tsConfigLoader(_a) {
|
||||
var getEnv = _a.getEnv, cwd = _a.cwd, _b = _a.loadSync, loadSync = _b === void 0 ? loadSyncDefault : _b;
|
||||
var TS_NODE_PROJECT = getEnv("TS_NODE_PROJECT");
|
||||
// tsconfig.loadSync handles if TS_NODE_PROJECT is a file or directory
|
||||
var loadResult = loadSync(cwd, TS_NODE_PROJECT);
|
||||
return loadResult;
|
||||
}
|
||||
exports.tsConfigLoader = tsConfigLoader;
|
||||
function loadSyncDefault(cwd, filename) {
|
||||
// Tsconfig.loadSync uses path.resolve. This is why we can use an absolute path as filename
|
||||
var configPath = resolveConfigPath(cwd, filename);
|
||||
if (!configPath) {
|
||||
return {
|
||||
tsConfigPath: undefined,
|
||||
baseUrl: undefined,
|
||||
paths: undefined,
|
||||
};
|
||||
}
|
||||
var config = loadTsconfig(configPath);
|
||||
return {
|
||||
tsConfigPath: configPath,
|
||||
baseUrl: config && config.compilerOptions && config.compilerOptions.baseUrl,
|
||||
paths: config && config.compilerOptions && config.compilerOptions.paths,
|
||||
};
|
||||
}
|
||||
function resolveConfigPath(cwd, filename) {
|
||||
if (filename) {
|
||||
var absolutePath = fs.lstatSync(filename).isDirectory()
|
||||
? path.resolve(filename, "./tsconfig.json")
|
||||
: path.resolve(cwd, filename);
|
||||
return absolutePath;
|
||||
}
|
||||
if (fs.statSync(cwd).isFile()) {
|
||||
return path.resolve(cwd);
|
||||
}
|
||||
var configAbsolutePath = walkForTsConfig(cwd);
|
||||
return configAbsolutePath ? path.resolve(configAbsolutePath) : undefined;
|
||||
}
|
||||
function walkForTsConfig(directory, existsSync) {
|
||||
if (existsSync === void 0) { existsSync = fs.existsSync; }
|
||||
var configPath = path.join(directory, "./tsconfig.json");
|
||||
if (existsSync(configPath)) {
|
||||
return configPath;
|
||||
}
|
||||
var parentDirectory = path.join(directory, "../");
|
||||
// If we reached the top
|
||||
if (directory === parentDirectory) {
|
||||
return undefined;
|
||||
}
|
||||
return walkForTsConfig(parentDirectory, existsSync);
|
||||
}
|
||||
exports.walkForTsConfig = walkForTsConfig;
|
||||
function loadTsconfig(configFilePath, existsSync, readFileSync) {
|
||||
if (existsSync === void 0) { existsSync = fs.existsSync; }
|
||||
if (readFileSync === void 0) { readFileSync = function (filename) {
|
||||
return fs.readFileSync(filename, "utf8");
|
||||
}; }
|
||||
if (!existsSync(configFilePath)) {
|
||||
return undefined;
|
||||
}
|
||||
var configString = readFileSync(configFilePath);
|
||||
var cleanedJson = StripBom(configString);
|
||||
var config = JSON5.parse(cleanedJson);
|
||||
var extendedConfig = config.extends;
|
||||
if (extendedConfig) {
|
||||
if (typeof extendedConfig === "string" &&
|
||||
extendedConfig.indexOf(".json") === -1) {
|
||||
extendedConfig += ".json";
|
||||
}
|
||||
var currentDir = path.dirname(configFilePath);
|
||||
var extendedConfigPath = path.join(currentDir, extendedConfig);
|
||||
if (extendedConfig.indexOf("/") !== -1 &&
|
||||
extendedConfig.indexOf(".") !== -1 &&
|
||||
!existsSync(extendedConfigPath)) {
|
||||
extendedConfigPath = path.join(currentDir, "node_modules", extendedConfig);
|
||||
}
|
||||
var base = loadTsconfig(extendedConfigPath, existsSync, readFileSync) || {};
|
||||
// baseUrl should be interpreted as relative to the base tsconfig,
|
||||
// but we need to update it so it is relative to the original tsconfig being loaded
|
||||
if (base.compilerOptions && base.compilerOptions.baseUrl) {
|
||||
var extendsDir = path.dirname(extendedConfig);
|
||||
base.compilerOptions.baseUrl = path.join(extendsDir, base.compilerOptions.baseUrl);
|
||||
}
|
||||
return __assign({}, base, config, { compilerOptions: __assign({}, base.compilerOptions, config.compilerOptions) });
|
||||
}
|
||||
return config;
|
||||
}
|
||||
exports.loadTsconfig = loadTsconfig;
|
Loading…
Add table
Add a link
Reference in a new issue