nf3 0.3.6 → 0.3.8
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.
- package/dist/_chunks/libs/exsolve.mjs +593 -1
- package/dist/_chunks/libs/pathe.mjs +70 -1
- package/dist/_chunks/trace.mjs +16 -8
- package/dist/db.mjs +11 -14
- package/dist/index.mjs +2 -3
- package/dist/node_modules/@isaacs/brace-expansion/dist/commonjs/index.js +1 -1
- package/dist/node_modules/@isaacs/brace-expansion/package.json +1 -1
- package/dist/node_modules/@vercel/nft/out/analyze.js +1 -1
- package/dist/node_modules/consola/dist/core.cjs +1 -1
- package/dist/node_modules/glob/package.json +1 -1
- package/dist/node_modules/lru-cache/dist/commonjs/index.js +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/node_modules/minimatch/package.json +1 -1
- package/dist/node_modules/semver/package.json +1 -1
- package/dist/plugin.mjs +3 -7
- package/package.json +20 -20
- package/dist/_chunks/trace2.mjs +0 -3
|
@@ -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
|
|
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 };
|
package/dist/_chunks/trace.mjs
CHANGED
|
@@ -4,8 +4,16 @@ 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
|
-
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __exportAll = (all, no_symbols) => {
|
|
9
|
+
let target = {};
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
+
return target;
|
|
16
|
+
};
|
|
9
17
|
const isWindows = process.platform === "win32";
|
|
10
18
|
const NODE_MODULES_RE = /^(?<dir>.+[\\/]node_modules[\\/])(?<name>[^@\\/]+|@[^\\/]+[\\/][^\\/]+)(?:[\\/](?<subpath>.+))?$/;
|
|
11
19
|
function parseNodeModulePath(path) {
|
|
@@ -76,9 +84,11 @@ function toPathRegExp(input) {
|
|
|
76
84
|
if (typeof input === "string") return new RegExp(pathRegExp(input));
|
|
77
85
|
throw new TypeError("Expected a string or RegExp", { cause: input });
|
|
78
86
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
87
|
+
var trace_exports = /* @__PURE__ */ __exportAll({
|
|
88
|
+
DEFAULT_CONDITIONS: () => DEFAULT_CONDITIONS,
|
|
89
|
+
applyProductionCondition: () => applyProductionCondition,
|
|
90
|
+
traceNodeModules: () => traceNodeModules
|
|
91
|
+
});
|
|
82
92
|
const DEFAULT_CONDITIONS = [
|
|
83
93
|
"node",
|
|
84
94
|
"import",
|
|
@@ -258,6 +268,4 @@ async function isFile(file) {
|
|
|
258
268
|
throw error;
|
|
259
269
|
}
|
|
260
270
|
}
|
|
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 };
|
|
271
|
+
export { pathRegExp as a, guessSubpath as i, traceNodeModules as n, toImport as o, trace_exports as r, toPathRegExp as s, DEFAULT_CONDITIONS as t };
|
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,14 @@ const NodeNativePackages = Object.freeze([
|
|
|
38
32
|
"utf-8-validate",
|
|
39
33
|
"keytar"
|
|
40
34
|
]);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
const NonBundleablePackages = [
|
|
36
|
+
"pg",
|
|
37
|
+
"sequelize",
|
|
38
|
+
"@discordjs/ws",
|
|
39
|
+
"@prisma/client",
|
|
40
|
+
"@sentry/node",
|
|
41
|
+
"@sentry/node-core",
|
|
42
|
+
"@sentry/nuxt",
|
|
43
|
+
"@sentry/tanstackstart-react"
|
|
44
|
+
];
|
|
45
|
+
export { NodeNativePackages, NonBundleablePackages };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n 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.expand=expand;const balanced_match_1=require(`@isaacs/balanced-match`),escSlash=`\0SLASH`+Math.random()+`\0`,escOpen=`\0OPEN`+Math.random()+`\0`,escClose=`\0CLOSE`+Math.random()+`\0`,escComma=`\0COMMA`+Math.random()+`\0`,escPeriod=`\0PERIOD`+Math.random()+`\0`,escSlashPattern=new RegExp(escSlash,`g`),escOpenPattern=new RegExp(escOpen,`g`),escClosePattern=new RegExp(escClose,`g`),escCommaPattern=new RegExp(escComma,`g`),escPeriodPattern=new RegExp(escPeriod,`g`),slashPattern=/\\\\/g,openPattern=/\\{/g,closePattern=/\\}/g,commaPattern=/\\,/g,periodPattern=/\\./g;function numeric(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function escapeBraces(e){return e.replace(slashPattern,escSlash).replace(openPattern,escOpen).replace(closePattern,escClose).replace(commaPattern,escComma).replace(periodPattern,escPeriod)}function unescapeBraces(e){return e.replace(escSlashPattern,`\\`).replace(escOpenPattern,`{`).replace(escClosePattern,`}`).replace(escCommaPattern,`,`).replace(escPeriodPattern,`.`)}function parseCommaParts(t){if(!t)return[``];let n=[],r=(0,balanced_match_1.balanced)(`{`,`}`,t);if(!r)return t.split(`,`);let{pre:i,body:a,post:o}=r,s=i.split(`,`);s[s.length-1]+=`{`+a+`}`;let c=parseCommaParts(o);return o.length&&(s[s.length-1]+=c.shift(),s.push.apply(s,c)),n.push.apply(n,s),n}function expand(e){return e
|
|
1
|
+
"use strict";Object.defineProperty(exports,`__esModule`,{value:!0}),exports.EXPANSION_MAX=void 0,exports.expand=expand;const balanced_match_1=require(`@isaacs/balanced-match`),escSlash=`\0SLASH`+Math.random()+`\0`,escOpen=`\0OPEN`+Math.random()+`\0`,escClose=`\0CLOSE`+Math.random()+`\0`,escComma=`\0COMMA`+Math.random()+`\0`,escPeriod=`\0PERIOD`+Math.random()+`\0`,escSlashPattern=new RegExp(escSlash,`g`),escOpenPattern=new RegExp(escOpen,`g`),escClosePattern=new RegExp(escClose,`g`),escCommaPattern=new RegExp(escComma,`g`),escPeriodPattern=new RegExp(escPeriod,`g`),slashPattern=/\\\\/g,openPattern=/\\{/g,closePattern=/\\}/g,commaPattern=/\\,/g,periodPattern=/\\./g;exports.EXPANSION_MAX=1e5;function numeric(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function escapeBraces(e){return e.replace(slashPattern,escSlash).replace(openPattern,escOpen).replace(closePattern,escClose).replace(commaPattern,escComma).replace(periodPattern,escPeriod)}function unescapeBraces(e){return e.replace(escSlashPattern,`\\`).replace(escOpenPattern,`{`).replace(escClosePattern,`}`).replace(escCommaPattern,`,`).replace(escPeriodPattern,`.`)}function parseCommaParts(t){if(!t)return[``];let n=[],r=(0,balanced_match_1.balanced)(`{`,`}`,t);if(!r)return t.split(`,`);let{pre:i,body:a,post:o}=r,s=i.split(`,`);s[s.length-1]+=`{`+a+`}`;let c=parseCommaParts(o);return o.length&&(s[s.length-1]+=c.shift(),s.push.apply(s,c)),n.push.apply(n,s),n}function expand(e,t={}){if(!e)return[];let{max:n=exports.EXPANSION_MAX}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),expand_(escapeBraces(e),n,!0).map(unescapeBraces)}function embrace(e){return`{`+e+`}`}function isPadded(e){return/^-?0\d/.test(e)}function lte(e,t){return e<=t}function gte(e,t){return e>=t}function expand_(t,n,i){let a=[],o=(0,balanced_match_1.balanced)(`{`,`}`,t);if(!o)return[t];let s=o.pre,c=o.post.length?expand_(o.post,n,!1):[``];if(/\$$/.test(o.pre))for(let e=0;e<c.length&&e<n;e++){let t=s+`{`+o.body+`}`+c[e];a.push(t)}else{let e=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(o.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(o.body),u=e||l,d=o.body.indexOf(`,`)>=0;if(!u&&!d)return o.post.match(/,(?!,).*\}/)?(t=o.pre+`{`+o.body+escClose+o.post,expand_(t,n,!0)):[t];let f;if(u)f=o.body.split(/\.\./);else if(f=parseCommaParts(o.body),f.length===1&&f[0]!==void 0&&(f=expand_(f[0],n,!1).map(embrace),f.length===1))return c.map(e=>o.pre+f[0]+e);let p;if(u&&f[0]!==void 0&&f[1]!==void 0){let e=numeric(f[0]),t=numeric(f[1]),n=Math.max(f[0].length,f[1].length),r=f.length===3&&f[2]!==void 0?Math.abs(numeric(f[2])):1,i=lte;t<e&&(r*=-1,i=gte);let a=f.some(isPadded);p=[];for(let o=e;i(o,t);o+=r){let e;if(l)e=String.fromCharCode(o),e===`\\`&&(e=``);else if(e=String(o),a){let t=n-e.length;if(t>0){let n=Array(t+1).join(`0`);e=o<0?`-`+n+e.slice(1):n+e}}p.push(e)}}else{p=[];for(let e=0;e<f.length;e++)p.push.apply(p,expand_(f[e],n,!1))}for(let e=0;e<p.length;e++)for(let t=0;t<c.length&&a.length<n;t++){let n=s+p[e]+c[t];(!i||u||n)&&a.push(n)}}return a}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=analyze;const path_1=__importDefault(require(`path`)),estree_walker_1=require(`estree-walker`),pluginutils_1=require(`@rollup/pluginutils`),static_eval_1=require(`./utils/static-eval`),acorn_1=require(`acorn`),bindings_1=__importDefault(require(`bindings`)),ast_helpers_1=require(`./utils/ast-helpers`),glob_1=require(`glob`),get_package_base_1=require(`./utils/get-package-base`),binary_locators_1=require(`./utils/binary-locators`),interop_require_1=require(`./utils/interop-require`),special_cases_1=__importDefault(require(`./utils/special-cases`)),resolve_dependency_js_1=__importDefault(require(`./resolve-dependency.js`)),node_gyp_build_1=__importDefault(require(`node-gyp-build`)),node_pre_gyp_1=__importDefault(require(`@mapbox/node-pre-gyp`)),url_1=require(`url`),acorn=acorn_1.Parser.extend(require(`acorn-import-attributes`).importAttributesOrAssertions),os_1=__importDefault(require(`os`)),url_2=__importDefault(require(`url`)),wrappers_1=require(`./utils/wrappers`),resolve_from_1=__importDefault(require(`resolve-from`)),staticProcess={cwd:()=>cwd,env:{NODE_ENV:static_eval_1.UNKNOWN,[static_eval_1.UNKNOWN]:!0},[static_eval_1.UNKNOWN]:!0},EXPRESS_SET=Symbol(),EXPRESS_ENGINE=Symbol(),NBIND_INIT=Symbol(),SET_ROOT_DIR=Symbol(),PKG_INFO=Symbol(),FS_FN=Symbol(),FS_DIR_FN=Symbol(),BINDINGS=Symbol(),NODE_GYP_BUILD=Symbol(),fsSymbols={access:FS_FN,accessSync:FS_FN,createReadStream:FS_FN,exists:FS_FN,existsSync:FS_FN,fstat:FS_FN,fstatSync:FS_FN,lstat:FS_FN,lstatSync:FS_FN,open:FS_FN,readdir:FS_DIR_FN,readdirSync:FS_DIR_FN,readFile:FS_FN,readFileSync:FS_FN,stat:FS_FN,statSync:FS_FN},fsExtraSymbols={...fsSymbols,pathExists:FS_FN,pathExistsSync:FS_FN,readJson:FS_FN,readJSON:FS_FN,readJsonSync:FS_FN,readJSONSync:FS_FN},MODULE_FN=Symbol(),CREATE_REQUIRE=Symbol(),moduleSymbols={register:MODULE_FN,createRequire:CREATE_REQUIRE},staticModules=Object.assign(Object.create(null),{bindings:{default:BINDINGS},express:{default:function(){return{[static_eval_1.UNKNOWN]:!0,set:EXPRESS_SET,engine:EXPRESS_ENGINE}}},fs:{default:fsSymbols,...fsSymbols},module:{default:moduleSymbols,...moduleSymbols},"fs-extra":{default:fsExtraSymbols,...fsExtraSymbols},"graceful-fs":{default:fsSymbols,...fsSymbols},process:{default:staticProcess,...staticProcess},path:{default:{}},os:{default:os_1.default,...os_1.default},url:{default:url_2.default,...url_2.default},"@mapbox/node-pre-gyp":{default:node_pre_gyp_1.default,...node_pre_gyp_1.default},"node-pre-gyp":binary_locators_1.pregyp,"node-pre-gyp/lib/pre-binding":binary_locators_1.pregyp,"node-pre-gyp/lib/pre-binding.js":binary_locators_1.pregyp,"node-gyp-build":{default:NODE_GYP_BUILD},"@aminya/node-gyp-build":{default:NODE_GYP_BUILD},nbind:{init:NBIND_INIT,default:{init:NBIND_INIT}},"resolve-from":{default:resolve_from_1.default},"strong-globalize":{default:{SetRootDir:SET_ROOT_DIR},SetRootDir:SET_ROOT_DIR},pkginfo:{default:PKG_INFO}}),globalBindings={_interopRequireDefault:interop_require_1.normalizeDefaultRequire,_interopRequireWildcard:interop_require_1.normalizeWildcardRequire,__importDefault:interop_require_1.normalizeDefaultRequire,__importStar:interop_require_1.normalizeWildcardRequire,MONGOOSE_DRIVER_PATH:void 0,URL:url_1.URL,Object:{assign:Object.assign}};globalBindings.global=globalBindings.GLOBAL=globalBindings.globalThis=globalBindings;const TRIGGER=Symbol();binary_locators_1.pregyp.find[TRIGGER]=!0;const staticPath=staticModules.path;Object.keys(path_1.default).forEach(e=>{let n=path_1.default[e];if(typeof n==`function`){let t=function e(){return n.apply(e,arguments)};t[TRIGGER]=!0,staticPath[e]=staticPath.default[e]=t}else staticPath[e]=staticPath.default[e]=n}),staticPath.resolve=staticPath.default.resolve=function(...e){return path_1.default.resolve.apply(this,[cwd,...e])},staticPath.resolve[TRIGGER]=!0;const excludeAssetExtensions=new Set([`.h`,`.cmake`,`.c`,`.cpp`]),excludeAssetFiles=new Set([`CHANGELOG.md`,`README.md`,`readme.md`,`changelog.md`]);let cwd;const absoluteRegEx=/^\/[^\/]+|^[a-z]:[\\/][^\\/]+/i;function isAbsolutePathOrUrl(e){if(e instanceof url_1.URL)return e.protocol===`file:`;if(typeof e==`string`){if(e.startsWith(`file:`))try{return new url_1.URL(e),!0}catch{return!1}return absoluteRegEx.test(e)}return!1}const BOUND_REQUIRE=Symbol(),repeatGlobRegEx=/([\/\\]\*\*[\/\\]\*)+/g;async function analyze(e,a,c){let l=new Set,u=new Set,d=new Set,f=path_1.default.dirname(e);cwd=c.cwd;let p=(0,get_package_base_1.getPackageBase)(e),m=e=>{if(!c.analysis.emitGlobs)return;e=e.replaceAll(path_1.default.sep,path_1.default.posix.sep);let n=e.indexOf(static_eval_1.WILDCARD),r=n===-1?e.length:e.lastIndexOf(path_1.default.posix.sep,n),a=e.substring(0,r),o=e.slice(r),s=o.replace(static_eval_1.wildcardRegEx,(e,n)=>o[n-1]===path_1.default.posix.sep?`**/*`:`*`).replace(repeatGlobRegEx,`/**/*`)||`/**/*`;c.ignoreFn(path_1.default.relative(c.base,a+s))||(h=h.then(async()=>{c.log&&console.log(`Globbing `+a+s),(await(0,glob_1.glob)(a+s,{mark:!0,ignore:a+`/**/node_modules/**/*`,dot:!0,nodir:!0})).filter(e=>!excludeAssetExtensions.has(path_1.default.extname(e))&&!excludeAssetFiles.has(path_1.default.basename(e))).forEach(e=>l.add(e))}))},h=Promise.resolve();a=a.replace(/^#![^\n\r]*[\r\n]/,``);let g,_=!1;try{g=acorn.parse(a,{ecmaVersion:`latest`,allowReturnOutsideFunction:!0}),_=!1}catch(t){t&&t.message&&t.message.includes(`sourceType: module`)||c.warnings.add(Error(`Failed to parse ${e} as script:\n${t&&t.message}`))}if(!g)try{g=acorn.parse(a,{ecmaVersion:`latest`,sourceType:`module`,allowAwaitOutsideFunction:!0}),_=!0}catch(t){return c.warnings.add(Error(`Failed to parse ${e} as module:\n${t&&t.message}`)),{assets:l,deps:u,imports:d,isESM:!1}}let v=(0,url_1.pathToFileURL)(e).href,y=Object.assign(Object.create(null),{__dirname:{shadowDepth:0,value:{value:path_1.default.resolve(e,`..`)}},__filename:{shadowDepth:0,value:{value:e}},process:{shadowDepth:0,value:{value:staticProcess}}});(!_||c.mixedModules)&&(y.require={shadowDepth:0,value:{value:{[static_eval_1.FUNCTION](e){return u.add(e),staticModules[e.startsWith(`node:`)?e.slice(5):e].default},resolve(t){return(0,resolve_dependency_js_1.default)(t,e,c)}}}},y.require.value.value.resolve[TRIGGER]=!0);function b(e,t){e===`require`&&`value`in t&&t.value!==BOUND_REQUIRE||(y[e]={shadowDepth:0,value:t})}function x(e){let t=y[e];if(t&&t.shadowDepth===0)return t.value}function S(e){let t=y[e];return t&&t.shadowDepth===0}if((_||c.mixedModules)&&isAst(g))for(let e of g.body)if(e.type===`ImportDeclaration`){let t=String(e.source.value);u.add(t);let n=staticModules[t.startsWith(`node:`)?t.slice(5):t];if(n)for(let t of e.specifiers)t.type===`ImportNamespaceSpecifier`?b(t.local.name,{value:n}):t.type===`ImportDefaultSpecifier`&&`default`in n?b(t.local.name,{value:n.default}):t.type===`ImportSpecifier`&&t.imported.name in n&&b(t.local.name,{value:n[t.imported.name]})}else (e.type===`ExportNamedDeclaration`||e.type===`ExportAllDeclaration`)&&e.source&&u.add(String(e.source.value));async function C(e,t=!0){let n=Object.create(null);return Object.keys(globalBindings).forEach(e=>{n[e]={value:globalBindings[e]}}),Object.keys(y).forEach(e=>{n[e]=x(e)}),n[`import.meta`]={url:v},await(0,static_eval_1.evaluate)(e,n,t)}let w,T,E=!1;function D(e){if(!c.analysis.emitGlobs||!e.startsWith(`./`)&&!e.startsWith(`../`))return;e=path_1.default.resolve(f,e).replaceAll(path_1.default.sep,path_1.default.posix.sep);let n=e.indexOf(static_eval_1.WILDCARD),r=n===-1?e.length:e.lastIndexOf(path_1.default.posix.sep,n),a=e.substring(0,r),o=e.slice(r),s=o.replace(static_eval_1.wildcardRegEx,(e,n)=>o[n-1]===path_1.default.posix.sep?`**/*`:`*`)||`/**/*`;s.endsWith(`*`)||(s+=`?(`+(c.ts?`.ts|.tsx|`:``)+`.js|.json|.node)`),!c.ignoreFn(path_1.default.relative(c.base,a+s))&&(h=h.then(async()=>{c.log&&console.log(`Globbing `+a+s),(await(0,glob_1.glob)(a+s,{mark:!0,ignore:a+`/**/node_modules/**/*`,nodir:!0})).filter(e=>!excludeAssetExtensions.has(path_1.default.extname(e))&&!excludeAssetFiles.has(path_1.default.basename(e))).forEach(e=>u.add(e))}))}async function O(e,t=!1){if(e.type===`ConditionalExpression`){await O(e.consequent,t),await O(e.alternate,t);return}if(e.type===`LogicalExpression`){await O(e.left,t),await O(e.right,t);return}let n=await C(e,!0);if(!n)return;function r(e){(t?d:u).add(e)}`value`in n&&typeof n.value==`string`?n.wildcards?n.wildcards.length>=1&&D(n.value):r(n.value):(`ifTrue`in n&&typeof n.ifTrue==`string`&&r(n.ifTrue),`else`in n&&typeof n.else==`string`&&r(n.else))}let k=(0,pluginutils_1.attachScopes)(g,`scope`);isAst(g)&&((0,wrappers_1.handleWrappers)(g),await(0,special_cases_1.default)({id:e,ast:g,emitDependency:e=>u.add(e),emitAsset:e=>l.add(e),emitAssetDirectory:m,job:c}));async function A(e,t){if(!w)throw Error(`Internal error: No staticChildNode for backtrack.`);let n=await C(e,!0);if(n&&(`value`in n&&typeof n.value!=`symbol`||`ifTrue`in n&&typeof n.ifTrue!=`symbol`&&typeof n.else!=`symbol`)){T=n,w=e,t&&t.skip();return}await P()}return await(0,estree_walker_1.asyncWalk)(g,{async enter(n,r){let i=n,a=r;if(i.scope)for(let e in k=i.scope,i.scope.declarations)e in y&&y[e].shadowDepth++;if(!w&&a){if(i.type===`Identifier`){if((0,ast_helpers_1.isIdentifierRead)(i,a)&&c.analysis.computeFileReferences){let e;(typeof(e=x(i.name)?.value)==`string`&&e.match(absoluteRegEx)||e&&(typeof e==`function`||typeof e==`object`)&&e[TRIGGER])&&(T={value:typeof e==`string`?e:void 0},w=i,await A(a,this))}}else if(c.analysis.computeFileReferences&&i.type===`MemberExpression`&&i.object.type===`MetaProperty`&&i.object.meta.name===`import`&&i.object.property.name===`meta`&&(i.property.computed?i.property.value:i.property.name)===`url`)T={value:v},w=i,await A(a,this);else if(i.type===`ImportExpression`){await O(i.source,!0);return}else if(i.type===`CallExpression`){if((!_||c.mixedModules)&&i.callee.type===`Identifier`&&i.arguments.length){if(i.callee.name===`require`&&y.require&&y.require.shadowDepth===0){await O(i.arguments[0]);return}}else if((!_||c.mixedModules)&&i.callee.type===`MemberExpression`&&i.callee.object.type===`Identifier`&&i.callee.object.name===`module`&&!(`module`in y)&&i.callee.property.type===`Identifier`&&!i.callee.computed&&i.callee.property.name===`require`&&i.arguments.length){await O(i.arguments[0]);return}else if((!_||c.mixedModules)&&i.callee.type===`MemberExpression`&&i.callee.object.type===`Identifier`&&i.callee.object.name===`require`&&y.require&&y.require.shadowDepth===0&&i.callee.property.type===`Identifier`&&!i.callee.computed&&i.callee.property.name===`resolve`&&i.arguments.length){await O(i.arguments[0]);return}let n=c.analysis.evaluatePureExpressions&&await C(i.callee,!1);if(n&&`value`in n&&typeof n.value==`function`&&n.value[TRIGGER]&&c.analysis.computeFileReferences)T=await C(i,!0),T&&a&&(w=i,await A(a,this));else if(n&&`value`in n&&typeof n.value==`symbol`)switch(n.value){case BOUND_REQUIRE:i.arguments.length===1&&i.arguments[0].type===`Literal`&&i.callee.type===`Identifier`&&(!y.require||y.require.shadowDepth===0)&&await O(i.arguments[0]);break;case BINDINGS:if(i.arguments.length){let e=await C(i.arguments[0],!1);if(e&&`value`in e&&e.value){let t;typeof e.value==`object`?t=e.value:typeof e.value==`string`&&(t={bindings:e.value}),t.path||=!0,t.module_root=p;let n;try{n=(0,bindings_1.default)(t)}catch{}n&&(T={value:n},w=i,await P())}}break;case NODE_GYP_BUILD:if(i.arguments.length){let e=await C(i.arguments[0],!1);if(e&&`value`in e&&e.value){let t=e.value,n;try{let e=i?.callee?.arguments?.[0]?.value||`node-gyp-build`,r=(0,resolve_from_1.default)(t,e);n=require(r).path(t)}catch{try{n=node_gyp_build_1.default.path(t)}catch{}}n&&(T={value:n},w=i,await P())}}break;case NBIND_INIT:if(i.arguments.length){let e=await C(i.arguments[0],!1);if(e&&`value`in e&&(typeof e.value==`string`||e.value===void 0)){let n=(0,binary_locators_1.nbind)(e.value);if(n&&n.path)return u.add(path_1.default.relative(f,n.path).replace(/\\/g,`/`)),this.skip()}}break;case EXPRESS_SET:if(i.arguments.length===2&&i.arguments[0].type===`Literal`&&i.arguments[0].value===`view engine`&&!E)return await O(i.arguments[1]),this.skip();break;case EXPRESS_ENGINE:E=!0;break;case FS_FN:case FS_DIR_FN:if(i.arguments[0]&&c.analysis.computeFileReferences&&(T=await C(i.arguments[0],!0),T))return w=i.arguments[0],n.value===FS_DIR_FN&&i.arguments[0].type===`Identifier`&&i.arguments[0].name===`__dirname`?m(f):await A(a,this),this.skip();break;case SET_ROOT_DIR:if(i.arguments[0]){let e=await C(i.arguments[0],!1);return e&&`value`in e&&e.value&&m(e.value+`/intl`),this.skip()}break;case PKG_INFO:let r=path_1.default.resolve(e,`../package.json`),s=path_1.default.resolve(`/package.json`);for(;r!==s&&await c.stat(r)===null;)r=path_1.default.resolve(r,`../../package.json`);r!==s&&l.add(r);break;case MODULE_FN:if(i.arguments.length&&i.arguments[0].type===`Literal`){let e=i.arguments[0].value;if(e.startsWith(`.`)){let n=i.arguments.length>1?await C(i.arguments[1]):void 0;if(n&&`value`in n){let r=n.value instanceof url_1.URL?n.value.href:typeof n.value==`string`?n.value:n.value.parentURL,i=new url_1.URL(e,r).href,a=v.slice(0,v.lastIndexOf(`/`)),o=path_1.default.relative(a,i),s=o.startsWith(`.`)?o:`./`+o;d.add(s)}}else d.add(e)}break}}else if(i.type===`VariableDeclaration`&&a&&!(0,ast_helpers_1.isVarLoop)(a)&&c.analysis.evaluatePureExpressions)for(let e of i.declarations){if(!e.init)continue;let t=await C(e.init,!0);if(t){if(e.id.type===`Identifier`)b(e.id.name,t);else if(e.id.type===`ObjectPattern`&&`value`in t)for(let n of e.id.properties)n.type!==`Property`||n.key.type!==`Identifier`||n.value.type!==`Identifier`||typeof t.value!=`object`||t.value===null||!(n.key.name in t.value)||b(n.value.name,{value:t.value[n.key.name]});!(`value`in t)&&isAbsolutePathOrUrl(t.ifTrue)&&isAbsolutePathOrUrl(t.else)&&(T=t,w=e.init,await P())}}else if(i.type===`AssignmentExpression`&&a&&!(0,ast_helpers_1.isLoop)(a)&&c.analysis.evaluatePureExpressions){if(!S(i.left.name)){let e=await C(i.right,!1);if(e&&`value`in e){if(i.left.type===`Identifier`)b(i.left.name,e);else if(i.left.type===`ObjectPattern`)for(let t of i.left.properties)t.type!==`Property`||t.key.type!==`Identifier`||t.value.type!==`Identifier`||typeof e.value!=`object`||e.value===null||!(t.key.name in e.value)||b(t.value.name,{value:e.value[t.key.name]});isAbsolutePathOrUrl(e.value)&&(T=e,w=i.right,await P())}}}else if((!_||c.mixedModules)&&(i.type===`FunctionDeclaration`||i.type===`FunctionExpression`||i.type===`ArrowFunctionExpression`)&&(i.arguments||i.params)[0]&&(i.arguments||i.params)[0].type===`Identifier`){let e,t;if((i.type===`ArrowFunctionExpression`||i.type===`FunctionExpression`)&&a&&a.type===`VariableDeclarator`&&a.id.type===`Identifier`?(e=a.id,t=i.arguments||i.params):i.id&&(e=i.id,t=i.arguments||i.params),e&&i.body.body){let n,r=!1;for(let e=0;e<i.body.body.length;e++)if(i.body.body[e].type===`VariableDeclaration`&&!n&&(n=i.body.body[e].declarations.find(e=>e&&e.id&&e.id.type===`Identifier`&&e.init&&e.init.type===`CallExpression`&&e.init.callee.type===`Identifier`&&e.init.callee.name===`require`&&y.require.shadowDepth===0&&e.init.arguments[0]&&e.init.arguments[0].type===`Identifier`&&e.init.arguments[0].name===t[0].name)),n&&i.body.body[e].type===`ReturnStatement`&&i.body.body[e].argument&&i.body.body[e].argument.type===`Identifier`&&i.body.body[e].argument.name===n.id.name){r=!0;break}r&&b(e.name,{value:BOUND_REQUIRE})}}if(i.type===`CallExpression`&&i.callee.type===`MemberExpression`&&i.callee.object.type===`Identifier`&&i.callee.object.name===`module`&&i.callee.property.type===`Identifier`&&i.callee.property.name===`createRequire`&&a.type===`VariableDeclarator`&&a.id.type===`Identifier`){let e=a.id.name;b(e,{value:BOUND_REQUIRE})}if(i.type===`CallExpression`&&i.callee.type===`Identifier`&&i.callee.name===`createRequire`){let e=x(`createRequire`);if(e&&`value`in e&&e.value===CREATE_REQUIRE&&a.type===`VariableDeclarator`&&a.id.type===`Identifier`){let e=a.id.name;b(e,{value:BOUND_REQUIRE})}}}},async leave(e,t){let n=e,r=t;if(n.scope)for(let e in k.parent&&(k=k.parent),n.scope.declarations)e in y&&(y[e].shadowDepth>0?y[e].shadowDepth--:delete y[e]);w&&r&&await A(r,this)}}),await h,{assets:l,deps:u,imports:d,isESM:_};async function j(e){let n=e.indexOf(static_eval_1.WILDCARD),r=n===-1?e.length:e.lastIndexOf(path_1.default.sep,n),a=e.substring(0,r);try{var o=await c.stat(a);if(o===null)throw Error(`file not found`)}catch{return}n!==-1&&o.isFile()||(o.isFile()?l.add(e):o.isDirectory()&&M(e)&&m(e))}function M(n){let r=``;if(n.endsWith(path_1.default.sep)?r=path_1.default.sep:n.endsWith(path_1.default.sep+static_eval_1.WILDCARD)?r=path_1.default.sep+static_eval_1.WILDCARD:n.endsWith(static_eval_1.WILDCARD)&&(r=static_eval_1.WILDCARD),n===f+r||n===cwd+r||n.endsWith(path_1.default.sep+`node_modules`+r)||f.startsWith(n.slice(0,n.length-r.length)+path_1.default.sep))return!1;if(p){let r=e.substring(0,e.indexOf(path_1.default.sep+`node_modules`))+path_1.default.sep+`node_modules`+path_1.default.sep;if(!n.startsWith(r))return c.log&&console.log(`Skipping asset emission of `+n.replace(static_eval_1.wildcardRegEx,`*`)+` for `+e+` as it is outside the package base `+p),!1}return!0}function N(e){return e instanceof url_1.URL?(0,url_1.fileURLToPath)(e):e.startsWith(`file:`)?(0,url_1.fileURLToPath)(new url_1.URL(e)):path_1.default.resolve(e)}async function P(){if(T){if(`value`in T&&isAbsolutePathOrUrl(T.value))try{await j(N(T.value))}catch{}else if(`ifTrue`in T&&`else`in T&&isAbsolutePathOrUrl(T.ifTrue)&&isAbsolutePathOrUrl(T.else)){let e;try{e=N(T.ifTrue)}catch{}let t;try{t=N(T.else)}catch{}e&&await j(e),t&&await j(t)}else if(w&&w.type===`ArrayExpression`&&`value`in T&&T.value instanceof Array)for(let e of T.value)try{await j(N(e))}catch{}w=T=void 0}}}function isAst(e){return`body`in e}
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=analyze;const path_1=__importDefault(require(`path`)),estree_walker_1=require(`estree-walker`),pluginutils_1=require(`@rollup/pluginutils`),static_eval_1=require(`./utils/static-eval`),acorn_1=require(`acorn`),bindings_1=__importDefault(require(`bindings`)),ast_helpers_1=require(`./utils/ast-helpers`),glob_1=require(`glob`),get_package_base_1=require(`./utils/get-package-base`),binary_locators_1=require(`./utils/binary-locators`),interop_require_1=require(`./utils/interop-require`),special_cases_1=__importDefault(require(`./utils/special-cases`)),resolve_dependency_js_1=__importDefault(require(`./resolve-dependency.js`)),node_gyp_build_1=__importDefault(require(`node-gyp-build`)),node_pre_gyp_1=__importDefault(require(`@mapbox/node-pre-gyp`)),url_1=require(`url`),acorn=acorn_1.Parser.extend(require(`acorn-import-attributes`).importAttributesOrAssertions),os_1=__importDefault(require(`os`)),url_2=__importDefault(require(`url`)),wrappers_1=require(`./utils/wrappers`),resolve_from_1=__importDefault(require(`resolve-from`)),staticProcess={cwd:()=>cwd,env:{NODE_ENV:static_eval_1.UNKNOWN,[static_eval_1.UNKNOWN]:!0},[static_eval_1.UNKNOWN]:!0},EXPRESS_SET=Symbol(),EXPRESS_ENGINE=Symbol(),NBIND_INIT=Symbol(),SET_ROOT_DIR=Symbol(),PKG_INFO=Symbol(),FS_FN=Symbol(),FS_DIR_FN=Symbol(),BINDINGS=Symbol(),NODE_GYP_BUILD=Symbol(),fsSymbols={access:FS_FN,accessSync:FS_FN,createReadStream:FS_FN,exists:FS_FN,existsSync:FS_FN,fstat:FS_FN,fstatSync:FS_FN,lstat:FS_FN,lstatSync:FS_FN,open:FS_FN,readdir:FS_DIR_FN,readdirSync:FS_DIR_FN,readFile:FS_FN,readFileSync:FS_FN,stat:FS_FN,statSync:FS_FN},fsExtraSymbols={...fsSymbols,pathExists:FS_FN,pathExistsSync:FS_FN,readJson:FS_FN,readJSON:FS_FN,readJsonSync:FS_FN,readJSONSync:FS_FN},MODULE_FN=Symbol(),CREATE_REQUIRE=Symbol(),moduleSymbols={register:MODULE_FN,createRequire:CREATE_REQUIRE},staticModules=Object.assign(Object.create(null),{bindings:{default:BINDINGS},express:{default:function(){return{[static_eval_1.UNKNOWN]:!0,set:EXPRESS_SET,engine:EXPRESS_ENGINE}}},fs:{default:fsSymbols,...fsSymbols},module:{default:moduleSymbols,...moduleSymbols},"fs-extra":{default:fsExtraSymbols,...fsExtraSymbols},"graceful-fs":{default:fsSymbols,...fsSymbols},process:{default:staticProcess,...staticProcess},path:{default:{}},os:{default:os_1.default,...os_1.default},url:{default:url_2.default,...url_2.default},"@mapbox/node-pre-gyp":{default:node_pre_gyp_1.default,...node_pre_gyp_1.default},"node-pre-gyp":binary_locators_1.pregyp,"node-pre-gyp/lib/pre-binding":binary_locators_1.pregyp,"node-pre-gyp/lib/pre-binding.js":binary_locators_1.pregyp,"node-gyp-build":{default:NODE_GYP_BUILD},"@aminya/node-gyp-build":{default:NODE_GYP_BUILD},nbind:{init:NBIND_INIT,default:{init:NBIND_INIT}},"resolve-from":{default:resolve_from_1.default},"strong-globalize":{default:{SetRootDir:SET_ROOT_DIR},SetRootDir:SET_ROOT_DIR},pkginfo:{default:PKG_INFO}}),globalBindings={_interopRequireDefault:interop_require_1.normalizeDefaultRequire,_interopRequireWildcard:interop_require_1.normalizeWildcardRequire,__importDefault:interop_require_1.normalizeDefaultRequire,__importStar:interop_require_1.normalizeWildcardRequire,MONGOOSE_DRIVER_PATH:void 0,URL:url_1.URL,Object:{assign:Object.assign}};globalBindings.global=globalBindings.GLOBAL=globalBindings.globalThis=globalBindings;const TRIGGER=Symbol();binary_locators_1.pregyp.find[TRIGGER]=!0;const staticPath=staticModules.path;Object.keys(path_1.default).forEach(e=>{let n=path_1.default[e];if(typeof n==`function`){let t=function e(){return n.apply(e,arguments)};t[TRIGGER]=!0,staticPath[e]=staticPath.default[e]=t}else staticPath[e]=staticPath.default[e]=n}),staticPath.resolve=staticPath.default.resolve=function(...e){return path_1.default.resolve.apply(this,[cwd,...e])},staticPath.resolve[TRIGGER]=!0;const excludeAssetExtensions=new Set([`.h`,`.cmake`,`.c`,`.cpp`]),excludeAssetFiles=new Set([`CHANGELOG.md`,`README.md`,`readme.md`,`changelog.md`]);let cwd;const absoluteRegEx=/^\/[^\/]+|^[a-z]:[\\/][^\\/]+/i;function isAbsolutePathOrUrl(e){if(e instanceof url_1.URL)return e.protocol===`file:`;if(typeof e==`string`){if(e.startsWith(`file:`))try{return new url_1.URL(e),!0}catch{return!1}return absoluteRegEx.test(e)}return!1}const BOUND_REQUIRE=Symbol(),repeatGlobRegEx=/([\/\\]\*\*[\/\\]\*)+/g;async function analyze(e,a,c){let l=new Set,u=new Set,d=new Set,f=path_1.default.dirname(e);cwd=c.cwd;let p=(0,get_package_base_1.getPackageBase)(e),m=e=>{if(!c.analysis.emitGlobs)return;e=e.replaceAll(path_1.default.sep,path_1.default.posix.sep);let n=e.indexOf(static_eval_1.WILDCARD),r=n===-1?e.length:e.lastIndexOf(path_1.default.posix.sep,n),a=e.substring(0,r),o=e.slice(r),s=o.replace(static_eval_1.wildcardRegEx,(e,n)=>o[n-1]===path_1.default.posix.sep?`**/*`:`*`).replace(repeatGlobRegEx,`/**/*`)||`/**/*`;c.ignoreFn(path_1.default.relative(c.base,a+s))||(h=h.then(async()=>{c.log&&console.log(`Globbing `+a+s),(await(0,glob_1.glob)(a+s,{mark:!0,ignore:a+`/**/node_modules/**/*`,dot:!0,nodir:!0})).filter(e=>!excludeAssetExtensions.has(path_1.default.extname(e))&&!excludeAssetFiles.has(path_1.default.basename(e))).forEach(e=>l.add(e))}))},h=Promise.resolve();a=a.replace(/^#![^\n\r]*[\r\n]/,``);let g,_=!1;try{g=acorn.parse(a,{ecmaVersion:`latest`,allowReturnOutsideFunction:!0}),_=!1}catch(t){t&&t.message&&t.message.includes(`sourceType: module`)||c.warnings.add(Error(`Failed to parse ${e} as script:\n${t&&t.message}`))}if(!g)try{g=acorn.parse(a,{ecmaVersion:`latest`,sourceType:`module`,allowAwaitOutsideFunction:!0}),_=!0}catch(t){return c.warnings.add(Error(`Failed to parse ${e} as module:\n${t&&t.message}`)),{assets:l,deps:u,imports:d,isESM:!1}}let v=(0,url_1.pathToFileURL)(e).href,y=Object.assign(Object.create(null),{__dirname:{shadowDepth:0,value:{value:path_1.default.resolve(e,`..`)}},__filename:{shadowDepth:0,value:{value:e}},process:{shadowDepth:0,value:{value:staticProcess}}});(!_||c.mixedModules)&&(y.require={shadowDepth:0,value:{value:{[static_eval_1.FUNCTION](e){return u.add(e),staticModules[e.startsWith(`node:`)?e.slice(5):e].default},resolve(t){return(0,resolve_dependency_js_1.default)(t,e,c)}}}},y.require.value.value.resolve[TRIGGER]=!0);function b(e,t){e===`require`&&`value`in t&&t.value!==BOUND_REQUIRE||(y[e]={shadowDepth:0,value:t})}function x(e){let t=y[e];if(t&&t.shadowDepth===0)return t.value}function S(e){let t=y[e];return t&&t.shadowDepth===0}if((_||c.mixedModules)&&isAst(g))for(let e of g.body)if(e.type===`ImportDeclaration`){let t=String(e.source.value);u.add(t);let n=staticModules[t.startsWith(`node:`)?t.slice(5):t];if(n)for(let t of e.specifiers)t.type===`ImportNamespaceSpecifier`?b(t.local.name,{value:n}):t.type===`ImportDefaultSpecifier`&&`default`in n?b(t.local.name,{value:n.default}):t.type===`ImportSpecifier`&&t.imported.name in n&&b(t.local.name,{value:n[t.imported.name]})}else (e.type===`ExportNamedDeclaration`||e.type===`ExportAllDeclaration`)&&e.source&&u.add(String(e.source.value));async function C(e,t=!0){let n=Object.create(null);return Object.keys(globalBindings).forEach(e=>{n[e]={value:globalBindings[e]}}),Object.keys(y).forEach(e=>{n[e]=x(e)}),n[`import.meta`]={url:v},await(0,static_eval_1.evaluate)(e,n,t)}let w,T,E=!1;function D(e){if(!c.analysis.emitGlobs||!e.startsWith(`./`)&&!e.startsWith(`../`))return;e=path_1.default.resolve(f,e).replaceAll(path_1.default.sep,path_1.default.posix.sep);let n=e.indexOf(static_eval_1.WILDCARD),r=n===-1?e.length:e.lastIndexOf(path_1.default.posix.sep,n),a=e.substring(0,r),o=e.slice(r),s=o.replace(static_eval_1.wildcardRegEx,(e,n)=>o[n-1]===path_1.default.posix.sep?`**/*`:`*`)||`/**/*`;s.endsWith(`*`)||(s+=`?(`+(c.ts?`.ts|.tsx|`:``)+`.js|.json|.node)`),!c.ignoreFn(path_1.default.relative(c.base,a+s))&&(h=h.then(async()=>{c.log&&console.log(`Globbing `+a+s),(await(0,glob_1.glob)(a+s,{mark:!0,ignore:a+`/**/node_modules/**/*`,nodir:!0})).filter(e=>!excludeAssetExtensions.has(path_1.default.extname(e))&&!excludeAssetFiles.has(path_1.default.basename(e))).forEach(e=>u.add(e))}))}async function O(e,t=!1){if(e.type===`ConditionalExpression`){await O(e.consequent,t),await O(e.alternate,t);return}if(e.type===`LogicalExpression`){await O(e.left,t),await O(e.right,t);return}let n=await C(e,!0);if(!n)return;function r(e){(t?d:u).add(e)}`value`in n&&typeof n.value==`string`?n.wildcards?n.wildcards.length>=1&&D(n.value):r(n.value):(`ifTrue`in n&&typeof n.ifTrue==`string`&&r(n.ifTrue),`else`in n&&typeof n.else==`string`&&r(n.else))}let k=(0,pluginutils_1.attachScopes)(g,`scope`);isAst(g)&&((0,wrappers_1.handleWrappers)(g),await(0,special_cases_1.default)({id:e,ast:g,emitDependency:e=>u.add(e),emitAsset:e=>l.add(e),emitAssetDirectory:m,job:c}));async function A(e,t){if(!w)throw Error(`Internal error: No staticChildNode for backtrack.`);let n=await C(e,!0);if(n&&(`value`in n&&typeof n.value!=`symbol`||`ifTrue`in n&&typeof n.ifTrue!=`symbol`&&typeof n.else!=`symbol`)){T=n,w=e,t&&t.skip();return}await P()}return await(0,estree_walker_1.asyncWalk)(g,{async enter(n,r){let i=n,a=r;if(i.scope){k=i.scope;for(let e in i.scope.declarations)e in y&&y[e].shadowDepth++}if(!w&&a){if(i.type===`Identifier`){if((0,ast_helpers_1.isIdentifierRead)(i,a)&&c.analysis.computeFileReferences){let e;(typeof(e=x(i.name)?.value)==`string`&&e.match(absoluteRegEx)||e&&(typeof e==`function`||typeof e==`object`)&&e[TRIGGER])&&(T={value:typeof e==`string`?e:void 0},w=i,await A(a,this))}}else if(c.analysis.computeFileReferences&&i.type===`MemberExpression`&&i.object.type===`MetaProperty`&&i.object.meta.name===`import`&&i.object.property.name===`meta`&&(i.property.computed?i.property.value:i.property.name)===`url`)T={value:v},w=i,await A(a,this);else if(i.type===`ImportExpression`){await O(i.source,!0);return}else if(i.type===`CallExpression`){if((!_||c.mixedModules)&&i.callee.type===`Identifier`&&i.arguments.length){if(i.callee.name===`require`&&y.require&&y.require.shadowDepth===0){await O(i.arguments[0]);return}}else if((!_||c.mixedModules)&&i.callee.type===`MemberExpression`&&i.callee.object.type===`Identifier`&&i.callee.object.name===`module`&&!(`module`in y)&&i.callee.property.type===`Identifier`&&!i.callee.computed&&i.callee.property.name===`require`&&i.arguments.length){await O(i.arguments[0]);return}else if((!_||c.mixedModules)&&i.callee.type===`MemberExpression`&&i.callee.object.type===`Identifier`&&i.callee.object.name===`require`&&y.require&&y.require.shadowDepth===0&&i.callee.property.type===`Identifier`&&!i.callee.computed&&i.callee.property.name===`resolve`&&i.arguments.length){await O(i.arguments[0]);return}let n=c.analysis.evaluatePureExpressions&&await C(i.callee,!1);if(n&&`value`in n&&typeof n.value==`function`&&n.value[TRIGGER]&&c.analysis.computeFileReferences)T=await C(i,!0),T&&a&&(w=i,await A(a,this));else if(n&&`value`in n&&typeof n.value==`symbol`)switch(n.value){case BOUND_REQUIRE:i.arguments.length===1&&i.arguments[0].type===`Literal`&&i.callee.type===`Identifier`&&(!y.require||y.require.shadowDepth===0)&&await O(i.arguments[0]);break;case BINDINGS:if(i.arguments.length){let e=await C(i.arguments[0],!1);if(e&&`value`in e&&e.value){let t;typeof e.value==`object`?t=e.value:typeof e.value==`string`&&(t={bindings:e.value}),t.path||=!0,t.module_root=p;let n;try{n=(0,bindings_1.default)(t)}catch{}n&&(T={value:n},w=i,await P())}}break;case NODE_GYP_BUILD:if(i.arguments.length){let e=await C(i.arguments[0],!1);if(e&&`value`in e&&e.value){let t=e.value,n;try{let e=i?.callee?.arguments?.[0]?.value||`node-gyp-build`,r=(0,resolve_from_1.default)(t,e);n=require(r).path(t)}catch{try{n=node_gyp_build_1.default.path(t)}catch{}}n&&(T={value:n},w=i,await P())}}break;case NBIND_INIT:if(i.arguments.length){let e=await C(i.arguments[0],!1);if(e&&`value`in e&&(typeof e.value==`string`||e.value===void 0)){let n=(0,binary_locators_1.nbind)(e.value);if(n&&n.path)return u.add(path_1.default.relative(f,n.path).replace(/\\/g,`/`)),this.skip()}}break;case EXPRESS_SET:if(i.arguments.length===2&&i.arguments[0].type===`Literal`&&i.arguments[0].value===`view engine`&&!E)return await O(i.arguments[1]),this.skip();break;case EXPRESS_ENGINE:E=!0;break;case FS_FN:case FS_DIR_FN:if(i.arguments[0]&&c.analysis.computeFileReferences&&(T=await C(i.arguments[0],!0),T))return w=i.arguments[0],n.value===FS_DIR_FN&&i.arguments[0].type===`Identifier`&&i.arguments[0].name===`__dirname`?m(f):await A(a,this),this.skip();break;case SET_ROOT_DIR:if(i.arguments[0]){let e=await C(i.arguments[0],!1);return e&&`value`in e&&e.value&&m(e.value+`/intl`),this.skip()}break;case PKG_INFO:let r=path_1.default.resolve(e,`../package.json`),s=path_1.default.resolve(`/package.json`);for(;r!==s&&await c.stat(r)===null;)r=path_1.default.resolve(r,`../../package.json`);r!==s&&l.add(r);break;case MODULE_FN:if(i.arguments.length&&i.arguments[0].type===`Literal`){let e=i.arguments[0].value;if(e.startsWith(`.`)){let n=i.arguments.length>1?await C(i.arguments[1]):void 0;if(n&&`value`in n){let r=n.value instanceof url_1.URL?n.value.href:typeof n.value==`string`?n.value:n.value.parentURL,i=new url_1.URL(e,r).href,a=v.slice(0,v.lastIndexOf(`/`)),o=path_1.default.relative(a,i),s=o.startsWith(`.`)?o:`./`+o;d.add(s)}}else d.add(e)}break}}else if(i.type===`VariableDeclaration`&&a&&!(0,ast_helpers_1.isVarLoop)(a)&&c.analysis.evaluatePureExpressions)for(let e of i.declarations){if(!e.init)continue;let t=await C(e.init,!0);if(t){if(e.id.type===`Identifier`)b(e.id.name,t);else if(e.id.type===`ObjectPattern`&&`value`in t)for(let n of e.id.properties)n.type!==`Property`||n.key.type!==`Identifier`||n.value.type!==`Identifier`||typeof t.value!=`object`||t.value===null||!(n.key.name in t.value)||b(n.value.name,{value:t.value[n.key.name]});!(`value`in t)&&isAbsolutePathOrUrl(t.ifTrue)&&isAbsolutePathOrUrl(t.else)&&(T=t,w=e.init,await P())}}else if(i.type===`AssignmentExpression`&&a&&!(0,ast_helpers_1.isLoop)(a)&&c.analysis.evaluatePureExpressions){if(!S(i.left.name)){let e=await C(i.right,!1);if(e&&`value`in e){if(i.left.type===`Identifier`)b(i.left.name,e);else if(i.left.type===`ObjectPattern`)for(let t of i.left.properties)t.type!==`Property`||t.key.type!==`Identifier`||t.value.type!==`Identifier`||typeof e.value!=`object`||e.value===null||!(t.key.name in e.value)||b(t.value.name,{value:e.value[t.key.name]});isAbsolutePathOrUrl(e.value)&&(T=e,w=i.right,await P())}}}else if((!_||c.mixedModules)&&(i.type===`FunctionDeclaration`||i.type===`FunctionExpression`||i.type===`ArrowFunctionExpression`)&&(i.arguments||i.params)[0]&&(i.arguments||i.params)[0].type===`Identifier`){let e,t;if((i.type===`ArrowFunctionExpression`||i.type===`FunctionExpression`)&&a&&a.type===`VariableDeclarator`&&a.id.type===`Identifier`?(e=a.id,t=i.arguments||i.params):i.id&&(e=i.id,t=i.arguments||i.params),e&&i.body.body){let n,r=!1;for(let e=0;e<i.body.body.length;e++)if(i.body.body[e].type===`VariableDeclaration`&&!n&&(n=i.body.body[e].declarations.find(e=>e&&e.id&&e.id.type===`Identifier`&&e.init&&e.init.type===`CallExpression`&&e.init.callee.type===`Identifier`&&e.init.callee.name===`require`&&y.require.shadowDepth===0&&e.init.arguments[0]&&e.init.arguments[0].type===`Identifier`&&e.init.arguments[0].name===t[0].name)),n&&i.body.body[e].type===`ReturnStatement`&&i.body.body[e].argument&&i.body.body[e].argument.type===`Identifier`&&i.body.body[e].argument.name===n.id.name){r=!0;break}r&&b(e.name,{value:BOUND_REQUIRE})}}if(i.type===`CallExpression`&&i.callee.type===`MemberExpression`&&i.callee.object.type===`Identifier`&&i.callee.object.name===`module`&&i.callee.property.type===`Identifier`&&i.callee.property.name===`createRequire`&&a.type===`VariableDeclarator`&&a.id.type===`Identifier`){let e=a.id.name;b(e,{value:BOUND_REQUIRE})}if(i.type===`CallExpression`&&i.callee.type===`Identifier`&&i.callee.name===`createRequire`){let e=x(`createRequire`);if(e&&`value`in e&&e.value===CREATE_REQUIRE&&a.type===`VariableDeclarator`&&a.id.type===`Identifier`){let e=a.id.name;b(e,{value:BOUND_REQUIRE})}}}},async leave(e,t){let n=e,r=t;if(n.scope){k.parent&&(k=k.parent);for(let e in n.scope.declarations)e in y&&(y[e].shadowDepth>0?y[e].shadowDepth--:delete y[e])}w&&r&&await A(r,this)}}),await h,{assets:l,deps:u,imports:d,isESM:_};async function j(e){let n=e.indexOf(static_eval_1.WILDCARD),r=n===-1?e.length:e.lastIndexOf(path_1.default.sep,n),a=e.substring(0,r);try{var o=await c.stat(a);if(o===null)throw Error(`file not found`)}catch{return}n!==-1&&o.isFile()||(o.isFile()?l.add(e):o.isDirectory()&&M(e)&&m(e))}function M(n){let r=``;if(n.endsWith(path_1.default.sep)?r=path_1.default.sep:n.endsWith(path_1.default.sep+static_eval_1.WILDCARD)?r=path_1.default.sep+static_eval_1.WILDCARD:n.endsWith(static_eval_1.WILDCARD)&&(r=static_eval_1.WILDCARD),n===f+r||n===cwd+r||n.endsWith(path_1.default.sep+`node_modules`+r)||f.startsWith(n.slice(0,n.length-r.length)+path_1.default.sep))return!1;if(p){let r=e.substring(0,e.indexOf(path_1.default.sep+`node_modules`))+path_1.default.sep+`node_modules`+path_1.default.sep;if(!n.startsWith(r))return c.log&&console.log(`Skipping asset emission of `+n.replace(static_eval_1.wildcardRegEx,`*`)+` for `+e+` as it is outside the package base `+p),!1}return!0}function N(e){return e instanceof url_1.URL?(0,url_1.fileURLToPath)(e):e.startsWith(`file:`)?(0,url_1.fileURLToPath)(new url_1.URL(e)):path_1.default.resolve(e)}async function P(){if(T){if(`value`in T&&isAbsolutePathOrUrl(T.value))try{await j(N(T.value))}catch{}else if(`ifTrue`in T&&`else`in T&&isAbsolutePathOrUrl(T.ifTrue)&&isAbsolutePathOrUrl(T.else)){let e;try{e=N(T.ifTrue)}catch{}let t;try{t=N(T.else)}catch{}e&&await j(e),t&&await j(t)}else if(w&&w.type===`ArrayExpression`&&`value`in T&&T.value instanceof Array)for(let e of T.value)try{await j(N(e))}catch{}w=T=void 0}}}function isAst(e){return`body`in e}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const LogLevels={silent:-1/0,fatal:0,error:0,warn:1,log:2,info:3,success:3,fail:3,ready:3,start:3,box:3,debug:4,trace:5,verbose:1/0},LogTypes={silent:{level:-1},fatal:{level:LogLevels.fatal},error:{level:LogLevels.error},warn:{level:LogLevels.warn},log:{level:LogLevels.log},info:{level:LogLevels.info},success:{level:LogLevels.success},fail:{level:LogLevels.fail},ready:{level:LogLevels.info},start:{level:LogLevels.info},box:{level:LogLevels.info},debug:{level:LogLevels.debug},trace:{level:LogLevels.trace},verbose:{level:LogLevels.verbose}};function isPlainObject$1(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function _defu(e,t,i=`.`,a){if(!isPlainObject$1(t))return _defu(e,{},i,a);let o=Object.assign({},t);for(let t in e){if(t===`__proto__`||t===`constructor`)continue;let s=e[t];s!=null&&(a&&a(o,t,s,i)||(Array.isArray(s)&&Array.isArray(o[t])?o[t]=[...s,...o[t]]:isPlainObject$1(s)&&isPlainObject$1(o[t])?o[t]=_defu(s,o[t],(i?`${i}.`:``)+t.toString(),a):o[t]=s))}return o}function createDefu(e){return(...t)=>t.reduce((t,n)=>_defu(t,n,``,e),{})}const defu=createDefu();function isPlainObject(e){return Object.prototype.toString.call(e)===`[object Object]`}function isLogObj(e){return!(!isPlainObject(e)||!e.message&&!e.args||e.stack)}let paused=!1;const queue=[];class Consola{options;_lastLog;_mockFn;constructor(e={}){let n=e.types||LogTypes;
|
|
1
|
+
"use strict";const LogLevels={silent:-1/0,fatal:0,error:0,warn:1,log:2,info:3,success:3,fail:3,ready:3,start:3,box:3,debug:4,trace:5,verbose:1/0},LogTypes={silent:{level:-1},fatal:{level:LogLevels.fatal},error:{level:LogLevels.error},warn:{level:LogLevels.warn},log:{level:LogLevels.log},info:{level:LogLevels.info},success:{level:LogLevels.success},fail:{level:LogLevels.fail},ready:{level:LogLevels.info},start:{level:LogLevels.info},box:{level:LogLevels.info},debug:{level:LogLevels.debug},trace:{level:LogLevels.trace},verbose:{level:LogLevels.verbose}};function isPlainObject$1(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function _defu(e,t,i=`.`,a){if(!isPlainObject$1(t))return _defu(e,{},i,a);let o=Object.assign({},t);for(let t in e){if(t===`__proto__`||t===`constructor`)continue;let s=e[t];s!=null&&(a&&a(o,t,s,i)||(Array.isArray(s)&&Array.isArray(o[t])?o[t]=[...s,...o[t]]:isPlainObject$1(s)&&isPlainObject$1(o[t])?o[t]=_defu(s,o[t],(i?`${i}.`:``)+t.toString(),a):o[t]=s))}return o}function createDefu(e){return(...t)=>t.reduce((t,n)=>_defu(t,n,``,e),{})}const defu=createDefu();function isPlainObject(e){return Object.prototype.toString.call(e)===`[object Object]`}function isLogObj(e){return!(!isPlainObject(e)||!e.message&&!e.args||e.stack)}let paused=!1;const queue=[];class Consola{options;_lastLog;_mockFn;constructor(e={}){let n=e.types||LogTypes;this.options=defu({...e,defaults:{...e.defaults},level:_normalizeLogLevel(e.level,n),reporters:[...e.reporters||[]]},{types:LogTypes,throttle:1e3,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}});for(let e in n){let t={type:e,...this.options.defaults,...n[e]};this[e]=this._wrapLogFn(t),this[e].raw=this._wrapLogFn(t,!0)}this.options.mockFn&&this.mockTypes(),this._lastLog={}}get level(){return this.options.level}set level(e){this.options.level=_normalizeLogLevel(e,this.options.types,this.options.level)}prompt(e,t){if(!this.options.prompt)throw Error(`prompt is not supported!`);return this.options.prompt(e,t)}create(e){let t=new Consola({...this.options,...e});return this._mockFn&&t.mockTypes(this._mockFn),t}withDefaults(e){return this.create({...this.options,defaults:{...this.options.defaults,...e}})}withTag(e){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+`:`+e:e})}addReporter(e){return this.options.reporters.push(e),this}removeReporter(e){if(e){let t=this.options.reporters.indexOf(e);if(t!==-1)return this.options.reporters.splice(t,1)}else this.options.reporters.splice(0);return this}setReporters(e){return this.options.reporters=Array.isArray(e)?e:[e],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(let e in this.options.types)console[`__`+e]||(console[`__`+e]=console[e]),console[e]=this[e].raw}restoreConsole(){for(let e in this.options.types)console[`__`+e]&&(console[e]=console[`__`+e],delete console[`__`+e])}wrapStd(){this._wrapStream(this.options.stdout,`log`),this._wrapStream(this.options.stderr,`log`)}_wrapStream(e,t){e&&(e.__write||=e.write,e.write=e=>{this[t].raw(String(e).trim())})}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(e){e&&e.__write&&(e.write=e.__write,delete e.__write)}pauseLogs(){paused=!0}resumeLogs(){paused=!1;let e=queue.splice(0);for(let t of e)t[0]._logFn(t[1],t[2])}mockTypes(e){let t=e||this.options.mockFn;if(this._mockFn=t,typeof t==`function`)for(let e in this.options.types)this[e]=t(e,this.options.types[e])||this[e],this[e].raw=this[e]}_wrapLogFn(e,t){return(...n)=>{if(paused){queue.push([this,e,n,t]);return}return this._logFn(e,n,t)}}_logFn(e,t,n){if((e.level||0)>this.level)return!1;let r={date:new Date,args:[],...e,level:_normalizeLogLevel(e.level,this.options.types)};!n&&t.length===1&&isLogObj(t[0])?Object.assign(r,t[0]):r.args=[...t],r.message&&(r.args.unshift(r.message),delete r.message),r.additional&&(Array.isArray(r.additional)||(r.additional=r.additional.split(`
|
|
2
2
|
`)),r.args.push(`
|
|
3
3
|
`+r.additional.join(`
|
|
4
4
|
`)),delete r.additional),r.type=typeof r.type==`string`?r.type.toLowerCase():`log`,r.tag=typeof r.tag==`string`?r.tag:``;let i=(e=!1)=>{let t=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&t>0){let e=[...this._lastLog.object.args];t>1&&e.push(`(repeated ${t} times)`),this._log({...this._lastLog.object,args:e}),this._lastLog.count=1}e&&(this._lastLog.object=r,this._log(r))};clearTimeout(this._lastLog.timeout);let a=this._lastLog.time&&r.date?r.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=r.date,a<this.options.throttle)try{let e=JSON.stringify([r.type,r.tag,r.args]),t=this._lastLog.serialized===e;if(this._lastLog.serialized=e,t&&(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin)){this._lastLog.timeout=setTimeout(i,this.options.throttle);return}}catch{}i(!0)}_log(e){for(let t of this.options.reporters)t.log(e,{options:this.options})}}function _normalizeLogLevel(e,t={},n=3){return e===void 0?n:typeof e==`number`?e:t[e]&&t[e].level!==void 0?t[e].level:n}Consola.prototype.add=Consola.prototype.addReporter,Consola.prototype.remove=Consola.prototype.removeReporter,Consola.prototype.clear=Consola.prototype.removeReporter,Consola.prototype.withScope=Consola.prototype.withTag,Consola.prototype.mock=Consola.prototype.mockTypes,Consola.prototype.pause=Consola.prototype.pauseLogs,Consola.prototype.resume=Consola.prototype.resumeLogs;function createConsola(e={}){return new Consola(e)}exports.Consola=Consola,exports.LogLevels=LogLevels,exports.LogTypes=LogTypes,exports.createConsola=createConsola;
|
|
@@ -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;
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { n as isAbsolute, o as resolve } from "./_chunks/libs/pathe.mjs";
|
|
2
1
|
import { a as pathRegExp, i as guessSubpath, o as toImport, s as toPathRegExp, t as DEFAULT_CONDITIONS } from "./_chunks/trace.mjs";
|
|
2
|
+
import { n as isAbsolute, o as resolve } from "./_chunks/libs/pathe.mjs";
|
|
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 || ".");
|
|
@@ -77,7 +75,7 @@ function externals(opts) {
|
|
|
77
75
|
order: "post",
|
|
78
76
|
async handler() {
|
|
79
77
|
if (opts.trace === false || tracedPaths.size === 0) return;
|
|
80
|
-
const { traceNodeModules } = await import("./_chunks/
|
|
78
|
+
const { traceNodeModules } = await import("./_chunks/trace.mjs").then((n) => n.r);
|
|
81
79
|
await traceNodeModules([...tracedPaths], {
|
|
82
80
|
conditions: opts.conditions,
|
|
83
81
|
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,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nf3",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "",
|
|
5
|
-
"repository": "unjs/nf3",
|
|
6
5
|
"license": "MIT",
|
|
7
|
-
"
|
|
6
|
+
"repository": "unjs/nf3",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
8
10
|
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
9
13
|
"exports": {
|
|
10
14
|
".": "./dist/index.mjs",
|
|
11
15
|
"./db": "./dist/db.mjs",
|
|
12
16
|
"./plugin": "./dist/plugin.mjs"
|
|
13
17
|
},
|
|
14
|
-
"types": "./dist/index.d.mts",
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "obuild",
|
|
20
20
|
"dev": "vitest dev",
|
|
21
|
-
"lint": "
|
|
22
|
-
"lint:fix": "automd &&
|
|
21
|
+
"lint": "oxlint . && oxfmt --check .",
|
|
22
|
+
"lint:fix": "automd && oxlint . --fix && oxfmt .",
|
|
23
23
|
"prepack": "pnpm build",
|
|
24
24
|
"release": "pnpm test && pnpm build && changelogen --release && npm publish && git push --follow-tags",
|
|
25
25
|
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
|
|
@@ -27,27 +27,27 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
30
|
-
"@types/node": "^25.
|
|
30
|
+
"@types/node": "^25.2.1",
|
|
31
31
|
"@types/semver": "^7.7.1",
|
|
32
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
32
|
+
"@typescript/native-preview": "^7.0.0-dev.20260205.1",
|
|
33
33
|
"@vercel/nft": "^1.3.0",
|
|
34
34
|
"@vitest/coverage-v8": "^4.0.18",
|
|
35
|
-
"automd": "^0.4.
|
|
35
|
+
"automd": "^0.4.3",
|
|
36
36
|
"changelogen": "^0.6.2",
|
|
37
|
-
"eslint": "^9.39.2",
|
|
38
37
|
"eslint-config-unjs": "^0.6.2",
|
|
39
38
|
"exsolve": "^1.0.8",
|
|
40
|
-
"obuild": "^0.4.
|
|
41
|
-
"oxc-minify": "^0.
|
|
39
|
+
"obuild": "^0.4.23",
|
|
40
|
+
"oxc-minify": "^0.112.0",
|
|
41
|
+
"oxfmt": "^0.28.0",
|
|
42
|
+
"oxlint": "^1.43.0",
|
|
42
43
|
"pathe": "^2.0.3",
|
|
43
44
|
"pkg-types": "^2.3.0",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"rollup": "^4.56.0",
|
|
45
|
+
"rolldown": "^1.0.0-rc.3",
|
|
46
|
+
"rollup": "^4.57.1",
|
|
47
47
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
48
|
-
"semver": "^7.7.
|
|
48
|
+
"semver": "^7.7.4",
|
|
49
49
|
"typescript": "^5.9.3",
|
|
50
50
|
"vitest": "^4.0.18"
|
|
51
51
|
},
|
|
52
|
-
"packageManager": "pnpm@10.28.
|
|
52
|
+
"packageManager": "pnpm@10.28.2"
|
|
53
53
|
}
|
package/dist/_chunks/trace2.mjs
DELETED