diff --git a/.pnp.cjs b/.pnp.cjs index 604ccdb..d975f4f 100644 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -4007,7 +4007,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageDependencies": [\ ["make-dir", "npm:2.1.0"],\ ["pify", "npm:4.0.1"],\ - ["semver", "npm:5.7.1"]\ + ["semver", "npm:5.7.2"]\ ],\ "linkType": "HARD"\ }]\ @@ -4666,10 +4666,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }]\ ]],\ ["semver", [\ - ["npm:5.7.1", {\ - "packageLocation": "./.yarn/cache/semver-npm-5.7.1-40bcea106b-57fd0acfd0.zip/node_modules/semver/",\ + ["npm:5.7.2", {\ + "packageLocation": "./.yarn/cache/semver-npm-5.7.2-938ee91eaa-fb4ab5e0dd.zip/node_modules/semver/",\ "packageDependencies": [\ - ["semver", "npm:5.7.1"]\ + ["semver", "npm:5.7.2"]\ ],\ "linkType": "HARD"\ }],\ @@ -13844,7 +13844,6 @@ function reportRequiredFilesToWatchMode(files) { } function applyPatch(pnpapi, opts) { - const defaultCache = {}; let enableNativeHooks = true; process.versions.pnp = String(pnpapi.VERSIONS.std); const moduleExports = require$$0__default.default; @@ -13864,62 +13863,13 @@ function applyPatch(pnpapi, opts) { } const originalModuleLoad = require$$0.Module._load; require$$0.Module._load = function(request, parent, isMain) { - if (!enableNativeHooks) - return originalModuleLoad.call(require$$0.Module, request, parent, isMain); - if (isBuiltinModule(request)) { - try { - enableNativeHooks = false; - return originalModuleLoad.call(require$$0.Module, request, parent, isMain); - } finally { - enableNativeHooks = true; - } - } - const parentApiPath = opts.manager.getApiPathFromParent(parent); - const parentApi = parentApiPath !== null ? opts.manager.getApiEntry(parentApiPath, true).instance : null; - if (parentApi === null) - return originalModuleLoad(request, parent, isMain); - if (request === `pnpapi`) - return parentApi; - const modulePath = require$$0.Module._resolveFilename(request, parent, isMain); - const isOwnedByRuntime = parentApi !== null ? parentApi.findPackageLocator(modulePath) !== null : false; - const moduleApiPath = isOwnedByRuntime ? parentApiPath : opts.manager.findApiPathFor(npath.dirname(modulePath)); - const entry = moduleApiPath !== null ? opts.manager.getApiEntry(moduleApiPath) : { instance: null, cache: defaultCache }; - const cacheEntry = entry.cache[modulePath]; - if (cacheEntry) { - if (cacheEntry.loaded === false && cacheEntry.isLoading !== true) { - try { - cacheEntry.isLoading = true; - if (isMain) { - process.mainModule = cacheEntry; - cacheEntry.id = `.`; - } - cacheEntry.load(modulePath); - } finally { - cacheEntry.isLoading = false; - } + if (request === `pnpapi`) { + const parentApiPath = opts.manager.getApiPathFromParent(parent); + if (parentApiPath) { + return opts.manager.getApiEntry(parentApiPath, true).instance; } - return cacheEntry.exports; - } - const module = new require$$0.Module(modulePath, parent != null ? parent : void 0); - module.pnpApiPath = moduleApiPath; - reportRequiredFilesToWatchMode([modulePath]); - entry.cache[modulePath] = module; - if (isMain) { - process.mainModule = module; - module.id = `.`; } - let hasThrown = true; - try { - module.isLoading = true; - module.load(modulePath); - hasThrown = false; - } finally { - module.isLoading = false; - if (hasThrown) { - delete require$$0.Module._cache[modulePath]; - } - } - return module.exports; + return originalModuleLoad.call(require$$0.Module, request, parent, isMain); }; function getIssuerSpecsFromPaths(paths) { return paths.map((path) => ({ @@ -13987,7 +13937,7 @@ function applyPatch(pnpapi, opts) { const parentDirectory = (parent == null ? void 0 : parent.filename) != null ? npath.dirname(parent.filename) : null; const absoluteRequest = npath.isAbsolute(request) ? request : parentDirectory !== null ? npath.resolve(parentDirectory, request) : null; if (absoluteRequest !== null) { - const apiPath = parentDirectory === npath.dirname(absoluteRequest) && (parent == null ? void 0 : parent.pnpApiPath) ? parent.pnpApiPath : opts.manager.findApiPathFor(absoluteRequest); + const apiPath = parent && parentDirectory === npath.dirname(absoluteRequest) ? opts.manager.getApiPathFromParent(parent) : opts.manager.findApiPathFor(absoluteRequest); if (apiPath !== null) { issuerSpecs.unshift({ apiPath, @@ -14146,118 +14096,6 @@ function hydrateRuntimeState(data, { basePath }) { }; } -/** - * @param {object} exports - * @param {Set} keys - */ -function loop(exports, keys) { - if (typeof exports === 'string') { - return exports; - } - - if (exports) { - let idx, tmp; - if (Array.isArray(exports)) { - for (idx=0; idx < exports.length; idx++) { - if (tmp = loop(exports[idx], keys)) return tmp; - } - } else { - for (idx in exports) { - if (keys.has(idx)) { - return loop(exports[idx], keys); - } - } - } - } -} - -/** - * @param {string} name The package name - * @param {string} entry The target entry, eg "." - * @param {number} [condition] Unmatched condition? - */ -function bail(name, entry, condition) { - throw new Error( - condition - ? `No known conditions for "${entry}" entry in "${name}" package` - : `Missing "${entry}" export in "${name}" package` - ); -} - -/** - * @param {string} name the package name - * @param {string} entry the target path/import - */ -function toName(name, entry) { - return entry === name ? '.' - : entry[0] === '.' ? entry - : entry.replace(new RegExp('^' + name + '\/'), './'); -} - -/** - * @param {object} pkg package.json contents - * @param {string} [entry] entry name or import path - * @param {object} [options] - * @param {boolean} [options.browser] - * @param {boolean} [options.require] - * @param {string[]} [options.conditions] - * @param {boolean} [options.unsafe] - */ -function resolve(pkg, entry='.', options={}) { - let { name, exports } = pkg; - - if (exports) { - let { browser, require, unsafe, conditions=[] } = options; - - let target = toName(name, entry); - if (target[0] !== '.') target = './' + target; - - if (typeof exports === 'string') { - return target === '.' ? exports : bail(name, target); - } - - let allows = new Set(['default', ...conditions]); - unsafe || allows.add(require ? 'require' : 'import'); - unsafe || allows.add(browser ? 'browser' : 'node'); - - let key, tmp, isSingle=false; - - for (key in exports) { - isSingle = key[0] !== '.'; - break; - } - - if (isSingle) { - return target === '.' - ? loop(exports, allows) || bail(name, target, 1) - : bail(name, target); - } - - if (tmp = exports[target]) { - return loop(tmp, allows) || bail(name, target, 1); - } - - for (key in exports) { - tmp = key[key.length - 1]; - if (tmp === '/' && target.startsWith(key)) { - return (tmp = loop(exports[key], allows)) - ? (tmp + target.substring(key.length)) - : bail(name, target, 1); - } - if (tmp === '*' && target.startsWith(key.slice(0, -1))) { - // do not trigger if no *content* to inject - if (target.substring(key.length - 1).length > 0) { - return (tmp = loop(exports[key], allows)) - ? tmp.replace('*', target.substring(key.length - 1)) - : bail(name, target, 1); - } - } - } - - return bail(name, target); - } -} - const ArrayIsArray = Array.isArray; const JSONStringify = JSON.stringify; const ObjectGetOwnPropertyNames = Object.getOwnPropertyNames; @@ -14318,6 +14156,15 @@ const ERR_INVALID_PACKAGE_CONFIG = createErrorType( }, Error ); +const ERR_PACKAGE_PATH_NOT_EXPORTED = createErrorType( + "ERR_PACKAGE_PATH_NOT_EXPORTED", + (pkgPath, subpath, base = void 0) => { + if (subpath === ".") + return `No "exports" main defined in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`; + return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`; + }, + Error +); function filterOwnProperties(source, keys) { const filtered = /* @__PURE__ */ Object.create(null); @@ -14637,12 +14484,121 @@ function patternKeyCompare(a, b) { return 1; return 0; } -function packageImportsResolve({ - name, +function isConditionalExportsMainSugar(exports, packageJSONUrl, base) { + if (typeof exports === "string" || ArrayIsArray(exports)) + return true; + if (typeof exports !== "object" || exports === null) + return false; + const keys = ObjectGetOwnPropertyNames(exports); + let isConditionalSugar = false; + let i = 0; + for (let j = 0; j < keys.length; j++) { + const key = keys[j]; + const curIsConditionalSugar = key === "" || key[0] !== "."; + if (i++ === 0) { + isConditionalSugar = curIsConditionalSugar; + } else if (isConditionalSugar !== curIsConditionalSugar) { + throw new ERR_INVALID_PACKAGE_CONFIG( + url.fileURLToPath(packageJSONUrl), + base, + `"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 isConditionalSugar; +} +function throwExportsNotFound(subpath, packageJSONUrl, base) { + throw new ERR_PACKAGE_PATH_NOT_EXPORTED( + url.fileURLToPath(new URL(".", packageJSONUrl)), + subpath, + base && url.fileURLToPath(base) + ); +} +const emittedPackageWarnings = /* @__PURE__ */ new Set(); +function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) { + const pjsonPath = url.fileURLToPath(pjsonUrl); + if (emittedPackageWarnings.has(pjsonPath + "|" + match)) + return; + emittedPackageWarnings.add(pjsonPath + "|" + match); + process.emitWarning( + `Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${url.fileURLToPath(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, + "DeprecationWarning", + "DEP0155" + ); +} +function packageExportsResolve({ + packageJSONUrl, + packageSubpath, + exports, base, - conditions, - readFileSyncFn + conditions }) { + if (isConditionalExportsMainSugar(exports, packageJSONUrl, base)) + exports = { ".": exports }; + if (ObjectPrototypeHasOwnProperty(exports, packageSubpath) && !StringPrototypeIncludes(packageSubpath, "*") && !StringPrototypeEndsWith(packageSubpath, "/")) { + const target = exports[packageSubpath]; + const resolveResult = resolvePackageTarget( + packageJSONUrl, + target, + "", + packageSubpath, + base, + false, + false, + conditions + ); + if (resolveResult == null) { + throwExportsNotFound(packageSubpath, packageJSONUrl, base); + } + return resolveResult; + } + let bestMatch = ""; + let bestMatchSubpath; + const keys = ObjectGetOwnPropertyNames(exports); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const patternIndex = StringPrototypeIndexOf(key, "*"); + if (patternIndex !== -1 && StringPrototypeStartsWith( + packageSubpath, + StringPrototypeSlice(key, 0, patternIndex) + )) { + if (StringPrototypeEndsWith(packageSubpath, "/")) + emitTrailingSlashPatternDeprecation( + packageSubpath, + packageJSONUrl, + base + ); + const patternTrailer = StringPrototypeSlice(key, patternIndex + 1); + if (packageSubpath.length >= key.length && StringPrototypeEndsWith(packageSubpath, patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && StringPrototypeLastIndexOf(key, "*") === patternIndex) { + bestMatch = key; + bestMatchSubpath = StringPrototypeSlice( + packageSubpath, + patternIndex, + packageSubpath.length - patternTrailer.length + ); + } + } + } + if (bestMatch) { + const target = exports[bestMatch]; + const resolveResult = resolvePackageTarget( + packageJSONUrl, + target, + bestMatchSubpath, + bestMatch, + base, + true, + false, + conditions + ); + if (resolveResult == null) { + throwExportsNotFound(packageSubpath, packageJSONUrl, base); + } + return resolveResult; + } + throwExportsNotFound(packageSubpath, packageJSONUrl, base); +} +function packageImportsResolve({ name, base, conditions, readFileSyncFn }) { if (name === "#" || StringPrototypeStartsWith(name, "#/") || StringPrototypeEndsWith(name, "/")) { const reason = "is not a valid internal imports specifier name"; throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, url.fileURLToPath(base)); @@ -15110,12 +15066,11 @@ function makeApi(runtimeState, opts) { return false; } const defaultExportsConditions = /* @__PURE__ */ new Set([ - `default`, `node`, `require`, ...getOptionValue(`--conditions`) ]); - function applyNodeExportsResolution(unqualifiedPath, conditions = defaultExportsConditions) { + function applyNodeExportsResolution(unqualifiedPath, conditions = defaultExportsConditions, issuer) { const locator = findPackageLocator(ppath.join(unqualifiedPath, `internal.js`), { resolveIgnored: true, includeDiscardFromLookup: true @@ -15131,6 +15086,8 @@ function makeApi(runtimeState, opts) { if (!opts.fakeFs.existsSync(manifestPath)) return null; const pkgJson = JSON.parse(opts.fakeFs.readFileSync(manifestPath, `utf8`)); + if (pkgJson.exports == null) + return null; let subpath = ppath.contains(packageLocation, unqualifiedPath); if (subpath === null) { throw makeError( @@ -15138,25 +15095,25 @@ function makeApi(runtimeState, opts) { `unqualifiedPath doesn't contain the packageLocation (this is probably an internal error)` ); } - if (!isRelativeRegexp.test(subpath)) + if (subpath !== `.` && !isRelativeRegexp.test(subpath)) subpath = `./${subpath}`; - let resolvedExport; try { - resolvedExport = resolve(pkgJson, ppath.normalize(subpath), { - conditions, - unsafe: true + const resolvedExport = packageExportsResolve({ + packageJSONUrl: url.pathToFileURL(npath.fromPortablePath(manifestPath)), + packageSubpath: subpath, + exports: pkgJson.exports, + base: issuer ? url.pathToFileURL(npath.fromPortablePath(issuer)) : null, + conditions }); + return npath.toPortablePath(url.fileURLToPath(resolvedExport)); } catch (error) { throw makeError( ErrorCode.EXPORTS_RESOLUTION_FAILED, error.message, { unqualifiedPath: getPathForDisplay(unqualifiedPath), locator, pkgJson, subpath: getPathForDisplay(subpath), conditions }, - `ERR_PACKAGE_PATH_NOT_EXPORTED` + error.code ); } - if (typeof resolvedExport === `string`) - return ppath.join(packageLocation, resolvedExport); - return null; } function applyNodeExtensionResolution(unqualifiedPath, candidates, { extensions }) { let stat; @@ -15533,10 +15490,10 @@ Required by: ${issuerLocator.name}@${issuerLocator.reference} (via ${issuerForDi } return ppath.normalize(unqualifiedPath); } - function resolveUnqualifiedExport(request, unqualifiedPath, conditions = defaultExportsConditions) { + function resolveUnqualifiedExport(request, unqualifiedPath, conditions = defaultExportsConditions, issuer) { if (isStrictRegExp.test(request)) return unqualifiedPath; - const unqualifiedExportPath = applyNodeExportsResolution(unqualifiedPath, conditions); + const unqualifiedExportPath = applyNodeExportsResolution(unqualifiedPath, conditions, issuer); if (unqualifiedExportPath) { return ppath.normalize(unqualifiedExportPath); } else { @@ -15623,7 +15580,7 @@ ${candidates.map((candidate) => `Not found: ${getPathForDisplay(candidate)} if (unqualifiedPath === null) return null; const isIssuerIgnored = () => issuer !== null ? isPathIgnored(issuer) : false; - const remappedPath = (!considerBuiltins || !isBuiltinModule(request)) && !isIssuerIgnored() ? resolveUnqualifiedExport(request, unqualifiedPath, conditions) : unqualifiedPath; + const remappedPath = (!considerBuiltins || !isBuiltinModule(request)) && !isIssuerIgnored() ? resolveUnqualifiedExport(request, unqualifiedPath, conditions, issuer) : unqualifiedPath; return resolveUnqualified(remappedPath, { extensions }); } catch (error) { if (Object.prototype.hasOwnProperty.call(error, `pnpCode`)) @@ -15701,7 +15658,6 @@ function makeManager(pnpapi, opts) { const initialApiStats = opts.fakeFs.statSync(npath.toPortablePath(initialApiPath)); const apiMetadata = /* @__PURE__ */ new Map([ [initialApiPath, { - cache: require$$0.Module._cache, instance: pnpapi, stats: initialApiStats, lastRefreshCheck: Date.now() @@ -15733,7 +15689,6 @@ function makeManager(pnpapi, opts) { } } else { apiMetadata.set(pnpApiPath, apiEntry = { - cache: {}, instance: loadApiInstance(pnpApiPath), stats: opts.fakeFs.statSync(pnpApiPath), lastRefreshCheck: Date.now() @@ -15803,19 +15758,16 @@ ${controlSegment} } while (curr !== PortablePath.root); return addToCacheAndReturn(start, curr, null); } + const moduleToApiPathCache = /* @__PURE__ */ new WeakMap(); function getApiPathFromParent(parent) { if (parent == null) return initialApiPath; - if (typeof parent.pnpApiPath === `undefined`) { - if (parent.filename !== null) { - return parent.pnpApiPath = findApiPathFor(parent.filename); - } else { - return initialApiPath; - } - } - if (parent.pnpApiPath !== null) - return parent.pnpApiPath; - return null; + let apiPath = moduleToApiPathCache.get(parent); + if (typeof apiPath !== `undefined`) + return apiPath; + apiPath = parent.filename ? findApiPathFor(parent.filename) : null; + moduleToApiPathCache.set(parent, apiPath); + return apiPath; } return { getApiPathFromParent, diff --git a/.yarn/cache/semver-npm-5.7.1-40bcea106b-57fd0acfd0.zip b/.yarn/cache/semver-npm-5.7.1-40bcea106b-57fd0acfd0.zip deleted file mode 100644 index 68795d8..0000000 Binary files a/.yarn/cache/semver-npm-5.7.1-40bcea106b-57fd0acfd0.zip and /dev/null differ diff --git a/.yarn/cache/semver-npm-5.7.2-938ee91eaa-fb4ab5e0dd.zip b/.yarn/cache/semver-npm-5.7.2-938ee91eaa-fb4ab5e0dd.zip new file mode 100644 index 0000000..1a2673b Binary files /dev/null and b/.yarn/cache/semver-npm-5.7.2-938ee91eaa-fb4ab5e0dd.zip differ diff --git a/yarn.lock b/yarn.lock index f2a73af..9485f9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3318,11 +3318,11 @@ __metadata: linkType: hard "semver@npm:^5.6.0": - version: 5.7.1 - resolution: "semver@npm:5.7.1" + version: 5.7.2 + resolution: "semver@npm:5.7.2" bin: - semver: ./bin/semver - checksum: 57fd0acfd0bac382ee87cd52cd0aaa5af086a7dc8d60379dfe65fea491fb2489b6016400813930ecd61fd0952dae75c115287a1b16c234b1550887117744dfaf + semver: bin/semver + checksum: fb4ab5e0dd1c22ce0c937ea390b4a822147a9c53dbd2a9a0132f12fe382902beef4fbf12cf51bb955248d8d15874ce8cd89532569756384f994309825f10b686 languageName: node linkType: hard