diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 5f9c26946463..d90c553c0802 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -628,9 +628,9 @@ } }, "node_modules/@humanwhocodes/retry": { - "version": "0.4.2", - "resolved": "https://npm.skia.org/chrome-devtools/@humanwhocodes%2fretry/-/retry-0.4.2.tgz", - "integrity": "sha512-xeO57FpIu4p1Ri3Jq/EXq4ClRm86dVF2z/+kvFnyqVYRavTZmaFaUBbWCOuuTh0o/g7DSsk6kc2vrS4Vl5oPOQ==", + "version": "0.4.3", + "resolved": "https://npm.skia.org/chrome-devtools/@humanwhocodes%2fretry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", "dev": true, "license": "Apache-2.0", "engines": { @@ -811,9 +811,9 @@ } }, "node_modules/@puppeteer/browsers/node_modules/debug": { - "version": "4.4.0", - "resolved": "https://npm.skia.org/chrome-devtools/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "version": "4.4.1", + "resolved": "https://npm.skia.org/chrome-devtools/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1018,9 +1018,9 @@ } }, "node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "version": "4.2.1", + "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true, "license": "Apache-2.0", "engines": { @@ -1365,9 +1365,9 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://npm.skia.org/chrome-devtools/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "version": "2.0.2", + "resolved": "https://npm.skia.org/chrome-devtools/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1433,9 +1433,9 @@ } }, "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "version": "4.2.1", + "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true, "license": "Apache-2.0", "engines": { @@ -1915,7 +1915,9 @@ "license": "ISC" }, "node_modules/brace-expansion": { - "version": "1.1.11", + "version": "1.1.12", + "resolved": "https://npm.skia.org/chrome-devtools/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", "dev": true, "license": "MIT", "dependencies": { @@ -2021,14 +2023,14 @@ } }, "node_modules/cacheable": { - "version": "1.8.9", - "resolved": "https://npm.skia.org/chrome-devtools/cacheable/-/cacheable-1.8.9.tgz", - "integrity": "sha512-FicwAUyWnrtnd4QqYAoRlNs44/a1jTL7XDKqm5gJ90wz1DQPlC7U2Rd1Tydpv+E7WAr4sQHuw8Q8M3nZMAyecQ==", + "version": "1.10.0", + "resolved": "https://npm.skia.org/chrome-devtools/cacheable/-/cacheable-1.10.0.tgz", + "integrity": "sha512-SSgQTAnhd7WlJXnGlIi4jJJOiHzgnM5wRMEPaXAU4kECTAMpBoYKoZ9i5zHmclIEZbxcu3j7yY/CF8DTmwIsHg==", "dev": true, "license": "MIT", "dependencies": { - "hookified": "^1.7.1", - "keyv": "^5.3.1" + "hookified": "^1.8.2", + "keyv": "^5.3.3" } }, "node_modules/call-bind": { @@ -3642,9 +3644,9 @@ } }, "node_modules/eslint/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "version": "4.2.1", + "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true, "license": "Apache-2.0", "engines": { @@ -3719,9 +3721,9 @@ } }, "node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "version": "4.2.1", + "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true, "license": "Apache-2.0", "engines": { @@ -4418,9 +4420,9 @@ } }, "node_modules/hookified": { - "version": "1.7.1", - "resolved": "https://npm.skia.org/chrome-devtools/hookified/-/hookified-1.7.1.tgz", - "integrity": "sha512-OXcdHsXeOiD7OJ5zvWj8Oy/6RCdLwntAX+wUrfemNcMGn6sux4xbEHi2QXwqePYhjQ/yvxxq2MvCRirdlHscBw==", + "version": "1.9.1", + "resolved": "https://npm.skia.org/chrome-devtools/hookified/-/hookified-1.9.1.tgz", + "integrity": "sha512-u3pxtGhKjcSXnGm1CX6aXS9xew535j3lkOCegbA6jdyh0BaAjTbXI4aslKstCr6zUNtoCxFGFKwjbSHdGrMB8g==", "dev": true, "license": "MIT" }, @@ -5410,9 +5412,9 @@ } }, "node_modules/keyv": { - "version": "5.3.2", - "resolved": "https://npm.skia.org/chrome-devtools/keyv/-/keyv-5.3.2.tgz", - "integrity": "sha512-Lji2XRxqqa5Wg+CHLVfFKBImfJZ4pCSccu9eVWK6w4c2SDFLd8JAn1zqTuSFnsxb7ope6rMsnIHfp+eBbRBRZQ==", + "version": "5.3.4", + "resolved": "https://npm.skia.org/chrome-devtools/keyv/-/keyv-5.3.4.tgz", + "integrity": "sha512-ypEvQvInNpUe+u+w8BIcPkQvEqXquyyibWE/1NB5T2BTzIpS5cGEV1LZskDzPSTvNAaT4+5FutvzlvnkxOSKlw==", "dev": true, "license": "MIT", "dependencies": { @@ -7180,9 +7182,9 @@ } }, "node_modules/puppeteer-core/node_modules/debug": { - "version": "4.4.0", - "resolved": "https://npm.skia.org/chrome-devtools/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "version": "4.4.1", + "resolved": "https://npm.skia.org/chrome-devtools/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", "dev": true, "license": "MIT", "dependencies": { @@ -7596,9 +7598,9 @@ "license": "MIT" }, "node_modules/semver": { - "version": "7.7.1", - "resolved": "https://npm.skia.org/chrome-devtools/semver/-/semver-7.7.1.tgz", - "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "version": "7.7.2", + "resolved": "https://npm.skia.org/chrome-devtools/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", "dev": true, "license": "ISC", "bin": { @@ -8340,31 +8342,31 @@ } }, "node_modules/stylelint/node_modules/file-entry-cache": { - "version": "10.0.7", - "resolved": "https://npm.skia.org/chrome-devtools/file-entry-cache/-/file-entry-cache-10.0.7.tgz", - "integrity": "sha512-txsf5fu3anp2ff3+gOJJzRImtrtm/oa9tYLN0iTuINZ++EyVR/nRrg2fKYwvG/pXDofcrvvb0scEbX3NyW/COw==", + "version": "10.1.1", + "resolved": "https://npm.skia.org/chrome-devtools/file-entry-cache/-/file-entry-cache-10.1.1.tgz", + "integrity": "sha512-zcmsHjg2B2zjuBgjdnB+9q0+cWcgWfykIcsDkWDB4GTPtl1eXUA+gTI6sO0u01AqK3cliHryTU55/b2Ow1hfZg==", "dev": true, "license": "MIT", "dependencies": { - "flat-cache": "^6.1.7" + "flat-cache": "^6.1.10" } }, "node_modules/stylelint/node_modules/flat-cache": { - "version": "6.1.7", - "resolved": "https://npm.skia.org/chrome-devtools/flat-cache/-/flat-cache-6.1.7.tgz", - "integrity": "sha512-qwZ4xf1v1m7Rc9XiORly31YaChvKt6oNVHuqqZcoED/7O+ToyNVGobKsIAopY9ODcWpEDKEBAbrSOCBHtNQvew==", + "version": "6.1.10", + "resolved": "https://npm.skia.org/chrome-devtools/flat-cache/-/flat-cache-6.1.10.tgz", + "integrity": "sha512-B6/v1f0NwjxzmeOhzfXPGWpKBVA207LS7lehaVKQnFrVktcFRfkzjZZ2gwj2i1TkEUMQht7ZMJbABUT5N+V1Nw==", "dev": true, "license": "MIT", "dependencies": { - "cacheable": "^1.8.9", + "cacheable": "^1.10.0", "flatted": "^3.3.3", - "hookified": "^1.7.1" + "hookified": "^1.9.1" } }, "node_modules/stylelint/node_modules/ignore": { - "version": "7.0.3", - "resolved": "https://npm.skia.org/chrome-devtools/ignore/-/ignore-7.0.3.tgz", - "integrity": "sha512-bAH5jbK/F3T3Jls4I0SO1hmPR0dKU0a7+SY6n1yzRtG54FLO8d6w/nxLFX2Nb7dBu6cCWXPaAME6cYqFUMmuCA==", + "version": "7.0.5", + "resolved": "https://npm.skia.org/chrome-devtools/ignore/-/ignore-7.0.5.tgz", + "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", "dev": true, "license": "MIT", "engines": { @@ -8379,9 +8381,9 @@ "license": "CC0-1.0" }, "node_modules/stylelint/node_modules/postcss": { - "version": "8.5.3", - "resolved": "https://npm.skia.org/chrome-devtools/postcss/-/postcss-8.5.3.tgz", - "integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==", + "version": "8.5.6", + "resolved": "https://npm.skia.org/chrome-devtools/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", "dev": true, "funding": [ { @@ -8399,7 +8401,7 @@ ], "license": "MIT", "dependencies": { - "nanoid": "^3.3.8", + "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" }, diff --git a/node_modules/@humanwhocodes/retry/dist/retrier.cjs b/node_modules/@humanwhocodes/retry/dist/retrier.cjs index 33f7fbecaa45..635e1e089dfc 100644 --- a/node_modules/@humanwhocodes/retry/dist/retrier.cjs +++ b/node_modules/@humanwhocodes/retry/dist/retrier.cjs @@ -345,11 +345,12 @@ class Retrier { /** * Adds a new retry job to the queue. - * @param {Function} fn The function to call. + * @template {(...args: unknown[]) => Promise} Func + * @template {Awaited>} RetVal + * @param {Func} fn The function to call. * @param {object} [options] The options for the job. * @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation. - * @returns {Promise} A promise that resolves when the queue is - * processed. + * @returns {Promise} A promise that resolves when the queue is processed. */ retry(fn, { signal } = {}) { diff --git a/node_modules/@humanwhocodes/retry/dist/retrier.d.cts b/node_modules/@humanwhocodes/retry/dist/retrier.d.cts index 4b60d6f06e1a..2d3811efac30 100644 --- a/node_modules/@humanwhocodes/retry/dist/retrier.d.cts +++ b/node_modules/@humanwhocodes/retry/dist/retrier.d.cts @@ -32,14 +32,15 @@ export class Retrier { get working(): number; /** * Adds a new retry job to the queue. - * @param {Function} fn The function to call. + * @template {(...args: unknown[]) => Promise} Func + * @template {Awaited>} RetVal + * @param {Func} fn The function to call. * @param {object} [options] The options for the job. * @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation. - * @returns {Promise} A promise that resolves when the queue is - * processed. + * @returns {Promise} A promise that resolves when the queue is processed. */ - retry(fn: Function, { signal }?: { + retry Promise, RetVal extends Awaited>>(fn: Func, { signal }?: { signal?: AbortSignal | undefined; - } | undefined): Promise; + } | undefined): Promise; #private; } diff --git a/node_modules/@humanwhocodes/retry/dist/retrier.d.ts b/node_modules/@humanwhocodes/retry/dist/retrier.d.ts index 4b60d6f06e1a..2d3811efac30 100644 --- a/node_modules/@humanwhocodes/retry/dist/retrier.d.ts +++ b/node_modules/@humanwhocodes/retry/dist/retrier.d.ts @@ -32,14 +32,15 @@ export class Retrier { get working(): number; /** * Adds a new retry job to the queue. - * @param {Function} fn The function to call. + * @template {(...args: unknown[]) => Promise} Func + * @template {Awaited>} RetVal + * @param {Func} fn The function to call. * @param {object} [options] The options for the job. * @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation. - * @returns {Promise} A promise that resolves when the queue is - * processed. + * @returns {Promise} A promise that resolves when the queue is processed. */ - retry(fn: Function, { signal }?: { + retry Promise, RetVal extends Awaited>>(fn: Func, { signal }?: { signal?: AbortSignal | undefined; - } | undefined): Promise; + } | undefined): Promise; #private; } diff --git a/node_modules/@humanwhocodes/retry/dist/retrier.js b/node_modules/@humanwhocodes/retry/dist/retrier.js index f1a8c87bfb25..29c9d3ea720d 100644 --- a/node_modules/@humanwhocodes/retry/dist/retrier.js +++ b/node_modules/@humanwhocodes/retry/dist/retrier.js @@ -344,11 +344,12 @@ class Retrier { /** * Adds a new retry job to the queue. - * @param {Function} fn The function to call. + * @template {(...args: unknown[]) => Promise} Func + * @template {Awaited>} RetVal + * @param {Func} fn The function to call. * @param {object} [options] The options for the job. * @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation. - * @returns {Promise} A promise that resolves when the queue is - * processed. + * @returns {Promise} A promise that resolves when the queue is processed. */ retry(fn, { signal } = {}) { diff --git a/node_modules/@humanwhocodes/retry/dist/retrier.mjs b/node_modules/@humanwhocodes/retry/dist/retrier.mjs index 2457a2f4a992..a05cd0d17673 100644 --- a/node_modules/@humanwhocodes/retry/dist/retrier.mjs +++ b/node_modules/@humanwhocodes/retry/dist/retrier.mjs @@ -343,11 +343,12 @@ class Retrier { /** * Adds a new retry job to the queue. - * @param {Function} fn The function to call. + * @template {(...args: unknown[]) => Promise} Func + * @template {Awaited>} RetVal + * @param {Func} fn The function to call. * @param {object} [options] The options for the job. * @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation. - * @returns {Promise} A promise that resolves when the queue is - * processed. + * @returns {Promise} A promise that resolves when the queue is processed. */ retry(fn, { signal } = {}) { diff --git a/node_modules/@humanwhocodes/retry/package.json b/node_modules/@humanwhocodes/retry/package.json index 54de0bc2f427..df8e94376ff3 100644 --- a/node_modules/@humanwhocodes/retry/package.json +++ b/node_modules/@humanwhocodes/retry/package.json @@ -1,6 +1,6 @@ { "name": "@humanwhocodes/retry", - "version": "0.4.2", + "version": "0.4.3", "description": "A utility to retry failed async methods.", "type": "module", "main": "dist/retrier.cjs", diff --git a/node_modules/@puppeteer/browsers/node_modules/debug/package.json b/node_modules/@puppeteer/browsers/node_modules/debug/package.json index 60dfcf57cae4..afc2f8b615b2 100644 --- a/node_modules/@puppeteer/browsers/node_modules/debug/package.json +++ b/node_modules/@puppeteer/browsers/node_modules/debug/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.4.0", + "version": "4.4.1", "repository": { "type": "git", "url": "git://github.com/debug-js/debug.git" @@ -26,7 +26,7 @@ "scripts": { "lint": "xo", "test": "npm run test:node && npm run test:browser && npm run lint", - "test:node": "istanbul cover _mocha -- test.js test.node.js", + "test:node": "mocha test.js test.node.js", "test:browser": "karma start --single-run", "test:coverage": "cat ./coverage/lcov.info | coveralls" }, @@ -37,7 +37,6 @@ "brfs": "^2.0.1", "browserify": "^16.2.3", "coveralls": "^3.0.2", - "istanbul": "^0.4.5", "karma": "^3.1.4", "karma-browserify": "^6.0.0", "karma-chrome-launcher": "^2.2.0", diff --git a/node_modules/@puppeteer/browsers/node_modules/debug/src/browser.js b/node_modules/@puppeteer/browsers/node_modules/debug/src/browser.js index df8e179e8b5d..5993451b82e6 100644 --- a/node_modules/@puppeteer/browsers/node_modules/debug/src/browser.js +++ b/node_modules/@puppeteer/browsers/node_modules/debug/src/browser.js @@ -219,7 +219,7 @@ function save(namespaces) { function load() { let r; try { - r = exports.storage.getItem('debug'); + r = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ; } catch (error) { // Swallow // XXX (@Qix-) should we be logging these? diff --git a/node_modules/@puppeteer/browsers/node_modules/debug/src/common.js b/node_modules/@puppeteer/browsers/node_modules/debug/src/common.js index 528c7ecf417c..141cb578b772 100644 --- a/node_modules/@puppeteer/browsers/node_modules/debug/src/common.js +++ b/node_modules/@puppeteer/browsers/node_modules/debug/src/common.js @@ -168,7 +168,7 @@ function setup(env) { const split = (typeof namespaces === 'string' ? namespaces : '') .trim() - .replace(' ', ',') + .replace(/\s+/g, ',') .split(',') .filter(Boolean); diff --git a/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/README.md b/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/README.md index 3cbbdd39d0ad..aa860ba5774f 100644 --- a/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/README.md +++ b/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/README.md @@ -109,11 +109,12 @@ Welcome. See [ESLint contribution guidelines](https://eslint.org/docs/developer- The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate) to get your logo on our READMEs and [website](https://eslint.org/sponsors). -

Platinum Sponsors

+

Diamond Sponsors

+

AG Grid

Platinum Sponsors

Automattic Airbnb

Gold Sponsors

-

trunk.io

Silver Sponsors

-

JetBrains Liftoff American Express Workleap

Bronze Sponsors

-

WordHint Anagram Solver Icons8 Discord GitBook Nx HeroCoders

+

Qlty Software trunk.io Shopify

Silver Sponsors

+

Vite Liftoff American Express StackBlitz

Bronze Sponsors

+

Sentry Syntax Cybozu Anagram Solver Icons8 Discord GitBook Neko Nx Mercedes-Benz Group HeroCoders LambdaTest

Technology Sponsors

Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.

Netlify Algolia 1Password

diff --git a/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs b/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs index 7f58e49bcd4f..afc433c7cd5b 100644 --- a/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs +++ b/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs @@ -102,8 +102,8 @@ const KEYS = { "attributes" ], ExportSpecifier: [ - "exported", - "local" + "local", + "exported" ], ExpressionStatement: [ "expression" diff --git a/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts b/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts index a8684341f1cf..34253c96c3dd 100644 --- a/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts +++ b/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts @@ -24,4 +24,5 @@ declare function unionWith(additionalKeys: VisitorKeys): VisitorKeys; type VisitorKeys = VisitorKeys$1; -export { KEYS, type VisitorKeys, getKeys, unionWith }; +export { KEYS, getKeys, unionWith }; +export type { VisitorKeys }; diff --git a/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/lib/visitor-keys.js b/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/lib/visitor-keys.js index 41feb4b2f8a9..c891e040af32 100644 --- a/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/lib/visitor-keys.js +++ b/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/lib/visitor-keys.js @@ -100,8 +100,8 @@ const KEYS = { "attributes" ], ExportSpecifier: [ - "exported", - "local" + "local", + "exported" ], ExpressionStatement: [ "expression" diff --git a/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/package.json b/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/package.json index 4dc2123dbaf0..852e4ddb18cc 100644 --- a/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/package.json +++ b/node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "eslint-visitor-keys", - "version": "4.2.0", + "version": "4.2.1", "description": "Constants and utilities about visitor keys to traverse AST.", "type": "module", "main": "dist/eslint-visitor-keys.cjs", @@ -29,12 +29,9 @@ "@types/estree": "^0.0.51", "@types/estree-jsx": "^0.0.1", "@typescript-eslint/parser": "^8.7.0", - "c8": "^7.11.0", - "chai": "^4.3.6", "eslint-release": "^3.2.0", "esquery": "^1.4.0", "json-diff": "^0.7.3", - "mocha": "^9.2.1", "opener": "^1.5.2", "rollup": "^4.22.4", "rollup-plugin-dts": "^6.1.1", @@ -55,9 +52,15 @@ "test:open-coverage": "c8 report --reporter lcov && opener coverage/lcov-report/index.html", "test:types": "tsd" }, - "repository": "eslint/js", + "repository": { + "type": "git", + "url": "https://github.com/eslint/js.git", + "directory": "packages/eslint-visitor-keys" + }, "funding": "https://opencollective.com/eslint", - "keywords": [], + "keywords": [ + "eslint" + ], "author": "Toru Nagashima (https://github.com/mysticatea)", "license": "Apache-2.0", "bugs": { diff --git a/node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion/index.js b/node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion/index.js index 4af9ddee463f..a27f81ce041e 100644 --- a/node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion/index.js +++ b/node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion/index.js @@ -116,7 +116,7 @@ function expand(str, isTop) { var isOptions = m.body.indexOf(',') >= 0; if (!isSequence && !isOptions) { // {a},b} - if (m.post.match(/,.*\}/)) { + if (m.post.match(/,(?!,).*\}/)) { str = m.pre + '{' + m.body + escClose + m.post; return expand(str); } diff --git a/node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion/package.json b/node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion/package.json index 7097d41e39de..c7eee3451100 100644 --- a/node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion/package.json +++ b/node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion/package.json @@ -1,7 +1,7 @@ { "name": "brace-expansion", "description": "Brace expansion as known from sh/bash", - "version": "2.0.1", + "version": "2.0.2", "repository": { "type": "git", "url": "git://github.com/juliangruber/brace-expansion.git" @@ -42,5 +42,8 @@ "iphone/6.0..latest", "android-browser/4.2..latest" ] + }, + "publishConfig": { + "tag": "2.x" } } diff --git a/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/README.md b/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/README.md index 3cbbdd39d0ad..aa860ba5774f 100644 --- a/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/README.md +++ b/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/README.md @@ -109,11 +109,12 @@ Welcome. See [ESLint contribution guidelines](https://eslint.org/docs/developer- The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate) to get your logo on our READMEs and [website](https://eslint.org/sponsors). -

Platinum Sponsors

+

Diamond Sponsors

+

AG Grid

Platinum Sponsors

Automattic Airbnb

Gold Sponsors

-

trunk.io

Silver Sponsors

-

JetBrains Liftoff American Express Workleap

Bronze Sponsors

-

WordHint Anagram Solver Icons8 Discord GitBook Nx HeroCoders

+

Qlty Software trunk.io Shopify

Silver Sponsors

+

Vite Liftoff American Express StackBlitz

Bronze Sponsors

+

Sentry Syntax Cybozu Anagram Solver Icons8 Discord GitBook Neko Nx Mercedes-Benz Group HeroCoders LambdaTest

Technology Sponsors

Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.

Netlify Algolia 1Password

diff --git a/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs b/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs index 7f58e49bcd4f..afc433c7cd5b 100644 --- a/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs +++ b/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs @@ -102,8 +102,8 @@ const KEYS = { "attributes" ], ExportSpecifier: [ - "exported", - "local" + "local", + "exported" ], ExpressionStatement: [ "expression" diff --git a/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts b/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts index a8684341f1cf..34253c96c3dd 100644 --- a/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts +++ b/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts @@ -24,4 +24,5 @@ declare function unionWith(additionalKeys: VisitorKeys): VisitorKeys; type VisitorKeys = VisitorKeys$1; -export { KEYS, type VisitorKeys, getKeys, unionWith }; +export { KEYS, getKeys, unionWith }; +export type { VisitorKeys }; diff --git a/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/lib/visitor-keys.js b/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/lib/visitor-keys.js index 41feb4b2f8a9..c891e040af32 100644 --- a/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/lib/visitor-keys.js +++ b/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/lib/visitor-keys.js @@ -100,8 +100,8 @@ const KEYS = { "attributes" ], ExportSpecifier: [ - "exported", - "local" + "local", + "exported" ], ExpressionStatement: [ "expression" diff --git a/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/package.json b/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/package.json index 4dc2123dbaf0..852e4ddb18cc 100644 --- a/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/package.json +++ b/node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "eslint-visitor-keys", - "version": "4.2.0", + "version": "4.2.1", "description": "Constants and utilities about visitor keys to traverse AST.", "type": "module", "main": "dist/eslint-visitor-keys.cjs", @@ -29,12 +29,9 @@ "@types/estree": "^0.0.51", "@types/estree-jsx": "^0.0.1", "@typescript-eslint/parser": "^8.7.0", - "c8": "^7.11.0", - "chai": "^4.3.6", "eslint-release": "^3.2.0", "esquery": "^1.4.0", "json-diff": "^0.7.3", - "mocha": "^9.2.1", "opener": "^1.5.2", "rollup": "^4.22.4", "rollup-plugin-dts": "^6.1.1", @@ -55,9 +52,15 @@ "test:open-coverage": "c8 report --reporter lcov && opener coverage/lcov-report/index.html", "test:types": "tsd" }, - "repository": "eslint/js", + "repository": { + "type": "git", + "url": "https://github.com/eslint/js.git", + "directory": "packages/eslint-visitor-keys" + }, "funding": "https://opencollective.com/eslint", - "keywords": [], + "keywords": [ + "eslint" + ], "author": "Toru Nagashima (https://github.com/mysticatea)", "license": "Apache-2.0", "bugs": { diff --git a/node_modules/brace-expansion/index.js b/node_modules/brace-expansion/index.js index 0478be81eabc..bd19fe685f68 100644 --- a/node_modules/brace-expansion/index.js +++ b/node_modules/brace-expansion/index.js @@ -109,7 +109,7 @@ function expand(str, isTop) { var isOptions = m.body.indexOf(',') >= 0; if (!isSequence && !isOptions) { // {a},b} - if (m.post.match(/,.*\}/)) { + if (m.post.match(/,(?!,).*\}/)) { str = m.pre + '{' + m.body + escClose + m.post; return expand(str); } diff --git a/node_modules/brace-expansion/package.json b/node_modules/brace-expansion/package.json index a18faa8fd67b..344788817d05 100644 --- a/node_modules/brace-expansion/package.json +++ b/node_modules/brace-expansion/package.json @@ -1,7 +1,7 @@ { "name": "brace-expansion", "description": "Brace expansion as known from sh/bash", - "version": "1.1.11", + "version": "1.1.12", "repository": { "type": "git", "url": "git://github.com/juliangruber/brace-expansion.git" @@ -43,5 +43,8 @@ "iphone/6.0..latest", "android-browser/4.2..latest" ] + }, + "publishConfig": { + "tag": "1.x" } } diff --git a/node_modules/cacheable/README.md b/node_modules/cacheable/README.md index 8c9ebce06416..645455fedc8b 100644 --- a/node_modules/cacheable/README.md +++ b/node_modules/cacheable/README.md @@ -29,6 +29,7 @@ * [Basic Usage](#basic-usage) * [Hooks and Events](#hooks-and-events) * [Storage Tiering and Caching](#storage-tiering-and-caching) +* [TTL Propagation and Storage Tiering](#ttl-propagation-and-storage-tiering) * [Shorthand for Time to Live (ttl)](#shorthand-for-time-to-live-ttl) * [Non-Blocking Operations](#non-blocking-operations) * [CacheSync - Distributed Updates](#cachesync---distributed-updates) @@ -36,10 +37,13 @@ * [Cacheable Statistics (Instance Only)](#cacheable-statistics-instance-only) * [Cacheable - API](#cacheable---api) * [CacheableMemory - In-Memory Cache](#cacheablememory---in-memory-cache) +* [CacheableMemory Store Hashing](#cacheablememory-store-hashing) +* [CacheableMemory LRU Feature](#cacheablememory-lru-feature) +* [CacheableMemory Performance](#cacheablememory-performance) * [CacheableMemory Options](#cacheablememory-options) * [CacheableMemory - API](#cacheablememory---api) -* [Wrap / Memoization for Sync and Async Functions](#wrap--memoization-for-sync-and-async-functions) * [Keyv Storage Adapter - KeyvCacheableMemory](#keyv-storage-adapter---keyvcacheablememory) +* [Wrap / Memoization for Sync and Async Functions](#wrap--memoization-for-sync-and-async-functions) * [How to Contribute](#how-to-contribute) * [License and Copyright](#license-and-copyright) @@ -98,6 +102,7 @@ The following hooks are available for you to extend the functionality of `cachea * `AFTER_GET`: This is called after the `get()` method is called. * `BEFORE_GET_MANY`: This is called before the `getMany()` method is called. * `AFTER_GET_MANY`: This is called after the `getMany()` method is called. +* `BEFORE_SECONDARY_SETS_PRIMARY`: This is called when the secondary store sets the value in the primary store. An example of how to use these hooks: @@ -110,6 +115,19 @@ cacheable.onHook(CacheableHooks.BEFORE_SET, (data) => { }); ``` +Here is an example of how to use `BEFORE_SECONDARY_SETS_PRIMARY` hook: + +```javascript +import { Cacheable, CacheableHooks } from 'cacheable'; +import KeyvRedis from '@keyv/redis'; +const secondary = new KeyvRedis('redis://user:pass@localhost:6379'); +const cache = new Cacheable({secondary}); +cache.onHook(CacheableHooks.BEFORE_SECONDARY_SETS_PRIMARY, (data) => { + console.log(`before secondary sets primary: ${data.key} ${data.value} ${data.ttl}`); +}); +``` +This is called when the secondary store sets the value in the primary store. This is useful if you want to do something before the value is set in the primary store such as manipulating the ttl or the value. + # Storage Tiering and Caching `cacheable` is built as a layer 1 and layer 2 caching engine by default. The purpose is to have your layer 1 be fast and your layer 2 be more persistent. The primary store is the layer 1 cache and the secondary store is the layer 2 cache. By adding the secondary store you are enabling layer 2 caching. By default the operations are blocking but fault tolerant: @@ -119,6 +137,48 @@ cacheable.onHook(CacheableHooks.BEFORE_SET, (data) => { * `Deleting Data`: Deletes the value from the primary store and secondary store at the same time waiting for both to respond. * `Clearing Data`: Clears the primary store and secondary store at the same time waiting for both to respond. +When `Getting Data` if the value does not exist in the primary store it will try to get it from the secondary store. If the secondary store returns the value it will set it in the primary store. Because we use [TTL Propagation](#ttl-propagation-and-storage-tiering) the value will be set in the primary store with the TTL of the secondary store unless the time to live (TTL) is greater than the primary store which will then use the TTL of the primary store. An example of this is: + +```javascript +import { Cacheable } from 'cacheable'; +import KeyvRedis from '@keyv/redis'; +const secondary = new KeyvRedis('redis://user:pass@localhost:6379', { ttl: 1000 }); +const cache = new Cacheable({secondary, ttl: 100}); + +await cache.set('key', 'value'); // sets the value in the primary store with a ttl of 100 ms and secondary store with a ttl of 1000 ms + +await sleep(500); // wait for .5 seconds + +const value = await cache.get('key'); // gets the value from the secondary store and now sets the value in the primary store with a ttl of 500 ms which is what is left from the secondary store +``` + +In this example the primary store has a ttl of `100 ms` and the secondary store has a ttl of `1000 ms`. Because the ttl is greater in the secondary store it will default to setting ttl value in the primary store. + +```javascript +import { Cacheable } from 'cacheable'; +import {Keyv} from 'keyv'; +import KeyvRedis from '@keyv/redis'; +const primary = new Keyv({ ttl: 200 }); +const secondary = new KeyvRedis('redis://user:pass@localhost:6379', { ttl: 1000 }); +const cache = new Cacheable({primary, secondary}); + +await cache.set('key', 'value'); // sets the value in the primary store with a ttl of 100 ms and secondary store with a ttl of 1000 ms + +await sleep(200); // wait for .2 seconds + +const value = await cache.get('key'); // gets the value from the secondary store and now sets the value in the primary store with a ttl of 200 ms which is what the primary store is set with +``` + +# TTL Propagation and Storage Tiering + +Cacheable TTL propagation is a feature that allows you to set a time to live (TTL) for the cache. By default the TTL is set in the following order: + +``` +ttl = set at the function ?? storage adapter ttl ?? cacheable ttl +``` + +This means that if you set a TTL at the function level it will override the storage adapter TTL and the cacheable TTL. If you do not set a TTL at the function level it will use the storage adapter TTL and then the cacheable TTL. If you do not set a TTL at all it will use the default TTL of `undefined` which is disabled. + # Shorthand for Time to Live (ttl) By default `Cacheable` and `CacheableMemory` the `ttl` is in milliseconds but you can use shorthand for the time to live. Here are the following shorthand values: @@ -157,10 +217,79 @@ cache.ttl = -1; // sets the default ttl to 0 which is disabled console.log(cache.ttl); // undefined ``` +## Retrieving raw cache entries + +The `get` and `getMany` methods support a `raw` option, which returns the full stored metadata (`StoredDataRaw`) instead of just the value: + +```typescript +import { Cacheable } from 'cacheable'; + +const cache = new Cacheable(); + +// store a value +await cache.set('user:1', { name: 'Alice' }); + +// default: only the value +const user = await cache.get<{ name: string }>('user:1'); +console.log(user); // { name: 'Alice' } + +// with raw: full record including expiration +const raw = await cache.get<{ name: string }>('user:1', { raw: true }); +console.log(raw.value); // { name: 'Alice' } +console.log(raw.expires); // e.g. 1677628495000 or null +``` + +```typescript +// getMany with raw option +await cache.set('a', 1); +await cache.set('b', 2); + +const raws = await cache.getMany(['a', 'b'], { raw: true }); +raws.forEach((entry, idx) => { + console.log(`key=${['a','b'][idx]}, value=${entry?.value}, expires=${entry?.expires}`); +}); +``` + + # Non-Blocking Operations If you want your layer 2 (secondary) store to be non-blocking you can set the `nonBlocking` property to `true` in the options. This will make the secondary store non-blocking and will not wait for the secondary store to respond on `setting data`, `deleting data`, or `clearing data`. This is useful if you want to have a faster response time and not wait for the secondary store to respond. +# GetOrSet + +The `getOrSet` method provides a convenient way to implement the cache-aside pattern. It attempts to retrieve a value +from cache, and if not found, calls the provided function to compute the value and store it in cache before returning +it. + +```typescript +import { Cacheable } from 'cacheable'; + +// Create a new Cacheable instance +const cache = new Cacheable(); + +// Use getOrSet to fetch user data +async function getUserData(userId: string) { + return await cache.getOrSet( + `user:${userId}`, + async () => { + // This function only runs if the data isn't in the cache + console.log('Fetching user from database...'); + // Simulate database fetch + return { id: userId, name: 'John Doe', email: 'john@example.com' }; + }, + { ttl: '30m' } // Cache for 30 minutes + ); +} + +// First call - will fetch from "database" +const user1 = await getUserData('123'); +console.log(user1); // { id: '123', name: 'John Doe', email: 'john@example.com' } + +// Second call - will retrieve from cache +const user2 = await getUserData('123'); +console.log(user2); // Same data, but retrieved from cache +``` + ```javascript import { Cacheable } from 'cacheable'; import {KeyvRedis} from '@keyv/redis'; @@ -215,7 +344,9 @@ _This does not enable statistics for your layer 2 cache as that is a distributed * `set(key, value, ttl?)`: Sets a value in the cache. * `setMany([{key, value, ttl?}])`: Sets multiple values in the cache. * `get(key)`: Gets a value from the cache. +* `get(key, { raw: true })`: Gets a raw value from the cache. * `getMany([keys])`: Gets multiple values from the cache. +* `getMany([keys], { raw: true })`: Gets multiple raw values from the cache. * `has(key)`: Checks if a value exists in the cache. * `hasMany([keys])`: Checks if multiple values exist in the cache. * `take(key)`: Takes a value from the cache and deletes it. @@ -224,6 +355,7 @@ _This does not enable statistics for your layer 2 cache as that is a distributed * `deleteMany([keys])`: Deletes multiple values from the cache. * `clear()`: Clears the cache stores. Be careful with this as it will clear both layer 1 and layer 2. * `wrap(function, WrapOptions)`: Wraps an `async` function in a cache. +* `getOrSet(key, valueFunction, ttl?)`: Gets a value from cache or sets it if not found using the provided function. * `disconnect()`: Disconnects from the cache stores. * `onHook(hook, callback)`: Sets a hook. * `removeHook(hook)`: Removes a hook. @@ -258,12 +390,111 @@ This simple in-memory cache uses multiple Map objects and a with `expiration` an By default we use lazy expiration deletion which means on `get` and `getMany` type functions we look if it is expired and then delete it. If you want to have a more aggressive expiration policy you can set the `checkInterval` property to a value greater than `0` which will check for expired keys at the interval you set. +Here are some of the main features of `CacheableMemory`: +* High performance in-memory cache with a robust API and feature set. šŸš€ +* Can scale past the `16,777,216 (2^24) keys` limit of a single `Map` via `hashStoreSize`. Default is `16` Map objects. +* LRU (Least Recently Used) cache feature to limit the number of keys in the cache via `lruSize`. Limit to `16,777,216 (2^24) keys` total. +* Expiration policy to delete expired keys with lazy deletion or aggressive deletion via `checkInterval`. +* `Wrap` feature to memoize `sync` and `async` functions with stampede protection. +* Ability to do many operations at once such as `setMany`, `getMany`, `deleteMany`, and `takeMany`. +* Supports `raw` data retrieval with `getRaw` and `getManyRaw` methods to get the full metadata of the cache entry. + +## CacheableMemory Store Hashing + +`CacheableMemory` uses `Map` objects to store the keys and values. To make this scale past the `16,777,216 (2^24) keys` limit of a single `Map` we use a hash to balance the data across multiple `Map` objects. This is done by hashing the key and using the hash to determine which `Map` object to use. The default hashing algorithm is `djb2Hash` but you can change it by setting the `storeHashAlgorithm` property in the options. By default we set the amount of `Map` objects to `16`. + +NOTE: if you are using the LRU cache feature the `lruSize` no matter how many `Map` objects you have it will be limited to the `16,777,216 (2^24) keys` limit of a single `Map` object. This is because we use a double linked list to manage the LRU cache and it is not possible to have more than `16,777,216 (2^24) keys` in a single `Map` object. + +Here is an example of how to set the number of `Map` objects and the hashing algorithm: + +```javascript +import { CacheableMemory } from 'cacheable'; +const cache = new CacheableMemory({ + storeSize: 32, // set the number of Map objects to 32 +}); +cache.set('key', 'value'); +const value = cache.get('key'); // value +``` + +Here is an example of how to use the `storeHashAlgorithm` property: + +```javascript +import { CacheableMemory } from 'cacheable'; +const cache = new CacheableMemory({ storeHashAlgorithm: 'sha256' }); +cache.set('key', 'value'); +const value = cache.get('key'); // value +``` + +If you want to provide your own hashing function you can set the `storeHashAlgorithm` property to a function that takes an object and returns a `number` that is in the range of the amount of `Map` stores you have. + +```javascript +import { CacheableMemory } from 'cacheable'; +/** + * Custom hash function that takes a key and the size of the store + * and returns a number between 0 and storeHashSize - 1. + * @param {string} key - The key to hash. + * @param {number} storeHashSize - The size of the store (number of Map objects). + * @returns {number} - A number between 0 and storeHashSize - 1. + */ +const customHash = (key, storeHashSize) => { + // custom hashing logic + return key.length % storeHashSize; // returns a number between 0 and 31 for 32 Map objects +}; +const cache = new CacheableMemory({ storeHashAlgorithm: customHash, storeSize: 32 }); +cache.set('key', 'value'); +const value = cache.get('key'); // value +``` + +## CacheableMemory LRU Feature + +You can enable the LRU (Least Recently Used) feature in `CacheableMemory` by setting the `lruSize` property in the options. This will limit the number of keys in the cache to the size you set. When the cache reaches the limit it will remove the least recently used keys from the cache. This is useful if you want to limit the memory usage of the cache. + +When you set the `lruSize` we use a double linked list to manage the LRU cache and also set the `hashStoreSize` to `1` which means we will only use a single `Map` object for the LRU cache. This is because the LRU cache is managed by the double linked list and it is not possible to have more than `16,777,216 (2^24) keys` in a single `Map` object. + +```javascript +import { CacheableMemory } from 'cacheable'; +const cache = new CacheableMemory({ lruSize: 1 }); // sets the LRU cache size to 1000 keys and hashStoreSize to 1 +cache.set('key1', 'value1'); +cache.set('key2', 'value2'); +const value1 = cache.get('key1'); +console.log(value1); // undefined if the cache is full and key1 is the least recently used +const value2 = cache.get('key2'); +console.log(value2); // value2 if key2 is still in the cache +console.log(cache.size()); // 1 +``` + +NOTE: if you set the `lruSize` property to `0` after it was enabled it will disable the LRU cache feature and will not limit the number of keys in the cache. This will remove the `16,777,216 (2^24) keys` limit of a single `Map` object and will allow you to store more keys in the cache. + +## CacheableMemory Performance + +Our goal with `cacheable` and `CacheableMemory` is to provide a high performance caching engine that is simple to use and has a robust API. We test it against other cacheing engines such that are less feature rich to make sure there is little difference. Here are some of the benchmarks we have run: + +*Memory Benchmark Results:* +| name | summary | ops/sec | time/op | margin | samples | +|------------------------------------------|:---------:|----------:|----------:|:--------:|----------:| +| Map (v22) - set / get | šŸ„‡ | 117K | 9µs | ±1.29% | 110K | +| Cacheable Memory (v1.10.0) - set / get | -1.3% | 116K | 9µs | ±0.77% | 110K | +| Node Cache - set / get | -4.1% | 112K | 9µs | ±1.34% | 107K | +| bentocache (v1.4.0) - set / get | -45% | 65K | 17µs | ±1.10% | 100K | + +*Memory LRU Benchmark Results:* +| name | summary | ops/sec | time/op | margin | samples | +|------------------------------------------|:---------:|----------:|----------:|:--------:|----------:| +| quick-lru (v7.0.1) - set / get | šŸ„‡ | 118K | 9µs | ±0.85% | 112K | +| Map (v22) - set / get | -0.56% | 117K | 9µs | ±1.35% | 110K | +| lru.min (v1.1.2) - set / get | -1.7% | 116K | 9µs | ±0.90% | 110K | +| Cacheable Memory (v1.10.0) - set / get | -3.3% | 114K | 9µs | ±1.16% | 108K | + +As you can see from the benchmarks `CacheableMemory` is on par with other caching engines such as `Map`, `Node Cache`, and `bentocache`. We have also tested it against other LRU caching engines such as `quick-lru` and `lru.min` and it performs well against them too. + ## CacheableMemory Options * `ttl`: The time to live for the cache in milliseconds. Default is `undefined` which is means indefinitely. * `useClones`: If the cache should use clones for the values. Default is `true`. * `lruSize`: The size of the LRU cache. Default is `0` which is unlimited. * `checkInterval`: The interval to check for expired keys in milliseconds. Default is `0` which is disabled. +* `storeHashSize`: The number of `Map` objects to use for the cache. Default is `16`. +* `storeHashAlgorithm`: The hashing algorithm to use for the cache. Default is `djb2Hash`. ## CacheableMemory - API @@ -281,13 +512,33 @@ By default we use lazy expiration deletion which means on `get` and `getMany` ty * `takeMany([keys])`: Takes multiple values from the cache and deletes them. * `wrap(function, WrapSyncOptions)`: Wraps a `sync` function in a cache. * `clear()`: Clears the cache. -* `size()`: The number of keys in the cache. -* `keys()`: The keys in the cache. -* `items()`: The items in the cache as `CacheableStoreItem` example `{ key, value, expires? }`. +* `ttl`: The default time to live for the cache in milliseconds. Default is `undefined` which is disabled. +* `useClones`: If the cache should use clones for the values. Default is `true`. +* `lruSize`: The size of the LRU cache. Default is `0` which is unlimited. +* `size`: The number of keys in the cache. +* `checkInterval`: The interval to check for expired keys in milliseconds. Default is `0` which is disabled. +* `storeHashSize`: The number of `Map` objects to use for the cache. Default is `16`. +* `storeHashAlgorithm`: The hashing algorithm to use for the cache. Default is `djb2Hash`. +* `keys`: Get the keys in the cache. Not able to be set. +* `items`: Get the items in the cache as `CacheableStoreItem` example `{ key, value, expires? }`. +* `store`: The hash store for the cache which is an array of `Map` objects. * `checkExpired()`: Checks for expired keys in the cache. This is used by the `checkInterval` property. * `startIntervalCheck()`: Starts the interval check for expired keys if `checkInterval` is above 0 ms. * `stopIntervalCheck()`: Stops the interval check for expired keys. -* `hash(object: any, algorithm = 'sha256'): string`: Hashes an object with the algorithm. Default is `sha256`. + +# Keyv Storage Adapter - KeyvCacheableMemory + +`cacheable` comes with a built-in storage adapter for Keyv called `KeyvCacheableMemory`. This takes `CacheableMemory` and creates a storage adapter for Keyv. This is useful if you want to use `CacheableMemory` as a storage adapter for Keyv. Here is an example of how to use `KeyvCacheableMemory`: + +```javascript +import { Keyv } from 'keyv'; +import { KeyvCacheableMemory } from 'cacheable'; + +const keyv = new Keyv({ store: new KeyvCacheableMemory() }); +await keyv.set('foo', 'bar'); +const value = await keyv.get('foo'); +console.log(value); // bar +``` # Wrap / Memoization for Sync and Async Functions @@ -363,23 +614,9 @@ console.log(wrappedFunction()); // error console.log(wrappedFunction()); // error from cache ``` -# Keyv Storage Adapter - KeyvCacheableMemory - -`cacheable` comes with a built-in storage adapter for Keyv called `KeyvCacheableMemory`. This takes `CacheableMemory` and creates a storage adapter for Keyv. This is useful if you want to use `CacheableMemory` as a storage adapter for Keyv. Here is an example of how to use `KeyvCacheableMemory`: - -```javascript -import { Keyv } from 'keyv'; -import { KeyvCacheableMemory } from 'cacheable'; - -const keyv = new Keyv({ store: new KeyvCacheableMemory() }); -await keyv.set('foo', 'bar'); -const value = await keyv.get('foo'); -console.log(value); // bar -``` - # How to Contribute You can contribute by forking the repo and submitting a pull request. Please make sure to add tests and update the documentation. To learn more about how to contribute go to our main README [https://github.com/jaredwray/cacheable](https://github.com/jaredwray/cacheable). This will talk about how to `Open a Pull Request`, `Ask a Question`, or `Post an Issue`. # License and Copyright -[MIT Ā© Jared Wray](./LICENSE) \ No newline at end of file +[MIT Ā© Jared Wray](./LICENSE) diff --git a/node_modules/cacheable/dist/index.cjs b/node_modules/cacheable/dist/index.cjs index 58ccfb2063cf..7dc53b46f305 100644 --- a/node_modules/cacheable/dist/index.cjs +++ b/node_modules/cacheable/dist/index.cjs @@ -132,6 +132,26 @@ function hash(object, algorithm = "sha256") { hasher.update(objectString); return hasher.digest("hex"); } +function hashToNumber(object, min = 0, max = 10, algorithm = "sha256") { + const objectString = JSON.stringify(object); + if (!crypto.getHashes().includes(algorithm)) { + throw new Error(`Unsupported hash algorithm: '${algorithm}'`); + } + const hasher = crypto.createHash(algorithm); + hasher.update(objectString); + const hashHex = hasher.digest("hex"); + const hashNumber = Number.parseInt(hashHex, 16); + const range = max - min + 1; + return min + hashNumber % range; +} +function djb2Hash(string_, min = 0, max = 10) { + let hash2 = 5381; + for (let i = 0; i < string_.length; i++) { + hash2 = hash2 * 33 ^ string_.charCodeAt(i); + } + const range = max - min + 1; + return min + Math.abs(hash2) % range; +} // src/coalesce-async.ts var callbacks = /* @__PURE__ */ new Map(); @@ -208,29 +228,31 @@ function wrapSync(function_, options) { return value; }; } +async function getOrSet(key, function_, options) { + let value = await options.cache.get(key); + if (value === void 0) { + const cacheId = options.cacheId ?? "default"; + const coalesceKey = `${cacheId}::${key}`; + value = await coalesceAsync(coalesceKey, async () => { + try { + const result = await function_(); + await options.cache.set(key, result, options.ttl); + return result; + } catch (error) { + options.cache.emit("error", error); + if (options.cacheErrors) { + await options.cache.set(key, error, options.ttl); + } + } + }); + } + return value; +} function wrap(function_, options) { - const { ttl, keyPrefix, cache } = options; + const { keyPrefix, cache } = options; return async function(...arguments_) { - let value; const cacheKey = createWrapKey(function_, arguments_, keyPrefix); - value = await cache.get(cacheKey); - if (value === void 0) { - const cacheId = options.cacheId ?? "default"; - const coalesceKey = `${cacheId}::${cacheKey}`; - value = await coalesceAsync(coalesceKey, async () => { - try { - const result = await function_(...arguments_); - await cache.set(cacheKey, result, ttl); - return result; - } catch (error) { - cache.emit("error", error); - if (options.cacheErrors) { - await cache.set(cacheKey, error, ttl); - } - } - }); - } - return value; + return cache.getOrSet(cacheKey, async () => function_(...arguments_), options); }; } function createWrapKey(function_, arguments_, keyPrefix) { @@ -314,19 +336,14 @@ var DoublyLinkedList = class { }; // src/memory.ts +var defaultStoreHashSize = 16; +var maximumMapSize = 16777216; var CacheableMemory = class extends import_hookified.Hookified { _lru = new DoublyLinkedList(); - _hashCache = /* @__PURE__ */ new Map(); - _hash0 = /* @__PURE__ */ new Map(); - _hash1 = /* @__PURE__ */ new Map(); - _hash2 = /* @__PURE__ */ new Map(); - _hash3 = /* @__PURE__ */ new Map(); - _hash4 = /* @__PURE__ */ new Map(); - _hash5 = /* @__PURE__ */ new Map(); - _hash6 = /* @__PURE__ */ new Map(); - _hash7 = /* @__PURE__ */ new Map(); - _hash8 = /* @__PURE__ */ new Map(); - _hash9 = /* @__PURE__ */ new Map(); + _storeHashSize = defaultStoreHashSize; + _storeHashAlgorithm = "djb2Hash" /* djb2Hash */; + // Default is djb2Hash + _store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map()); _ttl; // Turned off by default _useClone = true; @@ -349,12 +366,23 @@ var CacheableMemory = class extends import_hookified.Hookified { if (options?.useClone !== void 0) { this._useClone = options.useClone; } + if (options?.storeHashSize && options.storeHashSize > 0) { + this._storeHashSize = options.storeHashSize; + } if (options?.lruSize) { - this._lruSize = options.lruSize; + if (options.lruSize > maximumMapSize) { + this.emit("error", new Error(`LRU size cannot be larger than ${maximumMapSize} due to Map limitations.`)); + } else { + this._lruSize = options.lruSize; + } } if (options?.checkInterval) { this._checkInterval = options.checkInterval; } + if (options?.storeHashAlgorithm) { + this._storeHashAlgorithm = options.storeHashAlgorithm; + } + this._store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map()); this.startIntervalCheck(); } /** @@ -387,17 +415,25 @@ var CacheableMemory = class extends import_hookified.Hookified { } /** * Gets the size of the LRU cache - * @returns {number} - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. + * @returns {number} - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm. */ get lruSize() { return this._lruSize; } /** * Sets the size of the LRU cache - * @param {number} value - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. + * @param {number} value - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm. */ set lruSize(value) { + if (value > maximumMapSize) { + this.emit("error", new Error(`LRU size cannot be larger than ${maximumMapSize} due to Map limitations.`)); + return; + } this._lruSize = value; + if (this._lruSize === 0) { + this._lru = new DoublyLinkedList(); + return; + } this.lruResize(); } /** @@ -419,21 +455,85 @@ var CacheableMemory = class extends import_hookified.Hookified { * @returns {number} - The size of the cache */ get size() { - return this._hash0.size + this._hash1.size + this._hash2.size + this._hash3.size + this._hash4.size + this._hash5.size + this._hash6.size + this._hash7.size + this._hash8.size + this._hash9.size; + let size = 0; + for (const store of this._store) { + size += store.size; + } + return size; + } + /** + * Gets the number of hash stores + * @returns {number} - The number of hash stores + */ + get storeHashSize() { + return this._storeHashSize; + } + /** + * Sets the number of hash stores. This will recreate the store and all data will be cleared + * @param {number} value - The number of hash stores + */ + set storeHashSize(value) { + if (value === this._storeHashSize) { + return; + } + this._storeHashSize = value; + this._store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map()); + } + /** + * Gets the store hash algorithm + * @returns {StoreHashAlgorithm | StoreHashAlgorithmFunction} - The store hash algorithm + */ + get storeHashAlgorithm() { + return this._storeHashAlgorithm; + } + /** + * Sets the store hash algorithm. This will recreate the store and all data will be cleared + * @param {StoreHashAlgorithm | StoreHashAlgorithmFunction} value - The store hash algorithm + */ + set storeHashAlgorithm(value) { + this._storeHashAlgorithm = value; } /** * Gets the keys * @returns {IterableIterator} - The keys */ get keys() { - return this.concatStores().keys(); + const keys = new Array(); + for (const store of this._store) { + for (const key of store.keys()) { + const item = store.get(key); + if (item && this.hasExpired(item)) { + store.delete(key); + continue; + } + keys.push(key); + } + } + return keys.values(); } /** * Gets the items * @returns {IterableIterator} - The items */ get items() { - return this.concatStores().values(); + const items = new Array(); + for (const store of this._store) { + for (const item of store.values()) { + if (this.hasExpired(item)) { + store.delete(item.key); + continue; + } + items.push(item); + } + } + return items.values(); + } + /** + * Gets the store + * @returns {Array>} - The store + */ + get store() { + return this._store; } /** * Gets the value of the key @@ -446,7 +546,7 @@ var CacheableMemory = class extends import_hookified.Hookified { if (!item) { return void 0; } - if (item.expires && item.expires && Date.now() > item.expires) { + if (item.expires && Date.now() > item.expires) { store.delete(key); return void 0; } @@ -629,17 +729,7 @@ var CacheableMemory = class extends import_hookified.Hookified { * @returns {void} */ clear() { - this._hash0.clear(); - this._hash1.clear(); - this._hash2.clear(); - this._hash3.clear(); - this._hash4.clear(); - this._hash5.clear(); - this._hash6.clear(); - this._hash7.clear(); - this._hash8.clear(); - this._hash9.clear(); - this._hashCache.clear(); + this._store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map()); this._lru = new DoublyLinkedList(); } /** @@ -648,66 +738,27 @@ var CacheableMemory = class extends import_hookified.Hookified { * @returns {CacheableHashStore} - The store */ getStore(key) { - const hash2 = this.hashKey(key); - return this.getStoreFromHash(hash2); + const hash2 = this.getKeyStoreHash(key); + this._store[hash2] ||= /* @__PURE__ */ new Map(); + return this._store[hash2]; } /** - * Get the store based on the hash (internal use) - * @param {number} hash - * @returns {Map} + * Hash the key for which store to go to (internal use) + * @param {string} key - The key to hash + * Available algorithms are: SHA256, SHA1, MD5, and djb2Hash. + * @returns {number} - The hashed key as a number */ - getStoreFromHash(hash2) { - switch (hash2) { - case 1: { - return this._hash1; - } - case 2: { - return this._hash2; - } - case 3: { - return this._hash3; - } - case 4: { - return this._hash4; - } - case 5: { - return this._hash5; - } - case 6: { - return this._hash6; - } - case 7: { - return this._hash7; - } - case 8: { - return this._hash8; - } - case 9: { - return this._hash9; - } - default: { - return this._hash0; - } + getKeyStoreHash(key) { + if (this._store.length === 1) { + return 0; } - } - /** - * Hash the key (internal use) - * @param key - * @returns {number} from 0 to 9 - */ - hashKey(key) { - const cacheHashNumber = this._hashCache.get(key); - if (cacheHashNumber) { - return cacheHashNumber; + if (this._storeHashAlgorithm === "djb2Hash" /* djb2Hash */) { + return djb2Hash(key, 0, this._storeHashSize); } - let hash2 = 0; - const primeMultiplier = 31; - for (let i = 0; i < key.length; i++) { - hash2 = hash2 * primeMultiplier + key.charCodeAt(i); + if (typeof this._storeHashAlgorithm === "function") { + return this._storeHashAlgorithm(key, this._storeHashSize); } - const result = Math.abs(hash2) % 10; - this._hashCache.set(key, result); - return result; + return hashToNumber(key, 0, this._storeHashSize, this._storeHashAlgorithm); } /** * Clone the value. This is for internal use @@ -743,13 +794,10 @@ var CacheableMemory = class extends import_hookified.Hookified { this._lru.moveToFront(key); } /** - * Resize the LRU cache. This is for internal use + * Resize the LRU cache. This is for internal use. * @returns {void} */ lruResize() { - if (this._lruSize === 0) { - return; - } while (this._lru.size > this._lruSize) { const oldestKey = this._lru.getOldest(); if (oldestKey) { @@ -763,10 +811,11 @@ var CacheableMemory = class extends import_hookified.Hookified { * @returns {void} */ checkExpiration() { - const stores = this.concatStores(); - for (const item of stores.values()) { - if (item.expires && Date.now() > item.expires) { - this.delete(item.key); + for (const store of this._store) { + for (const item of store.values()) { + if (item.expires && Date.now() > item.expires) { + store.delete(item.key); + } } } } @@ -795,15 +844,6 @@ var CacheableMemory = class extends import_hookified.Hookified { this._interval = 0; this._checkInterval = 0; } - /** - * Hash the object. This is for internal use - * @param {any} object - The object to hash - * @param {string} [algorithm='sha256'] - The algorithm to hash - * @returns {string} - The hashed string - */ - hash(object, algorithm = "sha256") { - return hash(object, algorithm); - } /** * Wrap the function for caching * @param {Function} function_ - The function to wrap @@ -828,9 +868,6 @@ var CacheableMemory = class extends import_hookified.Hookified { } return result; } - concatStores() { - return new Map([...this._hash0, ...this._hash1, ...this._hash2, ...this._hash3, ...this._hash4, ...this._hash5, ...this._hash6, ...this._hash7, ...this._hash8, ...this._hash9]); - } setTtl(ttl) { if (typeof ttl === "string" || ttl === void 0) { this._ttl = ttl; @@ -840,6 +877,12 @@ var CacheableMemory = class extends import_hookified.Hookified { this._ttl = void 0; } } + hasExpired(item) { + if (item.expires && Date.now() > item.expires) { + return true; + } + return false; + } }; // src/keyv-memory.ts @@ -1147,6 +1190,35 @@ var CacheableStats = class { } }; +// src/ttl.ts +function getTtlFromExpires(expires) { + if (expires === void 0 || expires === null) { + return void 0; + } + const now = Date.now(); + if (expires < now) { + return void 0; + } + return expires - now; +} +function getCascadingTtl(cacheableTtl, primaryTtl, secondaryTtl) { + return secondaryTtl ?? primaryTtl ?? shorthandToMilliseconds(cacheableTtl); +} +function calculateTtlFromExpiration(ttl, expires) { + const ttlFromExpires = getTtlFromExpires(expires); + const expiresFromTtl = ttl ? Date.now() + ttl : void 0; + if (ttlFromExpires === void 0) { + return ttl; + } + if (expiresFromTtl === void 0) { + return ttlFromExpires; + } + if (expires > expiresFromTtl) { + return ttl; + } + return ttlFromExpires; +} + // src/index.ts var import_keyv3 = require("keyv"); var CacheableHooks = /* @__PURE__ */ ((CacheableHooks2) => { @@ -1158,6 +1230,7 @@ var CacheableHooks = /* @__PURE__ */ ((CacheableHooks2) => { CacheableHooks2["AFTER_GET"] = "AFTER_GET"; CacheableHooks2["BEFORE_GET_MANY"] = "BEFORE_GET_MANY"; CacheableHooks2["AFTER_GET_MANY"] = "AFTER_GET_MANY"; + CacheableHooks2["BEFORE_SECONDARY_SETS_PRIMARY"] = "BEFORE_SECONDARY_SETS_PRIMARY"; return CacheableHooks2; })(CacheableHooks || {}); var CacheableEvents = /* @__PURE__ */ ((CacheableEvents2) => { @@ -1366,25 +1439,26 @@ var Cacheable = class extends import_hookified2.Hookified { } return this._namespace; } - /** - * Gets the value of the key. If the key does not exist in the primary store then it will check the secondary store. - * @param {string} key The key to get the value of - * @returns {Promise} The value of the key or undefined if the key does not exist - */ - async get(key) { + async get(key, options = {}) { let result; + const { raw = false } = options; try { await this.hook("BEFORE_GET" /* BEFORE_GET */, key); - result = await this._primary.get(key); + result = await this._primary.get(key, { raw: true }); + let ttl; if (!result && this._secondary) { - const rawResult = await this._secondary.get(key, { raw: true }); - if (rawResult) { - result = rawResult.value; - const finalTtl = rawResult.expires ?? void 0; - await this._primary.set(key, result, finalTtl); + const secondaryResult = await this.getSecondaryRawResults(key); + if (secondaryResult?.value) { + result = secondaryResult; + const cascadeTtl = getCascadingTtl(this._ttl, this._primary.ttl); + const expires = secondaryResult.expires ?? void 0; + ttl = calculateTtlFromExpiration(cascadeTtl, expires); + const setItem = { key, value: result.value, ttl }; + await this.hook("BEFORE_SECONDARY_SETS_PRIMARY" /* BEFORE_SECONDARY_SETS_PRIMARY */, setItem); + await this._primary.set(setItem.key, setItem.value, setItem.ttl); } } - await this.hook("AFTER_GET" /* AFTER_GET */, { key, result }); + await this.hook("AFTER_GET" /* AFTER_GET */, { key, result, ttl }); } catch (error) { this.emit("error" /* ERROR */, error); } @@ -1396,18 +1470,14 @@ var Cacheable = class extends import_hookified2.Hookified { } this.stats.incrementGets(); } - return result; + return raw ? result : result?.value; } - /** - * Gets the values of the keys. If the key does not exist in the primary store then it will check the secondary store. - * @param {string[]} keys The keys to get the values of - * @returns {Promise>} The values of the keys or undefined if the key does not exist - */ - async getMany(keys) { + async getMany(keys, options = {}) { let result = []; + const { raw = false } = options; try { await this.hook("BEFORE_GET_MANY" /* BEFORE_GET_MANY */, keys); - result = await this._primary.get(keys); + result = await this._primary.get(keys, { raw: true }); if (this._secondary) { const missingKeys = []; for (const [i, key] of keys.entries()) { @@ -1415,12 +1485,16 @@ var Cacheable = class extends import_hookified2.Hookified { missingKeys.push(key); } } - const secondaryResult = await this._secondary.get(missingKeys); - for (const [i, key] of keys.entries()) { - if (!result[i] && secondaryResult[i]) { - result[i] = secondaryResult[i]; - const finalTtl = shorthandToMilliseconds(this._ttl); - await this._primary.set(key, secondaryResult[i], finalTtl); + const secondaryResults = await this.getManySecondaryRawResults(missingKeys); + for await (const [i, key] of keys.entries()) { + if (!result[i] && secondaryResults[i]) { + result[i] = secondaryResults[i]; + const cascadeTtl = getCascadingTtl(this._ttl, this._primary.ttl); + const expires = secondaryResults[i].expires; + const ttl = calculateTtlFromExpiration(cascadeTtl, expires); + const setItem = { key, value: result[i].value, ttl }; + await this.hook("BEFORE_SECONDARY_SETS_PRIMARY" /* BEFORE_SECONDARY_SETS_PRIMARY */, setItem); + await this._primary.set(setItem.key, setItem.value, setItem.ttl); } } } @@ -1438,7 +1512,7 @@ var Cacheable = class extends import_hookified2.Hookified { } this.stats.incrementGets(); } - return result; + return raw ? result : result.map((item) => item?.value); } /** * Sets the value of the key. If the secondary store is set then it will also set the value in the secondary store. @@ -1668,6 +1742,24 @@ var Cacheable = class extends import_hookified2.Hookified { }; return wrap(function_, wrapOptions); } + /** + * Retrieves the value associated with the given key from the cache. If the key is not found, + * invokes the provided function to calculate the value, stores it in the cache, and then returns it. + * + * @param {string} key - The key to retrieve or set in the cache. + * @param {() => Promise} function_ - The asynchronous function that computes the value to be cached if the key does not exist. + * @param {WrapFunctionOptions} [options] - Optional settings for caching, such as the time to live (TTL) or whether to cache errors. + * @return {Promise} - A promise that resolves to the cached or newly computed value, or undefined if an error occurs and caching is not configured for errors. + */ + async getOrSet(key, function_, options) { + const getOrSetOptions = { + cache: this, + cacheId: this._cacheId, + ttl: options?.ttl ?? this._ttl, + cacheErrors: options?.cacheErrors + }; + return getOrSet(key, function_, getOrSetOptions); + } /** * Will hash an object using the specified algorithm. The default algorithm is 'sha256'. * @param {any} object the object to hash @@ -1677,6 +1769,20 @@ var Cacheable = class extends import_hookified2.Hookified { hash(object, algorithm = "sha256") { return hash(object, algorithm); } + async getSecondaryRawResults(key) { + let result; + if (this._secondary) { + result = await this._secondary.get(key, { raw: true }); + } + return result; + } + async getManySecondaryRawResults(keys) { + let result = new Array(); + if (this._secondary) { + result = await this._secondary.get(keys, { raw: true }); + } + return result; + } async deleteManyKeyv(keyv, keys) { const promises = []; for (const key of keys) { diff --git a/node_modules/cacheable/dist/index.d.cts b/node_modules/cacheable/dist/index.d.cts index e17daff52a22..2dd0c8ead47a 100644 --- a/node_modules/cacheable/dist/index.d.cts +++ b/node_modules/cacheable/dist/index.d.cts @@ -1,4 +1,4 @@ -import { KeyvStoreAdapter, StoredData, Keyv } from 'keyv'; +import { KeyvStoreAdapter, StoredData, Keyv, StoredDataRaw } from 'keyv'; export { Keyv, KeyvHooks, KeyvOptions, KeyvStoreAdapter } from 'keyv'; import { Hookified } from 'hookified'; @@ -109,6 +109,10 @@ type CacheableStoreItem = { expires?: number; }; +type GetOrSetFunctionOptions = { + ttl?: number | string; + cacheErrors?: boolean; +}; type WrapFunctionOptions = { ttl?: number | string; keyPrefix?: string; @@ -125,20 +129,30 @@ type AnyFunction = (...arguments_: any[]) => any; declare function wrapSync(function_: AnyFunction, options: WrapSyncOptions): AnyFunction; declare function wrap(function_: AnyFunction, options: WrapOptions): AnyFunction; +declare enum StoreHashAlgorithm { + SHA256 = "sha256", + SHA1 = "sha1", + MD5 = "md5", + djb2Hash = "djb2Hash" +} +type StoreHashAlgorithmFunction = ((key: string, storeHashSize: number) => number); /** * @typedef {Object} CacheableMemoryOptions * @property {number|string} [ttl] - Time to Live - If you set a number it is miliseconds, if you set a string it is a human-readable * format such as `1s` for 1 second or `1h` for 1 hour. Setting undefined means that it will use the default time-to-live. If both are * undefined then it will not have a time-to-live. * @property {boolean} [useClone] - If true, it will clone the value before returning it. If false, it will return the value directly. Default is true. - * @property {number} [lruSize] - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. + * @property {number} [lruSize] - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm. * @property {number} [checkInterval] - The interval to check for expired items. If set to 0, it will not check for expired items. Default is 0. + * @property {number} [storeHashSize] - The number of how many Map stores we have for the hash. Default is 10. */ type CacheableMemoryOptions = { ttl?: number | string; useClone?: boolean; lruSize?: number; checkInterval?: number; + storeHashSize?: number; + storeHashAlgorithm?: StoreHashAlgorithm | ((key: string, storeHashSize: number) => number); }; type SetOptions = { ttl?: number | string; @@ -146,17 +160,9 @@ type SetOptions = { }; declare class CacheableMemory extends Hookified { private _lru; - private readonly _hashCache; - private readonly _hash0; - private readonly _hash1; - private readonly _hash2; - private readonly _hash3; - private readonly _hash4; - private readonly _hash5; - private readonly _hash6; - private readonly _hash7; - private readonly _hash8; - private readonly _hash9; + private _storeHashSize; + private _storeHashAlgorithm; + private _store; private _ttl; private _useClone; private _lruSize; @@ -189,12 +195,12 @@ declare class CacheableMemory extends Hookified { set useClone(value: boolean); /** * Gets the size of the LRU cache - * @returns {number} - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. + * @returns {number} - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm. */ get lruSize(): number; /** * Sets the size of the LRU cache - * @param {number} value - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. + * @param {number} value - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm. */ set lruSize(value: number); /** @@ -212,6 +218,26 @@ declare class CacheableMemory extends Hookified { * @returns {number} - The size of the cache */ get size(): number; + /** + * Gets the number of hash stores + * @returns {number} - The number of hash stores + */ + get storeHashSize(): number; + /** + * Sets the number of hash stores. This will recreate the store and all data will be cleared + * @param {number} value - The number of hash stores + */ + set storeHashSize(value: number); + /** + * Gets the store hash algorithm + * @returns {StoreHashAlgorithm | StoreHashAlgorithmFunction} - The store hash algorithm + */ + get storeHashAlgorithm(): StoreHashAlgorithm | StoreHashAlgorithmFunction; + /** + * Sets the store hash algorithm. This will recreate the store and all data will be cleared + * @param {StoreHashAlgorithm | StoreHashAlgorithmFunction} value - The store hash algorithm + */ + set storeHashAlgorithm(value: StoreHashAlgorithm | StoreHashAlgorithmFunction); /** * Gets the keys * @returns {IterableIterator} - The keys @@ -222,6 +248,11 @@ declare class CacheableMemory extends Hookified { * @returns {IterableIterator} - The items */ get items(): IterableIterator; + /** + * Gets the store + * @returns {Array>} - The store + */ + get store(): Array>; /** * Gets the value of the key * @param {string} key - The key to get the value @@ -310,17 +341,12 @@ declare class CacheableMemory extends Hookified { */ getStore(key: string): Map; /** - * Get the store based on the hash (internal use) - * @param {number} hash - * @returns {Map} + * Hash the key for which store to go to (internal use) + * @param {string} key - The key to hash + * Available algorithms are: SHA256, SHA1, MD5, and djb2Hash. + * @returns {number} - The hashed key as a number */ - getStoreFromHash(hash: number): Map; - /** - * Hash the key (internal use) - * @param key - * @returns {number} from 0 to 9 - */ - hashKey(key: string): number; + getKeyStoreHash(key: string): number; /** * Clone the value. This is for internal use * @param {any} value - The value to clone @@ -340,7 +366,7 @@ declare class CacheableMemory extends Hookified { */ lruMoveToFront(key: string): void; /** - * Resize the LRU cache. This is for internal use + * Resize the LRU cache. This is for internal use. * @returns {void} */ lruResize(): void; @@ -359,13 +385,6 @@ declare class CacheableMemory extends Hookified { * @returns {void} */ stopIntervalCheck(): void; - /** - * Hash the object. This is for internal use - * @param {any} object - The object to hash - * @param {string} [algorithm='sha256'] - The algorithm to hash - * @returns {string} - The hashed string - */ - hash(object: any, algorithm?: string): string; /** * Wrap the function for caching * @param {Function} function_ - The function to wrap @@ -374,8 +393,8 @@ declare class CacheableMemory extends Hookified { */ wrap(function_: (...arguments_: Arguments) => T, options?: WrapFunctionOptions): (...arguments_: Arguments) => T; private isPrimitive; - private concatStores; private setTtl; + private hasExpired; } type KeyvCacheableMemoryOptions = CacheableMemoryOptions & { @@ -423,7 +442,8 @@ declare enum CacheableHooks { BEFORE_GET = "BEFORE_GET", AFTER_GET = "AFTER_GET", BEFORE_GET_MANY = "BEFORE_GET_MANY", - AFTER_GET_MANY = "AFTER_GET_MANY" + AFTER_GET_MANY = "AFTER_GET_MANY", + BEFORE_SECONDARY_SETS_PRIMARY = "BEFORE_SECONDARY_SETS_PRIMARY" } declare enum CacheableEvents { ERROR = "error" @@ -593,17 +613,46 @@ declare class Cacheable extends Hookified { setSecondary(secondary: Keyv | KeyvStoreAdapter): void; getNameSpace(): string | undefined; /** - * Gets the value of the key. If the key does not exist in the primary store then it will check the secondary store. - * @param {string} key The key to get the value of - * @returns {Promise} The value of the key or undefined if the key does not exist - */ - get(key: string): Promise; - /** - * Gets the values of the keys. If the key does not exist in the primary store then it will check the secondary store. - * @param {string[]} keys The keys to get the values of - * @returns {Promise>} The values of the keys or undefined if the key does not exist - */ - getMany(keys: string[]): Promise>; + * Retrieves an entry from the cache, with an optional ā€œrawā€ mode. + * + * Checks the primary store first; if not found and a secondary store is configured, + * it will fetch from the secondary, repopulate the primary, and return the result. + * + * @typeParam T - The expected type of the stored value. + * @param {string} key - The cache key to retrieve. + * @param {{ raw?: boolean }} [opts] - Options for retrieval. + * @param {boolean} [opts.raw=false] - If `true`, returns the full raw data object + * (`StoredDataRaw`); otherwise returns just the value. + * @returns {Promise | undefined>} + * A promise that resolves to the cached value (or raw data) if found, or `undefined`. + */ + get(key: string, options?: { + raw?: false; + }): Promise; + get(key: string, options: { + raw: true; + }): Promise>; + /** + * Retrieves multiple entries from the cache. + * Checks the primary store for each key; if a key is missing and a secondary store is configured, + * it will fetch from the secondary store, repopulate the primary store, and return the results. + * + * @typeParam T - The expected type of the stored values. + * @param {string[]} keys - The cache keys to retrieve. + * @param {{ raw?: boolean }} [options] - Options for retrieval. + * @param {boolean} [options.raw=false] - When `true`, returns an array of raw data objects (`StoredDataRaw`); + * when `false`, returns an array of unwrapped values (`T`) or `undefined` for misses. + * @returns {Promise> | Promise>>} + * A promise that resolves to: + * - `Array` if `raw` is `false` (default). + * - `Array>` if `raw` is `true`. + */ + getMany(keys: string[], options?: { + raw?: false; + }): Promise>; + getMany(keys: string[], options: { + raw: true; + }): Promise>>; /** * Sets the value of the key. If the secondary store is set then it will also set the value in the secondary store. * @param {string} key the key to set the value of @@ -674,6 +723,16 @@ declare class Cacheable extends Hookified { * @returns {Function} The wrapped function */ wrap(function_: (...arguments_: Arguments) => T, options?: WrapFunctionOptions): (...arguments_: Arguments) => T; + /** + * Retrieves the value associated with the given key from the cache. If the key is not found, + * invokes the provided function to calculate the value, stores it in the cache, and then returns it. + * + * @param {string} key - The key to retrieve or set in the cache. + * @param {() => Promise} function_ - The asynchronous function that computes the value to be cached if the key does not exist. + * @param {WrapFunctionOptions} [options] - Optional settings for caching, such as the time to live (TTL) or whether to cache errors. + * @return {Promise} - A promise that resolves to the cached or newly computed value, or undefined if an error occurs and caching is not configured for errors. + */ + getOrSet(key: string, function_: () => Promise, options?: GetOrSetFunctionOptions): Promise; /** * Will hash an object using the specified algorithm. The default algorithm is 'sha256'. * @param {any} object the object to hash @@ -681,6 +740,8 @@ declare class Cacheable extends Hookified { * @returns {string} the hash of the object */ hash(object: any, algorithm?: string): string; + private getSecondaryRawResults; + private getManySecondaryRawResults; private deleteManyKeyv; private setManyKeyv; private hasManyKeyv; diff --git a/node_modules/cacheable/dist/index.d.ts b/node_modules/cacheable/dist/index.d.ts index e17daff52a22..2dd0c8ead47a 100644 --- a/node_modules/cacheable/dist/index.d.ts +++ b/node_modules/cacheable/dist/index.d.ts @@ -1,4 +1,4 @@ -import { KeyvStoreAdapter, StoredData, Keyv } from 'keyv'; +import { KeyvStoreAdapter, StoredData, Keyv, StoredDataRaw } from 'keyv'; export { Keyv, KeyvHooks, KeyvOptions, KeyvStoreAdapter } from 'keyv'; import { Hookified } from 'hookified'; @@ -109,6 +109,10 @@ type CacheableStoreItem = { expires?: number; }; +type GetOrSetFunctionOptions = { + ttl?: number | string; + cacheErrors?: boolean; +}; type WrapFunctionOptions = { ttl?: number | string; keyPrefix?: string; @@ -125,20 +129,30 @@ type AnyFunction = (...arguments_: any[]) => any; declare function wrapSync(function_: AnyFunction, options: WrapSyncOptions): AnyFunction; declare function wrap(function_: AnyFunction, options: WrapOptions): AnyFunction; +declare enum StoreHashAlgorithm { + SHA256 = "sha256", + SHA1 = "sha1", + MD5 = "md5", + djb2Hash = "djb2Hash" +} +type StoreHashAlgorithmFunction = ((key: string, storeHashSize: number) => number); /** * @typedef {Object} CacheableMemoryOptions * @property {number|string} [ttl] - Time to Live - If you set a number it is miliseconds, if you set a string it is a human-readable * format such as `1s` for 1 second or `1h` for 1 hour. Setting undefined means that it will use the default time-to-live. If both are * undefined then it will not have a time-to-live. * @property {boolean} [useClone] - If true, it will clone the value before returning it. If false, it will return the value directly. Default is true. - * @property {number} [lruSize] - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. + * @property {number} [lruSize] - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm. * @property {number} [checkInterval] - The interval to check for expired items. If set to 0, it will not check for expired items. Default is 0. + * @property {number} [storeHashSize] - The number of how many Map stores we have for the hash. Default is 10. */ type CacheableMemoryOptions = { ttl?: number | string; useClone?: boolean; lruSize?: number; checkInterval?: number; + storeHashSize?: number; + storeHashAlgorithm?: StoreHashAlgorithm | ((key: string, storeHashSize: number) => number); }; type SetOptions = { ttl?: number | string; @@ -146,17 +160,9 @@ type SetOptions = { }; declare class CacheableMemory extends Hookified { private _lru; - private readonly _hashCache; - private readonly _hash0; - private readonly _hash1; - private readonly _hash2; - private readonly _hash3; - private readonly _hash4; - private readonly _hash5; - private readonly _hash6; - private readonly _hash7; - private readonly _hash8; - private readonly _hash9; + private _storeHashSize; + private _storeHashAlgorithm; + private _store; private _ttl; private _useClone; private _lruSize; @@ -189,12 +195,12 @@ declare class CacheableMemory extends Hookified { set useClone(value: boolean); /** * Gets the size of the LRU cache - * @returns {number} - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. + * @returns {number} - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm. */ get lruSize(): number; /** * Sets the size of the LRU cache - * @param {number} value - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. + * @param {number} value - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm. */ set lruSize(value: number); /** @@ -212,6 +218,26 @@ declare class CacheableMemory extends Hookified { * @returns {number} - The size of the cache */ get size(): number; + /** + * Gets the number of hash stores + * @returns {number} - The number of hash stores + */ + get storeHashSize(): number; + /** + * Sets the number of hash stores. This will recreate the store and all data will be cleared + * @param {number} value - The number of hash stores + */ + set storeHashSize(value: number); + /** + * Gets the store hash algorithm + * @returns {StoreHashAlgorithm | StoreHashAlgorithmFunction} - The store hash algorithm + */ + get storeHashAlgorithm(): StoreHashAlgorithm | StoreHashAlgorithmFunction; + /** + * Sets the store hash algorithm. This will recreate the store and all data will be cleared + * @param {StoreHashAlgorithm | StoreHashAlgorithmFunction} value - The store hash algorithm + */ + set storeHashAlgorithm(value: StoreHashAlgorithm | StoreHashAlgorithmFunction); /** * Gets the keys * @returns {IterableIterator} - The keys @@ -222,6 +248,11 @@ declare class CacheableMemory extends Hookified { * @returns {IterableIterator} - The items */ get items(): IterableIterator; + /** + * Gets the store + * @returns {Array>} - The store + */ + get store(): Array>; /** * Gets the value of the key * @param {string} key - The key to get the value @@ -310,17 +341,12 @@ declare class CacheableMemory extends Hookified { */ getStore(key: string): Map; /** - * Get the store based on the hash (internal use) - * @param {number} hash - * @returns {Map} + * Hash the key for which store to go to (internal use) + * @param {string} key - The key to hash + * Available algorithms are: SHA256, SHA1, MD5, and djb2Hash. + * @returns {number} - The hashed key as a number */ - getStoreFromHash(hash: number): Map; - /** - * Hash the key (internal use) - * @param key - * @returns {number} from 0 to 9 - */ - hashKey(key: string): number; + getKeyStoreHash(key: string): number; /** * Clone the value. This is for internal use * @param {any} value - The value to clone @@ -340,7 +366,7 @@ declare class CacheableMemory extends Hookified { */ lruMoveToFront(key: string): void; /** - * Resize the LRU cache. This is for internal use + * Resize the LRU cache. This is for internal use. * @returns {void} */ lruResize(): void; @@ -359,13 +385,6 @@ declare class CacheableMemory extends Hookified { * @returns {void} */ stopIntervalCheck(): void; - /** - * Hash the object. This is for internal use - * @param {any} object - The object to hash - * @param {string} [algorithm='sha256'] - The algorithm to hash - * @returns {string} - The hashed string - */ - hash(object: any, algorithm?: string): string; /** * Wrap the function for caching * @param {Function} function_ - The function to wrap @@ -374,8 +393,8 @@ declare class CacheableMemory extends Hookified { */ wrap(function_: (...arguments_: Arguments) => T, options?: WrapFunctionOptions): (...arguments_: Arguments) => T; private isPrimitive; - private concatStores; private setTtl; + private hasExpired; } type KeyvCacheableMemoryOptions = CacheableMemoryOptions & { @@ -423,7 +442,8 @@ declare enum CacheableHooks { BEFORE_GET = "BEFORE_GET", AFTER_GET = "AFTER_GET", BEFORE_GET_MANY = "BEFORE_GET_MANY", - AFTER_GET_MANY = "AFTER_GET_MANY" + AFTER_GET_MANY = "AFTER_GET_MANY", + BEFORE_SECONDARY_SETS_PRIMARY = "BEFORE_SECONDARY_SETS_PRIMARY" } declare enum CacheableEvents { ERROR = "error" @@ -593,17 +613,46 @@ declare class Cacheable extends Hookified { setSecondary(secondary: Keyv | KeyvStoreAdapter): void; getNameSpace(): string | undefined; /** - * Gets the value of the key. If the key does not exist in the primary store then it will check the secondary store. - * @param {string} key The key to get the value of - * @returns {Promise} The value of the key or undefined if the key does not exist - */ - get(key: string): Promise; - /** - * Gets the values of the keys. If the key does not exist in the primary store then it will check the secondary store. - * @param {string[]} keys The keys to get the values of - * @returns {Promise>} The values of the keys or undefined if the key does not exist - */ - getMany(keys: string[]): Promise>; + * Retrieves an entry from the cache, with an optional ā€œrawā€ mode. + * + * Checks the primary store first; if not found and a secondary store is configured, + * it will fetch from the secondary, repopulate the primary, and return the result. + * + * @typeParam T - The expected type of the stored value. + * @param {string} key - The cache key to retrieve. + * @param {{ raw?: boolean }} [opts] - Options for retrieval. + * @param {boolean} [opts.raw=false] - If `true`, returns the full raw data object + * (`StoredDataRaw`); otherwise returns just the value. + * @returns {Promise | undefined>} + * A promise that resolves to the cached value (or raw data) if found, or `undefined`. + */ + get(key: string, options?: { + raw?: false; + }): Promise; + get(key: string, options: { + raw: true; + }): Promise>; + /** + * Retrieves multiple entries from the cache. + * Checks the primary store for each key; if a key is missing and a secondary store is configured, + * it will fetch from the secondary store, repopulate the primary store, and return the results. + * + * @typeParam T - The expected type of the stored values. + * @param {string[]} keys - The cache keys to retrieve. + * @param {{ raw?: boolean }} [options] - Options for retrieval. + * @param {boolean} [options.raw=false] - When `true`, returns an array of raw data objects (`StoredDataRaw`); + * when `false`, returns an array of unwrapped values (`T`) or `undefined` for misses. + * @returns {Promise> | Promise>>} + * A promise that resolves to: + * - `Array` if `raw` is `false` (default). + * - `Array>` if `raw` is `true`. + */ + getMany(keys: string[], options?: { + raw?: false; + }): Promise>; + getMany(keys: string[], options: { + raw: true; + }): Promise>>; /** * Sets the value of the key. If the secondary store is set then it will also set the value in the secondary store. * @param {string} key the key to set the value of @@ -674,6 +723,16 @@ declare class Cacheable extends Hookified { * @returns {Function} The wrapped function */ wrap(function_: (...arguments_: Arguments) => T, options?: WrapFunctionOptions): (...arguments_: Arguments) => T; + /** + * Retrieves the value associated with the given key from the cache. If the key is not found, + * invokes the provided function to calculate the value, stores it in the cache, and then returns it. + * + * @param {string} key - The key to retrieve or set in the cache. + * @param {() => Promise} function_ - The asynchronous function that computes the value to be cached if the key does not exist. + * @param {WrapFunctionOptions} [options] - Optional settings for caching, such as the time to live (TTL) or whether to cache errors. + * @return {Promise} - A promise that resolves to the cached or newly computed value, or undefined if an error occurs and caching is not configured for errors. + */ + getOrSet(key: string, function_: () => Promise, options?: GetOrSetFunctionOptions): Promise; /** * Will hash an object using the specified algorithm. The default algorithm is 'sha256'. * @param {any} object the object to hash @@ -681,6 +740,8 @@ declare class Cacheable extends Hookified { * @returns {string} the hash of the object */ hash(object: any, algorithm?: string): string; + private getSecondaryRawResults; + private getManySecondaryRawResults; private deleteManyKeyv; private setManyKeyv; private hasManyKeyv; diff --git a/node_modules/cacheable/dist/index.js b/node_modules/cacheable/dist/index.js index 6da0f3d6953d..0df77551a9b9 100644 --- a/node_modules/cacheable/dist/index.js +++ b/node_modules/cacheable/dist/index.js @@ -78,7 +78,7 @@ import { import { Hookified } from "hookified"; // src/hash.ts -import * as crypto from "node:crypto"; +import * as crypto from "crypto"; function hash(object, algorithm = "sha256") { const objectString = JSON.stringify(object); if (!crypto.getHashes().includes(algorithm)) { @@ -88,6 +88,26 @@ function hash(object, algorithm = "sha256") { hasher.update(objectString); return hasher.digest("hex"); } +function hashToNumber(object, min = 0, max = 10, algorithm = "sha256") { + const objectString = JSON.stringify(object); + if (!crypto.getHashes().includes(algorithm)) { + throw new Error(`Unsupported hash algorithm: '${algorithm}'`); + } + const hasher = crypto.createHash(algorithm); + hasher.update(objectString); + const hashHex = hasher.digest("hex"); + const hashNumber = Number.parseInt(hashHex, 16); + const range = max - min + 1; + return min + hashNumber % range; +} +function djb2Hash(string_, min = 0, max = 10) { + let hash2 = 5381; + for (let i = 0; i < string_.length; i++) { + hash2 = hash2 * 33 ^ string_.charCodeAt(i); + } + const range = max - min + 1; + return min + Math.abs(hash2) % range; +} // src/coalesce-async.ts var callbacks = /* @__PURE__ */ new Map(); @@ -164,29 +184,31 @@ function wrapSync(function_, options) { return value; }; } +async function getOrSet(key, function_, options) { + let value = await options.cache.get(key); + if (value === void 0) { + const cacheId = options.cacheId ?? "default"; + const coalesceKey = `${cacheId}::${key}`; + value = await coalesceAsync(coalesceKey, async () => { + try { + const result = await function_(); + await options.cache.set(key, result, options.ttl); + return result; + } catch (error) { + options.cache.emit("error", error); + if (options.cacheErrors) { + await options.cache.set(key, error, options.ttl); + } + } + }); + } + return value; +} function wrap(function_, options) { - const { ttl, keyPrefix, cache } = options; + const { keyPrefix, cache } = options; return async function(...arguments_) { - let value; const cacheKey = createWrapKey(function_, arguments_, keyPrefix); - value = await cache.get(cacheKey); - if (value === void 0) { - const cacheId = options.cacheId ?? "default"; - const coalesceKey = `${cacheId}::${cacheKey}`; - value = await coalesceAsync(coalesceKey, async () => { - try { - const result = await function_(...arguments_); - await cache.set(cacheKey, result, ttl); - return result; - } catch (error) { - cache.emit("error", error); - if (options.cacheErrors) { - await cache.set(cacheKey, error, ttl); - } - } - }); - } - return value; + return cache.getOrSet(cacheKey, async () => function_(...arguments_), options); }; } function createWrapKey(function_, arguments_, keyPrefix) { @@ -270,19 +292,14 @@ var DoublyLinkedList = class { }; // src/memory.ts +var defaultStoreHashSize = 16; +var maximumMapSize = 16777216; var CacheableMemory = class extends Hookified { _lru = new DoublyLinkedList(); - _hashCache = /* @__PURE__ */ new Map(); - _hash0 = /* @__PURE__ */ new Map(); - _hash1 = /* @__PURE__ */ new Map(); - _hash2 = /* @__PURE__ */ new Map(); - _hash3 = /* @__PURE__ */ new Map(); - _hash4 = /* @__PURE__ */ new Map(); - _hash5 = /* @__PURE__ */ new Map(); - _hash6 = /* @__PURE__ */ new Map(); - _hash7 = /* @__PURE__ */ new Map(); - _hash8 = /* @__PURE__ */ new Map(); - _hash9 = /* @__PURE__ */ new Map(); + _storeHashSize = defaultStoreHashSize; + _storeHashAlgorithm = "djb2Hash" /* djb2Hash */; + // Default is djb2Hash + _store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map()); _ttl; // Turned off by default _useClone = true; @@ -305,12 +322,23 @@ var CacheableMemory = class extends Hookified { if (options?.useClone !== void 0) { this._useClone = options.useClone; } + if (options?.storeHashSize && options.storeHashSize > 0) { + this._storeHashSize = options.storeHashSize; + } if (options?.lruSize) { - this._lruSize = options.lruSize; + if (options.lruSize > maximumMapSize) { + this.emit("error", new Error(`LRU size cannot be larger than ${maximumMapSize} due to Map limitations.`)); + } else { + this._lruSize = options.lruSize; + } } if (options?.checkInterval) { this._checkInterval = options.checkInterval; } + if (options?.storeHashAlgorithm) { + this._storeHashAlgorithm = options.storeHashAlgorithm; + } + this._store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map()); this.startIntervalCheck(); } /** @@ -343,17 +371,25 @@ var CacheableMemory = class extends Hookified { } /** * Gets the size of the LRU cache - * @returns {number} - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. + * @returns {number} - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm. */ get lruSize() { return this._lruSize; } /** * Sets the size of the LRU cache - * @param {number} value - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. + * @param {number} value - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm. */ set lruSize(value) { + if (value > maximumMapSize) { + this.emit("error", new Error(`LRU size cannot be larger than ${maximumMapSize} due to Map limitations.`)); + return; + } this._lruSize = value; + if (this._lruSize === 0) { + this._lru = new DoublyLinkedList(); + return; + } this.lruResize(); } /** @@ -375,21 +411,85 @@ var CacheableMemory = class extends Hookified { * @returns {number} - The size of the cache */ get size() { - return this._hash0.size + this._hash1.size + this._hash2.size + this._hash3.size + this._hash4.size + this._hash5.size + this._hash6.size + this._hash7.size + this._hash8.size + this._hash9.size; + let size = 0; + for (const store of this._store) { + size += store.size; + } + return size; + } + /** + * Gets the number of hash stores + * @returns {number} - The number of hash stores + */ + get storeHashSize() { + return this._storeHashSize; + } + /** + * Sets the number of hash stores. This will recreate the store and all data will be cleared + * @param {number} value - The number of hash stores + */ + set storeHashSize(value) { + if (value === this._storeHashSize) { + return; + } + this._storeHashSize = value; + this._store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map()); + } + /** + * Gets the store hash algorithm + * @returns {StoreHashAlgorithm | StoreHashAlgorithmFunction} - The store hash algorithm + */ + get storeHashAlgorithm() { + return this._storeHashAlgorithm; + } + /** + * Sets the store hash algorithm. This will recreate the store and all data will be cleared + * @param {StoreHashAlgorithm | StoreHashAlgorithmFunction} value - The store hash algorithm + */ + set storeHashAlgorithm(value) { + this._storeHashAlgorithm = value; } /** * Gets the keys * @returns {IterableIterator} - The keys */ get keys() { - return this.concatStores().keys(); + const keys = new Array(); + for (const store of this._store) { + for (const key of store.keys()) { + const item = store.get(key); + if (item && this.hasExpired(item)) { + store.delete(key); + continue; + } + keys.push(key); + } + } + return keys.values(); } /** * Gets the items * @returns {IterableIterator} - The items */ get items() { - return this.concatStores().values(); + const items = new Array(); + for (const store of this._store) { + for (const item of store.values()) { + if (this.hasExpired(item)) { + store.delete(item.key); + continue; + } + items.push(item); + } + } + return items.values(); + } + /** + * Gets the store + * @returns {Array>} - The store + */ + get store() { + return this._store; } /** * Gets the value of the key @@ -402,7 +502,7 @@ var CacheableMemory = class extends Hookified { if (!item) { return void 0; } - if (item.expires && item.expires && Date.now() > item.expires) { + if (item.expires && Date.now() > item.expires) { store.delete(key); return void 0; } @@ -585,17 +685,7 @@ var CacheableMemory = class extends Hookified { * @returns {void} */ clear() { - this._hash0.clear(); - this._hash1.clear(); - this._hash2.clear(); - this._hash3.clear(); - this._hash4.clear(); - this._hash5.clear(); - this._hash6.clear(); - this._hash7.clear(); - this._hash8.clear(); - this._hash9.clear(); - this._hashCache.clear(); + this._store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map()); this._lru = new DoublyLinkedList(); } /** @@ -604,66 +694,27 @@ var CacheableMemory = class extends Hookified { * @returns {CacheableHashStore} - The store */ getStore(key) { - const hash2 = this.hashKey(key); - return this.getStoreFromHash(hash2); + const hash2 = this.getKeyStoreHash(key); + this._store[hash2] ||= /* @__PURE__ */ new Map(); + return this._store[hash2]; } /** - * Get the store based on the hash (internal use) - * @param {number} hash - * @returns {Map} + * Hash the key for which store to go to (internal use) + * @param {string} key - The key to hash + * Available algorithms are: SHA256, SHA1, MD5, and djb2Hash. + * @returns {number} - The hashed key as a number */ - getStoreFromHash(hash2) { - switch (hash2) { - case 1: { - return this._hash1; - } - case 2: { - return this._hash2; - } - case 3: { - return this._hash3; - } - case 4: { - return this._hash4; - } - case 5: { - return this._hash5; - } - case 6: { - return this._hash6; - } - case 7: { - return this._hash7; - } - case 8: { - return this._hash8; - } - case 9: { - return this._hash9; - } - default: { - return this._hash0; - } + getKeyStoreHash(key) { + if (this._store.length === 1) { + return 0; } - } - /** - * Hash the key (internal use) - * @param key - * @returns {number} from 0 to 9 - */ - hashKey(key) { - const cacheHashNumber = this._hashCache.get(key); - if (cacheHashNumber) { - return cacheHashNumber; + if (this._storeHashAlgorithm === "djb2Hash" /* djb2Hash */) { + return djb2Hash(key, 0, this._storeHashSize); } - let hash2 = 0; - const primeMultiplier = 31; - for (let i = 0; i < key.length; i++) { - hash2 = hash2 * primeMultiplier + key.charCodeAt(i); + if (typeof this._storeHashAlgorithm === "function") { + return this._storeHashAlgorithm(key, this._storeHashSize); } - const result = Math.abs(hash2) % 10; - this._hashCache.set(key, result); - return result; + return hashToNumber(key, 0, this._storeHashSize, this._storeHashAlgorithm); } /** * Clone the value. This is for internal use @@ -699,13 +750,10 @@ var CacheableMemory = class extends Hookified { this._lru.moveToFront(key); } /** - * Resize the LRU cache. This is for internal use + * Resize the LRU cache. This is for internal use. * @returns {void} */ lruResize() { - if (this._lruSize === 0) { - return; - } while (this._lru.size > this._lruSize) { const oldestKey = this._lru.getOldest(); if (oldestKey) { @@ -719,10 +767,11 @@ var CacheableMemory = class extends Hookified { * @returns {void} */ checkExpiration() { - const stores = this.concatStores(); - for (const item of stores.values()) { - if (item.expires && Date.now() > item.expires) { - this.delete(item.key); + for (const store of this._store) { + for (const item of store.values()) { + if (item.expires && Date.now() > item.expires) { + store.delete(item.key); + } } } } @@ -751,15 +800,6 @@ var CacheableMemory = class extends Hookified { this._interval = 0; this._checkInterval = 0; } - /** - * Hash the object. This is for internal use - * @param {any} object - The object to hash - * @param {string} [algorithm='sha256'] - The algorithm to hash - * @returns {string} - The hashed string - */ - hash(object, algorithm = "sha256") { - return hash(object, algorithm); - } /** * Wrap the function for caching * @param {Function} function_ - The function to wrap @@ -784,9 +824,6 @@ var CacheableMemory = class extends Hookified { } return result; } - concatStores() { - return new Map([...this._hash0, ...this._hash1, ...this._hash2, ...this._hash3, ...this._hash4, ...this._hash5, ...this._hash6, ...this._hash7, ...this._hash8, ...this._hash9]); - } setTtl(ttl) { if (typeof ttl === "string" || ttl === void 0) { this._ttl = ttl; @@ -796,6 +833,12 @@ var CacheableMemory = class extends Hookified { this._ttl = void 0; } } + hasExpired(item) { + if (item.expires && Date.now() > item.expires) { + return true; + } + return false; + } }; // src/keyv-memory.ts @@ -1103,6 +1146,35 @@ var CacheableStats = class { } }; +// src/ttl.ts +function getTtlFromExpires(expires) { + if (expires === void 0 || expires === null) { + return void 0; + } + const now = Date.now(); + if (expires < now) { + return void 0; + } + return expires - now; +} +function getCascadingTtl(cacheableTtl, primaryTtl, secondaryTtl) { + return secondaryTtl ?? primaryTtl ?? shorthandToMilliseconds(cacheableTtl); +} +function calculateTtlFromExpiration(ttl, expires) { + const ttlFromExpires = getTtlFromExpires(expires); + const expiresFromTtl = ttl ? Date.now() + ttl : void 0; + if (ttlFromExpires === void 0) { + return ttl; + } + if (expiresFromTtl === void 0) { + return ttlFromExpires; + } + if (expires > expiresFromTtl) { + return ttl; + } + return ttlFromExpires; +} + // src/index.ts import { KeyvHooks, @@ -1117,6 +1189,7 @@ var CacheableHooks = /* @__PURE__ */ ((CacheableHooks2) => { CacheableHooks2["AFTER_GET"] = "AFTER_GET"; CacheableHooks2["BEFORE_GET_MANY"] = "BEFORE_GET_MANY"; CacheableHooks2["AFTER_GET_MANY"] = "AFTER_GET_MANY"; + CacheableHooks2["BEFORE_SECONDARY_SETS_PRIMARY"] = "BEFORE_SECONDARY_SETS_PRIMARY"; return CacheableHooks2; })(CacheableHooks || {}); var CacheableEvents = /* @__PURE__ */ ((CacheableEvents2) => { @@ -1325,25 +1398,26 @@ var Cacheable = class extends Hookified2 { } return this._namespace; } - /** - * Gets the value of the key. If the key does not exist in the primary store then it will check the secondary store. - * @param {string} key The key to get the value of - * @returns {Promise} The value of the key or undefined if the key does not exist - */ - async get(key) { + async get(key, options = {}) { let result; + const { raw = false } = options; try { await this.hook("BEFORE_GET" /* BEFORE_GET */, key); - result = await this._primary.get(key); + result = await this._primary.get(key, { raw: true }); + let ttl; if (!result && this._secondary) { - const rawResult = await this._secondary.get(key, { raw: true }); - if (rawResult) { - result = rawResult.value; - const finalTtl = rawResult.expires ?? void 0; - await this._primary.set(key, result, finalTtl); + const secondaryResult = await this.getSecondaryRawResults(key); + if (secondaryResult?.value) { + result = secondaryResult; + const cascadeTtl = getCascadingTtl(this._ttl, this._primary.ttl); + const expires = secondaryResult.expires ?? void 0; + ttl = calculateTtlFromExpiration(cascadeTtl, expires); + const setItem = { key, value: result.value, ttl }; + await this.hook("BEFORE_SECONDARY_SETS_PRIMARY" /* BEFORE_SECONDARY_SETS_PRIMARY */, setItem); + await this._primary.set(setItem.key, setItem.value, setItem.ttl); } } - await this.hook("AFTER_GET" /* AFTER_GET */, { key, result }); + await this.hook("AFTER_GET" /* AFTER_GET */, { key, result, ttl }); } catch (error) { this.emit("error" /* ERROR */, error); } @@ -1355,18 +1429,14 @@ var Cacheable = class extends Hookified2 { } this.stats.incrementGets(); } - return result; + return raw ? result : result?.value; } - /** - * Gets the values of the keys. If the key does not exist in the primary store then it will check the secondary store. - * @param {string[]} keys The keys to get the values of - * @returns {Promise>} The values of the keys or undefined if the key does not exist - */ - async getMany(keys) { + async getMany(keys, options = {}) { let result = []; + const { raw = false } = options; try { await this.hook("BEFORE_GET_MANY" /* BEFORE_GET_MANY */, keys); - result = await this._primary.get(keys); + result = await this._primary.get(keys, { raw: true }); if (this._secondary) { const missingKeys = []; for (const [i, key] of keys.entries()) { @@ -1374,12 +1444,16 @@ var Cacheable = class extends Hookified2 { missingKeys.push(key); } } - const secondaryResult = await this._secondary.get(missingKeys); - for (const [i, key] of keys.entries()) { - if (!result[i] && secondaryResult[i]) { - result[i] = secondaryResult[i]; - const finalTtl = shorthandToMilliseconds(this._ttl); - await this._primary.set(key, secondaryResult[i], finalTtl); + const secondaryResults = await this.getManySecondaryRawResults(missingKeys); + for await (const [i, key] of keys.entries()) { + if (!result[i] && secondaryResults[i]) { + result[i] = secondaryResults[i]; + const cascadeTtl = getCascadingTtl(this._ttl, this._primary.ttl); + const expires = secondaryResults[i].expires; + const ttl = calculateTtlFromExpiration(cascadeTtl, expires); + const setItem = { key, value: result[i].value, ttl }; + await this.hook("BEFORE_SECONDARY_SETS_PRIMARY" /* BEFORE_SECONDARY_SETS_PRIMARY */, setItem); + await this._primary.set(setItem.key, setItem.value, setItem.ttl); } } } @@ -1397,7 +1471,7 @@ var Cacheable = class extends Hookified2 { } this.stats.incrementGets(); } - return result; + return raw ? result : result.map((item) => item?.value); } /** * Sets the value of the key. If the secondary store is set then it will also set the value in the secondary store. @@ -1627,6 +1701,24 @@ var Cacheable = class extends Hookified2 { }; return wrap(function_, wrapOptions); } + /** + * Retrieves the value associated with the given key from the cache. If the key is not found, + * invokes the provided function to calculate the value, stores it in the cache, and then returns it. + * + * @param {string} key - The key to retrieve or set in the cache. + * @param {() => Promise} function_ - The asynchronous function that computes the value to be cached if the key does not exist. + * @param {WrapFunctionOptions} [options] - Optional settings for caching, such as the time to live (TTL) or whether to cache errors. + * @return {Promise} - A promise that resolves to the cached or newly computed value, or undefined if an error occurs and caching is not configured for errors. + */ + async getOrSet(key, function_, options) { + const getOrSetOptions = { + cache: this, + cacheId: this._cacheId, + ttl: options?.ttl ?? this._ttl, + cacheErrors: options?.cacheErrors + }; + return getOrSet(key, function_, getOrSetOptions); + } /** * Will hash an object using the specified algorithm. The default algorithm is 'sha256'. * @param {any} object the object to hash @@ -1636,6 +1728,20 @@ var Cacheable = class extends Hookified2 { hash(object, algorithm = "sha256") { return hash(object, algorithm); } + async getSecondaryRawResults(key) { + let result; + if (this._secondary) { + result = await this._secondary.get(key, { raw: true }); + } + return result; + } + async getManySecondaryRawResults(keys) { + let result = new Array(); + if (this._secondary) { + result = await this._secondary.get(keys, { raw: true }); + } + return result; + } async deleteManyKeyv(keyv, keys) { const promises = []; for (const key of keys) { diff --git a/node_modules/cacheable/package.json b/node_modules/cacheable/package.json index 95e9c1847ffd..2b6e2f2204f3 100644 --- a/node_modules/cacheable/package.json +++ b/node_modules/cacheable/package.json @@ -1,6 +1,6 @@ { "name": "cacheable", - "version": "1.8.9", + "version": "1.10.0", "description": "High Performance Layer 1 / Layer 2 Caching with Keyv Storage", "type": "module", "main": "./dist/index.cjs", @@ -21,20 +21,20 @@ "license": "MIT", "private": false, "devDependencies": { - "@faker-js/faker": "^9.5.1", - "@keyv/redis": "^4.3.1", - "@types/node": "^22.13.9", - "@vitest/coverage-v8": "^3.0.7", - "lru-cache": "^11.0.2", + "@faker-js/faker": "^9.7.0", + "@keyv/redis": "^4.4.0", + "@types/node": "^22.15.3", + "@vitest/coverage-v8": "^3.1.3", + "lru-cache": "^11.1.0", "rimraf": "^6.0.1", "tsup": "^8.4.0", - "typescript": "^5.8.2", - "vitest": "^3.0.7", + "typescript": "^5.8.3", + "vitest": "^3.1.3", "xo": "^0.60.0" }, "dependencies": { - "hookified": "^1.7.1", - "keyv": "^5.3.1" + "hookified": "^1.8.2", + "keyv": "^5.3.3" }, "keywords": [ "cacheable", diff --git a/node_modules/eslint/node_modules/eslint-visitor-keys/README.md b/node_modules/eslint/node_modules/eslint-visitor-keys/README.md index 3cbbdd39d0ad..aa860ba5774f 100644 --- a/node_modules/eslint/node_modules/eslint-visitor-keys/README.md +++ b/node_modules/eslint/node_modules/eslint-visitor-keys/README.md @@ -109,11 +109,12 @@ Welcome. See [ESLint contribution guidelines](https://eslint.org/docs/developer- The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate) to get your logo on our READMEs and [website](https://eslint.org/sponsors). -

Platinum Sponsors

+

Diamond Sponsors

+

AG Grid

Platinum Sponsors

Automattic Airbnb

Gold Sponsors

-

trunk.io

Silver Sponsors

-

JetBrains Liftoff American Express Workleap

Bronze Sponsors

-

WordHint Anagram Solver Icons8 Discord GitBook Nx HeroCoders

+

Qlty Software trunk.io Shopify

Silver Sponsors

+

Vite Liftoff American Express StackBlitz

Bronze Sponsors

+

Sentry Syntax Cybozu Anagram Solver Icons8 Discord GitBook Neko Nx Mercedes-Benz Group HeroCoders LambdaTest

Technology Sponsors

Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.

Netlify Algolia 1Password

diff --git a/node_modules/eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs b/node_modules/eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs index 7f58e49bcd4f..afc433c7cd5b 100644 --- a/node_modules/eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs +++ b/node_modules/eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs @@ -102,8 +102,8 @@ const KEYS = { "attributes" ], ExportSpecifier: [ - "exported", - "local" + "local", + "exported" ], ExpressionStatement: [ "expression" diff --git a/node_modules/eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts b/node_modules/eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts index a8684341f1cf..34253c96c3dd 100644 --- a/node_modules/eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts +++ b/node_modules/eslint/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts @@ -24,4 +24,5 @@ declare function unionWith(additionalKeys: VisitorKeys): VisitorKeys; type VisitorKeys = VisitorKeys$1; -export { KEYS, type VisitorKeys, getKeys, unionWith }; +export { KEYS, getKeys, unionWith }; +export type { VisitorKeys }; diff --git a/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.js b/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.js index 41feb4b2f8a9..c891e040af32 100644 --- a/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.js +++ b/node_modules/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.js @@ -100,8 +100,8 @@ const KEYS = { "attributes" ], ExportSpecifier: [ - "exported", - "local" + "local", + "exported" ], ExpressionStatement: [ "expression" diff --git a/node_modules/eslint/node_modules/eslint-visitor-keys/package.json b/node_modules/eslint/node_modules/eslint-visitor-keys/package.json index 4dc2123dbaf0..852e4ddb18cc 100644 --- a/node_modules/eslint/node_modules/eslint-visitor-keys/package.json +++ b/node_modules/eslint/node_modules/eslint-visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "eslint-visitor-keys", - "version": "4.2.0", + "version": "4.2.1", "description": "Constants and utilities about visitor keys to traverse AST.", "type": "module", "main": "dist/eslint-visitor-keys.cjs", @@ -29,12 +29,9 @@ "@types/estree": "^0.0.51", "@types/estree-jsx": "^0.0.1", "@typescript-eslint/parser": "^8.7.0", - "c8": "^7.11.0", - "chai": "^4.3.6", "eslint-release": "^3.2.0", "esquery": "^1.4.0", "json-diff": "^0.7.3", - "mocha": "^9.2.1", "opener": "^1.5.2", "rollup": "^4.22.4", "rollup-plugin-dts": "^6.1.1", @@ -55,9 +52,15 @@ "test:open-coverage": "c8 report --reporter lcov && opener coverage/lcov-report/index.html", "test:types": "tsd" }, - "repository": "eslint/js", + "repository": { + "type": "git", + "url": "https://github.com/eslint/js.git", + "directory": "packages/eslint-visitor-keys" + }, "funding": "https://opencollective.com/eslint", - "keywords": [], + "keywords": [ + "eslint" + ], "author": "Toru Nagashima (https://github.com/mysticatea)", "license": "Apache-2.0", "bugs": { diff --git a/node_modules/espree/node_modules/eslint-visitor-keys/README.md b/node_modules/espree/node_modules/eslint-visitor-keys/README.md index 3cbbdd39d0ad..aa860ba5774f 100644 --- a/node_modules/espree/node_modules/eslint-visitor-keys/README.md +++ b/node_modules/espree/node_modules/eslint-visitor-keys/README.md @@ -109,11 +109,12 @@ Welcome. See [ESLint contribution guidelines](https://eslint.org/docs/developer- The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate) to get your logo on our READMEs and [website](https://eslint.org/sponsors). -

Platinum Sponsors

+

Diamond Sponsors

+

AG Grid

Platinum Sponsors

Automattic Airbnb

Gold Sponsors

-

trunk.io

Silver Sponsors

-

JetBrains Liftoff American Express Workleap

Bronze Sponsors

-

WordHint Anagram Solver Icons8 Discord GitBook Nx HeroCoders

+

Qlty Software trunk.io Shopify

Silver Sponsors

+

Vite Liftoff American Express StackBlitz

Bronze Sponsors

+

Sentry Syntax Cybozu Anagram Solver Icons8 Discord GitBook Neko Nx Mercedes-Benz Group HeroCoders LambdaTest

Technology Sponsors

Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.

Netlify Algolia 1Password

diff --git a/node_modules/espree/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs b/node_modules/espree/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs index 7f58e49bcd4f..afc433c7cd5b 100644 --- a/node_modules/espree/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs +++ b/node_modules/espree/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs @@ -102,8 +102,8 @@ const KEYS = { "attributes" ], ExportSpecifier: [ - "exported", - "local" + "local", + "exported" ], ExpressionStatement: [ "expression" diff --git a/node_modules/espree/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts b/node_modules/espree/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts index a8684341f1cf..34253c96c3dd 100644 --- a/node_modules/espree/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts +++ b/node_modules/espree/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts @@ -24,4 +24,5 @@ declare function unionWith(additionalKeys: VisitorKeys): VisitorKeys; type VisitorKeys = VisitorKeys$1; -export { KEYS, type VisitorKeys, getKeys, unionWith }; +export { KEYS, getKeys, unionWith }; +export type { VisitorKeys }; diff --git a/node_modules/espree/node_modules/eslint-visitor-keys/lib/visitor-keys.js b/node_modules/espree/node_modules/eslint-visitor-keys/lib/visitor-keys.js index 41feb4b2f8a9..c891e040af32 100644 --- a/node_modules/espree/node_modules/eslint-visitor-keys/lib/visitor-keys.js +++ b/node_modules/espree/node_modules/eslint-visitor-keys/lib/visitor-keys.js @@ -100,8 +100,8 @@ const KEYS = { "attributes" ], ExportSpecifier: [ - "exported", - "local" + "local", + "exported" ], ExpressionStatement: [ "expression" diff --git a/node_modules/espree/node_modules/eslint-visitor-keys/package.json b/node_modules/espree/node_modules/eslint-visitor-keys/package.json index 4dc2123dbaf0..852e4ddb18cc 100644 --- a/node_modules/espree/node_modules/eslint-visitor-keys/package.json +++ b/node_modules/espree/node_modules/eslint-visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "eslint-visitor-keys", - "version": "4.2.0", + "version": "4.2.1", "description": "Constants and utilities about visitor keys to traverse AST.", "type": "module", "main": "dist/eslint-visitor-keys.cjs", @@ -29,12 +29,9 @@ "@types/estree": "^0.0.51", "@types/estree-jsx": "^0.0.1", "@typescript-eslint/parser": "^8.7.0", - "c8": "^7.11.0", - "chai": "^4.3.6", "eslint-release": "^3.2.0", "esquery": "^1.4.0", "json-diff": "^0.7.3", - "mocha": "^9.2.1", "opener": "^1.5.2", "rollup": "^4.22.4", "rollup-plugin-dts": "^6.1.1", @@ -55,9 +52,15 @@ "test:open-coverage": "c8 report --reporter lcov && opener coverage/lcov-report/index.html", "test:types": "tsd" }, - "repository": "eslint/js", + "repository": { + "type": "git", + "url": "https://github.com/eslint/js.git", + "directory": "packages/eslint-visitor-keys" + }, "funding": "https://opencollective.com/eslint", - "keywords": [], + "keywords": [ + "eslint" + ], "author": "Toru Nagashima (https://github.com/mysticatea)", "license": "Apache-2.0", "bugs": { diff --git a/node_modules/hookified/README.md b/node_modules/hookified/README.md index 4c7c0951a5ee..fb62c64a9ac6 100644 --- a/node_modules/hookified/README.md +++ b/node_modules/hookified/README.md @@ -1,4 +1,4 @@ -![site/logo.svg](site/logo.svg) +![Hookified](site/logo.svg) # Event Emitting and Middleware Hooks @@ -6,16 +6,54 @@ [![GitHub license](https://img.shields.io/github/license/jaredwray/hookified)](https://github.com/jaredwray/hookified/blob/master/LICENSE) [![codecov](https://codecov.io/gh/jaredwray/hookified/graph/badge.svg?token=nKkVklTFdA)](https://codecov.io/gh/jaredwray/hookified) [![npm](https://img.shields.io/npm/dm/hookified)](https://npmjs.com/package/hookified) -[![jsDelivr hits](https://img.shields.io/jsdelivr/npm/hm/hookified)](https://www.jsdelivr.com/package/npm/hookified) +[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/hookified/badge)](https://www.jsdelivr.com/package/npm/hookified) [![npm](https://img.shields.io/npm/v/hookified)](https://npmjs.com/package/hookified) # Features - Simple replacement for EventEmitter -- Async / Sync Middleware Hooks for Your Methods +- Async / Sync Middleware Hooks for Your Methods - ESM / CJS with Types and Nodejs 20+ - Browser Support and Delivered via CDN +- Ability to throw errors in hooks +- Ability to pass in a logger (such as Pino) for errors +- No package dependencies and only 100KB in size +- Fast and Efficient with [Benchmarks](#benchmarks) - Maintained on a regular basis! +# Table of Contents +- [Installation](#installation) +- [Usage](#usage) +- [Using it in the Browser](#using-it-in-the-browser) +- [API - Hooks](#api---hooks) + - [.throwHookErrors](#throwhookerrors) + - [.onHook(eventName, handler)](#onhookeventname-handler) + - [.onHooks(Array)](#onhooksarray) + - [.onceHook(eventName, handler)](#oncehookeventname-handler) + - [.prependHook(eventName, handler)](#prependhookeventname-handler) + - [.prependOnceHook(eventName, handler)](#prependoncehookeventname-handler) + - [.removeHook(eventName)](#removehookeventname) + - [.removeHooks(Array)](#removehooksarray) + - [.hook(eventName, ...args)](#hookeventname-args) + - [.hooks](#hooks) + - [.getHooks(eventName)](#gethookseventname) + - [.clearHooks(eventName)](#clearhookeventname) +- [API - Events](#api---events) + - [.on(eventName, handler)](#oneventname-handler) + - [.off(eventName, handler)](#offeventname-handler) + - [.emit(eventName, ...args)](#emiteventname-args) + - [.listeners(eventName)](#listenerseventname) + - [.removeAllListeners(eventName)](#removealllistenerseventname) + - [.setMaxListeners(maxListeners: number)](#setmaxlistenersmaxlisteners-number) + - [.once(eventName, handler)](#oneventname-handler-1) + - [.prependListener(eventName, handler)](#prependlistenereventname-handler) + - [.prependOnceListener(eventName, handler)](#prependoncelistenereventname-handler) + - [.eventNames()](#eventnames) + - [.listenerCount(eventName?)](#listenercounteventname) + - [.rawListeners(eventName?)](#rawlistenerseventname) +- [Development and Contribution](#development-and-contribution) +- [Benchmarks](#benchmarks) +- [License](#license) + # Installation ```bash npm install hookified --save @@ -132,7 +170,7 @@ import { Hookified } from 'hookified'; class MyClass extends Hookified { constructor() { - super({ throwHookErrors: true}); + super({ throwHookErrors: true }); } } @@ -152,9 +190,38 @@ try { myClass.throwHookErrors = false; console.log(myClass.throwHookErrors); // false +``` + +## .logger +If set, errors thrown in hooks will be logged to the logger. If not set, errors will be only emitted. + +```javascript +import { Hookified } from 'hookified'; +import pino from 'pino'; + +const logger = pino(); // create a logger instance that is compatible with Logger type +class MyClass extends Hookified { + constructor() { + super({ logger }); + } + + async myMethodWithHooks() Promise { + let data = { some: 'data' }; + // do something + await this.hook('before:myMethod2', data); + + return data; + } +} +const myClass = new MyClass(); +myClass.onHook('before:myMethod2', async () => { + throw new Error('error'); +}); +// when you call before:myMethod2 it will log the error to the logger +await myClass.hook('before:myMethod2'); ``` ## .onHook(eventName, handler) @@ -184,6 +251,48 @@ myClass.onHook('before:myMethod2', async (data) => { }); ``` +## .onHooks(Array) + +Subscribe to multiple hook events at once + +```javascript +import { Hookified } from 'hookified'; + +class MyClass extends Hookified { + constructor() { + super(); + } + + async myMethodWithHooks() Promise { + let data = { some: 'data' }; + await this.hook('before:myMethodWithHooks', data); + + // do something here with the data + data.some = 'new data'; + + await this.hook('after:myMethodWithHooks', data); + + return data; + } +} + +const myClass = new MyClass(); +const hooks = [ + { + event: 'before:myMethodWithHooks', + handler: async (data) => { + data.some = 'new data1'; + }, + }, + { + event: 'after:myMethodWithHooks', + handler: async (data) => { + data.some = 'new data2'; + }, + }, +]; +``` + ## .onceHook(eventName, handler) Subscribe to a hook event once. @@ -307,6 +416,51 @@ myClass.onHook('before:myMethod2', handler); myClass.removeHook('before:myMethod2', handler); ``` +## .removeHooks(Array) +Unsubscribe from multiple hooks. + +```javascript +import { Hookified } from 'hookified'; + +class MyClass extends Hookified { + constructor() { + super(); + } + + async myMethodWithHooks() Promise { + let data = { some: 'data' }; + await this.hook('before:myMethodWithHooks', data); + + // do something + data.some = 'new data'; + await this.hook('after:myMethodWithHooks', data); + + return data; + } +} + +const myClass = new MyClass(); + +const hooks = [ + { + event: 'before:myMethodWithHooks', + handler: async (data) => { + data.some = 'new data1'; + }, + }, + { + event: 'after:myMethodWithHooks', + handler: async (data) => { + data.some = 'new data2'; + }, + }, +]; +myClass.onHooks(hooks); + +// remove all hooks +myClass.removeHook(hooks); +``` + ## .hook(eventName, ...args) Run a hook event. @@ -734,18 +888,48 @@ myClass.on('message', (message) => { console.log(myClass.rawListeners('message')); ``` -# Development and Testing +# Development and Contribution Hookified is written in TypeScript and tests are written in `vitest`. To run the tests, use the following command: To setup the environment and run the tests: ```bash -npm i && npm test +pnpm i && pnpm test +``` + +Note that we are using `pnpm` as our package manager. If you don't have it installed, you can install it globally with: + +```bash +npm install -g pnpm ``` To contribute follow the [Contributing Guidelines](CONTRIBUTING.md) and [Code of Conduct](CODE_OF_CONDUCT.md). +# Benchmarks + +We are doing very simple benchmarking to see how this compares to other libraries using `tinybench`. This is not a full benchmark but just a simple way to see how it performs. Our goal is to be as close or better than the other libraries including native (EventEmitter). + +## Hooks + +| name | summary | ops/sec | time/op | margin | samples | +|-------------------|:---------:|----------:|----------:|:--------:|----------:| +| Hookified 1.8.0 | šŸ„‡ | 4M | 299ns | ±2.42% | 3M | +| Hookable 5.5.3 | -73% | 982K | 1µs | ±2.92% | 812K | + +## Emits + +This shows how close the native `EventEmitter` is to `hookified` and `eventemitter3`. We are using the same test as above but just emitting events. It is not a fair comparison but it is interesting to see how close they are. + +| name | summary | ops/sec | time/op | margin | samples | +|-------------------------|:---------:|----------:|----------:|:--------:|----------:| +| Hookified 1.8.0 | šŸ„‡ | 10M | 112ns | ±1.13% | 9M | +| EventEmitter3 5.0.1 | -1.3% | 10M | 114ns | ±1.84% | 9M | +| EventEmitter v22.12.0 | -1.5% | 9M | 114ns | ±1.18% | 9M | +| Emittery 1.1.0 | -92% | 785K | 1µs | ±0.45% | 761K | + +_Note: the `EventEmitter` version is Nodejs versioning._ + # License [MIT & Ā© Jared Wray](LICENSE) diff --git a/node_modules/hookified/dist/browser/index.global.js b/node_modules/hookified/dist/browser/index.global.js index d84d25d36c14..bc49dc9a97b3 100644 --- a/node_modules/hookified/dist/browser/index.global.js +++ b/node_modules/hookified/dist/browser/index.global.js @@ -1,2 +1,2 @@ -"use strict";(()=>{var g=Object.defineProperty;var v=(i,t,e)=>t in i?g(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var o=(i,t,e)=>v(i,typeof t!="symbol"?t+"":t,e);var l=class{constructor(){o(this,"_eventListeners");o(this,"_maxListeners");this._eventListeners=new Map,this._maxListeners=100}once(t,e){let s=(...r)=>{this.off(t,s),e(...r)};return this.on(t,s),this}listenerCount(t){if(!t)return this.getAllListeners().length;let e=this._eventListeners.get(t);return e?e.length:0}eventNames(){return Array.from(this._eventListeners.keys())}rawListeners(t){return t?this._eventListeners.get(t)??[]:this.getAllListeners()}prependListener(t,e){let s=this._eventListeners.get(t)??[];return s.unshift(e),this._eventListeners.set(t,s),this}prependOnceListener(t,e){let s=(...r)=>{this.off(t,s),e(...r)};return this.prependListener(t,s),this}maxListeners(){return this._maxListeners}addListener(t,e){return this.on(t,e),this}on(t,e){this._eventListeners.has(t)||this._eventListeners.set(t,[]);let s=this._eventListeners.get(t);return s&&(s.length>=this._maxListeners&&console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length+1} ${t} listeners added. Use setMaxListeners() to increase limit.`),s.push(e)),this}removeListener(t,e){return this.off(t,e),this}off(t,e){let s=this._eventListeners.get(t)??[],r=s.indexOf(e);return r!==-1&&s.splice(r,1),s.length===0&&this._eventListeners.delete(t),this}emit(t,...e){let s=!1,r=this._eventListeners.get(t);if(r&&r.length>0)for(let n of r)n(...e),s=!0;return s}listeners(t){return this._eventListeners.get(t)??[]}removeAllListeners(t){return t?this._eventListeners.delete(t):this._eventListeners.clear(),this}setMaxListeners(t){this._maxListeners=t;for(let e of this._eventListeners.values())e.length>t&&e.splice(t)}getAllListeners(){let t=new Array;for(let e of this._eventListeners.values())t=t.concat(e);return t}};var m=class extends l{constructor(e){super();o(this,"_hooks");o(this,"_throwHookErrors",!1);this._hooks=new Map,e?.throwHookErrors!==void 0&&(this._throwHookErrors=e.throwHookErrors)}get hooks(){return this._hooks}get throwHookErrors(){return this._throwHookErrors}set throwHookErrors(e){this._throwHookErrors=e}onHook(e,s){let r=this._hooks.get(e);r?r.push(s):this._hooks.set(e,[s])}prependHook(e,s){let r=this._hooks.get(e);r?r.unshift(s):this._hooks.set(e,[s])}prependOnceHook(e,s){let r=async(...n)=>(this.removeHook(e,r),s(...n));this.prependHook(e,r)}onceHook(e,s){let r=async(...n)=>(this.removeHook(e,r),s(...n));this.onHook(e,r)}removeHook(e,s){let r=this._hooks.get(e);if(r){let n=r.indexOf(s);n!==-1&&r.splice(n,1)}}async hook(e,...s){let r=this._hooks.get(e);if(r)for(let n of r)try{await n(...s)}catch(h){let a=`${e}: ${h.message}`;if(this.emit("error",new Error(a)),this._throwHookErrors)throw new Error(a)}}getHooks(e){return this._hooks.get(e)}clearHooks(){this._hooks.clear()}};})(); +"use strict";(()=>{var a=Object.defineProperty;var u=(i,t,e)=>t in i?a(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var o=(i,t,e)=>u(i,typeof t!="symbol"?t+"":t,e);var l=class{constructor(t){o(this,"_eventListeners");o(this,"_maxListeners");o(this,"_logger");this._eventListeners=new Map,this._maxListeners=100,this._logger=t?.logger}once(t,e){let s=(...r)=>{this.off(t,s),e(...r)};return this.on(t,s),this}listenerCount(t){if(!t)return this.getAllListeners().length;let e=this._eventListeners.get(t);return e?e.length:0}eventNames(){return[...this._eventListeners.keys()]}rawListeners(t){return t?this._eventListeners.get(t)??[]:this.getAllListeners()}prependListener(t,e){let s=this._eventListeners.get(t)??[];return s.unshift(e),this._eventListeners.set(t,s),this}prependOnceListener(t,e){let s=(...r)=>{this.off(t,s),e(...r)};return this.prependListener(t,s),this}maxListeners(){return this._maxListeners}addListener(t,e){return this.on(t,e),this}on(t,e){this._eventListeners.has(t)||this._eventListeners.set(t,[]);let s=this._eventListeners.get(t);return s&&(s.length>=this._maxListeners&&console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length+1} ${t} listeners added. Use setMaxListeners() to increase limit.`),s.push(e)),this}removeListener(t,e){return this.off(t,e),this}off(t,e){let s=this._eventListeners.get(t)??[],r=s.indexOf(e);return r!==-1&&s.splice(r,1),s.length===0&&this._eventListeners.delete(t),this}emit(t,...e){let s=!1,r=this._eventListeners.get(t);if(r&&r.length>0)for(let n of r)n(...e),s=!0;return s}listeners(t){return this._eventListeners.get(t)??[]}removeAllListeners(t){return t?this._eventListeners.delete(t):this._eventListeners.clear(),this}setMaxListeners(t){this._maxListeners=t;for(let e of this._eventListeners.values())e.length>t&&e.splice(t)}getAllListeners(){let t=new Array;for(let e of this._eventListeners.values())t=[...t,...e];return t}};var h=class extends l{constructor(e){super({logger:e?.logger});o(this,"_hooks");o(this,"_throwHookErrors",!1);this._hooks=new Map,e?.throwHookErrors!==void 0&&(this._throwHookErrors=e.throwHookErrors)}get hooks(){return this._hooks}get throwHookErrors(){return this._throwHookErrors}set throwHookErrors(e){this._throwHookErrors=e}get logger(){return this._logger}set logger(e){this._logger=e}onHook(e,s){let r=this._hooks.get(e);r?r.push(s):this._hooks.set(e,[s])}onHooks(e){for(let s of e)this.onHook(s.event,s.handler)}prependHook(e,s){let r=this._hooks.get(e);r?r.unshift(s):this._hooks.set(e,[s])}prependOnceHook(e,s){let r=async(...n)=>(this.removeHook(e,r),s(...n));this.prependHook(e,r)}onceHook(e,s){let r=async(...n)=>(this.removeHook(e,r),s(...n));this.onHook(e,r)}removeHook(e,s){let r=this._hooks.get(e);if(r){let n=r.indexOf(s);n!==-1&&r.splice(n,1)}}removeHooks(e){for(let s of e)this.removeHook(s.event,s.handler)}async hook(e,...s){let r=this._hooks.get(e);if(r)for(let n of r)try{await n(...s)}catch(m){let g=`${e}: ${m.message}`;if(this.emit("error",new Error(g)),this._logger&&this._logger.error(g),this._throwHookErrors)throw new Error(g)}}getHooks(e){return this._hooks.get(e)}clearHooks(){this._hooks.clear()}};})(); //# sourceMappingURL=index.global.js.map \ No newline at end of file diff --git a/node_modules/hookified/dist/browser/index.global.js.map b/node_modules/hookified/dist/browser/index.global.js.map index c2109c34d6dd..7bfd6975a40c 100644 --- a/node_modules/hookified/dist/browser/index.global.js.map +++ b/node_modules/hookified/dist/browser/index.global.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/eventified.ts","../../src/index.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type IEventEmitter = {\n\t/**\n\t * Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.on('data', (message) => {\n\t * console.log(message);\n\t * });\n\t */\n\ton(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Alias for `on`. Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\taddListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Registers a one-time listener for the specified event. The listener is removed after it is called once.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.once('close', () => {\n\t * console.log('The connection was closed.');\n\t * });\n\t */\n\tonce(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.off('data', myListener);\n\t */\n\toff(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Alias for `off`. Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\tremoveListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Emits the specified event, invoking all registered listeners with the provided arguments.\n\t *\n\t * @param eventName - The name (or symbol) of the event to emit.\n\t * @param args - Arguments passed to each listener.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t *\n\t * @example\n\t * emitter.emit('data', 'Hello World');\n\t */\n\temit(eventName: string | symbol, ...arguments_: any[]): boolean;\n\n\t/**\n\t * Returns the number of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns The number of registered listeners.\n\t *\n\t * @example\n\t * const count = emitter.listenerCount('data');\n\t * console.log(count); // e.g., 2\n\t */\n\tlistenerCount(eventName: string | symbol): number;\n\n\t/**\n\t * Removes all listeners for the specified event. If no event is specified, it removes all listeners for all events.\n\t *\n\t * @param eventName - (Optional) The name (or symbol) of the event.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.removeAllListeners('data');\n\t */\n\tremoveAllListeners(eventName?: string | symbol): IEventEmitter;\n\n\t/**\n\t * Returns an array of event names for which listeners have been registered.\n\t *\n\t * @returns An array of event names (or symbols).\n\t *\n\t * @example\n\t * const events = emitter.eventNames();\n\t * console.log(events); // e.g., ['data', 'close']\n\t */\n\teventNames(): Array;\n\n\t/**\n\t * Returns an array of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of listener functions.\n\t *\n\t * @example\n\t * const listeners = emitter.listeners('data');\n\t * console.log(listeners.length); // e.g., 2\n\t */\n\tlisteners(eventName: string | symbol): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Returns an array of raw listeners for the specified event. This includes listeners wrapped by internal mechanisms (e.g., once-only listeners).\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of raw listener functions.\n\t *\n\t * @example\n\t * const rawListeners = emitter.rawListeners('data');\n\t */\n\trawListeners(eventName: string | symbol): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Adds a listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependListener('data', (message) => {\n\t * console.log('This will run first.');\n\t * });\n\t */\n\tprependListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Adds a one-time listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependOnceListener('data', (message) => {\n\t * console.log('This will run first and only once.');\n\t * });\n\t */\n\tprependOnceListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n};\n\nexport type EventListener = (...arguments_: any[]) => void;\n\nexport class Eventified implements IEventEmitter {\n\t_eventListeners: Map;\n\t_maxListeners: number;\n\n\tconstructor() {\n\t\tthis._eventListeners = new Map();\n\t\tthis._maxListeners = 100; // Default maximum number of listeners\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that will run only once\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tonce(eventName: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.on(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the number of listeners for a specific event. If no event is provided, it returns the total number of listeners\n\t * @param {string} eventName The event name. Not required\n\t * @returns {number} The number of listeners\n\t */\n\tlistenerCount(eventName?: string | symbol): number {\n\t\tif (!eventName) {\n\t\t\treturn this.getAllListeners().length;\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(eventName as string);\n\t\treturn listeners ? listeners.length : 0;\n\t}\n\n\t/**\n\t * Gets an array of event names\n\t * @returns {Array} An array of event names\n\t */\n\teventNames(): Array {\n\t\treturn Array.from(this._eventListeners.keys());\n\t}\n\n\t/**\n\t * Gets an array of listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\trawListeners(event?: string | symbol): EventListener[] {\n\t\tif (!event) {\n\t\t\treturn this.getAllListeners();\n\t\t}\n\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Prepends a listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tprependListener(eventName: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(eventName) ?? [];\n\t\tlisteners.unshift(listener);\n\t\tthis._eventListeners.set(eventName, listeners);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Prepends a one-time listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tprependOnceListener(eventName: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.prependListener(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the maximum number of listeners that can be added for a single event\n\t * @returns {number} The maximum number of listeners\n\t */\n\tpublic maxListeners(): number {\n\t\treturn this._maxListeners;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event. It is an alias for the on() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic addListener(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tthis.on(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic on(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tif (!this._eventListeners.has(event)) {\n\t\t\tthis._eventListeners.set(event, []);\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners) {\n\t\t\tif (listeners.length >= this._maxListeners) {\n\t\t\t\tconsole.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${listeners.length + 1} ${event as string} listeners added. Use setMaxListeners() to increase limit.`);\n\t\t\t}\n\n\t\t\tlisteners.push(listener);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event. It is an alias for the off() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeListener(event: string, listener: EventListener): IEventEmitter {\n\t\tthis.off(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic off(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(event) ?? [];\n\t\tconst index = listeners.indexOf(listener);\n\t\tif (index !== -1) {\n\t\t\tlisteners.splice(index, 1);\n\t\t}\n\n\t\tif (listeners.length === 0) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Calls all listeners for a specific event\n\t * @param {string | symbol} event\n\t * @param arguments_ The arguments to pass to the listeners\n\t * @returns {boolean} Returns true if the event had listeners, false otherwise\n\t */\n\tpublic emit(event: string | symbol, ...arguments_: any[]): boolean {\n\t\tlet result = false;\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners && listeners.length > 0) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\t\tlistener(...arguments_);\n\t\t\t\tresult = true;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Gets all listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic listeners(event: string): EventListener[] {\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Removes all listeners for a specific event. If no event is provided, it removes all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeAllListeners(event?: string): IEventEmitter {\n\t\tif (event) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t} else {\n\t\t\tthis._eventListeners.clear();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the maximum number of listeners that can be added for a single event\n\t * @param {number} n The maximum number of listeners\n\t * @returns {void}\n\t */\n\tpublic setMaxListeners(n: number): void {\n\t\tthis._maxListeners = n;\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tif (listeners.length > n) {\n\t\t\t\tlisteners.splice(n);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Gets all listeners\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic getAllListeners(): EventListener[] {\n\t\tlet result = new Array();\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tresult = result.concat(listeners);\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import {Eventified} from './eventified.js';\n\nexport type Hook = (...arguments_: any[]) => Promise | void;\n\nexport type HookifiedOptions = {\n\tthrowHookErrors?: boolean;\n};\n\nexport class Hookified extends Eventified {\n\t_hooks: Map;\n\t_throwHookErrors = false;\n\n\tconstructor(options?: HookifiedOptions) {\n\t\tsuper();\n\t\tthis._hooks = new Map();\n\n\t\tif (options?.throwHookErrors !== undefined) {\n\t\t\tthis._throwHookErrors = options.throwHookErrors;\n\t\t}\n\t}\n\n\t/**\n\t * Gets all hooks\n\t * @returns {Map}\n\t */\n\tget hooks() {\n\t\treturn this._hooks;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t */\n\tget throwHookErrors() {\n\t\treturn this._throwHookErrors;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t */\n\tset throwHookErrors(value) {\n\t\tthis._throwHookErrors = value;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tonHook(event: string, handler: Hook) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.push(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that runs before all other handlers\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tprependHook(event: string, handler: Hook) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.unshift(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event before all other handlers\n\t * @param event\n\t * @param handler\n\t */\n\tprependOnceHook(event: string, handler: Hook) {\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.prependHook(event, hook);\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event\n\t * @param event\n\t * @param handler\n\t */\n\tonceHook(event: string, handler: Hook) {\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.onHook(event, hook);\n\t}\n\n\t/**\n\t * Removes a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler\n\t * @returns {void}\n\t */\n\tremoveHook(event: string, handler: Hook) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tconst index = eventHandlers.indexOf(handler);\n\t\t\tif (index !== -1) {\n\t\t\t\teventHandlers.splice(index, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Calls all handlers for a specific event\n\t * @param {string} event\n\t * @param {T[]} arguments_\n\t * @returns {Promise}\n\t */\n\tasync hook(event: string, ...arguments_: T[]) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tfor (const handler of eventHandlers) {\n\t\t\t\ttry {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tawait handler(...arguments_);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = `${event}: ${(error as Error).message}`;\n\t\t\t\t\tthis.emit('error', new Error(message));\n\t\t\t\t\tif (this._throwHookErrors) {\n\t\t\t\t\t\tthrow new Error(message);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Gets all hooks for a specific event\n\t * @param {string} event\n\t * @returns {Hook[]}\n\t */\n\tgetHooks(event: string) {\n\t\treturn this._hooks.get(event);\n\t}\n\n\t/**\n\t * Removes all hooks\n\t * @returns {void}\n\t */\n\tclearHooks() {\n\t\tthis._hooks.clear();\n\t}\n}\n\nexport {Eventified, type EventListener} from './eventified.js';\n"],"mappings":"uLAgKO,IAAMA,EAAN,KAA0C,CAIhD,aAAc,CAHdC,EAAA,wBACAA,EAAA,sBAGC,KAAK,gBAAkB,IAAI,IAC3B,KAAK,cAAgB,GACtB,CAQA,KAAKC,EAA4BC,EAAwC,CACxE,IAAMC,EAA8B,IAAIC,IAAsB,CAC7D,KAAK,IAAIH,EAAqBE,CAAY,EAE1CD,EAAS,GAAGE,CAAU,CACvB,EAEA,YAAK,GAAGH,EAAqBE,CAAY,EAClC,IACR,CAOA,cAAcF,EAAqC,CAClD,GAAI,CAACA,EACJ,OAAO,KAAK,gBAAgB,EAAE,OAG/B,IAAMI,EAAY,KAAK,gBAAgB,IAAIJ,CAAmB,EAC9D,OAAOI,EAAYA,EAAU,OAAS,CACvC,CAMA,YAAqC,CACpC,OAAO,MAAM,KAAK,KAAK,gBAAgB,KAAK,CAAC,CAC9C,CAOA,aAAaC,EAA0C,CACtD,OAAKA,EAIE,KAAK,gBAAgB,IAAIA,CAAK,GAAK,CAAC,EAHnC,KAAK,gBAAgB,CAI9B,CAQA,gBAAgBL,EAA4BC,EAAwC,CACnF,IAAMG,EAAY,KAAK,gBAAgB,IAAIJ,CAAS,GAAK,CAAC,EAC1D,OAAAI,EAAU,QAAQH,CAAQ,EAC1B,KAAK,gBAAgB,IAAID,EAAWI,CAAS,EACtC,IACR,CAQA,oBAAoBJ,EAA4BC,EAAwC,CACvF,IAAMC,EAA8B,IAAIC,IAAsB,CAC7D,KAAK,IAAIH,EAAqBE,CAAY,EAE1CD,EAAS,GAAGE,CAAU,CACvB,EAEA,YAAK,gBAAgBH,EAAqBE,CAAY,EAC/C,IACR,CAMO,cAAuB,CAC7B,OAAO,KAAK,aACb,CAQO,YAAYG,EAAwBJ,EAAwC,CAClF,YAAK,GAAGI,EAAOJ,CAAQ,EAChB,IACR,CAQO,GAAGI,EAAwBJ,EAAwC,CACpE,KAAK,gBAAgB,IAAII,CAAK,GAClC,KAAK,gBAAgB,IAAIA,EAAO,CAAC,CAAC,EAGnC,IAAMD,EAAY,KAAK,gBAAgB,IAAIC,CAAK,EAEhD,OAAID,IACCA,EAAU,QAAU,KAAK,eAC5B,QAAQ,KAAK,qEAAqEA,EAAU,OAAS,CAAC,IAAIC,CAAe,4DAA4D,EAGtLD,EAAU,KAAKH,CAAQ,GAGjB,IACR,CAQO,eAAeI,EAAeJ,EAAwC,CAC5E,YAAK,IAAII,EAAOJ,CAAQ,EACjB,IACR,CAQO,IAAII,EAAwBJ,EAAwC,CAC1E,IAAMG,EAAY,KAAK,gBAAgB,IAAIC,CAAK,GAAK,CAAC,EAChDC,EAAQF,EAAU,QAAQH,CAAQ,EACxC,OAAIK,IAAU,IACbF,EAAU,OAAOE,EAAO,CAAC,EAGtBF,EAAU,SAAW,GACxB,KAAK,gBAAgB,OAAOC,CAAK,EAG3B,IACR,CAQO,KAAKA,KAA2BF,EAA4B,CAClE,IAAII,EAAS,GACPH,EAAY,KAAK,gBAAgB,IAAIC,CAAK,EAEhD,GAAID,GAAaA,EAAU,OAAS,EACnC,QAAWH,KAAYG,EAEtBH,EAAS,GAAGE,CAAU,EACtBI,EAAS,GAIX,OAAOA,CACR,CAOO,UAAUF,EAAgC,CAChD,OAAO,KAAK,gBAAgB,IAAIA,CAAK,GAAK,CAAC,CAC5C,CAOO,mBAAmBA,EAA+B,CACxD,OAAIA,EACH,KAAK,gBAAgB,OAAOA,CAAK,EAEjC,KAAK,gBAAgB,MAAM,EAGrB,IACR,CAOO,gBAAgBG,EAAiB,CACvC,KAAK,cAAgBA,EACrB,QAAWJ,KAAa,KAAK,gBAAgB,OAAO,EAC/CA,EAAU,OAASI,GACtBJ,EAAU,OAAOI,CAAC,CAGrB,CAMO,iBAAmC,CACzC,IAAID,EAAS,IAAI,MACjB,QAAWH,KAAa,KAAK,gBAAgB,OAAO,EACnDG,EAASA,EAAO,OAAOH,CAAS,EAGjC,OAAOG,CACR,CACD,ECpYO,IAAME,EAAN,cAAwBC,CAAW,CAIzC,YAAYC,EAA4B,CACvC,MAAM,EAJPC,EAAA,eACAA,EAAA,wBAAmB,IAIlB,KAAK,OAAS,IAAI,IAEdD,GAAS,kBAAoB,SAChC,KAAK,iBAAmBA,EAAQ,gBAElC,CAMA,IAAI,OAAQ,CACX,OAAO,KAAK,MACb,CAMA,IAAI,iBAAkB,CACrB,OAAO,KAAK,gBACb,CAMA,IAAI,gBAAgBE,EAAO,CAC1B,KAAK,iBAAmBA,CACzB,CAQA,OAAOC,EAAeC,EAAe,CACpC,IAAMC,EAAgB,KAAK,OAAO,IAAIF,CAAK,EACvCE,EACHA,EAAc,KAAKD,CAAO,EAE1B,KAAK,OAAO,IAAID,EAAO,CAACC,CAAO,CAAC,CAElC,CAQA,YAAYD,EAAeC,EAAe,CACzC,IAAMC,EAAgB,KAAK,OAAO,IAAIF,CAAK,EACvCE,EACHA,EAAc,QAAQD,CAAO,EAE7B,KAAK,OAAO,IAAID,EAAO,CAACC,CAAO,CAAC,CAElC,CAOA,gBAAgBD,EAAeC,EAAe,CAC7C,IAAME,EAAO,SAAUC,KACtB,KAAK,WAAWJ,EAAOG,CAAI,EAEpBF,EAAQ,GAAGG,CAAU,GAG7B,KAAK,YAAYJ,EAAOG,CAAI,CAC7B,CAOA,SAASH,EAAeC,EAAe,CACtC,IAAME,EAAO,SAAUC,KACtB,KAAK,WAAWJ,EAAOG,CAAI,EAEpBF,EAAQ,GAAGG,CAAU,GAG7B,KAAK,OAAOJ,EAAOG,CAAI,CACxB,CAQA,WAAWH,EAAeC,EAAe,CACxC,IAAMC,EAAgB,KAAK,OAAO,IAAIF,CAAK,EAC3C,GAAIE,EAAe,CAClB,IAAMG,EAAQH,EAAc,QAAQD,CAAO,EACvCI,IAAU,IACbH,EAAc,OAAOG,EAAO,CAAC,CAE/B,CACD,CAQA,MAAM,KAAQL,KAAkBI,EAAiB,CAChD,IAAMF,EAAgB,KAAK,OAAO,IAAIF,CAAK,EAC3C,GAAIE,EACH,QAAWD,KAAWC,EACrB,GAAI,CAEH,MAAMD,EAAQ,GAAGG,CAAU,CAC5B,OAASE,EAAO,CACf,IAAMC,EAAU,GAAGP,CAAK,KAAMM,EAAgB,OAAO,GAErD,GADA,KAAK,KAAK,QAAS,IAAI,MAAMC,CAAO,CAAC,EACjC,KAAK,iBACR,MAAM,IAAI,MAAMA,CAAO,CAEzB,CAGH,CAOA,SAASP,EAAe,CACvB,OAAO,KAAK,OAAO,IAAIA,CAAK,CAC7B,CAMA,YAAa,CACZ,KAAK,OAAO,MAAM,CACnB,CACD","names":["Eventified","__publicField","eventName","listener","onceListener","arguments_","listeners","event","index","result","n","Hookified","Eventified","options","__publicField","value","event","handler","eventHandlers","hook","arguments_","index","error","message"]} \ No newline at end of file +{"version":3,"sources":["../../src/eventified.ts","../../src/index.ts"],"sourcesContent":["import {type Logger} from 'logger.js';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type IEventEmitter = {\n\t/**\n\t * Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.on('data', (message) => {\n\t * console.log(message);\n\t * });\n\t */\n\ton(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Alias for `on`. Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\taddListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Registers a one-time listener for the specified event. The listener is removed after it is called once.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.once('close', () => {\n\t * console.log('The connection was closed.');\n\t * });\n\t */\n\tonce(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.off('data', myListener);\n\t */\n\toff(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Alias for `off`. Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\tremoveListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Emits the specified event, invoking all registered listeners with the provided arguments.\n\t *\n\t * @param eventName - The name (or symbol) of the event to emit.\n\t * @param args - Arguments passed to each listener.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t *\n\t * @example\n\t * emitter.emit('data', 'Hello World');\n\t */\n\temit(eventName: string | symbol, ...arguments_: any[]): boolean;\n\n\t/**\n\t * Returns the number of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns The number of registered listeners.\n\t *\n\t * @example\n\t * const count = emitter.listenerCount('data');\n\t * console.log(count); // e.g., 2\n\t */\n\tlistenerCount(eventName: string | symbol): number;\n\n\t/**\n\t * Removes all listeners for the specified event. If no event is specified, it removes all listeners for all events.\n\t *\n\t * @param eventName - (Optional) The name (or symbol) of the event.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.removeAllListeners('data');\n\t */\n\tremoveAllListeners(eventName?: string | symbol): IEventEmitter;\n\n\t/**\n\t * Returns an array of event names for which listeners have been registered.\n\t *\n\t * @returns An array of event names (or symbols).\n\t *\n\t * @example\n\t * const events = emitter.eventNames();\n\t * console.log(events); // e.g., ['data', 'close']\n\t */\n\teventNames(): Array;\n\n\t/**\n\t * Returns an array of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of listener functions.\n\t *\n\t * @example\n\t * const listeners = emitter.listeners('data');\n\t * console.log(listeners.length); // e.g., 2\n\t */\n\tlisteners(eventName: string | symbol): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Returns an array of raw listeners for the specified event. This includes listeners wrapped by internal mechanisms (e.g., once-only listeners).\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of raw listener functions.\n\t *\n\t * @example\n\t * const rawListeners = emitter.rawListeners('data');\n\t */\n\trawListeners(eventName: string | symbol): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Adds a listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependListener('data', (message) => {\n\t * console.log('This will run first.');\n\t * });\n\t */\n\tprependListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Adds a one-time listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependOnceListener('data', (message) => {\n\t * console.log('This will run first and only once.');\n\t * });\n\t */\n\tprependOnceListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n};\n\nexport type EventListener = (...arguments_: any[]) => void;\n\nexport type EventEmitterOptions = {\n\tlogger?: Logger;\n};\n\nexport class Eventified implements IEventEmitter {\n\t_eventListeners: Map;\n\t_maxListeners: number;\n\t_logger?: Logger;\n\n\tconstructor(options?: EventEmitterOptions) {\n\t\tthis._eventListeners = new Map();\n\t\tthis._maxListeners = 100; // Default maximum number of listeners\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\tthis._logger = options?.logger;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that will run only once\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic once(eventName: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.on(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the number of listeners for a specific event. If no event is provided, it returns the total number of listeners\n\t * @param {string} eventName The event name. Not required\n\t * @returns {number} The number of listeners\n\t */\n\tpublic listenerCount(eventName?: string | symbol): number {\n\t\tif (!eventName) {\n\t\t\treturn this.getAllListeners().length;\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(eventName as string);\n\t\treturn listeners ? listeners.length : 0;\n\t}\n\n\t/**\n\t * Gets an array of event names\n\t * @returns {Array} An array of event names\n\t */\n\tpublic eventNames(): Array {\n\t\treturn [...this._eventListeners.keys()];\n\t}\n\n\t/**\n\t * Gets an array of listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic rawListeners(event?: string | symbol): EventListener[] {\n\t\tif (!event) {\n\t\t\treturn this.getAllListeners();\n\t\t}\n\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Prepends a listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic prependListener(eventName: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(eventName) ?? [];\n\t\tlisteners.unshift(listener);\n\t\tthis._eventListeners.set(eventName, listeners);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Prepends a one-time listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic prependOnceListener(eventName: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.prependListener(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the maximum number of listeners that can be added for a single event\n\t * @returns {number} The maximum number of listeners\n\t */\n\tpublic maxListeners(): number {\n\t\treturn this._maxListeners;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event. It is an alias for the on() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic addListener(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tthis.on(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic on(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tif (!this._eventListeners.has(event)) {\n\t\t\tthis._eventListeners.set(event, []);\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners) {\n\t\t\tif (listeners.length >= this._maxListeners) {\n\t\t\t\tconsole.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${listeners.length + 1} ${event as string} listeners added. Use setMaxListeners() to increase limit.`);\n\t\t\t}\n\n\t\t\tlisteners.push(listener);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event. It is an alias for the off() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeListener(event: string, listener: EventListener): IEventEmitter {\n\t\tthis.off(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic off(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(event) ?? [];\n\t\tconst index = listeners.indexOf(listener);\n\t\tif (index !== -1) {\n\t\t\tlisteners.splice(index, 1);\n\t\t}\n\n\t\tif (listeners.length === 0) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Calls all listeners for a specific event\n\t * @param {string | symbol} event\n\t * @param arguments_ The arguments to pass to the listeners\n\t * @returns {boolean} Returns true if the event had listeners, false otherwise\n\t */\n\tpublic emit(event: string | symbol, ...arguments_: any[]): boolean {\n\t\tlet result = false;\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners && listeners.length > 0) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\t\tlistener(...arguments_);\n\t\t\t\tresult = true;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Gets all listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic listeners(event: string): EventListener[] {\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Removes all listeners for a specific event. If no event is provided, it removes all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeAllListeners(event?: string): IEventEmitter {\n\t\tif (event) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t} else {\n\t\t\tthis._eventListeners.clear();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the maximum number of listeners that can be added for a single event\n\t * @param {number} n The maximum number of listeners\n\t * @returns {void}\n\t */\n\tpublic setMaxListeners(n: number): void {\n\t\tthis._maxListeners = n;\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tif (listeners.length > n) {\n\t\t\t\tlisteners.splice(n);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Gets all listeners\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic getAllListeners(): EventListener[] {\n\t\tlet result = new Array();\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tresult = [...result, ...listeners];\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import {Eventified} from './eventified.js';\nimport {type Logger} from './logger.js';\n\nexport type Hook = (...arguments_: any[]) => Promise | void;\n\nexport type HookEntry = {\n\tevent: string;\n\thandler: Hook;\n};\n\nexport type HookifiedOptions = {\n\tthrowHookErrors?: boolean;\n\tlogger?: Logger;\n};\n\nexport class Hookified extends Eventified {\n\t_hooks: Map;\n\t_throwHookErrors = false;\n\n\tconstructor(options?: HookifiedOptions) {\n\t\tsuper({logger: options?.logger});\n\t\tthis._hooks = new Map();\n\n\t\tif (options?.throwHookErrors !== undefined) {\n\t\t\tthis._throwHookErrors = options.throwHookErrors;\n\t\t}\n\t}\n\n\t/**\n\t * Gets all hooks\n\t * @returns {Map}\n\t */\n\tpublic get hooks() {\n\t\treturn this._hooks;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t */\n\tpublic get throwHookErrors() {\n\t\treturn this._throwHookErrors;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t */\n\tpublic set throwHookErrors(value) {\n\t\tthis._throwHookErrors = value;\n\t}\n\n\t/**\n\t * Gets the logger\n\t * @returns {Logger}\n\t */\n\tpublic get logger(): Logger | undefined {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this._logger;\n\t}\n\n\t/**\n\t * Sets the logger\n\t * @param {Logger} logger\n\t */\n\tpublic set logger(logger: Logger | undefined) {\n\t\tthis._logger = logger;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic onHook(event: string, handler: Hook) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.push(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {Array} hooks\n\t * @returns {void}\n\t */\n\tpublic onHooks(hooks: HookEntry[]) {\n\t\tfor (const hook of hooks) {\n\t\t\tthis.onHook(hook.event, hook.handler);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that runs before all other handlers\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic prependHook(event: string, handler: Hook) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.unshift(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event before all other handlers\n\t * @param event\n\t * @param handler\n\t */\n\tpublic prependOnceHook(event: string, handler: Hook) {\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.prependHook(event, hook);\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event\n\t * @param event\n\t * @param handler\n\t */\n\tpublic onceHook(event: string, handler: Hook) {\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.onHook(event, hook);\n\t}\n\n\t/**\n\t * Removes a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler\n\t * @returns {void}\n\t */\n\tpublic removeHook(event: string, handler: Hook) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tconst index = eventHandlers.indexOf(handler);\n\t\t\tif (index !== -1) {\n\t\t\t\teventHandlers.splice(index, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes all handlers for a specific event\n\t * @param {Array} hooks\n\t * @returns {void}\n\t */\n\tpublic removeHooks(hooks: HookEntry[]) {\n\t\tfor (const hook of hooks) {\n\t\t\tthis.removeHook(hook.event, hook.handler);\n\t\t}\n\t}\n\n\t/**\n\t * Calls all handlers for a specific event\n\t * @param {string} event\n\t * @param {T[]} arguments_\n\t * @returns {Promise}\n\t */\n\tpublic async hook(event: string, ...arguments_: T[]) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tfor (const handler of eventHandlers) {\n\t\t\t\ttry {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tawait handler(...arguments_);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = `${event}: ${(error as Error).message}`;\n\t\t\t\t\tthis.emit('error', new Error(message));\n\t\t\t\t\tif (this._logger) {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-call\n\t\t\t\t\t\tthis._logger.error(message);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._throwHookErrors) {\n\t\t\t\t\t\tthrow new Error(message);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Gets all hooks for a specific event\n\t * @param {string} event\n\t * @returns {Hook[]}\n\t */\n\tpublic getHooks(event: string) {\n\t\treturn this._hooks.get(event);\n\t}\n\n\t/**\n\t * Removes all hooks\n\t * @returns {void}\n\t */\n\tpublic clearHooks() {\n\t\tthis._hooks.clear();\n\t}\n}\n\nexport {Eventified, type EventListener} from './eventified.js';\nexport {type Logger} from './logger.js';\n"],"mappings":"uLAsKO,IAAMA,EAAN,KAA0C,CAKhD,YAAYC,EAA+B,CAJ3CC,EAAA,wBACAA,EAAA,sBACAA,EAAA,gBAGC,KAAK,gBAAkB,IAAI,IAC3B,KAAK,cAAgB,IAErB,KAAK,QAAUD,GAAS,MACzB,CAQO,KAAKE,EAA4BC,EAAwC,CAC/E,IAAMC,EAA8B,IAAIC,IAAsB,CAC7D,KAAK,IAAIH,EAAqBE,CAAY,EAE1CD,EAAS,GAAGE,CAAU,CACvB,EAEA,YAAK,GAAGH,EAAqBE,CAAY,EAClC,IACR,CAOO,cAAcF,EAAqC,CACzD,GAAI,CAACA,EACJ,OAAO,KAAK,gBAAgB,EAAE,OAG/B,IAAMI,EAAY,KAAK,gBAAgB,IAAIJ,CAAmB,EAC9D,OAAOI,EAAYA,EAAU,OAAS,CACvC,CAMO,YAAqC,CAC3C,MAAO,CAAC,GAAG,KAAK,gBAAgB,KAAK,CAAC,CACvC,CAOO,aAAaC,EAA0C,CAC7D,OAAKA,EAIE,KAAK,gBAAgB,IAAIA,CAAK,GAAK,CAAC,EAHnC,KAAK,gBAAgB,CAI9B,CAQO,gBAAgBL,EAA4BC,EAAwC,CAC1F,IAAMG,EAAY,KAAK,gBAAgB,IAAIJ,CAAS,GAAK,CAAC,EAC1D,OAAAI,EAAU,QAAQH,CAAQ,EAC1B,KAAK,gBAAgB,IAAID,EAAWI,CAAS,EACtC,IACR,CAQO,oBAAoBJ,EAA4BC,EAAwC,CAC9F,IAAMC,EAA8B,IAAIC,IAAsB,CAC7D,KAAK,IAAIH,EAAqBE,CAAY,EAE1CD,EAAS,GAAGE,CAAU,CACvB,EAEA,YAAK,gBAAgBH,EAAqBE,CAAY,EAC/C,IACR,CAMO,cAAuB,CAC7B,OAAO,KAAK,aACb,CAQO,YAAYG,EAAwBJ,EAAwC,CAClF,YAAK,GAAGI,EAAOJ,CAAQ,EAChB,IACR,CAQO,GAAGI,EAAwBJ,EAAwC,CACpE,KAAK,gBAAgB,IAAII,CAAK,GAClC,KAAK,gBAAgB,IAAIA,EAAO,CAAC,CAAC,EAGnC,IAAMD,EAAY,KAAK,gBAAgB,IAAIC,CAAK,EAEhD,OAAID,IACCA,EAAU,QAAU,KAAK,eAC5B,QAAQ,KAAK,qEAAqEA,EAAU,OAAS,CAAC,IAAIC,CAAe,4DAA4D,EAGtLD,EAAU,KAAKH,CAAQ,GAGjB,IACR,CAQO,eAAeI,EAAeJ,EAAwC,CAC5E,YAAK,IAAII,EAAOJ,CAAQ,EACjB,IACR,CAQO,IAAII,EAAwBJ,EAAwC,CAC1E,IAAMG,EAAY,KAAK,gBAAgB,IAAIC,CAAK,GAAK,CAAC,EAChDC,EAAQF,EAAU,QAAQH,CAAQ,EACxC,OAAIK,IAAU,IACbF,EAAU,OAAOE,EAAO,CAAC,EAGtBF,EAAU,SAAW,GACxB,KAAK,gBAAgB,OAAOC,CAAK,EAG3B,IACR,CAQO,KAAKA,KAA2BF,EAA4B,CAClE,IAAII,EAAS,GACPH,EAAY,KAAK,gBAAgB,IAAIC,CAAK,EAEhD,GAAID,GAAaA,EAAU,OAAS,EACnC,QAAWH,KAAYG,EAEtBH,EAAS,GAAGE,CAAU,EACtBI,EAAS,GAIX,OAAOA,CACR,CAOO,UAAUF,EAAgC,CAChD,OAAO,KAAK,gBAAgB,IAAIA,CAAK,GAAK,CAAC,CAC5C,CAOO,mBAAmBA,EAA+B,CACxD,OAAIA,EACH,KAAK,gBAAgB,OAAOA,CAAK,EAEjC,KAAK,gBAAgB,MAAM,EAGrB,IACR,CAOO,gBAAgBG,EAAiB,CACvC,KAAK,cAAgBA,EACrB,QAAWJ,KAAa,KAAK,gBAAgB,OAAO,EAC/CA,EAAU,OAASI,GACtBJ,EAAU,OAAOI,CAAC,CAGrB,CAMO,iBAAmC,CACzC,IAAID,EAAS,IAAI,MACjB,QAAWH,KAAa,KAAK,gBAAgB,OAAO,EACnDG,EAAS,CAAC,GAAGA,EAAQ,GAAGH,CAAS,EAGlC,OAAOG,CACR,CACD,ECtYO,IAAME,EAAN,cAAwBC,CAAW,CAIzC,YAAYC,EAA4B,CACvC,MAAM,CAAC,OAAQA,GAAS,MAAM,CAAC,EAJhCC,EAAA,eACAA,EAAA,wBAAmB,IAIlB,KAAK,OAAS,IAAI,IAEdD,GAAS,kBAAoB,SAChC,KAAK,iBAAmBA,EAAQ,gBAElC,CAMA,IAAW,OAAQ,CAClB,OAAO,KAAK,MACb,CAMA,IAAW,iBAAkB,CAC5B,OAAO,KAAK,gBACb,CAMA,IAAW,gBAAgBE,EAAO,CACjC,KAAK,iBAAmBA,CACzB,CAMA,IAAW,QAA6B,CAEvC,OAAO,KAAK,OACb,CAMA,IAAW,OAAOC,EAA4B,CAC7C,KAAK,QAAUA,CAChB,CAQO,OAAOC,EAAeC,EAAe,CAC3C,IAAMC,EAAgB,KAAK,OAAO,IAAIF,CAAK,EACvCE,EACHA,EAAc,KAAKD,CAAO,EAE1B,KAAK,OAAO,IAAID,EAAO,CAACC,CAAO,CAAC,CAElC,CAOO,QAAQE,EAAoB,CAClC,QAAWC,KAAQD,EAClB,KAAK,OAAOC,EAAK,MAAOA,EAAK,OAAO,CAEtC,CAQO,YAAYJ,EAAeC,EAAe,CAChD,IAAMC,EAAgB,KAAK,OAAO,IAAIF,CAAK,EACvCE,EACHA,EAAc,QAAQD,CAAO,EAE7B,KAAK,OAAO,IAAID,EAAO,CAACC,CAAO,CAAC,CAElC,CAOO,gBAAgBD,EAAeC,EAAe,CACpD,IAAMG,EAAO,SAAUC,KACtB,KAAK,WAAWL,EAAOI,CAAI,EAEpBH,EAAQ,GAAGI,CAAU,GAG7B,KAAK,YAAYL,EAAOI,CAAI,CAC7B,CAOO,SAASJ,EAAeC,EAAe,CAC7C,IAAMG,EAAO,SAAUC,KACtB,KAAK,WAAWL,EAAOI,CAAI,EAEpBH,EAAQ,GAAGI,CAAU,GAG7B,KAAK,OAAOL,EAAOI,CAAI,CACxB,CAQO,WAAWJ,EAAeC,EAAe,CAC/C,IAAMC,EAAgB,KAAK,OAAO,IAAIF,CAAK,EAC3C,GAAIE,EAAe,CAClB,IAAMI,EAAQJ,EAAc,QAAQD,CAAO,EACvCK,IAAU,IACbJ,EAAc,OAAOI,EAAO,CAAC,CAE/B,CACD,CAOO,YAAYH,EAAoB,CACtC,QAAWC,KAAQD,EAClB,KAAK,WAAWC,EAAK,MAAOA,EAAK,OAAO,CAE1C,CAQA,MAAa,KAAQJ,KAAkBK,EAAiB,CACvD,IAAMH,EAAgB,KAAK,OAAO,IAAIF,CAAK,EAC3C,GAAIE,EACH,QAAWD,KAAWC,EACrB,GAAI,CAEH,MAAMD,EAAQ,GAAGI,CAAU,CAC5B,OAASE,EAAO,CACf,IAAMC,EAAU,GAAGR,CAAK,KAAMO,EAAgB,OAAO,GAOrD,GANA,KAAK,KAAK,QAAS,IAAI,MAAMC,CAAO,CAAC,EACjC,KAAK,SAER,KAAK,QAAQ,MAAMA,CAAO,EAGvB,KAAK,iBACR,MAAM,IAAI,MAAMA,CAAO,CAEzB,CAGH,CAOO,SAASR,EAAe,CAC9B,OAAO,KAAK,OAAO,IAAIA,CAAK,CAC7B,CAMO,YAAa,CACnB,KAAK,OAAO,MAAM,CACnB,CACD","names":["Eventified","options","__publicField","eventName","listener","onceListener","arguments_","listeners","event","index","result","n","Hookified","Eventified","options","__publicField","value","logger","event","handler","eventHandlers","hooks","hook","arguments_","index","error","message"]} \ No newline at end of file diff --git a/node_modules/hookified/dist/browser/index.js b/node_modules/hookified/dist/browser/index.js index bf7a88900f12..37a1b1d4202a 100644 --- a/node_modules/hookified/dist/browser/index.js +++ b/node_modules/hookified/dist/browser/index.js @@ -1,2 +1,2 @@ -var g=Object.defineProperty;var v=(i,t,e)=>t in i?g(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var o=(i,t,e)=>v(i,typeof t!="symbol"?t+"":t,e);var l=class{constructor(){o(this,"_eventListeners");o(this,"_maxListeners");this._eventListeners=new Map,this._maxListeners=100}once(t,e){let s=(...r)=>{this.off(t,s),e(...r)};return this.on(t,s),this}listenerCount(t){if(!t)return this.getAllListeners().length;let e=this._eventListeners.get(t);return e?e.length:0}eventNames(){return Array.from(this._eventListeners.keys())}rawListeners(t){return t?this._eventListeners.get(t)??[]:this.getAllListeners()}prependListener(t,e){let s=this._eventListeners.get(t)??[];return s.unshift(e),this._eventListeners.set(t,s),this}prependOnceListener(t,e){let s=(...r)=>{this.off(t,s),e(...r)};return this.prependListener(t,s),this}maxListeners(){return this._maxListeners}addListener(t,e){return this.on(t,e),this}on(t,e){this._eventListeners.has(t)||this._eventListeners.set(t,[]);let s=this._eventListeners.get(t);return s&&(s.length>=this._maxListeners&&console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length+1} ${t} listeners added. Use setMaxListeners() to increase limit.`),s.push(e)),this}removeListener(t,e){return this.off(t,e),this}off(t,e){let s=this._eventListeners.get(t)??[],r=s.indexOf(e);return r!==-1&&s.splice(r,1),s.length===0&&this._eventListeners.delete(t),this}emit(t,...e){let s=!1,r=this._eventListeners.get(t);if(r&&r.length>0)for(let n of r)n(...e),s=!0;return s}listeners(t){return this._eventListeners.get(t)??[]}removeAllListeners(t){return t?this._eventListeners.delete(t):this._eventListeners.clear(),this}setMaxListeners(t){this._maxListeners=t;for(let e of this._eventListeners.values())e.length>t&&e.splice(t)}getAllListeners(){let t=new Array;for(let e of this._eventListeners.values())t=t.concat(e);return t}};var m=class extends l{constructor(e){super();o(this,"_hooks");o(this,"_throwHookErrors",!1);this._hooks=new Map,e?.throwHookErrors!==void 0&&(this._throwHookErrors=e.throwHookErrors)}get hooks(){return this._hooks}get throwHookErrors(){return this._throwHookErrors}set throwHookErrors(e){this._throwHookErrors=e}onHook(e,s){let r=this._hooks.get(e);r?r.push(s):this._hooks.set(e,[s])}prependHook(e,s){let r=this._hooks.get(e);r?r.unshift(s):this._hooks.set(e,[s])}prependOnceHook(e,s){let r=async(...n)=>(this.removeHook(e,r),s(...n));this.prependHook(e,r)}onceHook(e,s){let r=async(...n)=>(this.removeHook(e,r),s(...n));this.onHook(e,r)}removeHook(e,s){let r=this._hooks.get(e);if(r){let n=r.indexOf(s);n!==-1&&r.splice(n,1)}}async hook(e,...s){let r=this._hooks.get(e);if(r)for(let n of r)try{await n(...s)}catch(h){let a=`${e}: ${h.message}`;if(this.emit("error",new Error(a)),this._throwHookErrors)throw new Error(a)}}getHooks(e){return this._hooks.get(e)}clearHooks(){this._hooks.clear()}};export{l as Eventified,m as Hookified}; +var a=Object.defineProperty;var u=(i,t,e)=>t in i?a(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var o=(i,t,e)=>u(i,typeof t!="symbol"?t+"":t,e);var l=class{constructor(t){o(this,"_eventListeners");o(this,"_maxListeners");o(this,"_logger");this._eventListeners=new Map,this._maxListeners=100,this._logger=t?.logger}once(t,e){let s=(...r)=>{this.off(t,s),e(...r)};return this.on(t,s),this}listenerCount(t){if(!t)return this.getAllListeners().length;let e=this._eventListeners.get(t);return e?e.length:0}eventNames(){return[...this._eventListeners.keys()]}rawListeners(t){return t?this._eventListeners.get(t)??[]:this.getAllListeners()}prependListener(t,e){let s=this._eventListeners.get(t)??[];return s.unshift(e),this._eventListeners.set(t,s),this}prependOnceListener(t,e){let s=(...r)=>{this.off(t,s),e(...r)};return this.prependListener(t,s),this}maxListeners(){return this._maxListeners}addListener(t,e){return this.on(t,e),this}on(t,e){this._eventListeners.has(t)||this._eventListeners.set(t,[]);let s=this._eventListeners.get(t);return s&&(s.length>=this._maxListeners&&console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length+1} ${t} listeners added. Use setMaxListeners() to increase limit.`),s.push(e)),this}removeListener(t,e){return this.off(t,e),this}off(t,e){let s=this._eventListeners.get(t)??[],r=s.indexOf(e);return r!==-1&&s.splice(r,1),s.length===0&&this._eventListeners.delete(t),this}emit(t,...e){let s=!1,r=this._eventListeners.get(t);if(r&&r.length>0)for(let n of r)n(...e),s=!0;return s}listeners(t){return this._eventListeners.get(t)??[]}removeAllListeners(t){return t?this._eventListeners.delete(t):this._eventListeners.clear(),this}setMaxListeners(t){this._maxListeners=t;for(let e of this._eventListeners.values())e.length>t&&e.splice(t)}getAllListeners(){let t=new Array;for(let e of this._eventListeners.values())t=[...t,...e];return t}};var h=class extends l{constructor(e){super({logger:e?.logger});o(this,"_hooks");o(this,"_throwHookErrors",!1);this._hooks=new Map,e?.throwHookErrors!==void 0&&(this._throwHookErrors=e.throwHookErrors)}get hooks(){return this._hooks}get throwHookErrors(){return this._throwHookErrors}set throwHookErrors(e){this._throwHookErrors=e}get logger(){return this._logger}set logger(e){this._logger=e}onHook(e,s){let r=this._hooks.get(e);r?r.push(s):this._hooks.set(e,[s])}onHooks(e){for(let s of e)this.onHook(s.event,s.handler)}prependHook(e,s){let r=this._hooks.get(e);r?r.unshift(s):this._hooks.set(e,[s])}prependOnceHook(e,s){let r=async(...n)=>(this.removeHook(e,r),s(...n));this.prependHook(e,r)}onceHook(e,s){let r=async(...n)=>(this.removeHook(e,r),s(...n));this.onHook(e,r)}removeHook(e,s){let r=this._hooks.get(e);if(r){let n=r.indexOf(s);n!==-1&&r.splice(n,1)}}removeHooks(e){for(let s of e)this.removeHook(s.event,s.handler)}async hook(e,...s){let r=this._hooks.get(e);if(r)for(let n of r)try{await n(...s)}catch(m){let g=`${e}: ${m.message}`;if(this.emit("error",new Error(g)),this._logger&&this._logger.error(g),this._throwHookErrors)throw new Error(g)}}getHooks(e){return this._hooks.get(e)}clearHooks(){this._hooks.clear()}};export{l as Eventified,h as Hookified}; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/hookified/dist/browser/index.js.map b/node_modules/hookified/dist/browser/index.js.map index f2f596a470b7..38da326b7188 100644 --- a/node_modules/hookified/dist/browser/index.js.map +++ b/node_modules/hookified/dist/browser/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/eventified.ts","../../src/index.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type IEventEmitter = {\n\t/**\n\t * Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.on('data', (message) => {\n\t * console.log(message);\n\t * });\n\t */\n\ton(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Alias for `on`. Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\taddListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Registers a one-time listener for the specified event. The listener is removed after it is called once.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.once('close', () => {\n\t * console.log('The connection was closed.');\n\t * });\n\t */\n\tonce(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.off('data', myListener);\n\t */\n\toff(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Alias for `off`. Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\tremoveListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Emits the specified event, invoking all registered listeners with the provided arguments.\n\t *\n\t * @param eventName - The name (or symbol) of the event to emit.\n\t * @param args - Arguments passed to each listener.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t *\n\t * @example\n\t * emitter.emit('data', 'Hello World');\n\t */\n\temit(eventName: string | symbol, ...arguments_: any[]): boolean;\n\n\t/**\n\t * Returns the number of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns The number of registered listeners.\n\t *\n\t * @example\n\t * const count = emitter.listenerCount('data');\n\t * console.log(count); // e.g., 2\n\t */\n\tlistenerCount(eventName: string | symbol): number;\n\n\t/**\n\t * Removes all listeners for the specified event. If no event is specified, it removes all listeners for all events.\n\t *\n\t * @param eventName - (Optional) The name (or symbol) of the event.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.removeAllListeners('data');\n\t */\n\tremoveAllListeners(eventName?: string | symbol): IEventEmitter;\n\n\t/**\n\t * Returns an array of event names for which listeners have been registered.\n\t *\n\t * @returns An array of event names (or symbols).\n\t *\n\t * @example\n\t * const events = emitter.eventNames();\n\t * console.log(events); // e.g., ['data', 'close']\n\t */\n\teventNames(): Array;\n\n\t/**\n\t * Returns an array of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of listener functions.\n\t *\n\t * @example\n\t * const listeners = emitter.listeners('data');\n\t * console.log(listeners.length); // e.g., 2\n\t */\n\tlisteners(eventName: string | symbol): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Returns an array of raw listeners for the specified event. This includes listeners wrapped by internal mechanisms (e.g., once-only listeners).\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of raw listener functions.\n\t *\n\t * @example\n\t * const rawListeners = emitter.rawListeners('data');\n\t */\n\trawListeners(eventName: string | symbol): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Adds a listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependListener('data', (message) => {\n\t * console.log('This will run first.');\n\t * });\n\t */\n\tprependListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Adds a one-time listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependOnceListener('data', (message) => {\n\t * console.log('This will run first and only once.');\n\t * });\n\t */\n\tprependOnceListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n};\n\nexport type EventListener = (...arguments_: any[]) => void;\n\nexport class Eventified implements IEventEmitter {\n\t_eventListeners: Map;\n\t_maxListeners: number;\n\n\tconstructor() {\n\t\tthis._eventListeners = new Map();\n\t\tthis._maxListeners = 100; // Default maximum number of listeners\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that will run only once\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tonce(eventName: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.on(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the number of listeners for a specific event. If no event is provided, it returns the total number of listeners\n\t * @param {string} eventName The event name. Not required\n\t * @returns {number} The number of listeners\n\t */\n\tlistenerCount(eventName?: string | symbol): number {\n\t\tif (!eventName) {\n\t\t\treturn this.getAllListeners().length;\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(eventName as string);\n\t\treturn listeners ? listeners.length : 0;\n\t}\n\n\t/**\n\t * Gets an array of event names\n\t * @returns {Array} An array of event names\n\t */\n\teventNames(): Array {\n\t\treturn Array.from(this._eventListeners.keys());\n\t}\n\n\t/**\n\t * Gets an array of listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\trawListeners(event?: string | symbol): EventListener[] {\n\t\tif (!event) {\n\t\t\treturn this.getAllListeners();\n\t\t}\n\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Prepends a listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tprependListener(eventName: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(eventName) ?? [];\n\t\tlisteners.unshift(listener);\n\t\tthis._eventListeners.set(eventName, listeners);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Prepends a one-time listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tprependOnceListener(eventName: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.prependListener(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the maximum number of listeners that can be added for a single event\n\t * @returns {number} The maximum number of listeners\n\t */\n\tpublic maxListeners(): number {\n\t\treturn this._maxListeners;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event. It is an alias for the on() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic addListener(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tthis.on(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic on(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tif (!this._eventListeners.has(event)) {\n\t\t\tthis._eventListeners.set(event, []);\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners) {\n\t\t\tif (listeners.length >= this._maxListeners) {\n\t\t\t\tconsole.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${listeners.length + 1} ${event as string} listeners added. Use setMaxListeners() to increase limit.`);\n\t\t\t}\n\n\t\t\tlisteners.push(listener);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event. It is an alias for the off() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeListener(event: string, listener: EventListener): IEventEmitter {\n\t\tthis.off(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic off(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(event) ?? [];\n\t\tconst index = listeners.indexOf(listener);\n\t\tif (index !== -1) {\n\t\t\tlisteners.splice(index, 1);\n\t\t}\n\n\t\tif (listeners.length === 0) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Calls all listeners for a specific event\n\t * @param {string | symbol} event\n\t * @param arguments_ The arguments to pass to the listeners\n\t * @returns {boolean} Returns true if the event had listeners, false otherwise\n\t */\n\tpublic emit(event: string | symbol, ...arguments_: any[]): boolean {\n\t\tlet result = false;\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners && listeners.length > 0) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\t\tlistener(...arguments_);\n\t\t\t\tresult = true;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Gets all listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic listeners(event: string): EventListener[] {\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Removes all listeners for a specific event. If no event is provided, it removes all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeAllListeners(event?: string): IEventEmitter {\n\t\tif (event) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t} else {\n\t\t\tthis._eventListeners.clear();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the maximum number of listeners that can be added for a single event\n\t * @param {number} n The maximum number of listeners\n\t * @returns {void}\n\t */\n\tpublic setMaxListeners(n: number): void {\n\t\tthis._maxListeners = n;\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tif (listeners.length > n) {\n\t\t\t\tlisteners.splice(n);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Gets all listeners\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic getAllListeners(): EventListener[] {\n\t\tlet result = new Array();\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tresult = result.concat(listeners);\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import {Eventified} from './eventified.js';\n\nexport type Hook = (...arguments_: any[]) => Promise | void;\n\nexport type HookifiedOptions = {\n\tthrowHookErrors?: boolean;\n};\n\nexport class Hookified extends Eventified {\n\t_hooks: Map;\n\t_throwHookErrors = false;\n\n\tconstructor(options?: HookifiedOptions) {\n\t\tsuper();\n\t\tthis._hooks = new Map();\n\n\t\tif (options?.throwHookErrors !== undefined) {\n\t\t\tthis._throwHookErrors = options.throwHookErrors;\n\t\t}\n\t}\n\n\t/**\n\t * Gets all hooks\n\t * @returns {Map}\n\t */\n\tget hooks() {\n\t\treturn this._hooks;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t */\n\tget throwHookErrors() {\n\t\treturn this._throwHookErrors;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t */\n\tset throwHookErrors(value) {\n\t\tthis._throwHookErrors = value;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tonHook(event: string, handler: Hook) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.push(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that runs before all other handlers\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tprependHook(event: string, handler: Hook) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.unshift(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event before all other handlers\n\t * @param event\n\t * @param handler\n\t */\n\tprependOnceHook(event: string, handler: Hook) {\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.prependHook(event, hook);\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event\n\t * @param event\n\t * @param handler\n\t */\n\tonceHook(event: string, handler: Hook) {\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.onHook(event, hook);\n\t}\n\n\t/**\n\t * Removes a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler\n\t * @returns {void}\n\t */\n\tremoveHook(event: string, handler: Hook) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tconst index = eventHandlers.indexOf(handler);\n\t\t\tif (index !== -1) {\n\t\t\t\teventHandlers.splice(index, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Calls all handlers for a specific event\n\t * @param {string} event\n\t * @param {T[]} arguments_\n\t * @returns {Promise}\n\t */\n\tasync hook(event: string, ...arguments_: T[]) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tfor (const handler of eventHandlers) {\n\t\t\t\ttry {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tawait handler(...arguments_);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = `${event}: ${(error as Error).message}`;\n\t\t\t\t\tthis.emit('error', new Error(message));\n\t\t\t\t\tif (this._throwHookErrors) {\n\t\t\t\t\t\tthrow new Error(message);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Gets all hooks for a specific event\n\t * @param {string} event\n\t * @returns {Hook[]}\n\t */\n\tgetHooks(event: string) {\n\t\treturn this._hooks.get(event);\n\t}\n\n\t/**\n\t * Removes all hooks\n\t * @returns {void}\n\t */\n\tclearHooks() {\n\t\tthis._hooks.clear();\n\t}\n}\n\nexport {Eventified, type EventListener} from './eventified.js';\n"],"mappings":"oKAgKO,IAAMA,EAAN,KAA0C,CAIhD,aAAc,CAHdC,EAAA,wBACAA,EAAA,sBAGC,KAAK,gBAAkB,IAAI,IAC3B,KAAK,cAAgB,GACtB,CAQA,KAAKC,EAA4BC,EAAwC,CACxE,IAAMC,EAA8B,IAAIC,IAAsB,CAC7D,KAAK,IAAIH,EAAqBE,CAAY,EAE1CD,EAAS,GAAGE,CAAU,CACvB,EAEA,YAAK,GAAGH,EAAqBE,CAAY,EAClC,IACR,CAOA,cAAcF,EAAqC,CAClD,GAAI,CAACA,EACJ,OAAO,KAAK,gBAAgB,EAAE,OAG/B,IAAMI,EAAY,KAAK,gBAAgB,IAAIJ,CAAmB,EAC9D,OAAOI,EAAYA,EAAU,OAAS,CACvC,CAMA,YAAqC,CACpC,OAAO,MAAM,KAAK,KAAK,gBAAgB,KAAK,CAAC,CAC9C,CAOA,aAAaC,EAA0C,CACtD,OAAKA,EAIE,KAAK,gBAAgB,IAAIA,CAAK,GAAK,CAAC,EAHnC,KAAK,gBAAgB,CAI9B,CAQA,gBAAgBL,EAA4BC,EAAwC,CACnF,IAAMG,EAAY,KAAK,gBAAgB,IAAIJ,CAAS,GAAK,CAAC,EAC1D,OAAAI,EAAU,QAAQH,CAAQ,EAC1B,KAAK,gBAAgB,IAAID,EAAWI,CAAS,EACtC,IACR,CAQA,oBAAoBJ,EAA4BC,EAAwC,CACvF,IAAMC,EAA8B,IAAIC,IAAsB,CAC7D,KAAK,IAAIH,EAAqBE,CAAY,EAE1CD,EAAS,GAAGE,CAAU,CACvB,EAEA,YAAK,gBAAgBH,EAAqBE,CAAY,EAC/C,IACR,CAMO,cAAuB,CAC7B,OAAO,KAAK,aACb,CAQO,YAAYG,EAAwBJ,EAAwC,CAClF,YAAK,GAAGI,EAAOJ,CAAQ,EAChB,IACR,CAQO,GAAGI,EAAwBJ,EAAwC,CACpE,KAAK,gBAAgB,IAAII,CAAK,GAClC,KAAK,gBAAgB,IAAIA,EAAO,CAAC,CAAC,EAGnC,IAAMD,EAAY,KAAK,gBAAgB,IAAIC,CAAK,EAEhD,OAAID,IACCA,EAAU,QAAU,KAAK,eAC5B,QAAQ,KAAK,qEAAqEA,EAAU,OAAS,CAAC,IAAIC,CAAe,4DAA4D,EAGtLD,EAAU,KAAKH,CAAQ,GAGjB,IACR,CAQO,eAAeI,EAAeJ,EAAwC,CAC5E,YAAK,IAAII,EAAOJ,CAAQ,EACjB,IACR,CAQO,IAAII,EAAwBJ,EAAwC,CAC1E,IAAMG,EAAY,KAAK,gBAAgB,IAAIC,CAAK,GAAK,CAAC,EAChDC,EAAQF,EAAU,QAAQH,CAAQ,EACxC,OAAIK,IAAU,IACbF,EAAU,OAAOE,EAAO,CAAC,EAGtBF,EAAU,SAAW,GACxB,KAAK,gBAAgB,OAAOC,CAAK,EAG3B,IACR,CAQO,KAAKA,KAA2BF,EAA4B,CAClE,IAAII,EAAS,GACPH,EAAY,KAAK,gBAAgB,IAAIC,CAAK,EAEhD,GAAID,GAAaA,EAAU,OAAS,EACnC,QAAWH,KAAYG,EAEtBH,EAAS,GAAGE,CAAU,EACtBI,EAAS,GAIX,OAAOA,CACR,CAOO,UAAUF,EAAgC,CAChD,OAAO,KAAK,gBAAgB,IAAIA,CAAK,GAAK,CAAC,CAC5C,CAOO,mBAAmBA,EAA+B,CACxD,OAAIA,EACH,KAAK,gBAAgB,OAAOA,CAAK,EAEjC,KAAK,gBAAgB,MAAM,EAGrB,IACR,CAOO,gBAAgBG,EAAiB,CACvC,KAAK,cAAgBA,EACrB,QAAWJ,KAAa,KAAK,gBAAgB,OAAO,EAC/CA,EAAU,OAASI,GACtBJ,EAAU,OAAOI,CAAC,CAGrB,CAMO,iBAAmC,CACzC,IAAID,EAAS,IAAI,MACjB,QAAWH,KAAa,KAAK,gBAAgB,OAAO,EACnDG,EAASA,EAAO,OAAOH,CAAS,EAGjC,OAAOG,CACR,CACD,ECpYO,IAAME,EAAN,cAAwBC,CAAW,CAIzC,YAAYC,EAA4B,CACvC,MAAM,EAJPC,EAAA,eACAA,EAAA,wBAAmB,IAIlB,KAAK,OAAS,IAAI,IAEdD,GAAS,kBAAoB,SAChC,KAAK,iBAAmBA,EAAQ,gBAElC,CAMA,IAAI,OAAQ,CACX,OAAO,KAAK,MACb,CAMA,IAAI,iBAAkB,CACrB,OAAO,KAAK,gBACb,CAMA,IAAI,gBAAgBE,EAAO,CAC1B,KAAK,iBAAmBA,CACzB,CAQA,OAAOC,EAAeC,EAAe,CACpC,IAAMC,EAAgB,KAAK,OAAO,IAAIF,CAAK,EACvCE,EACHA,EAAc,KAAKD,CAAO,EAE1B,KAAK,OAAO,IAAID,EAAO,CAACC,CAAO,CAAC,CAElC,CAQA,YAAYD,EAAeC,EAAe,CACzC,IAAMC,EAAgB,KAAK,OAAO,IAAIF,CAAK,EACvCE,EACHA,EAAc,QAAQD,CAAO,EAE7B,KAAK,OAAO,IAAID,EAAO,CAACC,CAAO,CAAC,CAElC,CAOA,gBAAgBD,EAAeC,EAAe,CAC7C,IAAME,EAAO,SAAUC,KACtB,KAAK,WAAWJ,EAAOG,CAAI,EAEpBF,EAAQ,GAAGG,CAAU,GAG7B,KAAK,YAAYJ,EAAOG,CAAI,CAC7B,CAOA,SAASH,EAAeC,EAAe,CACtC,IAAME,EAAO,SAAUC,KACtB,KAAK,WAAWJ,EAAOG,CAAI,EAEpBF,EAAQ,GAAGG,CAAU,GAG7B,KAAK,OAAOJ,EAAOG,CAAI,CACxB,CAQA,WAAWH,EAAeC,EAAe,CACxC,IAAMC,EAAgB,KAAK,OAAO,IAAIF,CAAK,EAC3C,GAAIE,EAAe,CAClB,IAAMG,EAAQH,EAAc,QAAQD,CAAO,EACvCI,IAAU,IACbH,EAAc,OAAOG,EAAO,CAAC,CAE/B,CACD,CAQA,MAAM,KAAQL,KAAkBI,EAAiB,CAChD,IAAMF,EAAgB,KAAK,OAAO,IAAIF,CAAK,EAC3C,GAAIE,EACH,QAAWD,KAAWC,EACrB,GAAI,CAEH,MAAMD,EAAQ,GAAGG,CAAU,CAC5B,OAASE,EAAO,CACf,IAAMC,EAAU,GAAGP,CAAK,KAAMM,EAAgB,OAAO,GAErD,GADA,KAAK,KAAK,QAAS,IAAI,MAAMC,CAAO,CAAC,EACjC,KAAK,iBACR,MAAM,IAAI,MAAMA,CAAO,CAEzB,CAGH,CAOA,SAASP,EAAe,CACvB,OAAO,KAAK,OAAO,IAAIA,CAAK,CAC7B,CAMA,YAAa,CACZ,KAAK,OAAO,MAAM,CACnB,CACD","names":["Eventified","__publicField","eventName","listener","onceListener","arguments_","listeners","event","index","result","n","Hookified","Eventified","options","__publicField","value","event","handler","eventHandlers","hook","arguments_","index","error","message"]} \ No newline at end of file +{"version":3,"sources":["../../src/eventified.ts","../../src/index.ts"],"sourcesContent":["import {type Logger} from 'logger.js';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type IEventEmitter = {\n\t/**\n\t * Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.on('data', (message) => {\n\t * console.log(message);\n\t * });\n\t */\n\ton(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Alias for `on`. Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\taddListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Registers a one-time listener for the specified event. The listener is removed after it is called once.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.once('close', () => {\n\t * console.log('The connection was closed.');\n\t * });\n\t */\n\tonce(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.off('data', myListener);\n\t */\n\toff(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Alias for `off`. Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\tremoveListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Emits the specified event, invoking all registered listeners with the provided arguments.\n\t *\n\t * @param eventName - The name (or symbol) of the event to emit.\n\t * @param args - Arguments passed to each listener.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t *\n\t * @example\n\t * emitter.emit('data', 'Hello World');\n\t */\n\temit(eventName: string | symbol, ...arguments_: any[]): boolean;\n\n\t/**\n\t * Returns the number of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns The number of registered listeners.\n\t *\n\t * @example\n\t * const count = emitter.listenerCount('data');\n\t * console.log(count); // e.g., 2\n\t */\n\tlistenerCount(eventName: string | symbol): number;\n\n\t/**\n\t * Removes all listeners for the specified event. If no event is specified, it removes all listeners for all events.\n\t *\n\t * @param eventName - (Optional) The name (or symbol) of the event.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.removeAllListeners('data');\n\t */\n\tremoveAllListeners(eventName?: string | symbol): IEventEmitter;\n\n\t/**\n\t * Returns an array of event names for which listeners have been registered.\n\t *\n\t * @returns An array of event names (or symbols).\n\t *\n\t * @example\n\t * const events = emitter.eventNames();\n\t * console.log(events); // e.g., ['data', 'close']\n\t */\n\teventNames(): Array;\n\n\t/**\n\t * Returns an array of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of listener functions.\n\t *\n\t * @example\n\t * const listeners = emitter.listeners('data');\n\t * console.log(listeners.length); // e.g., 2\n\t */\n\tlisteners(eventName: string | symbol): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Returns an array of raw listeners for the specified event. This includes listeners wrapped by internal mechanisms (e.g., once-only listeners).\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of raw listener functions.\n\t *\n\t * @example\n\t * const rawListeners = emitter.rawListeners('data');\n\t */\n\trawListeners(eventName: string | symbol): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Adds a listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependListener('data', (message) => {\n\t * console.log('This will run first.');\n\t * });\n\t */\n\tprependListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n\n\t/**\n\t * Adds a one-time listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependOnceListener('data', (message) => {\n\t * console.log('This will run first and only once.');\n\t * });\n\t */\n\tprependOnceListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter;\n};\n\nexport type EventListener = (...arguments_: any[]) => void;\n\nexport type EventEmitterOptions = {\n\tlogger?: Logger;\n};\n\nexport class Eventified implements IEventEmitter {\n\t_eventListeners: Map;\n\t_maxListeners: number;\n\t_logger?: Logger;\n\n\tconstructor(options?: EventEmitterOptions) {\n\t\tthis._eventListeners = new Map();\n\t\tthis._maxListeners = 100; // Default maximum number of listeners\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\tthis._logger = options?.logger;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that will run only once\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic once(eventName: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.on(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the number of listeners for a specific event. If no event is provided, it returns the total number of listeners\n\t * @param {string} eventName The event name. Not required\n\t * @returns {number} The number of listeners\n\t */\n\tpublic listenerCount(eventName?: string | symbol): number {\n\t\tif (!eventName) {\n\t\t\treturn this.getAllListeners().length;\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(eventName as string);\n\t\treturn listeners ? listeners.length : 0;\n\t}\n\n\t/**\n\t * Gets an array of event names\n\t * @returns {Array} An array of event names\n\t */\n\tpublic eventNames(): Array {\n\t\treturn [...this._eventListeners.keys()];\n\t}\n\n\t/**\n\t * Gets an array of listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic rawListeners(event?: string | symbol): EventListener[] {\n\t\tif (!event) {\n\t\t\treturn this.getAllListeners();\n\t\t}\n\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Prepends a listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic prependListener(eventName: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(eventName) ?? [];\n\t\tlisteners.unshift(listener);\n\t\tthis._eventListeners.set(eventName, listeners);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Prepends a one-time listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic prependOnceListener(eventName: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.prependListener(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the maximum number of listeners that can be added for a single event\n\t * @returns {number} The maximum number of listeners\n\t */\n\tpublic maxListeners(): number {\n\t\treturn this._maxListeners;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event. It is an alias for the on() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic addListener(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tthis.on(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic on(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tif (!this._eventListeners.has(event)) {\n\t\t\tthis._eventListeners.set(event, []);\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners) {\n\t\t\tif (listeners.length >= this._maxListeners) {\n\t\t\t\tconsole.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${listeners.length + 1} ${event as string} listeners added. Use setMaxListeners() to increase limit.`);\n\t\t\t}\n\n\t\t\tlisteners.push(listener);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event. It is an alias for the off() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeListener(event: string, listener: EventListener): IEventEmitter {\n\t\tthis.off(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic off(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(event) ?? [];\n\t\tconst index = listeners.indexOf(listener);\n\t\tif (index !== -1) {\n\t\t\tlisteners.splice(index, 1);\n\t\t}\n\n\t\tif (listeners.length === 0) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Calls all listeners for a specific event\n\t * @param {string | symbol} event\n\t * @param arguments_ The arguments to pass to the listeners\n\t * @returns {boolean} Returns true if the event had listeners, false otherwise\n\t */\n\tpublic emit(event: string | symbol, ...arguments_: any[]): boolean {\n\t\tlet result = false;\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners && listeners.length > 0) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\t\tlistener(...arguments_);\n\t\t\t\tresult = true;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Gets all listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic listeners(event: string): EventListener[] {\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Removes all listeners for a specific event. If no event is provided, it removes all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeAllListeners(event?: string): IEventEmitter {\n\t\tif (event) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t} else {\n\t\t\tthis._eventListeners.clear();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the maximum number of listeners that can be added for a single event\n\t * @param {number} n The maximum number of listeners\n\t * @returns {void}\n\t */\n\tpublic setMaxListeners(n: number): void {\n\t\tthis._maxListeners = n;\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tif (listeners.length > n) {\n\t\t\t\tlisteners.splice(n);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Gets all listeners\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic getAllListeners(): EventListener[] {\n\t\tlet result = new Array();\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tresult = [...result, ...listeners];\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import {Eventified} from './eventified.js';\nimport {type Logger} from './logger.js';\n\nexport type Hook = (...arguments_: any[]) => Promise | void;\n\nexport type HookEntry = {\n\tevent: string;\n\thandler: Hook;\n};\n\nexport type HookifiedOptions = {\n\tthrowHookErrors?: boolean;\n\tlogger?: Logger;\n};\n\nexport class Hookified extends Eventified {\n\t_hooks: Map;\n\t_throwHookErrors = false;\n\n\tconstructor(options?: HookifiedOptions) {\n\t\tsuper({logger: options?.logger});\n\t\tthis._hooks = new Map();\n\n\t\tif (options?.throwHookErrors !== undefined) {\n\t\t\tthis._throwHookErrors = options.throwHookErrors;\n\t\t}\n\t}\n\n\t/**\n\t * Gets all hooks\n\t * @returns {Map}\n\t */\n\tpublic get hooks() {\n\t\treturn this._hooks;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t */\n\tpublic get throwHookErrors() {\n\t\treturn this._throwHookErrors;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t */\n\tpublic set throwHookErrors(value) {\n\t\tthis._throwHookErrors = value;\n\t}\n\n\t/**\n\t * Gets the logger\n\t * @returns {Logger}\n\t */\n\tpublic get logger(): Logger | undefined {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this._logger;\n\t}\n\n\t/**\n\t * Sets the logger\n\t * @param {Logger} logger\n\t */\n\tpublic set logger(logger: Logger | undefined) {\n\t\tthis._logger = logger;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic onHook(event: string, handler: Hook) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.push(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {Array} hooks\n\t * @returns {void}\n\t */\n\tpublic onHooks(hooks: HookEntry[]) {\n\t\tfor (const hook of hooks) {\n\t\t\tthis.onHook(hook.event, hook.handler);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that runs before all other handlers\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic prependHook(event: string, handler: Hook) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.unshift(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event before all other handlers\n\t * @param event\n\t * @param handler\n\t */\n\tpublic prependOnceHook(event: string, handler: Hook) {\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.prependHook(event, hook);\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event\n\t * @param event\n\t * @param handler\n\t */\n\tpublic onceHook(event: string, handler: Hook) {\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.onHook(event, hook);\n\t}\n\n\t/**\n\t * Removes a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler\n\t * @returns {void}\n\t */\n\tpublic removeHook(event: string, handler: Hook) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tconst index = eventHandlers.indexOf(handler);\n\t\t\tif (index !== -1) {\n\t\t\t\teventHandlers.splice(index, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes all handlers for a specific event\n\t * @param {Array} hooks\n\t * @returns {void}\n\t */\n\tpublic removeHooks(hooks: HookEntry[]) {\n\t\tfor (const hook of hooks) {\n\t\t\tthis.removeHook(hook.event, hook.handler);\n\t\t}\n\t}\n\n\t/**\n\t * Calls all handlers for a specific event\n\t * @param {string} event\n\t * @param {T[]} arguments_\n\t * @returns {Promise}\n\t */\n\tpublic async hook(event: string, ...arguments_: T[]) {\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tfor (const handler of eventHandlers) {\n\t\t\t\ttry {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tawait handler(...arguments_);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = `${event}: ${(error as Error).message}`;\n\t\t\t\t\tthis.emit('error', new Error(message));\n\t\t\t\t\tif (this._logger) {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-call\n\t\t\t\t\t\tthis._logger.error(message);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._throwHookErrors) {\n\t\t\t\t\t\tthrow new Error(message);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Gets all hooks for a specific event\n\t * @param {string} event\n\t * @returns {Hook[]}\n\t */\n\tpublic getHooks(event: string) {\n\t\treturn this._hooks.get(event);\n\t}\n\n\t/**\n\t * Removes all hooks\n\t * @returns {void}\n\t */\n\tpublic clearHooks() {\n\t\tthis._hooks.clear();\n\t}\n}\n\nexport {Eventified, type EventListener} from './eventified.js';\nexport {type Logger} from './logger.js';\n"],"mappings":"oKAsKO,IAAMA,EAAN,KAA0C,CAKhD,YAAYC,EAA+B,CAJ3CC,EAAA,wBACAA,EAAA,sBACAA,EAAA,gBAGC,KAAK,gBAAkB,IAAI,IAC3B,KAAK,cAAgB,IAErB,KAAK,QAAUD,GAAS,MACzB,CAQO,KAAKE,EAA4BC,EAAwC,CAC/E,IAAMC,EAA8B,IAAIC,IAAsB,CAC7D,KAAK,IAAIH,EAAqBE,CAAY,EAE1CD,EAAS,GAAGE,CAAU,CACvB,EAEA,YAAK,GAAGH,EAAqBE,CAAY,EAClC,IACR,CAOO,cAAcF,EAAqC,CACzD,GAAI,CAACA,EACJ,OAAO,KAAK,gBAAgB,EAAE,OAG/B,IAAMI,EAAY,KAAK,gBAAgB,IAAIJ,CAAmB,EAC9D,OAAOI,EAAYA,EAAU,OAAS,CACvC,CAMO,YAAqC,CAC3C,MAAO,CAAC,GAAG,KAAK,gBAAgB,KAAK,CAAC,CACvC,CAOO,aAAaC,EAA0C,CAC7D,OAAKA,EAIE,KAAK,gBAAgB,IAAIA,CAAK,GAAK,CAAC,EAHnC,KAAK,gBAAgB,CAI9B,CAQO,gBAAgBL,EAA4BC,EAAwC,CAC1F,IAAMG,EAAY,KAAK,gBAAgB,IAAIJ,CAAS,GAAK,CAAC,EAC1D,OAAAI,EAAU,QAAQH,CAAQ,EAC1B,KAAK,gBAAgB,IAAID,EAAWI,CAAS,EACtC,IACR,CAQO,oBAAoBJ,EAA4BC,EAAwC,CAC9F,IAAMC,EAA8B,IAAIC,IAAsB,CAC7D,KAAK,IAAIH,EAAqBE,CAAY,EAE1CD,EAAS,GAAGE,CAAU,CACvB,EAEA,YAAK,gBAAgBH,EAAqBE,CAAY,EAC/C,IACR,CAMO,cAAuB,CAC7B,OAAO,KAAK,aACb,CAQO,YAAYG,EAAwBJ,EAAwC,CAClF,YAAK,GAAGI,EAAOJ,CAAQ,EAChB,IACR,CAQO,GAAGI,EAAwBJ,EAAwC,CACpE,KAAK,gBAAgB,IAAII,CAAK,GAClC,KAAK,gBAAgB,IAAIA,EAAO,CAAC,CAAC,EAGnC,IAAMD,EAAY,KAAK,gBAAgB,IAAIC,CAAK,EAEhD,OAAID,IACCA,EAAU,QAAU,KAAK,eAC5B,QAAQ,KAAK,qEAAqEA,EAAU,OAAS,CAAC,IAAIC,CAAe,4DAA4D,EAGtLD,EAAU,KAAKH,CAAQ,GAGjB,IACR,CAQO,eAAeI,EAAeJ,EAAwC,CAC5E,YAAK,IAAII,EAAOJ,CAAQ,EACjB,IACR,CAQO,IAAII,EAAwBJ,EAAwC,CAC1E,IAAMG,EAAY,KAAK,gBAAgB,IAAIC,CAAK,GAAK,CAAC,EAChDC,EAAQF,EAAU,QAAQH,CAAQ,EACxC,OAAIK,IAAU,IACbF,EAAU,OAAOE,EAAO,CAAC,EAGtBF,EAAU,SAAW,GACxB,KAAK,gBAAgB,OAAOC,CAAK,EAG3B,IACR,CAQO,KAAKA,KAA2BF,EAA4B,CAClE,IAAII,EAAS,GACPH,EAAY,KAAK,gBAAgB,IAAIC,CAAK,EAEhD,GAAID,GAAaA,EAAU,OAAS,EACnC,QAAWH,KAAYG,EAEtBH,EAAS,GAAGE,CAAU,EACtBI,EAAS,GAIX,OAAOA,CACR,CAOO,UAAUF,EAAgC,CAChD,OAAO,KAAK,gBAAgB,IAAIA,CAAK,GAAK,CAAC,CAC5C,CAOO,mBAAmBA,EAA+B,CACxD,OAAIA,EACH,KAAK,gBAAgB,OAAOA,CAAK,EAEjC,KAAK,gBAAgB,MAAM,EAGrB,IACR,CAOO,gBAAgBG,EAAiB,CACvC,KAAK,cAAgBA,EACrB,QAAWJ,KAAa,KAAK,gBAAgB,OAAO,EAC/CA,EAAU,OAASI,GACtBJ,EAAU,OAAOI,CAAC,CAGrB,CAMO,iBAAmC,CACzC,IAAID,EAAS,IAAI,MACjB,QAAWH,KAAa,KAAK,gBAAgB,OAAO,EACnDG,EAAS,CAAC,GAAGA,EAAQ,GAAGH,CAAS,EAGlC,OAAOG,CACR,CACD,ECtYO,IAAME,EAAN,cAAwBC,CAAW,CAIzC,YAAYC,EAA4B,CACvC,MAAM,CAAC,OAAQA,GAAS,MAAM,CAAC,EAJhCC,EAAA,eACAA,EAAA,wBAAmB,IAIlB,KAAK,OAAS,IAAI,IAEdD,GAAS,kBAAoB,SAChC,KAAK,iBAAmBA,EAAQ,gBAElC,CAMA,IAAW,OAAQ,CAClB,OAAO,KAAK,MACb,CAMA,IAAW,iBAAkB,CAC5B,OAAO,KAAK,gBACb,CAMA,IAAW,gBAAgBE,EAAO,CACjC,KAAK,iBAAmBA,CACzB,CAMA,IAAW,QAA6B,CAEvC,OAAO,KAAK,OACb,CAMA,IAAW,OAAOC,EAA4B,CAC7C,KAAK,QAAUA,CAChB,CAQO,OAAOC,EAAeC,EAAe,CAC3C,IAAMC,EAAgB,KAAK,OAAO,IAAIF,CAAK,EACvCE,EACHA,EAAc,KAAKD,CAAO,EAE1B,KAAK,OAAO,IAAID,EAAO,CAACC,CAAO,CAAC,CAElC,CAOO,QAAQE,EAAoB,CAClC,QAAWC,KAAQD,EAClB,KAAK,OAAOC,EAAK,MAAOA,EAAK,OAAO,CAEtC,CAQO,YAAYJ,EAAeC,EAAe,CAChD,IAAMC,EAAgB,KAAK,OAAO,IAAIF,CAAK,EACvCE,EACHA,EAAc,QAAQD,CAAO,EAE7B,KAAK,OAAO,IAAID,EAAO,CAACC,CAAO,CAAC,CAElC,CAOO,gBAAgBD,EAAeC,EAAe,CACpD,IAAMG,EAAO,SAAUC,KACtB,KAAK,WAAWL,EAAOI,CAAI,EAEpBH,EAAQ,GAAGI,CAAU,GAG7B,KAAK,YAAYL,EAAOI,CAAI,CAC7B,CAOO,SAASJ,EAAeC,EAAe,CAC7C,IAAMG,EAAO,SAAUC,KACtB,KAAK,WAAWL,EAAOI,CAAI,EAEpBH,EAAQ,GAAGI,CAAU,GAG7B,KAAK,OAAOL,EAAOI,CAAI,CACxB,CAQO,WAAWJ,EAAeC,EAAe,CAC/C,IAAMC,EAAgB,KAAK,OAAO,IAAIF,CAAK,EAC3C,GAAIE,EAAe,CAClB,IAAMI,EAAQJ,EAAc,QAAQD,CAAO,EACvCK,IAAU,IACbJ,EAAc,OAAOI,EAAO,CAAC,CAE/B,CACD,CAOO,YAAYH,EAAoB,CACtC,QAAWC,KAAQD,EAClB,KAAK,WAAWC,EAAK,MAAOA,EAAK,OAAO,CAE1C,CAQA,MAAa,KAAQJ,KAAkBK,EAAiB,CACvD,IAAMH,EAAgB,KAAK,OAAO,IAAIF,CAAK,EAC3C,GAAIE,EACH,QAAWD,KAAWC,EACrB,GAAI,CAEH,MAAMD,EAAQ,GAAGI,CAAU,CAC5B,OAASE,EAAO,CACf,IAAMC,EAAU,GAAGR,CAAK,KAAMO,EAAgB,OAAO,GAOrD,GANA,KAAK,KAAK,QAAS,IAAI,MAAMC,CAAO,CAAC,EACjC,KAAK,SAER,KAAK,QAAQ,MAAMA,CAAO,EAGvB,KAAK,iBACR,MAAM,IAAI,MAAMA,CAAO,CAEzB,CAGH,CAOO,SAASR,EAAe,CAC9B,OAAO,KAAK,OAAO,IAAIA,CAAK,CAC7B,CAMO,YAAa,CACnB,KAAK,OAAO,MAAM,CACnB,CACD","names":["Eventified","options","__publicField","eventName","listener","onceListener","arguments_","listeners","event","index","result","n","Hookified","Eventified","options","__publicField","value","logger","event","handler","eventHandlers","hooks","hook","arguments_","index","error","message"]} \ No newline at end of file diff --git a/node_modules/hookified/dist/node/index.cjs b/node_modules/hookified/dist/node/index.cjs index b9eb35331abc..b2b09424257a 100644 --- a/node_modules/hookified/dist/node/index.cjs +++ b/node_modules/hookified/dist/node/index.cjs @@ -1,374 +1 @@ -"use strict"; -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: true }); -}; -var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); - } - return to; -}; -var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); - -// src/index.ts -var index_exports = {}; -__export(index_exports, { - Eventified: () => Eventified, - Hookified: () => Hookified -}); -module.exports = __toCommonJS(index_exports); - -// src/eventified.ts -var Eventified = class { - _eventListeners; - _maxListeners; - constructor() { - this._eventListeners = /* @__PURE__ */ new Map(); - this._maxListeners = 100; - } - /** - * Adds a handler function for a specific event that will run only once - * @param {string | symbol} eventName - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - once(eventName, listener) { - const onceListener = (...arguments_) => { - this.off(eventName, onceListener); - listener(...arguments_); - }; - this.on(eventName, onceListener); - return this; - } - /** - * Gets the number of listeners for a specific event. If no event is provided, it returns the total number of listeners - * @param {string} eventName The event name. Not required - * @returns {number} The number of listeners - */ - listenerCount(eventName) { - if (!eventName) { - return this.getAllListeners().length; - } - const listeners = this._eventListeners.get(eventName); - return listeners ? listeners.length : 0; - } - /** - * Gets an array of event names - * @returns {Array} An array of event names - */ - eventNames() { - return Array.from(this._eventListeners.keys()); - } - /** - * Gets an array of listeners for a specific event. If no event is provided, it returns all listeners - * @param {string} [event] (Optional) The event name - * @returns {EventListener[]} An array of listeners - */ - rawListeners(event) { - if (!event) { - return this.getAllListeners(); - } - return this._eventListeners.get(event) ?? []; - } - /** - * Prepends a listener to the beginning of the listeners array for the specified event - * @param {string | symbol} eventName - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - prependListener(eventName, listener) { - const listeners = this._eventListeners.get(eventName) ?? []; - listeners.unshift(listener); - this._eventListeners.set(eventName, listeners); - return this; - } - /** - * Prepends a one-time listener to the beginning of the listeners array for the specified event - * @param {string | symbol} eventName - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - prependOnceListener(eventName, listener) { - const onceListener = (...arguments_) => { - this.off(eventName, onceListener); - listener(...arguments_); - }; - this.prependListener(eventName, onceListener); - return this; - } - /** - * Gets the maximum number of listeners that can be added for a single event - * @returns {number} The maximum number of listeners - */ - maxListeners() { - return this._maxListeners; - } - /** - * Adds a listener for a specific event. It is an alias for the on() method - * @param {string | symbol} event - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - addListener(event, listener) { - this.on(event, listener); - return this; - } - /** - * Adds a listener for a specific event - * @param {string | symbol} event - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - on(event, listener) { - if (!this._eventListeners.has(event)) { - this._eventListeners.set(event, []); - } - const listeners = this._eventListeners.get(event); - if (listeners) { - if (listeners.length >= this._maxListeners) { - console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${listeners.length + 1} ${event} listeners added. Use setMaxListeners() to increase limit.`); - } - listeners.push(listener); - } - return this; - } - /** - * Removes a listener for a specific event. It is an alias for the off() method - * @param {string | symbol} event - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - removeListener(event, listener) { - this.off(event, listener); - return this; - } - /** - * Removes a listener for a specific event - * @param {string | symbol} event - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - off(event, listener) { - const listeners = this._eventListeners.get(event) ?? []; - const index = listeners.indexOf(listener); - if (index !== -1) { - listeners.splice(index, 1); - } - if (listeners.length === 0) { - this._eventListeners.delete(event); - } - return this; - } - /** - * Calls all listeners for a specific event - * @param {string | symbol} event - * @param arguments_ The arguments to pass to the listeners - * @returns {boolean} Returns true if the event had listeners, false otherwise - */ - emit(event, ...arguments_) { - let result = false; - const listeners = this._eventListeners.get(event); - if (listeners && listeners.length > 0) { - for (const listener of listeners) { - listener(...arguments_); - result = true; - } - } - return result; - } - /** - * Gets all listeners for a specific event. If no event is provided, it returns all listeners - * @param {string} [event] (Optional) The event name - * @returns {EventListener[]} An array of listeners - */ - listeners(event) { - return this._eventListeners.get(event) ?? []; - } - /** - * Removes all listeners for a specific event. If no event is provided, it removes all listeners - * @param {string} [event] (Optional) The event name - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - removeAllListeners(event) { - if (event) { - this._eventListeners.delete(event); - } else { - this._eventListeners.clear(); - } - return this; - } - /** - * Sets the maximum number of listeners that can be added for a single event - * @param {number} n The maximum number of listeners - * @returns {void} - */ - setMaxListeners(n) { - this._maxListeners = n; - for (const listeners of this._eventListeners.values()) { - if (listeners.length > n) { - listeners.splice(n); - } - } - } - /** - * Gets all listeners - * @returns {EventListener[]} An array of listeners - */ - getAllListeners() { - let result = new Array(); - for (const listeners of this._eventListeners.values()) { - result = result.concat(listeners); - } - return result; - } -}; - -// src/index.ts -var Hookified = class extends Eventified { - _hooks; - _throwHookErrors = false; - constructor(options) { - super(); - this._hooks = /* @__PURE__ */ new Map(); - if (options?.throwHookErrors !== void 0) { - this._throwHookErrors = options.throwHookErrors; - } - } - /** - * Gets all hooks - * @returns {Map} - */ - get hooks() { - return this._hooks; - } - /** - * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event. - * @returns {boolean} - */ - get throwHookErrors() { - return this._throwHookErrors; - } - /** - * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event. - * @param {boolean} value - */ - set throwHookErrors(value) { - this._throwHookErrors = value; - } - /** - * Adds a handler function for a specific event - * @param {string} event - * @param {Hook} handler - this can be async or sync - * @returns {void} - */ - onHook(event, handler) { - const eventHandlers = this._hooks.get(event); - if (eventHandlers) { - eventHandlers.push(handler); - } else { - this._hooks.set(event, [handler]); - } - } - /** - * Adds a handler function for a specific event that runs before all other handlers - * @param {string} event - * @param {Hook} handler - this can be async or sync - * @returns {void} - */ - prependHook(event, handler) { - const eventHandlers = this._hooks.get(event); - if (eventHandlers) { - eventHandlers.unshift(handler); - } else { - this._hooks.set(event, [handler]); - } - } - /** - * Adds a handler that only executes once for a specific event before all other handlers - * @param event - * @param handler - */ - prependOnceHook(event, handler) { - const hook = async (...arguments_) => { - this.removeHook(event, hook); - return handler(...arguments_); - }; - this.prependHook(event, hook); - } - /** - * Adds a handler that only executes once for a specific event - * @param event - * @param handler - */ - onceHook(event, handler) { - const hook = async (...arguments_) => { - this.removeHook(event, hook); - return handler(...arguments_); - }; - this.onHook(event, hook); - } - /** - * Removes a handler function for a specific event - * @param {string} event - * @param {Hook} handler - * @returns {void} - */ - removeHook(event, handler) { - const eventHandlers = this._hooks.get(event); - if (eventHandlers) { - const index = eventHandlers.indexOf(handler); - if (index !== -1) { - eventHandlers.splice(index, 1); - } - } - } - /** - * Calls all handlers for a specific event - * @param {string} event - * @param {T[]} arguments_ - * @returns {Promise} - */ - async hook(event, ...arguments_) { - const eventHandlers = this._hooks.get(event); - if (eventHandlers) { - for (const handler of eventHandlers) { - try { - await handler(...arguments_); - } catch (error) { - const message = `${event}: ${error.message}`; - this.emit("error", new Error(message)); - if (this._throwHookErrors) { - throw new Error(message); - } - } - } - } - } - /** - * Gets all hooks for a specific event - * @param {string} event - * @returns {Hook[]} - */ - getHooks(event) { - return this._hooks.get(event); - } - /** - * Removes all hooks - * @returns {void} - */ - clearHooks() { - this._hooks.clear(); - } -}; -// Annotate the CommonJS export names for ESM import in node: -0 && (module.exports = { - Eventified, - Hookified -}); +"use strict";var g=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var v=(n,e)=>{for(var t in e)g(n,t,{get:e[t],enumerable:!0})},p=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of a(e))!u.call(n,r)&&r!==t&&g(n,r,{get:()=>e[r],enumerable:!(s=m(e,r))||s.enumerable});return n};var c=n=>p(g({},"__esModule",{value:!0}),n);var E={};v(E,{Eventified:()=>i,Hookified:()=>h});module.exports=c(E);var i=class{_eventListeners;_maxListeners;_logger;constructor(e){this._eventListeners=new Map,this._maxListeners=100,this._logger=e?.logger}once(e,t){let s=(...r)=>{this.off(e,s),t(...r)};return this.on(e,s),this}listenerCount(e){if(!e)return this.getAllListeners().length;let t=this._eventListeners.get(e);return t?t.length:0}eventNames(){return[...this._eventListeners.keys()]}rawListeners(e){return e?this._eventListeners.get(e)??[]:this.getAllListeners()}prependListener(e,t){let s=this._eventListeners.get(e)??[];return s.unshift(t),this._eventListeners.set(e,s),this}prependOnceListener(e,t){let s=(...r)=>{this.off(e,s),t(...r)};return this.prependListener(e,s),this}maxListeners(){return this._maxListeners}addListener(e,t){return this.on(e,t),this}on(e,t){this._eventListeners.has(e)||this._eventListeners.set(e,[]);let s=this._eventListeners.get(e);return s&&(s.length>=this._maxListeners&&console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length+1} ${e} listeners added. Use setMaxListeners() to increase limit.`),s.push(t)),this}removeListener(e,t){return this.off(e,t),this}off(e,t){let s=this._eventListeners.get(e)??[],r=s.indexOf(t);return r!==-1&&s.splice(r,1),s.length===0&&this._eventListeners.delete(e),this}emit(e,...t){let s=!1,r=this._eventListeners.get(e);if(r&&r.length>0)for(let o of r)o(...t),s=!0;return s}listeners(e){return this._eventListeners.get(e)??[]}removeAllListeners(e){return e?this._eventListeners.delete(e):this._eventListeners.clear(),this}setMaxListeners(e){this._maxListeners=e;for(let t of this._eventListeners.values())t.length>e&&t.splice(e)}getAllListeners(){let e=new Array;for(let t of this._eventListeners.values())e=[...e,...t];return e}};var h=class extends i{_hooks;_throwHookErrors=!1;constructor(e){super({logger:e?.logger}),this._hooks=new Map,e?.throwHookErrors!==void 0&&(this._throwHookErrors=e.throwHookErrors)}get hooks(){return this._hooks}get throwHookErrors(){return this._throwHookErrors}set throwHookErrors(e){this._throwHookErrors=e}get logger(){return this._logger}set logger(e){this._logger=e}onHook(e,t){let s=this._hooks.get(e);s?s.push(t):this._hooks.set(e,[t])}onHooks(e){for(let t of e)this.onHook(t.event,t.handler)}prependHook(e,t){let s=this._hooks.get(e);s?s.unshift(t):this._hooks.set(e,[t])}prependOnceHook(e,t){let s=async(...r)=>(this.removeHook(e,s),t(...r));this.prependHook(e,s)}onceHook(e,t){let s=async(...r)=>(this.removeHook(e,s),t(...r));this.onHook(e,s)}removeHook(e,t){let s=this._hooks.get(e);if(s){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}removeHooks(e){for(let t of e)this.removeHook(t.event,t.handler)}async hook(e,...t){let s=this._hooks.get(e);if(s)for(let r of s)try{await r(...t)}catch(o){let l=`${e}: ${o.message}`;if(this.emit("error",new Error(l)),this._logger&&this._logger.error(l),this._throwHookErrors)throw new Error(l)}}getHooks(e){return this._hooks.get(e)}clearHooks(){this._hooks.clear()}};0&&(module.exports={Eventified,Hookified}); diff --git a/node_modules/hookified/dist/node/index.d.cts b/node_modules/hookified/dist/node/index.d.cts index 4dabdf28f78a..05d9c1ccd396 100644 --- a/node_modules/hookified/dist/node/index.d.cts +++ b/node_modules/hookified/dist/node/index.d.cts @@ -1,3 +1,12 @@ +type Logger = { + trace: (message: string, ...arguments_: unknown[]) => void; + debug: (message: string, ...arguments_: unknown[]) => void; + info: (message: string, ...arguments_: unknown[]) => void; + warn: (message: string, ...arguments_: unknown[]) => void; + error: (message: string, ...arguments_: unknown[]) => void; + fatal: (message: string, ...arguments_: unknown[]) => void; +}; + type IEventEmitter = { /** * Registers a listener for the specified event. @@ -143,10 +152,14 @@ type IEventEmitter = { prependOnceListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter; }; type EventListener = (...arguments_: any[]) => void; +type EventEmitterOptions = { + logger?: Logger; +}; declare class Eventified implements IEventEmitter { _eventListeners: Map; _maxListeners: number; - constructor(); + _logger?: Logger; + constructor(options?: EventEmitterOptions); /** * Adds a handler function for a specific event that will run only once * @param {string | symbol} eventName @@ -251,8 +264,13 @@ declare class Eventified implements IEventEmitter { } type Hook = (...arguments_: any[]) => Promise | void; +type HookEntry = { + event: string; + handler: Hook; +}; type HookifiedOptions = { throwHookErrors?: boolean; + logger?: Logger; }; declare class Hookified extends Eventified { _hooks: Map; @@ -273,6 +291,16 @@ declare class Hookified extends Eventified { * @param {boolean} value */ set throwHookErrors(value: boolean); + /** + * Gets the logger + * @returns {Logger} + */ + get logger(): Logger | undefined; + /** + * Sets the logger + * @param {Logger} logger + */ + set logger(logger: Logger | undefined); /** * Adds a handler function for a specific event * @param {string} event @@ -280,6 +308,12 @@ declare class Hookified extends Eventified { * @returns {void} */ onHook(event: string, handler: Hook): void; + /** + * Adds a handler function for a specific event + * @param {Array} hooks + * @returns {void} + */ + onHooks(hooks: HookEntry[]): void; /** * Adds a handler function for a specific event that runs before all other handlers * @param {string} event @@ -306,6 +340,12 @@ declare class Hookified extends Eventified { * @returns {void} */ removeHook(event: string, handler: Hook): void; + /** + * Removes all handlers for a specific event + * @param {Array} hooks + * @returns {void} + */ + removeHooks(hooks: HookEntry[]): void; /** * Calls all handlers for a specific event * @param {string} event @@ -326,4 +366,4 @@ declare class Hookified extends Eventified { clearHooks(): void; } -export { type EventListener, Eventified, type Hook, Hookified, type HookifiedOptions }; +export { type EventListener, Eventified, type Hook, type HookEntry, Hookified, type HookifiedOptions, type Logger }; diff --git a/node_modules/hookified/dist/node/index.d.ts b/node_modules/hookified/dist/node/index.d.ts index 4dabdf28f78a..05d9c1ccd396 100644 --- a/node_modules/hookified/dist/node/index.d.ts +++ b/node_modules/hookified/dist/node/index.d.ts @@ -1,3 +1,12 @@ +type Logger = { + trace: (message: string, ...arguments_: unknown[]) => void; + debug: (message: string, ...arguments_: unknown[]) => void; + info: (message: string, ...arguments_: unknown[]) => void; + warn: (message: string, ...arguments_: unknown[]) => void; + error: (message: string, ...arguments_: unknown[]) => void; + fatal: (message: string, ...arguments_: unknown[]) => void; +}; + type IEventEmitter = { /** * Registers a listener for the specified event. @@ -143,10 +152,14 @@ type IEventEmitter = { prependOnceListener(eventName: string | symbol, listener: (...arguments_: any[]) => void): IEventEmitter; }; type EventListener = (...arguments_: any[]) => void; +type EventEmitterOptions = { + logger?: Logger; +}; declare class Eventified implements IEventEmitter { _eventListeners: Map; _maxListeners: number; - constructor(); + _logger?: Logger; + constructor(options?: EventEmitterOptions); /** * Adds a handler function for a specific event that will run only once * @param {string | symbol} eventName @@ -251,8 +264,13 @@ declare class Eventified implements IEventEmitter { } type Hook = (...arguments_: any[]) => Promise | void; +type HookEntry = { + event: string; + handler: Hook; +}; type HookifiedOptions = { throwHookErrors?: boolean; + logger?: Logger; }; declare class Hookified extends Eventified { _hooks: Map; @@ -273,6 +291,16 @@ declare class Hookified extends Eventified { * @param {boolean} value */ set throwHookErrors(value: boolean); + /** + * Gets the logger + * @returns {Logger} + */ + get logger(): Logger | undefined; + /** + * Sets the logger + * @param {Logger} logger + */ + set logger(logger: Logger | undefined); /** * Adds a handler function for a specific event * @param {string} event @@ -280,6 +308,12 @@ declare class Hookified extends Eventified { * @returns {void} */ onHook(event: string, handler: Hook): void; + /** + * Adds a handler function for a specific event + * @param {Array} hooks + * @returns {void} + */ + onHooks(hooks: HookEntry[]): void; /** * Adds a handler function for a specific event that runs before all other handlers * @param {string} event @@ -306,6 +340,12 @@ declare class Hookified extends Eventified { * @returns {void} */ removeHook(event: string, handler: Hook): void; + /** + * Removes all handlers for a specific event + * @param {Array} hooks + * @returns {void} + */ + removeHooks(hooks: HookEntry[]): void; /** * Calls all handlers for a specific event * @param {string} event @@ -326,4 +366,4 @@ declare class Hookified extends Eventified { clearHooks(): void; } -export { type EventListener, Eventified, type Hook, Hookified, type HookifiedOptions }; +export { type EventListener, Eventified, type Hook, type HookEntry, Hookified, type HookifiedOptions, type Logger }; diff --git a/node_modules/hookified/dist/node/index.js b/node_modules/hookified/dist/node/index.js index 6c0a64e57c72..9853c5ae9c79 100644 --- a/node_modules/hookified/dist/node/index.js +++ b/node_modules/hookified/dist/node/index.js @@ -1,346 +1 @@ -// src/eventified.ts -var Eventified = class { - _eventListeners; - _maxListeners; - constructor() { - this._eventListeners = /* @__PURE__ */ new Map(); - this._maxListeners = 100; - } - /** - * Adds a handler function for a specific event that will run only once - * @param {string | symbol} eventName - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - once(eventName, listener) { - const onceListener = (...arguments_) => { - this.off(eventName, onceListener); - listener(...arguments_); - }; - this.on(eventName, onceListener); - return this; - } - /** - * Gets the number of listeners for a specific event. If no event is provided, it returns the total number of listeners - * @param {string} eventName The event name. Not required - * @returns {number} The number of listeners - */ - listenerCount(eventName) { - if (!eventName) { - return this.getAllListeners().length; - } - const listeners = this._eventListeners.get(eventName); - return listeners ? listeners.length : 0; - } - /** - * Gets an array of event names - * @returns {Array} An array of event names - */ - eventNames() { - return Array.from(this._eventListeners.keys()); - } - /** - * Gets an array of listeners for a specific event. If no event is provided, it returns all listeners - * @param {string} [event] (Optional) The event name - * @returns {EventListener[]} An array of listeners - */ - rawListeners(event) { - if (!event) { - return this.getAllListeners(); - } - return this._eventListeners.get(event) ?? []; - } - /** - * Prepends a listener to the beginning of the listeners array for the specified event - * @param {string | symbol} eventName - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - prependListener(eventName, listener) { - const listeners = this._eventListeners.get(eventName) ?? []; - listeners.unshift(listener); - this._eventListeners.set(eventName, listeners); - return this; - } - /** - * Prepends a one-time listener to the beginning of the listeners array for the specified event - * @param {string | symbol} eventName - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - prependOnceListener(eventName, listener) { - const onceListener = (...arguments_) => { - this.off(eventName, onceListener); - listener(...arguments_); - }; - this.prependListener(eventName, onceListener); - return this; - } - /** - * Gets the maximum number of listeners that can be added for a single event - * @returns {number} The maximum number of listeners - */ - maxListeners() { - return this._maxListeners; - } - /** - * Adds a listener for a specific event. It is an alias for the on() method - * @param {string | symbol} event - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - addListener(event, listener) { - this.on(event, listener); - return this; - } - /** - * Adds a listener for a specific event - * @param {string | symbol} event - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - on(event, listener) { - if (!this._eventListeners.has(event)) { - this._eventListeners.set(event, []); - } - const listeners = this._eventListeners.get(event); - if (listeners) { - if (listeners.length >= this._maxListeners) { - console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${listeners.length + 1} ${event} listeners added. Use setMaxListeners() to increase limit.`); - } - listeners.push(listener); - } - return this; - } - /** - * Removes a listener for a specific event. It is an alias for the off() method - * @param {string | symbol} event - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - removeListener(event, listener) { - this.off(event, listener); - return this; - } - /** - * Removes a listener for a specific event - * @param {string | symbol} event - * @param {EventListener} listener - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - off(event, listener) { - const listeners = this._eventListeners.get(event) ?? []; - const index = listeners.indexOf(listener); - if (index !== -1) { - listeners.splice(index, 1); - } - if (listeners.length === 0) { - this._eventListeners.delete(event); - } - return this; - } - /** - * Calls all listeners for a specific event - * @param {string | symbol} event - * @param arguments_ The arguments to pass to the listeners - * @returns {boolean} Returns true if the event had listeners, false otherwise - */ - emit(event, ...arguments_) { - let result = false; - const listeners = this._eventListeners.get(event); - if (listeners && listeners.length > 0) { - for (const listener of listeners) { - listener(...arguments_); - result = true; - } - } - return result; - } - /** - * Gets all listeners for a specific event. If no event is provided, it returns all listeners - * @param {string} [event] (Optional) The event name - * @returns {EventListener[]} An array of listeners - */ - listeners(event) { - return this._eventListeners.get(event) ?? []; - } - /** - * Removes all listeners for a specific event. If no event is provided, it removes all listeners - * @param {string} [event] (Optional) The event name - * @returns {IEventEmitter} returns the instance of the class for chaining - */ - removeAllListeners(event) { - if (event) { - this._eventListeners.delete(event); - } else { - this._eventListeners.clear(); - } - return this; - } - /** - * Sets the maximum number of listeners that can be added for a single event - * @param {number} n The maximum number of listeners - * @returns {void} - */ - setMaxListeners(n) { - this._maxListeners = n; - for (const listeners of this._eventListeners.values()) { - if (listeners.length > n) { - listeners.splice(n); - } - } - } - /** - * Gets all listeners - * @returns {EventListener[]} An array of listeners - */ - getAllListeners() { - let result = new Array(); - for (const listeners of this._eventListeners.values()) { - result = result.concat(listeners); - } - return result; - } -}; - -// src/index.ts -var Hookified = class extends Eventified { - _hooks; - _throwHookErrors = false; - constructor(options) { - super(); - this._hooks = /* @__PURE__ */ new Map(); - if (options?.throwHookErrors !== void 0) { - this._throwHookErrors = options.throwHookErrors; - } - } - /** - * Gets all hooks - * @returns {Map} - */ - get hooks() { - return this._hooks; - } - /** - * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event. - * @returns {boolean} - */ - get throwHookErrors() { - return this._throwHookErrors; - } - /** - * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event. - * @param {boolean} value - */ - set throwHookErrors(value) { - this._throwHookErrors = value; - } - /** - * Adds a handler function for a specific event - * @param {string} event - * @param {Hook} handler - this can be async or sync - * @returns {void} - */ - onHook(event, handler) { - const eventHandlers = this._hooks.get(event); - if (eventHandlers) { - eventHandlers.push(handler); - } else { - this._hooks.set(event, [handler]); - } - } - /** - * Adds a handler function for a specific event that runs before all other handlers - * @param {string} event - * @param {Hook} handler - this can be async or sync - * @returns {void} - */ - prependHook(event, handler) { - const eventHandlers = this._hooks.get(event); - if (eventHandlers) { - eventHandlers.unshift(handler); - } else { - this._hooks.set(event, [handler]); - } - } - /** - * Adds a handler that only executes once for a specific event before all other handlers - * @param event - * @param handler - */ - prependOnceHook(event, handler) { - const hook = async (...arguments_) => { - this.removeHook(event, hook); - return handler(...arguments_); - }; - this.prependHook(event, hook); - } - /** - * Adds a handler that only executes once for a specific event - * @param event - * @param handler - */ - onceHook(event, handler) { - const hook = async (...arguments_) => { - this.removeHook(event, hook); - return handler(...arguments_); - }; - this.onHook(event, hook); - } - /** - * Removes a handler function for a specific event - * @param {string} event - * @param {Hook} handler - * @returns {void} - */ - removeHook(event, handler) { - const eventHandlers = this._hooks.get(event); - if (eventHandlers) { - const index = eventHandlers.indexOf(handler); - if (index !== -1) { - eventHandlers.splice(index, 1); - } - } - } - /** - * Calls all handlers for a specific event - * @param {string} event - * @param {T[]} arguments_ - * @returns {Promise} - */ - async hook(event, ...arguments_) { - const eventHandlers = this._hooks.get(event); - if (eventHandlers) { - for (const handler of eventHandlers) { - try { - await handler(...arguments_); - } catch (error) { - const message = `${event}: ${error.message}`; - this.emit("error", new Error(message)); - if (this._throwHookErrors) { - throw new Error(message); - } - } - } - } - } - /** - * Gets all hooks for a specific event - * @param {string} event - * @returns {Hook[]} - */ - getHooks(event) { - return this._hooks.get(event); - } - /** - * Removes all hooks - * @returns {void} - */ - clearHooks() { - this._hooks.clear(); - } -}; -export { - Eventified, - Hookified -}; +var n=class{_eventListeners;_maxListeners;_logger;constructor(e){this._eventListeners=new Map,this._maxListeners=100,this._logger=e?.logger}once(e,t){let s=(...r)=>{this.off(e,s),t(...r)};return this.on(e,s),this}listenerCount(e){if(!e)return this.getAllListeners().length;let t=this._eventListeners.get(e);return t?t.length:0}eventNames(){return[...this._eventListeners.keys()]}rawListeners(e){return e?this._eventListeners.get(e)??[]:this.getAllListeners()}prependListener(e,t){let s=this._eventListeners.get(e)??[];return s.unshift(t),this._eventListeners.set(e,s),this}prependOnceListener(e,t){let s=(...r)=>{this.off(e,s),t(...r)};return this.prependListener(e,s),this}maxListeners(){return this._maxListeners}addListener(e,t){return this.on(e,t),this}on(e,t){this._eventListeners.has(e)||this._eventListeners.set(e,[]);let s=this._eventListeners.get(e);return s&&(s.length>=this._maxListeners&&console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length+1} ${e} listeners added. Use setMaxListeners() to increase limit.`),s.push(t)),this}removeListener(e,t){return this.off(e,t),this}off(e,t){let s=this._eventListeners.get(e)??[],r=s.indexOf(t);return r!==-1&&s.splice(r,1),s.length===0&&this._eventListeners.delete(e),this}emit(e,...t){let s=!1,r=this._eventListeners.get(e);if(r&&r.length>0)for(let i of r)i(...t),s=!0;return s}listeners(e){return this._eventListeners.get(e)??[]}removeAllListeners(e){return e?this._eventListeners.delete(e):this._eventListeners.clear(),this}setMaxListeners(e){this._maxListeners=e;for(let t of this._eventListeners.values())t.length>e&&t.splice(e)}getAllListeners(){let e=new Array;for(let t of this._eventListeners.values())e=[...e,...t];return e}};var l=class extends n{_hooks;_throwHookErrors=!1;constructor(e){super({logger:e?.logger}),this._hooks=new Map,e?.throwHookErrors!==void 0&&(this._throwHookErrors=e.throwHookErrors)}get hooks(){return this._hooks}get throwHookErrors(){return this._throwHookErrors}set throwHookErrors(e){this._throwHookErrors=e}get logger(){return this._logger}set logger(e){this._logger=e}onHook(e,t){let s=this._hooks.get(e);s?s.push(t):this._hooks.set(e,[t])}onHooks(e){for(let t of e)this.onHook(t.event,t.handler)}prependHook(e,t){let s=this._hooks.get(e);s?s.unshift(t):this._hooks.set(e,[t])}prependOnceHook(e,t){let s=async(...r)=>(this.removeHook(e,s),t(...r));this.prependHook(e,s)}onceHook(e,t){let s=async(...r)=>(this.removeHook(e,s),t(...r));this.onHook(e,s)}removeHook(e,t){let s=this._hooks.get(e);if(s){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}removeHooks(e){for(let t of e)this.removeHook(t.event,t.handler)}async hook(e,...t){let s=this._hooks.get(e);if(s)for(let r of s)try{await r(...t)}catch(i){let o=`${e}: ${i.message}`;if(this.emit("error",new Error(o)),this._logger&&this._logger.error(o),this._throwHookErrors)throw new Error(o)}}getHooks(e){return this._hooks.get(e)}clearHooks(){this._hooks.clear()}};export{n as Eventified,l as Hookified}; diff --git a/node_modules/hookified/package.json b/node_modules/hookified/package.json index de4c41ae9886..1f6715f1ace4 100644 --- a/node_modules/hookified/package.json +++ b/node_modules/hookified/package.json @@ -1,6 +1,6 @@ { "name": "hookified", - "version": "1.7.1", + "version": "1.9.1", "description": "Event Emitting and Middleware Hooks", "type": "module", "main": "dist/node/index.cjs", @@ -21,9 +21,12 @@ "test:ci": "xo && vitest run --coverage", "clean": "rimraf ./dist ./coverage ./site/dist", "build": "rimraf ./dist && tsup", + "benchmark": "pnpm benchmark:hooks && pnpm benchmark:emit", + "benchmark:hooks": "pnpm tsx benchmark/hook.ts", + "benchmark:emit": "pnpm tsx benchmark/emit.ts", "website:build": "docula build", "website:serve": "docula serve", - "prepare": "npm run build" + "prepare": "pnpm build" }, "keywords": [ "hooks", @@ -57,16 +60,30 @@ }, "homepage": "https://github.com/jaredwray/hookified#readme", "devDependencies": { - "@vitest/coverage-v8": "^3.0.5", - "docula": "^0.10.0", + "@monstermann/tinybench-pretty-printer": "^0.1.0", + "@types/node": "^22.15.29", + "@vitest/coverage-v8": "^3.1.4", + "docula": "^0.12.2", + "emittery": "^1.1.0", + "eventemitter3": "^5.0.1", + "hookable": "^5.5.3", + "pino": "^9.7.0", "rimraf": "^6.0.1", - "tsup": "^8.3.6", - "typescript": "^5.7.3", - "vitest": "^3.0.5", - "xo": "^0.60.0" + "tinybench": "^4.0.1", + "tsup": "^8.5.0", + "tsx": "^4.19.4", + "typescript": "^5.8.3", + "vitest": "^3.1.4", + "xo": "^1.0.5" }, "files": [ "dist", "LICENSE" - ] + ], + "pnpm": { + "onlyBuiltDependencies": [ + "esbuild", + "unrs-resolver" + ] + } } diff --git a/node_modules/keyv/README.md b/node_modules/keyv/README.md index fa0988d0b539..0cc239a5b640 100644 --- a/node_modules/keyv/README.md +++ b/node_modules/keyv/README.md @@ -24,6 +24,46 @@ There are a few existing modules similar to Keyv, however Keyv is different beca - Connection errors are passed through (db failures won't kill your app) - Supports the current active LTS version of Node.js or higher +# Table of Contents +- [Usage](#usage) +- [Type-safe Usage](#type-safe-usage) +- [Using Storage Adapters](#using-storage-adapters) +- [Namespaces](#namespaces) +- [Events](#events) +- [Hooks](#hooks) +- [Custom Serializers](#custom-serializers) +- [Official Storage Adapters](#official-storage-adapters) +- [Third-party Storage Adapters](#third-party-storage-adapters) +- [Compression](#compression) +- [API](#api) + - [new Keyv([storage-adapter], [options]) or new Keyv([options])](#new-keyvstorage-adapter-options-or-new-keyvoptions) + - [.namespace](#namespace) + - [.ttl](#ttl) + - [.store](#store) + - [.serialize](#serialize) + - [.deserialize](#deserialize) + - [.compression](#compression) + - [.useKeyPrefix](#usekeyprefix) + - [Keyv Instance](#keyv-instance) + - [.set(key, value, [ttl])](#setkey-value-ttl) + - [.setMany(entries)](#setmanyentries) + - [.get(key, [options])](#getkey-options) + - [.getMany(keys, [options])](#getmanykeys-options) + - [.delete(key)](#deletekey) + - [.deleteMany(keys)](#deletemanykeys) + - [.clear()](#clear) + - [.iterator()](#iterator) +- [API - Properties](#api---properties) + - [.namespace](#namespace-1) + - [.ttl](#ttl-1) + - [.store](#store-1) + - [.serialize](#serialize-1) + - [.deserialize](#deserialize-1) + - [.compression](#compression-1) + - [.useKeyPrefix](#usekeyprefix-1) +- [How to Contribute](#how-to-contribute) +- [License](#license) + # Usage Install Keyv. @@ -189,7 +229,7 @@ import Keyv, { KeyvHooks } from 'keyv'; ```js //PRE_SET hook const keyv = new Keyv(); -keyv.hooks.addHandler(KeyvHooks.PRE_SET, (key, value) => console.log(`Setting key ${key} to ${value}`)); +keyv.hooks.addHandler(KeyvHooks.PRE_SET, (data) => console.log(`Setting key ${data.key} to ${data.value}`)); //POST_SET hook const keyv = new Keyv(); @@ -200,9 +240,10 @@ In these examples you can also manipulate the value before it is set. For exampl ```js const keyv = new Keyv(); -keyv.hooks.addHandler(KeyvHooks.PRE_SET, (key, value) => { - console.log(`Setting key ${key} to ${value}`); - key = `prefix-${key}`; +keyv.hooks.addHandler(KeyvHooks.PRE_SET, (data) => { + console.log(`Manipulating key ${data.key} and ${data.value}`); + data.key = `prefix-${data.key}`; + data.value = `prefix-${data.value}`; }); ``` diff --git a/node_modules/keyv/dist/index.cjs b/node_modules/keyv/dist/index.cjs index d045624c54ef..43193b5a9ddd 100644 --- a/node_modules/keyv/dist/index.cjs +++ b/node_modules/keyv/dist/index.cjs @@ -83,14 +83,6 @@ var EventManager = class { for (const listener of listeners) { listener(...arguments_); } - } else if (event === "error") { - if (arguments_[0] instanceof Error) { - throw arguments_[0]; - } else { - const error = new CustomError(arguments_[0]); - error.context = arguments_[0]; - throw error; - } } } // Get all listeners for a specific event @@ -110,17 +102,6 @@ var EventManager = class { this._maxListeners = n; } }; -var CustomError = class _CustomError extends Error { - context; - constructor(message, context) { - super(message); - this.context = context; - if (Error.captureStackTrace) { - Error.captureStackTrace(this, _CustomError); - } - this.name = this.constructor.name; - } -}; var event_manager_default = EventManager; // src/hooks-manager.ts @@ -482,6 +463,7 @@ var Keyv = class extends event_manager_default { _isValidStorageAdapter(store) { return store instanceof Map || typeof store.get === "function" && typeof store.set === "function" && typeof store.delete === "function" && typeof store.clear === "function"; } + // eslint-disable-next-line @stylistic/max-len async get(key, options) { const { store } = this.opts; const isArray = Array.isArray(key); @@ -568,24 +550,24 @@ var Keyv = class extends event_manager_default { * @returns {boolean} if it sets then it will return a true. On failure will return false. */ async set(key, value, ttl) { - this.hooks.trigger("preSet" /* PRE_SET */, { key, value, ttl }); - const keyPrefixed = this._getKeyPrefix(key); - if (ttl === void 0) { - ttl = this._ttl; - } - if (ttl === 0) { - ttl = void 0; + const data = { key, value, ttl }; + this.hooks.trigger("preSet" /* PRE_SET */, data); + const keyPrefixed = this._getKeyPrefix(data.key); + data.ttl ??= this._ttl; + if (data.ttl === 0) { + data.ttl = void 0; } const { store } = this.opts; - const expires = typeof ttl === "number" ? Date.now() + ttl : null; - if (typeof value === "symbol") { + const expires = typeof data.ttl === "number" ? Date.now() + data.ttl : void 0; + if (typeof data.value === "symbol") { this.emit("error", "symbol cannot be serialized"); + throw new Error("symbol cannot be serialized"); } - const formattedValue = { value, expires }; + const formattedValue = { value: data.value, expires }; const serializedValue = await this.serializeData(formattedValue); let result = true; try { - const value2 = await store.set(keyPrefixed, serializedValue, ttl); + const value2 = await store.set(keyPrefixed, serializedValue, data.ttl); if (typeof value2 === "boolean") { result = value2; } @@ -606,8 +588,21 @@ var Keyv = class extends event_manager_default { let results = []; try { if (this._store.setMany !== void 0) { - results = await this._store.setMany(entries); - return results; + const serializedEntries = await Promise.all(entries.map(async ({ key, value, ttl }) => { + ttl ??= this._ttl; + if (ttl === 0) { + ttl = void 0; + } + const expires = typeof ttl === "number" ? Date.now() + ttl : void 0; + if (typeof value === "symbol") { + this.emit("error", "symbol cannot be serialized"); + throw new Error("symbol cannot be serialized"); + } + const formattedValue = { value, expires }; + const serializedValue = await this.serializeData(formattedValue); + return { key, value: serializedValue, ttl }; + })); + results = await this._store.setMany(serializedEntries); } const promises = []; for (const entry of entries) { diff --git a/node_modules/keyv/dist/index.d.cts b/node_modules/keyv/dist/index.d.cts index 3db6576393ea..50ca37d5254b 100644 --- a/node_modules/keyv/dist/index.d.cts +++ b/node_modules/keyv/dist/index.d.cts @@ -42,7 +42,7 @@ declare class StatsManager extends EventManager { type DeserializedData = { value?: Value; - expires?: number | null; + expires?: number | undefined; }; type CompressionAdapter = { compress(value: any, options?: any): Promise; diff --git a/node_modules/keyv/dist/index.d.ts b/node_modules/keyv/dist/index.d.ts index 3db6576393ea..50ca37d5254b 100644 --- a/node_modules/keyv/dist/index.d.ts +++ b/node_modules/keyv/dist/index.d.ts @@ -42,7 +42,7 @@ declare class StatsManager extends EventManager { type DeserializedData = { value?: Value; - expires?: number | null; + expires?: number | undefined; }; type CompressionAdapter = { compress(value: any, options?: any): Promise; diff --git a/node_modules/keyv/dist/index.js b/node_modules/keyv/dist/index.js index 49adc09e9a8f..7c2dd9e24bc8 100644 --- a/node_modules/keyv/dist/index.js +++ b/node_modules/keyv/dist/index.js @@ -57,14 +57,6 @@ var EventManager = class { for (const listener of listeners) { listener(...arguments_); } - } else if (event === "error") { - if (arguments_[0] instanceof Error) { - throw arguments_[0]; - } else { - const error = new CustomError(arguments_[0]); - error.context = arguments_[0]; - throw error; - } } } // Get all listeners for a specific event @@ -84,17 +76,6 @@ var EventManager = class { this._maxListeners = n; } }; -var CustomError = class _CustomError extends Error { - context; - constructor(message, context) { - super(message); - this.context = context; - if (Error.captureStackTrace) { - Error.captureStackTrace(this, _CustomError); - } - this.name = this.constructor.name; - } -}; var event_manager_default = EventManager; // src/hooks-manager.ts @@ -456,6 +437,7 @@ var Keyv = class extends event_manager_default { _isValidStorageAdapter(store) { return store instanceof Map || typeof store.get === "function" && typeof store.set === "function" && typeof store.delete === "function" && typeof store.clear === "function"; } + // eslint-disable-next-line @stylistic/max-len async get(key, options) { const { store } = this.opts; const isArray = Array.isArray(key); @@ -542,24 +524,24 @@ var Keyv = class extends event_manager_default { * @returns {boolean} if it sets then it will return a true. On failure will return false. */ async set(key, value, ttl) { - this.hooks.trigger("preSet" /* PRE_SET */, { key, value, ttl }); - const keyPrefixed = this._getKeyPrefix(key); - if (ttl === void 0) { - ttl = this._ttl; - } - if (ttl === 0) { - ttl = void 0; + const data = { key, value, ttl }; + this.hooks.trigger("preSet" /* PRE_SET */, data); + const keyPrefixed = this._getKeyPrefix(data.key); + data.ttl ??= this._ttl; + if (data.ttl === 0) { + data.ttl = void 0; } const { store } = this.opts; - const expires = typeof ttl === "number" ? Date.now() + ttl : null; - if (typeof value === "symbol") { + const expires = typeof data.ttl === "number" ? Date.now() + data.ttl : void 0; + if (typeof data.value === "symbol") { this.emit("error", "symbol cannot be serialized"); + throw new Error("symbol cannot be serialized"); } - const formattedValue = { value, expires }; + const formattedValue = { value: data.value, expires }; const serializedValue = await this.serializeData(formattedValue); let result = true; try { - const value2 = await store.set(keyPrefixed, serializedValue, ttl); + const value2 = await store.set(keyPrefixed, serializedValue, data.ttl); if (typeof value2 === "boolean") { result = value2; } @@ -580,8 +562,21 @@ var Keyv = class extends event_manager_default { let results = []; try { if (this._store.setMany !== void 0) { - results = await this._store.setMany(entries); - return results; + const serializedEntries = await Promise.all(entries.map(async ({ key, value, ttl }) => { + ttl ??= this._ttl; + if (ttl === 0) { + ttl = void 0; + } + const expires = typeof ttl === "number" ? Date.now() + ttl : void 0; + if (typeof value === "symbol") { + this.emit("error", "symbol cannot be serialized"); + throw new Error("symbol cannot be serialized"); + } + const formattedValue = { value, expires }; + const serializedValue = await this.serializeData(formattedValue); + return { key, value: serializedValue, ttl }; + })); + results = await this._store.setMany(serializedEntries); } const promises = []; for (const entry of entries) { diff --git a/node_modules/keyv/package.json b/node_modules/keyv/package.json index 2e1539a7f9e8..484831b248e4 100644 --- a/node_modules/keyv/package.json +++ b/node_modules/keyv/package.json @@ -1,6 +1,6 @@ { "name": "keyv", - "version": "5.3.2", + "version": "5.3.4", "description": "Simple key-value storage with support for multiple backends", "type": "module", "main": "dist/index.cjs", @@ -57,20 +57,20 @@ "@keyv/serialize": "^1.0.3" }, "devDependencies": { - "@faker-js/faker": "^9.5.1", - "@vitest/coverage-v8": "^3.0.7", + "@faker-js/faker": "^9.8.0", + "@vitest/coverage-v8": "^3.2.3", "rimraf": "^6.0.1", "timekeeper": "^2.3.1", - "tsd": "^0.31.2", - "vitest": "^3.0.7", - "xo": "^0.60.0", - "@keyv/compress-brotli": "^2.0.3", - "@keyv/compress-gzip": "^2.0.2", - "@keyv/test-suite": "^2.0.5", + "tsd": "^0.32.0", + "vitest": "^3.2.3", + "xo": "^1.1.0", + "@keyv/compress-brotli": "^2.0.4", + "@keyv/compress-gzip": "^2.0.3", + "@keyv/sqlite": "^4.0.4", "@keyv/memcache": "^2.0.1", - "@keyv/sqlite": "^4.0.1", - "@keyv/compress-lz4": "^1.0.0", - "@keyv/mongo": "^3.0.1" + "@keyv/test-suite": "^2.0.7", + "@keyv/mongo": "^3.0.2", + "@keyv/compress-lz4": "^1.0.0" }, "tsd": { "directory": "test" diff --git a/node_modules/puppeteer-core/node_modules/debug/package.json b/node_modules/puppeteer-core/node_modules/debug/package.json index 60dfcf57cae4..afc2f8b615b2 100644 --- a/node_modules/puppeteer-core/node_modules/debug/package.json +++ b/node_modules/puppeteer-core/node_modules/debug/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.4.0", + "version": "4.4.1", "repository": { "type": "git", "url": "git://github.com/debug-js/debug.git" @@ -26,7 +26,7 @@ "scripts": { "lint": "xo", "test": "npm run test:node && npm run test:browser && npm run lint", - "test:node": "istanbul cover _mocha -- test.js test.node.js", + "test:node": "mocha test.js test.node.js", "test:browser": "karma start --single-run", "test:coverage": "cat ./coverage/lcov.info | coveralls" }, @@ -37,7 +37,6 @@ "brfs": "^2.0.1", "browserify": "^16.2.3", "coveralls": "^3.0.2", - "istanbul": "^0.4.5", "karma": "^3.1.4", "karma-browserify": "^6.0.0", "karma-chrome-launcher": "^2.2.0", diff --git a/node_modules/puppeteer-core/node_modules/debug/src/browser.js b/node_modules/puppeteer-core/node_modules/debug/src/browser.js index df8e179e8b5d..5993451b82e6 100644 --- a/node_modules/puppeteer-core/node_modules/debug/src/browser.js +++ b/node_modules/puppeteer-core/node_modules/debug/src/browser.js @@ -219,7 +219,7 @@ function save(namespaces) { function load() { let r; try { - r = exports.storage.getItem('debug'); + r = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ; } catch (error) { // Swallow // XXX (@Qix-) should we be logging these? diff --git a/node_modules/puppeteer-core/node_modules/debug/src/common.js b/node_modules/puppeteer-core/node_modules/debug/src/common.js index 528c7ecf417c..141cb578b772 100644 --- a/node_modules/puppeteer-core/node_modules/debug/src/common.js +++ b/node_modules/puppeteer-core/node_modules/debug/src/common.js @@ -168,7 +168,7 @@ function setup(env) { const split = (typeof namespaces === 'string' ? namespaces : '') .trim() - .replace(' ', ',') + .replace(/\s+/g, ',') .split(',') .filter(Boolean); diff --git a/node_modules/semver/bin/semver.js b/node_modules/semver/bin/semver.js index 22fc76ea2506..dbb1bf534ec7 100755 --- a/node_modules/semver/bin/semver.js +++ b/node_modules/semver/bin/semver.js @@ -3,6 +3,8 @@ // Exits successfully and prints matching version(s) if // any supplied version is valid and passes all tests. +'use strict' + const argv = process.argv.slice(2) let versions = [] diff --git a/node_modules/semver/classes/comparator.js b/node_modules/semver/classes/comparator.js index 3d39c0eef780..647c1f0976fd 100644 --- a/node_modules/semver/classes/comparator.js +++ b/node_modules/semver/classes/comparator.js @@ -1,3 +1,5 @@ +'use strict' + const ANY = Symbol('SemVer ANY') // hoisted class for cyclic dependency class Comparator { diff --git a/node_modules/semver/classes/index.js b/node_modules/semver/classes/index.js index 5e3f5c9b19ce..91c24ec4a726 100644 --- a/node_modules/semver/classes/index.js +++ b/node_modules/semver/classes/index.js @@ -1,3 +1,5 @@ +'use strict' + module.exports = { SemVer: require('./semver.js'), Range: require('./range.js'), diff --git a/node_modules/semver/classes/range.js b/node_modules/semver/classes/range.js index ceee23144d3b..f80c2359c6b8 100644 --- a/node_modules/semver/classes/range.js +++ b/node_modules/semver/classes/range.js @@ -1,3 +1,5 @@ +'use strict' + const SPACE_CHARACTERS = /\s+/g // hoisted class for cyclic dependency diff --git a/node_modules/semver/classes/semver.js b/node_modules/semver/classes/semver.js index 6fbc062bc246..2efba0f4b645 100644 --- a/node_modules/semver/classes/semver.js +++ b/node_modules/semver/classes/semver.js @@ -1,6 +1,8 @@ +'use strict' + const debug = require('../internal/debug') const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants') -const { safeRe: re, safeSrc: src, t } = require('../internal/re') +const { safeRe: re, t } = require('../internal/re') const parseOptions = require('../internal/parse-options') const { compareIdentifiers } = require('../internal/identifiers') @@ -182,8 +184,7 @@ class SemVer { } // Avoid an invalid semver results if (identifier) { - const r = new RegExp(`^${this.options.loose ? src[t.PRERELEASELOOSE] : src[t.PRERELEASE]}$`) - const match = `-${identifier}`.match(r) + const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]) if (!match || match[1] !== identifier) { throw new Error(`invalid identifier: ${identifier}`) } diff --git a/node_modules/semver/functions/clean.js b/node_modules/semver/functions/clean.js index 811fe6b82cb7..79703d631661 100644 --- a/node_modules/semver/functions/clean.js +++ b/node_modules/semver/functions/clean.js @@ -1,3 +1,5 @@ +'use strict' + const parse = require('./parse') const clean = (version, options) => { const s = parse(version.trim().replace(/^[=v]+/, ''), options) diff --git a/node_modules/semver/functions/cmp.js b/node_modules/semver/functions/cmp.js index 40119094747d..77487dcaac5f 100644 --- a/node_modules/semver/functions/cmp.js +++ b/node_modules/semver/functions/cmp.js @@ -1,3 +1,5 @@ +'use strict' + const eq = require('./eq') const neq = require('./neq') const gt = require('./gt') diff --git a/node_modules/semver/functions/coerce.js b/node_modules/semver/functions/coerce.js index b378dcea4e5a..cfe027599516 100644 --- a/node_modules/semver/functions/coerce.js +++ b/node_modules/semver/functions/coerce.js @@ -1,3 +1,5 @@ +'use strict' + const SemVer = require('../classes/semver') const parse = require('./parse') const { safeRe: re, t } = require('../internal/re') diff --git a/node_modules/semver/functions/compare-build.js b/node_modules/semver/functions/compare-build.js index 9eb881bef0fd..99157cf3d105 100644 --- a/node_modules/semver/functions/compare-build.js +++ b/node_modules/semver/functions/compare-build.js @@ -1,3 +1,5 @@ +'use strict' + const SemVer = require('../classes/semver') const compareBuild = (a, b, loose) => { const versionA = new SemVer(a, loose) diff --git a/node_modules/semver/functions/compare-loose.js b/node_modules/semver/functions/compare-loose.js index 4881fbe00250..75316346a81c 100644 --- a/node_modules/semver/functions/compare-loose.js +++ b/node_modules/semver/functions/compare-loose.js @@ -1,3 +1,5 @@ +'use strict' + const compare = require('./compare') const compareLoose = (a, b) => compare(a, b, true) module.exports = compareLoose diff --git a/node_modules/semver/functions/compare.js b/node_modules/semver/functions/compare.js index 748b7afa514a..63d8090c626c 100644 --- a/node_modules/semver/functions/compare.js +++ b/node_modules/semver/functions/compare.js @@ -1,3 +1,5 @@ +'use strict' + const SemVer = require('../classes/semver') const compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose)) diff --git a/node_modules/semver/functions/diff.js b/node_modules/semver/functions/diff.js index 33171dc1ca45..04e064e9196b 100644 --- a/node_modules/semver/functions/diff.js +++ b/node_modules/semver/functions/diff.js @@ -1,3 +1,5 @@ +'use strict' + const parse = require('./parse.js') const diff = (version1, version2) => { diff --git a/node_modules/semver/functions/eq.js b/node_modules/semver/functions/eq.js index 271fed976f34..5f0eead1169f 100644 --- a/node_modules/semver/functions/eq.js +++ b/node_modules/semver/functions/eq.js @@ -1,3 +1,5 @@ +'use strict' + const compare = require('./compare') const eq = (a, b, loose) => compare(a, b, loose) === 0 module.exports = eq diff --git a/node_modules/semver/functions/gt.js b/node_modules/semver/functions/gt.js index d9b2156d8b56..84a57ddff50a 100644 --- a/node_modules/semver/functions/gt.js +++ b/node_modules/semver/functions/gt.js @@ -1,3 +1,5 @@ +'use strict' + const compare = require('./compare') const gt = (a, b, loose) => compare(a, b, loose) > 0 module.exports = gt diff --git a/node_modules/semver/functions/gte.js b/node_modules/semver/functions/gte.js index 5aeaa634707a..7c52bdf2529a 100644 --- a/node_modules/semver/functions/gte.js +++ b/node_modules/semver/functions/gte.js @@ -1,3 +1,5 @@ +'use strict' + const compare = require('./compare') const gte = (a, b, loose) => compare(a, b, loose) >= 0 module.exports = gte diff --git a/node_modules/semver/functions/inc.js b/node_modules/semver/functions/inc.js index 7670b1bea1a4..ff999e9d04d7 100644 --- a/node_modules/semver/functions/inc.js +++ b/node_modules/semver/functions/inc.js @@ -1,3 +1,5 @@ +'use strict' + const SemVer = require('../classes/semver') const inc = (version, release, options, identifier, identifierBase) => { diff --git a/node_modules/semver/functions/lt.js b/node_modules/semver/functions/lt.js index b440ab7d4212..2fb32a0e63c9 100644 --- a/node_modules/semver/functions/lt.js +++ b/node_modules/semver/functions/lt.js @@ -1,3 +1,5 @@ +'use strict' + const compare = require('./compare') const lt = (a, b, loose) => compare(a, b, loose) < 0 module.exports = lt diff --git a/node_modules/semver/functions/lte.js b/node_modules/semver/functions/lte.js index 6dcc95650558..da9ee8f4e440 100644 --- a/node_modules/semver/functions/lte.js +++ b/node_modules/semver/functions/lte.js @@ -1,3 +1,5 @@ +'use strict' + const compare = require('./compare') const lte = (a, b, loose) => compare(a, b, loose) <= 0 module.exports = lte diff --git a/node_modules/semver/functions/major.js b/node_modules/semver/functions/major.js index 4283165e9d27..e6d08dc20cf2 100644 --- a/node_modules/semver/functions/major.js +++ b/node_modules/semver/functions/major.js @@ -1,3 +1,5 @@ +'use strict' + const SemVer = require('../classes/semver') const major = (a, loose) => new SemVer(a, loose).major module.exports = major diff --git a/node_modules/semver/functions/minor.js b/node_modules/semver/functions/minor.js index 57b3455f827b..9e70ffda1922 100644 --- a/node_modules/semver/functions/minor.js +++ b/node_modules/semver/functions/minor.js @@ -1,3 +1,5 @@ +'use strict' + const SemVer = require('../classes/semver') const minor = (a, loose) => new SemVer(a, loose).minor module.exports = minor diff --git a/node_modules/semver/functions/neq.js b/node_modules/semver/functions/neq.js index f944c0157697..84326b773361 100644 --- a/node_modules/semver/functions/neq.js +++ b/node_modules/semver/functions/neq.js @@ -1,3 +1,5 @@ +'use strict' + const compare = require('./compare') const neq = (a, b, loose) => compare(a, b, loose) !== 0 module.exports = neq diff --git a/node_modules/semver/functions/parse.js b/node_modules/semver/functions/parse.js index 459b3b17375c..d544d33a7e93 100644 --- a/node_modules/semver/functions/parse.js +++ b/node_modules/semver/functions/parse.js @@ -1,3 +1,5 @@ +'use strict' + const SemVer = require('../classes/semver') const parse = (version, options, throwErrors = false) => { if (version instanceof SemVer) { diff --git a/node_modules/semver/functions/patch.js b/node_modules/semver/functions/patch.js index 63afca2524fc..7675162f1742 100644 --- a/node_modules/semver/functions/patch.js +++ b/node_modules/semver/functions/patch.js @@ -1,3 +1,5 @@ +'use strict' + const SemVer = require('../classes/semver') const patch = (a, loose) => new SemVer(a, loose).patch module.exports = patch diff --git a/node_modules/semver/functions/prerelease.js b/node_modules/semver/functions/prerelease.js index 06aa13248ae6..b8fe1db5049a 100644 --- a/node_modules/semver/functions/prerelease.js +++ b/node_modules/semver/functions/prerelease.js @@ -1,3 +1,5 @@ +'use strict' + const parse = require('./parse') const prerelease = (version, options) => { const parsed = parse(version, options) diff --git a/node_modules/semver/functions/rcompare.js b/node_modules/semver/functions/rcompare.js index 0ac509e79dc8..8e1c222b2ffc 100644 --- a/node_modules/semver/functions/rcompare.js +++ b/node_modules/semver/functions/rcompare.js @@ -1,3 +1,5 @@ +'use strict' + const compare = require('./compare') const rcompare = (a, b, loose) => compare(b, a, loose) module.exports = rcompare diff --git a/node_modules/semver/functions/rsort.js b/node_modules/semver/functions/rsort.js index 82404c5cfe02..5d3d20096844 100644 --- a/node_modules/semver/functions/rsort.js +++ b/node_modules/semver/functions/rsort.js @@ -1,3 +1,5 @@ +'use strict' + const compareBuild = require('./compare-build') const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)) module.exports = rsort diff --git a/node_modules/semver/functions/satisfies.js b/node_modules/semver/functions/satisfies.js index 50af1c199b6c..a0264a222ac8 100644 --- a/node_modules/semver/functions/satisfies.js +++ b/node_modules/semver/functions/satisfies.js @@ -1,3 +1,5 @@ +'use strict' + const Range = require('../classes/range') const satisfies = (version, range, options) => { try { diff --git a/node_modules/semver/functions/sort.js b/node_modules/semver/functions/sort.js index 4d10917aba8e..edb24b1dc332 100644 --- a/node_modules/semver/functions/sort.js +++ b/node_modules/semver/functions/sort.js @@ -1,3 +1,5 @@ +'use strict' + const compareBuild = require('./compare-build') const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)) module.exports = sort diff --git a/node_modules/semver/functions/valid.js b/node_modules/semver/functions/valid.js index f27bae10731c..0db67edcb595 100644 --- a/node_modules/semver/functions/valid.js +++ b/node_modules/semver/functions/valid.js @@ -1,3 +1,5 @@ +'use strict' + const parse = require('./parse') const valid = (version, options) => { const v = parse(version, options) diff --git a/node_modules/semver/index.js b/node_modules/semver/index.js index 86d42ac16a84..285662acb328 100644 --- a/node_modules/semver/index.js +++ b/node_modules/semver/index.js @@ -1,3 +1,5 @@ +'use strict' + // just pre-load all the stuff that index.js lazily exports const internalRe = require('./internal/re') const constants = require('./internal/constants') diff --git a/node_modules/semver/internal/constants.js b/node_modules/semver/internal/constants.js index 94be1c570277..6d1db9154331 100644 --- a/node_modules/semver/internal/constants.js +++ b/node_modules/semver/internal/constants.js @@ -1,3 +1,5 @@ +'use strict' + // Note: this is the semver.org version of the spec that it implements // Not necessarily the package version of this code. const SEMVER_SPEC_VERSION = '2.0.0' diff --git a/node_modules/semver/internal/debug.js b/node_modules/semver/internal/debug.js index 1c00e1369aa2..20d1e9dceea9 100644 --- a/node_modules/semver/internal/debug.js +++ b/node_modules/semver/internal/debug.js @@ -1,3 +1,5 @@ +'use strict' + const debug = ( typeof process === 'object' && process.env && diff --git a/node_modules/semver/internal/identifiers.js b/node_modules/semver/internal/identifiers.js index e612d0a3d836..a4613dee7977 100644 --- a/node_modules/semver/internal/identifiers.js +++ b/node_modules/semver/internal/identifiers.js @@ -1,3 +1,5 @@ +'use strict' + const numeric = /^[0-9]+$/ const compareIdentifiers = (a, b) => { const anum = numeric.test(a) diff --git a/node_modules/semver/internal/lrucache.js b/node_modules/semver/internal/lrucache.js index 6d89ec948d0f..b8bf5262a050 100644 --- a/node_modules/semver/internal/lrucache.js +++ b/node_modules/semver/internal/lrucache.js @@ -1,3 +1,5 @@ +'use strict' + class LRUCache { constructor () { this.max = 1000 diff --git a/node_modules/semver/internal/parse-options.js b/node_modules/semver/internal/parse-options.js index 10d64ce06d3c..5295454130d4 100644 --- a/node_modules/semver/internal/parse-options.js +++ b/node_modules/semver/internal/parse-options.js @@ -1,3 +1,5 @@ +'use strict' + // parse out just the options we care about const looseOption = Object.freeze({ loose: true }) const emptyOpts = Object.freeze({ }) diff --git a/node_modules/semver/internal/re.js b/node_modules/semver/internal/re.js index 2a956ba0a318..4758c58d424a 100644 --- a/node_modules/semver/internal/re.js +++ b/node_modules/semver/internal/re.js @@ -1,3 +1,5 @@ +'use strict' + const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, @@ -76,12 +78,14 @@ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + // ## Pre-release Version Identifier // A numeric identifier, or a non-numeric identifier. +// Non-numberic identifiers include numberic identifiers but can be longer. +// Therefore non-numberic identifiers must go first. -createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER] -}|${src[t.NONNUMERICIDENTIFIER]})`) +createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER] +}|${src[t.NUMERICIDENTIFIER]})`) -createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE] -}|${src[t.NONNUMERICIDENTIFIER]})`) +createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER] +}|${src[t.NUMERICIDENTIFIERLOOSE]})`) // ## Pre-release Version // Hyphen, followed by one or more dot-separated pre-release version diff --git a/node_modules/semver/package.json b/node_modules/semver/package.json index c2644547a2a6..1fbef5a9bf9c 100644 --- a/node_modules/semver/package.json +++ b/node_modules/semver/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.7.1", + "version": "7.7.2", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": { @@ -15,7 +15,7 @@ }, "devDependencies": { "@npmcli/eslint-config": "^5.0.0", - "@npmcli/template-oss": "4.23.4", + "@npmcli/template-oss": "4.24.3", "benchmark": "^2.1.4", "tap": "^16.0.0" }, @@ -52,7 +52,7 @@ "author": "GitHub Inc.", "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.23.4", + "version": "4.24.3", "engines": ">=10", "distPaths": [ "classes/", diff --git a/node_modules/semver/preload.js b/node_modules/semver/preload.js index 947cd4f7917f..e6c47b9b051d 100644 --- a/node_modules/semver/preload.js +++ b/node_modules/semver/preload.js @@ -1,2 +1,4 @@ +'use strict' + // XXX remove in v8 or beyond module.exports = require('./index.js') diff --git a/node_modules/semver/ranges/gtr.js b/node_modules/semver/ranges/gtr.js index db7e35599dd5..0e7601f69355 100644 --- a/node_modules/semver/ranges/gtr.js +++ b/node_modules/semver/ranges/gtr.js @@ -1,3 +1,5 @@ +'use strict' + // Determine if version is greater than all the versions possible in the range. const outside = require('./outside') const gtr = (version, range, options) => outside(version, range, '>', options) diff --git a/node_modules/semver/ranges/intersects.js b/node_modules/semver/ranges/intersects.js index e0e9b7ce000e..917be7e4293d 100644 --- a/node_modules/semver/ranges/intersects.js +++ b/node_modules/semver/ranges/intersects.js @@ -1,3 +1,5 @@ +'use strict' + const Range = require('../classes/range') const intersects = (r1, r2, options) => { r1 = new Range(r1, options) diff --git a/node_modules/semver/ranges/ltr.js b/node_modules/semver/ranges/ltr.js index 528a885ebdfc..aa5e568ec279 100644 --- a/node_modules/semver/ranges/ltr.js +++ b/node_modules/semver/ranges/ltr.js @@ -1,3 +1,5 @@ +'use strict' + const outside = require('./outside') // Determine if version is less than all the versions possible in the range const ltr = (version, range, options) => outside(version, range, '<', options) diff --git a/node_modules/semver/ranges/max-satisfying.js b/node_modules/semver/ranges/max-satisfying.js index 6e3d993c6786..01fe5ae38371 100644 --- a/node_modules/semver/ranges/max-satisfying.js +++ b/node_modules/semver/ranges/max-satisfying.js @@ -1,3 +1,5 @@ +'use strict' + const SemVer = require('../classes/semver') const Range = require('../classes/range') diff --git a/node_modules/semver/ranges/min-satisfying.js b/node_modules/semver/ranges/min-satisfying.js index 9b60974e2253..af89c8ef4326 100644 --- a/node_modules/semver/ranges/min-satisfying.js +++ b/node_modules/semver/ranges/min-satisfying.js @@ -1,3 +1,5 @@ +'use strict' + const SemVer = require('../classes/semver') const Range = require('../classes/range') const minSatisfying = (versions, range, options) => { diff --git a/node_modules/semver/ranges/min-version.js b/node_modules/semver/ranges/min-version.js index 350e1f78368e..09a65aa36fd5 100644 --- a/node_modules/semver/ranges/min-version.js +++ b/node_modules/semver/ranges/min-version.js @@ -1,3 +1,5 @@ +'use strict' + const SemVer = require('../classes/semver') const Range = require('../classes/range') const gt = require('../functions/gt') diff --git a/node_modules/semver/ranges/outside.js b/node_modules/semver/ranges/outside.js index ae99b10a5b9e..ca7442120798 100644 --- a/node_modules/semver/ranges/outside.js +++ b/node_modules/semver/ranges/outside.js @@ -1,3 +1,5 @@ +'use strict' + const SemVer = require('../classes/semver') const Comparator = require('../classes/comparator') const { ANY } = Comparator diff --git a/node_modules/semver/ranges/simplify.js b/node_modules/semver/ranges/simplify.js index 618d5b627355..262732e670d7 100644 --- a/node_modules/semver/ranges/simplify.js +++ b/node_modules/semver/ranges/simplify.js @@ -1,3 +1,5 @@ +'use strict' + // given a set of versions and a range, create a "simplified" range // that includes the same versions that the original range does // If the original range is shorter than the simplified one, return that. diff --git a/node_modules/semver/ranges/subset.js b/node_modules/semver/ranges/subset.js index 1e5c26837c04..2c49aef1be5e 100644 --- a/node_modules/semver/ranges/subset.js +++ b/node_modules/semver/ranges/subset.js @@ -1,3 +1,5 @@ +'use strict' + const Range = require('../classes/range.js') const Comparator = require('../classes/comparator.js') const { ANY } = Comparator diff --git a/node_modules/semver/ranges/to-comparators.js b/node_modules/semver/ranges/to-comparators.js index 6c8bc7e6f15a..5be251961acb 100644 --- a/node_modules/semver/ranges/to-comparators.js +++ b/node_modules/semver/ranges/to-comparators.js @@ -1,3 +1,5 @@ +'use strict' + const Range = require('../classes/range') // Mostly just for testing and legacy API reasons diff --git a/node_modules/semver/ranges/valid.js b/node_modules/semver/ranges/valid.js index 365f35689d35..cc6b0e9f68f9 100644 --- a/node_modules/semver/ranges/valid.js +++ b/node_modules/semver/ranges/valid.js @@ -1,3 +1,5 @@ +'use strict' + const Range = require('../classes/range') const validRange = (range, options) => { try { diff --git a/node_modules/stylelint/node_modules/file-entry-cache/README.md b/node_modules/stylelint/node_modules/file-entry-cache/README.md index 67635126d0ec..335dea8fa1fb 100644 --- a/node_modules/stylelint/node_modules/file-entry-cache/README.md +++ b/node_modules/stylelint/node_modules/file-entry-cache/README.md @@ -92,6 +92,7 @@ There have been many features added and changes made to the `file-entry-cache` c # FileEntryCache Options (FileEntryCacheOptions) - `currentWorkingDirectory?` - The current working directory. Used when resolving relative paths. +- `useModifiedTime?` - If `true` it will use the modified time to determine if the file has changed. Default is `true` - `useCheckSum?` - If `true` it will use a checksum to determine if the file has changed. Default is `false` - `hashAlgorithm?` - The algorithm to use for the checksum. Default is `md5` but can be any algorithm supported by `crypto.createHash` - `cache.ttl?` - The time to live for the cache in milliseconds. Default is `0` which means no expiration @@ -117,7 +118,7 @@ There have been many features added and changes made to the `file-entry-cache` c - `removeEntry(filePath: string): void` - Removes an entry from the cache. This can be `relative` or `absolute` paths. - `reconcile(): void` - Saves the cache to disk and removes any files that are no longer found. - `hasFileChanged(filePath: string): boolean` - Checks if the file has changed. This will return `true` if the file has changed. -- `getFileDescriptor(filePath: string, options?: { useCheckSum?: boolean, currentWorkingDirectory?: string }): FileEntryDescriptor` - Gets the file descriptor for the file. Please refer to the entire section on `Get File Descriptor` for more information. +- `getFileDescriptor(filePath: string, options?: { useModifiedTime?: boolean, useCheckSum?: boolean, currentWorkingDirectory?: string }): FileEntryDescriptor` - Gets the file descriptor for the file. Please refer to the entire section on `Get File Descriptor` for more information. - `normalizeEntries(entries: FileEntryDescriptor[]): FileEntryDescriptor[]` - Normalizes the entries to have the correct paths. This is used when loading the cache from disk. - `analyzeFiles(files: string[])` will return `AnalyzedFiles` object with `changedFiles`, `notFoundFiles`, and `notChangedFiles` as FileDescriptor arrays. - `getUpdatedFiles(files: string[])` will return an array of `FileEntryDescriptor` objects that have changed. diff --git a/node_modules/stylelint/node_modules/file-entry-cache/dist/index.cjs b/node_modules/stylelint/node_modules/file-entry-cache/dist/index.cjs index 00928a819842..b1ef834449f7 100644 --- a/node_modules/stylelint/node_modules/file-entry-cache/dist/index.cjs +++ b/node_modules/stylelint/node_modules/file-entry-cache/dist/index.cjs @@ -70,12 +70,20 @@ var FileEntryDefault = class { var FileEntryCache = class { _cache = new import_flat_cache.FlatCache({ useClone: false }); _useCheckSum = false; + _useModifiedTime = true; _currentWorkingDirectory; _hashAlgorithm = "md5"; + /** + * Create a new FileEntryCache instance + * @param options - The options for the FileEntryCache + */ constructor(options) { if (options?.cache) { this._cache = new import_flat_cache.FlatCache(options.cache); } + if (options?.useModifiedTime) { + this._useModifiedTime = options.useModifiedTime; + } if (options?.useCheckSum) { this._useCheckSum = options.useCheckSum; } @@ -86,27 +94,73 @@ var FileEntryCache = class { this._hashAlgorithm = options.hashAlgorithm; } } + /** + * Get the cache + * @returns {FlatCache} The cache + */ get cache() { return this._cache; } + /** + * Set the cache + * @param {FlatCache} cache - The cache to set + */ set cache(cache) { this._cache = cache; } + /** + * Use the hash to check if the file has changed + * @returns {boolean} if the hash is used to check if the file has changed + */ get useCheckSum() { return this._useCheckSum; } + /** + * Set the useCheckSum value + * @param {boolean} value - The value to set + */ set useCheckSum(value) { this._useCheckSum = value; } + /** + * Use the modified time to check if the file has changed + * @returns {boolean} if the modified time is used to check if the file has changed + */ + get useModifiedTime() { + return this._useModifiedTime; + } + /** + * Set the useModifiedTime value + * @param {boolean} value - The value to set + */ + set useModifiedTime(value) { + this._useModifiedTime = value; + } + /** + * Get the hash algorithm + * @returns {string} The hash algorithm + */ get hashAlgorithm() { return this._hashAlgorithm; } + /** + * Set the hash algorithm + * @param {string} value - The value to set + */ set hashAlgorithm(value) { this._hashAlgorithm = value; } + /** + * Get the current working directory + * @returns {string | undefined} The current working directory + */ get currentWorkingDirectory() { return this._currentWorkingDirectory; } + /** + * Set the current working directory + * @param {string | undefined} value - The value to set + */ set currentWorkingDirectory(value) { this._currentWorkingDirectory = value; } @@ -116,7 +170,7 @@ var FileEntryCache = class { * @param {Buffer} buffer buffer to calculate hash on * @return {String} content hash digest */ - // eslint-disable-next-line @typescript-eslint/ban-types + // eslint-disable-next-line @typescript-eslint/no-restricted-types getHash(buffer) { return import_node_crypto.default.createHash(this._hashAlgorithm).update(buffer).digest("hex"); } @@ -182,7 +236,7 @@ var FileEntryCache = class { * @method reconcile */ reconcile() { - const items = this._cache.items; + const { items } = this._cache; for (const item of items) { const fileDescriptor = this.getFileDescriptor(item.key); if (fileDescriptor.notFound) { @@ -212,6 +266,7 @@ var FileEntryCache = class { * @param options - The options for getting the file descriptor * @returns The file descriptor */ + // eslint-disable-next-line complexity getFileDescriptor(filePath, options) { let fstat; const result = { @@ -222,6 +277,7 @@ var FileEntryCache = class { result.meta = this._cache.getKey(result.key) ?? {}; filePath = this.getAbsolutePath(filePath, { currentWorkingDirectory: options?.currentWorkingDirectory }); const useCheckSumValue = options?.useCheckSum ?? this._useCheckSum; + const useModifiedTimeValue = options?.useModifiedTime ?? this._useModifiedTime; try { fstat = import_node_fs.default.statSync(filePath); result.meta = { @@ -254,7 +310,10 @@ var FileEntryCache = class { if (result.meta.data === void 0) { result.meta.data = metaCache.data; } - if (metaCache?.mtime !== result.meta?.mtime || metaCache?.size !== result.meta?.size) { + if (useModifiedTimeValue && metaCache?.mtime !== result.meta?.mtime) { + result.changed = true; + } + if (metaCache?.size !== result.meta?.size) { result.changed = true; } if (useCheckSumValue && metaCache?.hash !== result.meta?.hash) { diff --git a/node_modules/stylelint/node_modules/file-entry-cache/dist/index.d.cts b/node_modules/stylelint/node_modules/file-entry-cache/dist/index.d.cts index 603650ab51a0..4b495cdaaa94 100644 --- a/node_modules/stylelint/node_modules/file-entry-cache/dist/index.d.cts +++ b/node_modules/stylelint/node_modules/file-entry-cache/dist/index.d.cts @@ -1,13 +1,16 @@ +import { Buffer } from 'node:buffer'; import { FlatCacheOptions, FlatCache } from 'flat-cache'; type FileEntryCacheOptions = { currentWorkingDirectory?: string; + useModifiedTime?: boolean; useCheckSum?: boolean; hashAlgorithm?: string; cache?: FlatCacheOptions; }; type GetFileDescriptorOptions = { useCheckSum?: boolean; + useModifiedTime?: boolean; currentWorkingDirectory?: string; }; type FileDescriptor = { @@ -37,16 +40,63 @@ declare class FileEntryDefault { declare class FileEntryCache { private _cache; private _useCheckSum; + private _useModifiedTime; private _currentWorkingDirectory; private _hashAlgorithm; + /** + * Create a new FileEntryCache instance + * @param options - The options for the FileEntryCache + */ constructor(options?: FileEntryCacheOptions); + /** + * Get the cache + * @returns {FlatCache} The cache + */ get cache(): FlatCache; + /** + * Set the cache + * @param {FlatCache} cache - The cache to set + */ set cache(cache: FlatCache); + /** + * Use the hash to check if the file has changed + * @returns {boolean} if the hash is used to check if the file has changed + */ get useCheckSum(): boolean; + /** + * Set the useCheckSum value + * @param {boolean} value - The value to set + */ set useCheckSum(value: boolean); + /** + * Use the modified time to check if the file has changed + * @returns {boolean} if the modified time is used to check if the file has changed + */ + get useModifiedTime(): boolean; + /** + * Set the useModifiedTime value + * @param {boolean} value - The value to set + */ + set useModifiedTime(value: boolean); + /** + * Get the hash algorithm + * @returns {string} The hash algorithm + */ get hashAlgorithm(): string; + /** + * Set the hash algorithm + * @param {string} value - The value to set + */ set hashAlgorithm(value: string); + /** + * Get the current working directory + * @returns {string | undefined} The current working directory + */ get currentWorkingDirectory(): string | undefined; + /** + * Set the current working directory + * @param {string | undefined} value - The value to set + */ set currentWorkingDirectory(value: string | undefined); /** * Given a buffer, calculate md5 hash of its content. diff --git a/node_modules/stylelint/node_modules/file-entry-cache/dist/index.d.ts b/node_modules/stylelint/node_modules/file-entry-cache/dist/index.d.ts index 603650ab51a0..4b495cdaaa94 100644 --- a/node_modules/stylelint/node_modules/file-entry-cache/dist/index.d.ts +++ b/node_modules/stylelint/node_modules/file-entry-cache/dist/index.d.ts @@ -1,13 +1,16 @@ +import { Buffer } from 'node:buffer'; import { FlatCacheOptions, FlatCache } from 'flat-cache'; type FileEntryCacheOptions = { currentWorkingDirectory?: string; + useModifiedTime?: boolean; useCheckSum?: boolean; hashAlgorithm?: string; cache?: FlatCacheOptions; }; type GetFileDescriptorOptions = { useCheckSum?: boolean; + useModifiedTime?: boolean; currentWorkingDirectory?: string; }; type FileDescriptor = { @@ -37,16 +40,63 @@ declare class FileEntryDefault { declare class FileEntryCache { private _cache; private _useCheckSum; + private _useModifiedTime; private _currentWorkingDirectory; private _hashAlgorithm; + /** + * Create a new FileEntryCache instance + * @param options - The options for the FileEntryCache + */ constructor(options?: FileEntryCacheOptions); + /** + * Get the cache + * @returns {FlatCache} The cache + */ get cache(): FlatCache; + /** + * Set the cache + * @param {FlatCache} cache - The cache to set + */ set cache(cache: FlatCache); + /** + * Use the hash to check if the file has changed + * @returns {boolean} if the hash is used to check if the file has changed + */ get useCheckSum(): boolean; + /** + * Set the useCheckSum value + * @param {boolean} value - The value to set + */ set useCheckSum(value: boolean); + /** + * Use the modified time to check if the file has changed + * @returns {boolean} if the modified time is used to check if the file has changed + */ + get useModifiedTime(): boolean; + /** + * Set the useModifiedTime value + * @param {boolean} value - The value to set + */ + set useModifiedTime(value: boolean); + /** + * Get the hash algorithm + * @returns {string} The hash algorithm + */ get hashAlgorithm(): string; + /** + * Set the hash algorithm + * @param {string} value - The value to set + */ set hashAlgorithm(value: string); + /** + * Get the current working directory + * @returns {string | undefined} The current working directory + */ get currentWorkingDirectory(): string | undefined; + /** + * Set the current working directory + * @param {string | undefined} value - The value to set + */ set currentWorkingDirectory(value: string | undefined); /** * Given a buffer, calculate md5 hash of its content. diff --git a/node_modules/stylelint/node_modules/file-entry-cache/dist/index.js b/node_modules/stylelint/node_modules/file-entry-cache/dist/index.js index 5b059604150a..402154f1493c 100644 --- a/node_modules/stylelint/node_modules/file-entry-cache/dist/index.js +++ b/node_modules/stylelint/node_modules/file-entry-cache/dist/index.js @@ -1,7 +1,7 @@ // src/index.ts -import crypto from "node:crypto"; -import fs from "node:fs"; -import path from "node:path"; +import crypto from "crypto"; +import fs from "fs"; +import path from "path"; import { FlatCache, createFromFile as createFlatCacheFile } from "flat-cache"; function createFromFile(filePath, useCheckSum, currentWorkingDirectory) { const fname = path.basename(filePath); @@ -33,12 +33,20 @@ var FileEntryDefault = class { var FileEntryCache = class { _cache = new FlatCache({ useClone: false }); _useCheckSum = false; + _useModifiedTime = true; _currentWorkingDirectory; _hashAlgorithm = "md5"; + /** + * Create a new FileEntryCache instance + * @param options - The options for the FileEntryCache + */ constructor(options) { if (options?.cache) { this._cache = new FlatCache(options.cache); } + if (options?.useModifiedTime) { + this._useModifiedTime = options.useModifiedTime; + } if (options?.useCheckSum) { this._useCheckSum = options.useCheckSum; } @@ -49,27 +57,73 @@ var FileEntryCache = class { this._hashAlgorithm = options.hashAlgorithm; } } + /** + * Get the cache + * @returns {FlatCache} The cache + */ get cache() { return this._cache; } + /** + * Set the cache + * @param {FlatCache} cache - The cache to set + */ set cache(cache) { this._cache = cache; } + /** + * Use the hash to check if the file has changed + * @returns {boolean} if the hash is used to check if the file has changed + */ get useCheckSum() { return this._useCheckSum; } + /** + * Set the useCheckSum value + * @param {boolean} value - The value to set + */ set useCheckSum(value) { this._useCheckSum = value; } + /** + * Use the modified time to check if the file has changed + * @returns {boolean} if the modified time is used to check if the file has changed + */ + get useModifiedTime() { + return this._useModifiedTime; + } + /** + * Set the useModifiedTime value + * @param {boolean} value - The value to set + */ + set useModifiedTime(value) { + this._useModifiedTime = value; + } + /** + * Get the hash algorithm + * @returns {string} The hash algorithm + */ get hashAlgorithm() { return this._hashAlgorithm; } + /** + * Set the hash algorithm + * @param {string} value - The value to set + */ set hashAlgorithm(value) { this._hashAlgorithm = value; } + /** + * Get the current working directory + * @returns {string | undefined} The current working directory + */ get currentWorkingDirectory() { return this._currentWorkingDirectory; } + /** + * Set the current working directory + * @param {string | undefined} value - The value to set + */ set currentWorkingDirectory(value) { this._currentWorkingDirectory = value; } @@ -79,7 +133,7 @@ var FileEntryCache = class { * @param {Buffer} buffer buffer to calculate hash on * @return {String} content hash digest */ - // eslint-disable-next-line @typescript-eslint/ban-types + // eslint-disable-next-line @typescript-eslint/no-restricted-types getHash(buffer) { return crypto.createHash(this._hashAlgorithm).update(buffer).digest("hex"); } @@ -145,7 +199,7 @@ var FileEntryCache = class { * @method reconcile */ reconcile() { - const items = this._cache.items; + const { items } = this._cache; for (const item of items) { const fileDescriptor = this.getFileDescriptor(item.key); if (fileDescriptor.notFound) { @@ -175,6 +229,7 @@ var FileEntryCache = class { * @param options - The options for getting the file descriptor * @returns The file descriptor */ + // eslint-disable-next-line complexity getFileDescriptor(filePath, options) { let fstat; const result = { @@ -185,6 +240,7 @@ var FileEntryCache = class { result.meta = this._cache.getKey(result.key) ?? {}; filePath = this.getAbsolutePath(filePath, { currentWorkingDirectory: options?.currentWorkingDirectory }); const useCheckSumValue = options?.useCheckSum ?? this._useCheckSum; + const useModifiedTimeValue = options?.useModifiedTime ?? this._useModifiedTime; try { fstat = fs.statSync(filePath); result.meta = { @@ -217,7 +273,10 @@ var FileEntryCache = class { if (result.meta.data === void 0) { result.meta.data = metaCache.data; } - if (metaCache?.mtime !== result.meta?.mtime || metaCache?.size !== result.meta?.size) { + if (useModifiedTimeValue && metaCache?.mtime !== result.meta?.mtime) { + result.changed = true; + } + if (metaCache?.size !== result.meta?.size) { result.changed = true; } if (useCheckSumValue && metaCache?.hash !== result.meta?.hash) { diff --git a/node_modules/stylelint/node_modules/file-entry-cache/package.json b/node_modules/stylelint/node_modules/file-entry-cache/package.json index f118842e2f24..fd1fb7075df8 100644 --- a/node_modules/stylelint/node_modules/file-entry-cache/package.json +++ b/node_modules/stylelint/node_modules/file-entry-cache/package.json @@ -1,6 +1,6 @@ { "name": "file-entry-cache", - "version": "10.0.7", + "version": "10.1.1", "description": "A lightweight cache for file metadata, ideal for processes that work on a specific set of files and only need to reprocess files that have changed since the last run", "type": "module", "main": "./dist/index.cjs", @@ -29,16 +29,16 @@ "cache" ], "devDependencies": { - "@types/node": "^22.13.9", - "@vitest/coverage-v8": "^3.0.7", + "@types/node": "^22.15.30", + "@vitest/coverage-v8": "^3.2.2", "rimraf": "^6.0.1", - "tsup": "^8.4.0", - "typescript": "^5.8.2", - "vitest": "^3.0.7", - "xo": "^0.60.0" + "tsup": "^8.5.0", + "typescript": "^5.8.3", + "vitest": "^3.2.2", + "xo": "^1.1.0" }, "dependencies": { - "flat-cache": "^6.1.7" + "flat-cache": "^6.1.10" }, "files": [ "dist", diff --git a/node_modules/stylelint/node_modules/flat-cache/dist/index.cjs b/node_modules/stylelint/node_modules/flat-cache/dist/index.cjs index 3e6c56845366..169731405cac 100644 --- a/node_modules/stylelint/node_modules/flat-cache/dist/index.cjs +++ b/node_modules/stylelint/node_modules/flat-cache/dist/index.cjs @@ -170,7 +170,6 @@ var FlatCache = class extends import_hookified.Hookified { * @param cacheId {String} the id of the cache, would also be used as the name of the file cache * @param cacheDir {String} directory for the cache entry */ - // eslint-disable-next-line unicorn/prevent-abbreviations load(cacheId, cacheDir) { try { const filePath = import_node_path.default.resolve(`${cacheDir ?? this._cacheDir}/${cacheId ?? this._cacheId}`); @@ -202,7 +201,7 @@ var FlatCache = class extends import_hookified.Hookified { */ all() { const result = {}; - const items = Array.from(this._cache.items); + const items = [...this._cache.items]; for (const item of items) { result[item.key] = item.value; } @@ -214,7 +213,7 @@ var FlatCache = class extends import_hookified.Hookified { * @returns {Array} */ get items() { - return Array.from(this._cache.items); + return [...this._cache.items]; } /** * Returns the path to the file where the cache is persisted @@ -238,7 +237,7 @@ var FlatCache = class extends import_hookified.Hookified { * @returns {Array} */ keys() { - return Array.from(this._cache.keys); + return [...this._cache.keys]; } /** * (Legacy) set key method. This method will be deprecated in the future @@ -319,7 +318,7 @@ var FlatCache = class extends import_hookified.Hookified { try { if (this._changesSinceLastSave || force) { const filePath = this.cacheFilePath; - const items = Array.from(this._cache.items); + const items = [...this._cache.items]; const data = this._stringify(items); if (!import_node_fs.default.existsSync(this._cacheDir)) { import_node_fs.default.mkdirSync(this._cacheDir, { recursive: true }); diff --git a/node_modules/stylelint/node_modules/flat-cache/dist/index.js b/node_modules/stylelint/node_modules/flat-cache/dist/index.js index 88a717f68736..97804ca0c09e 100644 --- a/node_modules/stylelint/node_modules/flat-cache/dist/index.js +++ b/node_modules/stylelint/node_modules/flat-cache/dist/index.js @@ -1,6 +1,6 @@ // src/index.ts -import path from "node:path"; -import fs from "node:fs"; +import path from "path"; +import fs from "fs"; import { CacheableMemory } from "cacheable"; import { parse, stringify } from "flatted"; import { Hookified } from "hookified"; @@ -130,7 +130,6 @@ var FlatCache = class extends Hookified { * @param cacheId {String} the id of the cache, would also be used as the name of the file cache * @param cacheDir {String} directory for the cache entry */ - // eslint-disable-next-line unicorn/prevent-abbreviations load(cacheId, cacheDir) { try { const filePath = path.resolve(`${cacheDir ?? this._cacheDir}/${cacheId ?? this._cacheId}`); @@ -162,7 +161,7 @@ var FlatCache = class extends Hookified { */ all() { const result = {}; - const items = Array.from(this._cache.items); + const items = [...this._cache.items]; for (const item of items) { result[item.key] = item.value; } @@ -174,7 +173,7 @@ var FlatCache = class extends Hookified { * @returns {Array} */ get items() { - return Array.from(this._cache.items); + return [...this._cache.items]; } /** * Returns the path to the file where the cache is persisted @@ -198,7 +197,7 @@ var FlatCache = class extends Hookified { * @returns {Array} */ keys() { - return Array.from(this._cache.keys); + return [...this._cache.keys]; } /** * (Legacy) set key method. This method will be deprecated in the future @@ -279,7 +278,7 @@ var FlatCache = class extends Hookified { try { if (this._changesSinceLastSave || force) { const filePath = this.cacheFilePath; - const items = Array.from(this._cache.items); + const items = [...this._cache.items]; const data = this._stringify(items); if (!fs.existsSync(this._cacheDir)) { fs.mkdirSync(this._cacheDir, { recursive: true }); diff --git a/node_modules/stylelint/node_modules/flat-cache/package.json b/node_modules/stylelint/node_modules/flat-cache/package.json index ff16779c92d8..7957f17186e6 100644 --- a/node_modules/stylelint/node_modules/flat-cache/package.json +++ b/node_modules/stylelint/node_modules/flat-cache/package.json @@ -1,6 +1,6 @@ { "name": "flat-cache", - "version": "6.1.7", + "version": "6.1.10", "description": "A simple key/value storage using files to persist the data", "type": "module", "main": "./dist/index.cjs", @@ -52,18 +52,18 @@ "file-system-cache" ], "devDependencies": { - "@types/node": "^22.13.9", - "@vitest/coverage-v8": "^3.0.7", + "@types/node": "^22.15.30", + "@vitest/coverage-v8": "^3.2.2", "rimraf": "^6.0.1", - "tsup": "^8.4.0", - "typescript": "^5.8.2", - "vitest": "^3.0.7", - "xo": "^0.60.0" + "tsup": "^8.5.0", + "typescript": "^5.8.3", + "vitest": "^3.2.2", + "xo": "^1.1.0" }, "dependencies": { "flatted": "^3.3.3", - "hookified": "^1.7.1", - "cacheable": "^1.8.9" + "hookified": "^1.9.1", + "cacheable": "^1.10.0" }, "files": [ "dist", diff --git a/node_modules/stylelint/node_modules/ignore/README.md b/node_modules/stylelint/node_modules/ignore/README.md index 4e9947111300..073660e66a2b 100644 --- a/node_modules/stylelint/node_modules/ignore/README.md +++ b/node_modules/stylelint/node_modules/ignore/README.md @@ -352,7 +352,7 @@ instead. ### `options.ignorecase` since 4.0.0 -Similar as the `core.ignorecase` option of [git-config](https://git-scm.com/docs/git-config), `node-ignore` will be case insensitive if `options.ignorecase` is set to `true` (the default value), otherwise case sensitive. +Similar to the `core.ignorecase` option of [git-config](https://git-scm.com/docs/git-config), `node-ignore` will be case insensitive if `options.ignorecase` is set to `true` (the default value), otherwise case sensitive. ```js const ig = ignore({ @@ -366,7 +366,7 @@ ig.ignores('*.PNG') // false ### `options.ignoreCase?: boolean` since 5.2.0 -Which is alternative to `options.ignoreCase` +Which is an alternative to `options.ignoreCase` ### `options.allowRelativePaths?: boolean` since 5.2.0 diff --git a/node_modules/stylelint/node_modules/ignore/index.js b/node_modules/stylelint/node_modules/ignore/index.js index 99aacbde045f..6dee02f87868 100644 --- a/node_modules/stylelint/node_modules/ignore/index.js +++ b/node_modules/stylelint/node_modules/ignore/index.js @@ -23,7 +23,7 @@ const REGEX_SPLITALL_CRLF = /\r?\n/g // - .. // Valid: // - .foo -const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/ +const REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/ const REGEX_TEST_TRAILING_SLASH = /\/$/ @@ -739,18 +739,8 @@ const factory = options => new Ignore(options) const isPathValid = path => checkPath(path && checkPath.convert(path), path, RETURN_FALSE) - -// Windows -// -------------------------------------------------------------- /* istanbul ignore next */ -if ( - // Detect `process` so that it can run in browsers. - typeof process !== 'undefined' - && ( - process.env && process.env.IGNORE_TEST_WIN32 - || process.platform === 'win32' - ) -) { +const setupWindows = () => { /* eslint no-control-regex: "off" */ const makePosix = str => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) @@ -767,6 +757,18 @@ if ( || isNotRelative(path) } + +// Windows +// -------------------------------------------------------------- +/* istanbul ignore next */ +if ( + // Detect `process` so that it can run in browsers. + typeof process !== 'undefined' + && process.platform === 'win32' +) { + setupWindows() +} + // COMMONJS_EXPORTS //////////////////////////////////////////////////////////// module.exports = factory @@ -777,3 +779,6 @@ module.exports = factory factory.default = factory module.exports.isPathValid = isPathValid + +// For testing purposes +define(module.exports, Symbol.for('setupWindows'), setupWindows) diff --git a/node_modules/stylelint/node_modules/ignore/legacy.js b/node_modules/stylelint/node_modules/ignore/legacy.js index fe9d3a242bce..13c03d7cf1fa 100644 --- a/node_modules/stylelint/node_modules/ignore/legacy.js +++ b/node_modules/stylelint/node_modules/ignore/legacy.js @@ -36,7 +36,7 @@ var REGEX_SPLITALL_CRLF = /\r?\n/g; // - .. // Valid: // - .foo -var REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/; +var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/; var REGEX_TEST_TRAILING_SLASH = /\/$/; var SLASH = '/'; @@ -642,12 +642,8 @@ var isPathValid = function isPathValid(path) { return checkPath(path && checkPath.convert(path), path, RETURN_FALSE); }; -// Windows -// -------------------------------------------------------------- /* istanbul ignore next */ -if ( -// Detect `process` so that it can run in browsers. -typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) { +var setupWindows = function setupWindows() { /* eslint no-control-regex: "off" */ var makePosix = function makePosix(str) { return /^\\\\\?\\/.test(str) || /[\0-\x1F"<>\|]+/.test(str) ? str : str.replace(/\\/g, '/'); @@ -660,6 +656,15 @@ typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 checkPath.isNotRelative = function (path) { return REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path); }; +}; + +// Windows +// -------------------------------------------------------------- +/* istanbul ignore next */ +if ( +// Detect `process` so that it can run in browsers. +typeof process !== 'undefined' && process.platform === 'win32') { + setupWindows(); } // COMMONJS_EXPORTS //////////////////////////////////////////////////////////// @@ -671,3 +676,6 @@ module.exports = factory; // Ref: https://github.com/search?q=ignore.default%28%29&type=code factory["default"] = factory; module.exports.isPathValid = isPathValid; + +// For testing purposes +define(module.exports, Symbol["for"]('setupWindows'), setupWindows); diff --git a/node_modules/stylelint/node_modules/ignore/package.json b/node_modules/stylelint/node_modules/ignore/package.json index 20f99d05de78..d486ab59dca4 100644 --- a/node_modules/stylelint/node_modules/ignore/package.json +++ b/node_modules/stylelint/node_modules/ignore/package.json @@ -1,6 +1,6 @@ { "name": "ignore", - "version": "7.0.3", + "version": "7.0.5", "description": "Ignore is a manager and filter for .gitignore rules, the one used by eslint, gitbook and many others.", "types": "index.d.ts", "files": [ @@ -63,7 +63,6 @@ "@babel/core": "^7.22.9", "@babel/preset-env": "^7.22.9", "@typescript-eslint/eslint-plugin": "^8.19.1", - "codecov": "^3.8.3", "debug": "^4.3.4", "eslint": "^8.46.0", "eslint-config-ostai": "^3.0.0", diff --git a/node_modules/stylelint/node_modules/postcss/README.md b/node_modules/stylelint/node_modules/postcss/README.md index 939a80215a7b..05fed079ca0a 100644 --- a/node_modules/stylelint/node_modules/postcss/README.md +++ b/node_modules/stylelint/node_modules/postcss/README.md @@ -9,11 +9,12 @@ These plugins can lint your CSS, supportĀ variablesĀ andĀ mixins, transpileĀ futureĀ CSSĀ syntax, inlineĀ images, andĀ more. PostCSS is used by industry leaders including Wikipedia, Twitter, Alibaba, -and JetBrains. TheĀ [Autoprefixer] and [Stylelint]Ā PostCSS pluginsĀ isĀ oneĀ ofĀ theĀ most popular CSS tools. +and JetBrains. TheĀ [Autoprefixer] and [Stylelint]Ā PostCSS pluginsĀ are someĀ ofĀ theĀ most popular CSS tools. --- -Ā Ā Made at Evil Martians, product consulting for developer tools. +Ā Ā Built by + Evil Martians, go-to agency for developer tools. --- diff --git a/node_modules/stylelint/node_modules/postcss/lib/container.d.ts b/node_modules/stylelint/node_modules/postcss/lib/container.d.ts index 9569f343bee0..c2b310b6b7bc 100644 --- a/node_modules/stylelint/node_modules/postcss/lib/container.d.ts +++ b/node_modules/stylelint/node_modules/postcss/lib/container.d.ts @@ -2,14 +2,17 @@ import AtRule from './at-rule.js' import Comment from './comment.js' import Declaration from './declaration.js' import Node, { ChildNode, ChildProps, NodeProps } from './node.js' +import { Root } from './postcss.js' import Rule from './rule.js' declare namespace Container { - export class ContainerWithChildren< - Child extends Node = ChildNode - > extends Container_ { + export type ContainerWithChildren = { nodes: Child[] - } + } & ( + | AtRule + | Root + | Rule + ) export interface ValueOptions { /** diff --git a/node_modules/stylelint/node_modules/postcss/lib/input.d.ts b/node_modules/stylelint/node_modules/postcss/lib/input.d.ts index 260040f35cff..3207da3e177f 100644 --- a/node_modules/stylelint/node_modules/postcss/lib/input.d.ts +++ b/node_modules/stylelint/node_modules/postcss/lib/input.d.ts @@ -18,6 +18,11 @@ declare namespace Input { */ endLine?: number + /** + * Offset of exclusive end position in source file. + */ + endOffset?: number + /** * Absolute path to the source file. */ @@ -28,6 +33,11 @@ declare namespace Input { */ line: number + /** + * Offset of inclusive start position in source file. + */ + offset: number + /** * Source code. */ @@ -131,6 +141,9 @@ declare class Input_ { */ constructor(css: string, opts?: ProcessOptions) + /** + * Returns `CssSyntaxError` with information about the error and its position. + */ error( message: string, start: @@ -151,9 +164,6 @@ declare class Input_ { }, opts?: { plugin?: CssSyntaxError['plugin'] } ): CssSyntaxError - /** - * Returns `CssSyntaxError` with information about the error and its position. - */ error( message: string, line: number, @@ -165,12 +175,23 @@ declare class Input_ { offset: number, opts?: { plugin?: CssSyntaxError['plugin'] } ): CssSyntaxError + + /** + * Converts source line and column to offset. + * + * @param line Source line. + * @param column Source column. + * @return Source offset. + */ + fromLineAndColumn(line: number, column: number): number + /** * Converts source offset to line and column. * * @param offset Source offset. */ fromOffset(offset: number): { col: number; line: number } | null + /** * Reads the input source map and returns a symbol position * in the input source (e.g., in a Sass file that was compiled diff --git a/node_modules/stylelint/node_modules/postcss/lib/input.js b/node_modules/stylelint/node_modules/postcss/lib/input.js index 9773e0fa33ec..bb0ccf53a788 100644 --- a/node_modules/stylelint/node_modules/postcss/lib/input.js +++ b/node_modules/stylelint/node_modules/postcss/lib/input.js @@ -9,11 +9,26 @@ let CssSyntaxError = require('./css-syntax-error') let PreviousMap = require('./previous-map') let terminalHighlight = require('./terminal-highlight') -let fromOffsetCache = Symbol('fromOffsetCache') +let lineToIndexCache = Symbol('lineToIndexCache') let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator) let pathAvailable = Boolean(resolve && isAbsolute) +function getLineToIndex(input) { + if (input[lineToIndexCache]) return input[lineToIndexCache] + let lines = input.css.split('\n') + let lineToIndex = new Array(lines.length) + let prevIndex = 0 + + for (let i = 0, l = lines.length; i < l; i++) { + lineToIndex[i] = prevIndex + prevIndex += lines[i].length + 1 + } + + input[lineToIndexCache] = lineToIndex + return lineToIndex +} + class Input { get from() { return this.file || this.id @@ -68,31 +83,38 @@ class Input { } error(message, line, column, opts = {}) { - let endColumn, endLine, result + let endColumn, endLine, endOffset, offset, result if (line && typeof line === 'object') { let start = line let end = column if (typeof start.offset === 'number') { - let pos = this.fromOffset(start.offset) + offset = start.offset + let pos = this.fromOffset(offset) line = pos.line column = pos.col } else { line = start.line column = start.column + offset = this.fromLineAndColumn(line, column) } if (typeof end.offset === 'number') { - let pos = this.fromOffset(end.offset) + endOffset = end.offset + let pos = this.fromOffset(endOffset) endLine = pos.line endColumn = pos.col } else { endLine = end.line endColumn = end.column + endOffset = this.fromLineAndColumn(end.line, end.column) } } else if (!column) { - let pos = this.fromOffset(line) + offset = line + let pos = this.fromOffset(offset) line = pos.line column = pos.col + } else { + offset = this.fromLineAndColumn(line, column) } let origin = this.origin(line, column, endLine, endColumn) @@ -120,7 +142,7 @@ class Input { ) } - result.input = { column, endColumn, endLine, line, source: this.css } + result.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css } if (this.file) { if (pathToFileURL) { result.input.url = pathToFileURL(this.file).toString() @@ -131,23 +153,15 @@ class Input { return result } - fromOffset(offset) { - let lastLine, lineToIndex - if (!this[fromOffsetCache]) { - let lines = this.css.split('\n') - lineToIndex = new Array(lines.length) - let prevIndex = 0 - - for (let i = 0, l = lines.length; i < l; i++) { - lineToIndex[i] = prevIndex - prevIndex += lines[i].length + 1 - } + fromLineAndColumn(line, column) { + let lineToIndex = getLineToIndex(this) + let index = lineToIndex[line - 1] + return index + column - 1 + } - this[fromOffsetCache] = lineToIndex - } else { - lineToIndex = this[fromOffsetCache] - } - lastLine = lineToIndex[lineToIndex.length - 1] + fromOffset(offset) { + let lineToIndex = getLineToIndex(this) + let lastLine = lineToIndex[lineToIndex.length - 1] let min = 0 if (offset >= lastLine) { diff --git a/node_modules/stylelint/node_modules/postcss/lib/node.d.ts b/node_modules/stylelint/node_modules/postcss/lib/node.d.ts index aa7229f833c1..a09fe4dda29e 100644 --- a/node_modules/stylelint/node_modules/postcss/lib/node.d.ts +++ b/node_modules/stylelint/node_modules/postcss/lib/node.d.ts @@ -1,5 +1,4 @@ import AtRule = require('./at-rule.js') - import { AtRuleProps } from './at-rule.js' import Comment, { CommentProps } from './comment.js' import Container, { NewChild } from './container.js' @@ -66,6 +65,22 @@ declare namespace Node { /** * The inclusive ending position for the source * code of a node. + * + * However, `end.offset` of a non `Root` node is the exclusive position. + * See https://github.com/postcss/postcss/pull/1879 for details. + * + * ```js + * const root = postcss.parse('a { color: black }') + * const a = root.first + * const color = a.first + * + * // The offset of `Root` node is the inclusive position + * css.source.end // { line: 1, column: 19, offset: 18 } + * + * // The offset of non `Root` node is the exclusive position + * a.source.end // { line: 1, column: 18, offset: 18 } + * color.source.end // { line: 1, column: 16, offset: 16 } + * ``` */ end?: Position @@ -424,7 +439,7 @@ declare abstract class Node_ { * @return Range. */ rangeBy( - opts?: Pick + opts?: Pick ): Node.Range /** diff --git a/node_modules/stylelint/node_modules/postcss/lib/node.js b/node_modules/stylelint/node_modules/postcss/lib/node.js index 2b865ba37327..b403b7136bc2 100644 --- a/node_modules/stylelint/node_modules/postcss/lib/node.js +++ b/node_modules/stylelint/node_modules/postcss/lib/node.js @@ -34,11 +34,8 @@ function cloneNode(obj, parent) { function sourceOffset(inputCSS, position) { // Not all custom syntaxes support `offset` in `source.start` and `source.end` - if ( - position && - typeof position.offset !== 'undefined' - ) { - return position.offset; + if (position && typeof position.offset !== 'undefined') { + return position.offset } let column = 1 @@ -208,14 +205,15 @@ class Node { return this.parent.nodes[index + 1] } - positionBy(opts) { + positionBy(opts = {}) { let pos = this.source.start if (opts.index) { pos = this.positionInside(opts.index) } else if (opts.word) { - let inputString = ('document' in this.source.input) - ? this.source.input.document - : this.source.input.css + let inputString = + 'document' in this.source.input + ? this.source.input.document + : this.source.input.css let stringRepresentation = inputString.slice( sourceOffset(inputString, this.source.start), sourceOffset(inputString, this.source.end) @@ -229,9 +227,10 @@ class Node { positionInside(index) { let column = this.source.start.column let line = this.source.start.line - let inputString = ('document' in this.source.input) - ? this.source.input.document - : this.source.input.css + let inputString = + 'document' in this.source.input + ? this.source.input.document + : this.source.input.css let offset = sourceOffset(inputString, this.source.start) let end = offset + index @@ -244,7 +243,7 @@ class Node { } } - return { column, line } + return { column, line, offset: end } } prev() { @@ -253,25 +252,36 @@ class Node { return this.parent.nodes[index - 1] } - rangeBy(opts) { + rangeBy(opts = {}) { + let inputString = + 'document' in this.source.input + ? this.source.input.document + : this.source.input.css let start = { column: this.source.start.column, - line: this.source.start.line + line: this.source.start.line, + offset: sourceOffset(inputString, this.source.start) } let end = this.source.end ? { column: this.source.end.column + 1, - line: this.source.end.line + line: this.source.end.line, + offset: + typeof this.source.end.offset === 'number' + ? // `source.end.offset` is exclusive, so we don't need to add 1 + this.source.end.offset + : // Since line/column in this.source.end is inclusive, + // the `sourceOffset(... , this.source.end)` returns an inclusive offset. + // So, we add 1 to convert it to exclusive. + sourceOffset(inputString, this.source.end) + 1 } : { column: start.column + 1, - line: start.line + line: start.line, + offset: start.offset + 1 } if (opts.word) { - let inputString = ('document' in this.source.input) - ? this.source.input.document - : this.source.input.css let stringRepresentation = inputString.slice( sourceOffset(inputString, this.source.start), sourceOffset(inputString, this.source.end) @@ -279,15 +289,14 @@ class Node { let index = stringRepresentation.indexOf(opts.word) if (index !== -1) { start = this.positionInside(index) - end = this.positionInside( - index + opts.word.length, - ) + end = this.positionInside(index + opts.word.length) } } else { if (opts.start) { start = { column: opts.start.column, - line: opts.start.line + line: opts.start.line, + offset: sourceOffset(inputString, opts.start) } } else if (opts.index) { start = this.positionInside(opts.index) @@ -296,7 +305,8 @@ class Node { if (opts.end) { end = { column: opts.end.column, - line: opts.end.line + line: opts.end.line, + offset: sourceOffset(inputString, opts.end) } } else if (typeof opts.endIndex === 'number') { end = this.positionInside(opts.endIndex) @@ -309,7 +319,11 @@ class Node { end.line < start.line || (end.line === start.line && end.column <= start.column) ) { - end = { column: start.column + 1, line: start.line } + end = { + column: start.column + 1, + line: start.line, + offset: start.offset + 1 + } } return { end, start } @@ -384,6 +398,7 @@ class Node { } else if (typeof value === 'object' && value.toJSON) { fixed[name] = value.toJSON(null, inputs) } else if (name === 'source') { + if (value == null) continue let inputId = inputs.get(value.input) if (inputId == null) { inputId = inputsNextIndex @@ -423,7 +438,7 @@ class Node { return result } - warn(result, text, opts) { + warn(result, text, opts = {}) { let data = { node: this } for (let i in opts) data[i] = opts[i] return result.warn(text, data) diff --git a/node_modules/stylelint/node_modules/postcss/lib/processor.js b/node_modules/stylelint/node_modules/postcss/lib/processor.js index c38be5326172..84936874dd21 100644 --- a/node_modules/stylelint/node_modules/postcss/lib/processor.js +++ b/node_modules/stylelint/node_modules/postcss/lib/processor.js @@ -7,7 +7,7 @@ let Root = require('./root') class Processor { constructor(plugins = []) { - this.version = '8.5.3' + this.version = '8.5.6' this.plugins = this.normalize(plugins) } diff --git a/node_modules/stylelint/node_modules/postcss/lib/result.js b/node_modules/stylelint/node_modules/postcss/lib/result.js index 4ab2a8fc220b..c6af4e8cabbf 100644 --- a/node_modules/stylelint/node_modules/postcss/lib/result.js +++ b/node_modules/stylelint/node_modules/postcss/lib/result.js @@ -12,7 +12,7 @@ class Result { this.messages = [] this.root = root this.opts = opts - this.css = undefined + this.css = '' this.map = undefined } diff --git a/node_modules/stylelint/node_modules/postcss/lib/stringifier.d.ts b/node_modules/stylelint/node_modules/postcss/lib/stringifier.d.ts index f707a6aa320a..b5a6f86feb58 100644 --- a/node_modules/stylelint/node_modules/postcss/lib/stringifier.d.ts +++ b/node_modules/stylelint/node_modules/postcss/lib/stringifier.d.ts @@ -25,7 +25,7 @@ declare class Stringifier_ { comment(node: Comment): void decl(node: Declaration, semicolon?: boolean): void document(node: Document): void - raw(node: AnyNode, own: null | string, detect?: string): string + raw(node: AnyNode, own: null | string, detect?: string): boolean | string rawBeforeClose(root: Root): string | undefined rawBeforeComment(root: Root, node: Comment): string | undefined rawBeforeDecl(root: Root, node: Declaration): string | undefined @@ -35,7 +35,7 @@ declare class Stringifier_ { rawEmptyBody(root: Root): string | undefined rawIndent(root: Root): string | undefined rawSemicolon(root: Root): boolean | undefined - rawValue(node: AnyNode, prop: string): string + rawValue(node: AnyNode, prop: string): number | string root(node: Root): void rule(node: Rule): void stringify(node: AnyNode, semicolon?: boolean): void diff --git a/node_modules/stylelint/node_modules/postcss/package.json b/node_modules/stylelint/node_modules/postcss/package.json old mode 100755 new mode 100644 index daf3530ad9c8..c69124b8b76a --- a/node_modules/stylelint/node_modules/postcss/package.json +++ b/node_modules/stylelint/node_modules/postcss/package.json @@ -1,14 +1,14 @@ { "name": "postcss", - "version": "8.5.3", + "version": "8.5.6", "description": "Tool for transforming styles with JS plugins", "engines": { "node": "^10 || ^12 || >=14" }, "exports": { ".": { - "require": "./lib/postcss.js", - "import": "./lib/postcss.mjs" + "import": "./lib/postcss.mjs", + "require": "./lib/postcss.js" }, "./lib/at-rule": "./lib/at-rule.js", "./lib/comment": "./lib/comment.js", @@ -74,7 +74,7 @@ "url": "https://github.com/postcss/postcss/issues" }, "dependencies": { - "nanoid": "^3.3.8", + "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" }, diff --git a/package-lock.json b/package-lock.json index df6227841a30..0a8db2a31f35 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1118,9 +1118,9 @@ } }, "node_modules/@humanwhocodes/retry": { - "version": "0.4.2", - "resolved": "https://npm.skia.org/chrome-devtools/@humanwhocodes%2fretry/-/retry-0.4.2.tgz", - "integrity": "sha512-xeO57FpIu4p1Ri3Jq/EXq4ClRm86dVF2z/+kvFnyqVYRavTZmaFaUBbWCOuuTh0o/g7DSsk6kc2vrS4Vl5oPOQ==", + "version": "0.4.3", + "resolved": "https://npm.skia.org/chrome-devtools/@humanwhocodes%2fretry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", "dev": true, "license": "Apache-2.0", "engines": { @@ -1301,9 +1301,9 @@ } }, "node_modules/@puppeteer/browsers/node_modules/debug": { - "version": "4.4.0", - "resolved": "https://npm.skia.org/chrome-devtools/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "version": "4.4.1", + "resolved": "https://npm.skia.org/chrome-devtools/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1778,9 +1778,9 @@ } }, "node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "version": "4.2.1", + "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true, "license": "Apache-2.0", "engines": { @@ -2136,9 +2136,9 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://npm.skia.org/chrome-devtools/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "version": "2.0.2", + "resolved": "https://npm.skia.org/chrome-devtools/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2204,9 +2204,9 @@ } }, "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "version": "4.2.1", + "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true, "license": "Apache-2.0", "engines": { @@ -2749,7 +2749,9 @@ "license": "ISC" }, "node_modules/brace-expansion": { - "version": "1.1.11", + "version": "1.1.12", + "resolved": "https://npm.skia.org/chrome-devtools/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", "dev": true, "license": "MIT", "dependencies": { @@ -2855,14 +2857,14 @@ } }, "node_modules/cacheable": { - "version": "1.8.9", - "resolved": "https://npm.skia.org/chrome-devtools/cacheable/-/cacheable-1.8.9.tgz", - "integrity": "sha512-FicwAUyWnrtnd4QqYAoRlNs44/a1jTL7XDKqm5gJ90wz1DQPlC7U2Rd1Tydpv+E7WAr4sQHuw8Q8M3nZMAyecQ==", + "version": "1.10.0", + "resolved": "https://npm.skia.org/chrome-devtools/cacheable/-/cacheable-1.10.0.tgz", + "integrity": "sha512-SSgQTAnhd7WlJXnGlIi4jJJOiHzgnM5wRMEPaXAU4kECTAMpBoYKoZ9i5zHmclIEZbxcu3j7yY/CF8DTmwIsHg==", "dev": true, "license": "MIT", "dependencies": { - "hookified": "^1.7.1", - "keyv": "^5.3.1" + "hookified": "^1.8.2", + "keyv": "^5.3.3" } }, "node_modules/call-bind": { @@ -4476,9 +4478,9 @@ } }, "node_modules/eslint/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "version": "4.2.1", + "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true, "license": "Apache-2.0", "engines": { @@ -4553,9 +4555,9 @@ } }, "node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "version": "4.2.1", + "resolved": "https://npm.skia.org/chrome-devtools/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true, "license": "Apache-2.0", "engines": { @@ -5267,9 +5269,9 @@ } }, "node_modules/hookified": { - "version": "1.7.1", - "resolved": "https://npm.skia.org/chrome-devtools/hookified/-/hookified-1.7.1.tgz", - "integrity": "sha512-OXcdHsXeOiD7OJ5zvWj8Oy/6RCdLwntAX+wUrfemNcMGn6sux4xbEHi2QXwqePYhjQ/yvxxq2MvCRirdlHscBw==", + "version": "1.9.1", + "resolved": "https://npm.skia.org/chrome-devtools/hookified/-/hookified-1.9.1.tgz", + "integrity": "sha512-u3pxtGhKjcSXnGm1CX6aXS9xew535j3lkOCegbA6jdyh0BaAjTbXI4aslKstCr6zUNtoCxFGFKwjbSHdGrMB8g==", "dev": true, "license": "MIT" }, @@ -6259,9 +6261,9 @@ } }, "node_modules/keyv": { - "version": "5.3.2", - "resolved": "https://npm.skia.org/chrome-devtools/keyv/-/keyv-5.3.2.tgz", - "integrity": "sha512-Lji2XRxqqa5Wg+CHLVfFKBImfJZ4pCSccu9eVWK6w4c2SDFLd8JAn1zqTuSFnsxb7ope6rMsnIHfp+eBbRBRZQ==", + "version": "5.3.4", + "resolved": "https://npm.skia.org/chrome-devtools/keyv/-/keyv-5.3.4.tgz", + "integrity": "sha512-ypEvQvInNpUe+u+w8BIcPkQvEqXquyyibWE/1NB5T2BTzIpS5cGEV1LZskDzPSTvNAaT4+5FutvzlvnkxOSKlw==", "dev": true, "license": "MIT", "dependencies": { @@ -8029,9 +8031,9 @@ } }, "node_modules/puppeteer-core/node_modules/debug": { - "version": "4.4.0", - "resolved": "https://npm.skia.org/chrome-devtools/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "version": "4.4.1", + "resolved": "https://npm.skia.org/chrome-devtools/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", "dev": true, "license": "MIT", "dependencies": { @@ -8445,9 +8447,9 @@ "license": "MIT" }, "node_modules/semver": { - "version": "7.7.1", - "resolved": "https://npm.skia.org/chrome-devtools/semver/-/semver-7.7.1.tgz", - "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "version": "7.7.2", + "resolved": "https://npm.skia.org/chrome-devtools/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", "dev": true, "license": "ISC", "bin": { @@ -9189,31 +9191,31 @@ } }, "node_modules/stylelint/node_modules/file-entry-cache": { - "version": "10.0.7", - "resolved": "https://npm.skia.org/chrome-devtools/file-entry-cache/-/file-entry-cache-10.0.7.tgz", - "integrity": "sha512-txsf5fu3anp2ff3+gOJJzRImtrtm/oa9tYLN0iTuINZ++EyVR/nRrg2fKYwvG/pXDofcrvvb0scEbX3NyW/COw==", + "version": "10.1.1", + "resolved": "https://npm.skia.org/chrome-devtools/file-entry-cache/-/file-entry-cache-10.1.1.tgz", + "integrity": "sha512-zcmsHjg2B2zjuBgjdnB+9q0+cWcgWfykIcsDkWDB4GTPtl1eXUA+gTI6sO0u01AqK3cliHryTU55/b2Ow1hfZg==", "dev": true, "license": "MIT", "dependencies": { - "flat-cache": "^6.1.7" + "flat-cache": "^6.1.10" } }, "node_modules/stylelint/node_modules/flat-cache": { - "version": "6.1.7", - "resolved": "https://npm.skia.org/chrome-devtools/flat-cache/-/flat-cache-6.1.7.tgz", - "integrity": "sha512-qwZ4xf1v1m7Rc9XiORly31YaChvKt6oNVHuqqZcoED/7O+ToyNVGobKsIAopY9ODcWpEDKEBAbrSOCBHtNQvew==", + "version": "6.1.10", + "resolved": "https://npm.skia.org/chrome-devtools/flat-cache/-/flat-cache-6.1.10.tgz", + "integrity": "sha512-B6/v1f0NwjxzmeOhzfXPGWpKBVA207LS7lehaVKQnFrVktcFRfkzjZZ2gwj2i1TkEUMQht7ZMJbABUT5N+V1Nw==", "dev": true, "license": "MIT", "dependencies": { - "cacheable": "^1.8.9", + "cacheable": "^1.10.0", "flatted": "^3.3.3", - "hookified": "^1.7.1" + "hookified": "^1.9.1" } }, "node_modules/stylelint/node_modules/ignore": { - "version": "7.0.3", - "resolved": "https://npm.skia.org/chrome-devtools/ignore/-/ignore-7.0.3.tgz", - "integrity": "sha512-bAH5jbK/F3T3Jls4I0SO1hmPR0dKU0a7+SY6n1yzRtG54FLO8d6w/nxLFX2Nb7dBu6cCWXPaAME6cYqFUMmuCA==", + "version": "7.0.5", + "resolved": "https://npm.skia.org/chrome-devtools/ignore/-/ignore-7.0.5.tgz", + "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", "dev": true, "license": "MIT", "engines": { @@ -9228,9 +9230,9 @@ "license": "CC0-1.0" }, "node_modules/stylelint/node_modules/postcss": { - "version": "8.5.3", - "resolved": "https://npm.skia.org/chrome-devtools/postcss/-/postcss-8.5.3.tgz", - "integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==", + "version": "8.5.6", + "resolved": "https://npm.skia.org/chrome-devtools/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", "dev": true, "funding": [ { @@ -9248,7 +9250,7 @@ ], "license": "MIT", "dependencies": { - "nanoid": "^3.3.8", + "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" },