From 0e41a7ccffdc16fff00e4825b1c92b9aa65e6fec Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Thu, 22 Dec 2022 23:12:03 +0000 Subject: [PATCH 01/13] introduce typescript --- .eslintrc.json | 8 +- .gitignore | 1 + lib/{getHashDigest.js => getHashDigest.ts} | 34 +- lib/hash/{BatchedHash.js => BatchedHash.ts} | 44 +- ...ateDecorator.js => BulkUpdateDecorator.ts} | 44 +- lib/hash/{md4.js => md4.ts} | 6 +- lib/hash/{wasm-hash.js => wasm-hash.ts} | 50 +- lib/hash/{xxhash64.js => xxhash64.ts} | 7 +- lib/index.js | 11 - lib/index.ts | 11 + ...{interpolateName.js => interpolateName.ts} | 13 +- lib/isUrlRequest.js | 31 -- lib/isUrlRequest.ts | 34 ++ lib/{urlToRequest.js => urlToRequest.ts} | 23 +- package.json | 7 +- tsconfig.json | 12 + yarn.lock | 519 +++++++++++++++++- 17 files changed, 697 insertions(+), 158 deletions(-) rename lib/{getHashDigest.js => getHashDigest.ts} (73%) rename lib/hash/{BatchedHash.js => BatchedHash.ts} (56%) rename lib/hash/{BulkUpdateDecorator.js => BulkUpdateDecorator.ts} (66%) rename lib/hash/{md4.js => md4.ts} (96%) rename lib/hash/{wasm-hash.js => wasm-hash.ts} (79%) rename lib/hash/{xxhash64.js => xxhash64.ts} (94%) delete mode 100644 lib/index.js create mode 100644 lib/index.ts rename lib/{interpolateName.js => interpolateName.ts} (92%) delete mode 100644 lib/isUrlRequest.js create mode 100644 lib/isUrlRequest.ts rename lib/{urlToRequest.js => urlToRequest.ts} (69%) create mode 100644 tsconfig.json diff --git a/.eslintrc.json b/.eslintrc.json index c436959..4e9f23e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,10 +1,11 @@ { "root": true, - "plugins": ["node"], - "extends": ["eslint:recommended", "plugin:node/recommended"], + "plugins": ["node", "@typescript-eslint"], + "extends": ["eslint:recommended", "plugin:node/recommended", "plugin:@typescript-eslint/recommended"], "env": { "node": true }, + "parser": "@typescript-eslint/parser", "rules": { "no-template-curly-in-string": "error", "no-caller": "error", @@ -18,6 +19,7 @@ "no-var": "error", "prefer-const": "error", "prefer-arrow-callback": "error", - "object-shorthand": "error" + "object-shorthand": "error", + "es-syntax": "false" } } diff --git a/.gitignore b/.gitignore index 428a1df..882d864 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea node_modules coverage +/dist \ No newline at end of file diff --git a/lib/getHashDigest.js b/lib/getHashDigest.ts similarity index 73% rename from lib/getHashDigest.js rename to lib/getHashDigest.ts index 600b86e..ce271be 100644 --- a/lib/getHashDigest.js +++ b/lib/getHashDigest.ts @@ -1,4 +1,4 @@ -"use strict"; +import {Hash} from 'crypto'; const baseEncodeTables = { 26: "abcdefghijklmnopqrstuvwxyz", @@ -11,12 +11,15 @@ const baseEncodeTables = { 64: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_", }; +type DigestTypes = "base26" | "base32" | "base36" | "base49" | "base52" | "base58" | "base62" | "base64"; +type BaseEncodings = 26 | 32 | 36 | 49 | 52 | 58 | 62 | 64; + /** * @param {Uint32Array} uint32Array Treated as a long base-0x100000000 number, little endian * @param {number} divisor The divisor * @return {number} Modulo (remainder) of the division */ -function divmod32(uint32Array, divisor) { +function divmod32(uint32Array: Uint32Array, divisor: number): number { let carry = 0; for (let i = uint32Array.length - 1; i >= 0; i--) { const value = carry * 0x100000000 + uint32Array[i]; @@ -26,8 +29,8 @@ function divmod32(uint32Array, divisor) { return carry; } -function encodeBufferToBase(buffer, base, length) { - const encodeTable = baseEncodeTables[base]; +function encodeBufferToBase(buffer: Buffer, base: BaseEncodings | number, length: number) { + const encodeTable = baseEncodeTables[(base as keyof typeof baseEncodeTables)]; if (!encodeTable) { throw new Error("Unknown encoding base" + base); @@ -54,13 +57,13 @@ function encodeBufferToBase(buffer, base, length) { return output; } -let crypto = undefined; -let createXXHash64 = undefined; -let createMd4 = undefined; -let BatchedHash = undefined; -let BulkUpdateDecorator = undefined; +let crypto: typeof import('crypto') +let createXXHash64: typeof import('./hash/xxhash64').default; +let createMd4: typeof import('./hash/md4').default; +let BatchedHash: typeof import('./hash/BatchedHash').default; +let BulkUpdateDecorator: typeof import('./hash/BulkUpdateDecorator').default; -function getHashDigest(buffer, algorithm, digestType, maxLength) { +export default function getHashDigest(buffer: Buffer, algorithm: string | "xxhash64" | "md4" | "native-md4", digestType: DigestTypes | string, maxLength: number) { algorithm = algorithm || "xxhash64"; maxLength = maxLength || 9999; @@ -75,7 +78,7 @@ function getHashDigest(buffer, algorithm, digestType, maxLength) { } } - hash = new BatchedHash(createXXHash64()); + hash = new BatchedHash(createXXHash64() as unknown as Hash); } else if (algorithm === "md4") { if (createMd4 === undefined) { createMd4 = require("./hash/md4"); @@ -85,7 +88,7 @@ function getHashDigest(buffer, algorithm, digestType, maxLength) { } } - hash = new BatchedHash(createMd4()); + hash = new BatchedHash(createMd4() as unknown as Hash); } else if (algorithm === "native-md4") { if (typeof crypto === "undefined") { crypto = require("crypto"); @@ -122,10 +125,11 @@ function getHashDigest(buffer, algorithm, digestType, maxLength) { digestType === "base58" || digestType === "base62" ) { - return encodeBufferToBase(hash.digest(), digestType.substr(4), maxLength); + const digestTypeToDigest: number = digestType.substr(4) as unknown as number; + + return encodeBufferToBase(hash.digest() as Buffer, digestTypeToDigest, maxLength); } else { + // @ts-ignore return hash.digest(digestType || "hex").substr(0, maxLength); } } - -module.exports = getHashDigest; diff --git a/lib/hash/BatchedHash.js b/lib/hash/BatchedHash.ts similarity index 56% rename from lib/hash/BatchedHash.js rename to lib/hash/BatchedHash.ts index 694ad4f..275946b 100644 --- a/lib/hash/BatchedHash.js +++ b/lib/hash/BatchedHash.ts @@ -1,7 +1,12 @@ -const MAX_SHORT_STRING = require("./wasm-hash").MAX_SHORT_STRING; +import type { Hash, Encoding, BinaryToTextEncoding } from "crypto"; +import { MAX_SHORT_STRING } from './wasm-hash' -class BatchedHash { - constructor(hash) { +export default class BatchedHash { + public string?: string; + public encoding?: Encoding; + public readonly hash: Hash; + + constructor(hash: Hash) { this.string = undefined; this.encoding = undefined; this.hash = hash; @@ -13,7 +18,7 @@ class BatchedHash { * @param {string=} inputEncoding data encoding * @returns {this} updated hash */ - update(data, inputEncoding) { + update(data: string | Buffer, inputEncoding?: Encoding): this { if (this.string !== undefined) { if ( typeof data === "string" && @@ -25,7 +30,12 @@ class BatchedHash { return this; } - this.hash.update(this.string, this.encoding); + if (this.encoding !== undefined) { + this.hash.update(this.string, this.encoding); + } else { + this.hash.update(this.string) + } + this.string = undefined; } @@ -38,7 +48,11 @@ class BatchedHash { this.string = data; this.encoding = inputEncoding; } else { - this.hash.update(data, inputEncoding); + if (inputEncoding !== undefined) { + this.hash.update(data, inputEncoding); + } else { + this.hash.update(data); + } } } else { this.hash.update(data); @@ -52,13 +66,19 @@ class BatchedHash { * @param {string=} encoding encoding of the return value * @returns {string|Buffer} digest */ - digest(encoding) { + digest(encoding?: BinaryToTextEncoding): string | Buffer { if (this.string !== undefined) { - this.hash.update(this.string, this.encoding); - } + if (this.encoding !== undefined) { + this.hash.update(this.string, this.encoding); + } else { + this.hash.update(this.string); + } - return this.hash.digest(encoding); + } + if (encoding !== undefined) { + return this.hash.digest(encoding); + } else { + return this.hash.digest(); + } } } - -module.exports = BatchedHash; diff --git a/lib/hash/BulkUpdateDecorator.js b/lib/hash/BulkUpdateDecorator.ts similarity index 66% rename from lib/hash/BulkUpdateDecorator.js rename to lib/hash/BulkUpdateDecorator.ts index f3f7c73..920d333 100644 --- a/lib/hash/BulkUpdateDecorator.js +++ b/lib/hash/BulkUpdateDecorator.ts @@ -1,15 +1,24 @@ -const BULK_SIZE = 2000; +import type { Hash, Encoding, BinaryToTextEncoding } from "crypto"; +type HashOrFactory = Hash | (() => Hash); + +const BULK_SIZE: number = 2000; // We are using an object instead of a Map as this will stay static during the runtime // so access to it can be optimized by v8 -const digestCaches = {}; +const digestCaches: {[key: string]: any} = {}; + -class BulkUpdateDecorator { +export default class BulkUpdateDecorator { /** - * @param {Hash | function(): Hash} hashOrFactory function to create a hash + * @param {HashOrFactory} hashOrFactory function to create a hash * @param {string=} hashKey key for caching */ - constructor(hashOrFactory, hashKey) { + hash?: Hash; + hashFactory?: (() => Hash); + hashKey: string; + buffer: string; + + constructor(hashOrFactory: HashOrFactory, hashKey: string) { this.hashKey = hashKey; if (typeof hashOrFactory === "function") { @@ -29,14 +38,14 @@ class BulkUpdateDecorator { * @param {string=} inputEncoding data encoding * @returns {this} updated hash */ - update(data, inputEncoding) { + update(data: string | Buffer, inputEncoding?: Encoding): this { if ( inputEncoding !== undefined || typeof data !== "string" || data.length > BULK_SIZE ) { if (this.hash === undefined) { - this.hash = this.hashFactory(); + this.hash = this.hashFactory!(); } if (this.buffer.length > 0) { @@ -44,13 +53,17 @@ class BulkUpdateDecorator { this.buffer = ""; } - this.hash.update(data, inputEncoding); + if (inputEncoding === undefined) { + this.hash.update(data); + } else { + this.hash.update(data as string, inputEncoding); + } } else { this.buffer += data; if (this.buffer.length > BULK_SIZE) { if (this.hash === undefined) { - this.hash = this.hashFactory(); + this.hash = this.hashFactory!(); } this.hash.update(this.buffer); @@ -66,8 +79,9 @@ class BulkUpdateDecorator { * @param {string=} encoding encoding of the return value * @returns {string|Buffer} digest */ - digest(encoding) { + digest(encoding?: BinaryToTextEncoding): string | Buffer { let digestCache; + let digestResult: string | Buffer; const buffer = this.buffer; @@ -87,14 +101,18 @@ class BulkUpdateDecorator { return cacheEntry; } - this.hash = this.hashFactory(); + this.hash = this.hashFactory!(); } if (buffer.length > 0) { this.hash.update(buffer); } - const digestResult = this.hash.digest(encoding); + if (encoding !== undefined) { + digestResult = this.hash.digest(encoding); + } else { + digestResult = this.hash.digest(); + } if (digestCache !== undefined) { digestCache.set(buffer, digestResult); @@ -103,5 +121,3 @@ class BulkUpdateDecorator { return digestResult; } } - -module.exports = BulkUpdateDecorator; diff --git a/lib/hash/md4.js b/lib/hash/md4.ts similarity index 96% rename from lib/hash/md4.js rename to lib/hash/md4.ts index 077fcec..09c3ffe 100644 --- a/lib/hash/md4.js +++ b/lib/hash/md4.ts @@ -3,9 +3,7 @@ Author Tobias Koppers @sokra */ -"use strict"; - -const create = require("./wasm-hash"); +import { create } from './wasm-hash'; //#region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1 const md4 = new WebAssembly.Module( @@ -17,4 +15,4 @@ const md4 = new WebAssembly.Module( ); //#endregion -module.exports = create.bind(null, md4, [], 64, 32); +export default create.bind(null, md4, [], 64, 32); diff --git a/lib/hash/wasm-hash.js b/lib/hash/wasm-hash.ts similarity index 79% rename from lib/hash/wasm-hash.js rename to lib/hash/wasm-hash.ts index bbe999a..a513334 100644 --- a/lib/hash/wasm-hash.js +++ b/lib/hash/wasm-hash.ts @@ -1,25 +1,32 @@ +import { Hash, BinaryToTextEncoding } from "crypto"; + /* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -"use strict"; - // 65536 is the size of a wasm memory page // 64 is the maximum chunk size for every possible wasm hash implementation // 4 is the maximum number of bytes per char for string encoding (max is utf-8) // ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64 -const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3; +export const MAX_SHORT_STRING: number = Math.floor((65536 - 64) / 4) & ~3; -class WasmHash { +export class WasmHash { /** * @param {WebAssembly.Instance} instance wasm instance * @param {WebAssembly.Instance[]} instancesPool pool of instances * @param {number} chunkSize size of data chunks passed to wasm * @param {number} digestSize size of digest returned by wasm */ - constructor(instance, instancesPool, chunkSize, digestSize) { - const exports = /** @type {any} */ (instance.exports); + exports: any; + mem: Buffer; + buffered: number; + instancesPool: WebAssembly.Instance[]; + chunkSize: number; + digestSize: number; + + constructor(instance: WebAssembly.Instance, instancesPool: WebAssembly.Instance[], chunkSize: number, digestSize: number) { + const exports = instance.exports as any; exports.init(); @@ -31,7 +38,7 @@ class WasmHash { this.digestSize = digestSize; } - reset() { + reset(): void { this.buffered = 0; this.exports.init(); } @@ -41,7 +48,7 @@ class WasmHash { * @param {BufferEncoding=} encoding encoding * @returns {this} itself */ - update(data, encoding) { + update(data: Buffer | string, encoding: BufferEncoding): this { if (typeof data === "string") { while (data.length > MAX_SHORT_STRING) { this._updateWithShortString(data.slice(0, MAX_SHORT_STRING), encoding); @@ -58,15 +65,10 @@ class WasmHash { return this; } - /** - * @param {string} data data - * @param {BufferEncoding=} encoding encoding - * @returns {void} - */ - _updateWithShortString(data, encoding) { + _updateWithShortString(data: string, encoding: BufferEncoding): void { const { exports, buffered, mem, chunkSize } = this; - let endPos; + let endPos: number; if (data.length < 70) { if (!encoding || encoding === "utf-8" || encoding === "utf8") { @@ -122,7 +124,7 @@ class WasmHash { * @param {Buffer} data data * @returns {void} */ - _updateWithBuffer(data) { + _updateWithBuffer(data: Buffer): void { const { exports, buffered, mem } = this; const length = data.length; @@ -166,7 +168,7 @@ class WasmHash { } } - digest(type) { + digest(encoding: BinaryToTextEncoding): string | Buffer { const { exports, buffered, mem, digestSize } = this; exports.final(buffered); @@ -175,23 +177,25 @@ class WasmHash { const hex = mem.toString("latin1", 0, digestSize); - if (type === "hex") { + if (encoding === "hex") { return hex; } - if (type === "binary" || !type) { + if (encoding === "binary" || !encoding) { return Buffer.from(hex, "hex"); } - return Buffer.from(hex, "hex").toString(type); + return Buffer.from(hex, "hex").toString(encoding); } } -const create = (wasmModule, instancesPool, chunkSize, digestSize) => { +export const create = (wasmModule: WebAssembly.Module, instancesPool: WasmHash[], chunkSize: number, digestSize: number) => { if (instancesPool.length > 0) { const old = instancesPool.pop(); - old.reset(); + // old is possibly undefined + // protect reset call here + old && old.reset(); return old; } else { @@ -204,5 +208,3 @@ const create = (wasmModule, instancesPool, chunkSize, digestSize) => { } }; -module.exports = create; -module.exports.MAX_SHORT_STRING = MAX_SHORT_STRING; diff --git a/lib/hash/xxhash64.js b/lib/hash/xxhash64.ts similarity index 94% rename from lib/hash/xxhash64.js rename to lib/hash/xxhash64.ts index afe3f3d..ec65404 100644 --- a/lib/hash/xxhash64.js +++ b/lib/hash/xxhash64.ts @@ -2,10 +2,7 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ - -"use strict"; - -const create = require("./wasm-hash"); +import { create } from './wasm-hash'; //#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1 const xxhash64 = new WebAssembly.Module( @@ -17,4 +14,4 @@ const xxhash64 = new WebAssembly.Module( ); //#endregion -module.exports = create.bind(null, xxhash64, [], 32, 16); +export default create.bind(null, xxhash64, [], 32, 16); diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d24f3d5..0000000 --- a/lib/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -const isUrlRequest = require("./isUrlRequest"); -const urlToRequest = require("./urlToRequest"); -const getHashDigest = require("./getHashDigest"); -const interpolateName = require("./interpolateName"); - -exports.urlToRequest = urlToRequest; -exports.getHashDigest = getHashDigest; -exports.interpolateName = interpolateName; -exports.isUrlRequest = isUrlRequest; diff --git a/lib/index.ts b/lib/index.ts new file mode 100644 index 0000000..656ca30 --- /dev/null +++ b/lib/index.ts @@ -0,0 +1,11 @@ +import isUrlRequest from "./isUrlRequest"; +import urlToRequest from "./urlToRequest"; +import getHashDigest from "./getHashDigest"; +import interpolateName from "./interpolateName"; + +export { + urlToRequest, + getHashDigest, + interpolateName, + isUrlRequest +} diff --git a/lib/interpolateName.js b/lib/interpolateName.ts similarity index 92% rename from lib/interpolateName.js rename to lib/interpolateName.ts index 267dd2c..e4d6458 100644 --- a/lib/interpolateName.js +++ b/lib/interpolateName.ts @@ -1,9 +1,8 @@ -"use strict"; +import type { LoaderContext } from "webpack"; +import path from "path"; +import getHashDigest from './getHashDigest'; -const path = require("path"); -const getHashDigest = require("./getHashDigest"); - -function interpolateName(loaderContext, name, options = {}) { +export default function interpolateName(loaderContext: LoaderContext<{}>, name: string, options = {}) { let filename; const hasQuery = @@ -111,6 +110,4 @@ function interpolateName(loaderContext, name, options = {}) { } return url; -} - -module.exports = interpolateName; +} \ No newline at end of file diff --git a/lib/isUrlRequest.js b/lib/isUrlRequest.js deleted file mode 100644 index 0114c41..0000000 --- a/lib/isUrlRequest.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; - -const path = require("path"); - -function isUrlRequest(url) { - // An URL is not an request if - - // 1. Allow `data URI` - if (/^data:/i.test(url)) { - return true; - } - - // 2. It's an absolute url and it is not `windows` path like `C:\dir\file` - if (/^[a-z][a-z0-9+.-]*:/i.test(url) && !path.win32.isAbsolute(url)) { - return false; - } - - // 3. It's a protocol-relative - if (/^\/\//.test(url)) { - return false; - } - - // 4. It's some kind of url for a template - if (/^#/.test(url)) { - return false; - } - - return true; -} - -module.exports = isUrlRequest; diff --git a/lib/isUrlRequest.ts b/lib/isUrlRequest.ts new file mode 100644 index 0000000..7a5a715 --- /dev/null +++ b/lib/isUrlRequest.ts @@ -0,0 +1,34 @@ +import path from 'path'; + +const DATA_URI_REGEXP: RegExp = /^data:/i; +const ABOSLUTE_URL_NON_WINDOWS_PATHLIKE_REGEXP: RegExp = /^[a-z][a-z0-9+.-]*:/i; +const POROTCOL_RELATIVE_REGEXP: RegExp = /^\/\//i; +const URL_FOR_TEMPLATE_REGEXP: RegExp = /^#/i; + +export default function isUrlRequest(url: string): boolean { + // An URL is not an request if + + // 1. Allow `data URI` + if (DATA_URI_REGEXP.test(url)) { + return true; + } + + // 2. It's an absolute url and it is not `windows` path like `C:\dir\file` + if (ABOSLUTE_URL_NON_WINDOWS_PATHLIKE_REGEXP.test(url) && !path.win32.isAbsolute(url)) { + return false; + } + + // 3. It's a protocol-relative + if (POROTCOL_RELATIVE_REGEXP.test(url)) { + return false; + } + + // 4. It's some kind of url for a template + if (URL_FOR_TEMPLATE_REGEXP.test(url)) { + return false; + } + + return true; +} + + diff --git a/lib/urlToRequest.js b/lib/urlToRequest.ts similarity index 69% rename from lib/urlToRequest.js rename to lib/urlToRequest.ts index 3f39db1..4cd5502 100644 --- a/lib/urlToRequest.js +++ b/lib/urlToRequest.ts @@ -1,27 +1,26 @@ -"use strict"; - // we can't use path.win32.isAbsolute because it also matches paths starting with a forward slash -const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i; +const NATIVE_WIN_32_PATH_REGEXP: RegExp = /^[A-Z]:[/\\]|^\\\\/i; +const MODULE_REQUEST_REGEXP: RegExp = /^[^?]*~/; +const ROOT_RELATIVE_URL_REGEXP: RegExp = /^\//; -function urlToRequest(url, root) { +export default function urlToRequest(url: string, root?: string | boolean): string { // Do not rewrite an empty url if (url === "") { return ""; } - const moduleRequestRegex = /^[^?]*~/; - let request; + let request: string; - if (matchNativeWin32Path.test(url)) { + if (NATIVE_WIN_32_PATH_REGEXP.test(url)) { // absolute windows path, keep it request = url; - } else if (root !== undefined && root !== false && /^\//.test(url)) { + } else if (root !== undefined && root !== false && ROOT_RELATIVE_URL_REGEXP.test(url)) { // if root is set and the url is root-relative switch (typeof root) { // 1. root is a string: root is prefixed to the url case "string": // special case: `~` roots convert to module request - if (moduleRequestRegex.test(root)) { + if (MODULE_REQUEST_REGEX.test(root)) { request = root.replace(/([^~/])$/, "$1/") + url.slice(1); } else { request = root + url; @@ -50,11 +49,9 @@ function urlToRequest(url, root) { } // A `~` makes the url an module - if (moduleRequestRegex.test(request)) { - request = request.replace(moduleRequestRegex, ""); + if (MODULE_REQUEST_REGEX.test(request)) { + request = request.replace(MODULE_REQUEST_REGEX, ""); } return request; } - -module.exports = urlToRequest; diff --git a/package.json b/package.json index f184859..123df7b 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "dependencies": {}, "scripts": { "lint": "prettier --list-different . && eslint .", + "build": "tsc", "pretest": "yarn lint", "test": "jest", "test:only": "jest --coverage", @@ -21,12 +22,16 @@ "node": ">= 12.13.0" }, "devDependencies": { + "@typescript-eslint/eslint-plugin": "^5.47.0", + "@typescript-eslint/parser": "^5.47.0", "coveralls": "^3.1.1", "eslint": "^8.0.1", "eslint-plugin-node": "^11.1.0", "jest": "^27.3.1", "prettier": "^2.4.1", - "standard-version": "^9.3.2" + "standard-version": "^9.3.2", + "typescript": "^4.9.4", + "webpack": "^5.64.4" }, "main": "lib/index.js", "files": [ diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..5ac0456 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "ES2017", + "module": "commonjs", + "lib": ["es2017", "DOM"], + "outDir": "dist", + "strict": true, + "types": ["node"], + "esModuleInterop": true, + }, + "include": ["lib/**/*.ts"], +} diff --git a/yarn.lock b/yarn.lock index cb1f7be..c1191a1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -522,7 +522,7 @@ "@jridgewell/set-array" "^1.0.0" "@jridgewell/sourcemap-codec" "^1.4.10" -"@jridgewell/gen-mapping@^0.3.2": +"@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2": version "0.3.2" resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== @@ -541,12 +541,20 @@ resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== +"@jridgewell/source-map@^0.3.2": + version "0.3.2" + resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb" + integrity sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw== + dependencies: + "@jridgewell/gen-mapping" "^0.3.0" + "@jridgewell/trace-mapping" "^0.3.9" + "@jridgewell/sourcemap-codec@1.4.14", "@jridgewell/sourcemap-codec@^1.4.10": version "1.4.14" resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== -"@jridgewell/trace-mapping@^0.3.9": +"@jridgewell/trace-mapping@^0.3.14", "@jridgewell/trace-mapping@^0.3.9": version "0.3.17" resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz#793041277af9073b0951a7fe0f0d8c4c98c36985" integrity sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g== @@ -562,12 +570,12 @@ "@nodelib/fs.stat" "2.0.5" run-parallel "^1.1.9" -"@nodelib/fs.stat@2.0.5": +"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": version "2.0.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== -"@nodelib/fs.walk@^1.2.8": +"@nodelib/fs.walk@^1.2.3", "@nodelib/fs.walk@^1.2.8": version "1.2.8" resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== @@ -627,6 +635,32 @@ dependencies: "@babel/types" "^7.3.0" +"@types/eslint-scope@^3.7.3": + version "3.7.4" + resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.4.tgz#37fc1223f0786c39627068a12e94d6e6fc61de16" + integrity sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA== + dependencies: + "@types/eslint" "*" + "@types/estree" "*" + +"@types/eslint@*": + version "8.4.10" + resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.4.10.tgz#19731b9685c19ed1552da7052b6f668ed7eb64bb" + integrity sha512-Sl/HOqN8NKPmhWo2VBEPm0nvHnu2LL3v9vKo8MEq0EtbJ4eVzGPl41VNPvn5E1i5poMk4/XD8UriLHpJvEP/Nw== + dependencies: + "@types/estree" "*" + "@types/json-schema" "*" + +"@types/estree@*": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.0.tgz#5fb2e536c1ae9bf35366eed879e827fa59ca41c2" + integrity sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ== + +"@types/estree@^0.0.51": + version "0.0.51" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" + integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== + "@types/graceful-fs@^4.1.2": version "4.1.5" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15" @@ -653,6 +687,11 @@ dependencies: "@types/istanbul-lib-report" "*" +"@types/json-schema@*", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": + version "7.0.11" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" + integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== + "@types/minimist@^1.2.0": version "1.2.2" resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.2.tgz#ee771e2ba4b3dc5b372935d549fd9617bf345b8c" @@ -673,6 +712,11 @@ resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.1.tgz#dfd20e2dc35f027cdd6c1908e80a5ddc7499670e" integrity sha512-ri0UmynRRvZiiUJdiz38MmIblKK+oH30MztdBVR95dv/Ubw6neWSb8u1XpRb72L4qsZOhz+L+z9JD40SJmfWow== +"@types/semver@^7.3.12": + version "7.3.13" + resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.13.tgz#da4bfd73f49bd541d28920ab0e2bf0ee80f71c91" + integrity sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw== + "@types/stack-utils@^2.0.0": version "2.0.1" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c" @@ -690,6 +734,220 @@ dependencies: "@types/yargs-parser" "*" +"@typescript-eslint/eslint-plugin@^5.47.0": + version "5.47.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.47.0.tgz#dadb79df3b0499699b155839fd6792f16897d910" + integrity sha512-AHZtlXAMGkDmyLuLZsRpH3p4G/1iARIwc/T0vIem2YB+xW6pZaXYXzCBnZSF/5fdM97R9QqZWZ+h3iW10XgevQ== + dependencies: + "@typescript-eslint/scope-manager" "5.47.0" + "@typescript-eslint/type-utils" "5.47.0" + "@typescript-eslint/utils" "5.47.0" + debug "^4.3.4" + ignore "^5.2.0" + natural-compare-lite "^1.4.0" + regexpp "^3.2.0" + semver "^7.3.7" + tsutils "^3.21.0" + +"@typescript-eslint/parser@^5.47.0": + version "5.47.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.47.0.tgz#62e83de93499bf4b500528f74bf2e0554e3a6c8d" + integrity sha512-udPU4ckK+R1JWCGdQC4Qa27NtBg7w020ffHqGyAK8pAgOVuNw7YaKXGChk+udh+iiGIJf6/E/0xhVXyPAbsczw== + dependencies: + "@typescript-eslint/scope-manager" "5.47.0" + "@typescript-eslint/types" "5.47.0" + "@typescript-eslint/typescript-estree" "5.47.0" + debug "^4.3.4" + +"@typescript-eslint/scope-manager@5.47.0": + version "5.47.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.47.0.tgz#f58144a6b0ff58b996f92172c488813aee9b09df" + integrity sha512-dvJab4bFf7JVvjPuh3sfBUWsiD73aiftKBpWSfi3sUkysDQ4W8x+ZcFpNp7Kgv0weldhpmMOZBjx1wKN8uWvAw== + dependencies: + "@typescript-eslint/types" "5.47.0" + "@typescript-eslint/visitor-keys" "5.47.0" + +"@typescript-eslint/type-utils@5.47.0": + version "5.47.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.47.0.tgz#2b440979c574e317d3473225ae781f292c99e55d" + integrity sha512-1J+DFFrYoDUXQE1b7QjrNGARZE6uVhBqIvdaXTe5IN+NmEyD68qXR1qX1g2u4voA+nCaelQyG8w30SAOihhEYg== + dependencies: + "@typescript-eslint/typescript-estree" "5.47.0" + "@typescript-eslint/utils" "5.47.0" + debug "^4.3.4" + tsutils "^3.21.0" + +"@typescript-eslint/types@5.47.0": + version "5.47.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.47.0.tgz#67490def406eaa023dbbd8da42ee0d0c9b5229d3" + integrity sha512-eslFG0Qy8wpGzDdYKu58CEr3WLkjwC5Usa6XbuV89ce/yN5RITLe1O8e+WFEuxnfftHiJImkkOBADj58ahRxSg== + +"@typescript-eslint/typescript-estree@5.47.0": + version "5.47.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.47.0.tgz#ed971a11c5c928646d6ba7fc9dfdd6e997649aca" + integrity sha512-LxfKCG4bsRGq60Sqqu+34QT5qT2TEAHvSCCJ321uBWywgE2dS0LKcu5u+3sMGo+Vy9UmLOhdTw5JHzePV/1y4Q== + dependencies: + "@typescript-eslint/types" "5.47.0" + "@typescript-eslint/visitor-keys" "5.47.0" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.3.7" + tsutils "^3.21.0" + +"@typescript-eslint/utils@5.47.0": + version "5.47.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.47.0.tgz#b5005f7d2696769a1fdc1e00897005a25b3a0ec7" + integrity sha512-U9xcc0N7xINrCdGVPwABjbAKqx4GK67xuMV87toI+HUqgXj26m6RBp9UshEXcTrgCkdGYFzgKLt8kxu49RilDw== + dependencies: + "@types/json-schema" "^7.0.9" + "@types/semver" "^7.3.12" + "@typescript-eslint/scope-manager" "5.47.0" + "@typescript-eslint/types" "5.47.0" + "@typescript-eslint/typescript-estree" "5.47.0" + eslint-scope "^5.1.1" + eslint-utils "^3.0.0" + semver "^7.3.7" + +"@typescript-eslint/visitor-keys@5.47.0": + version "5.47.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.47.0.tgz#4aca4efbdf6209c154df1f7599852d571b80bb45" + integrity sha512-ByPi5iMa6QqDXe/GmT/hR6MZtVPi0SqMQPDx15FczCBXJo/7M8T88xReOALAfpBLm+zxpPfmhuEvPb577JRAEg== + dependencies: + "@typescript-eslint/types" "5.47.0" + eslint-visitor-keys "^3.3.0" + +"@webassemblyjs/ast@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7" + integrity sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw== + dependencies: + "@webassemblyjs/helper-numbers" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + +"@webassemblyjs/floating-point-hex-parser@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz#f6c61a705f0fd7a6aecaa4e8198f23d9dc179e4f" + integrity sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ== + +"@webassemblyjs/helper-api-error@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz#1a63192d8788e5c012800ba6a7a46c705288fd16" + integrity sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg== + +"@webassemblyjs/helper-buffer@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz#832a900eb444884cde9a7cad467f81500f5e5ab5" + integrity sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA== + +"@webassemblyjs/helper-numbers@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz#64d81da219fbbba1e3bd1bfc74f6e8c4e10a62ae" + integrity sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ== + dependencies: + "@webassemblyjs/floating-point-hex-parser" "1.11.1" + "@webassemblyjs/helper-api-error" "1.11.1" + "@xtuc/long" "4.2.2" + +"@webassemblyjs/helper-wasm-bytecode@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz#f328241e41e7b199d0b20c18e88429c4433295e1" + integrity sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q== + +"@webassemblyjs/helper-wasm-section@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz#21ee065a7b635f319e738f0dd73bfbda281c097a" + integrity sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-buffer" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/wasm-gen" "1.11.1" + +"@webassemblyjs/ieee754@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz#963929e9bbd05709e7e12243a099180812992614" + integrity sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ== + dependencies: + "@xtuc/ieee754" "^1.2.0" + +"@webassemblyjs/leb128@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.1.tgz#ce814b45574e93d76bae1fb2644ab9cdd9527aa5" + integrity sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw== + dependencies: + "@xtuc/long" "4.2.2" + +"@webassemblyjs/utf8@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.1.tgz#d1f8b764369e7c6e6bae350e854dec9a59f0a3ff" + integrity sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ== + +"@webassemblyjs/wasm-edit@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz#ad206ebf4bf95a058ce9880a8c092c5dec8193d6" + integrity sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-buffer" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/helper-wasm-section" "1.11.1" + "@webassemblyjs/wasm-gen" "1.11.1" + "@webassemblyjs/wasm-opt" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" + "@webassemblyjs/wast-printer" "1.11.1" + +"@webassemblyjs/wasm-gen@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz#86c5ea304849759b7d88c47a32f4f039ae3c8f76" + integrity sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/ieee754" "1.11.1" + "@webassemblyjs/leb128" "1.11.1" + "@webassemblyjs/utf8" "1.11.1" + +"@webassemblyjs/wasm-opt@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz#657b4c2202f4cf3b345f8a4c6461c8c2418985f2" + integrity sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-buffer" "1.11.1" + "@webassemblyjs/wasm-gen" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" + +"@webassemblyjs/wasm-parser@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz#86ca734534f417e9bd3c67c7a1c75d8be41fb199" + integrity sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-api-error" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/ieee754" "1.11.1" + "@webassemblyjs/leb128" "1.11.1" + "@webassemblyjs/utf8" "1.11.1" + +"@webassemblyjs/wast-printer@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz#d0c73beda8eec5426f10ae8ef55cee5e7084c2f0" + integrity sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@xtuc/long" "4.2.2" + +"@xtuc/ieee754@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" + integrity sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA== + +"@xtuc/long@4.2.2": + version "4.2.2" + resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" + integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== + JSONStream@^1.0.4: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" @@ -711,6 +969,11 @@ acorn-globals@^6.0.0: acorn "^7.1.1" acorn-walk "^7.1.1" +acorn-import-assertions@^1.7.6: + version "1.8.0" + resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9" + integrity sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw== + acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" @@ -726,7 +989,7 @@ acorn@^7.1.1: resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== -acorn@^8.2.4, acorn@^8.8.0: +acorn@^8.2.4, acorn@^8.5.0, acorn@^8.7.1, acorn@^8.8.0: version "8.8.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.1.tgz#0a3f9cbecc4ec3bea6f0a80b66ae8dd2da250b73" integrity sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA== @@ -743,7 +1006,12 @@ agent-base@6: dependencies: debug "4" -ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4: +ajv-keywords@^3.5.2: + version "3.5.2" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" + integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== + +ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -809,6 +1077,11 @@ array-ify@^1.0.0: resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece" integrity sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng== +array-union@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" + integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== + arrify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" @@ -934,7 +1207,7 @@ browser-process-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== -browserslist@^4.21.3: +browserslist@^4.14.5, browserslist@^4.21.3: version "4.21.4" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.4.tgz#e7496bbc67b9e39dd0f98565feccdcb0d4ff6987" integrity sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw== @@ -1012,6 +1285,11 @@ char-regex@^1.0.2: resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf" integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw== +chrome-trace-event@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" + integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== + ci-info@^3.2.0: version "3.5.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.5.0.tgz#bfac2a29263de4c829d806b1ab478e35091e171f" @@ -1072,6 +1350,11 @@ combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" +commander@^2.20.0: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + compare-func@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-2.0.0.tgz#fb65e75edbddfd2e568554e8b5b05fff7a51fcb3" @@ -1336,7 +1619,7 @@ dateformat@^3.0.0: resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q== -debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2: +debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== @@ -1396,6 +1679,13 @@ diff-sequences@^27.5.1: resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.5.1.tgz#eaecc0d327fd68c8d9672a1e64ab8dccb2ef5327" integrity sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ== +dir-glob@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" + integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== + dependencies: + path-type "^4.0.0" + doctrine@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" @@ -1448,6 +1738,14 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +enhanced-resolve@^5.10.0: + version "5.12.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz#300e1c90228f5b570c4d35babf263f6da7155634" + integrity sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ== + dependencies: + graceful-fs "^4.2.4" + tapable "^2.2.0" + error-ex@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" @@ -1455,6 +1753,11 @@ error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" +es-module-lexer@^0.9.0: + version "0.9.3" + resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19" + integrity sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ== + escalade@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" @@ -1507,6 +1810,14 @@ eslint-plugin-node@^11.1.0: resolve "^1.10.1" semver "^6.1.0" +eslint-scope@5.1.1, eslint-scope@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" + integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== + dependencies: + esrecurse "^4.3.0" + estraverse "^4.1.1" + eslint-scope@^7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.1.1.tgz#fff34894c2f65e5226d3041ac480b4513a163642" @@ -1617,6 +1928,11 @@ esrecurse@^4.3.0: dependencies: estraverse "^5.2.0" +estraverse@^4.1.1: + version "4.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" + integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== + estraverse@^5.1.0, estraverse@^5.2.0: version "5.3.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" @@ -1627,6 +1943,11 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== +events@^3.2.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" + integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== + execa@^5.0.0: version "5.1.1" resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" @@ -1677,6 +1998,17 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== +fast-glob@^3.2.9: + version "3.2.12" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" + integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + fast-json-stable-stringify@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" @@ -1874,6 +2206,13 @@ gitconfiglocal@^1.0.0: dependencies: ini "^1.3.2" +glob-parent@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + glob-parent@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" @@ -1881,6 +2220,11 @@ glob-parent@^6.0.2: dependencies: is-glob "^4.0.3" +glob-to-regexp@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" + integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== + glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" @@ -1905,7 +2249,19 @@ globals@^13.15.0: dependencies: type-fest "^0.20.2" -graceful-fs@^4.1.2, graceful-fs@^4.2.9: +globby@^11.1.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" + integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== + dependencies: + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.2.9" + ignore "^5.2.0" + merge2 "^1.4.1" + slash "^3.0.0" + +graceful-fs@^4.1.2, graceful-fs@^4.2.4, graceful-fs@^4.2.9: version "4.2.10" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== @@ -2100,7 +2456,7 @@ is-generator-fn@^2.0.0: resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.1.0.tgz#7d140adc389aaf3011a8f2a2a4cfa6faadffb118" integrity sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ== -is-glob@^4.0.0, is-glob@^4.0.3: +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== @@ -2593,7 +2949,7 @@ jest-watcher@^27.5.1: jest-util "^27.5.1" string-length "^4.0.1" -jest-worker@^27.5.1: +jest-worker@^27.4.5, jest-worker@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0" integrity sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg== @@ -2684,7 +3040,7 @@ json-parse-better-errors@^1.0.1: resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== -json-parse-even-better-errors@^2.3.0: +json-parse-even-better-errors@^2.3.0, json-parse-even-better-errors@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== @@ -2780,6 +3136,11 @@ load-json-file@^4.0.0: pify "^3.0.0" strip-bom "^3.0.0" +loader-runner@^4.2.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1" + integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg== + locate-path@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" @@ -2883,6 +3244,11 @@ merge-stream@^2.0.0: resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== +merge2@^1.3.0, merge2@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== + micromatch@^4.0.4: version "4.0.5" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" @@ -2896,7 +3262,7 @@ mime-db@1.52.0: resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== -mime-types@^2.1.12, mime-types@~2.1.19: +mime-types@^2.1.12, mime-types@^2.1.27, mime-types@~2.1.19: version "2.1.35" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== @@ -2944,12 +3310,17 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== +natural-compare-lite@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz#17b09581988979fddafe0201e931ba933c96cbb4" + integrity sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g== + natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== -neo-async@^2.6.0: +neo-async@^2.6.0, neo-async@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== @@ -3165,6 +3536,11 @@ path-type@^3.0.0: dependencies: pify "^3.0.0" +path-type@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" + integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== + performance-now@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" @@ -3274,6 +3650,13 @@ quick-lru@^4.0.1: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" integrity sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g== +randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + react-is@^17.0.1: version "17.0.2" resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" @@ -3436,7 +3819,7 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" -safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@~5.2.0: +safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.2, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -3458,6 +3841,15 @@ saxes@^5.0.1: dependencies: xmlchars "^2.2.0" +schema-utils@^3.1.0, schema-utils@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281" + integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw== + dependencies: + "@types/json-schema" "^7.0.8" + ajv "^6.12.5" + ajv-keywords "^3.5.2" + "semver@2 || 3 || 4 || 5": version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" @@ -3468,13 +3860,20 @@ semver@^6.0.0, semver@^6.1.0, semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^7.1.1, semver@^7.3.2, semver@^7.3.4: +semver@^7.1.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.7: version "7.3.8" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== dependencies: lru-cache "^6.0.0" +serialize-javascript@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" + integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== + dependencies: + randombytes "^2.1.0" + shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" @@ -3502,7 +3901,7 @@ slash@^3.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== -source-map-support@^0.5.6: +source-map-support@^0.5.6, source-map-support@~0.5.20: version "0.5.21" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== @@ -3716,6 +4115,11 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== +tapable@^2.1.1, tapable@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" + integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== + terminal-link@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/terminal-link/-/terminal-link-2.1.1.tgz#14a64a27ab3c0df933ea546fba55f2d078edc994" @@ -3724,6 +4128,27 @@ terminal-link@^2.0.0: ansi-escapes "^4.2.1" supports-hyperlinks "^2.0.0" +terser-webpack-plugin@^5.1.3: + version "5.3.6" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.6.tgz#5590aec31aa3c6f771ce1b1acca60639eab3195c" + integrity sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ== + dependencies: + "@jridgewell/trace-mapping" "^0.3.14" + jest-worker "^27.4.5" + schema-utils "^3.1.1" + serialize-javascript "^6.0.0" + terser "^5.14.1" + +terser@^5.14.1: + version "5.16.1" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.16.1.tgz#5af3bc3d0f24241c7fb2024199d5c461a1075880" + integrity sha512-xvQfyfA1ayT0qdK47zskQgRZeWLoOQ8JQ6mIgRGVNwZKdQMU+5FkCBjmv4QjcrTzyZquRw2FVtlJSRUmMKQslw== + dependencies: + "@jridgewell/source-map" "^0.3.2" + acorn "^8.5.0" + commander "^2.20.0" + source-map-support "~0.5.20" + test-exclude@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e" @@ -3815,6 +4240,18 @@ trim-newlines@^3.0.0: resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144" integrity sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw== +tslib@^1.8.1: + version "1.14.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" + integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== + +tsutils@^3.21.0: + version "3.21.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" + integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA== + dependencies: + tslib "^1.8.1" + tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" @@ -3883,6 +4320,11 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== +typescript@^4.9.4: + version "4.9.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.4.tgz#a2a3d2756c079abda241d75f149df9d561091e78" + integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg== + uglify-js@^3.1.4: version "3.17.4" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" @@ -3973,6 +4415,14 @@ walker@^1.0.7: dependencies: makeerror "1.0.12" +watchpack@^2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.0.tgz#fa33032374962c78113f93c7f2fb4c54c9862a5d" + integrity sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg== + dependencies: + glob-to-regexp "^0.4.1" + graceful-fs "^4.1.2" + webidl-conversions@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff" @@ -3983,6 +4433,41 @@ webidl-conversions@^6.1.0: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-6.1.0.tgz#9111b4d7ea80acd40f5270d666621afa78b69514" integrity sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w== +webpack-sources@^3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" + integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== + +webpack@^5.64.4: + version "5.75.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.75.0.tgz#1e440468647b2505860e94c9ff3e44d5b582c152" + integrity sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ== + dependencies: + "@types/eslint-scope" "^3.7.3" + "@types/estree" "^0.0.51" + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/wasm-edit" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" + acorn "^8.7.1" + acorn-import-assertions "^1.7.6" + browserslist "^4.14.5" + chrome-trace-event "^1.0.2" + enhanced-resolve "^5.10.0" + es-module-lexer "^0.9.0" + eslint-scope "5.1.1" + events "^3.2.0" + glob-to-regexp "^0.4.1" + graceful-fs "^4.2.9" + json-parse-even-better-errors "^2.3.1" + loader-runner "^4.2.0" + mime-types "^2.1.27" + neo-async "^2.6.2" + schema-utils "^3.1.0" + tapable "^2.1.1" + terser-webpack-plugin "^5.1.3" + watchpack "^2.4.0" + webpack-sources "^3.2.3" + whatwg-encoding@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz#5abacf777c32166a51d085d6b4f3e7d27113ddb0" From abceae43706b83d090363b6a6c00fcafc7630af5 Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Thu, 22 Dec 2022 23:46:11 +0000 Subject: [PATCH 02/13] update tests and fix final ts errors --- lib/interpolateName.ts | 17 +++++++++++++---- lib/urlToRequest.ts | 6 +++--- test/getHashDigest.test.js | 2 +- test/interpolateName.test.js | 2 +- test/isUrlRequest.test.js | 2 +- test/urlToRequest.test.js | 2 +- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/interpolateName.ts b/lib/interpolateName.ts index e4d6458..b686e7a 100644 --- a/lib/interpolateName.ts +++ b/lib/interpolateName.ts @@ -2,11 +2,17 @@ import type { LoaderContext } from "webpack"; import path from "path"; import getHashDigest from './getHashDigest'; -export default function interpolateName(loaderContext: LoaderContext<{}>, name: string, options = {}) { +interface IInterpolateNameOptions { + content?: Buffer; + context?: string; + regExp?: string; +} + +export default function interpolateName(loaderContext: LoaderContext<{}>, name: string | ((resourcePath: string, resourceQuery?: string) => string), options: IInterpolateNameOptions = {}) { let filename; - const hasQuery = - loaderContext.resourceQuery && loaderContext.resourceQuery.length > 1; + const hasQuery: boolean = + (loaderContext.resourceQuery && loaderContext.resourceQuery.length > 1) as boolean; if (typeof name === "function") { filename = name( @@ -98,9 +104,12 @@ export default function interpolateName(loaderContext: LoaderContext<{}>, name: } if ( + // @ts-ignore typeof loaderContext.options === "object" && + // @ts-ignore typeof loaderContext.options.customInterpolateName === "function" ) { + // @ts-ignore url = loaderContext.options.customInterpolateName.call( loaderContext, url, @@ -110,4 +119,4 @@ export default function interpolateName(loaderContext: LoaderContext<{}>, name: } return url; -} \ No newline at end of file +} diff --git a/lib/urlToRequest.ts b/lib/urlToRequest.ts index 4cd5502..ea8fd5d 100644 --- a/lib/urlToRequest.ts +++ b/lib/urlToRequest.ts @@ -20,7 +20,7 @@ export default function urlToRequest(url: string, root?: string | boolean): stri // 1. root is a string: root is prefixed to the url case "string": // special case: `~` roots convert to module request - if (MODULE_REQUEST_REGEX.test(root)) { + if (MODULE_REQUEST_REGEXP.test(root)) { request = root.replace(/([^~/])$/, "$1/") + url.slice(1); } else { request = root + url; @@ -49,8 +49,8 @@ export default function urlToRequest(url: string, root?: string | boolean): stri } // A `~` makes the url an module - if (MODULE_REQUEST_REGEX.test(request)) { - request = request.replace(MODULE_REQUEST_REGEX, ""); + if (MODULE_REQUEST_REGEXP.test(request)) { + request = request.replace(MODULE_REQUEST_REGEXP, ""); } return request; diff --git a/test/getHashDigest.test.js b/test/getHashDigest.test.js index e993f11..912ec63 100644 --- a/test/getHashDigest.test.js +++ b/test/getHashDigest.test.js @@ -1,6 +1,6 @@ "use strict"; -const loaderUtils = require("../"); +const loaderUtils = require("../dist"); describe("getHashDigest()", () => { [ diff --git a/test/interpolateName.test.js b/test/interpolateName.test.js index d84bf8e..fa08738 100644 --- a/test/interpolateName.test.js +++ b/test/interpolateName.test.js @@ -1,6 +1,6 @@ "use strict"; -const loaderUtils = require("../"); +const loaderUtils = require("../dist"); describe("interpolateName()", () => { function run(tests) { diff --git a/test/isUrlRequest.test.js b/test/isUrlRequest.test.js index 56b8622..b71fa68 100644 --- a/test/isUrlRequest.test.js +++ b/test/isUrlRequest.test.js @@ -1,6 +1,6 @@ "use strict"; -const loaderUtils = require("../"); +const loaderUtils = require("../dist"); function ExpectedError(regex) { this.regex = regex; diff --git a/test/urlToRequest.test.js b/test/urlToRequest.test.js index 11308f8..50c6e3d 100644 --- a/test/urlToRequest.test.js +++ b/test/urlToRequest.test.js @@ -1,6 +1,6 @@ "use strict"; -const loaderUtils = require("../"); +const loaderUtils = require("../dist"); function ExpectedError(regex) { this.regex = regex; From fd6ceac02a104f403a8e7939e102acb9ade0be63 Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Fri, 23 Dec 2022 00:09:22 +0000 Subject: [PATCH 03/13] fix dynamic requires using .default for es module interop --- lib/getHashDigest.ts | 12 ++++++------ lib/interpolateName.ts | 4 +++- package.json | 2 +- test/getHashDigest.test.js | 2 +- test/interpolateName.test.js | 2 +- test/isUrlRequest.test.js | 2 +- test/urlToRequest.test.js | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/getHashDigest.ts b/lib/getHashDigest.ts index ce271be..9b68d39 100644 --- a/lib/getHashDigest.ts +++ b/lib/getHashDigest.ts @@ -71,20 +71,20 @@ export default function getHashDigest(buffer: Buffer, algorithm: string | "xxhas if (algorithm === "xxhash64") { if (createXXHash64 === undefined) { - createXXHash64 = require("./hash/xxhash64"); + createXXHash64 = require("./hash/xxhash64").default; if (BatchedHash === undefined) { - BatchedHash = require("./hash/BatchedHash"); + BatchedHash = require("./hash/BatchedHash").default; } } hash = new BatchedHash(createXXHash64() as unknown as Hash); } else if (algorithm === "md4") { if (createMd4 === undefined) { - createMd4 = require("./hash/md4"); + createMd4 = require("./hash/md4").default; if (BatchedHash === undefined) { - BatchedHash = require("./hash/BatchedHash"); + BatchedHash = require("./hash/BatchedHash").default; } } @@ -94,7 +94,7 @@ export default function getHashDigest(buffer: Buffer, algorithm: string | "xxhas crypto = require("crypto"); if (BulkUpdateDecorator === undefined) { - BulkUpdateDecorator = require("./hash/BulkUpdateDecorator"); + BulkUpdateDecorator = require("./hash/BulkUpdateDecorator").default; } } @@ -104,7 +104,7 @@ export default function getHashDigest(buffer: Buffer, algorithm: string | "xxhas crypto = require("crypto"); if (BulkUpdateDecorator === undefined) { - BulkUpdateDecorator = require("./hash/BulkUpdateDecorator"); + BulkUpdateDecorator = require("./hash/BulkUpdateDecorator").default; } } diff --git a/lib/interpolateName.ts b/lib/interpolateName.ts index b686e7a..824b1b0 100644 --- a/lib/interpolateName.ts +++ b/lib/interpolateName.ts @@ -104,7 +104,9 @@ export default function interpolateName(loaderContext: LoaderContext<{}>, name: } if ( - // @ts-ignore + // @ts-ignore LoaderContext doesn't even have options defined on it? + // If we chagned this to be `loaderContext.getOptions()` it would still not have + // the customInterpolateName function defined on it. typeof loaderContext.options === "object" && // @ts-ignore typeof loaderContext.options.customInterpolateName === "function" diff --git a/package.json b/package.json index 123df7b..7e577ad 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "typescript": "^4.9.4", "webpack": "^5.64.4" }, - "main": "lib/index.js", + "main": "dist/index.js", "files": [ "lib" ] diff --git a/test/getHashDigest.test.js b/test/getHashDigest.test.js index 912ec63..e993f11 100644 --- a/test/getHashDigest.test.js +++ b/test/getHashDigest.test.js @@ -1,6 +1,6 @@ "use strict"; -const loaderUtils = require("../dist"); +const loaderUtils = require("../"); describe("getHashDigest()", () => { [ diff --git a/test/interpolateName.test.js b/test/interpolateName.test.js index fa08738..d84bf8e 100644 --- a/test/interpolateName.test.js +++ b/test/interpolateName.test.js @@ -1,6 +1,6 @@ "use strict"; -const loaderUtils = require("../dist"); +const loaderUtils = require("../"); describe("interpolateName()", () => { function run(tests) { diff --git a/test/isUrlRequest.test.js b/test/isUrlRequest.test.js index b71fa68..56b8622 100644 --- a/test/isUrlRequest.test.js +++ b/test/isUrlRequest.test.js @@ -1,6 +1,6 @@ "use strict"; -const loaderUtils = require("../dist"); +const loaderUtils = require("../"); function ExpectedError(regex) { this.regex = regex; diff --git a/test/urlToRequest.test.js b/test/urlToRequest.test.js index 50c6e3d..11308f8 100644 --- a/test/urlToRequest.test.js +++ b/test/urlToRequest.test.js @@ -1,6 +1,6 @@ "use strict"; -const loaderUtils = require("../dist"); +const loaderUtils = require("../"); function ExpectedError(regex) { this.regex = regex; From f2db90e2a2cbe20f6ccc8f3f313d90a2eff49f25 Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Fri, 23 Dec 2022 00:39:39 +0000 Subject: [PATCH 04/13] add some eslint rules, prettify, and prettier script locally --- .eslintrc.json | 13 +- .prettierignore | 2 +- lib/getHashDigest.ts | 52 +++++-- lib/hash/BatchedHash.ts | 5 +- lib/hash/BulkUpdateDecorator.ts | 10 +- lib/hash/md4.ts | 2 +- lib/hash/wasm-hash.ts | 17 ++- lib/hash/xxhash64.ts | 2 +- lib/index.ts | 7 +- lib/interpolateName.ts | 15 +- lib/isUrlRequest.ts | 17 ++- lib/urlToRequest.ts | 17 ++- package.json | 3 +- tsconfig.json | 4 +- yarn.lock | 261 +++++++++++++++++--------------- 15 files changed, 247 insertions(+), 180 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 4e9f23e..c5656e9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,11 @@ { "root": true, "plugins": ["node", "@typescript-eslint"], - "extends": ["eslint:recommended", "plugin:node/recommended", "plugin:@typescript-eslint/recommended"], + "extends": [ + "eslint:recommended", + "plugin:node/recommended", + "plugin:@typescript-eslint/recommended" + ], "env": { "node": true }, @@ -20,6 +24,11 @@ "prefer-const": "error", "prefer-arrow-callback": "error", "object-shorthand": "error", - "es-syntax": "false" + "node/no-unsupported-features/es-syntax": 0, + "node/no-missing-require": 0, + "node/no-missing-import": 0, + "node/no-unpublished-import": 0, + "@typescript-eslint/no-var-requires": 0, + "@typescript-eslint/no-explicit-any": 0 } } diff --git a/.prettierignore b/.prettierignore index f8f1e31..2350e2f 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,4 +2,4 @@ /dist /node_modules /test/fixtures -CHANGELOG.md \ No newline at end of file +CHANGELOG.md diff --git a/lib/getHashDigest.ts b/lib/getHashDigest.ts index 9b68d39..5aedd0d 100644 --- a/lib/getHashDigest.ts +++ b/lib/getHashDigest.ts @@ -1,4 +1,4 @@ -import {Hash} from 'crypto'; +import { Hash } from "crypto"; const baseEncodeTables = { 26: "abcdefghijklmnopqrstuvwxyz", @@ -11,7 +11,15 @@ const baseEncodeTables = { 64: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_", }; -type DigestTypes = "base26" | "base32" | "base36" | "base49" | "base52" | "base58" | "base62" | "base64"; +type DigestTypes = + | "base26" + | "base32" + | "base36" + | "base49" + | "base52" + | "base58" + | "base62" + | "base64"; type BaseEncodings = 26 | 32 | 36 | 49 | 52 | 58 | 62 | 64; /** @@ -29,8 +37,12 @@ function divmod32(uint32Array: Uint32Array, divisor: number): number { return carry; } -function encodeBufferToBase(buffer: Buffer, base: BaseEncodings | number, length: number) { - const encodeTable = baseEncodeTables[(base as keyof typeof baseEncodeTables)]; +function encodeBufferToBase( + buffer: Buffer, + base: BaseEncodings | number, + length: number +) { + const encodeTable = baseEncodeTables[base as keyof typeof baseEncodeTables]; if (!encodeTable) { throw new Error("Unknown encoding base" + base); @@ -57,13 +69,18 @@ function encodeBufferToBase(buffer: Buffer, base: BaseEncodings | number, length return output; } -let crypto: typeof import('crypto') -let createXXHash64: typeof import('./hash/xxhash64').default; -let createMd4: typeof import('./hash/md4').default; -let BatchedHash: typeof import('./hash/BatchedHash').default; -let BulkUpdateDecorator: typeof import('./hash/BulkUpdateDecorator').default; - -export default function getHashDigest(buffer: Buffer, algorithm: string | "xxhash64" | "md4" | "native-md4", digestType: DigestTypes | string, maxLength: number) { +let crypto: typeof import("crypto"); +let createXXHash64: typeof import("./hash/xxhash64").default; +let createMd4: typeof import("./hash/md4").default; +let BatchedHash: typeof import("./hash/BatchedHash").default; +let BulkUpdateDecorator: typeof import("./hash/BulkUpdateDecorator").default; + +export default function getHashDigest( + buffer: Buffer, + algorithm: string | "xxhash64" | "md4" | "native-md4", + digestType: DigestTypes | string, + maxLength: number +) { algorithm = algorithm || "xxhash64"; maxLength = maxLength || 9999; @@ -125,10 +142,17 @@ export default function getHashDigest(buffer: Buffer, algorithm: string | "xxhas digestType === "base58" || digestType === "base62" ) { - const digestTypeToDigest: number = digestType.substr(4) as unknown as number; - - return encodeBufferToBase(hash.digest() as Buffer, digestTypeToDigest, maxLength); + const digestTypeToDigest: number = digestType.substr( + 4 + ) as unknown as number; + + return encodeBufferToBase( + hash.digest() as Buffer, + digestTypeToDigest, + maxLength + ); } else { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore return hash.digest(digestType || "hex").substr(0, maxLength); } diff --git a/lib/hash/BatchedHash.ts b/lib/hash/BatchedHash.ts index 275946b..91139d4 100644 --- a/lib/hash/BatchedHash.ts +++ b/lib/hash/BatchedHash.ts @@ -1,5 +1,5 @@ import type { Hash, Encoding, BinaryToTextEncoding } from "crypto"; -import { MAX_SHORT_STRING } from './wasm-hash' +import { MAX_SHORT_STRING } from "./wasm-hash"; export default class BatchedHash { public string?: string; @@ -33,7 +33,7 @@ export default class BatchedHash { if (this.encoding !== undefined) { this.hash.update(this.string, this.encoding); } else { - this.hash.update(this.string) + this.hash.update(this.string); } this.string = undefined; @@ -73,7 +73,6 @@ export default class BatchedHash { } else { this.hash.update(this.string); } - } if (encoding !== undefined) { return this.hash.digest(encoding); diff --git a/lib/hash/BulkUpdateDecorator.ts b/lib/hash/BulkUpdateDecorator.ts index 920d333..4de2f4c 100644 --- a/lib/hash/BulkUpdateDecorator.ts +++ b/lib/hash/BulkUpdateDecorator.ts @@ -1,12 +1,11 @@ import type { Hash, Encoding, BinaryToTextEncoding } from "crypto"; type HashOrFactory = Hash | (() => Hash); -const BULK_SIZE: number = 2000; +const BULK_SIZE = 2000; // We are using an object instead of a Map as this will stay static during the runtime // so access to it can be optimized by v8 -const digestCaches: {[key: string]: any} = {}; - +const digestCaches: { [key: string]: any } = {}; export default class BulkUpdateDecorator { /** @@ -14,7 +13,7 @@ export default class BulkUpdateDecorator { * @param {string=} hashKey key for caching */ hash?: Hash; - hashFactory?: (() => Hash); + hashFactory?: () => Hash; hashKey: string; buffer: string; @@ -45,6 +44,7 @@ export default class BulkUpdateDecorator { data.length > BULK_SIZE ) { if (this.hash === undefined) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.hash = this.hashFactory!(); } @@ -63,6 +63,7 @@ export default class BulkUpdateDecorator { if (this.buffer.length > BULK_SIZE) { if (this.hash === undefined) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.hash = this.hashFactory!(); } @@ -101,6 +102,7 @@ export default class BulkUpdateDecorator { return cacheEntry; } + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.hash = this.hashFactory!(); } diff --git a/lib/hash/md4.ts b/lib/hash/md4.ts index 09c3ffe..c39ebea 100644 --- a/lib/hash/md4.ts +++ b/lib/hash/md4.ts @@ -3,7 +3,7 @@ Author Tobias Koppers @sokra */ -import { create } from './wasm-hash'; +import { create } from "./wasm-hash"; //#region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1 const md4 = new WebAssembly.Module( diff --git a/lib/hash/wasm-hash.ts b/lib/hash/wasm-hash.ts index a513334..d846515 100644 --- a/lib/hash/wasm-hash.ts +++ b/lib/hash/wasm-hash.ts @@ -1,4 +1,4 @@ -import { Hash, BinaryToTextEncoding } from "crypto"; +import { BinaryToTextEncoding } from "crypto"; /* MIT License http://www.opensource.org/licenses/mit-license.php @@ -25,7 +25,12 @@ export class WasmHash { chunkSize: number; digestSize: number; - constructor(instance: WebAssembly.Instance, instancesPool: WebAssembly.Instance[], chunkSize: number, digestSize: number) { + constructor( + instance: WebAssembly.Instance, + instancesPool: WebAssembly.Instance[], + chunkSize: number, + digestSize: number + ) { const exports = instance.exports as any; exports.init(); @@ -189,7 +194,12 @@ export class WasmHash { } } -export const create = (wasmModule: WebAssembly.Module, instancesPool: WasmHash[], chunkSize: number, digestSize: number) => { +export const create = ( + wasmModule: WebAssembly.Module, + instancesPool: WasmHash[], + chunkSize: number, + digestSize: number +) => { if (instancesPool.length > 0) { const old = instancesPool.pop(); @@ -207,4 +217,3 @@ export const create = (wasmModule: WebAssembly.Module, instancesPool: WasmHash[] ); } }; - diff --git a/lib/hash/xxhash64.ts b/lib/hash/xxhash64.ts index ec65404..38b964e 100644 --- a/lib/hash/xxhash64.ts +++ b/lib/hash/xxhash64.ts @@ -2,7 +2,7 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -import { create } from './wasm-hash'; +import { create } from "./wasm-hash"; //#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1 const xxhash64 = new WebAssembly.Module( diff --git a/lib/index.ts b/lib/index.ts index 656ca30..f7629c3 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -3,9 +3,4 @@ import urlToRequest from "./urlToRequest"; import getHashDigest from "./getHashDigest"; import interpolateName from "./interpolateName"; -export { - urlToRequest, - getHashDigest, - interpolateName, - isUrlRequest -} +export { urlToRequest, getHashDigest, interpolateName, isUrlRequest }; diff --git a/lib/interpolateName.ts b/lib/interpolateName.ts index 824b1b0..0179a8c 100644 --- a/lib/interpolateName.ts +++ b/lib/interpolateName.ts @@ -1,6 +1,6 @@ import type { LoaderContext } from "webpack"; import path from "path"; -import getHashDigest from './getHashDigest'; +import getHashDigest from "./getHashDigest"; interface IInterpolateNameOptions { content?: Buffer; @@ -8,11 +8,15 @@ interface IInterpolateNameOptions { regExp?: string; } -export default function interpolateName(loaderContext: LoaderContext<{}>, name: string | ((resourcePath: string, resourceQuery?: string) => string), options: IInterpolateNameOptions = {}) { +export default function interpolateName( + loaderContext: LoaderContext, + name: string | ((resourcePath: string, resourceQuery?: string) => string), + options: IInterpolateNameOptions = {} +) { let filename; - const hasQuery: boolean = - (loaderContext.resourceQuery && loaderContext.resourceQuery.length > 1) as boolean; + const hasQuery: boolean = (loaderContext.resourceQuery && + loaderContext.resourceQuery.length > 1) as boolean; if (typeof name === "function") { filename = name( @@ -104,13 +108,16 @@ export default function interpolateName(loaderContext: LoaderContext<{}>, name: } if ( + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore LoaderContext doesn't even have options defined on it? // If we chagned this to be `loaderContext.getOptions()` it would still not have // the customInterpolateName function defined on it. typeof loaderContext.options === "object" && + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore typeof loaderContext.options.customInterpolateName === "function" ) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore url = loaderContext.options.customInterpolateName.call( loaderContext, diff --git a/lib/isUrlRequest.ts b/lib/isUrlRequest.ts index 7a5a715..0e4a2f7 100644 --- a/lib/isUrlRequest.ts +++ b/lib/isUrlRequest.ts @@ -1,9 +1,9 @@ -import path from 'path'; +import path from "path"; -const DATA_URI_REGEXP: RegExp = /^data:/i; -const ABOSLUTE_URL_NON_WINDOWS_PATHLIKE_REGEXP: RegExp = /^[a-z][a-z0-9+.-]*:/i; -const POROTCOL_RELATIVE_REGEXP: RegExp = /^\/\//i; -const URL_FOR_TEMPLATE_REGEXP: RegExp = /^#/i; +const DATA_URI_REGEXP = /^data:/i; +const ABOSLUTE_URL_NON_WINDOWS_PATHLIKE_REGEXP = /^[a-z][a-z0-9+.-]*:/i; +const POROTCOL_RELATIVE_REGEXP = /^\/\//i; +const URL_FOR_TEMPLATE_REGEXP = /^#/i; export default function isUrlRequest(url: string): boolean { // An URL is not an request if @@ -14,7 +14,10 @@ export default function isUrlRequest(url: string): boolean { } // 2. It's an absolute url and it is not `windows` path like `C:\dir\file` - if (ABOSLUTE_URL_NON_WINDOWS_PATHLIKE_REGEXP.test(url) && !path.win32.isAbsolute(url)) { + if ( + ABOSLUTE_URL_NON_WINDOWS_PATHLIKE_REGEXP.test(url) && + !path.win32.isAbsolute(url) + ) { return false; } @@ -30,5 +33,3 @@ export default function isUrlRequest(url: string): boolean { return true; } - - diff --git a/lib/urlToRequest.ts b/lib/urlToRequest.ts index ea8fd5d..fc2a462 100644 --- a/lib/urlToRequest.ts +++ b/lib/urlToRequest.ts @@ -1,9 +1,12 @@ // we can't use path.win32.isAbsolute because it also matches paths starting with a forward slash -const NATIVE_WIN_32_PATH_REGEXP: RegExp = /^[A-Z]:[/\\]|^\\\\/i; -const MODULE_REQUEST_REGEXP: RegExp = /^[^?]*~/; -const ROOT_RELATIVE_URL_REGEXP: RegExp = /^\//; +const NATIVE_WIN_32_PATH_REGEXP = /^[A-Z]:[/\\]|^\\\\/i; +const MODULE_REQUEST_REGEXP = /^[^?]*~/; +const ROOT_RELATIVE_URL_REGEXP = /^\//; -export default function urlToRequest(url: string, root?: string | boolean): string { +export default function urlToRequest( + url: string, + root?: string | boolean +): string { // Do not rewrite an empty url if (url === "") { return ""; @@ -14,7 +17,11 @@ export default function urlToRequest(url: string, root?: string | boolean): stri if (NATIVE_WIN_32_PATH_REGEXP.test(url)) { // absolute windows path, keep it request = url; - } else if (root !== undefined && root !== false && ROOT_RELATIVE_URL_REGEXP.test(url)) { + } else if ( + root !== undefined && + root !== false && + ROOT_RELATIVE_URL_REGEXP.test(url) + ) { // if root is set and the url is root-relative switch (typeof root) { // 1. root is a string: root is prefixed to the url diff --git a/package.json b/package.json index 7e577ad..26aa9e9 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "description": "utils for webpack loaders", "dependencies": {}, "scripts": { - "lint": "prettier --list-different . && eslint .", + "lint": "prettier --list-different . && eslint ./lib", + "pretty": "prettier --write .", "build": "tsc", "pretest": "yarn lint", "test": "jest", diff --git a/tsconfig.json b/tsconfig.json index 5ac0456..4173668 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "outDir": "dist", "strict": true, "types": ["node"], - "esModuleInterop": true, + "esModuleInterop": true }, - "include": ["lib/**/*.ts"], + "include": ["lib/**/*.ts"] } diff --git a/yarn.lock b/yarn.lock index c1191a1..e08e909 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17,49 +17,50 @@ dependencies: "@babel/highlight" "^7.18.6" -"@babel/compat-data@^7.20.0": - version "7.20.1" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.1.tgz#f2e6ef7790d8c8dbf03d379502dcc246dcce0b30" - integrity sha512-EWZ4mE2diW3QALKvDMiXnbZpRvlj+nayZ112nK93SnhqOtpdsbVD4W+2tEoT3YNBAG9RBR0ISY758ZkOgsn6pQ== +"@babel/compat-data@^7.20.5": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.5.tgz#86f172690b093373a933223b4745deeb6049e733" + integrity sha512-KZXo2t10+/jxmkhNXc7pZTqRvSOIvVv/+lJwHS+B2rErwOyjuVRh60yVpb7liQ1U5t7lLJ1bz+t8tSypUZdm0g== "@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.7.2", "@babel/core@^7.8.0": - version "7.20.2" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.2.tgz#8dc9b1620a673f92d3624bd926dc49a52cf25b92" - integrity sha512-w7DbG8DtMrJcFOi4VrLm+8QM4az8Mo+PuLBKLp2zrYRCow8W/f9xiXm5sN53C8HksCyDQwCKha9JiDoIyPjT2g== + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.7.tgz#37072f951bd4d28315445f66e0ec9f6ae0c8c35f" + integrity sha512-t1ZjCluspe5DW24bn2Rr1CDb2v9rn/hROtg9a2tmd0+QYf4bsloYfLQzjG4qHPNMhWtKdGC33R5AxGR2Af2cBw== dependencies: "@ampproject/remapping" "^2.1.0" "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.20.2" - "@babel/helper-compilation-targets" "^7.20.0" - "@babel/helper-module-transforms" "^7.20.2" - "@babel/helpers" "^7.20.1" - "@babel/parser" "^7.20.2" - "@babel/template" "^7.18.10" - "@babel/traverse" "^7.20.1" - "@babel/types" "^7.20.2" + "@babel/generator" "^7.20.7" + "@babel/helper-compilation-targets" "^7.20.7" + "@babel/helper-module-transforms" "^7.20.7" + "@babel/helpers" "^7.20.7" + "@babel/parser" "^7.20.7" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.20.7" + "@babel/types" "^7.20.7" convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.2" json5 "^2.2.1" semver "^6.3.0" -"@babel/generator@^7.20.1", "@babel/generator@^7.20.2", "@babel/generator@^7.7.2": - version "7.20.4" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.20.4.tgz#4d9f8f0c30be75fd90a0562099a26e5839602ab8" - integrity sha512-luCf7yk/cm7yab6CAW1aiFnmEfBJplb/JojV56MYEK7ziWfGmFlTfmL9Ehwfy4gFhbjBfWO1wj7/TuSbVNEEtA== +"@babel/generator@^7.20.7", "@babel/generator@^7.7.2": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.20.7.tgz#f8ef57c8242665c5929fe2e8d82ba75460187b4a" + integrity sha512-7wqMOJq8doJMZmP4ApXTzLxSr7+oO2jroJURrVEp6XShrQUObV8Tq/D0NCcoYg2uHqUrjzO0zwBjoYzelxK+sw== dependencies: - "@babel/types" "^7.20.2" + "@babel/types" "^7.20.7" "@jridgewell/gen-mapping" "^0.3.2" jsesc "^2.5.1" -"@babel/helper-compilation-targets@^7.20.0": - version "7.20.0" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.0.tgz#6bf5374d424e1b3922822f1d9bdaa43b1a139d0a" - integrity sha512-0jp//vDGp9e8hZzBc6N/KwA5ZK3Wsm/pfm4CrY7vzegkVxc65SgSn6wYOnwHe9Js9HRQ1YTCKLGPzDtaS3RoLQ== +"@babel/helper-compilation-targets@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.7.tgz#a6cd33e93629f5eb473b021aac05df62c4cd09bb" + integrity sha512-4tGORmfQcrc+bvrjb5y3dG9Mx1IOZjsHqQVUz7XCNHO+iTmqxWnVg3KRygjGmpRLJGdQSKuvFinbIb0CnZwHAQ== dependencies: - "@babel/compat-data" "^7.20.0" + "@babel/compat-data" "^7.20.5" "@babel/helper-validator-option" "^7.18.6" browserslist "^4.21.3" + lru-cache "^5.1.1" semver "^6.3.0" "@babel/helper-environment-visitor@^7.18.9": @@ -89,19 +90,19 @@ dependencies: "@babel/types" "^7.18.6" -"@babel/helper-module-transforms@^7.20.2": - version "7.20.2" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.2.tgz#ac53da669501edd37e658602a21ba14c08748712" - integrity sha512-zvBKyJXRbmK07XhMuujYoJ48B5yvvmM6+wcpv6Ivj4Yg6qO7NOZOSnvZN9CRl1zz1Z4cKf8YejmCMh8clOoOeA== +"@babel/helper-module-transforms@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.7.tgz#7a6c9a1155bef55e914af574153069c9d9470c43" + integrity sha512-FNdu7r67fqMUSVuQpFQGE6BPdhJIhitoxhGzDbAXNcA07uoVG37fOiMk3OSV8rEICuyG6t8LGkd9EE64qIEoIA== dependencies: "@babel/helper-environment-visitor" "^7.18.9" "@babel/helper-module-imports" "^7.18.6" "@babel/helper-simple-access" "^7.20.2" "@babel/helper-split-export-declaration" "^7.18.6" "@babel/helper-validator-identifier" "^7.19.1" - "@babel/template" "^7.18.10" - "@babel/traverse" "^7.20.1" - "@babel/types" "^7.20.2" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.20.7" + "@babel/types" "^7.20.7" "@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.19.0", "@babel/helper-plugin-utils@^7.8.0": version "7.20.2" @@ -137,14 +138,14 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz#bf0d2b5a509b1f336099e4ff36e1a63aa5db4db8" integrity sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw== -"@babel/helpers@^7.20.1": - version "7.20.1" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.20.1.tgz#2ab7a0fcb0a03b5bf76629196ed63c2d7311f4c9" - integrity sha512-J77mUVaDTUJFZ5BpP6mMn6OIl3rEWymk2ZxDBQJUG3P+PbmyMcF3bYWvz0ma69Af1oobDqT/iAsvzhB58xhQUg== +"@babel/helpers@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.20.7.tgz#04502ff0feecc9f20ecfaad120a18f011a8e6dce" + integrity sha512-PBPjs5BppzsGaxHQCDKnZ6Gd9s6xl8bBCluz3vEInLGRJmnZan4F6BYCeqtyXqkk4W5IlPmjK4JlOuZkpJ3xZA== dependencies: - "@babel/template" "^7.18.10" - "@babel/traverse" "^7.20.1" - "@babel/types" "^7.20.0" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.20.7" + "@babel/types" "^7.20.7" "@babel/highlight@^7.18.6": version "7.18.6" @@ -155,10 +156,10 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.18.10", "@babel/parser@^7.20.1", "@babel/parser@^7.20.2": - version "7.20.3" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.3.tgz#5358cf62e380cf69efcb87a7bb922ff88bfac6e2" - integrity sha512-OP/s5a94frIPXwjzEcv5S/tpQfc6XhxYUnmWpgdqMWGgYCuErA3SzozaRAMQgSZWKeTJxht9aWAkUY+0UzvOFg== +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.7.tgz#66fe23b3c8569220817d5feb8b9dcdc95bb4f71b" + integrity sha512-T3Z9oHybU+0vZlY9CiDSJQTD5ZapcW18ZctFMi0MOAl/4BjFF4ul7NVSARLdbGO5vDqy9eQiGTV0LtKfvCYvcg== "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -251,35 +252,35 @@ dependencies: "@babel/helper-plugin-utils" "^7.19.0" -"@babel/template@^7.18.10", "@babel/template@^7.3.3": - version "7.18.10" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.18.10.tgz#6f9134835970d1dbf0835c0d100c9f38de0c5e71" - integrity sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA== +"@babel/template@^7.18.10", "@babel/template@^7.20.7", "@babel/template@^7.3.3": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.20.7.tgz#a15090c2839a83b02aa996c0b4994005841fd5a8" + integrity sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw== dependencies: "@babel/code-frame" "^7.18.6" - "@babel/parser" "^7.18.10" - "@babel/types" "^7.18.10" + "@babel/parser" "^7.20.7" + "@babel/types" "^7.20.7" -"@babel/traverse@^7.20.1", "@babel/traverse@^7.7.2": - version "7.20.1" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.1.tgz#9b15ccbf882f6d107eeeecf263fbcdd208777ec8" - integrity sha512-d3tN8fkVJwFLkHkBN479SOsw4DMZnz8cdbL/gvuDuzy3TS6Nfw80HuQqhw1pITbIruHyh7d1fMA47kWzmcUEGA== +"@babel/traverse@^7.20.7", "@babel/traverse@^7.7.2": + version "7.20.8" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.8.tgz#e3a23eb04af24f8bbe8a8ba3eef6155b77df0b08" + integrity sha512-/RNkaYDeCy4MjyV70+QkSHhxbvj2JO/5Ft2Pa880qJOG8tWrqcT/wXUuCCv43yogfqPzHL77Xu101KQPf4clnQ== dependencies: "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.20.1" + "@babel/generator" "^7.20.7" "@babel/helper-environment-visitor" "^7.18.9" "@babel/helper-function-name" "^7.19.0" "@babel/helper-hoist-variables" "^7.18.6" "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/parser" "^7.20.1" - "@babel/types" "^7.20.0" + "@babel/parser" "^7.20.7" + "@babel/types" "^7.20.7" debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.18.10", "@babel/types@^7.18.6", "@babel/types@^7.19.0", "@babel/types@^7.20.0", "@babel/types@^7.20.2", "@babel/types@^7.3.0", "@babel/types@^7.3.3": - version "7.20.2" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.2.tgz#67ac09266606190f496322dbaff360fdaa5e7842" - integrity sha512-FnnvsNWgZCr232sqtXggapvlkk/tuwR/qhGzcmxI0GXLCjmPYQPzio2FbdlWuY6y1sHFfQKk+rRbUZ9VStQMog== +"@babel/types@^7.0.0", "@babel/types@^7.18.6", "@babel/types@^7.19.0", "@babel/types@^7.20.2", "@babel/types@^7.20.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.7.tgz#54ec75e252318423fc07fb644dc6a58a64c09b7f" + integrity sha512-69OnhBxSSgK0OzTJai4kyPDiKTIe3j+ctaHdIGVbRahTLAT7L3R9oeXHC2aVSuGYt3cVnoAMDmOCgJ2yaiLMvg== dependencies: "@babel/helper-string-parser" "^7.19.4" "@babel/helper-validator-identifier" "^7.19.1" @@ -290,25 +291,25 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@eslint/eslintrc@^1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.3.tgz#2b044ab39fdfa75b4688184f9e573ce3c5b0ff95" - integrity sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg== +"@eslint/eslintrc@^1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.4.0.tgz#8ec64e0df3e7a1971ee1ff5158da87389f167a63" + integrity sha512-7yfvXy6MWLgWSFsLhz5yH3iQ52St8cdUY6FoGieKkRDVxuxmrNuUetIuu6cmjNWwniUHiWXjxCr5tTXDrbYS5A== dependencies: ajv "^6.12.4" debug "^4.3.2" espree "^9.4.0" - globals "^13.15.0" + globals "^13.19.0" ignore "^5.2.0" import-fresh "^3.2.1" js-yaml "^4.1.0" minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@humanwhocodes/config-array@^0.11.6": - version "0.11.7" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.7.tgz#38aec044c6c828f6ed51d5d7ae3d9b9faf6dbb0f" - integrity sha512-kBbPWzN8oVMLb0hOUYXhmxggL/1cJE6ydvjDIGi9EnAGUyA7cLVKQg+d/Dsm+KZwx2czGHrCmMVLiyg8s5JPKw== +"@humanwhocodes/config-array@^0.11.8": + version "0.11.8" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz#03595ac2075a4dc0f191cc2131de14fbd7d410b9" + integrity sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g== dependencies: "@humanwhocodes/object-schema" "^1.2.1" debug "^4.1.1" @@ -584,9 +585,9 @@ fastq "^1.6.0" "@sinonjs/commons@^1.7.0": - version "1.8.5" - resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.5.tgz#e280c94c95f206dcfd5aca00a43f2156b758c764" - integrity sha512-rTpCA0wG1wUxglBSFdMMY0oTrKYvgf4fNgv/sXbfCVAdf+FnPBdKJR/7XbpTCwbCrvCbdPYnlWaUUYz4V2fPDA== + version "1.8.6" + resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.6.tgz#80c516a4dc264c2a69115e7578d62581ff455ed9" + integrity sha512-Ky+XkAkqPZSm3NLBeUng77EBQl3cmeJhITaGHdYH8kjVB+aun3S4XBRti2zt17mtt0mIUDiNxYeoJm6drVvBJQ== dependencies: type-detect "4.0.8" @@ -629,9 +630,9 @@ "@babel/types" "^7.0.0" "@types/babel__traverse@*", "@types/babel__traverse@^7.0.4", "@types/babel__traverse@^7.0.6": - version "7.18.2" - resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.18.2.tgz#235bf339d17185bdec25e024ca19cce257cc7309" - integrity sha512-FcFaxOr2V5KZCviw1TnutEMVUVsGt4D2hP1TAfXZAMKuHYW3xQhe3jTxNPWutgCJ3/X1c5yX8ZoGVEItxKbwBg== + version "7.18.3" + resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.18.3.tgz#dfc508a85781e5698d5b33443416b6268c4b3e8d" + integrity sha512-1kbcJ40lLB7MHsj39U4Sh1uTd2E7rLEa79kmDpI6cy+XiXsteB3POdQomoq4FxszMrO3ZYchkhYJw7A2862b3w== dependencies: "@babel/types" "^7.3.0" @@ -698,9 +699,9 @@ integrity sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ== "@types/node@*": - version "18.11.9" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.9.tgz#02d013de7058cea16d36168ef2fc653464cfbad4" - integrity sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg== + version "18.11.17" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.17.tgz#5c009e1d9c38f4a2a9d45c0b0c493fe6cdb4bcb5" + integrity sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng== "@types/normalize-package-data@^2.4.0": version "2.4.1" @@ -708,9 +709,9 @@ integrity sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw== "@types/prettier@^2.1.5": - version "2.7.1" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.1.tgz#dfd20e2dc35f027cdd6c1908e80a5ddc7499670e" - integrity sha512-ri0UmynRRvZiiUJdiz38MmIblKK+oH30MztdBVR95dv/Ubw6neWSb8u1XpRb72L4qsZOhz+L+z9JD40SJmfWow== + version "2.7.2" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.2.tgz#6c2324641cc4ba050a8c710b2b251b377581fbf0" + integrity sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg== "@types/semver@^7.3.12": version "7.3.13" @@ -1053,9 +1054,9 @@ ansi-styles@^5.0.0: integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== anymatch@^3.0.3: - version "3.1.2" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" - integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== dependencies: normalize-path "^3.0.0" picomatch "^2.0.4" @@ -1254,9 +1255,9 @@ camelcase@^6.2.0: integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== caniuse-lite@^1.0.30001400: - version "1.0.30001431" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001431.tgz#e7c59bd1bc518fae03a4656be442ce6c4887a795" - integrity sha512-zBUoFU0ZcxpvSt9IU66dXVT/3ctO1cy4y9cscs1szkPlcWb6pasYM144GqrUygUbT+k7cmUCW61cvskjcv0enQ== + version "1.0.30001441" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001441.tgz#987437b266260b640a23cd18fbddb509d7f69f3e" + integrity sha512-OyxRR4Vof59I3yGWXws6i908EtGbMzVUi3ganaZQHmydk1iwDhRnvaPG2WaR0KcqrDFKrxVZHULT396LEPhXfg== caseless@~0.12.0: version "0.12.0" @@ -1291,9 +1292,9 @@ chrome-trace-event@^1.0.2: integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== ci-info@^3.2.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.5.0.tgz#bfac2a29263de4c829d806b1ab478e35091e171f" - integrity sha512-yH4RezKOGlOhxkmhbeNuC4eYZKAUsEaGtBuBzDDP1eFUKiccDWzBABxBfOx31IDwDIXMTxWuwAxUGModvkbuVw== + version "3.7.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.7.0.tgz#6d01b3696c59915b6ce057e4aa4adfc2fa25f5ef" + integrity sha512-2CpRNYmImPx+RXKLq6jko/L07phmS9I02TyqkcNU20GCF/GgaWvc58hPtjxDX8lPpkdwc9sNh72V9k00S7ezog== cjs-module-lexer@^1.0.0: version "1.2.2" @@ -1640,9 +1641,9 @@ decamelize@^1.1.0: integrity sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA== decimal.js@^10.2.1: - version "10.4.2" - resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.4.2.tgz#0341651d1d997d86065a2ce3a441fbd0d8e8b98e" - integrity sha512-ic1yEvwT6GuvaYwBLLY6/aFFgjZdySKTE8en/fkU3QICTmRtgtSlFn0u0BXN06InZwtfCelR7j8LRiDI/02iGA== + version "10.4.3" + resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.4.3.tgz#1044092884d245d1b7f65725fa4ad4c6f781cc23" + integrity sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA== dedent@^0.7.0: version "0.7.0" @@ -1856,12 +1857,12 @@ eslint-visitor-keys@^3.3.0: integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== eslint@^8.0.1: - version "8.27.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.27.0.tgz#d547e2f7239994ad1faa4bb5d84e5d809db7cf64" - integrity sha512-0y1bfG2ho7mty+SiILVf9PfuRA49ek4Nc60Wmmu62QlobNR+CeXa4xXIJgcuwSQgZiWaPH+5BDsctpIW0PR/wQ== + version "8.30.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.30.0.tgz#83a506125d089eef7c5b5910eeea824273a33f50" + integrity sha512-MGADB39QqYuzEGov+F/qb18r4i7DohCDOfatHaxI2iGlPuC65bwG2gxgO+7DkyL38dRFaRH7RaRAgU6JKL9rMQ== dependencies: - "@eslint/eslintrc" "^1.3.3" - "@humanwhocodes/config-array" "^0.11.6" + "@eslint/eslintrc" "^1.4.0" + "@humanwhocodes/config-array" "^0.11.8" "@humanwhocodes/module-importer" "^1.0.1" "@nodelib/fs.walk" "^1.2.8" ajv "^6.10.0" @@ -1880,7 +1881,7 @@ eslint@^8.0.1: file-entry-cache "^6.0.1" find-up "^5.0.0" glob-parent "^6.0.2" - globals "^13.15.0" + globals "^13.19.0" grapheme-splitter "^1.0.4" ignore "^5.2.0" import-fresh "^3.0.0" @@ -2020,9 +2021,9 @@ fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== fastq@^1.6.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" - integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== + version "1.14.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.14.0.tgz#107f69d7295b11e0fccc264e1fc6389f623731ce" + integrity sha512-eR2D+V9/ExcbF9ls441yIuN6TI2ED1Y2ZcA5BmMtJsOkWOFRJQ0Jt0g1UwqXJJVAb+V+umH5Dfr8oh4EVP7VVg== dependencies: reusify "^1.0.4" @@ -2242,10 +2243,10 @@ globals@^11.1.0: resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== -globals@^13.15.0: - version "13.17.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.17.0.tgz#902eb1e680a41da93945adbdcb5a9f361ba69bd4" - integrity sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw== +globals@^13.19.0: + version "13.19.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.19.0.tgz#7a42de8e6ad4f7242fbcca27ea5b23aca367b5c8" + integrity sha512-dkQ957uSRWHw7CFXLUtUHQI3g3aWApYhfNR2O6jn/907riyTYKVBmxYVROkBcY614FSSeSJh7Xm7SrUWCxvJMQ== dependencies: type-fest "^0.20.2" @@ -2381,9 +2382,9 @@ iconv-lite@0.4.24: safer-buffer ">= 2.1.2 < 3" ignore@^5.1.1, ignore@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" - integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== + version "5.2.4" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" + integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== import-fresh@^3.0.0, import-fresh@^3.2.1: version "3.3.0" @@ -2787,9 +2788,9 @@ jest-mock@^27.5.1: "@types/node" "*" jest-pnp-resolver@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.2.tgz#b704ac0ae028a89108a4d040b3f919dfddc8e33c" - integrity sha512-olV41bKSMm8BdnuMsewT4jqlZ8+3TCARAXjZGT9jcoSnrfUnRCqnMoF9XEeoWjbzObpqF9dRhHQj0Xb9QdF6/w== + version "1.2.3" + resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz#930b1546164d4ad5937d5540e711d4d38d4cad2e" + integrity sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w== jest-regex-util@^27.5.1: version "27.5.1" @@ -2968,9 +2969,9 @@ jest@^27.3.1: jest-cli "^27.5.1" js-sdsl@^4.1.4: - version "4.1.5" - resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.1.5.tgz#1ff1645e6b4d1b028cd3f862db88c9d887f26e2a" - integrity sha512-08bOAKweV2NUC1wqTtf3qZlnpOX/R2DU9ikpjOHs0H+ibQv3zpncVQg6um4uYtRtrwIX8M4Nh3ytK4HGlYAq7Q== + version "4.2.0" + resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.2.0.tgz#278e98b7bea589b8baaf048c20aeb19eb7ad09d0" + integrity sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ== js-tokens@^4.0.0: version "4.0.0" @@ -3066,9 +3067,9 @@ json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== json5@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" - integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== + version "2.2.2" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.2.tgz#64471c5bdcc564c18f7c1d4df2e2297f2457c5ab" + integrity sha512-46Tk9JiOL2z7ytNQWFLpj99RZkVgeHf87yGQKsIkaPz1qSH9UczKH1rO7K3wgRselo0tYMUNfecYpm/p1vC7tQ== jsonparse@^1.2.0: version "1.3.1" @@ -3191,6 +3192,13 @@ log-driver@^1.2.7: resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.7.tgz#63b95021f0702fedfa2c9bb0a24e7797d71871d8" integrity sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg== +lru-cache@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" + integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== + dependencies: + yallist "^3.0.2" + lru-cache@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" @@ -3331,9 +3339,9 @@ node-int64@^0.4.0: integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw== node-releases@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503" - integrity sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg== + version "2.0.8" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.8.tgz#0f349cdc8fcfa39a92ac0be9bc48b7706292b9ae" + integrity sha512-dFSmB8fFHEH/s81Xi+Y/15DQY6VHW81nXRj86EMSL3lmuTmK1e+aT4wrFCkTbm+gSwkw4KpX+rT/pMM2c1mF+A== normalize-package-data@^2.3.2, normalize-package-data@^2.5.0: version "2.5.0" @@ -3589,9 +3597,9 @@ prelude-ls@~1.1.2: integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w== prettier@^2.4.1: - version "2.7.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" - integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== + version "2.8.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.1.tgz#4e1fd11c34e2421bc1da9aea9bd8127cd0a35efc" + integrity sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg== pretty-format@^27.5.1: version "27.5.1" @@ -4555,6 +4563,11 @@ y18n@^5.0.5: resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== +yallist@^3.0.2: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" + integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== + yallist@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" From 1b3706a03f7c790086d37f78a96b435f3ff98d3b Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Fri, 23 Dec 2022 20:11:55 +0000 Subject: [PATCH 05/13] address some PR comments --- lib/getHashDigest.ts | 26 ++++++++------------------ lib/index.ts | 10 ++++------ lib/urlToRequest.ts | 5 ++++- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/lib/getHashDigest.ts b/lib/getHashDigest.ts index 5aedd0d..2a228e7 100644 --- a/lib/getHashDigest.ts +++ b/lib/getHashDigest.ts @@ -1,4 +1,4 @@ -import { Hash } from "crypto"; +import type { Hash } from "crypto"; const baseEncodeTables = { 26: "abcdefghijklmnopqrstuvwxyz", @@ -11,16 +11,8 @@ const baseEncodeTables = { 64: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_", }; -type DigestTypes = - | "base26" - | "base32" - | "base36" - | "base49" - | "base52" - | "base58" - | "base62" - | "base64"; -type BaseEncodings = 26 | 32 | 36 | 49 | 52 | 58 | 62 | 64; +type BaseEncoding = keyof typeof baseEncodeTables; +type DigestType = `base${BaseEncoding}`; /** * @param {Uint32Array} uint32Array Treated as a long base-0x100000000 number, little endian @@ -39,10 +31,10 @@ function divmod32(uint32Array: Uint32Array, divisor: number): number { function encodeBufferToBase( buffer: Buffer, - base: BaseEncodings | number, + base: BaseEncoding, length: number ) { - const encodeTable = baseEncodeTables[base as keyof typeof baseEncodeTables]; + const encodeTable = baseEncodeTables[base]; if (!encodeTable) { throw new Error("Unknown encoding base" + base); @@ -78,7 +70,7 @@ let BulkUpdateDecorator: typeof import("./hash/BulkUpdateDecorator").default; export default function getHashDigest( buffer: Buffer, algorithm: string | "xxhash64" | "md4" | "native-md4", - digestType: DigestTypes | string, + digestType: DigestType | string, maxLength: number ) { algorithm = algorithm || "xxhash64"; @@ -142,13 +134,11 @@ export default function getHashDigest( digestType === "base58" || digestType === "base62" ) { - const digestTypeToDigest: number = digestType.substr( - 4 - ) as unknown as number; + const digestTypeToDigest = Number(digestType.substr(4)); return encodeBufferToBase( hash.digest() as Buffer, - digestTypeToDigest, + digestTypeToDigest as BaseEncoding, maxLength ); } else { diff --git a/lib/index.ts b/lib/index.ts index f7629c3..062c108 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1,6 +1,4 @@ -import isUrlRequest from "./isUrlRequest"; -import urlToRequest from "./urlToRequest"; -import getHashDigest from "./getHashDigest"; -import interpolateName from "./interpolateName"; - -export { urlToRequest, getHashDigest, interpolateName, isUrlRequest }; +export { default as isUrlRequest } from "./isUrlRequest"; +export { default as urlToRequest } from "./urlToRequest"; +export { default as getHashDigest } from "./getHashDigest"; +export { default as interpolateName } from "./interpolateName"; diff --git a/lib/urlToRequest.ts b/lib/urlToRequest.ts index fc2a462..3bb5824 100644 --- a/lib/urlToRequest.ts +++ b/lib/urlToRequest.ts @@ -2,6 +2,7 @@ const NATIVE_WIN_32_PATH_REGEXP = /^[A-Z]:[/\\]|^\\\\/i; const MODULE_REQUEST_REGEXP = /^[^?]*~/; const ROOT_RELATIVE_URL_REGEXP = /^\//; +const TILDE_ROOTS_MODULE_REQUEST_REGEXP = /([^~/])$/; export default function urlToRequest( url: string, @@ -28,7 +29,9 @@ export default function urlToRequest( case "string": // special case: `~` roots convert to module request if (MODULE_REQUEST_REGEXP.test(root)) { - request = root.replace(/([^~/])$/, "$1/") + url.slice(1); + request = + root.replace(TILDE_ROOTS_MODULE_REQUEST_REGEXP, "$1/") + + url.slice(1); } else { request = root + url; } From b9a9336facbf5cc5eeedeb1bd081f7c4d3bf4d82 Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Fri, 23 Dec 2022 20:26:33 +0000 Subject: [PATCH 06/13] change default exports for classes to just regular exports for compat --- lib/getHashDigest.ts | 22 ++++++++++++---------- lib/hash/BatchedHash.ts | 15 +++------------ lib/hash/BulkUpdateDecorator.ts | 21 ++++----------------- lib/hash/md4.ts | 4 ++-- lib/hash/xxhash64.ts | 4 ++-- 5 files changed, 23 insertions(+), 43 deletions(-) diff --git a/lib/getHashDigest.ts b/lib/getHashDigest.ts index 2a228e7..e908cc0 100644 --- a/lib/getHashDigest.ts +++ b/lib/getHashDigest.ts @@ -62,10 +62,10 @@ function encodeBufferToBase( } let crypto: typeof import("crypto"); -let createXXHash64: typeof import("./hash/xxhash64").default; -let createMd4: typeof import("./hash/md4").default; -let BatchedHash: typeof import("./hash/BatchedHash").default; -let BulkUpdateDecorator: typeof import("./hash/BulkUpdateDecorator").default; +let createXXHash64: typeof import("./hash/xxhash64").create; +let createMd4: typeof import("./hash/md4").create; +let BatchedHash: typeof import("./hash/BatchedHash").BatchedHash; +let BulkUpdateDecorator: typeof import("./hash/BulkUpdateDecorator").BulkUpdateDecorator; export default function getHashDigest( buffer: Buffer, @@ -80,20 +80,20 @@ export default function getHashDigest( if (algorithm === "xxhash64") { if (createXXHash64 === undefined) { - createXXHash64 = require("./hash/xxhash64").default; + createXXHash64 = require("./hash/xxhash64").create; if (BatchedHash === undefined) { - BatchedHash = require("./hash/BatchedHash").default; + BatchedHash = require("./hash/BatchedHash").BatchedHash; } } hash = new BatchedHash(createXXHash64() as unknown as Hash); } else if (algorithm === "md4") { if (createMd4 === undefined) { - createMd4 = require("./hash/md4").default; + createMd4 = require("./hash/md4").create; if (BatchedHash === undefined) { - BatchedHash = require("./hash/BatchedHash").default; + BatchedHash = require("./hash/BatchedHash").BatchedHash; } } @@ -103,7 +103,8 @@ export default function getHashDigest( crypto = require("crypto"); if (BulkUpdateDecorator === undefined) { - BulkUpdateDecorator = require("./hash/BulkUpdateDecorator").default; + BulkUpdateDecorator = + require("./hash/BulkUpdateDecorator").BulkUpdateDecorator; } } @@ -113,7 +114,8 @@ export default function getHashDigest( crypto = require("crypto"); if (BulkUpdateDecorator === undefined) { - BulkUpdateDecorator = require("./hash/BulkUpdateDecorator").default; + BulkUpdateDecorator = + require("./hash/BulkUpdateDecorator").BulkUpdateDecorator; } } diff --git a/lib/hash/BatchedHash.ts b/lib/hash/BatchedHash.ts index 91139d4..5e1516c 100644 --- a/lib/hash/BatchedHash.ts +++ b/lib/hash/BatchedHash.ts @@ -1,7 +1,7 @@ import type { Hash, Encoding, BinaryToTextEncoding } from "crypto"; import { MAX_SHORT_STRING } from "./wasm-hash"; -export default class BatchedHash { +export class BatchedHash { public string?: string; public encoding?: Encoding; public readonly hash: Hash; @@ -12,12 +12,7 @@ export default class BatchedHash { this.hash = hash; } - /** - * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding} - * @param {string|Buffer} data data - * @param {string=} inputEncoding data encoding - * @returns {this} updated hash - */ + // Updates the hash https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding update(data: string | Buffer, inputEncoding?: Encoding): this { if (this.string !== undefined) { if ( @@ -61,11 +56,7 @@ export default class BatchedHash { return this; } - /** - * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding} - * @param {string=} encoding encoding of the return value - * @returns {string|Buffer} digest - */ + // Calculates the digest https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding digest(encoding?: BinaryToTextEncoding): string | Buffer { if (this.string !== undefined) { if (this.encoding !== undefined) { diff --git a/lib/hash/BulkUpdateDecorator.ts b/lib/hash/BulkUpdateDecorator.ts index 4de2f4c..06da5d6 100644 --- a/lib/hash/BulkUpdateDecorator.ts +++ b/lib/hash/BulkUpdateDecorator.ts @@ -5,13 +5,9 @@ const BULK_SIZE = 2000; // We are using an object instead of a Map as this will stay static during the runtime // so access to it can be optimized by v8 -const digestCaches: { [key: string]: any } = {}; +const digestCaches: Record = {}; -export default class BulkUpdateDecorator { - /** - * @param {HashOrFactory} hashOrFactory function to create a hash - * @param {string=} hashKey key for caching - */ +export class BulkUpdateDecorator { hash?: Hash; hashFactory?: () => Hash; hashKey: string; @@ -31,12 +27,7 @@ export default class BulkUpdateDecorator { this.buffer = ""; } - /** - * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding} - * @param {string|Buffer} data data - * @param {string=} inputEncoding data encoding - * @returns {this} updated hash - */ + // Updates the hash https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding update(data: string | Buffer, inputEncoding?: Encoding): this { if ( inputEncoding !== undefined || @@ -75,11 +66,7 @@ export default class BulkUpdateDecorator { return this; } - /** - * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding} - * @param {string=} encoding encoding of the return value - * @returns {string|Buffer} digest - */ + // Calculates the digest https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding digest(encoding?: BinaryToTextEncoding): string | Buffer { let digestCache; let digestResult: string | Buffer; diff --git a/lib/hash/md4.ts b/lib/hash/md4.ts index c39ebea..a267e04 100644 --- a/lib/hash/md4.ts +++ b/lib/hash/md4.ts @@ -3,7 +3,7 @@ Author Tobias Koppers @sokra */ -import { create } from "./wasm-hash"; +import { create as createFn } from "./wasm-hash"; //#region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1 const md4 = new WebAssembly.Module( @@ -15,4 +15,4 @@ const md4 = new WebAssembly.Module( ); //#endregion -export default create.bind(null, md4, [], 64, 32); +export const create = createFn.bind(null, md4, [], 64, 32); diff --git a/lib/hash/xxhash64.ts b/lib/hash/xxhash64.ts index 38b964e..5f63f8b 100644 --- a/lib/hash/xxhash64.ts +++ b/lib/hash/xxhash64.ts @@ -2,7 +2,7 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -import { create } from "./wasm-hash"; +import { create as createFn } from "./wasm-hash"; //#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1 const xxhash64 = new WebAssembly.Module( @@ -14,4 +14,4 @@ const xxhash64 = new WebAssembly.Module( ); //#endregion -export default create.bind(null, xxhash64, [], 32, 16); +export const create = createFn.bind(null, xxhash64, [], 32, 16); From ec2d6a0810fe7bcfcc3a6706f6810d618f1aa301 Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Fri, 23 Dec 2022 21:17:52 +0000 Subject: [PATCH 07/13] introduce api-extractor for typings rollup --- .eslintrc.json | 2 +- .gitignore | 3 +- api-extractor.json | 427 ++++++++++++++++++++++++++++++++++++++++ etc/loader-utils.api.md | 29 +++ lib/getHashDigest.ts | 8 + lib/interpolateName.ts | 9 + lib/isUrlRequest.ts | 18 ++ lib/urlToRequest.ts | 43 ++++ package.json | 4 +- tsconfig.json | 4 +- yarn.lock | 192 +++++++++++++++++- 11 files changed, 727 insertions(+), 12 deletions(-) create mode 100644 api-extractor.json create mode 100644 etc/loader-utils.api.md diff --git a/.eslintrc.json b/.eslintrc.json index c5656e9..79cd8e6 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,7 +19,7 @@ "no-process-exit": "error", "no-loop-func": "error", "no-console": "off", - "valid-jsdoc": "error", + "valid-jsdoc": "off", "no-var": "error", "prefer-const": "error", "prefer-arrow-callback": "error", diff --git a/.gitignore b/.gitignore index 882d864..2aef375 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea node_modules coverage -/dist \ No newline at end of file +/dist +/temp diff --git a/api-extractor.json b/api-extractor.json new file mode 100644 index 0000000..0c0517f --- /dev/null +++ b/api-extractor.json @@ -0,0 +1,427 @@ +/** + * Config file for API Extractor. For more info, please visit: https://api-extractor.com + */ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + + /** + * Optionally specifies another JSON config file that this file extends from. This provides a way for + * standard settings to be shared across multiple projects. + * + * If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains + * the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be + * resolved using NodeJS require(). + * + * SUPPORTED TOKENS: none + * DEFAULT VALUE: "" + */ + // "extends": "./shared/api-extractor-base.json" + // "extends": "my-package/include/api-extractor-base.json" + + /** + * Determines the "" token that can be used with other config file settings. The project folder + * typically contains the tsconfig.json and package.json config files, but the path is user-defined. + * + * The path is resolved relative to the folder of the config file that contains the setting. + * + * The default value for "projectFolder" is the token "", which means the folder is determined by traversing + * parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder + * that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error + * will be reported. + * + * SUPPORTED TOKENS: + * DEFAULT VALUE: "" + */ + // "projectFolder": "..", + + /** + * (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor + * analyzes the symbols exported by this module. + * + * The file extension must be ".d.ts" and not ".ts". + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + */ + "mainEntryPointFilePath": "/dist/index.d.ts", + + /** + * A list of NPM package names whose exports should be treated as part of this package. + * + * For example, suppose that Webpack is used to generate a distributed bundle for the project "library1", + * and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part + * of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly + * imports library2. To avoid this, we can specify: + * + * "bundledPackages": [ "library2" ], + * + * This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been + * local files for library1. + */ + "bundledPackages": [], + + /** + * Specifies what type of newlines API Extractor should use when writing output files. By default, the output files + * will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead. + * To use the OS's default newline kind, specify "os". + * + * DEFAULT VALUE: "crlf" + */ + // "newlineKind": "crlf", + + /** + * Set to true when invoking API Extractor's test harness. When `testMode` is true, the `toolVersion` field in the + * .api.json file is assigned an empty string to prevent spurious diffs in output files tracked for tests. + * + * DEFAULT VALUE: "false" + */ + // "testMode": false, + + /** + * Specifies how API Extractor sorts members of an enum when generating the .api.json file. By default, the output + * files will be sorted alphabetically, which is "by-name". To keep the ordering in the source code, specify + * "preserve". + * + * DEFAULT VALUE: "by-name" + */ + // "enumMemberOrder": "by-name", + + /** + * Determines how the TypeScript compiler engine will be invoked by API Extractor. + */ + "compiler": { + /** + * Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * Note: This setting will be ignored if "overrideTsconfig" is used. + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/tsconfig.json" + */ + // "tsconfigFilePath": "/tsconfig.json", + /** + * Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk. + * The object must conform to the TypeScript tsconfig schema: + * + * http://json.schemastore.org/tsconfig + * + * If omitted, then the tsconfig.json file will be read from the "projectFolder". + * + * DEFAULT VALUE: no overrideTsconfig section + */ + // "overrideTsconfig": { + // . . . + // } + /** + * This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended + * and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when + * dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses + * for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck. + * + * DEFAULT VALUE: false + */ + // "skipLibCheck": true, + }, + + /** + * Configures how the API report file (*.api.md) will be generated. + */ + "apiReport": { + /** + * (REQUIRED) Whether to generate an API report. + */ + "enabled": true + + /** + * The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce + * a full file path. + * + * The file extension should be ".api.md", and the string should not contain a path separator such as "\" or "/". + * + * SUPPORTED TOKENS: , + * DEFAULT VALUE: ".api.md" + */ + // "reportFileName": ".api.md", + + /** + * Specifies the folder where the API report file is written. The file name portion is determined by + * the "reportFileName" setting. + * + * The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy, + * e.g. for an API review. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/temp/" + */ + // "reportFolder": "/temp/", + + /** + * Specifies the folder where the temporary report file is written. The file name portion is determined by + * the "reportFileName" setting. + * + * After the temporary file is written to disk, it is compared with the file in the "reportFolder". + * If they are different, a production build will fail. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/temp/" + */ + // "reportTempFolder": "/temp/", + + /** + * Whether "forgotten exports" should be included in the API report file. Forgotten exports are declarations + * flagged with `ae-forgotten-export` warnings. See https://api-extractor.com/pages/messages/ae-forgotten-export/ to + * learn more. + * + * DEFAULT VALUE: "false" + */ + // "includeForgottenExports": false + }, + + /** + * Configures how the doc model file (*.api.json) will be generated. + */ + "docModel": { + /** + * (REQUIRED) Whether to generate a doc model file. + */ + "enabled": true + + /** + * The output path for the doc model file. The file extension should be ".api.json". + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/temp/.api.json" + */ + // "apiJsonFilePath": "/temp/.api.json", + + /** + * Whether "forgotten exports" should be included in the doc model file. Forgotten exports are declarations + * flagged with `ae-forgotten-export` warnings. See https://api-extractor.com/pages/messages/ae-forgotten-export/ to + * learn more. + * + * DEFAULT VALUE: "false" + */ + // "includeForgottenExports": false, + + /** + * The base URL where the project's source code can be viewed on a website such as GitHub or + * Azure DevOps. This URL path corresponds to the `` path on disk. + * + * This URL is concatenated with the file paths serialized to the doc model to produce URL file paths to individual API items. + * For example, if the `projectFolderUrl` is "https://github.com/microsoft/rushstack/tree/main/apps/api-extractor" and an API + * item's file path is "api/ExtractorConfig.ts", the full URL file path would be + * "https://github.com/microsoft/rushstack/tree/main/apps/api-extractor/api/ExtractorConfig.js". + * + * Can be omitted if you don't need source code links in your API documentation reference. + * + * SUPPORTED TOKENS: none + * DEFAULT VALUE: "" + */ + // "projectFolderUrl": "http://github.com/path/to/your/projectFolder" + }, + + /** + * Configures how the .d.ts rollup file will be generated. + */ + "dtsRollup": { + /** + * (REQUIRED) Whether to generate the .d.ts rollup file. + */ + "enabled": true + + /** + * Specifies the output path for a .d.ts rollup file to be generated without any trimming. + * This file will include all declarations that are exported by the main entry point. + * + * If the path is an empty string, then this file will not be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/dist/.d.ts" + */ + // "untrimmedFilePath": "/dist/.d.ts", + + /** + * Specifies the output path for a .d.ts rollup file to be generated with trimming for an "alpha" release. + * This file will include only declarations that are marked as "@public", "@beta", or "@alpha". + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + // "alphaTrimmedFilePath": "/dist/-alpha.d.ts", + + /** + * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release. + * This file will include only declarations that are marked as "@public" or "@beta". + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + // "betaTrimmedFilePath": "/dist/-beta.d.ts", + + /** + * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release. + * This file will include only declarations that are marked as "@public". + * + * If the path is an empty string, then this file will not be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + // "publicTrimmedFilePath": "/dist/-public.d.ts", + + /** + * When a declaration is trimmed, by default it will be replaced by a code comment such as + * "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the + * declaration completely. + * + * DEFAULT VALUE: false + */ + // "omitTrimmingComments": true + }, + + /** + * Configures how the tsdoc-metadata.json file will be generated. + */ + "tsdocMetadata": { + /** + * Whether to generate the tsdoc-metadata.json file. + * + * DEFAULT VALUE: true + */ + // "enabled": true, + /** + * Specifies where the TSDoc metadata file should be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * The default value is "", which causes the path to be automatically inferred from the "tsdocMetadata", + * "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup + * falls back to "tsdoc-metadata.json" in the package folder. + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + // "tsdocMetadataFilePath": "/dist/tsdoc-metadata.json" + }, + + /** + * Configures how API Extractor reports error and warning messages produced during analysis. + * + * There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages. + */ + "messages": { + /** + * Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing + * the input .d.ts files. + * + * TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551" + * + * DEFAULT VALUE: A single "default" entry with logLevel=warning. + */ + "compilerMessageReporting": { + /** + * Configures the default routing for messages that don't match an explicit rule in this table. + */ + "default": { + /** + * Specifies whether the message should be written to the the tool's output log. Note that + * the "addToApiReportFile" property may supersede this option. + * + * Possible values: "error", "warning", "none" + * + * Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail + * and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes + * the "--local" option), the warning is displayed but the build will not fail. + * + * DEFAULT VALUE: "warning" + */ + "logLevel": "warning" + + /** + * When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md), + * then the message will be written inside that file; otherwise, the message is instead logged according to + * the "logLevel" option. + * + * DEFAULT VALUE: false + */ + // "addToApiReportFile": false + } + + // "TS2551": { + // "logLevel": "warning", + // "addToApiReportFile": true + // }, + // + // . . . + }, + + /** + * Configures handling of messages reported by API Extractor during its analysis. + * + * API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag" + * + * DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings + */ + "extractorMessageReporting": { + "default": { + "logLevel": "warning" + // "addToApiReportFile": false + } + + // "ae-extra-release-tag": { + // "logLevel": "warning", + // "addToApiReportFile": true + // }, + // + // . . . + }, + + /** + * Configures handling of messages reported by the TSDoc parser when analyzing code comments. + * + * TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text" + * + * DEFAULT VALUE: A single "default" entry with logLevel=warning. + */ + "tsdocMessageReporting": { + "default": { + "logLevel": "warning" + // "addToApiReportFile": false + } + + // "tsdoc-link-tag-unescaped-text": { + // "logLevel": "warning", + // "addToApiReportFile": true + // }, + // + // . . . + } + } +} diff --git a/etc/loader-utils.api.md b/etc/loader-utils.api.md new file mode 100644 index 0000000..d3bf813 --- /dev/null +++ b/etc/loader-utils.api.md @@ -0,0 +1,29 @@ +## API Report File for "loader-utils" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +/// + +import type { LoaderContext } from 'webpack'; + +// Warning: (ae-forgotten-export) The symbol "DigestType" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +export function getHashDigest(buffer: Buffer, algorithm: string | "xxhash64" | "md4" | "native-md4", digestType: DigestType | string, maxLength: number): any; + +// Warning: (ae-forgotten-export) The symbol "IInterpolateNameOptions" needs to be exported by the entry point index.d.ts +// +// @public +export function interpolateName(loaderContext: LoaderContext, name: string | ((resourcePath: string, resourceQuery?: string) => string), options?: IInterpolateNameOptions): string; + +// @public +export function isUrlRequest(url: string): boolean; + +// @public +export function urlToRequest(url: string, root?: string | boolean): string; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/lib/getHashDigest.ts b/lib/getHashDigest.ts index e908cc0..201c819 100644 --- a/lib/getHashDigest.ts +++ b/lib/getHashDigest.ts @@ -67,6 +67,14 @@ let createMd4: typeof import("./hash/md4").create; let BatchedHash: typeof import("./hash/BatchedHash").BatchedHash; let BulkUpdateDecorator: typeof import("./hash/BulkUpdateDecorator").BulkUpdateDecorator; +/** + * @public + * + * @param buffer - This represents the content that should be hashed + * @param hashType - The algorithm to use to hash the content. Can be one of `xxhash64`, `md4`, `native-md4` or any other hash algorithm supported by node.js `crypto` module. + * @param digestType - The encoding to use for the hash. Can be one of `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62` or `base64`. + * @param maxLength - The maximum length of the resulting hash. Defaults to `9999`. + */ export default function getHashDigest( buffer: Buffer, algorithm: string | "xxhash64" | "md4" | "native-md4", diff --git a/lib/interpolateName.ts b/lib/interpolateName.ts index 0179a8c..bbd00a8 100644 --- a/lib/interpolateName.ts +++ b/lib/interpolateName.ts @@ -8,6 +8,15 @@ interface IInterpolateNameOptions { regExp?: string; } +/** + * Interpolates a filename template using multiple placeholders and/or regular expressions. + * The template and regular expression are set as query params called `name` and `regExp` on the current loader's context. + * + * @param loaderContext - The loader context from webpack which is provided via `this` inside of a loader. + * @param name - The name of the string to transform/interpolate on. This can be a string or a function (providing the loader contexts resourcePath and resourceQuery) that returns a string. + * @param options - An object containing the following properties: `context`, `content`, `regExp`. + * @public + */ export default function interpolateName( loaderContext: LoaderContext, name: string | ((resourcePath: string, resourceQuery?: string) => string), diff --git a/lib/isUrlRequest.ts b/lib/isUrlRequest.ts index 0e4a2f7..30a74ed 100644 --- a/lib/isUrlRequest.ts +++ b/lib/isUrlRequest.ts @@ -5,6 +5,24 @@ const ABOSLUTE_URL_NON_WINDOWS_PATHLIKE_REGEXP = /^[a-z][a-z0-9+.-]*:/i; const POROTCOL_RELATIVE_REGEXP = /^\/\//i; const URL_FOR_TEMPLATE_REGEXP = /^#/i; +/** + * Utility method for ensuring if a string is a requestable URL + * @remarks + * You typically want to call `isUrlRequest()` before using the `urlToRequest()` function + * @example + * ```js + * const url = "path/to/module.js" + * if (loaderUtils.isUrlRequest(url)) { + * // Logic for requestable url + * const request = loaderUtils.urlToRequest(url); + * } else { + * // Logic for non-requestable url + * } + * ``` + * + * @param url - The url to check + * @public + */ export default function isUrlRequest(url: string): boolean { // An URL is not an request if diff --git a/lib/urlToRequest.ts b/lib/urlToRequest.ts index 3bb5824..e8bea92 100644 --- a/lib/urlToRequest.ts +++ b/lib/urlToRequest.ts @@ -4,6 +4,49 @@ const MODULE_REQUEST_REGEXP = /^[^?]*~/; const ROOT_RELATIVE_URL_REGEXP = /^\//; const TILDE_ROOTS_MODULE_REQUEST_REGEXP = /([^~/])$/; +/** + * Converts some resource URL into a webpack module request + * + * @example + * A simple example: + * ```js + * const url = "path/to/module.js" + * const request = loaderUtils.urlToRequest(url); + * // request === "./path/to/module.js" + * ``` + * + * @remarks + * ### Module URLs + * + * @example + * Any URL containing a `~` will be interpreted as a module request. Anything after the `~` will be considered the request path: + * ```js + * const url = "~/path/to/module.js" + * const request = loaderUtils.urlToRequest(url); + * // request === "path/to/module.js" + * ``` + * + * @remarks + * ### Root-relative URLs + * + * @example + * URLs that are root-relative (start with `/`) can be resolved relative to some arbitrary path by using the root parameter: + * ```js + * const url = "/path/to/module.js" + * const request = loaderUtils.urlToRequest(url, "./root"); + * // request === "./root/path/to/module.js" + * ``` + * + * @example + * To convert a root-relative URL into a module URL, specify a root value that starts with `~`: + * ```js + * const url = "/path/to/module.js" + * const request = loaderUtils.urlToRequest(url, "~"); + * // request === "path/to/module.js" + * ``` + * + * @public + */ export default function urlToRequest( url: string, root?: string | boolean diff --git a/package.json b/package.json index 26aa9e9..c6bfaaa 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "scripts": { "lint": "prettier --list-different . && eslint ./lib", "pretty": "prettier --write .", - "build": "tsc", + "type-rollup": "api-extractor run --local", + "build": "tsc && yarn type-rollup", "pretest": "yarn lint", "test": "jest", "test:only": "jest --coverage", @@ -23,6 +24,7 @@ "node": ">= 12.13.0" }, "devDependencies": { + "@microsoft/api-extractor": "^7.33.7", "@typescript-eslint/eslint-plugin": "^5.47.0", "@typescript-eslint/parser": "^5.47.0", "coveralls": "^3.1.1", diff --git a/tsconfig.json b/tsconfig.json index 4173668..d2d4b16 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,9 @@ "outDir": "dist", "strict": true, "types": ["node"], - "esModuleInterop": true + "esModuleInterop": true, + "declaration": true, + "declarationMap": true }, "include": ["lib/**/*.ts"] } diff --git a/yarn.lock b/yarn.lock index e08e909..314d9c5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -563,6 +563,48 @@ "@jridgewell/resolve-uri" "3.1.0" "@jridgewell/sourcemap-codec" "1.4.14" +"@microsoft/api-extractor-model@7.25.3": + version "7.25.3" + resolved "https://registry.yarnpkg.com/@microsoft/api-extractor-model/-/api-extractor-model-7.25.3.tgz#1ad0fe161623564e5b36b73d5889066e36097389" + integrity sha512-WWxBUq77p2iZ+5VF7Nmrm3y/UtqCh5bYV8ii3khwq3w99+fXWpvfsAhgSLsC7k8XDQc6De4ssMxH6He/qe1pzg== + dependencies: + "@microsoft/tsdoc" "0.14.2" + "@microsoft/tsdoc-config" "~0.16.1" + "@rushstack/node-core-library" "3.53.3" + +"@microsoft/api-extractor@^7.33.7": + version "7.33.7" + resolved "https://registry.yarnpkg.com/@microsoft/api-extractor/-/api-extractor-7.33.7.tgz#3579f23469a9e02deb4e7aee705ddd2a221c7b8d" + integrity sha512-fQT2v/j/55DhvMFiopLtth66E7xTFNhnumMKgKY14SaG6qU/V1W0e4nOAgbA+SmLakQjAd1Evu06ofaVaxBPbA== + dependencies: + "@microsoft/api-extractor-model" "7.25.3" + "@microsoft/tsdoc" "0.14.2" + "@microsoft/tsdoc-config" "~0.16.1" + "@rushstack/node-core-library" "3.53.3" + "@rushstack/rig-package" "0.3.17" + "@rushstack/ts-command-line" "4.13.1" + colors "~1.2.1" + lodash "~4.17.15" + resolve "~1.17.0" + semver "~7.3.0" + source-map "~0.6.1" + typescript "~4.8.4" + +"@microsoft/tsdoc-config@~0.16.1": + version "0.16.2" + resolved "https://registry.yarnpkg.com/@microsoft/tsdoc-config/-/tsdoc-config-0.16.2.tgz#b786bb4ead00d54f53839a458ce626c8548d3adf" + integrity sha512-OGiIzzoBLgWWR0UdRJX98oYO+XKGf7tiK4Zk6tQ/E4IJqGCe7dvkTvgDZV5cFJUzLGDOjeAXrnZoA6QkVySuxw== + dependencies: + "@microsoft/tsdoc" "0.14.2" + ajv "~6.12.6" + jju "~1.4.0" + resolve "~1.19.0" + +"@microsoft/tsdoc@0.14.2": + version "0.14.2" + resolved "https://registry.yarnpkg.com/@microsoft/tsdoc/-/tsdoc-0.14.2.tgz#c3ec604a0b54b9a9b87e9735dfc59e1a5da6a5fb" + integrity sha512-9b8mPpKrfeGRuhFH5iO1iwCLeIIsV6+H1sRfxbkoGXIyQE2BTsPd9zqSqQJ+pv5sJ/hT5M1zvOFL02MnEezFug== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -584,6 +626,38 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@rushstack/node-core-library@3.53.3": + version "3.53.3" + resolved "https://registry.yarnpkg.com/@rushstack/node-core-library/-/node-core-library-3.53.3.tgz#e78e0dc1545f6cd7d80b0408cf534aefc62fbbe2" + integrity sha512-H0+T5koi5MFhJUd5ND3dI3bwLhvlABetARl78L3lWftJVQEPyzcgTStvTTRiIM5mCltyTM8VYm6BuCtNUuxD0Q== + dependencies: + "@types/node" "12.20.24" + colors "~1.2.1" + fs-extra "~7.0.1" + import-lazy "~4.0.0" + jju "~1.4.0" + resolve "~1.17.0" + semver "~7.3.0" + z-schema "~5.0.2" + +"@rushstack/rig-package@0.3.17": + version "0.3.17" + resolved "https://registry.yarnpkg.com/@rushstack/rig-package/-/rig-package-0.3.17.tgz#687bd55603f2902447f3be246d93afac97095a1f" + integrity sha512-nxvAGeIMnHl1LlZSQmacgcRV4y1EYtgcDIrw6KkeVjudOMonlxO482PhDj3LVZEp6L7emSf6YSO2s5JkHlwfZA== + dependencies: + resolve "~1.17.0" + strip-json-comments "~3.1.1" + +"@rushstack/ts-command-line@4.13.1": + version "4.13.1" + resolved "https://registry.yarnpkg.com/@rushstack/ts-command-line/-/ts-command-line-4.13.1.tgz#148b644b627131480363b4853b558ba5eaa0d75c" + integrity sha512-UTQMRyy/jH1IS2U+6pyzyn9xQ2iMcoUKkTcZUzOP/aaMiKlWLwCTDiBVwhw/M1crDx6apF9CwyjuWO9r1SBdJQ== + dependencies: + "@types/argparse" "1.0.38" + argparse "~1.0.9" + colors "~1.2.1" + string-argv "~0.3.1" + "@sinonjs/commons@^1.7.0": version "1.8.6" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.6.tgz#80c516a4dc264c2a69115e7578d62581ff455ed9" @@ -603,6 +677,11 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== +"@types/argparse@1.0.38": + version "1.0.38" + resolved "https://registry.yarnpkg.com/@types/argparse/-/argparse-1.0.38.tgz#a81fd8606d481f873a3800c6ebae4f1d768a56a9" + integrity sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA== + "@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14": version "7.1.20" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.20.tgz#e168cdd612c92a2d335029ed62ac94c95b362359" @@ -703,6 +782,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.17.tgz#5c009e1d9c38f4a2a9d45c0b0c493fe6cdb4bcb5" integrity sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng== +"@types/node@12.20.24": + version "12.20.24" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.24.tgz#c37ac69cb2948afb4cef95f424fa0037971a9a5c" + integrity sha512-yxDeaQIAJlMav7fH5AQqPH1u8YIuhYJXYBzxaQ4PifsU0GDO38MSdmEDeRlIxrKbC6NbEaaEHDanWb+y30U8SQ== + "@types/normalize-package-data@^2.4.0": version "2.4.1" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301" @@ -1012,7 +1096,7 @@ ajv-keywords@^3.5.2: resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== -ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: +ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5, ajv@~6.12.6: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -1061,7 +1145,7 @@ anymatch@^3.0.3: normalize-path "^3.0.0" picomatch "^2.0.4" -argparse@^1.0.7: +argparse@^1.0.7, argparse@~1.0.9: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== @@ -1344,6 +1428,11 @@ color-name@~1.1.4: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +colors@~1.2.1: + version "1.2.5" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.2.5.tgz#89c7ad9a374bc030df8013241f68136ed8835afc" + integrity sha512-erNRLao/Y3Fv54qUa0LBB+//Uf3YwMUmdJinN20yMXm9zdKKqH9wt7R9IIVZ+K7ShzfpLV/Zg8+VyrBJYB4lpg== + combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: version "1.0.8" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" @@ -1356,6 +1445,11 @@ commander@^2.20.0: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== +commander@^9.4.1: + version "9.4.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-9.4.1.tgz#d1dd8f2ce6faf93147295c0df13c7c21141cfbdd" + integrity sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw== + compare-func@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-2.0.0.tgz#fb65e75edbddfd2e568554e8b5b05fff7a51fcb3" @@ -2121,6 +2215,15 @@ form-data@~2.3.2: combined-stream "^1.0.6" mime-types "^2.1.12" +fs-extra@~7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" + integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -2262,7 +2365,7 @@ globby@^11.1.0: merge2 "^1.4.1" slash "^3.0.0" -graceful-fs@^4.1.2, graceful-fs@^4.2.4, graceful-fs@^4.2.9: +graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.4, graceful-fs@^4.2.9: version "4.2.10" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== @@ -2394,6 +2497,11 @@ import-fresh@^3.0.0, import-fresh@^3.2.1: parent-module "^1.0.0" resolve-from "^4.0.0" +import-lazy@~4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-4.0.0.tgz#e8eb627483a0a43da3c03f3e35548be5cb0cc153" + integrity sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw== + import-local@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" @@ -2435,7 +2543,7 @@ is-arrayish@^0.2.1: resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== -is-core-module@^2.5.0, is-core-module@^2.9.0: +is-core-module@^2.1.0, is-core-module@^2.5.0, is-core-module@^2.9.0: version "2.11.0" resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144" integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw== @@ -2968,6 +3076,11 @@ jest@^27.3.1: import-local "^3.0.2" jest-cli "^27.5.1" +jju@~1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/jju/-/jju-1.4.0.tgz#a3abe2718af241a2b2904f84a625970f389ae32a" + integrity sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA== + js-sdsl@^4.1.4: version "4.2.0" resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.2.0.tgz#278e98b7bea589b8baaf048c20aeb19eb7ad09d0" @@ -3071,6 +3184,13 @@ json5@^2.2.1: resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.2.tgz#64471c5bdcc564c18f7c1d4df2e2297f2457c5ab" integrity sha512-46Tk9JiOL2z7ytNQWFLpj99RZkVgeHf87yGQKsIkaPz1qSH9UczKH1rO7K3wgRselo0tYMUNfecYpm/p1vC7tQ== +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg== + optionalDependencies: + graceful-fs "^4.1.6" + jsonparse@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" @@ -3172,6 +3292,16 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" +lodash.get@^4.4.2: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" + integrity sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ== + +lodash.isequal@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" + integrity sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ== + lodash.ismatch@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37" @@ -3182,7 +3312,7 @@ lodash.merge@^4.6.2: resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash@^4.17.15, lodash@^4.7.0: +lodash@^4.17.15, lodash@^4.7.0, lodash@~4.17.15: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -3532,7 +3662,7 @@ path-key@^3.0.0, path-key@^3.1.0: resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== -path-parse@^1.0.7: +path-parse@^1.0.6, path-parse@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== @@ -3808,6 +3938,21 @@ resolve@^1.10.0, resolve@^1.10.1, resolve@^1.20.0: path-parse "^1.0.7" supports-preserve-symlinks-flag "^1.0.0" +resolve@~1.17.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" + integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + dependencies: + path-parse "^1.0.6" + +resolve@~1.19.0: + version "1.19.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c" + integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg== + dependencies: + is-core-module "^2.1.0" + path-parse "^1.0.6" + reusify@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" @@ -3868,7 +4013,7 @@ semver@^6.0.0, semver@^6.1.0, semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^7.1.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.7: +semver@^7.1.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.7, semver@~7.3.0: version "7.3.8" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== @@ -4014,6 +4159,11 @@ standard-version@^9.3.2: stringify-package "^1.0.1" yargs "^16.0.0" +string-argv@~0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da" + integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg== + string-length@^4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/string-length/-/string-length-4.0.2.tgz#a8a8dc7bd5c1a82b9b3c8b87e125f66871b6e57a" @@ -4079,7 +4229,7 @@ strip-indent@^3.0.0: dependencies: min-indent "^1.0.0" -strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: +strip-json-comments@^3.1.0, strip-json-comments@^3.1.1, strip-json-comments@~3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== @@ -4333,11 +4483,21 @@ typescript@^4.9.4: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.4.tgz#a2a3d2756c079abda241d75f149df9d561091e78" integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg== +typescript@~4.8.4: + version "4.8.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6" + integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ== + uglify-js@^3.1.4: version "3.17.4" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" integrity sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g== +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== + universalify@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.2.0.tgz#6451760566fa857534745ab1dde952d1b1761be0" @@ -4393,6 +4553,11 @@ validate-npm-package-license@^3.0.1: spdx-correct "^3.0.0" spdx-expression-parse "^3.0.0" +validator@^13.7.0: + version "13.7.0" + resolved "https://registry.yarnpkg.com/validator/-/validator-13.7.0.tgz#4f9658ba13ba8f3d82ee881d3516489ea85c0857" + integrity sha512-nYXQLCBkpJ8X6ltALua9dRrZDHVYxjJ1wgskNt1lH9fzGjs3tgojGSCBjmEPwkWS1y29+DrizMTW19Pr9uB2nw== + verror@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" @@ -4595,3 +4760,14 @@ yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== + +z-schema@~5.0.2: + version "5.0.5" + resolved "https://registry.yarnpkg.com/z-schema/-/z-schema-5.0.5.tgz#6805a48c5366a6125cae0e58752babfd503daf32" + integrity sha512-D7eujBWkLa3p2sIpJA0d1pr7es+a7m0vFAnZLlCEKq/Ij2k0MLi9Br2UPxoxdYystm5K1yeBGzub0FlYUEWj2Q== + dependencies: + lodash.get "^4.4.2" + lodash.isequal "^4.5.0" + validator "^13.7.0" + optionalDependencies: + commander "^9.4.1" From 8216851a619875b9aa13f23c6c431ffa78793854 Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Fri, 23 Dec 2022 21:36:22 +0000 Subject: [PATCH 08/13] type cast digestType --- lib/getHashDigest.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/getHashDigest.ts b/lib/getHashDigest.ts index 201c819..49a0966 100644 --- a/lib/getHashDigest.ts +++ b/lib/getHashDigest.ts @@ -1,4 +1,4 @@ -import type { Hash } from "crypto"; +import type { Hash, BinaryToTextEncoding } from "crypto"; const baseEncodeTables = { 26: "abcdefghijklmnopqrstuvwxyz", @@ -152,8 +152,8 @@ export default function getHashDigest( maxLength ); } else { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - return hash.digest(digestType || "hex").substr(0, maxLength); + return ( + hash.digest((digestType as BinaryToTextEncoding) || "hex") as string + ).substr(0, maxLength); } } From c1d8c6e62e96e33a48bc4b7baf84c35d8f3787aa Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Tue, 3 Jan 2023 15:34:52 -0800 Subject: [PATCH 09/13] Clean up some hash typings. --- lib/getHashDigest.ts | 6 +++--- lib/hash/BatchedHash.ts | 11 ++++++++--- lib/hash/wasm-hash.ts | 15 ++++++++++----- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/getHashDigest.ts b/lib/getHashDigest.ts index 49a0966..953a183 100644 --- a/lib/getHashDigest.ts +++ b/lib/getHashDigest.ts @@ -1,4 +1,4 @@ -import type { Hash, BinaryToTextEncoding } from "crypto"; +import type { BinaryToTextEncoding } from "crypto"; const baseEncodeTables = { 26: "abcdefghijklmnopqrstuvwxyz", @@ -95,7 +95,7 @@ export default function getHashDigest( } } - hash = new BatchedHash(createXXHash64() as unknown as Hash); + hash = new BatchedHash(createXXHash64()); } else if (algorithm === "md4") { if (createMd4 === undefined) { createMd4 = require("./hash/md4").create; @@ -105,7 +105,7 @@ export default function getHashDigest( } } - hash = new BatchedHash(createMd4() as unknown as Hash); + hash = new BatchedHash(createMd4()); } else if (algorithm === "native-md4") { if (typeof crypto === "undefined") { crypto = require("crypto"); diff --git a/lib/hash/BatchedHash.ts b/lib/hash/BatchedHash.ts index 5e1516c..ee194ed 100644 --- a/lib/hash/BatchedHash.ts +++ b/lib/hash/BatchedHash.ts @@ -1,12 +1,17 @@ -import type { Hash, Encoding, BinaryToTextEncoding } from "crypto"; +import type { Encoding, BinaryToTextEncoding } from "crypto"; import { MAX_SHORT_STRING } from "./wasm-hash"; +export interface IHashLike { + update(data: string | Buffer, inputEncoding?: Encoding): this; + digest(encoding?: BinaryToTextEncoding): string | Buffer; +} + export class BatchedHash { public string?: string; public encoding?: Encoding; - public readonly hash: Hash; + public readonly hash: IHashLike; - constructor(hash: Hash) { + constructor(hash: IHashLike) { this.string = undefined; this.encoding = undefined; this.hash = hash; diff --git a/lib/hash/wasm-hash.ts b/lib/hash/wasm-hash.ts index d846515..2437d4b 100644 --- a/lib/hash/wasm-hash.ts +++ b/lib/hash/wasm-hash.ts @@ -1,5 +1,7 @@ import { BinaryToTextEncoding } from "crypto"; +import type { IHashLike } from "./BatchedHash"; + /* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra @@ -11,7 +13,7 @@ import { BinaryToTextEncoding } from "crypto"; // ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64 export const MAX_SHORT_STRING: number = Math.floor((65536 - 64) / 4) & ~3; -export class WasmHash { +export class WasmHash implements IHashLike { /** * @param {WebAssembly.Instance} instance wasm instance * @param {WebAssembly.Instance[]} instancesPool pool of instances @@ -200,15 +202,16 @@ export const create = ( chunkSize: number, digestSize: number ) => { + let result: WasmHash | undefined; if (instancesPool.length > 0) { - const old = instancesPool.pop(); + result = instancesPool.pop(); // old is possibly undefined // protect reset call here - old && old.reset(); + result?.reset(); + } - return old; - } else { + if (result === undefined) { return new WasmHash( new WebAssembly.Instance(wasmModule), instancesPool, @@ -216,4 +219,6 @@ export const create = ( digestSize ); } + + return result; }; From 9e8881358b6351c43865ddb8ea766411f37856c7 Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Tue, 3 Jan 2023 15:41:08 -0800 Subject: [PATCH 10/13] Update lib/interpolateName.ts Co-authored-by: Ian Clanton-Thuon --- lib/interpolateName.ts | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/interpolateName.ts b/lib/interpolateName.ts index bbd00a8..9a14aaa 100644 --- a/lib/interpolateName.ts +++ b/lib/interpolateName.ts @@ -116,19 +116,25 @@ export default function interpolateName( }); } + interface ILoaderContextOptions { + customInterpolateName( + this: LoaderContext, + url: string, + name: string | ((resourcePath: string, resourceQuery?: string) => string), + options?: IInterpolateNameOptions + ): string; + } + type LegacyLoaderContext = LoaderContext & { + options?: ILoaderContextOptions; + }; + const loaderContextOptions: ILoaderContextOptions | undefined = ( + loaderContext as LegacyLoaderContext + ).options; if ( - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore LoaderContext doesn't even have options defined on it? - // If we chagned this to be `loaderContext.getOptions()` it would still not have - // the customInterpolateName function defined on it. - typeof loaderContext.options === "object" && - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - typeof loaderContext.options.customInterpolateName === "function" + typeof loaderContextOptions === "object" && + typeof loaderContextOptions.customInterpolateName === "function" ) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - url = loaderContext.options.customInterpolateName.call( + url = loaderContextOptions.customInterpolateName.call( loaderContext, url, name, From 95c938d6904a9437d9d1ecf10d775a1b24d37975 Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Tue, 3 Jan 2023 23:56:21 +0000 Subject: [PATCH 11/13] fix warnings from api-extractor report --- lib/getHashDigest.ts | 11 +++-------- lib/hash/wasm-hash.ts | 2 +- lib/index.ts | 3 +++ lib/interpolateName.ts | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/getHashDigest.ts b/lib/getHashDigest.ts index 953a183..b0dceb5 100644 --- a/lib/getHashDigest.ts +++ b/lib/getHashDigest.ts @@ -1,6 +1,6 @@ import type { BinaryToTextEncoding } from "crypto"; -const baseEncodeTables = { +export const baseEncodeTables = { 26: "abcdefghijklmnopqrstuvwxyz", 32: "123456789abcdefghjkmnpqrstuvwxyz", // no 0lio 36: "0123456789abcdefghijklmnopqrstuvwxyz", @@ -11,14 +11,9 @@ const baseEncodeTables = { 64: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_", }; -type BaseEncoding = keyof typeof baseEncodeTables; -type DigestType = `base${BaseEncoding}`; +export type BaseEncoding = keyof typeof baseEncodeTables; +export type DigestType = `base${BaseEncoding}`; -/** - * @param {Uint32Array} uint32Array Treated as a long base-0x100000000 number, little endian - * @param {number} divisor The divisor - * @return {number} Modulo (remainder) of the division - */ function divmod32(uint32Array: Uint32Array, divisor: number): number { let carry = 0; for (let i = uint32Array.length - 1; i >= 0; i--) { diff --git a/lib/hash/wasm-hash.ts b/lib/hash/wasm-hash.ts index 2437d4b..e073d54 100644 --- a/lib/hash/wasm-hash.ts +++ b/lib/hash/wasm-hash.ts @@ -206,7 +206,7 @@ export const create = ( if (instancesPool.length > 0) { result = instancesPool.pop(); - // old is possibly undefined + // result is possibly undefined // protect reset call here result?.reset(); } diff --git a/lib/index.ts b/lib/index.ts index 062c108..6f316b4 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -2,3 +2,6 @@ export { default as isUrlRequest } from "./isUrlRequest"; export { default as urlToRequest } from "./urlToRequest"; export { default as getHashDigest } from "./getHashDigest"; export { default as interpolateName } from "./interpolateName"; + +export type { IInterpolateNameOptions } from "./interpolateName"; +export type { DigestType, BaseEncoding, baseEncodeTables } from "./getHashDigest"; \ No newline at end of file diff --git a/lib/interpolateName.ts b/lib/interpolateName.ts index 9a14aaa..51e7b54 100644 --- a/lib/interpolateName.ts +++ b/lib/interpolateName.ts @@ -2,7 +2,7 @@ import type { LoaderContext } from "webpack"; import path from "path"; import getHashDigest from "./getHashDigest"; -interface IInterpolateNameOptions { +export interface IInterpolateNameOptions { content?: Buffer; context?: string; regExp?: string; From 3505c4a045e5331547be28b036cb127b66c0e137 Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Tue, 3 Jan 2023 15:57:50 -0800 Subject: [PATCH 12/13] Remove types from JSDoc. --- lib/getHashDigest.ts | 5 +++++ lib/hash/wasm-hash.ts | 17 ++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/getHashDigest.ts b/lib/getHashDigest.ts index b0dceb5..9ab5414 100644 --- a/lib/getHashDigest.ts +++ b/lib/getHashDigest.ts @@ -14,6 +14,11 @@ export const baseEncodeTables = { export type BaseEncoding = keyof typeof baseEncodeTables; export type DigestType = `base${BaseEncoding}`; +/** + * @param uint32Array - Treated as a long base-0x100000000 number, little endian + * @param divisor - The divisor + * @return Modulo (remainder) of the division + */ function divmod32(uint32Array: Uint32Array, divisor: number): number { let carry = 0; for (let i = uint32Array.length - 1; i >= 0; i--) { diff --git a/lib/hash/wasm-hash.ts b/lib/hash/wasm-hash.ts index e073d54..fc6ccd7 100644 --- a/lib/hash/wasm-hash.ts +++ b/lib/hash/wasm-hash.ts @@ -15,10 +15,10 @@ export const MAX_SHORT_STRING: number = Math.floor((65536 - 64) / 4) & ~3; export class WasmHash implements IHashLike { /** - * @param {WebAssembly.Instance} instance wasm instance - * @param {WebAssembly.Instance[]} instancesPool pool of instances - * @param {number} chunkSize size of data chunks passed to wasm - * @param {number} digestSize size of digest returned by wasm + * @param instance - wasm instance + * @param instancesPool - pool of instances + * @param chunkSize - size of data chunks passed to wasm + * @param digestSize - size of digest returned by wasm */ exports: any; mem: Buffer; @@ -51,9 +51,9 @@ export class WasmHash implements IHashLike { } /** - * @param {Buffer | string} data data - * @param {BufferEncoding=} encoding encoding - * @returns {this} itself + * @param data - data + * @param encoding - encoding + * @returns itself */ update(data: Buffer | string, encoding: BufferEncoding): this { if (typeof data === "string") { @@ -128,8 +128,7 @@ export class WasmHash implements IHashLike { } /** - * @param {Buffer} data data - * @returns {void} + * @param data - data */ _updateWithBuffer(data: Buffer): void { const { exports, buffered, mem } = this; From dca41c623175be9085365f37dea49e995871b9be Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Wed, 4 Jan 2023 00:11:16 +0000 Subject: [PATCH 13/13] remove exports of types --- lib/getHashDigest.ts | 14 +++++++++----- lib/index.ts | 2 +- lib/interpolateName.ts | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/getHashDigest.ts b/lib/getHashDigest.ts index 9ab5414..9e8d28a 100644 --- a/lib/getHashDigest.ts +++ b/lib/getHashDigest.ts @@ -1,6 +1,6 @@ import type { BinaryToTextEncoding } from "crypto"; -export const baseEncodeTables = { +const baseEncodeTables = { 26: "abcdefghijklmnopqrstuvwxyz", 32: "123456789abcdefghjkmnpqrstuvwxyz", // no 0lio 36: "0123456789abcdefghijklmnopqrstuvwxyz", @@ -11,13 +11,17 @@ export const baseEncodeTables = { 64: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_", }; -export type BaseEncoding = keyof typeof baseEncodeTables; +type BaseEncoding = keyof typeof baseEncodeTables; + +/** + * @public + */ export type DigestType = `base${BaseEncoding}`; /** - * @param uint32Array - Treated as a long base-0x100000000 number, little endian - * @param divisor - The divisor - * @return Modulo (remainder) of the division + * @param {Uint32Array} uint32Array Treated as a long base-0x100000000 number, little endian + * @param {number} divisor The divisor + * @return {number} Modulo (remainder) of the division */ function divmod32(uint32Array: Uint32Array, divisor: number): number { let carry = 0; diff --git a/lib/index.ts b/lib/index.ts index 6f316b4..b3c899b 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -4,4 +4,4 @@ export { default as getHashDigest } from "./getHashDigest"; export { default as interpolateName } from "./interpolateName"; export type { IInterpolateNameOptions } from "./interpolateName"; -export type { DigestType, BaseEncoding, baseEncodeTables } from "./getHashDigest"; \ No newline at end of file +export type { DigestType } from "./getHashDigest"; \ No newline at end of file diff --git a/lib/interpolateName.ts b/lib/interpolateName.ts index 51e7b54..7c5feef 100644 --- a/lib/interpolateName.ts +++ b/lib/interpolateName.ts @@ -2,6 +2,9 @@ import type { LoaderContext } from "webpack"; import path from "path"; import getHashDigest from "./getHashDigest"; +/** + * @public + */ export interface IInterpolateNameOptions { content?: Buffer; context?: string;