diff --git a/.yarn/patches/esbuild-plugins-node-modules-polyfill-npm-1.0.7-ceaec37bb6.patch b/.yarn/patches/esbuild-plugins-node-modules-polyfill-npm-1.0.7-ceaec37bb6.patch deleted file mode 100644 index 54df4368..00000000 --- a/.yarn/patches/esbuild-plugins-node-modules-polyfill-npm-1.0.7-ceaec37bb6.patch +++ /dev/null @@ -1,122 +0,0 @@ -diff --git a/dist/index.js b/dist/index.js -index 19942834796b643f5b03e6c43d475dfdb228453d..462b0a2a539ff06af73837cf1703739fabcbe6f0 100644 ---- a/dist/index.js -+++ b/dist/index.js -@@ -34,6 +34,23 @@ __export(src_exports, { - }); - module.exports = __toCommonJS(src_exports); - -+// src/lib/polyfills/regexpEscape.ts -+var REGEXPESC = /[$()*+./?[\\\]^{|}-]/g; -+function regExpEsc(str) { -+ return str.replaceAll(REGEXPESC, "\\$&"); -+} -+__name(regExpEsc, "regExpEsc"); -+ -+// src/lib/polyfills/StringReplaceAllPolyfill.ts -+if (!String.prototype.replaceAll) { -+ String.prototype.replaceAll = /* @__PURE__ */ __name(function replaceAll(str, newStr) { -+ if (Object.prototype.toString.call(str).toLowerCase() === "[object regexp]") { -+ return this.replace(str, newStr); -+ } -+ return this.replaceAll(new RegExp(regExpEsc(str), "g"), newStr); -+ }, "replaceAll"); -+} -+ - // src/lib/utils/util.ts - var escapeRegex = /* @__PURE__ */ __name((str) => { - return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d"); -@@ -128,4 +145,22 @@ var nodeModulesPolyfillPlugin = /* @__PURE__ */ __name((options = {}) => { - nodeModulesPolyfillPlugin, - removeEndingSlash - }); -+/** -+ * Cleans a string from regex injection -+ * @param str The string to clean -+ * https://github.com/sapphiredev/utilities/blob/main/packages/utilities/src/lib/regExpEsc.ts -+ * @author The Sapphire Community and its contributors -+ * @license MIT -+ */ -+/** -+ * String.prototype.replaceAll() polyfill -+ * https://gomakethings.com/how-to-replace-a-section-of-a-string-with-another-one-with-vanilla-js/ -+ * @author Chris Ferdinandi -+ * @license MIT -+ */ -+/** -+ * https://github.com/sapphiredev/utilities/blob/main/packages/utilities/src/lib/regExpEsc.ts -+ * @author The Sapphire Community and its contributors -+ * @license MIT -+ */ - //# sourceMappingURL=index.js.map -\ No newline at end of file -diff --git a/dist/index.js.map b/dist/index.js.map -index 6425ce3083e907672e89f41bc0c0ea60238daa55..6e3410fce3ea09882e9f795c1284d852fbb01b18 100644 ---- a/dist/index.js.map -+++ b/dist/index.js.map -@@ -1 +1 @@ --{"version":3,"sources":["../src/index.ts","../src/lib/utils/util.ts","../src/lib/plugin.ts"],"sourcesContent":["export * from './lib/utils/util.js';\nexport * from './lib/plugin.js';\n","export const escapeRegex = (str: string) => {\n\treturn str.replaceAll(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&').replaceAll('-', '\\\\x2d');\n};\n\nexport const removeEndingSlash = (str: string) => {\n\treturn str.replace(/\\/$/, '');\n};\n\nexport const commonJsTemplate = ({ importPath }: { importPath: string }) => {\n\treturn `\nconst polyfill = require('${importPath}')\nif (polyfill && polyfill.default) {\n module.exports = polyfill.default\n for (let k in polyfill) {\n module.exports[k] = polyfill[k]\n }\n} else if (polyfill) {\n module.exports = polyfill\n}\n`;\n};\n","import { builtinModules } from 'node:module';\nimport path from 'node:path';\n\nimport { polyfillContent, polyfillPath } from 'modern-node-polyfills';\n\nimport { escapeRegex, commonJsTemplate, removeEndingSlash } from './utils/util.js';\n\nimport type { OnResolveArgs, Plugin } from 'esbuild';\nimport type esbuild from 'esbuild';\n\nconst NAME = 'node-modules-polyfills';\n\nexport interface NodePolyfillsOptions {\n\tname?: string;\n\tnamespace?: string;\n}\n\nconst loader = async (args: esbuild.OnLoadArgs): Promise => {\n\ttry {\n\t\tconst isCommonjs = args.namespace.endsWith('commonjs');\n\n\t\tconst resolved = await polyfillPath(removeEndingSlash(args.path));\n\t\tconst contents = await polyfillContent(removeEndingSlash(args.path));\n\t\tconst resolveDir = path.dirname(resolved);\n\n\t\tif (isCommonjs) {\n\t\t\treturn {\n\t\t\t\tloader: 'js',\n\t\t\t\tcontents: commonJsTemplate({\n\t\t\t\t\timportPath: args.path,\n\t\t\t\t}),\n\t\t\t\tresolveDir,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tloader: 'js',\n\t\t\tcontents,\n\t\t\tresolveDir,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error('node-modules-polyfill', error);\n\t\treturn {\n\t\t\tcontents: `export {}`,\n\t\t\tloader: 'js',\n\t\t};\n\t}\n};\n\nexport const nodeModulesPolyfillPlugin = (options: NodePolyfillsOptions = {}): Plugin => {\n\tconst { namespace = NAME, name = NAME } = options;\n\tif (namespace.endsWith('commonjs')) {\n\t\tthrow new Error(`namespace ${namespace} must not end with commonjs`);\n\t}\n\n\tconst commonjsNamespace = `${namespace}-commonjs`;\n\n\treturn {\n\t\tname,\n\t\tsetup: ({ onLoad, onResolve, initialOptions }) => {\n\t\t\t// polyfills contain global keyword, it must be defined\n\t\t\tif (initialOptions.define && !initialOptions.define.global) {\n\t\t\t\tinitialOptions.define.global = 'globalThis';\n\t\t\t} else if (!initialOptions.define) {\n\t\t\t\tinitialOptions.define = { global: 'globalThis' };\n\t\t\t}\n\n\t\t\tonLoad({ filter: /.*/, namespace }, loader);\n\t\t\tonLoad({ filter: /.*/, namespace: commonjsNamespace }, loader);\n\t\t\tconst filter = new RegExp(`(?:node:)?${builtinModules.map(escapeRegex).join('|')}`);\n\t\t\tconst resolver = async (args: OnResolveArgs) => {\n\t\t\t\tconst ignoreRequire = args.namespace === commonjsNamespace;\n\n\t\t\t\tconst pollyfill = await polyfillPath(args.path).catch(() => null);\n\n\t\t\t\tif (!pollyfill) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst isCommonjs = !ignoreRequire && args.kind === 'require-call';\n\n\t\t\t\treturn {\n\t\t\t\t\tnamespace: isCommonjs ? commonjsNamespace : namespace,\n\t\t\t\t\tpath: args.path,\n\t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,YAAY,MAAM,OAAO,KAAK,IAAI;AAC1C,MAAI,UAAU,SAAS,UAAU,GAAG;AACnC,UAAM,IAAI,MAAM,aAAa,sCAAsC;AAAA,EACpE;AAEA,QAAM,oBAAoB,GAAG;AAE7B,SAAO;AAAA,IACN;AAAA,IACA,OAAO,CAAC,EAAE,QAAQ,WAAW,eAAe,MAAM;AAEjD,UAAI,eAAe,UAAU,CAAC,eAAe,OAAO,QAAQ;AAC3D,uBAAe,OAAO,SAAS;AAAA,MAChC,WAAW,CAAC,eAAe,QAAQ;AAClC,uBAAe,SAAS,EAAE,QAAQ,aAAa;AAAA,MAChD;AAEA,aAAO,EAAE,QAAQ,MAAM,UAAU,GAAG,MAAM;AAC1C,aAAO,EAAE,QAAQ,MAAM,WAAW,kBAAkB,GAAG,MAAM;AAC7D,YAAM,SAAS,IAAI,OAAO,aAAa,kCAAe,IAAI,WAAW,EAAE,KAAK,GAAG,GAAG;AAClF,YAAM,WAAW,8BAAO,SAAwB;AAC/C,cAAM,gBAAgB,KAAK,cAAc;AAEzC,cAAM,YAAY,UAAM,2CAAa,KAAK,IAAI,EAAE,MAAM,MAAM,IAAI;AAEhE,YAAI,CAAC,WAAW;AACf;AAAA,QACD;AAEA,cAAM,aAAa,CAAC,iBAAiB,KAAK,SAAS;AAEnD,eAAO;AAAA,UACN,WAAW,aAAa,oBAAoB;AAAA,UAC5C,MAAM,KAAK;AAAA,QACZ;AAAA,MACD,GAfiB;AAiBjB,gBAAU,EAAE,OAAO,GAAG,QAAQ;AAAA,IAC/B;AAAA,EACD;AACD,GAzCyC;","names":["path"]} -\ No newline at end of file -+{"version":3,"sources":["../src/index.ts","../src/lib/polyfills/regexpEscape.ts","../src/lib/polyfills/StringReplaceAllPolyfill.ts","../src/lib/utils/util.ts","../src/lib/plugin.ts"],"sourcesContent":["export * from './lib/utils/util.js';\nexport * from './lib/plugin.js';\n","/**\n * https://github.com/sapphiredev/utilities/blob/main/packages/utilities/src/lib/regExpEsc.ts\n * @author The Sapphire Community and its contributors\n * @license MIT\n */\nconst REGEXPESC = /[$()*+./?[\\\\\\]^{|}-]/g;\n\n/**\n * Cleans a string from regex injection\n * @param str The string to clean\n * https://github.com/sapphiredev/utilities/blob/main/packages/utilities/src/lib/regExpEsc.ts\n * @author The Sapphire Community and its contributors\n * @license MIT\n */\nexport function regExpEsc(str: string): string {\n\treturn str.replaceAll(REGEXPESC, '\\\\$&');\n}\n","import { regExpEsc } from './regexpEscape.js';\n\n/**\n * String.prototype.replaceAll() polyfill\n * https://gomakethings.com/how-to-replace-a-section-of-a-string-with-another-one-with-vanilla-js/\n * @author Chris Ferdinandi\n * @license MIT\n */\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nif (!String.prototype.replaceAll) {\n\t// eslint-disable-next-line no-extend-native\n\tString.prototype.replaceAll = function replaceAll(\n\t\tstr: RegExp | string,\n\t\tnewStr: string | ((substring: string, ...args: any[]) => string),\n\t): string {\n\t\t// If a regex pattern\n\t\tif (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {\n\t\t\t// @ts-expect-error newStr can be both a string or a function returning a string\n\t\t\treturn this.replace(str, newStr);\n\t\t}\n\n\t\t// If a string\n\t\t// @ts-expect-error newStr can be both a string or a function returning a string\n\t\treturn this.replaceAll(new RegExp(regExpEsc(str), 'g'), newStr);\n\t};\n}\n","import '../polyfills/StringReplaceAllPolyfill.js';\n\nexport const escapeRegex = (str: string) => {\n\treturn str.replaceAll(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&').replaceAll('-', '\\\\x2d');\n};\n\nexport const removeEndingSlash = (str: string) => {\n\treturn str.replace(/\\/$/, '');\n};\n\nexport const commonJsTemplate = ({ importPath }: { importPath: string }) => {\n\treturn `\nconst polyfill = require('${importPath}')\nif (polyfill && polyfill.default) {\n module.exports = polyfill.default\n for (let k in polyfill) {\n module.exports[k] = polyfill[k]\n }\n} else if (polyfill) {\n module.exports = polyfill\n}\n`;\n};\n","import { builtinModules } from 'node:module';\nimport path from 'node:path';\n\nimport { polyfillContent, polyfillPath } from 'modern-node-polyfills';\n\nimport { escapeRegex, commonJsTemplate, removeEndingSlash } from './utils/util.js';\n\nimport type { OnResolveArgs, Plugin } from 'esbuild';\nimport type esbuild from 'esbuild';\n\nconst NAME = 'node-modules-polyfills';\n\nexport interface NodePolyfillsOptions {\n\tname?: string;\n\tnamespace?: string;\n}\n\nconst loader = async (args: esbuild.OnLoadArgs): Promise => {\n\ttry {\n\t\tconst isCommonjs = args.namespace.endsWith('commonjs');\n\n\t\tconst resolved = await polyfillPath(removeEndingSlash(args.path));\n\t\tconst contents = await polyfillContent(removeEndingSlash(args.path));\n\t\tconst resolveDir = path.dirname(resolved);\n\n\t\tif (isCommonjs) {\n\t\t\treturn {\n\t\t\t\tloader: 'js',\n\t\t\t\tcontents: commonJsTemplate({\n\t\t\t\t\timportPath: args.path,\n\t\t\t\t}),\n\t\t\t\tresolveDir,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tloader: 'js',\n\t\t\tcontents,\n\t\t\tresolveDir,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error('node-modules-polyfill', error);\n\t\treturn {\n\t\t\tcontents: `export {}`,\n\t\t\tloader: 'js',\n\t\t};\n\t}\n};\n\nexport const nodeModulesPolyfillPlugin = (options: NodePolyfillsOptions = {}): Plugin => {\n\tconst { namespace = NAME, name = NAME } = options;\n\tif (namespace.endsWith('commonjs')) {\n\t\tthrow new Error(`namespace ${namespace} must not end with commonjs`);\n\t}\n\n\tconst commonjsNamespace = `${namespace}-commonjs`;\n\n\treturn {\n\t\tname,\n\t\tsetup: ({ onLoad, onResolve, initialOptions }) => {\n\t\t\t// polyfills contain global keyword, it must be defined\n\t\t\tif (initialOptions.define && !initialOptions.define.global) {\n\t\t\t\tinitialOptions.define.global = 'globalThis';\n\t\t\t} else if (!initialOptions.define) {\n\t\t\t\tinitialOptions.define = { global: 'globalThis' };\n\t\t\t}\n\n\t\t\tonLoad({ filter: /.*/, namespace }, loader);\n\t\t\tonLoad({ filter: /.*/, namespace: commonjsNamespace }, loader);\n\t\t\tconst filter = new RegExp(`(?:node:)?${builtinModules.map(escapeRegex).join('|')}`);\n\t\t\tconst resolver = async (args: OnResolveArgs) => {\n\t\t\t\tconst ignoreRequire = args.namespace === commonjsNamespace;\n\n\t\t\t\tconst pollyfill = await polyfillPath(args.path).catch(() => null);\n\n\t\t\t\tif (!pollyfill) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst isCommonjs = !ignoreRequire && args.kind === 'require-call';\n\n\t\t\t\treturn {\n\t\t\t\t\tnamespace: isCommonjs ? commonjsNamespace : namespace,\n\t\t\t\t\tpath: args.path,\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tonResolve({ filter }, resolver);\n\t\t},\n\t};\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,YAAY;AASX,SAAS,UAAU,KAAqB;AAC9C,SAAO,IAAI,WAAW,WAAW,MAAM;AACxC;AAFgB;;;ACLhB,IAAI,CAAC,OAAO,UAAU,YAAY;AAEjC,SAAO,UAAU,aAAa,gCAAS,WACtC,KACA,QACS;AAET,QAAI,OAAO,UAAU,SAAS,KAAK,GAAG,EAAE,YAAY,MAAM,mBAAmB;AAE5E,aAAO,KAAK,QAAQ,KAAK,MAAM;AAAA,IAChC;AAIA,WAAO,KAAK,WAAW,IAAI,OAAO,UAAU,GAAG,GAAG,GAAG,GAAG,MAAM;AAAA,EAC/D,GAb8B;AAc/B;;;ACvBO,IAAM,cAAc,wBAAC,QAAgB;AAC3C,SAAO,IAAI,WAAW,uBAAuB,MAAM,EAAE,WAAW,KAAK,OAAO;AAC7E,GAF2B;AAIpB,IAAM,oBAAoB,wBAAC,QAAgB;AACjD,SAAO,IAAI,QAAQ,OAAO,EAAE;AAC7B,GAFiC;AAI1B,IAAM,mBAAmB,wBAAC,EAAE,WAAW,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,EAAE,QAAQ,MAAM,UAAU,GAAG,MAAM;AAC1C,aAAO,EAAE,QAAQ,MAAM,WAAW,kBAAkB,GAAG,MAAM;AAC7D,YAAM,SAAS,IAAI,OAAO,aAAa,kCAAe,IAAI,WAAW,EAAE,KAAK,GAAG,GAAG;AAClF,YAAM,WAAW,8BAAO,SAAwB;AAC/C,cAAM,gBAAgB,KAAK,cAAc;AAEzC,cAAM,YAAY,UAAM,2CAAa,KAAK,IAAI,EAAE,MAAM,MAAM,IAAI;AAEhE,YAAI,CAAC,WAAW;AACf;AAAA,QACD;AAEA,cAAM,aAAa,CAAC,iBAAiB,KAAK,SAAS;AAEnD,eAAO;AAAA,UACN,WAAW,aAAa,oBAAoB;AAAA,UAC5C,MAAM,KAAK;AAAA,QACZ;AAAA,MACD,GAfiB;AAiBjB,gBAAU,EAAE,OAAO,GAAG,QAAQ;AAAA,IAC/B;AAAA,EACD;AACD,GAzCyC;","names":["path"]} -\ No newline at end of file -diff --git a/dist/index.mjs b/dist/index.mjs -index 8e1a798c05ea0c3c36322f62046ceb588f89d0af..03bb0d16f06e155bd4b7149b59e20bf043582d2a 100644 ---- a/dist/index.mjs -+++ b/dist/index.mjs -@@ -1,6 +1,23 @@ - var __defProp = Object.defineProperty; - var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); - -+// src/lib/polyfills/regexpEscape.ts -+var REGEXPESC = /[$()*+./?[\\\]^{|}-]/g; -+function regExpEsc(str) { -+ return str.replaceAll(REGEXPESC, "\\$&"); -+} -+__name(regExpEsc, "regExpEsc"); -+ -+// src/lib/polyfills/StringReplaceAllPolyfill.ts -+if (!String.prototype.replaceAll) { -+ String.prototype.replaceAll = /* @__PURE__ */ __name(function replaceAll(str, newStr) { -+ if (Object.prototype.toString.call(str).toLowerCase() === "[object regexp]") { -+ return this.replace(str, newStr); -+ } -+ return this.replaceAll(new RegExp(regExpEsc(str), "g"), newStr); -+ }, "replaceAll"); -+} -+ - // src/lib/utils/util.ts - var escapeRegex = /* @__PURE__ */ __name((str) => { - return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d"); -@@ -94,4 +111,22 @@ export { - nodeModulesPolyfillPlugin, - removeEndingSlash - }; -+/** -+ * Cleans a string from regex injection -+ * @param str The string to clean -+ * https://github.com/sapphiredev/utilities/blob/main/packages/utilities/src/lib/regExpEsc.ts -+ * @author The Sapphire Community and its contributors -+ * @license MIT -+ */ -+/** -+ * String.prototype.replaceAll() polyfill -+ * https://gomakethings.com/how-to-replace-a-section-of-a-string-with-another-one-with-vanilla-js/ -+ * @author Chris Ferdinandi -+ * @license MIT -+ */ -+/** -+ * https://github.com/sapphiredev/utilities/blob/main/packages/utilities/src/lib/regExpEsc.ts -+ * @author The Sapphire Community and its contributors -+ * @license MIT -+ */ - //# sourceMappingURL=index.mjs.map -\ No newline at end of file -diff --git a/dist/index.mjs.map b/dist/index.mjs.map -index 52d3bbb796fa9ad66aa4fc9f87c3379962951dd3..ee2a9a7ac92dfdefb3a65a94cf8d21a405177a97 100644 ---- a/dist/index.mjs.map -+++ b/dist/index.mjs.map -@@ -1 +1 @@ --{"version":3,"sources":["../src/lib/utils/util.ts","../src/lib/plugin.ts"],"sourcesContent":["export const escapeRegex = (str: string) => {\n\treturn str.replaceAll(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&').replaceAll('-', '\\\\x2d');\n};\n\nexport const removeEndingSlash = (str: string) => {\n\treturn str.replace(/\\/$/, '');\n};\n\nexport const commonJsTemplate = ({ importPath }: { importPath: string }) => {\n\treturn `\nconst polyfill = require('${importPath}')\nif (polyfill && polyfill.default) {\n module.exports = polyfill.default\n for (let k in polyfill) {\n module.exports[k] = polyfill[k]\n }\n} else if (polyfill) {\n module.exports = polyfill\n}\n`;\n};\n","import { builtinModules } from 'node:module';\nimport path from 'node:path';\n\nimport { polyfillContent, polyfillPath } from 'modern-node-polyfills';\n\nimport { escapeRegex, commonJsTemplate, removeEndingSlash } from './utils/util.js';\n\nimport type { OnResolveArgs, Plugin } from 'esbuild';\nimport type esbuild from 'esbuild';\n\nconst NAME = 'node-modules-polyfills';\n\nexport interface NodePolyfillsOptions {\n\tname?: string;\n\tnamespace?: string;\n}\n\nconst loader = async (args: esbuild.OnLoadArgs): Promise => {\n\ttry {\n\t\tconst isCommonjs = args.namespace.endsWith('commonjs');\n\n\t\tconst resolved = await polyfillPath(removeEndingSlash(args.path));\n\t\tconst contents = await polyfillContent(removeEndingSlash(args.path));\n\t\tconst resolveDir = path.dirname(resolved);\n\n\t\tif (isCommonjs) {\n\t\t\treturn {\n\t\t\t\tloader: 'js',\n\t\t\t\tcontents: commonJsTemplate({\n\t\t\t\t\timportPath: args.path,\n\t\t\t\t}),\n\t\t\t\tresolveDir,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tloader: 'js',\n\t\t\tcontents,\n\t\t\tresolveDir,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error('node-modules-polyfill', error);\n\t\treturn {\n\t\t\tcontents: `export {}`,\n\t\t\tloader: 'js',\n\t\t};\n\t}\n};\n\nexport const nodeModulesPolyfillPlugin = (options: NodePolyfillsOptions = {}): Plugin => {\n\tconst { namespace = NAME, name = NAME } = options;\n\tif (namespace.endsWith('commonjs')) {\n\t\tthrow new Error(`namespace ${namespace} must not end with commonjs`);\n\t}\n\n\tconst commonjsNamespace = `${namespace}-commonjs`;\n\n\treturn {\n\t\tname,\n\t\tsetup: ({ onLoad, onResolve, initialOptions }) => {\n\t\t\t// polyfills contain global keyword, it must be defined\n\t\t\tif (initialOptions.define && !initialOptions.define.global) {\n\t\t\t\tinitialOptions.define.global = 'globalThis';\n\t\t\t} else if (!initialOptions.define) {\n\t\t\t\tinitialOptions.define = { global: 'globalThis' };\n\t\t\t}\n\n\t\t\tonLoad({ filter: /.*/, namespace }, loader);\n\t\t\tonLoad({ filter: /.*/, namespace: commonjsNamespace }, loader);\n\t\t\tconst filter = new RegExp(`(?:node:)?${builtinModules.map(escapeRegex).join('|')}`);\n\t\t\tconst resolver = async (args: OnResolveArgs) => {\n\t\t\t\tconst ignoreRequire = args.namespace === commonjsNamespace;\n\n\t\t\t\tconst pollyfill = await polyfillPath(args.path).catch(() => null);\n\n\t\t\t\tif (!pollyfill) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst isCommonjs = !ignoreRequire && args.kind === 'require-call';\n\n\t\t\t\treturn {\n\t\t\t\t\tnamespace: isCommonjs ? commonjsNamespace : namespace,\n\t\t\t\t\tpath: args.path,\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tonResolve({ filter }, resolver);\n\t\t},\n\t};\n};\n"],"mappings":";;;;AAAO,IAAM,cAAc,wBAAC,QAAgB;AAC3C,SAAO,IAAI,WAAW,uBAAuB,MAAM,EAAE,WAAW,KAAK,OAAO;AAC7E,GAF2B;AAIpB,IAAM,oBAAoB,wBAAC,QAAgB;AACjD,SAAO,IAAI,QAAQ,OAAO,EAAE;AAC7B,GAFiC;AAI1B,IAAM,mBAAmB,wBAAC,EAAE,WAAW,MAA8B;AAC3E,SAAO;AAAA,4BACoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAU5B,GAZgC;;;ACRhC,SAAS,sBAAsB;AAC/B,OAAO,UAAU;AAEjB,SAAS,iBAAiB,oBAAoB;AAO9C,IAAM,OAAO;AAOb,IAAM,SAAS,8BAAO,SAA4D;AACjF,MAAI;AACH,UAAM,aAAa,KAAK,UAAU,SAAS,UAAU;AAErD,UAAM,WAAW,MAAM,aAAa,kBAAkB,KAAK,IAAI,CAAC;AAChE,UAAM,WAAW,MAAM,gBAAgB,kBAAkB,KAAK,IAAI,CAAC;AACnE,UAAM,aAAa,KAAK,QAAQ,QAAQ;AAExC,QAAI,YAAY;AACf,aAAO;AAAA,QACN,QAAQ;AAAA,QACR,UAAU,iBAAiB;AAAA,UAC1B,YAAY,KAAK;AAAA,QAClB,CAAC;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA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;","names":[]} -\ No newline at end of file -+{"version":3,"sources":["../src/lib/polyfills/regexpEscape.ts","../src/lib/polyfills/StringReplaceAllPolyfill.ts","../src/lib/utils/util.ts","../src/lib/plugin.ts"],"sourcesContent":["/**\n * https://github.com/sapphiredev/utilities/blob/main/packages/utilities/src/lib/regExpEsc.ts\n * @author The Sapphire Community and its contributors\n * @license MIT\n */\nconst REGEXPESC = /[$()*+./?[\\\\\\]^{|}-]/g;\n\n/**\n * Cleans a string from regex injection\n * @param str The string to clean\n * https://github.com/sapphiredev/utilities/blob/main/packages/utilities/src/lib/regExpEsc.ts\n * @author The Sapphire Community and its contributors\n * @license MIT\n */\nexport function regExpEsc(str: string): string {\n\treturn str.replaceAll(REGEXPESC, '\\\\$&');\n}\n","import { regExpEsc } from './regexpEscape.js';\n\n/**\n * String.prototype.replaceAll() polyfill\n * https://gomakethings.com/how-to-replace-a-section-of-a-string-with-another-one-with-vanilla-js/\n * @author Chris Ferdinandi\n * @license MIT\n */\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nif (!String.prototype.replaceAll) {\n\t// eslint-disable-next-line no-extend-native\n\tString.prototype.replaceAll = function replaceAll(\n\t\tstr: RegExp | string,\n\t\tnewStr: string | ((substring: string, ...args: any[]) => string),\n\t): string {\n\t\t// If a regex pattern\n\t\tif (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {\n\t\t\t// @ts-expect-error newStr can be both a string or a function returning a string\n\t\t\treturn this.replace(str, newStr);\n\t\t}\n\n\t\t// If a string\n\t\t// @ts-expect-error newStr can be both a string or a function returning a string\n\t\treturn this.replaceAll(new RegExp(regExpEsc(str), 'g'), newStr);\n\t};\n}\n","import '../polyfills/StringReplaceAllPolyfill.js';\n\nexport const escapeRegex = (str: string) => {\n\treturn str.replaceAll(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&').replaceAll('-', '\\\\x2d');\n};\n\nexport const removeEndingSlash = (str: string) => {\n\treturn str.replace(/\\/$/, '');\n};\n\nexport const commonJsTemplate = ({ importPath }: { importPath: string }) => {\n\treturn `\nconst polyfill = require('${importPath}')\nif (polyfill && polyfill.default) {\n module.exports = polyfill.default\n for (let k in polyfill) {\n module.exports[k] = polyfill[k]\n }\n} else if (polyfill) {\n module.exports = polyfill\n}\n`;\n};\n","import { builtinModules } from 'node:module';\nimport path from 'node:path';\n\nimport { polyfillContent, polyfillPath } from 'modern-node-polyfills';\n\nimport { escapeRegex, commonJsTemplate, removeEndingSlash } from './utils/util.js';\n\nimport type { OnResolveArgs, Plugin } from 'esbuild';\nimport type esbuild from 'esbuild';\n\nconst NAME = 'node-modules-polyfills';\n\nexport interface NodePolyfillsOptions {\n\tname?: string;\n\tnamespace?: string;\n}\n\nconst loader = async (args: esbuild.OnLoadArgs): Promise => {\n\ttry {\n\t\tconst isCommonjs = args.namespace.endsWith('commonjs');\n\n\t\tconst resolved = await polyfillPath(removeEndingSlash(args.path));\n\t\tconst contents = await polyfillContent(removeEndingSlash(args.path));\n\t\tconst resolveDir = path.dirname(resolved);\n\n\t\tif (isCommonjs) {\n\t\t\treturn {\n\t\t\t\tloader: 'js',\n\t\t\t\tcontents: commonJsTemplate({\n\t\t\t\t\timportPath: args.path,\n\t\t\t\t}),\n\t\t\t\tresolveDir,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tloader: 'js',\n\t\t\tcontents,\n\t\t\tresolveDir,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error('node-modules-polyfill', error);\n\t\treturn {\n\t\t\tcontents: `export {}`,\n\t\t\tloader: 'js',\n\t\t};\n\t}\n};\n\nexport const nodeModulesPolyfillPlugin = (options: NodePolyfillsOptions = {}): Plugin => {\n\tconst { namespace = NAME, name = NAME } = options;\n\tif (namespace.endsWith('commonjs')) {\n\t\tthrow new Error(`namespace ${namespace} must not end with commonjs`);\n\t}\n\n\tconst commonjsNamespace = `${namespace}-commonjs`;\n\n\treturn {\n\t\tname,\n\t\tsetup: ({ onLoad, onResolve, initialOptions }) => {\n\t\t\t// polyfills contain global keyword, it must be defined\n\t\t\tif (initialOptions.define && !initialOptions.define.global) {\n\t\t\t\tinitialOptions.define.global = 'globalThis';\n\t\t\t} else if (!initialOptions.define) {\n\t\t\t\tinitialOptions.define = { global: 'globalThis' };\n\t\t\t}\n\n\t\t\tonLoad({ filter: /.*/, namespace }, loader);\n\t\t\tonLoad({ filter: /.*/, namespace: commonjsNamespace }, loader);\n\t\t\tconst filter = new RegExp(`(?:node:)?${builtinModules.map(escapeRegex).join('|')}`);\n\t\t\tconst resolver = async (args: OnResolveArgs) => {\n\t\t\t\tconst ignoreRequire = args.namespace === commonjsNamespace;\n\n\t\t\t\tconst pollyfill = await polyfillPath(args.path).catch(() => null);\n\n\t\t\t\tif (!pollyfill) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst isCommonjs = !ignoreRequire && args.kind === 'require-call';\n\n\t\t\t\treturn {\n\t\t\t\t\tnamespace: isCommonjs ? commonjsNamespace : namespace,\n\t\t\t\t\tpath: args.path,\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tonResolve({ filter }, resolver);\n\t\t},\n\t};\n};\n"],"mappings":";;;;AAKA,IAAM,YAAY;AASX,SAAS,UAAU,KAAqB;AAC9C,SAAO,IAAI,WAAW,WAAW,MAAM;AACxC;AAFgB;;;ACLhB,IAAI,CAAC,OAAO,UAAU,YAAY;AAEjC,SAAO,UAAU,aAAa,gCAAS,WACtC,KACA,QACS;AAET,QAAI,OAAO,UAAU,SAAS,KAAK,GAAG,EAAE,YAAY,MAAM,mBAAmB;AAE5E,aAAO,KAAK,QAAQ,KAAK,MAAM;AAAA,IAChC;AAIA,WAAO,KAAK,WAAW,IAAI,OAAO,UAAU,GAAG,GAAG,GAAG,GAAG,MAAM;AAAA,EAC/D,GAb8B;AAc/B;;;ACvBO,IAAM,cAAc,wBAAC,QAAgB;AAC3C,SAAO,IAAI,WAAW,uBAAuB,MAAM,EAAE,WAAW,KAAK,OAAO;AAC7E,GAF2B;A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Ae,OAAO,QAAQ;AAC3D,uBAAe,OAAO,SAAS;AAAA,MAChC,WAAW,CAAC,eAAe,QAAQ;AAClC,uBAAe,SAAS,EAAE,QAAQ,aAAa;AAAA,MAChD;AAEA,aAAO,EAAE,QAAQ,MAAM,UAAU,GAAG,MAAM;AAC1C,aAAO,EAAE,QAAQ,MAAM,WAAW,kBAAkB,GAAG,MAAM;AAC7D,YAAM,SAAS,IAAI,OAAO,aAAa,eAAe,IAAI,WAAW,EAAE,KAAK,GAAG,GAAG;AAClF,YAAM,WAAW,8BAAO,SAAwB;AAC/C,cAAM,gBAAgB,KAAK,cAAc;AAEzC,cAAM,YAAY,MAAM,aAAa,KAAK,IAAI,EAAE,MAAM,MAAM,IAAI;AAEhE,YAAI,CAAC,WAAW;AACf;AAAA,QACD;AAEA,cAAM,aAAa,CAAC,iBAAiB,KAAK,SAAS;AAEnD,eAAO;AAAA,UACN,WAAW,aAAa,oBAAoB;AAAA,UAC5C,MAAM,KAAK;AAAA,QACZ;AAAA,MACD,GAfiB;AAiBjB,gBAAU,EAAE,OAAO,GAAG,QAAQ;AAAA,IAC/B;AAAA,EACD;AACD,GAzCyC;","names":[]} -\ No newline at end of file diff --git a/package.json b/package.json index f43bcef6..c8f308a3 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,10 @@ "prepack": "yarn build && pinst --disable", "postpack": "pinst --enable" }, + "dependencies": { + "fast-deep-equal": "^3.1.3", + "lodash": "^4.17.21" + }, "devDependencies": { "@commitlint/cli": "^17.4.2", "@commitlint/config-conventional": "^17.4.2", @@ -43,9 +47,9 @@ "@types/jsdom": "^20.0.1", "@types/lodash": "^4.14.191", "@types/node": "^18.11.18", - "@typescript-eslint/eslint-plugin": "^5.48.1", - "@typescript-eslint/parser": "^5.48.1", - "@vitest/coverage-c8": "^0.27.1", + "@typescript-eslint/eslint-plugin": "^5.48.2", + "@typescript-eslint/parser": "^5.48.2", + "@vitest/coverage-c8": "^0.27.2", "cz-conventional-changelog": "^3.3.0", "esbuild-plugins-node-modules-polyfill": "^1.0.9", "eslint": "^8.32.0", @@ -57,26 +61,27 @@ "pinst": "^3.0.0", "prettier": "^2.8.3", "pretty-quick": "^3.1.3", - "ts-node": "^10.9.1", "tsup": "^6.5.0", "typedoc": "^0.23.24", "typedoc-json-parser": "^7.1.0", "typescript": "^4.9.4", "vite": "^4.0.4", - "vitest": "^0.27.1" + "vitest": "^0.27.2" + }, + "resolutions": { + "ansi-regex": "^5.0.1", + "minimist": "^1.2.7" }, "repository": { "type": "git", "url": "git+https://github.com/sapphiredev/shapeshift.git" }, "files": [ - "dist/**/*.js*", - "dist/**/*.mjs*", - "dist/**/*.d*" + "dist" ], "engines": { - "node": ">=v14.0.0", - "npm": ">=7.0.0" + "node": ">=v14", + "npm": ">=7" }, "keywords": [ "@sapphire/shapeshift", @@ -115,17 +120,5 @@ "publishConfig": { "access": "public" }, - "resolutions": { - "ansi-regex": "^5.0.1", - "minimist": "^1.2.7", - "esbuild-plugins-node-modules-polyfill@^1.0.7": "patch:esbuild-plugins-node-modules-polyfill@npm%3A1.0.7#./.yarn/patches/esbuild-plugins-node-modules-polyfill-npm-1.0.7-ceaec37bb6.patch" - }, - "packageManager": "yarn@3.3.1", - "dependencies": { - "fast-deep-equal": "^3.1.3", - "lodash": "^4.17.21" - }, - "volta": { - "node": "14.21.2" - } + "packageManager": "yarn@3.3.1" } diff --git a/yarn.lock b/yarn.lock index e068c94f..f0c7af21 100644 --- a/yarn.lock +++ b/yarn.lock @@ -724,7 +724,6 @@ __metadata: pinst: ^3.0.0 prettier: ^2.8.1 pretty-quick: ^3.1.3 - ts-node: ^10.9.1 tsup: ^6.5.0 typedoc: ^0.23.22 typedoc-json-parser: ^7.0.2 @@ -6147,7 +6146,7 @@ __metadata: languageName: node linkType: hard -"ts-node@npm:^10.8.1, ts-node@npm:^10.9.1": +"ts-node@npm:^10.8.1": version: 10.9.1 resolution: "ts-node@npm:10.9.1" dependencies: