nf3 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,593 @@
1
- import fs,{lstatSync,realpathSync,statSync}from"node:fs";import{URL as URL$1,fileURLToPath,pathToFileURL}from"node:url";import path,{isAbsolute}from"node:path";import assert from"node:assert";import process$1 from"node:process";import v8 from"node:v8";import{format,inspect}from"node:util";const nodeBuiltins=`_http_agent._http_client._http_common._http_incoming._http_outgoing._http_server._stream_duplex._stream_passthrough._stream_readable._stream_transform._stream_wrap._stream_writable._tls_common._tls_wrap.assert.assert/strict.async_hooks.buffer.child_process.cluster.console.constants.crypto.dgram.diagnostics_channel.dns.dns/promises.domain.events.fs.fs/promises.http.http2.https.inspector.inspector/promises.module.net.os.path.path/posix.path/win32.perf_hooks.process.punycode.querystring.readline.readline/promises.repl.stream.stream/consumers.stream/promises.stream/web.string_decoder.sys.timers.timers/promises.tls.trace_events.tty.url.util.util/types.v8.vm.wasi.worker_threads.zlib`.split(`.`),own$1={}.hasOwnProperty,classRegExp=/^([A-Z][a-z\d]*)+$/,kTypes=new Set([`string`,`function`,`number`,`object`,`Function`,`Object`,`boolean`,`bigint`,`symbol`]),messages=new Map;let userStackTraceLimit;function formatList(e,t=`and`){return e.length<3?e.join(` ${t} `):`${e.slice(0,-1).join(`, `)}, ${t} ${e.at(-1)}`}function createError(e,t,n){return messages.set(e,t),makeNodeErrorWithCode(n,e)}function makeNodeErrorWithCode(e,t){return function(...n){let r=Error.stackTraceLimit;isErrorStackTraceLimitWritable()&&(Error.stackTraceLimit=0);let i=new e;isErrorStackTraceLimitWritable()&&(Error.stackTraceLimit=r);let a=getMessage(t,n,i);return Object.defineProperties(i,{message:{value:a,enumerable:!1,writable:!0,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},enumerable:!1,writable:!0,configurable:!0}}),captureLargerStackTrace(i),i.code=t,i}}function isErrorStackTraceLimitWritable(){try{if(v8.startupSnapshot.isBuildingSnapshot())return!1}catch{}let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):own$1.call(e,`writable`)&&e.writable!==void 0?e.writable:e.set!==void 0}function hideStackFrames(e){let t=`__node_internal_`+e.name;return Object.defineProperty(e,`name`,{value:t}),e}const captureLargerStackTrace=hideStackFrames(function(e){let t=isErrorStackTraceLimitWritable();return t&&(userStackTraceLimit=Error.stackTraceLimit,Error.stackTraceLimit=1/0),Error.captureStackTrace(e),t&&(Error.stackTraceLimit=userStackTraceLimit),e});function getMessage(e,t,n){let r=messages.get(e);if(assert.ok(r!==void 0,"expected `message` to be found"),typeof r==`function`)return assert.ok(r.length<=t.length,`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${r.length}).`),Reflect.apply(r,n,t);let i=/%[dfijoOs]/g,a=0;for(;i.exec(r)!==null;)a++;return assert.ok(a===t.length,`Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${a}).`),t.length===0?r:(t.unshift(r),Reflect.apply(format,null,t))}function determineSpecificType(e){if(e==null)return String(e);if(typeof e==`function`&&e.name)return`function ${e.name}`;if(typeof e==`object`)return e.constructor&&e.constructor.name?`an instance of ${e.constructor.name}`:`${inspect(e,{depth:-1})}`;let t=inspect(e,{colors:!1});return t.length>28&&(t=`${t.slice(0,25)}...`),`type ${typeof e} (${t})`}createError(`ERR_INVALID_ARG_TYPE`,(e,t,n)=>{assert.ok(typeof e==`string`,`'name' must be a string`),Array.isArray(t)||(t=[t]);let r=`The `;if(e.endsWith(` argument`))r+=`${e} `;else{let t=e.includes(`.`)?`property`:`argument`;r+=`"${e}" ${t} `}r+=`must be `;let i=[],a=[],o=[];for(let e of t)assert.ok(typeof e==`string`,`All expected entries have to be of type string`),kTypes.has(e)?i.push(e.toLowerCase()):classRegExp.exec(e)===null?(assert.ok(e!==`object`,`The value "object" should be written as "Object"`),o.push(e)):a.push(e);if(a.length>0){let e=i.indexOf(`object`);e!==-1&&(i.slice(e,1),a.push(`Object`))}return i.length>0&&(r+=`${i.length>1?`one of type`:`of type`} ${formatList(i,`or`)}`,(a.length>0||o.length>0)&&(r+=` or `)),a.length>0&&(r+=`an instance of ${formatList(a,`or`)}`,o.length>0&&(r+=` or `)),o.length>0&&(o.length>1?r+=`one of ${formatList(o,`or`)}`:(o[0]?.toLowerCase()!==o[0]&&(r+=`an `),r+=`${o[0]}`)),r+=`. Received ${determineSpecificType(n)}`,r},TypeError);const ERR_INVALID_MODULE_SPECIFIER=createError(`ERR_INVALID_MODULE_SPECIFIER`,(e,t,n)=>`Invalid module "${e}" ${t}${n?` imported from ${n}`:``}`,TypeError),ERR_INVALID_PACKAGE_CONFIG=createError(`ERR_INVALID_PACKAGE_CONFIG`,(e,t,n)=>`Invalid package config ${e}${t?` while importing ${t}`:``}${n?`. ${n}`:``}`,Error),ERR_INVALID_PACKAGE_TARGET=createError(`ERR_INVALID_PACKAGE_TARGET`,(e,t,n,r=!1,i)=>{let a=typeof n==`string`&&!r&&n.length>0&&!n.startsWith(`./`);return t===`.`?(assert.ok(r===!1),`Invalid "exports" main target ${JSON.stringify(n)} defined in the package config ${e}package.json${i?` imported from ${i}`:``}${a?`; targets must start with "./"`:``}`):`Invalid "${r?`imports`:`exports`}" target ${JSON.stringify(n)} defined for '${t}' in the package config ${e}package.json${i?` imported from ${i}`:``}${a?`; targets must start with "./"`:``}`},Error),ERR_MODULE_NOT_FOUND=createError(`ERR_MODULE_NOT_FOUND`,(e,t,n=!1)=>`Cannot find ${n?`module`:`package`} '${e}' imported from ${t}`,Error);createError(`ERR_NETWORK_IMPORT_DISALLOWED`,`import of '%s' by %s is not supported: %s`,Error);const ERR_PACKAGE_IMPORT_NOT_DEFINED=createError(`ERR_PACKAGE_IMPORT_NOT_DEFINED`,(e,t,n)=>`Package import specifier "${e}" is not defined${t?` in package ${t||``}package.json`:``} imported from ${n}`,TypeError),ERR_PACKAGE_PATH_NOT_EXPORTED=createError(`ERR_PACKAGE_PATH_NOT_EXPORTED`,(e,t,n)=>t===`.`?`No "exports" main defined in ${e}package.json${n?` imported from ${n}`:``}`:`Package subpath '${t}' is not defined by "exports" in ${e}package.json${n?` imported from ${n}`:``}`,Error),ERR_UNSUPPORTED_DIR_IMPORT=createError(`ERR_UNSUPPORTED_DIR_IMPORT`,`Directory import '%s' is not supported resolving ES modules imported from %s`,Error),ERR_UNSUPPORTED_RESOLVE_REQUEST=createError(`ERR_UNSUPPORTED_RESOLVE_REQUEST`,`Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.`,TypeError),ERR_UNKNOWN_FILE_EXTENSION=createError(`ERR_UNKNOWN_FILE_EXTENSION`,(e,t)=>`Unknown file extension "${e}" for ${t}`,TypeError);createError(`ERR_INVALID_ARG_VALUE`,(e,t,n=`is invalid`)=>{let r=inspect(t);return r.length>128&&(r=`${r.slice(0,128)}...`),`The ${e.includes(`.`)?`property`:`argument`} '${e}' ${n}. Received ${r}`},TypeError);const hasOwnProperty$1={}.hasOwnProperty,cache=new Map;function read(t,{base:n,specifier:r}){let i=cache.get(t);if(i)return i;let o;try{o=fs.readFileSync(path.toNamespacedPath(t),`utf8`)}catch(e){let t=e;if(t.code!==`ENOENT`)throw t}let c={exists:!1,pjsonPath:t,main:void 0,name:void 0,type:`none`,exports:void 0,imports:void 0};if(o!==void 0){let e;try{e=JSON.parse(o)}catch(e){let i=new ERR_INVALID_PACKAGE_CONFIG(t,(n?`"${r}" from `:``)+fileURLToPath(n||r),e.message);throw i.cause=e,i}c.exists=!0,hasOwnProperty$1.call(e,`name`)&&typeof e.name==`string`&&(c.name=e.name),hasOwnProperty$1.call(e,`main`)&&typeof e.main==`string`&&(c.main=e.main),hasOwnProperty$1.call(e,`exports`)&&(c.exports=e.exports),hasOwnProperty$1.call(e,`imports`)&&(c.imports=e.imports),hasOwnProperty$1.call(e,`type`)&&(e.type===`commonjs`||e.type===`module`)&&(c.type=e.type)}return cache.set(t,c),c}function getPackageScopeConfig(e){let t=new URL(`package.json`,e);for(;!t.pathname.endsWith(`node_modules/package.json`);){let n=read(fileURLToPath(t),{specifier:e});if(n.exists)return n;let r=t;if(t=new URL(`../package.json`,t),t.pathname===r.pathname)break}return{pjsonPath:fileURLToPath(t),exists:!1,type:`none`}}const hasOwnProperty={}.hasOwnProperty,extensionFormatMap={__proto__:null,".json":`json`,".cjs":`commonjs`,".cts":`commonjs`,".js":`module`,".ts":`module`,".mts":`module`,".mjs":`module`},protocolHandlers={__proto__:null,"data:":getDataProtocolModuleFormat,"file:":getFileProtocolModuleFormat,"node:":()=>`builtin`};function mimeToFormat(e){return e&&/\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(e)?`module`:e===`application/json`?`json`:null}function getDataProtocolModuleFormat(e){let{1:t}=/^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(e.pathname)||[null,null,null];return mimeToFormat(t)}function extname(e){let t=e.pathname,n=t.length;for(;n--;){let e=t.codePointAt(n);if(e===47)return``;if(e===46)return t.codePointAt(n-1)===47?``:t.slice(n)}return``}function getFileProtocolModuleFormat(e,t,n){let r=extname(e);if(r===`.js`){let{type:t}=getPackageScopeConfig(e);return t===`none`?`commonjs`:t}if(r===``){let{type:t}=getPackageScopeConfig(e);return t===`none`||t===`commonjs`?`commonjs`:`module`}let i=extensionFormatMap[r];if(i)return i;if(!n)throw new ERR_UNKNOWN_FILE_EXTENSION(r,fileURLToPath(e))}function defaultGetFormatWithoutErrors(e,t){let n=e.protocol;return hasOwnProperty.call(protocolHandlers,n)&&protocolHandlers[n](e,t,!0)||null}const RegExpPrototypeSymbolReplace=RegExp.prototype[Symbol.replace],own={}.hasOwnProperty,invalidSegmentRegEx=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i,deprecatedInvalidSegmentRegEx=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i,invalidPackageNameRegEx=/^\.|%|\\/,patternRegEx=/\*/g,encodedSeparatorRegEx=/%2f|%5c/i,emittedPackageWarnings=new Set,doubleSlashRegEx=/[/\\]{2}/;function emitInvalidSegmentDeprecation(e,t,n,r,i,o,s){if(process$1.noDeprecation)return;let c=fileURLToPath(r),l=doubleSlashRegEx.exec(s?e:t)!==null;process$1.emitWarning(`Use of deprecated ${l?`double slash`:`leading or trailing slash matching`} resolving "${e}" for module request "${t}" ${t===n?``:`matched to "${n}" `}in the "${i?`imports`:`exports`}" field module resolution of the package at ${c}${o?` imported from ${fileURLToPath(o)}`:``}.`,`DeprecationWarning`,`DEP0166`)}function emitLegacyIndexDeprecation(e,t,n,r){if(process$1.noDeprecation||defaultGetFormatWithoutErrors(e,{parentURL:n.href})!==`module`)return;let o=fileURLToPath(e.href),c=fileURLToPath(new URL$1(`.`,t)),l=fileURLToPath(n);r?path.resolve(c,r)!==o&&process$1.emitWarning(`Package ${c} has a "main" field set to "${r}", excluding the full filename and extension to the resolved file at "${o.slice(c.length)}", imported from ${l}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`,`DeprecationWarning`,`DEP0151`):process$1.emitWarning(`No "main" or "exports" field defined in the package.json for ${c} resolving the main entry point "${o.slice(c.length)}", imported from ${l}.\nDefault "index" lookups for the main are deprecated for ES modules.`,`DeprecationWarning`,`DEP0151`)}function tryStatSync(e){try{return statSync(e)}catch{}}function fileExists(e){let t=statSync(e,{throwIfNoEntry:!1});return(t?t.isFile():void 0)??!1}function legacyMainResolve(e,t,n){let r;if(t.main!==void 0){if(r=new URL$1(t.main,e),fileExists(r))return r;let a=[`./${t.main}.js`,`./${t.main}.json`,`./${t.main}.node`,`./${t.main}/index.js`,`./${t.main}/index.json`,`./${t.main}/index.node`],o=-1;for(;++o<a.length&&(r=new URL$1(a[o],e),!fileExists(r));)r=void 0;if(r)return emitLegacyIndexDeprecation(r,e,n,t.main),r}let o=[`./index.js`,`./index.json`,`./index.node`],s=-1;for(;++s<o.length&&(r=new URL$1(o[s],e),!fileExists(r));)r=void 0;if(r)return emitLegacyIndexDeprecation(r,e,n,t.main),r;throw new ERR_MODULE_NOT_FOUND(fileURLToPath(new URL$1(`.`,e)),fileURLToPath(n))}function finalizeResolution(e,t,r){if(encodedSeparatorRegEx.exec(e.pathname)!==null)throw new ERR_INVALID_MODULE_SPECIFIER(e.pathname,String.raw`must not include encoded "/" or "\" characters`,fileURLToPath(t));let i;try{i=fileURLToPath(e)}catch(n){throw Object.defineProperty(n,`input`,{value:String(e)}),Object.defineProperty(n,`module`,{value:String(t)}),n}let c=tryStatSync(i.endsWith(`/`)?i.slice(-1):i);if(c&&c.isDirectory()){let n=new ERR_UNSUPPORTED_DIR_IMPORT(i,fileURLToPath(t));throw n.url=String(e),n}if(!c||!c.isFile()){let n=new ERR_MODULE_NOT_FOUND(i||e.pathname,t&&fileURLToPath(t),!0);throw n.url=String(e),n}if(!r){let t=realpathSync(i),{search:r,hash:a}=e;e=pathToFileURL(t+(i.endsWith(path.sep)?`/`:``)),e.search=r,e.hash=a}return e}function importNotDefined(e,t,n){return new ERR_PACKAGE_IMPORT_NOT_DEFINED(e,t&&fileURLToPath(new URL$1(`.`,t)),fileURLToPath(n))}function exportsNotFound(e,t,n){return new ERR_PACKAGE_PATH_NOT_EXPORTED(fileURLToPath(new URL$1(`.`,t)),e,n&&fileURLToPath(n))}function throwInvalidSubpath(e,t,n,r,i){throw new ERR_INVALID_MODULE_SPECIFIER(e,`request is not a valid match in pattern "${t}" for the "${r?`imports`:`exports`}" resolution of ${fileURLToPath(n)}`,i&&fileURLToPath(i))}function invalidPackageTarget(e,t,n,r,o){return t=typeof t==`object`&&t?JSON.stringify(t,null,``):`${t}`,new ERR_INVALID_PACKAGE_TARGET(fileURLToPath(new URL$1(`.`,n)),e,t,r,o&&fileURLToPath(o))}function resolvePackageTargetString(e,t,n,r,a,o,s,c,l){if(t!==``&&!o&&e.at(-1)!==`/`)throw invalidPackageTarget(n,e,r,s,a);if(!e.startsWith(`./`)){if(s&&!e.startsWith(`../`)&&!e.startsWith(`/`)){let n=!1;try{new URL$1(e),n=!0}catch{}if(!n)return packageResolve(o?RegExpPrototypeSymbolReplace.call(patternRegEx,e,()=>t):e+t,r,l)}throw invalidPackageTarget(n,e,r,s,a)}if(invalidSegmentRegEx.exec(e.slice(2))!==null)if(deprecatedInvalidSegmentRegEx.exec(e.slice(2))===null){if(!c){let i=o?n.replace(`*`,()=>t):n+t;emitInvalidSegmentDeprecation(o?RegExpPrototypeSymbolReplace.call(patternRegEx,e,()=>t):e,i,n,r,s,a,!0)}}else throw invalidPackageTarget(n,e,r,s,a);let u=new URL$1(e,r),d=u.pathname,f=new URL$1(`.`,r).pathname;if(!d.startsWith(f))throw invalidPackageTarget(n,e,r,s,a);if(t===``)return u;if(invalidSegmentRegEx.exec(t)!==null){let i=o?n.replace(`*`,()=>t):n+t;deprecatedInvalidSegmentRegEx.exec(t)===null?c||emitInvalidSegmentDeprecation(o?RegExpPrototypeSymbolReplace.call(patternRegEx,e,()=>t):e,i,n,r,s,a,!1):throwInvalidSubpath(i,n,r,s,a)}return o?new URL$1(RegExpPrototypeSymbolReplace.call(patternRegEx,u.href,()=>t)):new URL$1(t,u)}function isArrayIndex(e){let t=Number(e);return`${t}`===e?t>=0&&t<4294967295:!1}function resolvePackageTarget(e,t,n,r,i,o,s,c,l){if(typeof t==`string`)return resolvePackageTargetString(t,n,r,e,i,o,s,c,l);if(Array.isArray(t)){let a=t;if(a.length===0)return null;let u,d=-1;for(;++d<a.length;){let t=a[d],f;try{f=resolvePackageTarget(e,t,n,r,i,o,s,c,l)}catch(e){let t=e;if(u=t,t.code===`ERR_INVALID_PACKAGE_TARGET`)continue;throw e}if(f!==void 0){if(f===null){u=null;continue}return f}}if(u==null)return null;throw u}if(typeof t==`object`&&t){let u=Object.getOwnPropertyNames(t),d=-1;for(;++d<u.length;){let t=u[d];if(isArrayIndex(t))throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(e),fileURLToPath(i),`"exports" cannot contain numeric property keys.`)}for(d=-1;++d<u.length;){let a=u[d];if(a===`default`||l&&l.has(a)){let u=t[a],d=resolvePackageTarget(e,u,n,r,i,o,s,c,l);if(d===void 0)continue;return d}}return null}if(t===null)return null;throw invalidPackageTarget(r,t,e,s,i)}function isConditionalExportsMainSugar(e,t,n){if(typeof e==`string`||Array.isArray(e))return!0;if(typeof e!=`object`||!e)return!1;let r=Object.getOwnPropertyNames(e),i=!1,o=0,s=-1;for(;++s<r.length;){let e=r[s],c=e===``||e[0]!==`.`;if(o++===0)i=c;else if(i!==c)throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(t),fileURLToPath(n),`"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`)}return i}function emitTrailingSlashPatternDeprecation(e,t,n){if(process$1.noDeprecation)return;let r=fileURLToPath(t);emittedPackageWarnings.has(r+`|`+e)||(emittedPackageWarnings.add(r+`|`+e),process$1.emitWarning(`Use of deprecated trailing slash pattern mapping "${e}" in the "exports" field module resolution of the package at ${r}${n?` imported from ${fileURLToPath(n)}`:``}. Mapping specifiers ending in "/" is no longer supported.`,`DeprecationWarning`,`DEP0155`))}function packageExportsResolve(e,t,n,r,i){let a=n.exports;if(isConditionalExportsMainSugar(a,e,r)&&(a={".":a}),own.call(a,t)&&!t.includes(`*`)&&!t.endsWith(`/`)){let n=a[t],o=resolvePackageTarget(e,n,``,t,r,!1,!1,!1,i);if(o==null)throw exportsNotFound(t,e,r);return o}let o=``,s=``,c=Object.getOwnPropertyNames(a),l=-1;for(;++l<c.length;){let n=c[l],i=n.indexOf(`*`);if(i!==-1&&t.startsWith(n.slice(0,i))){t.endsWith(`/`)&&emitTrailingSlashPatternDeprecation(t,e,r);let a=n.slice(i+1);t.length>=n.length&&t.endsWith(a)&&patternKeyCompare(o,n)===1&&n.lastIndexOf(`*`)===i&&(o=n,s=t.slice(i,t.length-a.length))}}if(o){let n=a[o],c=resolvePackageTarget(e,n,s,o,r,!0,!1,t.endsWith(`/`),i);if(c==null)throw exportsNotFound(t,e,r);return c}throw exportsNotFound(t,e,r)}function patternKeyCompare(e,t){let n=e.indexOf(`*`),r=t.indexOf(`*`),i=n===-1?e.length:n+1,a=r===-1?t.length:r+1;return i>a?-1:a>i||n===-1?1:r===-1||e.length>t.length?-1:t.length>e.length?1:0}function packageImportsResolve(e,t,n){if(e===`#`||e.startsWith(`#/`)||e.endsWith(`/`))throw new ERR_INVALID_MODULE_SPECIFIER(e,`is not a valid internal imports specifier name`,fileURLToPath(t));let r,i=getPackageScopeConfig(t);if(i.exists){r=pathToFileURL(i.pjsonPath);let a=i.imports;if(a)if(own.call(a,e)&&!e.includes(`*`)){let i=resolvePackageTarget(r,a[e],``,e,t,!1,!0,!1,n);if(i!=null)return i}else{let i=``,o=``,s=Object.getOwnPropertyNames(a),c=-1;for(;++c<s.length;){let t=s[c],n=t.indexOf(`*`);if(n!==-1&&e.startsWith(t.slice(0,-1))){let r=t.slice(n+1);e.length>=t.length&&e.endsWith(r)&&patternKeyCompare(i,t)===1&&t.lastIndexOf(`*`)===n&&(i=t,o=e.slice(n,e.length-r.length))}}if(i){let e=a[i],s=resolvePackageTarget(r,e,o,i,t,!0,!0,!1,n);if(s!=null)return s}}}throw importNotDefined(e,r,t)}function parsePackageName(e,t){let n=e.indexOf(`/`),r=!0,i=!1;e[0]===`@`&&(i=!0,n===-1||e.length===0?r=!1:n=e.indexOf(`/`,n+1));let o=n===-1?e:e.slice(0,n);if(invalidPackageNameRegEx.exec(o)!==null&&(r=!1),!r)throw new ERR_INVALID_MODULE_SPECIFIER(e,`is not a valid package name`,fileURLToPath(t));return{packageName:o,packageSubpath:`.`+(n===-1?``:e.slice(n)),isScoped:i}}function packageResolve(e,t,n){if(nodeBuiltins.includes(e))return new URL$1(`node:`+e);let{packageName:r,packageSubpath:s,isScoped:c}=parsePackageName(e,t),l=getPackageScopeConfig(t);if(l.exists&&l.name===r&&l.exports!==void 0&&l.exports!==null)return packageExportsResolve(pathToFileURL(l.pjsonPath),s,l,t,n);let u=new URL$1(`./node_modules/`+r+`/package.json`,t),d=fileURLToPath(u),f;do{let o=tryStatSync(d.slice(0,-13));if(!o||!o.isDirectory()){f=d,u=new URL$1((c?`../../../../node_modules/`:`../../../node_modules/`)+r+`/package.json`,u),d=fileURLToPath(u);continue}let l=read(d,{base:t,specifier:e});return l.exports!==void 0&&l.exports!==null?packageExportsResolve(u,s,l,t,n):s===`.`?legacyMainResolve(u,l,t):new URL$1(s,u)}while(d.length!==f.length);throw new ERR_MODULE_NOT_FOUND(r,fileURLToPath(t),!1)}function isRelativeSpecifier(e){return e[0]===`.`&&(e.length===1||e[1]===`/`||e[1]===`.`&&(e.length===2||e[2]===`/`))}function shouldBeTreatedAsRelativeOrAbsolutePath(e){return e===``?!1:e[0]===`/`?!0:isRelativeSpecifier(e)}function moduleResolve(e,t,n,r){let a=t.protocol,o=a===`data:`,s;if(shouldBeTreatedAsRelativeOrAbsolutePath(e))try{s=new URL$1(e,t)}catch(n){let r=new ERR_UNSUPPORTED_RESOLVE_REQUEST(e,t);throw r.cause=n,r}else if(a===`file:`&&e[0]===`#`)s=packageImportsResolve(e,t,n);else try{s=new URL$1(e)}catch(r){if(o&&!nodeBuiltins.includes(e)){let n=new ERR_UNSUPPORTED_RESOLVE_REQUEST(e,t);throw n.cause=r,n}s=packageResolve(e,t,n)}return assert.ok(s!==void 0,`expected to be defined`),s.protocol===`file:`?finalizeResolution(s,t,r):s}const DEFAULT_CONDITIONS_SET=new Set([`node`,`import`]),isWindows=process.platform===`win32`,globalCache=globalThis.__EXSOLVE_CACHE__||=new Map;function resolveModuleURL(e,r){let i=_parseInput(e);if(`external`in i)return i.external;let a=i.specifier,s=i.url,c=i.absolutePath,l,u;if(r?.cache!==!1&&(l=_cacheKey(c||a,r),u=r?.cache&&typeof r?.cache==`object`?r.cache:globalCache),u){let e=u.get(l);if(typeof e==`string`)return e;if(e instanceof Error){if(r?.try)return;throw e}}if(c)try{let e=lstatSync(c);if(e.isSymbolicLink()&&(c=realpathSync(c),s=pathToFileURL(c)),e.isFile())return u&&u.set(l,s.href),s.href}catch(e){if(e?.code!==`ENOENT`)throw u&&u.set(l,e),e}let d=r?.conditions?new Set(r.conditions):DEFAULT_CONDITIONS_SET,f=a||s.href,p=_normalizeBases(r?.from),m=r?.suffixes||[``],h=r?.extensions?[``,...r.extensions]:[``],g;for(let e of p){for(let t of m){let n=_join(f,t);n===`.`&&(n+=`/.`);for(let t of h)if(g=_tryModuleResolve(n+t,e,d),g)break;if(g)break}if(g)break}if(!g){let t=Error(`Cannot resolve module "${e}" (from: ${p.map(e=>_fmtPath(e)).join(`, `)})`);if(t.code=`ERR_MODULE_NOT_FOUND`,u&&u.set(l,t),r?.try)return;throw t}return u&&u.set(l,g.href),g.href}function resolveModulePath(e,t){let n=resolveModuleURL(e,t);if(!n||!n.startsWith(`file://`)&&t?.try)return;let r=fileURLToPath(n);return isWindows?_normalizeWinPath(r):r}function _tryModuleResolve(e,t,n){try{return moduleResolve(e,t,n)}catch{}}function _normalizeBases(e){let t=(Array.isArray(e)?e:[e]).flatMap(e=>_normalizeBase(e));return t.length===0?[pathToFileURL(`./`)]:t}function _normalizeBase(e){if(!e)return[];if(_isURL(e))return[e];if(typeof e!=`string`)return[];if(/^(?:node|data|http|https|file):/.test(e))return new URL(e);try{return e.endsWith(`/`)||statSync(e).isDirectory()?pathToFileURL(e+`/`):pathToFileURL(e)}catch{return[pathToFileURL(e+`/`),pathToFileURL(e)]}}function _fmtPath(e){try{return fileURLToPath(e)}catch{return e}}function _cacheKey(e,t){return JSON.stringify([e,(t?.conditions||[`node`,`import`]).sort(),t?.extensions,t?.from,t?.suffixes])}function _join(e,t){return!e||!t||t===`/`?e:(e.endsWith(`/`)?e:e+`/`)+(t.startsWith(`/`)?t.slice(1):t)}function _normalizeWinPath(e){return e.replace(/\\/g,`/`).replace(/^[a-z]:\//,e=>e.toUpperCase())}function _isURL(e){return e instanceof URL||e?.constructor?.name===`URL`}function _parseInput(e){if(typeof e==`string`){if(e.startsWith(`file:`)){let t=new URL(e);return{url:t,absolutePath:fileURLToPath(t)}}return isAbsolute(e)?{url:pathToFileURL(e),absolutePath:e}:/^(?:node|data|http|https):/.test(e)?{external:e}:nodeBuiltins.includes(e)&&!e.includes(`:`)?{external:`node:${e}`}:{specifier:e}}if(_isURL(e))return e.protocol===`file:`?{url:e,absolutePath:fileURLToPath(e)}:{external:e.href};throw TypeError("id must be a `string` or `URL`")}export{resolveModulePath as t};
1
+ import fs, { lstatSync, realpathSync, statSync } from "node:fs";
2
+ import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
3
+ import path, { isAbsolute } from "node:path";
4
+ import assert from "node:assert";
5
+ import process$1 from "node:process";
6
+ import v8 from "node:v8";
7
+ import { format, inspect } from "node:util";
8
+ const nodeBuiltins = `_http_agent._http_client._http_common._http_incoming._http_outgoing._http_server._stream_duplex._stream_passthrough._stream_readable._stream_transform._stream_wrap._stream_writable._tls_common._tls_wrap.assert.assert/strict.async_hooks.buffer.child_process.cluster.console.constants.crypto.dgram.diagnostics_channel.dns.dns/promises.domain.events.fs.fs/promises.http.http2.https.inspector.inspector/promises.module.net.os.path.path/posix.path/win32.perf_hooks.process.punycode.querystring.readline.readline/promises.repl.stream.stream/consumers.stream/promises.stream/web.string_decoder.sys.timers.timers/promises.tls.trace_events.tty.url.util.util/types.v8.vm.wasi.worker_threads.zlib`.split(`.`), own$1 = {}.hasOwnProperty, classRegExp = /^([A-Z][a-z\d]*)+$/, kTypes = new Set([
9
+ `string`,
10
+ `function`,
11
+ `number`,
12
+ `object`,
13
+ `Function`,
14
+ `Object`,
15
+ `boolean`,
16
+ `bigint`,
17
+ `symbol`
18
+ ]), messages = /* @__PURE__ */ new Map();
19
+ let userStackTraceLimit;
20
+ function formatList(e, t = `and`) {
21
+ return e.length < 3 ? e.join(` ${t} `) : `${e.slice(0, -1).join(`, `)}, ${t} ${e.at(-1)}`;
22
+ }
23
+ function createError(e, t, n) {
24
+ return messages.set(e, t), makeNodeErrorWithCode(n, e);
25
+ }
26
+ function makeNodeErrorWithCode(e, t) {
27
+ return function(...n) {
28
+ let r = Error.stackTraceLimit;
29
+ isErrorStackTraceLimitWritable() && (Error.stackTraceLimit = 0);
30
+ let i = new e();
31
+ isErrorStackTraceLimitWritable() && (Error.stackTraceLimit = r);
32
+ let a = getMessage(t, n, i);
33
+ return Object.defineProperties(i, {
34
+ message: {
35
+ value: a,
36
+ enumerable: !1,
37
+ writable: !0,
38
+ configurable: !0
39
+ },
40
+ toString: {
41
+ value() {
42
+ return `${this.name} [${t}]: ${this.message}`;
43
+ },
44
+ enumerable: !1,
45
+ writable: !0,
46
+ configurable: !0
47
+ }
48
+ }), captureLargerStackTrace(i), i.code = t, i;
49
+ };
50
+ }
51
+ function isErrorStackTraceLimitWritable() {
52
+ try {
53
+ if (v8.startupSnapshot.isBuildingSnapshot()) return !1;
54
+ } catch {}
55
+ let e = Object.getOwnPropertyDescriptor(Error, `stackTraceLimit`);
56
+ return e === void 0 ? Object.isExtensible(Error) : own$1.call(e, `writable`) && e.writable !== void 0 ? e.writable : e.set !== void 0;
57
+ }
58
+ function hideStackFrames(e) {
59
+ let t = `__node_internal_` + e.name;
60
+ return Object.defineProperty(e, `name`, { value: t }), e;
61
+ }
62
+ const captureLargerStackTrace = hideStackFrames(function(e) {
63
+ let t = isErrorStackTraceLimitWritable();
64
+ return t && (userStackTraceLimit = Error.stackTraceLimit, Error.stackTraceLimit = Infinity), Error.captureStackTrace(e), t && (Error.stackTraceLimit = userStackTraceLimit), e;
65
+ });
66
+ function getMessage(e, t, n) {
67
+ let r = messages.get(e);
68
+ if (assert.ok(r !== void 0, "expected `message` to be found"), typeof r == `function`) return assert.ok(r.length <= t.length, `Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${r.length}).`), Reflect.apply(r, n, t);
69
+ let i = /%[dfijoOs]/g, a = 0;
70
+ for (; i.exec(r) !== null;) a++;
71
+ return assert.ok(a === t.length, `Code: ${e}; The provided arguments length (${t.length}) does not match the required ones (${a}).`), t.length === 0 ? r : (t.unshift(r), Reflect.apply(format, null, t));
72
+ }
73
+ function determineSpecificType(e) {
74
+ if (e == null) return String(e);
75
+ if (typeof e == `function` && e.name) return `function ${e.name}`;
76
+ if (typeof e == `object`) return e.constructor && e.constructor.name ? `an instance of ${e.constructor.name}` : `${inspect(e, { depth: -1 })}`;
77
+ let t = inspect(e, { colors: !1 });
78
+ return t.length > 28 && (t = `${t.slice(0, 25)}...`), `type ${typeof e} (${t})`;
79
+ }
80
+ createError(`ERR_INVALID_ARG_TYPE`, (e, t, n) => {
81
+ assert.ok(typeof e == `string`, `'name' must be a string`), Array.isArray(t) || (t = [t]);
82
+ let r = `The `;
83
+ if (e.endsWith(` argument`)) r += `${e} `;
84
+ else {
85
+ let t = e.includes(`.`) ? `property` : `argument`;
86
+ r += `"${e}" ${t} `;
87
+ }
88
+ r += `must be `;
89
+ let i = [], a = [], o = [];
90
+ for (let e of t) assert.ok(typeof e == `string`, `All expected entries have to be of type string`), kTypes.has(e) ? i.push(e.toLowerCase()) : classRegExp.exec(e) === null ? (assert.ok(e !== `object`, `The value "object" should be written as "Object"`), o.push(e)) : a.push(e);
91
+ if (a.length > 0) {
92
+ let e = i.indexOf(`object`);
93
+ e !== -1 && (i.slice(e, 1), a.push(`Object`));
94
+ }
95
+ return i.length > 0 && (r += `${i.length > 1 ? `one of type` : `of type`} ${formatList(i, `or`)}`, (a.length > 0 || o.length > 0) && (r += ` or `)), a.length > 0 && (r += `an instance of ${formatList(a, `or`)}`, o.length > 0 && (r += ` or `)), o.length > 0 && (o.length > 1 ? r += `one of ${formatList(o, `or`)}` : (o[0]?.toLowerCase() !== o[0] && (r += `an `), r += `${o[0]}`)), r += `. Received ${determineSpecificType(n)}`, r;
96
+ }, TypeError);
97
+ const ERR_INVALID_MODULE_SPECIFIER = createError(`ERR_INVALID_MODULE_SPECIFIER`, (e, t, n) => `Invalid module "${e}" ${t}${n ? ` imported from ${n}` : ``}`, TypeError), ERR_INVALID_PACKAGE_CONFIG = createError(`ERR_INVALID_PACKAGE_CONFIG`, (e, t, n) => `Invalid package config ${e}${t ? ` while importing ${t}` : ``}${n ? `. ${n}` : ``}`, Error), ERR_INVALID_PACKAGE_TARGET = createError(`ERR_INVALID_PACKAGE_TARGET`, (e, t, n, r = !1, i) => {
98
+ let a = typeof n == `string` && !r && n.length > 0 && !n.startsWith(`./`);
99
+ return t === `.` ? (assert.ok(r === !1), `Invalid "exports" main target ${JSON.stringify(n)} defined in the package config ${e}package.json${i ? ` imported from ${i}` : ``}${a ? `; targets must start with "./"` : ``}`) : `Invalid "${r ? `imports` : `exports`}" target ${JSON.stringify(n)} defined for '${t}' in the package config ${e}package.json${i ? ` imported from ${i}` : ``}${a ? `; targets must start with "./"` : ``}`;
100
+ }, Error), ERR_MODULE_NOT_FOUND = createError(`ERR_MODULE_NOT_FOUND`, (e, t, n = !1) => `Cannot find ${n ? `module` : `package`} '${e}' imported from ${t}`, Error);
101
+ createError(`ERR_NETWORK_IMPORT_DISALLOWED`, `import of '%s' by %s is not supported: %s`, Error);
102
+ const ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(`ERR_PACKAGE_IMPORT_NOT_DEFINED`, (e, t, n) => `Package import specifier "${e}" is not defined${t ? ` in package ${t || ``}package.json` : ``} imported from ${n}`, TypeError), ERR_PACKAGE_PATH_NOT_EXPORTED = createError(`ERR_PACKAGE_PATH_NOT_EXPORTED`, (e, t, n) => t === `.` ? `No "exports" main defined in ${e}package.json${n ? ` imported from ${n}` : ``}` : `Package subpath '${t}' is not defined by "exports" in ${e}package.json${n ? ` imported from ${n}` : ``}`, Error), ERR_UNSUPPORTED_DIR_IMPORT = createError(`ERR_UNSUPPORTED_DIR_IMPORT`, `Directory import '%s' is not supported resolving ES modules imported from %s`, Error), ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(`ERR_UNSUPPORTED_RESOLVE_REQUEST`, `Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.`, TypeError), ERR_UNKNOWN_FILE_EXTENSION = createError(`ERR_UNKNOWN_FILE_EXTENSION`, (e, t) => `Unknown file extension "${e}" for ${t}`, TypeError);
103
+ createError(`ERR_INVALID_ARG_VALUE`, (e, t, n = `is invalid`) => {
104
+ let r = inspect(t);
105
+ return r.length > 128 && (r = `${r.slice(0, 128)}...`), `The ${e.includes(`.`) ? `property` : `argument`} '${e}' ${n}. Received ${r}`;
106
+ }, TypeError);
107
+ const hasOwnProperty$1 = {}.hasOwnProperty, cache = /* @__PURE__ */ new Map();
108
+ function read(t, { base: n, specifier: r }) {
109
+ let i = cache.get(t);
110
+ if (i) return i;
111
+ let o;
112
+ try {
113
+ o = fs.readFileSync(path.toNamespacedPath(t), `utf8`);
114
+ } catch (e) {
115
+ let t = e;
116
+ if (t.code !== `ENOENT`) throw t;
117
+ }
118
+ let c = {
119
+ exists: !1,
120
+ pjsonPath: t,
121
+ main: void 0,
122
+ name: void 0,
123
+ type: `none`,
124
+ exports: void 0,
125
+ imports: void 0
126
+ };
127
+ if (o !== void 0) {
128
+ let e;
129
+ try {
130
+ e = JSON.parse(o);
131
+ } catch (e) {
132
+ let i = new ERR_INVALID_PACKAGE_CONFIG(t, (n ? `"${r}" from ` : ``) + fileURLToPath(n || r), e.message);
133
+ throw i.cause = e, i;
134
+ }
135
+ c.exists = !0, hasOwnProperty$1.call(e, `name`) && typeof e.name == `string` && (c.name = e.name), hasOwnProperty$1.call(e, `main`) && typeof e.main == `string` && (c.main = e.main), hasOwnProperty$1.call(e, `exports`) && (c.exports = e.exports), hasOwnProperty$1.call(e, `imports`) && (c.imports = e.imports), hasOwnProperty$1.call(e, `type`) && (e.type === `commonjs` || e.type === `module`) && (c.type = e.type);
136
+ }
137
+ return cache.set(t, c), c;
138
+ }
139
+ function getPackageScopeConfig(e) {
140
+ let t = new URL(`package.json`, e);
141
+ for (; !t.pathname.endsWith(`node_modules/package.json`);) {
142
+ let n = read(fileURLToPath(t), { specifier: e });
143
+ if (n.exists) return n;
144
+ let r = t;
145
+ if (t = new URL(`../package.json`, t), t.pathname === r.pathname) break;
146
+ }
147
+ return {
148
+ pjsonPath: fileURLToPath(t),
149
+ exists: !1,
150
+ type: `none`
151
+ };
152
+ }
153
+ const hasOwnProperty = {}.hasOwnProperty, extensionFormatMap = {
154
+ __proto__: null,
155
+ ".json": `json`,
156
+ ".cjs": `commonjs`,
157
+ ".cts": `commonjs`,
158
+ ".js": `module`,
159
+ ".ts": `module`,
160
+ ".mts": `module`,
161
+ ".mjs": `module`
162
+ }, protocolHandlers = {
163
+ __proto__: null,
164
+ "data:": getDataProtocolModuleFormat,
165
+ "file:": getFileProtocolModuleFormat,
166
+ "node:": () => `builtin`
167
+ };
168
+ function mimeToFormat(e) {
169
+ return e && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(e) ? `module` : e === `application/json` ? `json` : null;
170
+ }
171
+ function getDataProtocolModuleFormat(e) {
172
+ let { 1: t } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(e.pathname) || [
173
+ null,
174
+ null,
175
+ null
176
+ ];
177
+ return mimeToFormat(t);
178
+ }
179
+ function extname(e) {
180
+ let t = e.pathname, n = t.length;
181
+ for (; n--;) {
182
+ let e = t.codePointAt(n);
183
+ if (e === 47) return ``;
184
+ if (e === 46) return t.codePointAt(n - 1) === 47 ? `` : t.slice(n);
185
+ }
186
+ return ``;
187
+ }
188
+ function getFileProtocolModuleFormat(e, t, n) {
189
+ let r = extname(e);
190
+ if (r === `.js`) {
191
+ let { type: t } = getPackageScopeConfig(e);
192
+ return t === `none` ? `commonjs` : t;
193
+ }
194
+ if (r === ``) {
195
+ let { type: t } = getPackageScopeConfig(e);
196
+ return t === `none` || t === `commonjs` ? `commonjs` : `module`;
197
+ }
198
+ let i = extensionFormatMap[r];
199
+ if (i) return i;
200
+ if (!n) throw new ERR_UNKNOWN_FILE_EXTENSION(r, fileURLToPath(e));
201
+ }
202
+ function defaultGetFormatWithoutErrors(e, t) {
203
+ let n = e.protocol;
204
+ return hasOwnProperty.call(protocolHandlers, n) && protocolHandlers[n](e, t, !0) || null;
205
+ }
206
+ const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace], own = {}.hasOwnProperty, invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i, deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i, invalidPackageNameRegEx = /^\.|%|\\/, patternRegEx = /\*/g, encodedSeparatorRegEx = /%2f|%5c/i, emittedPackageWarnings = /* @__PURE__ */ new Set(), doubleSlashRegEx = /[/\\]{2}/;
207
+ function emitInvalidSegmentDeprecation(e, t, n, r, i, o, s) {
208
+ if (process$1.noDeprecation) return;
209
+ let c = fileURLToPath(r), l = doubleSlashRegEx.exec(s ? e : t) !== null;
210
+ process$1.emitWarning(`Use of deprecated ${l ? `double slash` : `leading or trailing slash matching`} resolving "${e}" for module request "${t}" ${t === n ? `` : `matched to "${n}" `}in the "${i ? `imports` : `exports`}" field module resolution of the package at ${c}${o ? ` imported from ${fileURLToPath(o)}` : ``}.`, `DeprecationWarning`, `DEP0166`);
211
+ }
212
+ function emitLegacyIndexDeprecation(e, t, n, r) {
213
+ if (process$1.noDeprecation || defaultGetFormatWithoutErrors(e, { parentURL: n.href }) !== `module`) return;
214
+ let o = fileURLToPath(e.href), c = fileURLToPath(new URL$1(`.`, t)), l = fileURLToPath(n);
215
+ r ? path.resolve(c, r) !== o && process$1.emitWarning(`Package ${c} has a "main" field set to "${r}", excluding the full filename and extension to the resolved file at "${o.slice(c.length)}", imported from ${l}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`, `DeprecationWarning`, `DEP0151`) : process$1.emitWarning(`No "main" or "exports" field defined in the package.json for ${c} resolving the main entry point "${o.slice(c.length)}", imported from ${l}.\nDefault "index" lookups for the main are deprecated for ES modules.`, `DeprecationWarning`, `DEP0151`);
216
+ }
217
+ function tryStatSync(e) {
218
+ try {
219
+ return statSync(e);
220
+ } catch {}
221
+ }
222
+ function fileExists(e) {
223
+ let t = statSync(e, { throwIfNoEntry: !1 });
224
+ return (t ? t.isFile() : void 0) ?? !1;
225
+ }
226
+ function legacyMainResolve(e, t, n) {
227
+ let r;
228
+ if (t.main !== void 0) {
229
+ if (r = new URL$1(t.main, e), fileExists(r)) return r;
230
+ let a = [
231
+ `./${t.main}.js`,
232
+ `./${t.main}.json`,
233
+ `./${t.main}.node`,
234
+ `./${t.main}/index.js`,
235
+ `./${t.main}/index.json`,
236
+ `./${t.main}/index.node`
237
+ ], o = -1;
238
+ for (; ++o < a.length && (r = new URL$1(a[o], e), !fileExists(r));) r = void 0;
239
+ if (r) return emitLegacyIndexDeprecation(r, e, n, t.main), r;
240
+ }
241
+ let o = [
242
+ `./index.js`,
243
+ `./index.json`,
244
+ `./index.node`
245
+ ], s = -1;
246
+ for (; ++s < o.length && (r = new URL$1(o[s], e), !fileExists(r));) r = void 0;
247
+ if (r) return emitLegacyIndexDeprecation(r, e, n, t.main), r;
248
+ throw new ERR_MODULE_NOT_FOUND(fileURLToPath(new URL$1(`.`, e)), fileURLToPath(n));
249
+ }
250
+ function finalizeResolution(e, t, r) {
251
+ if (encodedSeparatorRegEx.exec(e.pathname) !== null) throw new ERR_INVALID_MODULE_SPECIFIER(e.pathname, String.raw`must not include encoded "/" or "\" characters`, fileURLToPath(t));
252
+ let i;
253
+ try {
254
+ i = fileURLToPath(e);
255
+ } catch (n) {
256
+ throw Object.defineProperty(n, `input`, { value: String(e) }), Object.defineProperty(n, `module`, { value: String(t) }), n;
257
+ }
258
+ let c = tryStatSync(i.endsWith(`/`) ? i.slice(-1) : i);
259
+ if (c && c.isDirectory()) {
260
+ let n = new ERR_UNSUPPORTED_DIR_IMPORT(i, fileURLToPath(t));
261
+ throw n.url = String(e), n;
262
+ }
263
+ if (!c || !c.isFile()) {
264
+ let n = new ERR_MODULE_NOT_FOUND(i || e.pathname, t && fileURLToPath(t), !0);
265
+ throw n.url = String(e), n;
266
+ }
267
+ if (!r) {
268
+ let t = realpathSync(i), { search: r, hash: a } = e;
269
+ e = pathToFileURL(t + (i.endsWith(path.sep) ? `/` : ``)), e.search = r, e.hash = a;
270
+ }
271
+ return e;
272
+ }
273
+ function importNotDefined(e, t, n) {
274
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(e, t && fileURLToPath(new URL$1(`.`, t)), fileURLToPath(n));
275
+ }
276
+ function exportsNotFound(e, t, n) {
277
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED(fileURLToPath(new URL$1(`.`, t)), e, n && fileURLToPath(n));
278
+ }
279
+ function throwInvalidSubpath(e, t, n, r, i) {
280
+ throw new ERR_INVALID_MODULE_SPECIFIER(e, `request is not a valid match in pattern "${t}" for the "${r ? `imports` : `exports`}" resolution of ${fileURLToPath(n)}`, i && fileURLToPath(i));
281
+ }
282
+ function invalidPackageTarget(e, t, n, r, o) {
283
+ return t = typeof t == `object` && t ? JSON.stringify(t, null, ``) : `${t}`, new ERR_INVALID_PACKAGE_TARGET(fileURLToPath(new URL$1(`.`, n)), e, t, r, o && fileURLToPath(o));
284
+ }
285
+ function resolvePackageTargetString(e, t, n, r, a, o, s, c, l) {
286
+ if (t !== `` && !o && e.at(-1) !== `/`) throw invalidPackageTarget(n, e, r, s, a);
287
+ if (!e.startsWith(`./`)) {
288
+ if (s && !e.startsWith(`../`) && !e.startsWith(`/`)) {
289
+ let n = !1;
290
+ try {
291
+ new URL$1(e), n = !0;
292
+ } catch {}
293
+ if (!n) return packageResolve(o ? RegExpPrototypeSymbolReplace.call(patternRegEx, e, () => t) : e + t, r, l);
294
+ }
295
+ throw invalidPackageTarget(n, e, r, s, a);
296
+ }
297
+ if (invalidSegmentRegEx.exec(e.slice(2)) !== null) if (deprecatedInvalidSegmentRegEx.exec(e.slice(2)) === null) {
298
+ if (!c) {
299
+ let i = o ? n.replace(`*`, () => t) : n + t;
300
+ emitInvalidSegmentDeprecation(o ? RegExpPrototypeSymbolReplace.call(patternRegEx, e, () => t) : e, i, n, r, s, a, !0);
301
+ }
302
+ } else throw invalidPackageTarget(n, e, r, s, a);
303
+ let u = new URL$1(e, r), d = u.pathname, f = new URL$1(`.`, r).pathname;
304
+ if (!d.startsWith(f)) throw invalidPackageTarget(n, e, r, s, a);
305
+ if (t === ``) return u;
306
+ if (invalidSegmentRegEx.exec(t) !== null) {
307
+ let i = o ? n.replace(`*`, () => t) : n + t;
308
+ deprecatedInvalidSegmentRegEx.exec(t) === null ? c || emitInvalidSegmentDeprecation(o ? RegExpPrototypeSymbolReplace.call(patternRegEx, e, () => t) : e, i, n, r, s, a, !1) : throwInvalidSubpath(i, n, r, s, a);
309
+ }
310
+ return o ? new URL$1(RegExpPrototypeSymbolReplace.call(patternRegEx, u.href, () => t)) : new URL$1(t, u);
311
+ }
312
+ function isArrayIndex(e) {
313
+ let t = Number(e);
314
+ return `${t}` === e ? t >= 0 && t < 4294967295 : !1;
315
+ }
316
+ function resolvePackageTarget(e, t, n, r, i, o, s, c, l) {
317
+ if (typeof t == `string`) return resolvePackageTargetString(t, n, r, e, i, o, s, c, l);
318
+ if (Array.isArray(t)) {
319
+ let a = t;
320
+ if (a.length === 0) return null;
321
+ let u, d = -1;
322
+ for (; ++d < a.length;) {
323
+ let t = a[d], f;
324
+ try {
325
+ f = resolvePackageTarget(e, t, n, r, i, o, s, c, l);
326
+ } catch (e) {
327
+ let t = e;
328
+ if (u = t, t.code === `ERR_INVALID_PACKAGE_TARGET`) continue;
329
+ throw e;
330
+ }
331
+ if (f !== void 0) {
332
+ if (f === null) {
333
+ u = null;
334
+ continue;
335
+ }
336
+ return f;
337
+ }
338
+ }
339
+ if (u == null) return null;
340
+ throw u;
341
+ }
342
+ if (typeof t == `object` && t) {
343
+ let u = Object.getOwnPropertyNames(t), d = -1;
344
+ for (; ++d < u.length;) {
345
+ let t = u[d];
346
+ if (isArrayIndex(t)) throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(e), fileURLToPath(i), `"exports" cannot contain numeric property keys.`);
347
+ }
348
+ for (d = -1; ++d < u.length;) {
349
+ let a = u[d];
350
+ if (a === `default` || l && l.has(a)) {
351
+ let u = t[a], d = resolvePackageTarget(e, u, n, r, i, o, s, c, l);
352
+ if (d === void 0) continue;
353
+ return d;
354
+ }
355
+ }
356
+ return null;
357
+ }
358
+ if (t === null) return null;
359
+ throw invalidPackageTarget(r, t, e, s, i);
360
+ }
361
+ function isConditionalExportsMainSugar(e, t, n) {
362
+ if (typeof e == `string` || Array.isArray(e)) return !0;
363
+ if (typeof e != `object` || !e) return !1;
364
+ let r = Object.getOwnPropertyNames(e), i = !1, o = 0, s = -1;
365
+ for (; ++s < r.length;) {
366
+ let e = r[s], c = e === `` || e[0] !== `.`;
367
+ if (o++ === 0) i = c;
368
+ else if (i !== c) throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(t), fileURLToPath(n), `"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`);
369
+ }
370
+ return i;
371
+ }
372
+ function emitTrailingSlashPatternDeprecation(e, t, n) {
373
+ if (process$1.noDeprecation) return;
374
+ let r = fileURLToPath(t);
375
+ emittedPackageWarnings.has(r + `|` + e) || (emittedPackageWarnings.add(r + `|` + e), process$1.emitWarning(`Use of deprecated trailing slash pattern mapping "${e}" in the "exports" field module resolution of the package at ${r}${n ? ` imported from ${fileURLToPath(n)}` : ``}. Mapping specifiers ending in "/" is no longer supported.`, `DeprecationWarning`, `DEP0155`));
376
+ }
377
+ function packageExportsResolve(e, t, n, r, i) {
378
+ let a = n.exports;
379
+ if (isConditionalExportsMainSugar(a, e, r) && (a = { ".": a }), own.call(a, t) && !t.includes(`*`) && !t.endsWith(`/`)) {
380
+ let n = a[t], o = resolvePackageTarget(e, n, ``, t, r, !1, !1, !1, i);
381
+ if (o == null) throw exportsNotFound(t, e, r);
382
+ return o;
383
+ }
384
+ let o = ``, s = ``, c = Object.getOwnPropertyNames(a), l = -1;
385
+ for (; ++l < c.length;) {
386
+ let n = c[l], i = n.indexOf(`*`);
387
+ if (i !== -1 && t.startsWith(n.slice(0, i))) {
388
+ t.endsWith(`/`) && emitTrailingSlashPatternDeprecation(t, e, r);
389
+ let a = n.slice(i + 1);
390
+ t.length >= n.length && t.endsWith(a) && patternKeyCompare(o, n) === 1 && n.lastIndexOf(`*`) === i && (o = n, s = t.slice(i, t.length - a.length));
391
+ }
392
+ }
393
+ if (o) {
394
+ let n = a[o], c = resolvePackageTarget(e, n, s, o, r, !0, !1, t.endsWith(`/`), i);
395
+ if (c == null) throw exportsNotFound(t, e, r);
396
+ return c;
397
+ }
398
+ throw exportsNotFound(t, e, r);
399
+ }
400
+ function patternKeyCompare(e, t) {
401
+ let n = e.indexOf(`*`), r = t.indexOf(`*`), i = n === -1 ? e.length : n + 1, a = r === -1 ? t.length : r + 1;
402
+ return i > a ? -1 : a > i || n === -1 ? 1 : r === -1 || e.length > t.length ? -1 : t.length > e.length ? 1 : 0;
403
+ }
404
+ function packageImportsResolve(e, t, n) {
405
+ if (e === `#` || e.startsWith(`#/`) || e.endsWith(`/`)) throw new ERR_INVALID_MODULE_SPECIFIER(e, `is not a valid internal imports specifier name`, fileURLToPath(t));
406
+ let r, i = getPackageScopeConfig(t);
407
+ if (i.exists) {
408
+ r = pathToFileURL(i.pjsonPath);
409
+ let a = i.imports;
410
+ if (a) if (own.call(a, e) && !e.includes(`*`)) {
411
+ let i = resolvePackageTarget(r, a[e], ``, e, t, !1, !0, !1, n);
412
+ if (i != null) return i;
413
+ } else {
414
+ let i = ``, o = ``, s = Object.getOwnPropertyNames(a), c = -1;
415
+ for (; ++c < s.length;) {
416
+ let t = s[c], n = t.indexOf(`*`);
417
+ if (n !== -1 && e.startsWith(t.slice(0, -1))) {
418
+ let r = t.slice(n + 1);
419
+ e.length >= t.length && e.endsWith(r) && patternKeyCompare(i, t) === 1 && t.lastIndexOf(`*`) === n && (i = t, o = e.slice(n, e.length - r.length));
420
+ }
421
+ }
422
+ if (i) {
423
+ let e = a[i], s = resolvePackageTarget(r, e, o, i, t, !0, !0, !1, n);
424
+ if (s != null) return s;
425
+ }
426
+ }
427
+ }
428
+ throw importNotDefined(e, r, t);
429
+ }
430
+ function parsePackageName(e, t) {
431
+ let n = e.indexOf(`/`), r = !0, i = !1;
432
+ e[0] === `@` && (i = !0, n === -1 || e.length === 0 ? r = !1 : n = e.indexOf(`/`, n + 1));
433
+ let o = n === -1 ? e : e.slice(0, n);
434
+ if (invalidPackageNameRegEx.exec(o) !== null && (r = !1), !r) throw new ERR_INVALID_MODULE_SPECIFIER(e, `is not a valid package name`, fileURLToPath(t));
435
+ return {
436
+ packageName: o,
437
+ packageSubpath: `.` + (n === -1 ? `` : e.slice(n)),
438
+ isScoped: i
439
+ };
440
+ }
441
+ function packageResolve(e, t, n) {
442
+ if (nodeBuiltins.includes(e)) return new URL$1(`node:` + e);
443
+ let { packageName: r, packageSubpath: s, isScoped: c } = parsePackageName(e, t), l = getPackageScopeConfig(t);
444
+ if (l.exists && l.name === r && l.exports !== void 0 && l.exports !== null) return packageExportsResolve(pathToFileURL(l.pjsonPath), s, l, t, n);
445
+ let u = new URL$1(`./node_modules/` + r + `/package.json`, t), d = fileURLToPath(u), f;
446
+ do {
447
+ let o = tryStatSync(d.slice(0, -13));
448
+ if (!o || !o.isDirectory()) {
449
+ f = d, u = new URL$1((c ? `../../../../node_modules/` : `../../../node_modules/`) + r + `/package.json`, u), d = fileURLToPath(u);
450
+ continue;
451
+ }
452
+ let l = read(d, {
453
+ base: t,
454
+ specifier: e
455
+ });
456
+ return l.exports !== void 0 && l.exports !== null ? packageExportsResolve(u, s, l, t, n) : s === `.` ? legacyMainResolve(u, l, t) : new URL$1(s, u);
457
+ } while (d.length !== f.length);
458
+ throw new ERR_MODULE_NOT_FOUND(r, fileURLToPath(t), !1);
459
+ }
460
+ function isRelativeSpecifier(e) {
461
+ return e[0] === `.` && (e.length === 1 || e[1] === `/` || e[1] === `.` && (e.length === 2 || e[2] === `/`));
462
+ }
463
+ function shouldBeTreatedAsRelativeOrAbsolutePath(e) {
464
+ return e === `` ? !1 : e[0] === `/` ? !0 : isRelativeSpecifier(e);
465
+ }
466
+ function moduleResolve(e, t, n, r) {
467
+ let a = t.protocol, o = a === `data:`, s;
468
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(e)) try {
469
+ s = new URL$1(e, t);
470
+ } catch (n) {
471
+ let r = new ERR_UNSUPPORTED_RESOLVE_REQUEST(e, t);
472
+ throw r.cause = n, r;
473
+ }
474
+ else if (a === `file:` && e[0] === `#`) s = packageImportsResolve(e, t, n);
475
+ else try {
476
+ s = new URL$1(e);
477
+ } catch (r) {
478
+ if (o && !nodeBuiltins.includes(e)) {
479
+ let n = new ERR_UNSUPPORTED_RESOLVE_REQUEST(e, t);
480
+ throw n.cause = r, n;
481
+ }
482
+ s = packageResolve(e, t, n);
483
+ }
484
+ return assert.ok(s !== void 0, `expected to be defined`), s.protocol === `file:` ? finalizeResolution(s, t, r) : s;
485
+ }
486
+ const DEFAULT_CONDITIONS_SET = new Set([`node`, `import`]), isWindows = process.platform === `win32`, globalCache = globalThis.__EXSOLVE_CACHE__ ||= /* @__PURE__ */ new Map();
487
+ function resolveModuleURL(e, r) {
488
+ let i = _parseInput(e);
489
+ if (`external` in i) return i.external;
490
+ let a = i.specifier, s = i.url, c = i.absolutePath, l, u;
491
+ if (r?.cache !== !1 && (l = _cacheKey(c || a, r), u = r?.cache && typeof r?.cache == `object` ? r.cache : globalCache), u) {
492
+ let e = u.get(l);
493
+ if (typeof e == `string`) return e;
494
+ if (e instanceof Error) {
495
+ if (r?.try) return;
496
+ throw e;
497
+ }
498
+ }
499
+ if (c) try {
500
+ let e = lstatSync(c);
501
+ if (e.isSymbolicLink() && (c = realpathSync(c), s = pathToFileURL(c)), e.isFile()) return u && u.set(l, s.href), s.href;
502
+ } catch (e) {
503
+ if (e?.code !== `ENOENT`) throw u && u.set(l, e), e;
504
+ }
505
+ let d = r?.conditions ? new Set(r.conditions) : DEFAULT_CONDITIONS_SET, f = a || s.href, p = _normalizeBases(r?.from), m = r?.suffixes || [``], h = r?.extensions ? [``, ...r.extensions] : [``], g;
506
+ for (let e of p) {
507
+ for (let t of m) {
508
+ let n = _join(f, t);
509
+ n === `.` && (n += `/.`);
510
+ for (let t of h) if (g = _tryModuleResolve(n + t, e, d), g) break;
511
+ if (g) break;
512
+ }
513
+ if (g) break;
514
+ }
515
+ if (!g) {
516
+ let t = Error(`Cannot resolve module "${e}" (from: ${p.map((e) => _fmtPath(e)).join(`, `)})`);
517
+ if (t.code = `ERR_MODULE_NOT_FOUND`, u && u.set(l, t), r?.try) return;
518
+ throw t;
519
+ }
520
+ return u && u.set(l, g.href), g.href;
521
+ }
522
+ function resolveModulePath(e, t) {
523
+ let n = resolveModuleURL(e, t);
524
+ if (!n || !n.startsWith(`file://`) && t?.try) return;
525
+ let r = fileURLToPath(n);
526
+ return isWindows ? _normalizeWinPath(r) : r;
527
+ }
528
+ function _tryModuleResolve(e, t, n) {
529
+ try {
530
+ return moduleResolve(e, t, n);
531
+ } catch {}
532
+ }
533
+ function _normalizeBases(e) {
534
+ let t = (Array.isArray(e) ? e : [e]).flatMap((e) => _normalizeBase(e));
535
+ return t.length === 0 ? [pathToFileURL(`./`)] : t;
536
+ }
537
+ function _normalizeBase(e) {
538
+ if (!e) return [];
539
+ if (_isURL(e)) return [e];
540
+ if (typeof e != `string`) return [];
541
+ if (/^(?:node|data|http|https|file):/.test(e)) return new URL(e);
542
+ try {
543
+ return e.endsWith(`/`) || statSync(e).isDirectory() ? pathToFileURL(e + `/`) : pathToFileURL(e);
544
+ } catch {
545
+ return [pathToFileURL(e + `/`), pathToFileURL(e)];
546
+ }
547
+ }
548
+ function _fmtPath(e) {
549
+ try {
550
+ return fileURLToPath(e);
551
+ } catch {
552
+ return e;
553
+ }
554
+ }
555
+ function _cacheKey(e, t) {
556
+ return JSON.stringify([
557
+ e,
558
+ (t?.conditions || [`node`, `import`]).sort(),
559
+ t?.extensions,
560
+ t?.from,
561
+ t?.suffixes
562
+ ]);
563
+ }
564
+ function _join(e, t) {
565
+ return !e || !t || t === `/` ? e : (e.endsWith(`/`) ? e : e + `/`) + (t.startsWith(`/`) ? t.slice(1) : t);
566
+ }
567
+ function _normalizeWinPath(e) {
568
+ return e.replace(/\\/g, `/`).replace(/^[a-z]:\//, (e) => e.toUpperCase());
569
+ }
570
+ function _isURL(e) {
571
+ return e instanceof URL || e?.constructor?.name === `URL`;
572
+ }
573
+ function _parseInput(e) {
574
+ if (typeof e == `string`) {
575
+ if (e.startsWith(`file:`)) {
576
+ let t = new URL(e);
577
+ return {
578
+ url: t,
579
+ absolutePath: fileURLToPath(t)
580
+ };
581
+ }
582
+ return isAbsolute(e) ? {
583
+ url: pathToFileURL(e),
584
+ absolutePath: e
585
+ } : /^(?:node|data|http|https):/.test(e) ? { external: e } : nodeBuiltins.includes(e) && !e.includes(`:`) ? { external: `node:${e}` } : { specifier: e };
586
+ }
587
+ if (_isURL(e)) return e.protocol === `file:` ? {
588
+ url: e,
589
+ absolutePath: fileURLToPath(e)
590
+ } : { external: e.href };
591
+ throw TypeError("id must be a `string` or `URL`");
592
+ }
593
+ export { resolveModulePath as t };
@@ -1 +1,70 @@
1
- const _DRIVE_LETTER_START_RE=/^[A-Za-z]:\//;function normalizeWindowsPath(t=``){return t&&t.replace(/\\/g,`/`).replace(_DRIVE_LETTER_START_RE,e=>e.toUpperCase())}const _UNC_REGEX=/^[/\\]{2}/,_IS_ABSOLUTE_RE=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,_DRIVE_LETTER_RE=/^[A-Za-z]:$/,_ROOT_FOLDER_RE=/^\/([A-Za-z]:)?$/,normalize=function(e){if(e.length===0)return`.`;e=normalizeWindowsPath(e);let r=e.match(_UNC_REGEX),a=isAbsolute(e),o=e[e.length-1]===`/`;return e=normalizeString(e,!a),e.length===0?a?`/`:o?`./`:`.`:(o&&(e+=`/`),_DRIVE_LETTER_RE.test(e)&&(e+=`/`),r?a?`//${e}`:`//./${e}`:a&&!isAbsolute(e)?`/${e}`:e)},join=function(...e){let t=``;for(let n of e)if(n)if(t.length>0){let e=t[t.length-1]===`/`,r=n[0]===`/`;e&&r?t+=n.slice(1):t+=e||r?n:`/${n}`}else t+=n;return normalize(t)};function cwd(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const resolve=function(...e){e=e.map(e=>normalizeWindowsPath(e));let n=``,r=!1;for(let t=e.length-1;t>=-1&&!r;t--){let i=t>=0?e[t]:cwd();!i||i.length===0||(n=`${i}/${n}`,r=isAbsolute(i))}return n=normalizeString(n,!r),r&&!isAbsolute(n)?`/${n}`:n.length>0?n:`.`};function normalizeString(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}else if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}const isAbsolute=function(e){return _IS_ABSOLUTE_RE.test(e)},relative=function(e,t){let n=resolve(e).replace(_ROOT_FOLDER_RE,`$1`).split(`/`),r=resolve(t).replace(_ROOT_FOLDER_RE,`$1`).split(`/`);if(r[0][1]===`:`&&n[0][1]===`:`&&n[0]!==r[0])return r.join(`/`);let i=[...n];for(let e of i){if(r[0]!==e)break;n.shift(),r.shift()}return[...n.map(()=>`..`),...r].join(`/`)},dirname=function(e){let n=normalizeWindowsPath(e).replace(/\/$/,``).split(`/`).slice(0,-1);return n.length===1&&_DRIVE_LETTER_RE.test(n[0])&&(n[0]+=`/`),n.join(`/`)||(isAbsolute(e)?`/`:`.`)};export{relative as a,normalize as i,isAbsolute as n,resolve as o,join as r,dirname as t};
1
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
2
+ function normalizeWindowsPath(t = ``) {
3
+ return t && t.replace(/\\/g, `/`).replace(_DRIVE_LETTER_START_RE, (e) => e.toUpperCase());
4
+ }
5
+ const _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/, _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/, normalize = function(e) {
6
+ if (e.length === 0) return `.`;
7
+ e = normalizeWindowsPath(e);
8
+ let r = e.match(_UNC_REGEX), a = isAbsolute(e), o = e[e.length - 1] === `/`;
9
+ return e = normalizeString(e, !a), e.length === 0 ? a ? `/` : o ? `./` : `.` : (o && (e += `/`), _DRIVE_LETTER_RE.test(e) && (e += `/`), r ? a ? `//${e}` : `//./${e}` : a && !isAbsolute(e) ? `/${e}` : e);
10
+ }, join = function(...e) {
11
+ let t = ``;
12
+ for (let n of e) if (n) if (t.length > 0) {
13
+ let e = t[t.length - 1] === `/`, r = n[0] === `/`;
14
+ e && r ? t += n.slice(1) : t += e || r ? n : `/${n}`;
15
+ } else t += n;
16
+ return normalize(t);
17
+ };
18
+ function cwd() {
19
+ return typeof process < `u` && typeof process.cwd == `function` ? process.cwd().replace(/\\/g, `/`) : `/`;
20
+ }
21
+ const resolve = function(...e) {
22
+ e = e.map((e) => normalizeWindowsPath(e));
23
+ let n = ``, r = !1;
24
+ for (let t = e.length - 1; t >= -1 && !r; t--) {
25
+ let i = t >= 0 ? e[t] : cwd();
26
+ !i || i.length === 0 || (n = `${i}/${n}`, r = isAbsolute(i));
27
+ }
28
+ return n = normalizeString(n, !r), r && !isAbsolute(n) ? `/${n}` : n.length > 0 ? n : `.`;
29
+ };
30
+ function normalizeString(e, t) {
31
+ let n = ``, r = 0, i = -1, a = 0, o = null;
32
+ for (let s = 0; s <= e.length; ++s) {
33
+ if (s < e.length) o = e[s];
34
+ else if (o === `/`) break;
35
+ else o = `/`;
36
+ if (o === `/`) {
37
+ if (!(i === s - 1 || a === 1)) if (a === 2) {
38
+ if (n.length < 2 || r !== 2 || n[n.length - 1] !== `.` || n[n.length - 2] !== `.`) {
39
+ if (n.length > 2) {
40
+ let e = n.lastIndexOf(`/`);
41
+ e === -1 ? (n = ``, r = 0) : (n = n.slice(0, e), r = n.length - 1 - n.lastIndexOf(`/`)), i = s, a = 0;
42
+ continue;
43
+ } else if (n.length > 0) {
44
+ n = ``, r = 0, i = s, a = 0;
45
+ continue;
46
+ }
47
+ }
48
+ t && (n += n.length > 0 ? `/..` : `..`, r = 2);
49
+ } else n.length > 0 ? n += `/${e.slice(i + 1, s)}` : n = e.slice(i + 1, s), r = s - i - 1;
50
+ i = s, a = 0;
51
+ } else o === `.` && a !== -1 ? ++a : a = -1;
52
+ }
53
+ return n;
54
+ }
55
+ const isAbsolute = function(e) {
56
+ return _IS_ABSOLUTE_RE.test(e);
57
+ }, relative = function(e, t) {
58
+ let n = resolve(e).replace(_ROOT_FOLDER_RE, `$1`).split(`/`), r = resolve(t).replace(_ROOT_FOLDER_RE, `$1`).split(`/`);
59
+ if (r[0][1] === `:` && n[0][1] === `:` && n[0] !== r[0]) return r.join(`/`);
60
+ let i = [...n];
61
+ for (let e of i) {
62
+ if (r[0] !== e) break;
63
+ n.shift(), r.shift();
64
+ }
65
+ return [...n.map(() => `..`), ...r].join(`/`);
66
+ }, dirname = function(e) {
67
+ let n = normalizeWindowsPath(e).replace(/\/$/, ``).split(`/`).slice(0, -1);
68
+ return n.length === 1 && _DRIVE_LETTER_RE.test(n[0]) && (n[0] += `/`), n.join(`/`) || (isAbsolute(e) ? `/` : `.`);
69
+ };
70
+ export { relative as a, normalize as i, isAbsolute as n, resolve as o, join as r, dirname as t };
@@ -4,8 +4,6 @@ import { promises } from "node:fs";
4
4
  import { nodeFileTrace } from "@vercel/nft";
5
5
  import semver from "semver";
6
6
  import { readFile, writeFile } from "node:fs/promises";
7
-
8
- //#region src/_utils.ts
9
7
  const isWindows = process.platform === "win32";
10
8
  const NODE_MODULES_RE = /^(?<dir>.+[\\/]node_modules[\\/])(?<name>[^@\\/]+|@[^\\/]+[\\/][^\\/]+)(?:[\\/](?<subpath>.+))?$/;
11
9
  function parseNodeModulePath(path) {
@@ -76,9 +74,6 @@ function toPathRegExp(input) {
76
74
  if (typeof input === "string") return new RegExp(pathRegExp(input));
77
75
  throw new TypeError("Expected a string or RegExp", { cause: input });
78
76
  }
79
-
80
- //#endregion
81
- //#region src/trace.ts
82
77
  const DEFAULT_CONDITIONS = [
83
78
  "node",
84
79
  "import",
@@ -258,6 +253,4 @@ async function isFile(file) {
258
253
  throw error;
259
254
  }
260
255
  }
261
-
262
- //#endregion
263
- export { pathRegExp as a, guessSubpath as i, applyProductionCondition as n, toImport as o, traceNodeModules as r, toPathRegExp as s, DEFAULT_CONDITIONS as t };
256
+ export { pathRegExp as a, guessSubpath as i, applyProductionCondition as n, toImport as o, traceNodeModules as r, toPathRegExp as s, DEFAULT_CONDITIONS as t };
@@ -1,3 +1,2 @@
1
1
  import { n as applyProductionCondition, r as traceNodeModules, t as DEFAULT_CONDITIONS } from "./trace.mjs";
2
-
3
- export { traceNodeModules };
2
+ export { traceNodeModules };
package/dist/db.mjs CHANGED
@@ -1,9 +1,3 @@
1
- //#region src/db.ts
2
- /**
3
- * Known packages that include native code and require platform-specific builds.
4
- *
5
- * These packages cannot be bundled and should be traced as external dependencies most of the time.
6
- */
7
1
  const NodeNativePackages = Object.freeze([
8
2
  "canvas",
9
3
  "sharp",
@@ -38,11 +32,10 @@ const NodeNativePackages = Object.freeze([
38
32
  "utf-8-validate",
39
33
  "keytar"
40
34
  ]);
41
- /**
42
- * Packages that must be externalized (traced as dependencies) rather than bundled,
43
- * due to bundler compatibility issues with their module format or dynamic imports.
44
- */
45
- const NonBundleablePackages = ["pg", "sequelize"];
46
-
47
- //#endregion
48
- export { NodeNativePackages, NonBundleablePackages };
35
+ const NonBundleablePackages = [
36
+ "pg",
37
+ "sequelize",
38
+ "@discordjs/ws",
39
+ "@prisma/client"
40
+ ];
41
+ export { NodeNativePackages, NonBundleablePackages };
package/dist/index.mjs CHANGED
@@ -1,4 +1,3 @@
1
1
  import { r as traceNodeModules } from "./_chunks/trace.mjs";
2
2
  import { NodeNativePackages } from "./db.mjs";
3
-
4
- export { NodeNativePackages, traceNodeModules };
3
+ export { NodeNativePackages, traceNodeModules };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,`__esModule`,{value:!0}),exports.LRUCache=void 0;const defaultPerf=typeof performance==`object`&&performance&&typeof performance.now==`function`?performance:Date,warned=new Set,PROCESS=typeof process==`object`&&process?process:{},emitWarning=(e,t,r,i)=>{typeof PROCESS.emitWarning==`function`?PROCESS.emitWarning(e,t,r,i):console.error(`[${r}] ${t}: ${e}`)};let AC=globalThis.AbortController,AS=globalThis.AbortSignal;if(AC===void 0){AS=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},AC=class{constructor(){t()}signal=new AS;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(let t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e=PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING!==`1`,t=()=>{e&&(e=!1,emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.",`NO_ABORT_CONTROLLER`,`ENOTSUP`,t))}}const shouldWarn=e=>!warned.has(e),TYPE=Symbol(`type`),isPosInt=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),getUintArray=e=>isPosInt(e)?e<=2**8?Uint8Array:e<=2**16?Uint16Array:e<=2**32?Uint32Array:e<=2**53-1?ZeroArray:null:null;class ZeroArray extends Array{constructor(e){super(e),this.fill(0)}}class Stack{heap;length;static#constructing=!1;static create(e){let t=getUintArray(e);if(!t)return[];Stack.#constructing=!0;let n=new Stack(e,t);return Stack.#constructing=!1,n}constructor(e,t){if(!Stack.#constructing)throw TypeError(`instantiate Stack using Stack.create(n)`);this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class LRUCache{#max;#maxSize;#dispose;#onInsert;#disposeAfter;#fetchMethod;#memoMethod;#perf;get perf(){return this.#perf}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#size;#calculatedSize;#keyMap;#keyList;#valList;#next;#prev;#head;#tail;#free;#disposed;#sizes;#starts;#ttls;#autopurgeTimers;#hasDispose;#hasFetchMethod;#hasDisposeAfter;#hasOnInsert;static unsafeExposeInternals(e){return{starts:e.#starts,ttls:e.#ttls,autopurgeTimers:e.#autopurgeTimers,sizes:e.#sizes,keyMap:e.#keyMap,keyList:e.#keyList,valList:e.#valList,next:e.#next,prev:e.#prev,get head(){return e.#head},get tail(){return e.#tail},free:e.#free,isBackgroundFetch:t=>e.#isBackgroundFetch(t),backgroundFetch:(t,n,r,i)=>e.#backgroundFetch(t,n,r,i),moveToTail:t=>e.#moveToTail(t),indexes:t=>e.#indexes(t),rindexes:t=>e.#rindexes(t),isStale:t=>e.#isStale(t)}}get max(){return this.#max}get maxSize(){return this.#maxSize}get calculatedSize(){return this.#calculatedSize}get size(){return this.#size}get fetchMethod(){return this.#fetchMethod}get memoMethod(){return this.#memoMethod}get dispose(){return this.#dispose}get onInsert(){return this.#onInsert}get disposeAfter(){return this.#disposeAfter}constructor(n){let{max:i=0,ttl:a,ttlResolution:s=1,ttlAutopurge:u,updateAgeOnGet:p,updateAgeOnHas:m,allowStale:h,dispose:g,onInsert:_,disposeAfter:v,noDisposeOnSet:y,noUpdateTTL:b,maxSize:x=0,maxEntrySize:S=0,sizeCalculation:C,fetchMethod:w,memoMethod:T,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:D,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:k,ignoreFetchAbort:A,perf:j}=n;if(j!==void 0&&typeof j?.now!=`function`)throw TypeError(`perf option must have a now() method if specified`);if(this.#perf=j??defaultPerf,i!==0&&!isPosInt(i))throw TypeError(`max option must be a nonnegative integer`);let M=i?getUintArray(i):Array;if(!M)throw Error(`invalid max value: `+i);if(this.#max=i,this.#maxSize=x,this.maxEntrySize=S||this.#maxSize,this.sizeCalculation=C,this.sizeCalculation){if(!this.#maxSize&&!this.maxEntrySize)throw TypeError(`cannot set sizeCalculation without setting maxSize or maxEntrySize`);if(typeof this.sizeCalculation!=`function`)throw TypeError(`sizeCalculation set to non-function`)}if(T!==void 0&&typeof T!=`function`)throw TypeError(`memoMethod must be a function if defined`);if(this.#memoMethod=T,w!==void 0&&typeof w!=`function`)throw TypeError(`fetchMethod must be a function if specified`);if(this.#fetchMethod=w,this.#hasFetchMethod=!!w,this.#keyMap=new Map,this.#keyList=Array(i).fill(void 0),this.#valList=Array(i).fill(void 0),this.#next=new M(i),this.#prev=new M(i),this.#head=0,this.#tail=0,this.#free=Stack.create(i),this.#size=0,this.#calculatedSize=0,typeof g==`function`&&(this.#dispose=g),typeof _==`function`&&(this.#onInsert=_),typeof v==`function`?(this.#disposeAfter=v,this.#disposed=[]):(this.#disposeAfter=void 0,this.#disposed=void 0),this.#hasDispose=!!this.#dispose,this.#hasOnInsert=!!this.#onInsert,this.#hasDisposeAfter=!!this.#disposeAfter,this.noDisposeOnSet=!!y,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!k,this.ignoreFetchAbort=!!A,this.maxEntrySize!==0){if(this.#maxSize!==0&&!isPosInt(this.#maxSize))throw TypeError(`maxSize must be a positive integer if specified`);if(!isPosInt(this.maxEntrySize))throw TypeError(`maxEntrySize must be a positive integer if specified`);this.#initializeSizeTracking()}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!D,this.updateAgeOnGet=!!p,this.updateAgeOnHas=!!m,this.ttlResolution=isPosInt(s)||s===0?s:1,this.ttlAutopurge=!!u,this.ttl=a||0,this.ttl){if(!isPosInt(this.ttl))throw TypeError(`ttl must be a positive integer if specified`);this.#initializeTTLTracking()}if(this.#max===0&&this.ttl===0&&this.#maxSize===0)throw TypeError(`At least one of max, maxSize, or ttl is required`);if(!this.ttlAutopurge&&!this.#max&&!this.#maxSize){let e=`LRU_CACHE_UNBOUNDED`;shouldWarn(e)&&(warned.add(e),emitWarning(`TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.`,`UnboundedCacheWarning`,e,LRUCache))}}getRemainingTTL(e){return this.#keyMap.has(e)?1/0:0}#initializeTTLTracking(){let e=new ZeroArray(this.#max),t=new ZeroArray(this.#max);this.#ttls=e,this.#starts=t;let n=this.ttlAutopurge?Array(this.#max):void 0;this.#autopurgeTimers=n,this.#setItemTTL=(r,i,a=this.#perf.now())=>{if(t[r]=i===0?0:a,e[r]=i,n?.[r]&&(clearTimeout(n[r]),n[r]=void 0),i!==0&&n){let e=setTimeout(()=>{this.#isStale(r)&&this.#delete(this.#keyList[r],`expire`)},i+1);e.unref&&e.unref(),n[r]=e}},this.#updateItemAge=n=>{t[n]=e[n]===0?0:this.#perf.now()},this.#statusTTL=(n,a)=>{if(e[a]){let o=e[a],s=t[a];if(!o||!s)return;n.ttl=o,n.start=s,n.now=r||i(),n.remainingTTL=o-(n.now-s)}};let r=0,i=()=>{let e=this.#perf.now();if(this.ttlResolution>0){r=e;let t=setTimeout(()=>r=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=n=>{let a=this.#keyMap.get(n);if(a===void 0)return 0;let o=e[a],s=t[a];return!o||!s?1/0:o-((r||i())-s)},this.#isStale=n=>{let a=t[n],o=e[n];return!!o&&!!a&&(r||i())-a>o}}#updateItemAge=()=>{};#statusTTL=()=>{};#setItemTTL=()=>{};#isStale=()=>!1;#initializeSizeTracking(){let e=new ZeroArray(this.#max);this.#calculatedSize=0,this.#sizes=e,this.#removeItemSize=t=>{this.#calculatedSize-=e[t],e[t]=0},this.#requireSize=(e,t,n,r)=>{if(this.#isBackgroundFetch(t))return 0;if(!isPosInt(n))if(r){if(typeof r!=`function`)throw TypeError(`sizeCalculation must be a function`);if(n=r(t,e),!isPosInt(n))throw TypeError(`sizeCalculation return invalid (expect positive integer)`)}else throw TypeError(`invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.`);return n},this.#addItemSize=(t,n,r)=>{if(e[t]=n,this.#maxSize){let n=this.#maxSize-e[t];for(;this.#calculatedSize>n;)this.#evict(!0)}this.#calculatedSize+=e[t],r&&(r.entrySize=n,r.totalCalculatedSize=this.#calculatedSize)}}#removeItemSize=e=>{};#addItemSize=(e,t,n)=>{};#requireSize=(e,t,n,r)=>{if(n||r)throw TypeError(`cannot set size without setting maxSize or maxEntrySize on cache`);return 0};*#indexes({allowStale:e=this.allowStale}={}){if(this.#size)for(let t=this.#tail;!(!this.#isValidIndex(t)||((e||!this.#isStale(t))&&(yield t),t===this.#head));)t=this.#prev[t]}*#rindexes({allowStale:e=this.allowStale}={}){if(this.#size)for(let t=this.#head;!(!this.#isValidIndex(t)||((e||!this.#isStale(t))&&(yield t),t===this.#tail));)t=this.#next[t]}#isValidIndex(e){return e!==void 0&&this.#keyMap.get(this.#keyList[e])===e}*entries(){for(let e of this.#indexes())this.#valList[e]!==void 0&&this.#keyList[e]!==void 0&&!this.#isBackgroundFetch(this.#valList[e])&&(yield[this.#keyList[e],this.#valList[e]])}*rentries(){for(let e of this.#rindexes())this.#valList[e]!==void 0&&this.#keyList[e]!==void 0&&!this.#isBackgroundFetch(this.#valList[e])&&(yield[this.#keyList[e],this.#valList[e]])}*keys(){for(let e of this.#indexes()){let t=this.#keyList[e];t!==void 0&&!this.#isBackgroundFetch(this.#valList[e])&&(yield t)}}*rkeys(){for(let e of this.#rindexes()){let t=this.#keyList[e];t!==void 0&&!this.#isBackgroundFetch(this.#valList[e])&&(yield t)}}*values(){for(let e of this.#indexes())this.#valList[e]!==void 0&&!this.#isBackgroundFetch(this.#valList[e])&&(yield this.#valList[e])}*rvalues(){for(let e of this.#rindexes())this.#valList[e]!==void 0&&!this.#isBackgroundFetch(this.#valList[e])&&(yield this.#valList[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]=`LRUCache`;find(e,t={}){for(let n of this.#indexes()){let r=this.#valList[n],i=this.#isBackgroundFetch(r)?r.__staleWhileFetching:r;if(i!==void 0&&e(i,this.#keyList[n],this))return this.get(this.#keyList[n],t)}}forEach(e,t=this){for(let n of this.#indexes()){let r=this.#valList[n],i=this.#isBackgroundFetch(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#keyList[n],this)}}rforEach(e,t=this){for(let n of this.#rindexes()){let r=this.#valList[n],i=this.#isBackgroundFetch(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#keyList[n],this)}}purgeStale(){let e=!1;for(let t of this.#rindexes({allowStale:!0}))this.#isStale(t)&&(this.#delete(this.#keyList[t],`expire`),e=!0);return e}info(e){let t=this.#keyMap.get(e);if(t===void 0)return;let n=this.#valList[t],r=this.#isBackgroundFetch(n)?n.__staleWhileFetching:n;if(r===void 0)return;let i={value:r};if(this.#ttls&&this.#starts){let e=this.#ttls[t],n=this.#starts[t];e&&n&&(i.ttl=e-(this.#perf.now()-n),i.start=Date.now())}return this.#sizes&&(i.size=this.#sizes[t]),i}dump(){let e=[];for(let t of this.#indexes({allowStale:!0})){let n=this.#keyList[t],r=this.#valList[t],i=this.#isBackgroundFetch(r)?r.__staleWhileFetching:r;if(i===void 0||n===void 0)continue;let a={value:i};if(this.#ttls&&this.#starts){a.ttl=this.#ttls[t];let e=this.#perf.now()-this.#starts[t];a.start=Math.floor(Date.now()-e)}this.#sizes&&(a.size=this.#sizes[t]),e.unshift([n,a])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let e=Date.now()-n.start;n.start=this.#perf.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(t===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:i,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:s}=n,{noUpdateTTL:c=this.noUpdateTTL}=n,l=this.#requireSize(e,t,n.size||0,o);if(this.maxEntrySize&&l>this.maxEntrySize)return s&&(s.set=`miss`,s.maxEntrySizeExceeded=!0),this.#delete(e,`set`),this;let u=this.#size===0?void 0:this.#keyMap.get(e);if(u===void 0)u=this.#size===0?this.#tail:this.#free.length===0?this.#size===this.#max?this.#evict(!1):this.#size:this.#free.pop(),this.#keyList[u]=e,this.#valList[u]=t,this.#keyMap.set(e,u),this.#next[this.#tail]=u,this.#prev[u]=this.#tail,this.#tail=u,this.#size++,this.#addItemSize(u,l,s),s&&(s.set=`add`),c=!1,this.#hasOnInsert&&this.#onInsert?.(t,e,`add`);else{this.#moveToTail(u);let n=this.#valList[u];if(t!==n){if(this.#hasFetchMethod&&this.#isBackgroundFetch(n)){n.__abortController.abort(Error(`replaced`));let{__staleWhileFetching:t}=n;t!==void 0&&!a&&(this.#hasDispose&&this.#dispose?.(t,e,`set`),this.#hasDisposeAfter&&this.#disposed?.push([t,e,`set`]))}else a||(this.#hasDispose&&this.#dispose?.(n,e,`set`),this.#hasDisposeAfter&&this.#disposed?.push([n,e,`set`]));if(this.#removeItemSize(u),this.#addItemSize(u,l,s),this.#valList[u]=t,s){s.set=`replace`;let e=n&&this.#isBackgroundFetch(n)?n.__staleWhileFetching:n;e!==void 0&&(s.oldValue=e)}}else s&&(s.set=`update`);this.#hasOnInsert&&this.onInsert?.(t,e,t===n?`update`:`replace`)}if(r!==0&&!this.#ttls&&this.#initializeTTLTracking(),this.#ttls&&(c||this.#setItemTTL(u,r,i),s&&this.#statusTTL(s,u)),!a&&this.#hasDisposeAfter&&this.#disposed){let e=this.#disposed,t;for(;t=e?.shift();)this.#disposeAfter?.(...t)}return this}pop(){try{for(;this.#size;){let e=this.#valList[this.#head];if(this.#evict(!0),this.#isBackgroundFetch(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#hasDisposeAfter&&this.#disposed){let e=this.#disposed,t;for(;t=e?.shift();)this.#disposeAfter?.(...t)}}}#evict(e){let t=this.#head,n=this.#keyList[t],r=this.#valList[t];return this.#hasFetchMethod&&this.#isBackgroundFetch(r)?r.__abortController.abort(Error(`evicted`)):(this.#hasDispose||this.#hasDisposeAfter)&&(this.#hasDispose&&this.#dispose?.(r,n,`evict`),this.#hasDisposeAfter&&this.#disposed?.push([r,n,`evict`])),this.#removeItemSize(t),this.#autopurgeTimers?.[t]&&(clearTimeout(this.#autopurgeTimers[t]),this.#autopurgeTimers[t]=void 0),e&&(this.#keyList[t]=void 0,this.#valList[t]=void 0,this.#free.push(t)),this.#size===1?(this.#head=this.#tail=0,this.#free.length=0):this.#head=this.#next[t],this.#keyMap.delete(n),this.#size--,t}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=t,i=this.#keyMap.get(e);if(i!==void 0){let e=this.#valList[i];if(this.#isBackgroundFetch(e)&&e.__staleWhileFetching===void 0)return!1;if(this.#isStale(i))r&&(r.has=`stale`,this.#statusTTL(r,i));else return n&&this.#updateItemAge(i),r&&(r.has=`hit`,this.#statusTTL(r,i)),!0}else r&&(r.has=`miss`);return!1}peek(e,t={}){let{allowStale:n=this.allowStale}=t,r=this.#keyMap.get(e);if(r===void 0||!n&&this.#isStale(r))return;let i=this.#valList[r];return this.#isBackgroundFetch(i)?i.__staleWhileFetching:i}#backgroundFetch(e,t,n,r){let a=t===void 0?void 0:this.#valList[t];if(this.#isBackgroundFetch(a))return a;let o=new AC,{signal:s}=n;s?.addEventListener(`abort`,()=>o.abort(s.reason),{signal:o.signal});let c={signal:o.signal,options:n,context:r},l=(r,i=!1)=>{let{aborted:a}=o.signal,s=n.ignoreFetchAbort&&r!==void 0;if(n.status&&(a&&!i?(n.status.fetchAborted=!0,n.status.fetchError=o.signal.reason,s&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),a&&!s&&!i)return d(o.signal.reason);let l=p,u=this.#valList[t];return(u===p||s&&i&&u===void 0)&&(r===void 0?l.__staleWhileFetching===void 0?this.#delete(e,`fetch`):this.#valList[t]=l.__staleWhileFetching:(n.status&&(n.status.fetchUpdated=!0),this.set(e,r,c.options))),r},u=e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),d(e)),d=r=>{let{aborted:i}=o.signal,a=i&&n.allowStaleOnFetchAbort,s=a||n.allowStaleOnFetchRejection,c=s||n.noDeleteOnFetchRejection,l=p;if(this.#valList[t]===p&&(!c||l.__staleWhileFetching===void 0?this.#delete(e,`fetch`):a||(this.#valList[t]=l.__staleWhileFetching)),s)return n.status&&l.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),l.__staleWhileFetching;if(l.__returned===l)throw r},f=(t,r)=>{let i=this.#fetchMethod?.(e,a,c);i&&i instanceof Promise&&i.then(e=>t(e===void 0?void 0:e),r),o.signal.addEventListener(`abort`,()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>l(e,!0)))})};n.status&&(n.status.fetchDispatched=!0);let p=new Promise(f).then(l,u),m=Object.assign(p,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,m,{...c.options,status:void 0}),t=this.#keyMap.get(e)):this.#valList[t]=m,m}#isBackgroundFetch(e){if(!this.#hasFetchMethod)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty(`__staleWhileFetching`)&&t.__abortController instanceof AC}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:s=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:h=!1,status:g,signal:_}=t;if(!this.#hasFetchMethod)return g&&(g.fetch=`get`),this.get(e,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:g});let v={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:a,noDisposeOnSet:o,size:s,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:p,ignoreFetchAbort:f,status:g,signal:_},y=this.#keyMap.get(e);if(y===void 0){g&&(g.fetch=`miss`);let t=this.#backgroundFetch(e,y,v,m);return t.__returned=t}else{let t=this.#valList[y];if(this.#isBackgroundFetch(t)){let e=n&&t.__staleWhileFetching!==void 0;return g&&(g.fetch=`inflight`,e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let i=this.#isStale(y);if(!h&&!i)return g&&(g.fetch=`hit`),this.#moveToTail(y),r&&this.#updateItemAge(y),g&&this.#statusTTL(g,y),t;let a=this.#backgroundFetch(e,y,v,m),o=a.__staleWhileFetching!==void 0&&n;return g&&(g.fetch=i?`stale`:`refresh`,o&&i&&(g.returnedStale=!0)),o?a.__staleWhileFetching:a.__returned=a}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw Error(`fetch() returned undefined`);return n}memo(e,t={}){let n=this.#memoMethod;if(!n)throw Error(`no memoMethod provided to constructor`);let{context:r,forceRefresh:i,...a}=t,o=this.get(e,a);if(!i&&o!==void 0)return o;let s=n(e,o,{options:a,context:r});return this.set(e,s,a),s}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:a}=t,o=this.#keyMap.get(e);if(o!==void 0){let t=this.#valList[o],s=this.#isBackgroundFetch(t);return a&&this.#statusTTL(a,o),this.#isStale(o)?(a&&(a.get=`stale`),s?(a&&n&&t.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?t.__staleWhileFetching:void 0):(i||this.#delete(e,`expire`),a&&n&&(a.returnedStale=!0),n?t:void 0)):(a&&(a.get=`hit`),s?t.__staleWhileFetching:(this.#moveToTail(o),r&&this.#updateItemAge(o),t))}else a&&(a.get=`miss`)}#connect(e,t){this.#prev[t]=e,this.#next[e]=t}#moveToTail(e){e!==this.#tail&&(e===this.#head?this.#head=this.#next[e]:this.#connect(this.#prev[e],this.#next[e]),this.#connect(this.#tail,e),this.#tail=e)}delete(e){return this.#delete(e,`delete`)}#delete(e,t){let n=!1;if(this.#size!==0){let r=this.#keyMap.get(e);if(r!==void 0)if(this.#autopurgeTimers?.[r]&&(clearTimeout(this.#autopurgeTimers?.[r]),this.#autopurgeTimers[r]=void 0),n=!0,this.#size===1)this.#clear(t);else{this.#removeItemSize(r);let n=this.#valList[r];if(this.#isBackgroundFetch(n)?n.__abortController.abort(Error(`deleted`)):(this.#hasDispose||this.#hasDisposeAfter)&&(this.#hasDispose&&this.#dispose?.(n,e,t),this.#hasDisposeAfter&&this.#disposed?.push([n,e,t])),this.#keyMap.delete(e),this.#keyList[r]=void 0,this.#valList[r]=void 0,r===this.#tail)this.#tail=this.#prev[r];else if(r===this.#head)this.#head=this.#next[r];else{let e=this.#prev[r];this.#next[e]=this.#next[r];let t=this.#next[r];this.#prev[t]=this.#prev[r]}this.#size--,this.#free.push(r)}}if(this.#hasDisposeAfter&&this.#disposed?.length){let e=this.#disposed,t;for(;t=e?.shift();)this.#disposeAfter?.(...t)}return n}clear(){return this.#clear(`delete`)}#clear(e){for(let t of this.#rindexes({allowStale:!0})){let n=this.#valList[t];if(this.#isBackgroundFetch(n))n.__abortController.abort(Error(`deleted`));else{let r=this.#keyList[t];this.#hasDispose&&this.#dispose?.(n,r,e),this.#hasDisposeAfter&&this.#disposed?.push([n,r,e])}}if(this.#keyMap.clear(),this.#valList.fill(void 0),this.#keyList.fill(void 0),this.#ttls&&this.#starts){this.#ttls.fill(0),this.#starts.fill(0);for(let e of this.#autopurgeTimers??[])e!==void 0&&clearTimeout(e);this.#autopurgeTimers?.fill(void 0)}if(this.#sizes&&this.#sizes.fill(0),this.#head=0,this.#tail=0,this.#free.length=0,this.#calculatedSize=0,this.#size=0,this.#hasDisposeAfter&&this.#disposed){let e=this.#disposed,t;for(;t=e?.shift();)this.#disposeAfter?.(...t)}}}exports.LRUCache=LRUCache;
1
+ "use strict";Object.defineProperty(exports,`__esModule`,{value:!0}),exports.LRUCache=void 0;const defaultPerf=typeof performance==`object`&&performance&&typeof performance.now==`function`?performance:Date,warned=new Set,PROCESS=typeof process==`object`&&process?process:{},emitWarning=(e,t,r,i)=>{typeof PROCESS.emitWarning==`function`?PROCESS.emitWarning(e,t,r,i):console.error(`[${r}] ${t}: ${e}`)};let AC=globalThis.AbortController,AS=globalThis.AbortSignal;if(AC===void 0){AS=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},AC=class{constructor(){t()}signal=new AS;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(let t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e=PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING!==`1`,t=()=>{e&&(e=!1,emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.",`NO_ABORT_CONTROLLER`,`ENOTSUP`,t))}}const shouldWarn=e=>!warned.has(e),TYPE=Symbol(`type`),isPosInt=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),getUintArray=e=>isPosInt(e)?e<=2**8?Uint8Array:e<=2**16?Uint16Array:e<=2**32?Uint32Array:e<=2**53-1?ZeroArray:null:null;class ZeroArray extends Array{constructor(e){super(e),this.fill(0)}}class Stack{heap;length;static#constructing=!1;static create(e){let t=getUintArray(e);if(!t)return[];Stack.#constructing=!0;let n=new Stack(e,t);return Stack.#constructing=!1,n}constructor(e,t){if(!Stack.#constructing)throw TypeError(`instantiate Stack using Stack.create(n)`);this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class LRUCache{#max;#maxSize;#dispose;#onInsert;#disposeAfter;#fetchMethod;#memoMethod;#perf;get perf(){return this.#perf}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#size;#calculatedSize;#keyMap;#keyList;#valList;#next;#prev;#head;#tail;#free;#disposed;#sizes;#starts;#ttls;#autopurgeTimers;#hasDispose;#hasFetchMethod;#hasDisposeAfter;#hasOnInsert;static unsafeExposeInternals(e){return{starts:e.#starts,ttls:e.#ttls,autopurgeTimers:e.#autopurgeTimers,sizes:e.#sizes,keyMap:e.#keyMap,keyList:e.#keyList,valList:e.#valList,next:e.#next,prev:e.#prev,get head(){return e.#head},get tail(){return e.#tail},free:e.#free,isBackgroundFetch:t=>e.#isBackgroundFetch(t),backgroundFetch:(t,n,r,i)=>e.#backgroundFetch(t,n,r,i),moveToTail:t=>e.#moveToTail(t),indexes:t=>e.#indexes(t),rindexes:t=>e.#rindexes(t),isStale:t=>e.#isStale(t)}}get max(){return this.#max}get maxSize(){return this.#maxSize}get calculatedSize(){return this.#calculatedSize}get size(){return this.#size}get fetchMethod(){return this.#fetchMethod}get memoMethod(){return this.#memoMethod}get dispose(){return this.#dispose}get onInsert(){return this.#onInsert}get disposeAfter(){return this.#disposeAfter}constructor(n){let{max:i=0,ttl:a,ttlResolution:s=1,ttlAutopurge:u,updateAgeOnGet:p,updateAgeOnHas:m,allowStale:h,dispose:g,onInsert:_,disposeAfter:v,noDisposeOnSet:y,noUpdateTTL:b,maxSize:x=0,maxEntrySize:S=0,sizeCalculation:C,fetchMethod:w,memoMethod:T,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:D,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:k,ignoreFetchAbort:A,perf:j}=n;if(j!==void 0&&typeof j?.now!=`function`)throw TypeError(`perf option must have a now() method if specified`);if(this.#perf=j??defaultPerf,i!==0&&!isPosInt(i))throw TypeError(`max option must be a nonnegative integer`);let M=i?getUintArray(i):Array;if(!M)throw Error(`invalid max value: `+i);if(this.#max=i,this.#maxSize=x,this.maxEntrySize=S||this.#maxSize,this.sizeCalculation=C,this.sizeCalculation){if(!this.#maxSize&&!this.maxEntrySize)throw TypeError(`cannot set sizeCalculation without setting maxSize or maxEntrySize`);if(typeof this.sizeCalculation!=`function`)throw TypeError(`sizeCalculation set to non-function`)}if(T!==void 0&&typeof T!=`function`)throw TypeError(`memoMethod must be a function if defined`);if(this.#memoMethod=T,w!==void 0&&typeof w!=`function`)throw TypeError(`fetchMethod must be a function if specified`);if(this.#fetchMethod=w,this.#hasFetchMethod=!!w,this.#keyMap=new Map,this.#keyList=Array(i).fill(void 0),this.#valList=Array(i).fill(void 0),this.#next=new M(i),this.#prev=new M(i),this.#head=0,this.#tail=0,this.#free=Stack.create(i),this.#size=0,this.#calculatedSize=0,typeof g==`function`&&(this.#dispose=g),typeof _==`function`&&(this.#onInsert=_),typeof v==`function`?(this.#disposeAfter=v,this.#disposed=[]):(this.#disposeAfter=void 0,this.#disposed=void 0),this.#hasDispose=!!this.#dispose,this.#hasOnInsert=!!this.#onInsert,this.#hasDisposeAfter=!!this.#disposeAfter,this.noDisposeOnSet=!!y,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!k,this.ignoreFetchAbort=!!A,this.maxEntrySize!==0){if(this.#maxSize!==0&&!isPosInt(this.#maxSize))throw TypeError(`maxSize must be a positive integer if specified`);if(!isPosInt(this.maxEntrySize))throw TypeError(`maxEntrySize must be a positive integer if specified`);this.#initializeSizeTracking()}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!D,this.updateAgeOnGet=!!p,this.updateAgeOnHas=!!m,this.ttlResolution=isPosInt(s)||s===0?s:1,this.ttlAutopurge=!!u,this.ttl=a||0,this.ttl){if(!isPosInt(this.ttl))throw TypeError(`ttl must be a positive integer if specified`);this.#initializeTTLTracking()}if(this.#max===0&&this.ttl===0&&this.#maxSize===0)throw TypeError(`At least one of max, maxSize, or ttl is required`);if(!this.ttlAutopurge&&!this.#max&&!this.#maxSize){let e=`LRU_CACHE_UNBOUNDED`;shouldWarn(e)&&(warned.add(e),emitWarning(`TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.`,`UnboundedCacheWarning`,e,LRUCache))}}getRemainingTTL(e){return this.#keyMap.has(e)?1/0:0}#initializeTTLTracking(){let e=new ZeroArray(this.#max),t=new ZeroArray(this.#max);this.#ttls=e,this.#starts=t;let n=this.ttlAutopurge?Array(this.#max):void 0;this.#autopurgeTimers=n,this.#setItemTTL=(r,i,a=this.#perf.now())=>{if(t[r]=i===0?0:a,e[r]=i,n?.[r]&&(clearTimeout(n[r]),n[r]=void 0),i!==0&&n){let e=setTimeout(()=>{this.#isStale(r)&&this.#delete(this.#keyList[r],`expire`)},i+1);e.unref&&e.unref(),n[r]=e}},this.#updateItemAge=n=>{t[n]=e[n]===0?0:this.#perf.now()},this.#statusTTL=(n,a)=>{if(e[a]){let o=e[a],s=t[a];if(!o||!s)return;n.ttl=o,n.start=s,n.now=r||i(),n.remainingTTL=o-(n.now-s)}};let r=0,i=()=>{let e=this.#perf.now();if(this.ttlResolution>0){r=e;let t=setTimeout(()=>r=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=n=>{let a=this.#keyMap.get(n);if(a===void 0)return 0;let o=e[a],s=t[a];return!o||!s?1/0:o-((r||i())-s)},this.#isStale=n=>{let a=t[n],o=e[n];return!!o&&!!a&&(r||i())-a>o}}#updateItemAge=()=>{};#statusTTL=()=>{};#setItemTTL=()=>{};#isStale=()=>!1;#initializeSizeTracking(){let e=new ZeroArray(this.#max);this.#calculatedSize=0,this.#sizes=e,this.#removeItemSize=t=>{this.#calculatedSize-=e[t],e[t]=0},this.#requireSize=(e,t,n,r)=>{if(this.#isBackgroundFetch(t))return 0;if(!isPosInt(n))if(r){if(typeof r!=`function`)throw TypeError(`sizeCalculation must be a function`);if(n=r(t,e),!isPosInt(n))throw TypeError(`sizeCalculation return invalid (expect positive integer)`)}else throw TypeError(`invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.`);return n},this.#addItemSize=(t,n,r)=>{if(e[t]=n,this.#maxSize){let n=this.#maxSize-e[t];for(;this.#calculatedSize>n;)this.#evict(!0)}this.#calculatedSize+=e[t],r&&(r.entrySize=n,r.totalCalculatedSize=this.#calculatedSize)}}#removeItemSize=e=>{};#addItemSize=(e,t,n)=>{};#requireSize=(e,t,n,r)=>{if(n||r)throw TypeError(`cannot set size without setting maxSize or maxEntrySize on cache`);return 0};*#indexes({allowStale:e=this.allowStale}={}){if(this.#size)for(let t=this.#tail;!(!this.#isValidIndex(t)||((e||!this.#isStale(t))&&(yield t),t===this.#head));)t=this.#prev[t]}*#rindexes({allowStale:e=this.allowStale}={}){if(this.#size)for(let t=this.#head;!(!this.#isValidIndex(t)||((e||!this.#isStale(t))&&(yield t),t===this.#tail));)t=this.#next[t]}#isValidIndex(e){return e!==void 0&&this.#keyMap.get(this.#keyList[e])===e}*entries(){for(let e of this.#indexes())this.#valList[e]!==void 0&&this.#keyList[e]!==void 0&&!this.#isBackgroundFetch(this.#valList[e])&&(yield[this.#keyList[e],this.#valList[e]])}*rentries(){for(let e of this.#rindexes())this.#valList[e]!==void 0&&this.#keyList[e]!==void 0&&!this.#isBackgroundFetch(this.#valList[e])&&(yield[this.#keyList[e],this.#valList[e]])}*keys(){for(let e of this.#indexes()){let t=this.#keyList[e];t!==void 0&&!this.#isBackgroundFetch(this.#valList[e])&&(yield t)}}*rkeys(){for(let e of this.#rindexes()){let t=this.#keyList[e];t!==void 0&&!this.#isBackgroundFetch(this.#valList[e])&&(yield t)}}*values(){for(let e of this.#indexes())this.#valList[e]!==void 0&&!this.#isBackgroundFetch(this.#valList[e])&&(yield this.#valList[e])}*rvalues(){for(let e of this.#rindexes())this.#valList[e]!==void 0&&!this.#isBackgroundFetch(this.#valList[e])&&(yield this.#valList[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]=`LRUCache`;find(e,t={}){for(let n of this.#indexes()){let r=this.#valList[n],i=this.#isBackgroundFetch(r)?r.__staleWhileFetching:r;if(i!==void 0&&e(i,this.#keyList[n],this))return this.get(this.#keyList[n],t)}}forEach(e,t=this){for(let n of this.#indexes()){let r=this.#valList[n],i=this.#isBackgroundFetch(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#keyList[n],this)}}rforEach(e,t=this){for(let n of this.#rindexes()){let r=this.#valList[n],i=this.#isBackgroundFetch(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#keyList[n],this)}}purgeStale(){let e=!1;for(let t of this.#rindexes({allowStale:!0}))this.#isStale(t)&&(this.#delete(this.#keyList[t],`expire`),e=!0);return e}info(e){let t=this.#keyMap.get(e);if(t===void 0)return;let n=this.#valList[t],r=this.#isBackgroundFetch(n)?n.__staleWhileFetching:n;if(r===void 0)return;let i={value:r};if(this.#ttls&&this.#starts){let e=this.#ttls[t],n=this.#starts[t];e&&n&&(i.ttl=e-(this.#perf.now()-n),i.start=Date.now())}return this.#sizes&&(i.size=this.#sizes[t]),i}dump(){let e=[];for(let t of this.#indexes({allowStale:!0})){let n=this.#keyList[t],r=this.#valList[t],i=this.#isBackgroundFetch(r)?r.__staleWhileFetching:r;if(i===void 0||n===void 0)continue;let a={value:i};if(this.#ttls&&this.#starts){a.ttl=this.#ttls[t];let e=this.#perf.now()-this.#starts[t];a.start=Math.floor(Date.now()-e)}this.#sizes&&(a.size=this.#sizes[t]),e.unshift([n,a])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let e=Date.now()-n.start;n.start=this.#perf.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(t===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:i,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:s}=n,{noUpdateTTL:c=this.noUpdateTTL}=n,l=this.#requireSize(e,t,n.size||0,o);if(this.maxEntrySize&&l>this.maxEntrySize)return s&&(s.set=`miss`,s.maxEntrySizeExceeded=!0),this.#delete(e,`set`),this;let u=this.#size===0?void 0:this.#keyMap.get(e);if(u===void 0)u=this.#size===0?this.#tail:this.#free.length===0?this.#size===this.#max?this.#evict(!1):this.#size:this.#free.pop(),this.#keyList[u]=e,this.#valList[u]=t,this.#keyMap.set(e,u),this.#next[this.#tail]=u,this.#prev[u]=this.#tail,this.#tail=u,this.#size++,this.#addItemSize(u,l,s),s&&(s.set=`add`),c=!1,this.#hasOnInsert&&this.#onInsert?.(t,e,`add`);else{this.#moveToTail(u);let n=this.#valList[u];if(t!==n){if(this.#hasFetchMethod&&this.#isBackgroundFetch(n)){n.__abortController.abort(Error(`replaced`));let{__staleWhileFetching:t}=n;t!==void 0&&!a&&(this.#hasDispose&&this.#dispose?.(t,e,`set`),this.#hasDisposeAfter&&this.#disposed?.push([t,e,`set`]))}else a||(this.#hasDispose&&this.#dispose?.(n,e,`set`),this.#hasDisposeAfter&&this.#disposed?.push([n,e,`set`]));if(this.#removeItemSize(u),this.#addItemSize(u,l,s),this.#valList[u]=t,s){s.set=`replace`;let e=n&&this.#isBackgroundFetch(n)?n.__staleWhileFetching:n;e!==void 0&&(s.oldValue=e)}}else s&&(s.set=`update`);this.#hasOnInsert&&this.onInsert?.(t,e,t===n?`update`:`replace`)}if(r!==0&&!this.#ttls&&this.#initializeTTLTracking(),this.#ttls&&(c||this.#setItemTTL(u,r,i),s&&this.#statusTTL(s,u)),!a&&this.#hasDisposeAfter&&this.#disposed){let e=this.#disposed,t;for(;t=e?.shift();)this.#disposeAfter?.(...t)}return this}pop(){try{for(;this.#size;){let e=this.#valList[this.#head];if(this.#evict(!0),this.#isBackgroundFetch(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#hasDisposeAfter&&this.#disposed){let e=this.#disposed,t;for(;t=e?.shift();)this.#disposeAfter?.(...t)}}}#evict(e){let t=this.#head,n=this.#keyList[t],r=this.#valList[t];return this.#hasFetchMethod&&this.#isBackgroundFetch(r)?r.__abortController.abort(Error(`evicted`)):(this.#hasDispose||this.#hasDisposeAfter)&&(this.#hasDispose&&this.#dispose?.(r,n,`evict`),this.#hasDisposeAfter&&this.#disposed?.push([r,n,`evict`])),this.#removeItemSize(t),this.#autopurgeTimers?.[t]&&(clearTimeout(this.#autopurgeTimers[t]),this.#autopurgeTimers[t]=void 0),e&&(this.#keyList[t]=void 0,this.#valList[t]=void 0,this.#free.push(t)),this.#size===1?(this.#head=this.#tail=0,this.#free.length=0):this.#head=this.#next[t],this.#keyMap.delete(n),this.#size--,t}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=t,i=this.#keyMap.get(e);if(i!==void 0){let e=this.#valList[i];if(this.#isBackgroundFetch(e)&&e.__staleWhileFetching===void 0)return!1;if(this.#isStale(i))r&&(r.has=`stale`,this.#statusTTL(r,i));else return n&&this.#updateItemAge(i),r&&(r.has=`hit`,this.#statusTTL(r,i)),!0}else r&&(r.has=`miss`);return!1}peek(e,t={}){let{allowStale:n=this.allowStale}=t,r=this.#keyMap.get(e);if(r===void 0||!n&&this.#isStale(r))return;let i=this.#valList[r];return this.#isBackgroundFetch(i)?i.__staleWhileFetching:i}#backgroundFetch(e,t,n,r){let a=t===void 0?void 0:this.#valList[t];if(this.#isBackgroundFetch(a))return a;let o=new AC,{signal:s}=n;s?.addEventListener(`abort`,()=>o.abort(s.reason),{signal:o.signal});let c={signal:o.signal,options:n,context:r},l=(r,i=!1)=>{let{aborted:a}=o.signal,s=n.ignoreFetchAbort&&r!==void 0,l=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&r!==void 0);if(n.status&&(a&&!i?(n.status.fetchAborted=!0,n.status.fetchError=o.signal.reason,s&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),a&&!s&&!i)return d(o.signal.reason,l);let u=p,f=this.#valList[t];return(f===p||s&&i&&f===void 0)&&(r===void 0?u.__staleWhileFetching===void 0?this.#delete(e,`fetch`):this.#valList[t]=u.__staleWhileFetching:(n.status&&(n.status.fetchUpdated=!0),this.set(e,r,c.options))),r},u=e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),d(e,!1)),d=(r,i)=>{let{aborted:a}=o.signal,s=a&&n.allowStaleOnFetchAbort,c=s||n.allowStaleOnFetchRejection,l=c||n.noDeleteOnFetchRejection,u=p;if(this.#valList[t]===p&&(!l||!i&&u.__staleWhileFetching===void 0?this.#delete(e,`fetch`):s||(this.#valList[t]=u.__staleWhileFetching)),c)return n.status&&u.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),u.__staleWhileFetching;if(u.__returned===u)throw r},f=(t,r)=>{let i=this.#fetchMethod?.(e,a,c);i&&i instanceof Promise&&i.then(e=>t(e===void 0?void 0:e),r),o.signal.addEventListener(`abort`,()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>l(e,!0)))})};n.status&&(n.status.fetchDispatched=!0);let p=new Promise(f).then(l,u),m=Object.assign(p,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,m,{...c.options,status:void 0}),t=this.#keyMap.get(e)):this.#valList[t]=m,m}#isBackgroundFetch(e){if(!this.#hasFetchMethod)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty(`__staleWhileFetching`)&&t.__abortController instanceof AC}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:s=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:h=!1,status:g,signal:_}=t;if(!this.#hasFetchMethod)return g&&(g.fetch=`get`),this.get(e,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:g});let v={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:a,noDisposeOnSet:o,size:s,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:p,ignoreFetchAbort:f,status:g,signal:_},y=this.#keyMap.get(e);if(y===void 0){g&&(g.fetch=`miss`);let t=this.#backgroundFetch(e,y,v,m);return t.__returned=t}else{let t=this.#valList[y];if(this.#isBackgroundFetch(t)){let e=n&&t.__staleWhileFetching!==void 0;return g&&(g.fetch=`inflight`,e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let i=this.#isStale(y);if(!h&&!i)return g&&(g.fetch=`hit`),this.#moveToTail(y),r&&this.#updateItemAge(y),g&&this.#statusTTL(g,y),t;let a=this.#backgroundFetch(e,y,v,m),o=a.__staleWhileFetching!==void 0&&n;return g&&(g.fetch=i?`stale`:`refresh`,o&&i&&(g.returnedStale=!0)),o?a.__staleWhileFetching:a.__returned=a}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw Error(`fetch() returned undefined`);return n}memo(e,t={}){let n=this.#memoMethod;if(!n)throw Error(`no memoMethod provided to constructor`);let{context:r,forceRefresh:i,...a}=t,o=this.get(e,a);if(!i&&o!==void 0)return o;let s=n(e,o,{options:a,context:r});return this.set(e,s,a),s}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:a}=t,o=this.#keyMap.get(e);if(o!==void 0){let t=this.#valList[o],s=this.#isBackgroundFetch(t);return a&&this.#statusTTL(a,o),this.#isStale(o)?(a&&(a.get=`stale`),s?(a&&n&&t.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?t.__staleWhileFetching:void 0):(i||this.#delete(e,`expire`),a&&n&&(a.returnedStale=!0),n?t:void 0)):(a&&(a.get=`hit`),s?t.__staleWhileFetching:(this.#moveToTail(o),r&&this.#updateItemAge(o),t))}else a&&(a.get=`miss`)}#connect(e,t){this.#prev[t]=e,this.#next[e]=t}#moveToTail(e){e!==this.#tail&&(e===this.#head?this.#head=this.#next[e]:this.#connect(this.#prev[e],this.#next[e]),this.#connect(this.#tail,e),this.#tail=e)}delete(e){return this.#delete(e,`delete`)}#delete(e,t){let n=!1;if(this.#size!==0){let r=this.#keyMap.get(e);if(r!==void 0)if(this.#autopurgeTimers?.[r]&&(clearTimeout(this.#autopurgeTimers?.[r]),this.#autopurgeTimers[r]=void 0),n=!0,this.#size===1)this.#clear(t);else{this.#removeItemSize(r);let n=this.#valList[r];if(this.#isBackgroundFetch(n)?n.__abortController.abort(Error(`deleted`)):(this.#hasDispose||this.#hasDisposeAfter)&&(this.#hasDispose&&this.#dispose?.(n,e,t),this.#hasDisposeAfter&&this.#disposed?.push([n,e,t])),this.#keyMap.delete(e),this.#keyList[r]=void 0,this.#valList[r]=void 0,r===this.#tail)this.#tail=this.#prev[r];else if(r===this.#head)this.#head=this.#next[r];else{let e=this.#prev[r];this.#next[e]=this.#next[r];let t=this.#next[r];this.#prev[t]=this.#prev[r]}this.#size--,this.#free.push(r)}}if(this.#hasDisposeAfter&&this.#disposed?.length){let e=this.#disposed,t;for(;t=e?.shift();)this.#disposeAfter?.(...t)}return n}clear(){return this.#clear(`delete`)}#clear(e){for(let t of this.#rindexes({allowStale:!0})){let n=this.#valList[t];if(this.#isBackgroundFetch(n))n.__abortController.abort(Error(`deleted`));else{let r=this.#keyList[t];this.#hasDispose&&this.#dispose?.(n,r,e),this.#hasDisposeAfter&&this.#disposed?.push([n,r,e])}}if(this.#keyMap.clear(),this.#valList.fill(void 0),this.#keyList.fill(void 0),this.#ttls&&this.#starts){this.#ttls.fill(0),this.#starts.fill(0);for(let e of this.#autopurgeTimers??[])e!==void 0&&clearTimeout(e);this.#autopurgeTimers?.fill(void 0)}if(this.#sizes&&this.#sizes.fill(0),this.#head=0,this.#tail=0,this.#free.length=0,this.#calculatedSize=0,this.#size=0,this.#hasDisposeAfter&&this.#disposed){let e=this.#disposed,t;for(;t=e?.shift();)this.#disposeAfter?.(...t)}}}exports.LRUCache=LRUCache;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lru-cache",
3
- "version": "11.2.4",
3
+ "version": "11.2.5",
4
4
  "main": "./dist/commonjs/index.js",
5
5
  "exports": {
6
6
  ".": {
package/dist/plugin.mjs CHANGED
@@ -3,8 +3,6 @@ import { a as pathRegExp, i as guessSubpath, o as toImport, s as toPathRegExp, t
3
3
  import { t as resolveModulePath } from "./_chunks/libs/exsolve.mjs";
4
4
  import { builtinModules } from "node:module";
5
5
  import { pathToFileURL } from "node:url";
6
-
7
- //#region src/plugin.ts
8
6
  const PLUGIN_NAME = "nitro:externals";
9
7
  function externals(opts) {
10
8
  const rootDir = resolve(opts.rootDir || ".");
@@ -87,6 +85,4 @@ function externals(opts) {
87
85
  }
88
86
  };
89
87
  }
90
-
91
- //#endregion
92
- export { externals };
88
+ export { externals };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nf3",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "",
5
5
  "repository": "unjs/nf3",
6
6
  "license": "MIT",
@@ -27,9 +27,9 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@rollup/plugin-node-resolve": "^16.0.3",
30
- "@types/node": "^25.0.10",
30
+ "@types/node": "^25.1.0",
31
31
  "@types/semver": "^7.7.1",
32
- "@typescript/native-preview": "^7.0.0-dev.20260122.3",
32
+ "@typescript/native-preview": "^7.0.0-dev.20260128.1",
33
33
  "@vercel/nft": "^1.3.0",
34
34
  "@vitest/coverage-v8": "^4.0.18",
35
35
  "automd": "^0.4.2",
@@ -37,17 +37,17 @@
37
37
  "eslint": "^9.39.2",
38
38
  "eslint-config-unjs": "^0.6.2",
39
39
  "exsolve": "^1.0.8",
40
- "obuild": "^0.4.19",
41
- "oxc-minify": "^0.110.0",
40
+ "obuild": "^0.4.22",
41
+ "oxc-minify": "^0.111.0",
42
42
  "pathe": "^2.0.3",
43
43
  "pkg-types": "^2.3.0",
44
44
  "prettier": "^3.8.1",
45
- "rolldown": "^1.0.0-rc.1",
46
- "rollup": "^4.56.0",
45
+ "rolldown": "^1.0.0-rc.2",
46
+ "rollup": "^4.57.0",
47
47
  "rollup-plugin-esbuild": "^6.2.1",
48
48
  "semver": "^7.7.3",
49
49
  "typescript": "^5.9.3",
50
50
  "vitest": "^4.0.18"
51
51
  },
52
- "packageManager": "pnpm@10.28.1"
52
+ "packageManager": "pnpm@10.28.2"
53
53
  }