Release rolling / release (push) Successful in 11m16s
Bump published pins (compact-encoding 3, bare-fetch/tls/https/ws 3, bare-subprocess 6, bare-signals 5, corestore 7.12, protomux 3.11, hypercore-crypto 3.7, bare-runtime 1.31) and regenerate catalogs, manifests, and kernel/seeder bundles. Adapt call sites to the new APIs: - Corestore: explicit session flush before suspend(); treeCache ctor opts - bare-crypto: KeyObject.export() instead of removed ._key - Protomux 3.11: wait for fullyOpened()/fullyClosed() on chat channels - bare-fetch: surface response.type and Headers.getSetCookie - host snapshots: bare-os 3.9 / bare-posix / bare-fs.statfs frsize - bare-subprocess 6: optional IPC channel + json serialization Keep catalog sync from wiping curated pearEntries. Teach the Node test shim to stub bare-thread/bare-worker (ESM absolute paths) and chain Bare.on so bare-timers can load. Booter 479, protocol 34, seeder 14.
4000 lines
148 KiB
JavaScript
4000 lines
148 KiB
JavaScript
var __bare_os_bundle_exports__ = (() => {
|
|
var __create = Object.create;
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
}) : x)(function(x) {
|
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
});
|
|
var __commonJS = (cb, mod) => function __require2() {
|
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
};
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
// file that has been converted to a CommonJS file using a Babel-
|
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
mod
|
|
));
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
|
|
// ../../node_modules/bare-path/binding.js
|
|
var require_binding = __commonJS({
|
|
"../../node_modules/bare-path/binding.js"(exports, module) {
|
|
module.exports = __require.addon();
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-path/lib/constants.js
|
|
var require_constants = __commonJS({
|
|
"../../node_modules/bare-path/lib/constants.js"(exports, module) {
|
|
module.exports = {
|
|
CHAR_UPPERCASE_A: 65,
|
|
CHAR_LOWERCASE_A: 97,
|
|
CHAR_UPPERCASE_Z: 90,
|
|
CHAR_LOWERCASE_Z: 122,
|
|
CHAR_DOT: 46,
|
|
CHAR_FORWARD_SLASH: 47,
|
|
CHAR_BACKWARD_SLASH: 92,
|
|
CHAR_COLON: 58,
|
|
CHAR_QUESTION_MARK: 63
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-path/lib/shared.js
|
|
var require_shared = __commonJS({
|
|
"../../node_modules/bare-path/lib/shared.js"(exports) {
|
|
var { CHAR_DOT, CHAR_FORWARD_SLASH } = require_constants();
|
|
exports.validateString = function validateString(value, name) {
|
|
if (typeof value !== "string") {
|
|
throw new TypeError(
|
|
`The "${name}" argument must be of type string. Received type ${typeof value}`
|
|
);
|
|
}
|
|
};
|
|
exports.normalizeString = function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
|
|
let res = "";
|
|
let lastSegmentLength = 0;
|
|
let lastSlash = -1;
|
|
let dots = 0;
|
|
let code = 0;
|
|
for (let i = 0; i <= path.length; ++i) {
|
|
if (i < path.length) {
|
|
code = path.charCodeAt(i);
|
|
} else if (isPathSeparator(code)) {
|
|
break;
|
|
} else {
|
|
code = CHAR_FORWARD_SLASH;
|
|
}
|
|
if (isPathSeparator(code)) {
|
|
if (lastSlash === i - 1 || dots === 1) ;
|
|
else if (dots === 2) {
|
|
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== CHAR_DOT || res.charCodeAt(res.length - 2) !== CHAR_DOT) {
|
|
if (res.length > 2) {
|
|
const lastSlashIndex = res.lastIndexOf(separator);
|
|
if (lastSlashIndex === -1) {
|
|
res = "";
|
|
lastSegmentLength = 0;
|
|
} else {
|
|
res = res.substring(0, lastSlashIndex);
|
|
lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
|
|
}
|
|
lastSlash = i;
|
|
dots = 0;
|
|
continue;
|
|
} else if (res.length !== 0) {
|
|
res = "";
|
|
lastSegmentLength = 0;
|
|
lastSlash = i;
|
|
dots = 0;
|
|
continue;
|
|
}
|
|
}
|
|
if (allowAboveRoot) {
|
|
res += res.length > 0 ? `${separator}..` : "..";
|
|
lastSegmentLength = 2;
|
|
}
|
|
} else {
|
|
if (res.length > 0) {
|
|
res += `${separator}${path.substring(lastSlash + 1, i)}`;
|
|
} else {
|
|
res = path.substring(lastSlash + 1, i);
|
|
}
|
|
lastSegmentLength = i - lastSlash - 1;
|
|
}
|
|
lastSlash = i;
|
|
dots = 0;
|
|
} else if (code === CHAR_DOT && dots !== -1) {
|
|
++dots;
|
|
} else {
|
|
dots = -1;
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-path/lib/posix.js
|
|
var require_posix = __commonJS({
|
|
"../../node_modules/bare-path/lib/posix.js"(exports) {
|
|
var binding = require_binding();
|
|
var { normalizeString, validateString } = require_shared();
|
|
var { CHAR_DOT, CHAR_FORWARD_SLASH } = require_constants();
|
|
function isPosixPathSeparator(code) {
|
|
return code === CHAR_FORWARD_SLASH;
|
|
}
|
|
exports.win32 = require_win32();
|
|
exports.posix = exports;
|
|
exports.sep = "/";
|
|
exports.delimiter = ":";
|
|
exports.resolve = function resolve(...args) {
|
|
let resolvedPath = "";
|
|
let resolvedAbsolute = false;
|
|
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
const path = i >= 0 ? args[i] : binding.cwd();
|
|
if (i >= 0) validateString(path, `paths[${i}]`);
|
|
if (path.length === 0) {
|
|
continue;
|
|
}
|
|
resolvedPath = `${path}/${resolvedPath}`;
|
|
resolvedAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
|
}
|
|
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, "/", isPosixPathSeparator);
|
|
if (resolvedAbsolute) {
|
|
return `/${resolvedPath}`;
|
|
}
|
|
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
};
|
|
exports.normalize = function normalize(path) {
|
|
validateString(path, "path");
|
|
if (path.length === 0) return ".";
|
|
const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
|
const trailingSeparator = path.charCodeAt(path.length - 1) === CHAR_FORWARD_SLASH;
|
|
path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
|
|
if (path.length === 0) {
|
|
if (isAbsolute) return "/";
|
|
return trailingSeparator ? "./" : ".";
|
|
}
|
|
if (trailingSeparator) path += "/";
|
|
return isAbsolute ? `/${path}` : path;
|
|
};
|
|
exports.isAbsolute = function isAbsolute(path) {
|
|
validateString(path, "path");
|
|
return path.length > 0 && path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
|
};
|
|
exports.join = function join(...args) {
|
|
if (args.length === 0) return ".";
|
|
let joined;
|
|
for (let i = 0; i < args.length; ++i) {
|
|
const arg = args[i];
|
|
validateString(arg, "path");
|
|
if (arg.length > 0) {
|
|
if (joined === void 0) joined = arg;
|
|
else joined += `/${arg}`;
|
|
}
|
|
}
|
|
if (joined === void 0) return ".";
|
|
return exports.normalize(joined);
|
|
};
|
|
exports.relative = function relative(from, to) {
|
|
validateString(from, "from");
|
|
validateString(to, "to");
|
|
if (from === to) return "";
|
|
from = exports.resolve(from);
|
|
to = exports.resolve(to);
|
|
if (from === to) return "";
|
|
const fromStart = 1;
|
|
const fromEnd = from.length;
|
|
const fromLen = fromEnd - fromStart;
|
|
const toStart = 1;
|
|
const toLen = to.length - toStart;
|
|
const length = fromLen < toLen ? fromLen : toLen;
|
|
let lastCommonSep = -1;
|
|
let i = 0;
|
|
for (; i < length; i++) {
|
|
const fromCode = from.charCodeAt(fromStart + i);
|
|
if (fromCode !== to.charCodeAt(toStart + i)) {
|
|
break;
|
|
} else if (fromCode === CHAR_FORWARD_SLASH) {
|
|
lastCommonSep = i;
|
|
}
|
|
}
|
|
if (i === length) {
|
|
if (toLen > length) {
|
|
if (to.charCodeAt(toStart + i) === CHAR_FORWARD_SLASH) {
|
|
return to.substring(toStart + i + 1);
|
|
}
|
|
if (i === 0) {
|
|
return to.substring(toStart + i);
|
|
}
|
|
} else if (fromLen > length) {
|
|
if (from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
|
|
lastCommonSep = i;
|
|
} else if (i === 0) {
|
|
lastCommonSep = 0;
|
|
}
|
|
}
|
|
}
|
|
let out = "";
|
|
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
|
if (i === fromEnd || from.charCodeAt(i) === CHAR_FORWARD_SLASH) {
|
|
out += out.length === 0 ? ".." : "/..";
|
|
}
|
|
}
|
|
return `${out}${to.substring(toStart + lastCommonSep)}`;
|
|
};
|
|
exports.toNamespacedPath = function toNamespacedPath(path) {
|
|
return path;
|
|
};
|
|
exports.dirname = function dirname(path) {
|
|
validateString(path, "path");
|
|
if (path.length === 0) return ".";
|
|
const hasRoot = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
|
let end = -1;
|
|
let matchedSlash = true;
|
|
for (let i = path.length - 1; i >= 1; --i) {
|
|
if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
|
|
if (!matchedSlash) {
|
|
end = i;
|
|
break;
|
|
}
|
|
} else {
|
|
matchedSlash = false;
|
|
}
|
|
}
|
|
if (end === -1) return hasRoot ? "/" : ".";
|
|
if (hasRoot && end === 1) return "//";
|
|
return path.substring(0, end);
|
|
};
|
|
exports.basename = function basename(path, suffix) {
|
|
if (suffix !== void 0) validateString(suffix, "suffix");
|
|
validateString(path, "path");
|
|
let start = 0;
|
|
let end = -1;
|
|
let matchedSlash = true;
|
|
if (suffix !== void 0 && suffix.length > 0 && suffix.length <= path.length) {
|
|
if (suffix === path) {
|
|
return "";
|
|
}
|
|
let extIdx = suffix.length - 1;
|
|
let firstNonSlashEnd = -1;
|
|
for (let i = path.length - 1; i >= 0; --i) {
|
|
const code = path.charCodeAt(i);
|
|
if (code === CHAR_FORWARD_SLASH) {
|
|
if (!matchedSlash) {
|
|
start = i + 1;
|
|
break;
|
|
}
|
|
} else {
|
|
if (firstNonSlashEnd === -1) {
|
|
matchedSlash = false;
|
|
firstNonSlashEnd = i + 1;
|
|
}
|
|
if (extIdx >= 0) {
|
|
if (code === suffix.charCodeAt(extIdx)) {
|
|
if (--extIdx === -1) {
|
|
end = i;
|
|
}
|
|
} else {
|
|
extIdx = -1;
|
|
end = firstNonSlashEnd;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (start === end) end = firstNonSlashEnd;
|
|
else if (end === -1) end = path.length;
|
|
return path.substring(start, end);
|
|
}
|
|
for (let i = path.length - 1; i >= 0; --i) {
|
|
if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
|
|
if (!matchedSlash) {
|
|
start = i + 1;
|
|
break;
|
|
}
|
|
} else if (end === -1) {
|
|
matchedSlash = false;
|
|
end = i + 1;
|
|
}
|
|
}
|
|
if (end === -1) return "";
|
|
return path.substring(start, end);
|
|
};
|
|
exports.extname = function extname(path) {
|
|
validateString(path, "path");
|
|
let startDot = -1;
|
|
let startPart = 0;
|
|
let end = -1;
|
|
let matchedSlash = true;
|
|
let preDotState = 0;
|
|
for (let i = path.length - 1; i >= 0; --i) {
|
|
const code = path.charCodeAt(i);
|
|
if (code === CHAR_FORWARD_SLASH) {
|
|
if (!matchedSlash) {
|
|
startPart = i + 1;
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
if (end === -1) {
|
|
matchedSlash = false;
|
|
end = i + 1;
|
|
}
|
|
if (code === CHAR_DOT) {
|
|
if (startDot === -1) startDot = i;
|
|
else if (preDotState !== 1) preDotState = 1;
|
|
} else if (startDot !== -1) {
|
|
preDotState = -1;
|
|
}
|
|
}
|
|
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
return "";
|
|
}
|
|
return path.substring(startDot, end);
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-path/lib/win32.js
|
|
var require_win32 = __commonJS({
|
|
"../../node_modules/bare-path/lib/win32.js"(exports) {
|
|
var binding = require_binding();
|
|
var { normalizeString, validateString } = require_shared();
|
|
var {
|
|
CHAR_UPPERCASE_A,
|
|
CHAR_LOWERCASE_A,
|
|
CHAR_UPPERCASE_Z,
|
|
CHAR_LOWERCASE_Z,
|
|
CHAR_DOT,
|
|
CHAR_FORWARD_SLASH,
|
|
CHAR_BACKWARD_SLASH,
|
|
CHAR_COLON,
|
|
CHAR_QUESTION_MARK
|
|
} = require_constants();
|
|
function isWindowsPathSeparator(code) {
|
|
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
}
|
|
function isWindowsDeviceRoot(code) {
|
|
return code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z || code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z;
|
|
}
|
|
exports.posix = require_posix();
|
|
exports.win32 = exports;
|
|
exports.sep = "\\";
|
|
exports.delimiter = ";";
|
|
exports.resolve = function resolve(...args) {
|
|
let resolvedDevice = "";
|
|
let resolvedTail = "";
|
|
let resolvedAbsolute = false;
|
|
for (let i = args.length - 1; i >= -1; i--) {
|
|
let path;
|
|
if (i >= 0) {
|
|
path = args[i];
|
|
validateString(path, `paths[${i}]`);
|
|
if (path.length === 0) continue;
|
|
} else if (resolvedDevice.length === 0) {
|
|
path = binding.cwd();
|
|
} else {
|
|
path = binding.cwd(resolvedDevice);
|
|
if (path === void 0 || path.substring(0, 2).toLowerCase() !== resolvedDevice.toLowerCase() && path.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
|
|
path = `${resolvedDevice}\\`;
|
|
}
|
|
}
|
|
const len = path.length;
|
|
let rootEnd = 0;
|
|
let device = "";
|
|
let isAbsolute = false;
|
|
const code = path.charCodeAt(0);
|
|
if (len === 1) {
|
|
if (isWindowsPathSeparator(code)) {
|
|
rootEnd = 1;
|
|
isAbsolute = true;
|
|
}
|
|
} else if (isWindowsPathSeparator(code)) {
|
|
isAbsolute = true;
|
|
if (isWindowsPathSeparator(path.charCodeAt(1))) {
|
|
let j = 2;
|
|
let last = j;
|
|
while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
|
|
j++;
|
|
}
|
|
if (j < len && j !== last) {
|
|
const firstPart = path.substring(last, j);
|
|
last = j;
|
|
while (j < len && isWindowsPathSeparator(path.charCodeAt(j))) {
|
|
j++;
|
|
}
|
|
if (j < len && j !== last) {
|
|
last = j;
|
|
while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
|
|
j++;
|
|
}
|
|
if (j === len || j !== last) {
|
|
device = `\\\\${firstPart}\\${path.substring(last, j)}`;
|
|
rootEnd = j;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
rootEnd = 1;
|
|
}
|
|
} else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
|
|
device = path.substring(0, 2);
|
|
rootEnd = 2;
|
|
if (len > 2 && isWindowsPathSeparator(path.charCodeAt(2))) {
|
|
isAbsolute = true;
|
|
rootEnd = 3;
|
|
}
|
|
}
|
|
if (device.length > 0) {
|
|
if (resolvedDevice.length > 0) {
|
|
if (device.toLowerCase() !== resolvedDevice.toLowerCase()) {
|
|
continue;
|
|
}
|
|
} else {
|
|
resolvedDevice = device;
|
|
}
|
|
}
|
|
if (resolvedAbsolute) {
|
|
if (resolvedDevice.length > 0) {
|
|
break;
|
|
}
|
|
} else {
|
|
resolvedTail = `${path.substring(rootEnd)}\\${resolvedTail}`;
|
|
resolvedAbsolute = isAbsolute;
|
|
if (isAbsolute && resolvedDevice.length > 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, "\\", isWindowsPathSeparator);
|
|
return resolvedAbsolute ? `${resolvedDevice}\\${resolvedTail}` : `${resolvedDevice}${resolvedTail}` || ".";
|
|
};
|
|
exports.normalize = function normalize(path) {
|
|
validateString(path, "path");
|
|
const len = path.length;
|
|
if (len === 0) return ".";
|
|
let rootEnd = 0;
|
|
let device;
|
|
let isAbsolute = false;
|
|
const code = path.charCodeAt(0);
|
|
if (len === 1) {
|
|
return code === CHAR_FORWARD_SLASH ? "\\" : path;
|
|
}
|
|
if (isWindowsPathSeparator(code)) {
|
|
isAbsolute = true;
|
|
if (isWindowsPathSeparator(path.charCodeAt(1))) {
|
|
let j = 2;
|
|
let last = j;
|
|
while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
|
|
j++;
|
|
}
|
|
if (j < len && j !== last) {
|
|
const firstPart = path.substring(last, j);
|
|
last = j;
|
|
while (j < len && isWindowsPathSeparator(path.charCodeAt(j))) {
|
|
j++;
|
|
}
|
|
if (j < len && j !== last) {
|
|
last = j;
|
|
while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
|
|
j++;
|
|
}
|
|
if (j === len) {
|
|
return `\\\\${firstPart}\\${path.substring(last)}\\`;
|
|
}
|
|
if (j !== last) {
|
|
device = `\\\\${firstPart}\\${path.substring(last, j)}`;
|
|
rootEnd = j;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
rootEnd = 1;
|
|
}
|
|
} else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
|
|
device = path.substring(0, 2);
|
|
rootEnd = 2;
|
|
if (len > 2 && isWindowsPathSeparator(path.charCodeAt(2))) {
|
|
isAbsolute = true;
|
|
rootEnd = 3;
|
|
}
|
|
}
|
|
let tail = rootEnd < len ? normalizeString(path.substring(rootEnd), !isAbsolute, "\\", isWindowsPathSeparator) : "";
|
|
if (tail.length === 0 && !isAbsolute) {
|
|
tail = ".";
|
|
}
|
|
if (tail.length > 0 && isWindowsPathSeparator(path.charCodeAt(len - 1))) {
|
|
tail += "\\";
|
|
}
|
|
if (device === void 0) {
|
|
return isAbsolute ? `\\${tail}` : tail;
|
|
}
|
|
return isAbsolute ? `${device}\\${tail}` : `${device}${tail}`;
|
|
};
|
|
exports.isAbsolute = function isAbsolute(path) {
|
|
validateString(path, "path");
|
|
const len = path.length;
|
|
if (len === 0) return false;
|
|
const code = path.charCodeAt(0);
|
|
return isWindowsPathSeparator(code) || len > 2 && isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON && isWindowsPathSeparator(path.charCodeAt(2));
|
|
};
|
|
exports.join = function join(...args) {
|
|
if (args.length === 0) return ".";
|
|
let joined;
|
|
let firstPart;
|
|
for (let i = 0; i < args.length; ++i) {
|
|
const arg = args[i];
|
|
validateString(arg, "path");
|
|
if (arg.length > 0) {
|
|
if (joined === void 0) joined = firstPart = arg;
|
|
else joined += `\\${arg}`;
|
|
}
|
|
}
|
|
if (joined === void 0) return ".";
|
|
let needsReplace = true;
|
|
let slashCount = 0;
|
|
if (isWindowsPathSeparator(firstPart.charCodeAt(0))) {
|
|
++slashCount;
|
|
const firstLen = firstPart.length;
|
|
if (firstLen > 1 && isWindowsPathSeparator(firstPart.charCodeAt(1))) {
|
|
++slashCount;
|
|
if (firstLen > 2) {
|
|
if (isWindowsPathSeparator(firstPart.charCodeAt(2))) {
|
|
++slashCount;
|
|
} else {
|
|
needsReplace = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (needsReplace) {
|
|
while (slashCount < joined.length && isWindowsPathSeparator(joined.charCodeAt(slashCount))) {
|
|
slashCount++;
|
|
}
|
|
if (slashCount >= 2) {
|
|
joined = `\\${joined.substring(slashCount)}`;
|
|
}
|
|
}
|
|
return exports.normalize(joined);
|
|
};
|
|
exports.relative = function relative(from, to) {
|
|
validateString(from, "from");
|
|
validateString(to, "to");
|
|
if (from === to) return "";
|
|
const fromOrig = exports.resolve(from);
|
|
const toOrig = exports.resolve(to);
|
|
if (fromOrig === toOrig) return "";
|
|
from = fromOrig.toLowerCase();
|
|
to = toOrig.toLowerCase();
|
|
if (from === to) return "";
|
|
let fromStart = 0;
|
|
while (fromStart < from.length && from.charCodeAt(fromStart) === CHAR_BACKWARD_SLASH) {
|
|
fromStart++;
|
|
}
|
|
let fromEnd = from.length;
|
|
while (fromEnd - 1 > fromStart && from.charCodeAt(fromEnd - 1) === CHAR_BACKWARD_SLASH) {
|
|
fromEnd--;
|
|
}
|
|
const fromLen = fromEnd - fromStart;
|
|
let toStart = 0;
|
|
while (toStart < to.length && to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
|
|
toStart++;
|
|
}
|
|
let toEnd = to.length;
|
|
while (toEnd - 1 > toStart && to.charCodeAt(toEnd - 1) === CHAR_BACKWARD_SLASH) {
|
|
toEnd--;
|
|
}
|
|
const toLen = toEnd - toStart;
|
|
const length = fromLen < toLen ? fromLen : toLen;
|
|
let lastCommonSep = -1;
|
|
let i = 0;
|
|
for (; i < length; i++) {
|
|
const fromCode = from.charCodeAt(fromStart + i);
|
|
if (fromCode !== to.charCodeAt(toStart + i)) {
|
|
break;
|
|
} else if (fromCode === CHAR_BACKWARD_SLASH) {
|
|
lastCommonSep = i;
|
|
}
|
|
}
|
|
if (i !== length) {
|
|
if (lastCommonSep === -1) return toOrig;
|
|
} else {
|
|
if (toLen > length) {
|
|
if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
|
|
return toOrig.substring(toStart + i + 1);
|
|
}
|
|
if (i === 2) {
|
|
return toOrig.substring(toStart + i);
|
|
}
|
|
}
|
|
if (fromLen > length) {
|
|
if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
|
|
lastCommonSep = i;
|
|
} else if (i === 2) {
|
|
lastCommonSep = 3;
|
|
}
|
|
}
|
|
if (lastCommonSep === -1) lastCommonSep = 0;
|
|
}
|
|
let out = "";
|
|
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
|
if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
|
|
out += out.length === 0 ? ".." : "\\..";
|
|
}
|
|
}
|
|
toStart += lastCommonSep;
|
|
if (out.length > 0) {
|
|
return `${out}${toOrig.substring(toStart, toEnd)}`;
|
|
}
|
|
if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
|
|
++toStart;
|
|
}
|
|
return toOrig.substring(toStart, toEnd);
|
|
};
|
|
exports.toNamespacedPath = function toNamespacedPath(path) {
|
|
if (typeof path !== "string" || path.length === 0) return path;
|
|
const resolvedPath = exports.resolve(path);
|
|
if (resolvedPath.length <= 2) return path;
|
|
if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
|
|
if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) {
|
|
const code = resolvedPath.charCodeAt(2);
|
|
if (code !== CHAR_QUESTION_MARK && code !== CHAR_DOT) {
|
|
return `\\\\?\\UNC\\${resolvedPath.substring(2)}`;
|
|
}
|
|
}
|
|
} else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0)) && resolvedPath.charCodeAt(1) === CHAR_COLON && resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
|
|
return `\\\\?\\${resolvedPath}`;
|
|
}
|
|
return path;
|
|
};
|
|
exports.dirname = function dirname(path) {
|
|
validateString(path, "path");
|
|
const len = path.length;
|
|
if (len === 0) return ".";
|
|
let rootEnd = -1;
|
|
let offset = 0;
|
|
const code = path.charCodeAt(0);
|
|
if (len === 1) {
|
|
return isWindowsPathSeparator(code) ? path : ".";
|
|
}
|
|
if (isWindowsPathSeparator(code)) {
|
|
rootEnd = offset = 1;
|
|
if (isWindowsPathSeparator(path.charCodeAt(1))) {
|
|
let j = 2;
|
|
let last = j;
|
|
while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
|
|
j++;
|
|
}
|
|
if (j < len && j !== last) {
|
|
last = j;
|
|
while (j < len && isWindowsPathSeparator(path.charCodeAt(j))) {
|
|
j++;
|
|
}
|
|
if (j < len && j !== last) {
|
|
last = j;
|
|
while (j < len && !isWindowsPathSeparator(path.charCodeAt(j))) {
|
|
j++;
|
|
}
|
|
if (j === len) {
|
|
return path;
|
|
}
|
|
if (j !== last) {
|
|
rootEnd = offset = j + 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
|
|
rootEnd = len > 2 && isWindowsPathSeparator(path.charCodeAt(2)) ? 3 : 2;
|
|
offset = rootEnd;
|
|
}
|
|
let end = -1;
|
|
let matchedSlash = true;
|
|
for (let i = len - 1; i >= offset; --i) {
|
|
if (isWindowsPathSeparator(path.charCodeAt(i))) {
|
|
if (!matchedSlash) {
|
|
end = i;
|
|
break;
|
|
}
|
|
} else {
|
|
matchedSlash = false;
|
|
}
|
|
}
|
|
if (end === -1) {
|
|
if (rootEnd === -1) return ".";
|
|
end = rootEnd;
|
|
}
|
|
return path.substring(0, end);
|
|
};
|
|
exports.basename = function basename(path, suffix) {
|
|
if (suffix !== void 0) validateString(suffix, "suffix");
|
|
validateString(path, "path");
|
|
let start = 0;
|
|
let end = -1;
|
|
let matchedSlash = true;
|
|
if (path.length >= 2 && isWindowsDeviceRoot(path.charCodeAt(0)) && path.charCodeAt(1) === CHAR_COLON) {
|
|
start = 2;
|
|
}
|
|
if (suffix !== void 0 && suffix.length > 0 && suffix.length <= path.length) {
|
|
if (suffix === path) return "";
|
|
let extIdx = suffix.length - 1;
|
|
let firstNonSlashEnd = -1;
|
|
for (let i = path.length - 1; i >= start; --i) {
|
|
const code = path.charCodeAt(i);
|
|
if (isWindowsPathSeparator(code)) {
|
|
if (!matchedSlash) {
|
|
start = i + 1;
|
|
break;
|
|
}
|
|
} else {
|
|
if (firstNonSlashEnd === -1) {
|
|
matchedSlash = false;
|
|
firstNonSlashEnd = i + 1;
|
|
}
|
|
if (extIdx >= 0) {
|
|
if (code === suffix.charCodeAt(extIdx)) {
|
|
if (--extIdx === -1) {
|
|
end = i;
|
|
}
|
|
} else {
|
|
extIdx = -1;
|
|
end = firstNonSlashEnd;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (start === end) end = firstNonSlashEnd;
|
|
else if (end === -1) end = path.length;
|
|
return path.substring(start, end);
|
|
}
|
|
for (let i = path.length - 1; i >= start; --i) {
|
|
if (isWindowsPathSeparator(path.charCodeAt(i))) {
|
|
if (!matchedSlash) {
|
|
start = i + 1;
|
|
break;
|
|
}
|
|
} else if (end === -1) {
|
|
matchedSlash = false;
|
|
end = i + 1;
|
|
}
|
|
}
|
|
if (end === -1) return "";
|
|
return path.substring(start, end);
|
|
};
|
|
exports.extname = function extname(path) {
|
|
validateString(path, "path");
|
|
let start = 0;
|
|
let startDot = -1;
|
|
let startPart = 0;
|
|
let end = -1;
|
|
let matchedSlash = true;
|
|
let preDotState = 0;
|
|
if (path.length >= 2 && path.charCodeAt(1) === CHAR_COLON && isWindowsDeviceRoot(path.charCodeAt(0))) {
|
|
start = startPart = 2;
|
|
}
|
|
for (let i = path.length - 1; i >= start; --i) {
|
|
const code = path.charCodeAt(i);
|
|
if (isWindowsPathSeparator(code)) {
|
|
if (!matchedSlash) {
|
|
startPart = i + 1;
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
if (end === -1) {
|
|
matchedSlash = false;
|
|
end = i + 1;
|
|
}
|
|
if (code === CHAR_DOT) {
|
|
if (startDot === -1) startDot = i;
|
|
else if (preDotState !== 1) preDotState = 1;
|
|
} else if (startDot !== -1) {
|
|
preDotState = -1;
|
|
}
|
|
}
|
|
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
return "";
|
|
}
|
|
return path.substring(startDot, end);
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-path/index.js
|
|
var require_bare_path = __commonJS({
|
|
"../../node_modules/bare-path/index.js"(exports, module) {
|
|
if (Bare.platform === "win32") {
|
|
module.exports = require_win32();
|
|
} else {
|
|
module.exports = require_posix();
|
|
}
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-semver/lib/constants.js
|
|
var require_constants2 = __commonJS({
|
|
"../../node_modules/bare-semver/lib/constants.js"(exports, module) {
|
|
module.exports = {
|
|
EQ: 1,
|
|
LT: 2,
|
|
LTE: 3,
|
|
GT: 4,
|
|
GTE: 5
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-semver/lib/errors.js
|
|
var require_errors = __commonJS({
|
|
"../../node_modules/bare-semver/lib/errors.js"(exports, module) {
|
|
module.exports = class SemVerError extends Error {
|
|
constructor(msg, code, fn = SemVerError) {
|
|
super(`${code}: ${msg}`);
|
|
this.code = code;
|
|
if (Error.captureStackTrace) {
|
|
Error.captureStackTrace(this, fn);
|
|
}
|
|
}
|
|
get name() {
|
|
return "SemVerError";
|
|
}
|
|
static INVALID_VERSION(msg, fn = SemVerError.INVALID_VERSION) {
|
|
return new SemVerError(msg, "INVALID_VERSION", fn);
|
|
}
|
|
static INVALID_RANGE(msg, fn = SemVerError.INVALID_RANGE) {
|
|
return new SemVerError(msg, "INVALID_RANGE", fn);
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-semver/lib/version.js
|
|
var require_version = __commonJS({
|
|
"../../node_modules/bare-semver/lib/version.js"(exports, module) {
|
|
var errors = require_errors();
|
|
var Version = class {
|
|
constructor(major, minor, patch, opts = {}) {
|
|
const { prerelease = [], build = [] } = opts;
|
|
this.major = major;
|
|
this.minor = minor;
|
|
this.patch = patch;
|
|
this.prerelease = prerelease;
|
|
this.build = build;
|
|
}
|
|
compare(version) {
|
|
return exports.compare(this, version);
|
|
}
|
|
toString() {
|
|
let result = `${this.major}.${this.minor}.${this.patch}`;
|
|
if (this.prerelease.length) {
|
|
result += "-" + this.prerelease.join(".");
|
|
}
|
|
if (this.build.length) {
|
|
result += "+" + this.build.join(".");
|
|
}
|
|
return result;
|
|
}
|
|
};
|
|
module.exports = exports = Version;
|
|
exports.parse = function parse(input, state = { position: 0, partial: false, range: false, precision: 0 }) {
|
|
let i = state.position;
|
|
let c;
|
|
const unexpected = (expected) => {
|
|
let msg;
|
|
if (i >= input.length) {
|
|
msg = `Unexpected end of input in '${input}'`;
|
|
} else {
|
|
msg = `Unexpected token '${input[i]}' in '${input}' at position ${i}`;
|
|
}
|
|
if (expected) msg += `, ${expected}`;
|
|
throw errors.INVALID_VERSION(msg, unexpected);
|
|
};
|
|
const components = [0, 0, 0];
|
|
let k = 0;
|
|
while (k < 3) {
|
|
c = input[i];
|
|
if (k > 0) {
|
|
if (c === ".") c = input[++i];
|
|
else if (state.range) break;
|
|
else unexpected("expected '.'");
|
|
}
|
|
if (state.range && (c === "x" || c === "X" || c === "*")) {
|
|
i++;
|
|
while (input[i] === ".") {
|
|
let j = i + 1;
|
|
while (input[j] >= "0" && input[j] <= "9" || input[j] === "x" || input[j] === "X" || input[j] === "*") {
|
|
j++;
|
|
}
|
|
if (j === i + 1) break;
|
|
i = j;
|
|
}
|
|
break;
|
|
}
|
|
if (c === "0") {
|
|
i++;
|
|
k++;
|
|
} else if (c >= "1" && c <= "9") {
|
|
let j = 0;
|
|
do
|
|
c = input[i + ++j];
|
|
while (c >= "0" && c <= "9");
|
|
components[k++] = parseInt(input.substring(i, i + j));
|
|
i += j;
|
|
} else unexpected("expected /[0-9]/");
|
|
}
|
|
state.precision = k;
|
|
const prerelease = [];
|
|
if (k === 3 && input[i] === "-") {
|
|
i++;
|
|
while (true) {
|
|
c = input[i];
|
|
let tag = "";
|
|
let j = 0;
|
|
while (c >= "0" && c <= "9") c = input[i + ++j];
|
|
let isNumeric = false;
|
|
if (j) {
|
|
tag += input.substring(i, i + j);
|
|
c = input[i += j];
|
|
isNumeric = tag[0] !== "0" || tag.length === 1;
|
|
}
|
|
j = 0;
|
|
while (c >= "0" && c <= "9" || c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "-") {
|
|
c = input[i + ++j];
|
|
}
|
|
if (j) {
|
|
tag += input.substring(i, i + j);
|
|
c = input[i += j];
|
|
} else if (!isNumeric) unexpected("expected /[a-zA-Z-]/");
|
|
prerelease.push(tag);
|
|
if (c === ".") c = input[++i];
|
|
else break;
|
|
}
|
|
}
|
|
const build = [];
|
|
if (k === 3 && input[i] === "+") {
|
|
i++;
|
|
while (true) {
|
|
c = input[i];
|
|
let tag = "";
|
|
let j = 0;
|
|
while (c >= "0" && c <= "9" || c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "-") {
|
|
c = input[i + ++j];
|
|
}
|
|
if (j) {
|
|
tag += input.substring(i, i + j);
|
|
c = input[i += j];
|
|
} else unexpected("expected /[0-9a-zA-Z-]/");
|
|
build.push(tag);
|
|
if (c === ".") c = input[++i];
|
|
else break;
|
|
}
|
|
}
|
|
if (i < input.length && state.partial === false) {
|
|
unexpected("expected end of input");
|
|
}
|
|
state.position = i;
|
|
return new Version(...components, { prerelease, build });
|
|
};
|
|
var integer = /^[0-9]+$/;
|
|
exports.compare = function compare(a, b) {
|
|
if (a.major > b.major) return 1;
|
|
if (a.major < b.major) return -1;
|
|
if (a.minor > b.minor) return 1;
|
|
if (a.minor < b.minor) return -1;
|
|
if (a.patch > b.patch) return 1;
|
|
if (a.patch < b.patch) return -1;
|
|
if (a.prerelease.length === 0) return b.prerelease.length === 0 ? 0 : 1;
|
|
if (b.prerelease.length === 0) return -1;
|
|
let i = 0;
|
|
do {
|
|
let x = a.prerelease[i];
|
|
let y = b.prerelease[i];
|
|
if (x === void 0) return y === void 0 ? 0 : -1;
|
|
if (y === void 0) return 1;
|
|
if (x === y) continue;
|
|
const xInt = integer.test(x);
|
|
const yInt = integer.test(y);
|
|
if (xInt && yInt) {
|
|
x = +x;
|
|
y = +y;
|
|
} else {
|
|
if (xInt) return -1;
|
|
if (yInt) return 1;
|
|
}
|
|
return x > y ? 1 : -1;
|
|
} while (++i);
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-semver/lib/comparator.js
|
|
var require_comparator = __commonJS({
|
|
"../../node_modules/bare-semver/lib/comparator.js"(exports, module) {
|
|
var constants = require_constants2();
|
|
var symbols = {
|
|
[constants.EQ]: "=",
|
|
[constants.LT]: "<",
|
|
[constants.LTE]: "<=",
|
|
[constants.GT]: ">",
|
|
[constants.GTE]: ">="
|
|
};
|
|
module.exports = class Comparator {
|
|
constructor(operator, version) {
|
|
this.operator = operator;
|
|
this.version = version;
|
|
}
|
|
test(version) {
|
|
const result = version.compare(this.version);
|
|
switch (this.operator) {
|
|
case constants.LT:
|
|
return result < 0;
|
|
case constants.LTE:
|
|
return result <= 0;
|
|
case constants.GT:
|
|
return result > 0;
|
|
case constants.GTE:
|
|
return result >= 0;
|
|
default:
|
|
return result === 0;
|
|
}
|
|
}
|
|
toString() {
|
|
return symbols[this.operator] + this.version;
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-semver/lib/range.js
|
|
var require_range = __commonJS({
|
|
"../../node_modules/bare-semver/lib/range.js"(exports, module) {
|
|
var constants = require_constants2();
|
|
var errors = require_errors();
|
|
var Version = require_version();
|
|
var Comparator = require_comparator();
|
|
var Range = class {
|
|
constructor(comparators = []) {
|
|
this.comparators = comparators;
|
|
}
|
|
test(version) {
|
|
for (const set of this.comparators) {
|
|
let matches = true;
|
|
for (const comparator of set) {
|
|
if (comparator.test(version)) continue;
|
|
matches = false;
|
|
break;
|
|
}
|
|
if (!matches) continue;
|
|
if (version.prerelease.length && !allows(set, version)) continue;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
toString() {
|
|
let result = "";
|
|
let first = true;
|
|
for (const set of this.comparators) {
|
|
if (first) first = false;
|
|
else result += " || ";
|
|
result += set.join(" ");
|
|
}
|
|
return result;
|
|
}
|
|
};
|
|
module.exports = exports = Range;
|
|
exports.parse = function parse(input, state = { position: 0, partial: false }) {
|
|
let i = state.position;
|
|
let c;
|
|
const unexpected = (expected) => {
|
|
let msg;
|
|
if (i >= input.length) {
|
|
msg = `Unexpected end of input in '${input}'`;
|
|
} else {
|
|
msg = `Unexpected token '${input[i]}' in '${input}' at position ${i}`;
|
|
}
|
|
if (expected) msg += `, ${expected}`;
|
|
throw errors.INVALID_VERSION(msg, unexpected);
|
|
};
|
|
const comparators = [];
|
|
while (i < input.length) {
|
|
const set = [];
|
|
while (i < input.length) {
|
|
c = input[i];
|
|
let operator = constants.EQ;
|
|
let caret = false;
|
|
let tilde = false;
|
|
if (c === "<") {
|
|
operator = constants.LT;
|
|
c = input[++i];
|
|
if (c === "=") {
|
|
operator = constants.LTE;
|
|
c = input[++i];
|
|
}
|
|
} else if (c === ">") {
|
|
operator = constants.GT;
|
|
c = input[++i];
|
|
if (c === "=") {
|
|
operator = constants.GTE;
|
|
c = input[++i];
|
|
}
|
|
} else if (c === "=") {
|
|
c = input[++i];
|
|
} else if (c === "^") {
|
|
caret = true;
|
|
c = input[++i];
|
|
} else if (c === "~") {
|
|
tilde = true;
|
|
c = input[++i];
|
|
if (c === ">") c = input[++i];
|
|
}
|
|
while (c === " ") c = input[++i];
|
|
const state2 = { position: i, partial: true, range: true };
|
|
const lower = Version.parse(input, state2);
|
|
const precision = state2.precision;
|
|
c = input[i = state2.position];
|
|
while (c === " ") c = input[++i];
|
|
if (c === "-" && input[i + 1] === " " && operator === constants.EQ && !caret && !tilde) {
|
|
c = input[++i];
|
|
while (c === " ") c = input[++i];
|
|
state2.position = i;
|
|
const high = Version.parse(input, state2);
|
|
c = input[i = state2.position];
|
|
set.push(new Comparator(constants.GTE, lower));
|
|
if (state2.precision === 3) {
|
|
set.push(new Comparator(constants.LTE, high));
|
|
} else if (state2.precision === 2) {
|
|
set.push(upper(high.major, high.minor + 1, 0));
|
|
} else if (state2.precision === 1) {
|
|
set.push(upper(high.major + 1, 0, 0));
|
|
}
|
|
while (c === " ") c = input[++i];
|
|
} else {
|
|
if (caret) {
|
|
for (const comparator of expandCaret(lower, precision)) set.push(comparator);
|
|
} else if (tilde) {
|
|
for (const comparator of expandTilde(lower, precision)) set.push(comparator);
|
|
} else if (operator === constants.EQ) {
|
|
for (const comparator of expandPartial(lower, precision)) set.push(comparator);
|
|
} else {
|
|
set.push(new Comparator(operator, lower));
|
|
}
|
|
}
|
|
if (c === "|" && input[i + 1] === "|") {
|
|
c = input[i += 2];
|
|
while (c === " ") c = input[++i];
|
|
break;
|
|
}
|
|
if (c && c !== "<" && c !== ">" && c !== "^" && c !== "~" && c !== "=") {
|
|
unexpected("expected '||', '<', '>', '^', '~', or '='");
|
|
}
|
|
}
|
|
if (set.length) comparators.push(set);
|
|
}
|
|
if (i < input.length && state.partial === false) {
|
|
unexpected("expected end of input");
|
|
}
|
|
state.position = i;
|
|
return new Range(comparators);
|
|
};
|
|
function allows(set, version) {
|
|
for (const comparator of set) {
|
|
const target = comparator.version;
|
|
if (target.prerelease.length && target.major === version.major && target.minor === version.minor && target.patch === version.patch) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function upper(major, minor, patch) {
|
|
return new Comparator(constants.LT, new Version(major, minor, patch, { prerelease: ["0"] }));
|
|
}
|
|
function expandPartial(version, precision) {
|
|
if (precision === 0) return [new Comparator(constants.GTE, new Version(0, 0, 0))];
|
|
if (precision === 3) return [new Comparator(constants.EQ, version)];
|
|
const set = [new Comparator(constants.GTE, version)];
|
|
if (precision === 1) set.push(upper(version.major + 1, 0, 0));
|
|
else set.push(upper(version.major, version.minor + 1, 0));
|
|
return set;
|
|
}
|
|
function expandCaret(version, precision) {
|
|
if (precision === 0) return [new Comparator(constants.GTE, new Version(0, 0, 0))];
|
|
const { major, minor, patch } = version;
|
|
const set = [new Comparator(constants.GTE, version)];
|
|
if (major !== 0) set.push(upper(major + 1, 0, 0));
|
|
else if (precision === 1) set.push(upper(1, 0, 0));
|
|
else if (minor !== 0) set.push(upper(0, minor + 1, 0));
|
|
else if (precision === 2) set.push(upper(0, 1, 0));
|
|
else set.push(upper(0, 0, patch + 1));
|
|
return set;
|
|
}
|
|
function expandTilde(version, precision) {
|
|
if (precision === 0) return [new Comparator(constants.GTE, new Version(0, 0, 0))];
|
|
const { major, minor } = version;
|
|
const set = [new Comparator(constants.GTE, version)];
|
|
if (precision === 1) set.push(upper(major + 1, 0, 0));
|
|
else set.push(upper(major, minor + 1, 0));
|
|
return set;
|
|
}
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-semver/index.js
|
|
var require_bare_semver = __commonJS({
|
|
"../../node_modules/bare-semver/index.js"(exports) {
|
|
exports.constants = require_constants2();
|
|
exports.errors = require_errors();
|
|
var Version = exports.Version = require_version();
|
|
var Range = exports.Range = require_range();
|
|
exports.Comparator = require_comparator();
|
|
exports.satisfies = function satisfies(version, range) {
|
|
if (typeof version === "string") version = Version.parse(version);
|
|
if (typeof range === "string") range = Range.parse(range);
|
|
return range.test(version);
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-module-resolve/lib/errors.js
|
|
var require_errors2 = __commonJS({
|
|
"../../node_modules/bare-module-resolve/lib/errors.js"(exports, module) {
|
|
module.exports = class ModuleResolveError extends Error {
|
|
constructor(msg, fn = ModuleResolveError, code = fn.name) {
|
|
super(`${code}: ${msg}`);
|
|
this.code = code;
|
|
if (Error.captureStackTrace) Error.captureStackTrace(this, fn);
|
|
}
|
|
get name() {
|
|
return "ModuleResolveError";
|
|
}
|
|
static INVALID_MODULE_SPECIFIER(msg) {
|
|
return new ModuleResolveError(msg, ModuleResolveError.INVALID_MODULE_SPECIFIER);
|
|
}
|
|
static INVALID_PACKAGE_TARGET(msg) {
|
|
return new ModuleResolveError(msg, ModuleResolveError.INVALID_PACKAGE_TARGET);
|
|
}
|
|
static INVALID_PACKAGE_CONFIGURATION(msg) {
|
|
return new ModuleResolveError(msg, ModuleResolveError.INVALID_PACKAGE_CONFIGURATION);
|
|
}
|
|
static PACKAGE_PATH_NOT_EXPORTED(msg) {
|
|
return new ModuleResolveError(msg, ModuleResolveError.PACKAGE_PATH_NOT_EXPORTED);
|
|
}
|
|
static PACKAGE_IMPORT_NOT_DEFINED(msg) {
|
|
return new ModuleResolveError(msg, ModuleResolveError.PACKAGE_IMPORT_NOT_DEFINED);
|
|
}
|
|
static UNSUPPORTED_ENGINE(msg) {
|
|
return new ModuleResolveError(msg, ModuleResolveError.UNSUPPORTED_ENGINE);
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-module-resolve/index.js
|
|
var require_bare_module_resolve = __commonJS({
|
|
"../../node_modules/bare-module-resolve/index.js"(exports, module) {
|
|
var { satisfies } = require_bare_semver();
|
|
var errors = require_errors2();
|
|
module.exports = exports = function resolve(specifier, parentURL, opts, readPackage) {
|
|
if (typeof opts === "function") {
|
|
readPackage = opts;
|
|
opts = {};
|
|
} else if (typeof readPackage !== "function") {
|
|
readPackage = defaultReadPackage;
|
|
}
|
|
return {
|
|
*[Symbol.iterator]() {
|
|
const generator = exports.module(specifier, parentURL, opts);
|
|
let next = generator.next();
|
|
while (next.done !== true) {
|
|
const value = next.value;
|
|
if (value.package) {
|
|
next = generator.next(readPackage(value.package));
|
|
} else {
|
|
next = generator.next(yield value.resolution);
|
|
}
|
|
}
|
|
return next.value;
|
|
},
|
|
async *[Symbol.asyncIterator]() {
|
|
const generator = exports.module(specifier, parentURL, opts);
|
|
let next = generator.next();
|
|
while (next.done !== true) {
|
|
const value = next.value;
|
|
if (value.package) {
|
|
next = generator.next(await readPackage(value.package));
|
|
} else {
|
|
next = generator.next(yield value.resolution);
|
|
}
|
|
}
|
|
return next.value;
|
|
}
|
|
};
|
|
};
|
|
function defaultReadPackage() {
|
|
return null;
|
|
}
|
|
var UNRESOLVED = 0;
|
|
var YIELDED = 1;
|
|
var RESOLVED = YIELDED | 2;
|
|
var CYCLIC = 4;
|
|
exports.constants = {
|
|
UNRESOLVED,
|
|
YIELDED,
|
|
RESOLVED,
|
|
CYCLIC
|
|
};
|
|
exports.module = function* (specifier, parentURL, opts = {}) {
|
|
const { resolutions = null, imports = null } = opts;
|
|
if (exports.startsWithWindowsDriveLetter(specifier)) {
|
|
specifier = "/" + specifier;
|
|
}
|
|
let status;
|
|
if (resolutions) {
|
|
status = yield* exports.preresolved(specifier, resolutions, parentURL, opts);
|
|
if (status) return status;
|
|
}
|
|
status = yield* exports.url(specifier, parentURL, opts);
|
|
if (status) return status;
|
|
status = yield* exports.packageImports(specifier, parentURL, opts);
|
|
if (status) return status;
|
|
if (specifier === "." || specifier === ".." || specifier[0] === "/" || specifier[0] === "\\" || specifier.startsWith("./") || specifier.startsWith(".\\") || specifier.startsWith("../") || specifier.startsWith("..\\")) {
|
|
if (imports) {
|
|
status = yield* exports.packageImportsExports(specifier, imports, parentURL, true, opts);
|
|
if (status) return status;
|
|
}
|
|
status = yield* exports.deferred(specifier, opts);
|
|
if (status) return status;
|
|
status = yield* exports.file(specifier, parentURL, false, opts);
|
|
if (status === RESOLVED) return status;
|
|
const yielded = (status & YIELDED) !== 0;
|
|
status = yield* exports.directory(specifier, parentURL, opts);
|
|
if (yielded) status |= YIELDED;
|
|
return status;
|
|
}
|
|
return yield* exports.package(specifier, parentURL, opts);
|
|
};
|
|
exports.url = function* (url, parentURL, opts = {}) {
|
|
const { imports = null, deferredProtocol = "deferred:", resolutions = null } = opts;
|
|
let resolution;
|
|
try {
|
|
resolution = new URL(url);
|
|
} catch {
|
|
return UNRESOLVED;
|
|
}
|
|
if (imports) {
|
|
const status = yield* exports.packageImportsExports(
|
|
resolution.href,
|
|
imports,
|
|
parentURL,
|
|
true,
|
|
opts
|
|
);
|
|
if (status && (status & CYCLIC) === 0) return status;
|
|
}
|
|
if (resolution.protocol === deferredProtocol) {
|
|
const specifier = resolution.pathname;
|
|
if (resolutions) {
|
|
const imports2 = resolutions[parentURL.href];
|
|
if (typeof imports2 === "object" && imports2 !== null) {
|
|
opts = {
|
|
...opts,
|
|
resolutions: { ...resolutions, [parentURL.href]: { ...imports2, [specifier]: null } }
|
|
};
|
|
}
|
|
}
|
|
return yield* exports.module(specifier, parentURL, opts);
|
|
}
|
|
if (resolution.protocol === "node:") {
|
|
const specifier = resolution.pathname;
|
|
if (specifier === "." || specifier === ".." || specifier[0] === "/" || specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
throw errors.INVALID_MODULE_SPECIFIER(`Module specifier '${url}' is not a valid package name`);
|
|
}
|
|
return yield* exports.package(specifier, parentURL, opts);
|
|
}
|
|
const resolved = yield { resolution };
|
|
return resolved ? RESOLVED : YIELDED;
|
|
};
|
|
exports.preresolved = function* (specifier, resolutions, parentURL, opts = {}) {
|
|
const imports = resolutions[parentURL.href];
|
|
if (typeof imports === "object" && imports !== null) {
|
|
return yield* exports.packageImportsExports(specifier, imports, parentURL, true, opts);
|
|
}
|
|
return UNRESOLVED;
|
|
};
|
|
exports.deferred = function* (specifier, opts = {}) {
|
|
const { deferredProtocol = "deferred:", defer = [] } = opts;
|
|
if (defer.includes(specifier)) {
|
|
const resolved = yield { resolution: new URL(deferredProtocol + specifier) };
|
|
return resolved ? RESOLVED : YIELDED;
|
|
}
|
|
return UNRESOLVED;
|
|
};
|
|
exports.package = function* (packageSpecifier, parentURL, opts = {}) {
|
|
const { builtins = [] } = opts;
|
|
if (packageSpecifier === "") {
|
|
throw errors.INVALID_MODULE_SPECIFIER(
|
|
`Module specifier '${packageSpecifier}' is not a valid package name`
|
|
);
|
|
}
|
|
let packageName;
|
|
if (packageSpecifier[0] !== "@") {
|
|
packageName = packageSpecifier.split("/", 1).join();
|
|
} else {
|
|
if (!packageSpecifier.includes("/")) {
|
|
throw errors.INVALID_MODULE_SPECIFIER(
|
|
`Module specifier '${packageSpecifier}' is not a valid package name`
|
|
);
|
|
}
|
|
packageName = packageSpecifier.split("/", 2).join("/");
|
|
}
|
|
if (packageName[0] === "." || packageName.includes("\\") || packageName.includes("%")) {
|
|
throw errors.INVALID_MODULE_SPECIFIER(
|
|
`Module specifier '${packageSpecifier}' is not a valid package name`
|
|
);
|
|
}
|
|
let status;
|
|
status = yield* exports.builtinTarget(packageSpecifier, null, builtins, opts);
|
|
if (status) return status;
|
|
status = yield* exports.deferred(packageSpecifier, opts);
|
|
if (status) return status;
|
|
let packageSubpath = "." + packageSpecifier.substring(packageName.length);
|
|
status = yield* exports.packageSelf(packageName, packageSubpath, parentURL, opts);
|
|
if (status) return status;
|
|
parentURL = new URL(parentURL.href);
|
|
for (const packageURL of exports.lookupPackageRoot(packageName, parentURL)) {
|
|
const info = yield { package: packageURL };
|
|
if (info) {
|
|
if (info.engines) exports.validateEngines(packageURL, info.engines, opts);
|
|
if (info.exports) {
|
|
return yield* exports.packageExports(packageURL, packageSubpath, info.exports, opts);
|
|
}
|
|
if (packageSubpath === ".") {
|
|
if (typeof info.main === "string" && info.main !== "") {
|
|
packageSubpath = info.main;
|
|
} else {
|
|
return yield* exports.file("index", packageURL, true, opts);
|
|
}
|
|
}
|
|
status = yield* exports.file(packageSubpath, packageURL, false, opts);
|
|
if (status === RESOLVED) return status;
|
|
const yielded = (status & YIELDED) !== 0;
|
|
status = yield* exports.directory(packageSubpath, packageURL, opts);
|
|
if (yielded) status |= YIELDED;
|
|
return status;
|
|
}
|
|
}
|
|
return UNRESOLVED;
|
|
};
|
|
exports.packageSelf = function* (packageName, packageSubpath, parentURL, opts = {}) {
|
|
for (const packageURL of exports.lookupPackageScope(parentURL, opts)) {
|
|
const info = yield { package: packageURL };
|
|
if (info) {
|
|
if (info.name !== packageName) return false;
|
|
if (info.exports) {
|
|
return yield* exports.packageExports(packageURL, packageSubpath, info.exports, opts);
|
|
}
|
|
if (packageSubpath === ".") {
|
|
if (typeof info.main === "string" && info.main !== "") {
|
|
packageSubpath = info.main;
|
|
} else {
|
|
return yield* exports.file("index", packageURL, true, opts);
|
|
}
|
|
}
|
|
let status = yield* exports.file(packageSubpath, packageURL, false, opts);
|
|
if (status === RESOLVED) return status;
|
|
const yielded = (status & YIELDED) !== 0;
|
|
status = yield* exports.directory(packageSubpath, packageURL, opts);
|
|
if (yielded) status |= YIELDED;
|
|
return status;
|
|
}
|
|
}
|
|
return UNRESOLVED;
|
|
};
|
|
exports.packageExports = function* (packageURL, subpath, packageExports, opts = {}) {
|
|
if (typeof packageExports === "object" && packageExports !== null && !Array.isArray(packageExports)) {
|
|
const keys = Object.keys(packageExports);
|
|
const relative = keys.filter((key) => key.startsWith(".")).length;
|
|
if (relative !== 0 && relative !== keys.length) {
|
|
throw errors.INVALID_PACKAGE_CONFIGURATION(
|
|
`"exports" in '${packageURL}' cannot contain some keys starting with '.' and some not`
|
|
);
|
|
}
|
|
}
|
|
if (subpath === ".") {
|
|
let mainExport;
|
|
if (typeof packageExports === "string" || Array.isArray(packageExports)) {
|
|
mainExport = packageExports;
|
|
} else if (typeof packageExports === "object" && packageExports !== null) {
|
|
const keys = Object.keys(packageExports);
|
|
if (keys.some((key) => key.startsWith("."))) {
|
|
if ("." in packageExports) mainExport = packageExports["."];
|
|
} else {
|
|
mainExport = packageExports;
|
|
}
|
|
}
|
|
if (mainExport) {
|
|
const status = yield* exports.packageTarget(packageURL, mainExport, null, false, opts);
|
|
if (status) return status;
|
|
}
|
|
} else if (typeof packageExports === "object" && packageExports !== null) {
|
|
const keys = Object.keys(packageExports);
|
|
if (keys.every((key) => key.startsWith("."))) {
|
|
const status = yield* exports.packageImportsExports(
|
|
subpath,
|
|
packageExports,
|
|
packageURL,
|
|
false,
|
|
opts
|
|
);
|
|
if (status) return status;
|
|
}
|
|
}
|
|
throw errors.PACKAGE_PATH_NOT_EXPORTED(
|
|
`Package subpath '${subpath}' is not defined by "exports" in '${packageURL}'`
|
|
);
|
|
};
|
|
exports.packageImports = function* (specifier, parentURL, opts = {}) {
|
|
const { imports = null } = opts;
|
|
if (specifier === "#" || specifier.startsWith("#/")) {
|
|
throw errors.INVALID_MODULE_SPECIFIER(
|
|
`Module specifier '${specifier}' is not a valid internal imports specifier`
|
|
);
|
|
}
|
|
for (const packageURL of exports.lookupPackageScope(parentURL, opts)) {
|
|
const info = yield { package: packageURL };
|
|
if (info) {
|
|
if (info.imports) {
|
|
const status = yield* exports.packageImportsExports(
|
|
specifier,
|
|
info.imports,
|
|
packageURL,
|
|
true,
|
|
opts
|
|
);
|
|
if (status) return status;
|
|
}
|
|
if (specifier.startsWith("#")) {
|
|
throw errors.PACKAGE_IMPORT_NOT_DEFINED(
|
|
`Package import specifier '${specifier}' is not defined by "imports" in '${packageURL}'`
|
|
);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
if (imports) {
|
|
const status = yield* exports.packageImportsExports(specifier, imports, parentURL, true, opts);
|
|
if (status) return status;
|
|
}
|
|
return UNRESOLVED;
|
|
};
|
|
exports.packageImportsExports = function* (matchKey, matchObject, packageURL, isImports, opts = {}) {
|
|
if (matchKey in matchObject && !matchKey.includes("*")) {
|
|
const target = matchObject[matchKey];
|
|
return yield* exports.packageTarget(packageURL, target, null, isImports, opts);
|
|
}
|
|
const expansionKeys = Object.keys(matchObject).filter((key) => key.includes("*")).sort(exports.patternKeyCompare);
|
|
for (const expansionKey of expansionKeys) {
|
|
const patternIndex = expansionKey.indexOf("*");
|
|
const patternBase = expansionKey.substring(0, patternIndex);
|
|
if (matchKey.startsWith(patternBase) && matchKey !== patternBase) {
|
|
const patternTrailer = expansionKey.substring(patternIndex + 1);
|
|
if (patternTrailer === "" || matchKey.endsWith(patternTrailer) && matchKey.length >= expansionKey.length) {
|
|
const target = matchObject[expansionKey];
|
|
const patternMatch = matchKey.substring(
|
|
patternBase.length,
|
|
matchKey.length - patternTrailer.length
|
|
);
|
|
return yield* exports.packageTarget(packageURL, target, patternMatch, isImports, opts);
|
|
}
|
|
}
|
|
}
|
|
return UNRESOLVED;
|
|
};
|
|
exports.validateEngines = function validateEngines(packageURL, packageEngines, opts = {}) {
|
|
const { engines = {} } = opts;
|
|
for (const [engine, range] of Object.entries(packageEngines)) {
|
|
if (engine in engines) {
|
|
const version = engines[engine];
|
|
if (!satisfies(version, range)) {
|
|
throw errors.UNSUPPORTED_ENGINE(
|
|
`Package not compatible with engine '${engine}' ${version}, requires range '${range}' defined by "engines" in '${packageURL}'`
|
|
);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
exports.patternKeyCompare = function patternKeyCompare(keyA, keyB) {
|
|
const patternIndexA = keyA.indexOf("*");
|
|
const patternIndexB = keyB.indexOf("*");
|
|
const baseLengthA = patternIndexA === -1 ? keyA.length : patternIndexA + 1;
|
|
const baseLengthB = patternIndexB === -1 ? keyB.length : patternIndexB + 1;
|
|
if (baseLengthA > baseLengthB) return -1;
|
|
if (baseLengthB > baseLengthA) return 1;
|
|
if (patternIndexA === -1) return 1;
|
|
if (patternIndexB === -1) return -1;
|
|
if (keyA.length > keyB.length) return -1;
|
|
if (keyB.length > keyA.length) return 1;
|
|
return 0;
|
|
};
|
|
exports.packageTarget = function* (packageURL, target, patternMatch, isImports, opts = {}) {
|
|
const { conditions = [], matchedConditions = [], matchedTargets = [] } = opts;
|
|
opts = { ...opts, matchedConditions, matchedTargets };
|
|
if (typeof target === "string") {
|
|
if (!target.startsWith("./") && !isImports) {
|
|
throw errors.INVALID_PACKAGE_TARGET(
|
|
`Invalid target '${target}' defined by "exports" in '${packageURL}'`
|
|
);
|
|
}
|
|
if (patternMatch !== null) {
|
|
target = target.replaceAll("*", patternMatch);
|
|
}
|
|
if (matchedTargets.includes(target)) return CYCLIC;
|
|
matchedTargets.push(target);
|
|
let status = yield* exports.url(target, packageURL, opts);
|
|
if (status) {
|
|
matchedTargets.pop();
|
|
return status;
|
|
}
|
|
if (target === "." || target === ".." || target[0] === "/" || target.startsWith("./") || target.startsWith("../")) {
|
|
if (hasOpaquePath(packageURL)) {
|
|
matchedTargets.pop();
|
|
return UNRESOLVED;
|
|
}
|
|
const resolved = yield { resolution: new URL(target, packageURL) };
|
|
matchedTargets.pop();
|
|
return resolved ? RESOLVED : YIELDED;
|
|
}
|
|
status = yield* exports.package(target, packageURL, opts);
|
|
matchedTargets.pop();
|
|
return status;
|
|
}
|
|
if (Array.isArray(target)) {
|
|
let status = UNRESOLVED;
|
|
for (const targetValue of target) {
|
|
status |= yield* exports.packageTarget(packageURL, targetValue, patternMatch, isImports, opts);
|
|
if (status === RESOLVED) return status;
|
|
}
|
|
return status;
|
|
}
|
|
if (typeof target === "object" && target !== null) {
|
|
let status = UNRESOLVED;
|
|
for (const [condition, targetValue, subset] of exports.conditionMatches(
|
|
target,
|
|
conditions,
|
|
opts
|
|
)) {
|
|
matchedConditions.push(condition);
|
|
status |= yield* exports.packageTarget(packageURL, targetValue, patternMatch, isImports, {
|
|
...opts,
|
|
conditions: subset
|
|
});
|
|
matchedConditions.pop();
|
|
}
|
|
return status;
|
|
}
|
|
return UNRESOLVED;
|
|
};
|
|
exports.builtinTarget = function* (packageSpecifier, packageVersion, target, opts = {}) {
|
|
const { builtinProtocol = "builtin:", conditions = [], matchedConditions = [] } = opts;
|
|
opts = { ...opts, matchedConditions };
|
|
if (typeof target === "string") {
|
|
const targetParts = target.split("@");
|
|
let targetName;
|
|
let targetVersion;
|
|
if (target[0] !== "@") {
|
|
targetName = targetParts[0];
|
|
targetVersion = targetParts[1] || null;
|
|
} else {
|
|
targetName = targetParts.slice(0, 2).join("@");
|
|
targetVersion = targetParts[2] || null;
|
|
}
|
|
if (packageSpecifier === targetName) {
|
|
if (packageVersion === null && targetVersion === null) {
|
|
const resolved = yield {
|
|
resolution: new URL(builtinProtocol + packageSpecifier)
|
|
};
|
|
return resolved ? RESOLVED : YIELDED;
|
|
}
|
|
let version = null;
|
|
if (packageVersion === null) {
|
|
version = targetVersion;
|
|
} else if (targetVersion === null || packageVersion === targetVersion) {
|
|
version = packageVersion;
|
|
}
|
|
if (version !== null) {
|
|
const resolved = yield {
|
|
resolution: new URL(builtinProtocol + packageSpecifier + "@" + version)
|
|
};
|
|
return resolved ? RESOLVED : YIELDED;
|
|
}
|
|
}
|
|
return UNRESOLVED;
|
|
}
|
|
if (Array.isArray(target)) {
|
|
let status = UNRESOLVED;
|
|
for (const targetValue of target) {
|
|
status |= yield* exports.builtinTarget(packageSpecifier, packageVersion, targetValue, opts);
|
|
if (status === RESOLVED) return status;
|
|
}
|
|
return status;
|
|
}
|
|
if (typeof target === "object" && target !== null) {
|
|
let status = UNRESOLVED;
|
|
for (const [condition, targetValue, subset] of exports.conditionMatches(
|
|
target,
|
|
conditions,
|
|
opts
|
|
)) {
|
|
matchedConditions.push(condition);
|
|
status |= yield* exports.builtinTarget(packageSpecifier, packageVersion, targetValue, {
|
|
...opts,
|
|
conditions: subset
|
|
});
|
|
matchedConditions.pop();
|
|
}
|
|
return status;
|
|
}
|
|
return UNRESOLVED;
|
|
};
|
|
exports.conditionMatches = function* conditionMatches(target, conditions, opts = {}) {
|
|
if (conditions.every((condition) => typeof condition === "string")) {
|
|
const keys = Object.keys(target);
|
|
for (const condition of keys) {
|
|
if (condition === "default" || conditions.includes(condition)) {
|
|
yield [condition, target[condition], conditions];
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
let yielded = false;
|
|
for (const subset of conditions) {
|
|
if (yield* conditionMatches(target, subset, opts)) {
|
|
yielded = true;
|
|
}
|
|
}
|
|
return yielded;
|
|
};
|
|
exports.lookupPackageRoot = function* (packageName, parentURL) {
|
|
if (hasOpaquePath(parentURL)) return null;
|
|
parentURL = new URL(parentURL.href);
|
|
do {
|
|
const packageURL = new URL("node_modules/" + packageName + "/", parentURL);
|
|
const info = yield new URL("package.json", packageURL);
|
|
if (info) return info;
|
|
parentURL.pathname = parentURL.pathname.substring(0, parentURL.pathname.lastIndexOf("/"));
|
|
if (parentURL.pathname.length === 3 && exports.isWindowsDriveLetter(parentURL.pathname.substring(1))) {
|
|
break;
|
|
}
|
|
} while (parentURL.pathname !== "" && parentURL.pathname !== "/");
|
|
return null;
|
|
};
|
|
exports.lookupPackageScope = function* lookupPackageScope(scopeURL, opts = {}) {
|
|
const { resolutions = null } = opts;
|
|
if (resolutions) {
|
|
for (const { resolution } of exports.preresolved("#package", resolutions, scopeURL, opts)) {
|
|
if (resolution) return yield resolution;
|
|
}
|
|
}
|
|
if (hasOpaquePath(scopeURL)) return null;
|
|
scopeURL = new URL(scopeURL.href);
|
|
do {
|
|
if (scopeURL.pathname.endsWith("/node_modules")) break;
|
|
const info = yield new URL("package.json", scopeURL);
|
|
if (info) return info;
|
|
scopeURL.pathname = scopeURL.pathname.substring(0, scopeURL.pathname.lastIndexOf("/"));
|
|
if (scopeURL.pathname.length === 3 && exports.isWindowsDriveLetter(scopeURL.pathname.substring(1))) {
|
|
break;
|
|
}
|
|
} while (scopeURL.pathname !== "" && scopeURL.pathname !== "/");
|
|
return null;
|
|
};
|
|
exports.file = function* (filename, parentURL, isIndex, opts = {}) {
|
|
if (filename === "." || filename === ".." || filename[filename.length - 1] === "/" || filename[filename.length - 1] === "\\") {
|
|
return UNRESOLVED;
|
|
}
|
|
if (hasOpaquePath(parentURL)) return UNRESOLVED;
|
|
if (parentURL.protocol === "file:" && /%2f|%5c/i.test(filename)) {
|
|
throw errors.INVALID_MODULE_SPECIFIER(`Module specifier '${filename}' is invalid`);
|
|
}
|
|
const { extensions = [] } = opts;
|
|
let status = UNRESOLVED;
|
|
if (!isIndex) {
|
|
if (yield { resolution: new URL(filename, parentURL) }) {
|
|
return RESOLVED;
|
|
}
|
|
status = YIELDED;
|
|
}
|
|
for (const ext of extensions) {
|
|
if (filename.endsWith(ext)) continue;
|
|
if (yield { resolution: new URL(filename + ext, parentURL) }) {
|
|
return RESOLVED;
|
|
}
|
|
status = YIELDED;
|
|
}
|
|
return status;
|
|
};
|
|
exports.directory = function* (dirname, parentURL, opts = {}) {
|
|
if (hasOpaquePath(parentURL)) return UNRESOLVED;
|
|
let directoryURL;
|
|
if (dirname[dirname.length - 1] === "/" || dirname[dirname.length - 1] === "\\") {
|
|
directoryURL = new URL(dirname, parentURL);
|
|
} else {
|
|
directoryURL = new URL(dirname + "/", parentURL);
|
|
}
|
|
const info = yield { package: new URL("package.json", directoryURL) };
|
|
if (info) {
|
|
if (info.exports) {
|
|
return yield* exports.packageExports(directoryURL, ".", info.exports, opts);
|
|
}
|
|
if (typeof info.main === "string" && info.main !== "") {
|
|
let status = yield* exports.file(info.main, directoryURL, false, opts);
|
|
if (status === RESOLVED) return status;
|
|
const yielded = (status & YIELDED) !== 0;
|
|
status = yield* exports.directory(info.main, directoryURL, opts);
|
|
if (yielded) status |= YIELDED;
|
|
return status;
|
|
}
|
|
}
|
|
return yield* exports.file("index", directoryURL, true, opts);
|
|
};
|
|
function hasOpaquePath(url) {
|
|
return url.pathname[0] !== "/";
|
|
}
|
|
function isASCIIUpperAlpha(c) {
|
|
return c >= 65 && c <= 90;
|
|
}
|
|
function isASCIILowerAlpha(c) {
|
|
return c >= 97 && c <= 122;
|
|
}
|
|
function isASCIIAlpha(c) {
|
|
return isASCIIUpperAlpha(c) || isASCIILowerAlpha(c);
|
|
}
|
|
exports.isWindowsDriveLetter = function isWindowsDriveLetter(input) {
|
|
return input.length >= 2 && isASCIIAlpha(input.charCodeAt(0)) && (input.charCodeAt(1) === 58 || input.charCodeAt(1) === 124);
|
|
};
|
|
exports.startsWithWindowsDriveLetter = function startsWithWindowsDriveLetter(input) {
|
|
return input.length >= 2 && exports.isWindowsDriveLetter(input) && (input.length === 2 || input.charCodeAt(2) === 47 || input.charCodeAt(2) === 92 || input.charCodeAt(2) === 63 || input.charCodeAt(2) === 35);
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-module-lexer/lib/binding/bare.js
|
|
var require_bare = __commonJS({
|
|
"../../node_modules/bare-module-lexer/lib/binding/bare.js"(exports, module) {
|
|
module.exports = __require.addon("../..");
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-module-lexer/index.js
|
|
var require_bare_module_lexer = __commonJS({
|
|
"../../node_modules/bare-module-lexer/index.js"(exports, module) {
|
|
var binding = require_bare();
|
|
module.exports = exports = function lex(input, encoding, opts = {}) {
|
|
if (typeof encoding === "object" && encoding !== null) {
|
|
opts = encoding;
|
|
encoding = null;
|
|
}
|
|
if (typeof input !== "string" && !ArrayBuffer.isView(input)) {
|
|
throw new TypeError(`Input must be a string or buffer. Received type ${typeof input}`);
|
|
}
|
|
return binding.lex(typeof input === "string" ? Buffer.from(input, encoding) : input);
|
|
};
|
|
exports.constants = {
|
|
/**
|
|
* CommonJS `require()`.
|
|
*/
|
|
REQUIRE: binding.REQUIRE,
|
|
/**
|
|
* ES module `import`.
|
|
*/
|
|
IMPORT: binding.IMPORT,
|
|
/**
|
|
* ES module `import()` if `IMPORT` is set.
|
|
*/
|
|
DYNAMIC: binding.DYNAMIC,
|
|
/**
|
|
* CommonJS `require.addon()` if `REQUIRE` is set, or ES module `import.meta.addon()` if `IMPORT` is set.
|
|
*/
|
|
ADDON: binding.ADDON,
|
|
/**
|
|
* CommonJS `require.asset()` if `REQUIRE` is set, or ES module `import.meta.asset()` if `IMPORT` is set.
|
|
*/
|
|
ASSET: binding.ASSET,
|
|
/**
|
|
* CommonJS `require.resolve()` or `require.addon.resolve()` if `REQUIRE` and optionally `ADDON` are set, or ES module
|
|
* `import.meta.resolve()` or `import.meta.addon.resolve()` if `IMPORT` and optionally `ADDON` are set.
|
|
*/
|
|
RESOLVE: binding.RESOLVE,
|
|
/**
|
|
* Re-export of a CommonJS `require()` if `REQUIRE` is set.
|
|
*/
|
|
REEXPORT: binding.REEXPORT
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-type-stripper/lib/binding/bare.js
|
|
var require_bare2 = __commonJS({
|
|
"../../node_modules/bare-type-stripper/lib/binding/bare.js"(exports, module) {
|
|
module.exports = __require.addon("../..");
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-type-stripper/index.js
|
|
var require_bare_type_stripper = __commonJS({
|
|
"../../node_modules/bare-type-stripper/index.js"(exports, module) {
|
|
var binding = require_bare2();
|
|
module.exports = exports = function strip(input, encoding, opts = {}) {
|
|
if (typeof encoding === "object" && encoding !== null) {
|
|
opts = encoding;
|
|
encoding = null;
|
|
}
|
|
if (typeof input !== "string" && !ArrayBuffer.isView(input)) {
|
|
throw new TypeError(`Input must be a string or buffer. Received type ${typeof input}`);
|
|
}
|
|
const buffer = typeof input === "string" ? Buffer.from(input, encoding) : input;
|
|
const ranges = binding.lex(buffer);
|
|
check(buffer, ranges);
|
|
return apply(buffer, ranges);
|
|
};
|
|
exports.lex = function lex(input, encoding, opts = {}) {
|
|
if (typeof encoding === "object" && encoding !== null) {
|
|
opts = encoding;
|
|
encoding = null;
|
|
}
|
|
if (typeof input !== "string" && !ArrayBuffer.isView(input)) {
|
|
throw new TypeError(`Input must be a string or buffer. Received type ${typeof input}`);
|
|
}
|
|
const ranges = binding.lex(typeof input === "string" ? Buffer.from(input, encoding) : input);
|
|
const result = [];
|
|
for (let r = 0; r < ranges.length; r += 3) {
|
|
const flags = ranges[r + 2];
|
|
result.push(flags ? [ranges[r], ranges[r + 1], flags] : [ranges[r], ranges[r + 1]]);
|
|
}
|
|
return result;
|
|
};
|
|
exports.constants = {
|
|
/**
|
|
* Range flag: The first byte of the stripped range becomes ';' instead of
|
|
* a space, so ASI can't fold the previous statement into whatever follows.
|
|
*/
|
|
SEMI: binding.SEMI,
|
|
/**
|
|
* Range flag: The first byte of the stripped range becomes ')' instead of
|
|
* a space. Used in tandem with a wider strip range to relocate the closing
|
|
* ')' of an arrow function's parameter list to the line where '=>' lives,
|
|
* when the (now stripped) return-type annotation spanned newlines.
|
|
*/
|
|
PAREN: binding.PAREN,
|
|
/**
|
|
* Range flag: The range marks non-erasable TypeScript syntax (enums,
|
|
* namespaces, parameter properties, angle casts) that cannot be stripped
|
|
* to valid JavaScript. strip() throws on these; lex() returns them so
|
|
* callers can implement their own handling.
|
|
*/
|
|
ERROR: binding.ERROR
|
|
};
|
|
function check(buffer, ranges) {
|
|
for (let r = 0; r < ranges.length; r += 3) {
|
|
if ((ranges[r + 2] & binding.ERROR) === 0) continue;
|
|
const start = ranges[r];
|
|
const end = ranges[r + 1];
|
|
let line = 1;
|
|
let column = 1;
|
|
for (let i = 0; i < start; i++) {
|
|
if (buffer[i] === 10) {
|
|
line++;
|
|
column = 1;
|
|
} else {
|
|
column++;
|
|
}
|
|
}
|
|
const source = Buffer.from(buffer.subarray(start, Math.min(end, start + 32))).toString();
|
|
throw new SyntaxError(
|
|
`Cannot strip non-erasable TypeScript syntax '${source}' at ${line}:${column}`
|
|
);
|
|
}
|
|
}
|
|
function apply(buffer, ranges) {
|
|
const out = Buffer.from(buffer);
|
|
for (let r = 0; r < ranges.length; r += 3) {
|
|
const s = ranges[r];
|
|
const e = ranges[r + 1];
|
|
const f = ranges[r + 2];
|
|
if (f & binding.ERROR) continue;
|
|
for (let i = s; i < e; i++) {
|
|
if (i === s) {
|
|
if (f & binding.SEMI) {
|
|
out[i] = 59;
|
|
continue;
|
|
}
|
|
if (f & binding.PAREN) {
|
|
out[i] = 41;
|
|
continue;
|
|
}
|
|
}
|
|
const c = out[i];
|
|
if (c === 10 || c === 13) continue;
|
|
out[i] = 32;
|
|
}
|
|
}
|
|
return out;
|
|
}
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-url/binding.js
|
|
var require_binding2 = __commonJS({
|
|
"../../node_modules/bare-url/binding.js"(exports, module) {
|
|
module.exports = __require.addon();
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-url/lib/errors.js
|
|
var require_errors3 = __commonJS({
|
|
"../../node_modules/bare-url/lib/errors.js"(exports, module) {
|
|
module.exports = class URLError extends Error {
|
|
constructor(msg, fn = URLError, code = fn.name) {
|
|
super(`${code}: ${msg}`);
|
|
this.code = code;
|
|
if (Error.captureStackTrace) Error.captureStackTrace(this, fn);
|
|
}
|
|
get name() {
|
|
return "URLError";
|
|
}
|
|
static INVALID_URL(msg, input) {
|
|
const err = new URLError(msg, URLError.INVALID_URL);
|
|
err.input = input;
|
|
return err;
|
|
}
|
|
static INVALID_URL_SCHEME(msg = "Invalid URL") {
|
|
return new URLError(msg, URLError.INVALID_URL_SCHEME);
|
|
}
|
|
static INVALID_FILE_URL_HOST(msg = "Invalid file: URL host") {
|
|
return new URLError(msg, URLError.INVALID_FILE_URL_HOST);
|
|
}
|
|
static INVALID_FILE_URL_PATH(msg = "Invalid file: URL path") {
|
|
return new URLError(msg, URLError.INVALID_FILE_URL_PATH);
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-url/lib/url-search-params.js
|
|
var require_url_search_params = __commonJS({
|
|
"../../node_modules/bare-url/lib/url-search-params.js"(exports, module) {
|
|
var kind = Symbol.for("bare.url.search-params.kind");
|
|
var URLSearchParams = class _URLSearchParams {
|
|
static _urls = /* @__PURE__ */ new WeakMap();
|
|
static get [kind]() {
|
|
return 0;
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
|
|
constructor(init, url = null) {
|
|
this._params = null;
|
|
if (url) _URLSearchParams._urls.set(this, url);
|
|
if (typeof init === "string") {
|
|
this._parse(init);
|
|
} else {
|
|
this._params = /* @__PURE__ */ new Map();
|
|
if (init) {
|
|
for (const [name, value] of typeof init[Symbol.iterator] === "function" ? init : Object.entries(init)) {
|
|
this.append(name, value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
get [kind]() {
|
|
return _URLSearchParams[kind];
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-size
|
|
get size() {
|
|
let size = 0;
|
|
for (const values of this._params.values()) size += values.length;
|
|
return size;
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-append
|
|
append(name, value = null) {
|
|
if (value === null) return;
|
|
let list = this._params.get(name);
|
|
if (list === void 0) {
|
|
list = [];
|
|
this._params.set(name, list);
|
|
}
|
|
list.push(value);
|
|
this._update();
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-delete
|
|
delete(name, value = null) {
|
|
if (value === null) this._params.delete(name);
|
|
else {
|
|
let list = this._params.get(name);
|
|
if (list === void 0) return;
|
|
list = list.filter((found) => found !== value);
|
|
if (list.length === 0) this._params.delete(name);
|
|
else this._params.set(name, list);
|
|
}
|
|
this._update();
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-get
|
|
get(name) {
|
|
const list = this._params.get(name);
|
|
if (list === void 0) return null;
|
|
return list[0];
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-getall
|
|
getAll(name) {
|
|
const list = this._params.get(name);
|
|
if (list === void 0) return [];
|
|
return Array.from(list);
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-has
|
|
has(name, value = null) {
|
|
const list = this._params.get(name);
|
|
if (list === void 0) return false;
|
|
if (value === null) return true;
|
|
return list.includes(value);
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-set
|
|
set(name, value = null) {
|
|
if (value === null) this._params.delete(name);
|
|
else this._params.set(name, [value]);
|
|
this._update();
|
|
}
|
|
toString() {
|
|
return this._serialize();
|
|
}
|
|
toJSON() {
|
|
return [...this];
|
|
}
|
|
*[Symbol.iterator]() {
|
|
for (const [name, values] of this._params) {
|
|
for (const value of values) yield [name, value];
|
|
}
|
|
}
|
|
[Symbol.for("bare.inspect")]() {
|
|
const object = {
|
|
__proto__: { constructor: _URLSearchParams }
|
|
};
|
|
for (const [name, values] of this._params) {
|
|
if (values.length === 1) object[name] = values[0];
|
|
else object[name] = values;
|
|
}
|
|
return object;
|
|
}
|
|
// https://url.spec.whatwg.org/#concept-urlsearchparams-update
|
|
_update() {
|
|
const url = _URLSearchParams._urls.get(this);
|
|
if (url === void 0) return;
|
|
url.search = this._serialize();
|
|
}
|
|
// https://url.spec.whatwg.org/#concept-urlencoded-parser
|
|
_parse(input) {
|
|
const params = /* @__PURE__ */ new Map();
|
|
this._params = params;
|
|
const len = input.length;
|
|
let start = input.charCodeAt(0) === 63 ? 1 : 0;
|
|
while (start < len) {
|
|
let end = input.indexOf("&", start);
|
|
if (end === -1) end = len;
|
|
if (end !== start) {
|
|
let split = input.indexOf("=", start);
|
|
if (split === -1 || split > end) split = end;
|
|
const name = decode(input.slice(start, split));
|
|
const value = split === end ? "" : decode(input.slice(split + 1, end));
|
|
const list = params.get(name);
|
|
if (list === void 0) params.set(name, [value]);
|
|
else list.push(value);
|
|
}
|
|
start = end + 1;
|
|
}
|
|
}
|
|
// https://url.spec.whatwg.org/#concept-urlencoded-serializer
|
|
_serialize() {
|
|
let result = "";
|
|
let separator = "";
|
|
for (const [name, values] of this._params) {
|
|
const encoded = encode(String(name));
|
|
for (const value of values) {
|
|
result += separator + encoded + "=" + encode(String(value));
|
|
separator = "&";
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
};
|
|
module.exports = exports = URLSearchParams;
|
|
exports.isURLSearchParams = function isURLSearchParams(value) {
|
|
if (value instanceof URLSearchParams) return true;
|
|
return typeof value === "object" && value !== null && value[kind] === URLSearchParams[kind];
|
|
};
|
|
var unencoded = /^[\w*.-]*$/;
|
|
var spaced = /^[\w*. -]*$/;
|
|
var extra = /[!'()~]/;
|
|
var extraAll = /[!'()~]/g;
|
|
var escapes = {
|
|
"!": "%21",
|
|
"'": "%27",
|
|
"(": "%28",
|
|
")": "%29",
|
|
"~": "%7E"
|
|
};
|
|
var lone = /[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/g;
|
|
function encode(component) {
|
|
if (unencoded.test(component)) return component;
|
|
if (spaced.test(component)) return component.replaceAll(" ", "+");
|
|
let encoded;
|
|
try {
|
|
encoded = encodeURIComponent(component);
|
|
} catch {
|
|
encoded = encodeURIComponent(component.replace(lone, "\uFFFD"));
|
|
}
|
|
if (encoded.includes("%20")) encoded = encoded.replaceAll("%20", "+");
|
|
if (extra.test(encoded)) encoded = encoded.replace(extraAll, (match) => escapes[match]);
|
|
return encoded;
|
|
}
|
|
function decode(component) {
|
|
if (component.indexOf("+") !== -1) component = component.replaceAll("+", " ");
|
|
if (component.indexOf("%") === -1) return component;
|
|
return decodeURIComponent(component);
|
|
}
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-url/index.js
|
|
var require_bare_url = __commonJS({
|
|
"../../node_modules/bare-url/index.js"(exports, module) {
|
|
var path = require_bare_path();
|
|
var binding = require_binding2();
|
|
var errors = require_errors3();
|
|
var URLSearchParams = require_url_search_params();
|
|
var kind = Symbol.for("bare.url.kind");
|
|
var isWindows = Bare.platform === "win32";
|
|
var components = new Uint32Array(8);
|
|
var unset = 4294967295;
|
|
var reserved = isWindows ? /[%#?\n\r\t]/ : /[%#?\n\r\t\\]/;
|
|
var URL2 = class _URL {
|
|
static get [kind]() {
|
|
return 0;
|
|
}
|
|
constructor(input, base, opts = {}) {
|
|
if (arguments.length === 0) throw errors.INVALID_URL();
|
|
input = String(input);
|
|
if (base !== void 0) base = String(base);
|
|
this._href = void 0;
|
|
this._schemeEnd = 0;
|
|
this._usernameEnd = 0;
|
|
this._hostStart = 0;
|
|
this._hostEnd = 0;
|
|
this._pathStart = 0;
|
|
this._queryStart = 0;
|
|
this._fragmentStart = 0;
|
|
this._params = null;
|
|
this._parse(input, base, opts.throw !== false);
|
|
}
|
|
get [kind]() {
|
|
return _URL[kind];
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-href
|
|
get href() {
|
|
return this._href;
|
|
}
|
|
set href(value) {
|
|
this._update(value);
|
|
if (this._params) this._params._parse(this.search);
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-protocol
|
|
get protocol() {
|
|
return this._slice(0, this._schemeEnd) + ":";
|
|
}
|
|
set protocol(value) {
|
|
this._update(this._replace(value.replace(/:+$/, ""), 0, this._schemeEnd));
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-username
|
|
get username() {
|
|
return this._slice(this._schemeEnd + 3, this._usernameEnd);
|
|
}
|
|
set username(value) {
|
|
if (cannotHaveCredentialsOrPort(this)) {
|
|
return;
|
|
}
|
|
if (this.username === "") value += "@";
|
|
this._update(this._replace(value, this._schemeEnd + 3, this._usernameEnd));
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-password
|
|
get password() {
|
|
return this._href.slice(
|
|
this._usernameEnd + 1,
|
|
this._hostStart - 1
|
|
/* @ */
|
|
);
|
|
}
|
|
set password(value) {
|
|
if (cannotHaveCredentialsOrPort(this)) {
|
|
return;
|
|
}
|
|
let start = this._usernameEnd + 1;
|
|
let end = this._hostStart - 1;
|
|
if (this.password === "") {
|
|
value = ":" + value;
|
|
start--;
|
|
}
|
|
if (this.username === "") {
|
|
value += "@";
|
|
end++;
|
|
}
|
|
this._update(this._replace(value, start, end));
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-host
|
|
get host() {
|
|
return this._slice(this._hostStart, this._pathStart);
|
|
}
|
|
set host(value) {
|
|
if (hasOpaquePath(this)) {
|
|
return;
|
|
}
|
|
this._update(
|
|
this._replace(value, this._hostStart, value.includes(":") ? this._pathStart : this._hostEnd)
|
|
);
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-hostname
|
|
get hostname() {
|
|
return this._slice(this._hostStart, this._hostEnd);
|
|
}
|
|
set hostname(value) {
|
|
if (hasOpaquePath(this)) {
|
|
return;
|
|
}
|
|
this._update(this._replace(value, this._hostStart, this._hostEnd));
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-port
|
|
get port() {
|
|
return this._slice(this._hostEnd + 1, this._pathStart);
|
|
}
|
|
set port(value) {
|
|
if (cannotHaveCredentialsOrPort(this)) {
|
|
return;
|
|
}
|
|
let start = this._hostEnd + 1;
|
|
if (this.port === "") {
|
|
value = ":" + value;
|
|
start--;
|
|
}
|
|
this._update(this._replace(value, start, this._pathStart));
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-pathname
|
|
get pathname() {
|
|
return this._slice(
|
|
this._pathStart,
|
|
this._queryStart - 1
|
|
/* ? */
|
|
);
|
|
}
|
|
set pathname(value) {
|
|
if (hasOpaquePath(this)) {
|
|
return;
|
|
}
|
|
if (value[0] !== "/" && value[0] !== "\\") {
|
|
value = "/" + value;
|
|
}
|
|
this._update(this._replace(
|
|
value,
|
|
this._pathStart,
|
|
this._queryStart - 1
|
|
/* ? */
|
|
));
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-search
|
|
get search() {
|
|
return this._slice(
|
|
this._queryStart - 1,
|
|
this._fragmentStart - 1
|
|
/* # */
|
|
);
|
|
}
|
|
set search(value) {
|
|
if (value && value[0] !== "?") value = "?" + value;
|
|
this._update(
|
|
this._replace(
|
|
value,
|
|
this._queryStart - 1,
|
|
this._fragmentStart - 1
|
|
/* # */
|
|
)
|
|
);
|
|
if (this._params) this._params._parse(this.search);
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-searchparams
|
|
get searchParams() {
|
|
if (this._params === null) {
|
|
this._params = new URLSearchParams(this.search, this);
|
|
}
|
|
return this._params;
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-hash
|
|
get hash() {
|
|
return this._slice(
|
|
this._fragmentStart - 1
|
|
/* # */
|
|
);
|
|
}
|
|
set hash(value) {
|
|
if (value && value[0] !== "#") value = "#" + value;
|
|
this._update(this._replace(
|
|
value,
|
|
this._fragmentStart - 1
|
|
/* # */
|
|
));
|
|
}
|
|
toString() {
|
|
return this._href;
|
|
}
|
|
toJSON() {
|
|
return this._href;
|
|
}
|
|
[Symbol.for("bare.inspect")]() {
|
|
return {
|
|
__proto__: { constructor: _URL },
|
|
href: this.href,
|
|
protocol: this.protocol,
|
|
username: this.username,
|
|
password: this.password,
|
|
host: this.host,
|
|
hostname: this.hostname,
|
|
port: this.port,
|
|
pathname: this.pathname,
|
|
search: this.search,
|
|
searchParams: this.searchParams,
|
|
hash: this.hash
|
|
};
|
|
}
|
|
_slice(start, end = this._href.length) {
|
|
return this._href.slice(start, end);
|
|
}
|
|
_replace(replacement, start, end = this._href.length) {
|
|
return this._slice(0, start) + replacement + this._slice(end);
|
|
}
|
|
_parse(input, base, shouldThrow) {
|
|
let href;
|
|
try {
|
|
href = binding.parse(input, base || null, components, shouldThrow);
|
|
} catch (err) {
|
|
if (err instanceof TypeError) throw err;
|
|
throw errors.INVALID_URL(`Invalid URL '${input}'`, input);
|
|
}
|
|
if (href === void 0) return;
|
|
this._href = href;
|
|
this._schemeEnd = components[0];
|
|
this._usernameEnd = components[1];
|
|
this._hostStart = components[2];
|
|
this._hostEnd = components[3];
|
|
this._pathStart = components[5];
|
|
const queryStart = components[6];
|
|
const fragmentStart = components[7];
|
|
const end = href.length + 1;
|
|
this._queryStart = queryStart === unset ? end : queryStart;
|
|
this._fragmentStart = fragmentStart === unset ? end : fragmentStart;
|
|
}
|
|
_update(input) {
|
|
try {
|
|
this._parse(input, null, true);
|
|
} catch (err) {
|
|
if (err instanceof TypeError) throw err;
|
|
}
|
|
}
|
|
};
|
|
module.exports = exports = URL2;
|
|
function hasOpaquePath(url) {
|
|
return url.pathname[0] !== "/";
|
|
}
|
|
function cannotHaveCredentialsOrPort(url) {
|
|
return url.hostname === "" || url.protocol === "file:";
|
|
}
|
|
exports.URL = URL2;
|
|
exports.URLSearchParams = URLSearchParams;
|
|
exports.errors = errors;
|
|
exports.isURL = function isURL(value) {
|
|
if (value instanceof URL2) return true;
|
|
return typeof value === "object" && value !== null && value[kind] === URL2[kind];
|
|
};
|
|
exports.isURLSearchParams = URLSearchParams.isURLSearchParams;
|
|
exports.parse = function parse(input, base) {
|
|
const url = new URL2(input, base, { throw: false });
|
|
return url._href ? url : null;
|
|
};
|
|
exports.canParse = function canParse(input, base) {
|
|
return binding.canParse(String(input), base ? String(base) : null);
|
|
};
|
|
exports.fileURLToPath = function fileURLToPath(url) {
|
|
if (typeof url === "string") {
|
|
url = new URL2(url);
|
|
}
|
|
if (url.protocol !== "file:") {
|
|
throw errors.INVALID_URL_SCHEME("The URL must use the file: protocol");
|
|
}
|
|
if (!isWindows && url.hostname) {
|
|
throw errors.INVALID_FILE_URL_HOST("The file: URL host must be 'localhost' or empty");
|
|
}
|
|
const encoded = url.pathname;
|
|
const hasEncoded = encoded.includes("%");
|
|
if (hasEncoded) {
|
|
if (isWindows) {
|
|
if (/%2f|%5c/i.test(encoded)) {
|
|
throw errors.INVALID_FILE_URL_PATH(
|
|
"The file: URL path must not include encoded \\ or / characters"
|
|
);
|
|
}
|
|
} else if (/%2f/i.test(encoded)) {
|
|
throw errors.INVALID_FILE_URL_PATH("The file: URL path must not include encoded / characters");
|
|
}
|
|
if (/%00/i.test(encoded)) {
|
|
throw errors.INVALID_FILE_URL_PATH(
|
|
"The file: URL path must not include encoded NUL characters"
|
|
);
|
|
}
|
|
}
|
|
const pathname = path.normalize(hasEncoded ? decodeURIComponent(encoded) : encoded);
|
|
if (isWindows) {
|
|
if (url.hostname) return "\\\\" + url.hostname + pathname;
|
|
const letter = pathname.charCodeAt(1) | 32;
|
|
if (letter < 97 || letter > 122 || pathname.charCodeAt(2) !== 58) {
|
|
throw errors.INVALID_FILE_URL_PATH("The file: URL path must be absolute");
|
|
}
|
|
return pathname.slice(1);
|
|
}
|
|
return pathname;
|
|
};
|
|
exports.pathToFileURL = function pathToFileURL(pathname) {
|
|
let resolved = path.resolve(pathname);
|
|
if (pathname[pathname.length - 1] === "/") {
|
|
resolved += "/";
|
|
} else if (isWindows && pathname[pathname.length - 1] === "\\") {
|
|
resolved += "\\";
|
|
}
|
|
if (reserved.test(resolved)) {
|
|
resolved = resolved.replaceAll("%", "%25").replaceAll("#", "%23").replaceAll("?", "%3f").replaceAll("\n", "%0a").replaceAll("\r", "%0d").replaceAll(" ", "%09");
|
|
if (!isWindows) {
|
|
resolved = resolved.replaceAll("\\", "%5c");
|
|
}
|
|
}
|
|
return new URL2("file:" + resolved);
|
|
};
|
|
exports.format = function format(parts) {
|
|
const { protocol, auth, host, hostname, port, pathname, search, query, hash, slashes } = parts;
|
|
let result = "";
|
|
if (typeof protocol === "string") {
|
|
result += protocol;
|
|
if (protocol[protocol.length - 1] !== ":") {
|
|
result += ":";
|
|
}
|
|
if (slashes === true || /https?|ftp|gopher|file/.test(protocol)) {
|
|
result += "//";
|
|
}
|
|
}
|
|
if (typeof auth === "string") {
|
|
if (host || hostname) result += auth + "@";
|
|
}
|
|
if (typeof host === "string") result += host;
|
|
else {
|
|
result += hostname;
|
|
if (port) result += ":" + port;
|
|
}
|
|
if (typeof pathname === "string" && pathname !== "") {
|
|
if (pathname[0] !== "/") result += "/";
|
|
result += pathname;
|
|
}
|
|
if (typeof search === "string") {
|
|
if (search[0] !== "?") result += "?";
|
|
result += search;
|
|
} else if (typeof query === "object" && query !== null) {
|
|
result += "?" + new URLSearchParams(query);
|
|
}
|
|
if (typeof hash === "string") {
|
|
if (hash[0] !== "#") result += "#";
|
|
result += hash;
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-bundle/lib/errors.js
|
|
var require_errors4 = __commonJS({
|
|
"../../node_modules/bare-bundle/lib/errors.js"(exports, module) {
|
|
module.exports = class BundleError extends Error {
|
|
constructor(msg, fn = BundleError, opts = {}) {
|
|
const { cause, code = fn.name } = opts;
|
|
super(`${code}: ${msg}`, { cause });
|
|
this.code = code;
|
|
if (Error.captureStackTrace) {
|
|
Error.captureStackTrace(this, fn);
|
|
}
|
|
}
|
|
get name() {
|
|
return "BundleError";
|
|
}
|
|
static INVALID_BUNDLE_HEADER(msg, cause) {
|
|
return new BundleError(msg, BundleError.INVALID_BUNDLE_HEADER, { cause });
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-bundle/index.js
|
|
var require_bare_bundle = __commonJS({
|
|
"../../node_modules/bare-bundle/index.js"(exports, module) {
|
|
var errors = require_errors4();
|
|
var kind = Symbol.for("bare.bundle.kind");
|
|
var MemoryFile = class _MemoryFile {
|
|
constructor(data, opts = {}) {
|
|
const { executable = false, mode = executable ? 493 : 420 } = opts;
|
|
this._data = typeof data === "string" ? Buffer.from(data) : data;
|
|
this._mode = mode;
|
|
}
|
|
size() {
|
|
return this._data.byteLength;
|
|
}
|
|
mode() {
|
|
return this._mode;
|
|
}
|
|
read() {
|
|
return this._data;
|
|
}
|
|
inspect() {
|
|
return {
|
|
__proto__: { constructor: _MemoryFile },
|
|
data: this._data,
|
|
mode: this._mode.toString(8)
|
|
};
|
|
}
|
|
[Symbol.for("bare.inspect")]() {
|
|
return this.inspect();
|
|
}
|
|
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
return this.inspect();
|
|
}
|
|
};
|
|
module.exports = exports = class Bundle2 {
|
|
static get [kind]() {
|
|
return 0;
|
|
}
|
|
static get version() {
|
|
return 0;
|
|
}
|
|
constructor(opts = {}) {
|
|
const { File = MemoryFile } = opts;
|
|
this._File = File;
|
|
this._id = null;
|
|
this._main = null;
|
|
this._imports = {};
|
|
this._resolutions = {};
|
|
this._addons = [];
|
|
this._assets = [];
|
|
this._files = /* @__PURE__ */ new Map();
|
|
}
|
|
get [kind]() {
|
|
return Bundle2[kind];
|
|
}
|
|
get version() {
|
|
return Bundle2.version;
|
|
}
|
|
get id() {
|
|
return this._id;
|
|
}
|
|
set id(value) {
|
|
if (typeof value !== "string" && value !== null) {
|
|
throw new TypeError(`ID must be a string or null. Received type ${typeof value} (${value})`);
|
|
}
|
|
this._id = value;
|
|
}
|
|
get main() {
|
|
return this._main;
|
|
}
|
|
set main(value) {
|
|
if (typeof value !== "string" && value !== null) {
|
|
throw new TypeError(`Main must be a string or null. Received type ${typeof value} (${value})`);
|
|
}
|
|
this._main = value;
|
|
}
|
|
get imports() {
|
|
return this._imports;
|
|
}
|
|
set imports(value) {
|
|
this._imports = cloneImportsMap(value);
|
|
}
|
|
get resolutions() {
|
|
return this._resolutions;
|
|
}
|
|
set resolutions(value) {
|
|
this._resolutions = cloneResolutionsMap(value);
|
|
}
|
|
get addons() {
|
|
return this._addons;
|
|
}
|
|
set addons(value) {
|
|
this._addons = cloneFilesList(value, "Addons");
|
|
}
|
|
get assets() {
|
|
return this._assets;
|
|
}
|
|
set assets(value) {
|
|
this._assets = cloneFilesList(value, "Assets");
|
|
}
|
|
get files() {
|
|
return Object.fromEntries(this._files.entries());
|
|
}
|
|
*[Symbol.iterator]() {
|
|
for (const [key, file] of this._files) {
|
|
yield [key, file.read(), file.mode()];
|
|
}
|
|
}
|
|
empty() {
|
|
return this._files.size === 0;
|
|
}
|
|
keys() {
|
|
return this._files.keys();
|
|
}
|
|
exists(key) {
|
|
return this._files.has(key);
|
|
}
|
|
size(key) {
|
|
const file = this._files.get(key) || null;
|
|
if (file === null) return 0;
|
|
return file.size();
|
|
}
|
|
mode(key) {
|
|
const file = this._files.get(key) || null;
|
|
if (file === null) return 0;
|
|
return file.mode();
|
|
}
|
|
read(key) {
|
|
const file = this._files.get(key) || null;
|
|
if (file === null) return null;
|
|
return file.read();
|
|
}
|
|
write(key, data, opts = {}) {
|
|
if (typeof key !== "string") {
|
|
throw new TypeError(`File path must be a string. Received type ${typeof key} (${key})`);
|
|
}
|
|
const { main = false, alias = null, imports = null, addon = false, asset = false } = opts;
|
|
this._files.set(key, new MemoryFile(data, opts));
|
|
if (main) this._main = key;
|
|
if (alias) this._imports[alias] = key;
|
|
if (imports) this._resolutions[key] = cloneImportsMap(imports);
|
|
if (addon) this._addons.push(key);
|
|
if (asset) this._assets.push(key);
|
|
return this;
|
|
}
|
|
mount(root, opts = {}) {
|
|
const bundle = new Bundle2();
|
|
bundle._File = this._File;
|
|
bundle._id = this._id;
|
|
if (this._main) bundle._main = mountSpecifier(this._main, root);
|
|
bundle._imports = transformImportsMap(this._imports, root, null, opts, mountSpecifier);
|
|
bundle._resolutions = transformResolutionsMap(this._resolutions, root, opts, mountSpecifier);
|
|
for (const [key, file] of this._files) {
|
|
bundle._files.set(mountSpecifier(key, root), file);
|
|
}
|
|
bundle._addons = transformFilesList(this._addons, root, mountSpecifier);
|
|
bundle._assets = transformFilesList(this._assets, root, mountSpecifier);
|
|
return bundle;
|
|
}
|
|
unmount(root, opts = {}) {
|
|
const bundle = new Bundle2();
|
|
bundle._File = this._File;
|
|
bundle._id = this._id;
|
|
if (this._main) bundle._main = unmountSpecifier(this._main, root);
|
|
bundle._imports = transformImportsMap(this._imports, root, null, opts, unmountSpecifier);
|
|
bundle._resolutions = transformResolutionsMap(this._resolutions, root, opts, unmountSpecifier);
|
|
for (const [key, file] of this._files) {
|
|
bundle._files.set(unmountSpecifier(key, root), file);
|
|
}
|
|
bundle._addons = transformFilesList(this._addons, root, unmountSpecifier);
|
|
bundle._assets = transformFilesList(this._assets, root, unmountSpecifier);
|
|
return bundle;
|
|
}
|
|
toBuffer(opts = {}) {
|
|
const { indent = 0, shared = false } = opts;
|
|
const header = {
|
|
version: Bundle2.version,
|
|
id: this._id,
|
|
main: this._main,
|
|
imports: cloneImportsMap(this._imports),
|
|
resolutions: cloneResolutionsMap(this._resolutions),
|
|
addons: cloneFilesList(this._addons, "Addons"),
|
|
assets: cloneFilesList(this._assets, "Assets"),
|
|
files: {}
|
|
};
|
|
const keys = [...this._files.keys()].sort();
|
|
let offset = 0;
|
|
for (const key of keys) {
|
|
const length2 = this.size(key);
|
|
header.files[key] = { offset, length: length2, mode: this.mode(key) };
|
|
offset += length2;
|
|
}
|
|
const json = Buffer.from(`
|
|
${JSON.stringify(header, null, indent)}
|
|
`);
|
|
const length = Buffer.from(json.byteLength.toString(10));
|
|
const total = length.byteLength + json.byteLength + offset;
|
|
const storage = shared ? new SharedArrayBuffer(total) : new ArrayBuffer(total);
|
|
const buffer = Buffer.from(storage);
|
|
offset = 0;
|
|
buffer.set(length, offset);
|
|
offset += length.byteLength;
|
|
buffer.set(json, offset);
|
|
offset += json.byteLength;
|
|
for (const key of keys) {
|
|
buffer.set(this.read(key), offset);
|
|
offset += this.size(key);
|
|
}
|
|
return buffer;
|
|
}
|
|
inspect() {
|
|
return {
|
|
__proto__: { constructor: Bundle2 },
|
|
version: this.version,
|
|
id: this.id,
|
|
main: this.main,
|
|
imports: this.imports,
|
|
resolutions: this.resolutions,
|
|
addons: this.addons,
|
|
assets: this.assets,
|
|
files: this.files
|
|
};
|
|
}
|
|
[Symbol.for("bare.inspect")]() {
|
|
return this.inspect();
|
|
}
|
|
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
return this.inspect();
|
|
}
|
|
};
|
|
var Bundle = exports;
|
|
exports.errors = errors;
|
|
exports.isBundle = function isBundle(value) {
|
|
if (value instanceof Bundle) return true;
|
|
return typeof value === "object" && value !== null && value[kind] === Bundle[kind];
|
|
};
|
|
exports.from = function from(value) {
|
|
if (typeof value === "string") return fromString(value);
|
|
if (Buffer.isBuffer(value)) return fromBuffer(value);
|
|
return value;
|
|
};
|
|
function fromString(string) {
|
|
return fromBuffer(Buffer.from(string));
|
|
}
|
|
function fromBuffer(buffer) {
|
|
if (buffer[0] === 35 && buffer[1] === 33) {
|
|
let end2 = 2;
|
|
while (buffer[end2] !== 10) end2++;
|
|
buffer = buffer.subarray(end2 + 1);
|
|
}
|
|
let end = 0;
|
|
while (isDecimal(buffer[end])) end++;
|
|
const len = parseInt(buffer.toString("utf8", 0, end), 10);
|
|
let header;
|
|
try {
|
|
header = JSON.parse(buffer.toString("utf8", end, end + len));
|
|
} catch (err) {
|
|
throw errors.INVALID_BUNDLE_HEADER("Invalid bundle header", err);
|
|
}
|
|
const bundle = new Bundle();
|
|
if (header.id) bundle.id = header.id;
|
|
if (header.main) bundle.main = header.main;
|
|
if (header.imports) bundle.imports = header.imports;
|
|
if (header.resolutions) bundle.resolutions = header.resolutions;
|
|
if (header.addons) bundle.addons = header.addons;
|
|
if (header.assets) bundle.assets = header.assets;
|
|
let offset = end + len;
|
|
for (const [file, info] of Object.entries(header.files)) {
|
|
bundle.write(file, buffer.subarray(offset, offset + info.length), {
|
|
mode: info.mode || 420
|
|
});
|
|
offset += info.length;
|
|
}
|
|
return bundle;
|
|
}
|
|
function isDecimal(c) {
|
|
return c >= 48 && c <= 57;
|
|
}
|
|
function compareKeys([a], [b]) {
|
|
return a > b ? 1 : a < b ? -1 : 0;
|
|
}
|
|
function cloneImportsMap(value) {
|
|
if (typeof value === "object" && value !== null) {
|
|
const imports = {};
|
|
for (const entry of Object.entries(value).sort(compareKeys)) {
|
|
imports[entry[0]] = cloneImportsMapEntry(entry[1]);
|
|
}
|
|
return imports;
|
|
}
|
|
throw new TypeError(`Imports map must be an object. Received type ${typeof value} (${value})`);
|
|
}
|
|
function cloneImportsMapEntry(value) {
|
|
if (typeof value === "string") return value;
|
|
if (typeof value === "object" && value !== null) {
|
|
const imports = {};
|
|
for (const entry of Object.entries(value)) {
|
|
imports[entry[0]] = cloneImportsMapEntry(entry[1]);
|
|
}
|
|
return imports;
|
|
}
|
|
throw new TypeError(
|
|
`Imports map entry must be a string or object. Received type ${typeof value} (${value})`
|
|
);
|
|
}
|
|
function cloneResolutionsMap(value) {
|
|
if (typeof value === "object" && value !== null) {
|
|
const resolutions = {};
|
|
for (const entry of Object.entries(value).sort(compareKeys)) {
|
|
resolutions[entry[0]] = cloneImportsMap(entry[1]);
|
|
}
|
|
return resolutions;
|
|
}
|
|
throw new TypeError(`Resolutions map must be an object. Received type ${typeof value} (${value})`);
|
|
}
|
|
function cloneFilesList(value, name) {
|
|
if (Array.isArray(value)) {
|
|
const files = [];
|
|
for (const entry of value) {
|
|
if (typeof entry !== "string") {
|
|
throw new TypeError(
|
|
`${name} entry must be a string. Received type ${typeof entry} (${entry})`
|
|
);
|
|
}
|
|
files.push(entry);
|
|
}
|
|
return files.sort();
|
|
}
|
|
throw new TypeError(`${name} list must be an array. Received type ${typeof value} (${value})`);
|
|
}
|
|
function transformImportsMap(value, root, conditionalRoot, opts, fn) {
|
|
const { conditions = {} } = opts;
|
|
const imports = {};
|
|
for (const entry of Object.entries(value)) {
|
|
const condition = entry[0];
|
|
imports[condition] = transformImportsMapEntry(
|
|
entry[1],
|
|
root,
|
|
conditionalRoot || conditions[condition],
|
|
opts,
|
|
fn
|
|
);
|
|
}
|
|
return imports;
|
|
}
|
|
function transformImportsMapEntry(value, root, conditionalRoot, opts, fn) {
|
|
const { conditions = {} } = opts;
|
|
if (typeof value === "string") {
|
|
return fn(value, conditionalRoot || conditions.default || root);
|
|
}
|
|
return transformImportsMap(value, root, conditionalRoot, opts, fn);
|
|
}
|
|
function transformResolutionsMap(value, root, opts, fn) {
|
|
const resolutions = {};
|
|
for (const entry of Object.entries(value)) {
|
|
resolutions[fn(entry[0], root)] = transformImportsMap(entry[1], root, null, opts, fn);
|
|
}
|
|
return resolutions;
|
|
}
|
|
function transformFilesList(value, root, fn) {
|
|
const files = [];
|
|
for (const entry of value) {
|
|
files.push(fn(entry, root));
|
|
}
|
|
return files;
|
|
}
|
|
function mountSpecifier(specifier, root) {
|
|
if (startsWithWindowsDriveLetter(specifier)) {
|
|
specifier = "/" + specifier;
|
|
}
|
|
if (specifier[0] === "/" || specifier[0] === "\\") {
|
|
specifier = "." + specifier;
|
|
}
|
|
if (specifier.startsWith("./") || specifier.startsWith(".\\")) {
|
|
return new URL(specifier, root).href;
|
|
}
|
|
return specifier;
|
|
}
|
|
function unmountSpecifier(specifier, root) {
|
|
specifier = new URL(specifier);
|
|
if (typeof root === "string") root = new URL(root);
|
|
if (specifier.protocol !== root.protocol || specifier.host !== root.host || specifier.port !== root.port) {
|
|
return specifier.href;
|
|
}
|
|
const specifierPath = splitPath(specifier.pathname);
|
|
const rootPath = splitPath(root.pathname);
|
|
while (specifierPath.length > 0 && rootPath[0] === specifierPath[0]) {
|
|
specifierPath.shift();
|
|
rootPath.shift();
|
|
}
|
|
rootPath.fill("..");
|
|
return "/" + rootPath.concat(specifierPath).join("/");
|
|
}
|
|
function splitPath(path) {
|
|
const parts = path.split("/");
|
|
if (!parts[0]) parts.shift();
|
|
if (!parts[parts.length - 1]) parts.pop();
|
|
return parts;
|
|
}
|
|
function isASCIIUpperAlpha(c) {
|
|
return c >= 65 && c <= 90;
|
|
}
|
|
function isASCIILowerAlpha(c) {
|
|
return c >= 97 && c <= 122;
|
|
}
|
|
function isASCIIAlpha(c) {
|
|
return isASCIIUpperAlpha(c) || isASCIILowerAlpha(c);
|
|
}
|
|
function isWindowsDriveLetter(input) {
|
|
return input.length >= 2 && isASCIIAlpha(input.charCodeAt(0)) && (input.charCodeAt(1) === 58 || input.charCodeAt(1) === 124);
|
|
}
|
|
function startsWithWindowsDriveLetter(input) {
|
|
return input.length >= 2 && isWindowsDriveLetter(input) && (input.length === 2 || input.charCodeAt(2) === 47 || input.charCodeAt(2) === 92 || input.charCodeAt(2) === 63 || input.charCodeAt(2) === 35);
|
|
}
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-module/lib/protocol.js
|
|
var require_protocol = __commonJS({
|
|
"../../node_modules/bare-module/lib/protocol.js"(exports, module) {
|
|
module.exports = class ModuleProtocol {
|
|
constructor(methods = {}, context = null) {
|
|
for (const name of [
|
|
"preresolve",
|
|
"postresolve",
|
|
"resolve",
|
|
"exists",
|
|
"read",
|
|
"addon",
|
|
"asset"
|
|
]) {
|
|
const method = methods[name];
|
|
if (typeof method === "function") {
|
|
this[name] = context ? method.bind(this, context) : method.bind(this);
|
|
} else if (context) {
|
|
const method2 = context[name];
|
|
if (typeof method2 === "function") {
|
|
this[name] = method2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
preresolve(specifier, parentURL) {
|
|
return specifier;
|
|
}
|
|
postresolve(url) {
|
|
return url;
|
|
}
|
|
*resolve(specifier, parentURL, imports) {
|
|
}
|
|
exists(url, type) {
|
|
return false;
|
|
}
|
|
read(url) {
|
|
return null;
|
|
}
|
|
addon(url) {
|
|
return url;
|
|
}
|
|
asset(url) {
|
|
return url;
|
|
}
|
|
extend(methods) {
|
|
return new ModuleProtocol(methods, this);
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-module/lib/constants.js
|
|
var require_constants3 = __commonJS({
|
|
"../../node_modules/bare-module/lib/constants.js"(exports, module) {
|
|
module.exports = {
|
|
states: {
|
|
EVALUATED: 1,
|
|
SYNTHESIZED: 2,
|
|
RUN: 4
|
|
},
|
|
types: {
|
|
SCRIPT: 1,
|
|
MODULE: 2,
|
|
JSON: 3,
|
|
BUNDLE: 4,
|
|
ADDON: 5,
|
|
BINARY: 6,
|
|
TEXT: 7,
|
|
ASSET: 8
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-module/lib/errors.js
|
|
var require_errors5 = __commonJS({
|
|
"../../node_modules/bare-module/lib/errors.js"(exports, module) {
|
|
module.exports = class ModuleError extends Error {
|
|
constructor(msg, fn = ModuleError, code = fn.name) {
|
|
super(`${code}: ${msg}`);
|
|
this.code = code;
|
|
if (Error.captureStackTrace) {
|
|
Error.captureStackTrace(this, fn);
|
|
}
|
|
}
|
|
get name() {
|
|
return "ModuleError";
|
|
}
|
|
static MODULE_NOT_FOUND(msg, specifier, referrer = null, candidates = []) {
|
|
const err = new ModuleError(msg, ModuleError.MODULE_NOT_FOUND);
|
|
err.specifier = specifier;
|
|
err.referrer = referrer;
|
|
err.candidates = candidates;
|
|
return err;
|
|
}
|
|
static ASSET_NOT_FOUND(msg, specifier, referrer = null, candidates = []) {
|
|
const err = new ModuleError(msg, ModuleError.ASSET_NOT_FOUND);
|
|
err.specifier = specifier;
|
|
err.referrer = referrer;
|
|
err.candidates = candidates;
|
|
return err;
|
|
}
|
|
static UNKNOWN_PROTOCOL(msg) {
|
|
return new ModuleError(msg, ModuleError.UNKNOWN_PROTOCOL);
|
|
}
|
|
static INVALID_BUNDLE_EXTENSION(msg) {
|
|
return new ModuleError(msg, ModuleError.INVALID_BUNDLE_EXTENSION);
|
|
}
|
|
static INVALID_URL_PATH(msg) {
|
|
return new ModuleError(msg, ModuleError.INVALID_URL_PATH);
|
|
}
|
|
static INVALID_IMPORTS_MAP(msg) {
|
|
return new ModuleError(msg, ModuleError.INVALID_IMPORTS_MAP);
|
|
}
|
|
static TYPE_INCOMPATIBLE(msg) {
|
|
return new ModuleError(msg, ModuleError.TYPE_INCOMPATIBLE);
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-module/binding.js
|
|
var require_binding3 = __commonJS({
|
|
"../../node_modules/bare-module/binding.js"(exports, module) {
|
|
module.exports = __require.addon();
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-module/index.js
|
|
var require_bare_module = __commonJS({
|
|
"../../node_modules/bare-module/index.js"(exports, module) {
|
|
var path = require_bare_path();
|
|
var resolve = require_bare_module_resolve();
|
|
var lex = require_bare_module_lexer();
|
|
var strip = require_bare_type_stripper();
|
|
var { isURL, fileURLToPath, pathToFileURL } = require_bare_url();
|
|
var Bundle = require_bare_bundle();
|
|
var Protocol = require_protocol();
|
|
var constants = require_constants3();
|
|
var errors = require_errors5();
|
|
var binding = require_binding3();
|
|
var kind = Symbol.for("bare.module.kind");
|
|
var isWindows = Bare.platform === "win32";
|
|
var { startsWithWindowsDriveLetter } = resolve;
|
|
module.exports = exports = class Module2 {
|
|
static get [kind]() {
|
|
return 1;
|
|
}
|
|
constructor(url) {
|
|
this._url = url;
|
|
this._state = 0;
|
|
this._type = 0;
|
|
this._defaultType = 0;
|
|
this._main = null;
|
|
this._exports = null;
|
|
this._imports = null;
|
|
this._resolutions = null;
|
|
this._builtins = null;
|
|
this._conditions = null;
|
|
this._protocol = null;
|
|
this._cache = null;
|
|
this._source = null;
|
|
this._function = null;
|
|
this._names = null;
|
|
this._promise = null;
|
|
this._handle = null;
|
|
Object.preventExtensions(this);
|
|
}
|
|
get [kind]() {
|
|
return Module2[kind];
|
|
}
|
|
get url() {
|
|
return this._url;
|
|
}
|
|
get type() {
|
|
return this._type;
|
|
}
|
|
get defaultType() {
|
|
return this._defaultType;
|
|
}
|
|
get main() {
|
|
return this._main;
|
|
}
|
|
get exports() {
|
|
return this._exports;
|
|
}
|
|
set exports(value) {
|
|
this._exports = value;
|
|
}
|
|
get imports() {
|
|
return this._imports;
|
|
}
|
|
get resolutions() {
|
|
return this._resolutions;
|
|
}
|
|
get builtins() {
|
|
return this._builtins;
|
|
}
|
|
get conditions() {
|
|
return Array.from(this._conditions);
|
|
}
|
|
get protocol() {
|
|
return this._protocol;
|
|
}
|
|
get cache() {
|
|
return this._cache;
|
|
}
|
|
// For Node.js compatibility
|
|
get filename() {
|
|
return urlToPath(this._url);
|
|
}
|
|
// For Node.js compatibility
|
|
get dirname() {
|
|
return urlToDirname(this._url);
|
|
}
|
|
// For Node.js compatibility
|
|
get id() {
|
|
return this.filename;
|
|
}
|
|
// For Node.js compatibility
|
|
get path() {
|
|
return this.dirname;
|
|
}
|
|
_transform(isImport, isDynamicImport) {
|
|
if (isDynamicImport) {
|
|
this._run();
|
|
} else if (isImport) {
|
|
this._synthesize();
|
|
} else {
|
|
this._evaluate();
|
|
}
|
|
return this;
|
|
}
|
|
_synthesize() {
|
|
if ((this._state & constants.states.SYNTHESIZED) !== 0) return;
|
|
this._state |= constants.states.SYNTHESIZED;
|
|
if (this._type === constants.types.MODULE) return;
|
|
const names = /* @__PURE__ */ new Set(["default"]);
|
|
const queue = [this];
|
|
const seen = /* @__PURE__ */ new Set();
|
|
while (queue.length) {
|
|
const module2 = queue.pop();
|
|
if (seen.has(module2)) continue;
|
|
seen.add(module2);
|
|
switch (module2._type) {
|
|
case constants.types.SCRIPT: {
|
|
const result = lex(module2._source);
|
|
for (const { name } of result.exports) names.add(name);
|
|
const referrer = module2;
|
|
for (const { specifier, type } of result.imports) {
|
|
if ((type & lex.constants.REEXPORT) !== 0 && (type & lex.constants.ADDON) === 0 && (type & lex.constants.ASSET) === 0) {
|
|
const resolved = Module2.resolve(specifier, referrer._url, {
|
|
isImport: true,
|
|
referrer
|
|
});
|
|
const module3 = Module2.load(resolved, {
|
|
isImport: true,
|
|
referrer
|
|
});
|
|
if (module3._names) {
|
|
for (const name of module3._names) names.add(name);
|
|
} else {
|
|
queue.push(module3);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case constants.types.MODULE:
|
|
module2._evaluate();
|
|
for (const name of Object.keys(module2._exports)) names.add(name);
|
|
break;
|
|
case constants.types.JSON:
|
|
for (const name of Object.keys(module2._exports)) names.add(name);
|
|
}
|
|
}
|
|
this._names = Array.from(names);
|
|
this._handle = binding.createSyntheticModule(this._url.href, this._names, Module2._handle);
|
|
const id = binding.getModuleID(this._handle);
|
|
Module2._registry.set(id, this);
|
|
}
|
|
_evaluate() {
|
|
if ((this._state & constants.states.EVALUATED) !== 0) return;
|
|
this._state |= constants.states.EVALUATED;
|
|
if (this._type === constants.types.SCRIPT) {
|
|
const require2 = exports.createRequire(this._url, { module: this });
|
|
this._exports = {};
|
|
const fn = this._function;
|
|
fn(require2, this, this._exports, urlToPath(this._url), urlToDirname(this._url));
|
|
} else if (this._type === constants.types.MODULE) {
|
|
this._run();
|
|
this._exports = binding.getModuleNamespace(this._handle);
|
|
}
|
|
}
|
|
_run() {
|
|
if ((this._state & constants.states.RUN) !== 0) return;
|
|
this._state |= constants.states.RUN;
|
|
this._synthesize();
|
|
this._promise = binding.runModule(this._handle, Module2._handle, Module2._onrun);
|
|
}
|
|
[Symbol.for("bare.inspect")]() {
|
|
return {
|
|
__proto__: { constructor: Module2 },
|
|
url: this.url,
|
|
type: this.type,
|
|
defaultType: this.defaultType,
|
|
main: this.main,
|
|
exports: this.exports,
|
|
imports: this.imports,
|
|
resolutions: this.resolutions,
|
|
builtins: this.builtins,
|
|
conditions: this.conditions
|
|
};
|
|
}
|
|
static _extensions = /* @__PURE__ */ Object.create(null);
|
|
static _protocol = null;
|
|
static _registry = /* @__PURE__ */ new WeakMap();
|
|
static _cache = module[kind] === Module2[kind] ? module.cache || /* @__PURE__ */ Object.create(null) : /* @__PURE__ */ Object.create(null);
|
|
static _conditions = ["bare", "node", ...Bare.Addon.host.split("-")];
|
|
static _handle = binding.init(this, this._onimport, this._onevaluate, this._onmeta);
|
|
static _onimport(specifier, attributes, referrerName, id, isDynamicImport) {
|
|
const referrer = this._registry.get(id) || null;
|
|
let parentURL;
|
|
if (referrer !== null) {
|
|
parentURL = referrer._url;
|
|
} else if (isDynamicImport) {
|
|
parentURL = referrerName ? toURL(referrerName) : pathToFileURL("./");
|
|
} else {
|
|
throw errors.MODULE_NOT_FOUND(`Cannot find referrer for module '${specifier}'`, specifier);
|
|
}
|
|
const resolved = this.resolve(specifier, parentURL, {
|
|
isImport: true,
|
|
referrer,
|
|
attributes
|
|
});
|
|
const module2 = this.load(resolved, {
|
|
isImport: true,
|
|
isDynamicImport,
|
|
referrer,
|
|
attributes
|
|
});
|
|
return isDynamicImport ? module2._promise.then(() => binding.getModuleNamespace(module2._handle)) : module2._handle;
|
|
}
|
|
static _onevaluate(id) {
|
|
const module2 = this._registry.get(id) || null;
|
|
if (module2 === null) {
|
|
throw errors.MODULE_NOT_FOUND("Cannot find module");
|
|
}
|
|
module2._evaluate();
|
|
for (const name of module2._names) {
|
|
let value;
|
|
if (name === "default" && (typeof module2._exports !== "object" || module2._exports === null || name in module2._exports === false)) {
|
|
value = module2._exports;
|
|
} else {
|
|
value = module2._exports[name];
|
|
}
|
|
binding.setModuleExport(module2._handle, name, value);
|
|
}
|
|
}
|
|
static _onmeta(id, meta) {
|
|
const module2 = this._registry.get(id) || null;
|
|
if (module2 === null) {
|
|
throw errors.MODULE_NOT_FOUND("Cannot find module");
|
|
}
|
|
const referrer = module2;
|
|
meta.url = module2._url.href;
|
|
meta.main = module2._main === module2;
|
|
meta.cache = module2._cache;
|
|
meta.dirname = module2.dirname;
|
|
meta.filename = module2.filename;
|
|
meta.resolve = function resolve2(specifier, parentURL = referrer._url) {
|
|
return Module2.resolve(specifier, toURL(parentURL, referrer._url), {
|
|
referrer
|
|
}).href;
|
|
};
|
|
meta.addon = function addon(specifier = ".", parentURL = referrer._url) {
|
|
const resolved = Bare.Addon.resolve(specifier, toURL(parentURL, referrer._url), { referrer });
|
|
const addon2 = Bare.Addon.load(resolved, { referrer });
|
|
return addon2._exports;
|
|
};
|
|
meta.addon.resolve = function resolve2(specifier = ".", parentURL = referrer._url) {
|
|
return Bare.Addon.resolve(specifier, toURL(parentURL, referrer._url), {
|
|
referrer
|
|
}).href;
|
|
};
|
|
meta.addon.host = Bare.Addon.host;
|
|
meta.asset = function asset(specifier, parentURL = referrer._url) {
|
|
return Module2.asset(specifier, toURL(parentURL, referrer._url), {
|
|
referrer
|
|
}).href;
|
|
};
|
|
}
|
|
static _onrun(reason, promise, err = reason) {
|
|
if (err) {
|
|
promise.catch(() => {
|
|
});
|
|
throw err;
|
|
} else {
|
|
promise.catch(
|
|
(err2) => queueMicrotask(() => {
|
|
throw err2;
|
|
})
|
|
);
|
|
}
|
|
}
|
|
static get protocol() {
|
|
return this._protocol;
|
|
}
|
|
static get cache() {
|
|
return this._cache;
|
|
}
|
|
static load(url, source = null, opts = {}) {
|
|
if (!ArrayBuffer.isView(source) && !Bundle.isBundle(source) && typeof source !== "string" && source !== null) {
|
|
opts = source;
|
|
source = null;
|
|
}
|
|
const referrer = opts.referrer || null;
|
|
const inherited = inherit(referrer);
|
|
const {
|
|
isImport = false,
|
|
isDynamicImport = false,
|
|
attributes,
|
|
type = typeForAttributes(attributes),
|
|
defaultType = inherited.defaultType,
|
|
cache = inherited.cache,
|
|
main = inherited.main,
|
|
protocol = inherited.protocol,
|
|
imports = inherited.imports,
|
|
resolutions = inherited.resolutions,
|
|
builtins = inherited.builtins,
|
|
conditions = inherited.conditions
|
|
} = opts;
|
|
let module2 = cache[url.href] || null;
|
|
if (module2 !== null) {
|
|
if (type !== 0 && type !== module2._type) {
|
|
throw errors.TYPE_INCOMPATIBLE(
|
|
`Module '${module2.url.href}' is not of type '${nameOfType(type)}'`
|
|
);
|
|
}
|
|
return module2._transform(isImport, isDynamicImport);
|
|
}
|
|
module2 = cache[url.href] = new Module2(url);
|
|
try {
|
|
switch (url.protocol) {
|
|
case "builtin:":
|
|
module2._exports = builtins[url.pathname];
|
|
break;
|
|
default: {
|
|
module2._defaultType = defaultType;
|
|
module2._cache = cache;
|
|
module2._main = main || module2;
|
|
module2._protocol = protocol;
|
|
module2._imports = imports;
|
|
module2._resolutions = resolutions;
|
|
module2._builtins = builtins;
|
|
module2._conditions = conditions;
|
|
if (typeof attributes === "object" && attributes !== null && typeof attributes.imports === "string") {
|
|
const resolved = Module2.resolve(attributes.imports, referrer._url, {
|
|
referrer: module2
|
|
});
|
|
const imports2 = Module2.load(resolved, {
|
|
referrer: module2,
|
|
type: constants.types.JSON
|
|
});
|
|
module2._imports = mixinImports(module2._imports, imports2._exports, resolved);
|
|
}
|
|
let extension = canonicalExtensionForType(type) || path.extname(url.pathname);
|
|
if (extension in Module2._extensions === false) {
|
|
if (defaultType) {
|
|
extension = canonicalExtensionForType(defaultType) || ".js";
|
|
} else {
|
|
extension = ".js";
|
|
}
|
|
}
|
|
Module2._extensions[extension](module2, source, referrer);
|
|
}
|
|
}
|
|
return module2._transform(isImport, isDynamicImport);
|
|
} catch (err) {
|
|
delete cache[url.href];
|
|
throw err;
|
|
}
|
|
}
|
|
static resolve(specifier, parentURL, opts = {}) {
|
|
if (typeof specifier !== "string") {
|
|
throw new TypeError(
|
|
`Specifier must be a string. Received type ${typeof specifier} (${specifier})`
|
|
);
|
|
}
|
|
const referrer = opts.referrer || null;
|
|
const inherited = inherit(referrer);
|
|
const {
|
|
isImport = false,
|
|
attributes,
|
|
type = typeForAttributes(attributes),
|
|
extensions = extensionsForType(type),
|
|
cache = referrer ? referrer._cache : /* @__PURE__ */ Object.create(null),
|
|
protocol = inherited.protocol,
|
|
imports = inherited.imports,
|
|
resolutions = inherited.resolutions,
|
|
builtins = inherited.builtins,
|
|
conditions = inherited.conditions
|
|
} = opts;
|
|
const resolved = protocol.preresolve(specifier, parentURL);
|
|
const [resolution] = protocol.resolve(resolved, parentURL, imports);
|
|
if (resolution) return protocol.postresolve(resolution);
|
|
const candidates = [];
|
|
for (const resolution2 of resolve(
|
|
resolved,
|
|
parentURL,
|
|
{
|
|
conditions: isImport ? ["import", ...conditions] : ["require", ...conditions],
|
|
imports,
|
|
resolutions,
|
|
extensions,
|
|
builtins: builtins ? Object.keys(builtins) : [],
|
|
engines: Bare.versions
|
|
},
|
|
readPackageFor(protocol, cache)
|
|
)) {
|
|
candidates.push(resolution2);
|
|
const condition = isImport ? "import" : "require";
|
|
switch (resolution2.protocol) {
|
|
case "builtin:":
|
|
cacheResolution(resolutions, parentURL, resolved, condition, resolution2);
|
|
return resolution2;
|
|
default:
|
|
if (protocol.exists(resolution2, type)) {
|
|
const postresolved = protocol.postresolve(resolution2);
|
|
cacheResolution(resolutions, parentURL, resolved, condition, postresolved);
|
|
return postresolved;
|
|
}
|
|
}
|
|
}
|
|
throw errors.MODULE_NOT_FOUND(
|
|
notFound("module", specifier, parentURL, candidates),
|
|
specifier,
|
|
parentURL,
|
|
candidates
|
|
);
|
|
}
|
|
static asset(specifier, parentURL, opts = {}) {
|
|
if (typeof specifier !== "string") {
|
|
throw new TypeError(
|
|
`Specifier must be a string. Received type ${typeof specifier} (${specifier})`
|
|
);
|
|
}
|
|
const referrer = opts.referrer || null;
|
|
const inherited = inherit(referrer);
|
|
const {
|
|
cache = referrer ? referrer._cache : /* @__PURE__ */ Object.create(null),
|
|
protocol = inherited.protocol,
|
|
imports = inherited.imports,
|
|
resolutions = inherited.resolutions,
|
|
conditions = inherited.conditions
|
|
} = opts;
|
|
const resolved = protocol.preresolve(specifier, parentURL);
|
|
const [resolution] = protocol.resolve(resolved, parentURL, imports);
|
|
if (resolution) return protocol.postresolve(resolution);
|
|
const candidates = [];
|
|
for (const resolution2 of resolve(
|
|
resolved,
|
|
parentURL,
|
|
{
|
|
conditions: ["asset", ...conditions],
|
|
imports,
|
|
resolutions,
|
|
engines: Bare.versions
|
|
},
|
|
readPackageFor(protocol, cache)
|
|
)) {
|
|
candidates.push(resolution2);
|
|
if (protocol.exists(resolution2, constants.types.ASSET)) {
|
|
const postresolved = protocol.postresolve(
|
|
protocol.asset ? protocol.asset(resolution2) : resolution2
|
|
);
|
|
cacheResolution(resolutions, parentURL, resolved, "asset", postresolved);
|
|
return postresolved;
|
|
}
|
|
}
|
|
throw errors.ASSET_NOT_FOUND(
|
|
notFound("asset", specifier, parentURL, candidates),
|
|
specifier,
|
|
parentURL,
|
|
candidates
|
|
);
|
|
}
|
|
};
|
|
var Module = exports;
|
|
function inherit(referrer) {
|
|
return {
|
|
defaultType: referrer ? referrer._defaultType : 0,
|
|
cache: referrer ? referrer._cache : Module._cache,
|
|
main: referrer ? referrer._main : null,
|
|
protocol: referrer ? referrer._protocol : Module._protocol,
|
|
imports: referrer ? referrer._imports : null,
|
|
resolutions: referrer ? referrer._resolutions : /* @__PURE__ */ Object.create(null),
|
|
builtins: referrer ? referrer._builtins : null,
|
|
conditions: referrer ? referrer._conditions : Module._conditions
|
|
};
|
|
}
|
|
function readPackageFor(protocol, cache) {
|
|
return function readPackage(packageURL) {
|
|
if (protocol.exists(packageURL, constants.types.JSON)) {
|
|
return Module.load(packageURL, { protocol, cache })._exports;
|
|
}
|
|
return null;
|
|
};
|
|
}
|
|
function notFound(kind2, specifier, parentURL, candidates) {
|
|
let message = `Cannot find ${kind2} '${specifier}' imported from '${parentURL.href}'`;
|
|
if (candidates.length > 0) {
|
|
message += "\nCandidates:";
|
|
message += "\n" + candidates.map((url) => "- " + url.href).join("\n");
|
|
}
|
|
return message;
|
|
}
|
|
var typeInfo = {
|
|
[constants.types.SCRIPT]: {
|
|
name: "script",
|
|
attribute: "script",
|
|
canonicalExtension: ".cjs",
|
|
extensions: [".js", ".cjs", ".ts", ".cts"]
|
|
},
|
|
[constants.types.MODULE]: {
|
|
name: "module",
|
|
attribute: "module",
|
|
canonicalExtension: ".mjs",
|
|
extensions: [".js", ".mjs", ".ts", ".mts"]
|
|
},
|
|
[constants.types.JSON]: {
|
|
name: "json",
|
|
attribute: "json",
|
|
canonicalExtension: ".json",
|
|
extensions: [".json"]
|
|
},
|
|
[constants.types.BUNDLE]: {
|
|
name: "bundle",
|
|
attribute: "bundle",
|
|
canonicalExtension: ".bundle",
|
|
extensions: [".bundle"]
|
|
},
|
|
[constants.types.ADDON]: {
|
|
name: "bare",
|
|
attribute: "addon",
|
|
canonicalExtension: ".bare",
|
|
extensions: [".bare", ".node"]
|
|
},
|
|
[constants.types.BINARY]: {
|
|
name: "binary",
|
|
attribute: "binary",
|
|
canonicalExtension: ".bin",
|
|
extensions: [".bin"]
|
|
},
|
|
[constants.types.TEXT]: {
|
|
name: "text",
|
|
attribute: "text",
|
|
canonicalExtension: ".txt",
|
|
extensions: [".txt"]
|
|
}
|
|
};
|
|
var defaultExtensions = [".js", ".cjs", ".mjs", ".ts", ".cts", ".mts", ".json", ".bare", ".node"];
|
|
var typeByAttribute = /* @__PURE__ */ Object.create(null);
|
|
for (const type in typeInfo) {
|
|
typeByAttribute[typeInfo[type].attribute] = +type;
|
|
}
|
|
function extensionsForType(type) {
|
|
return type in typeInfo ? typeInfo[type].extensions : defaultExtensions;
|
|
}
|
|
function canonicalExtensionForType(type) {
|
|
return type in typeInfo ? typeInfo[type].canonicalExtension : null;
|
|
}
|
|
function nameOfType(type) {
|
|
return type in typeInfo ? typeInfo[type].name : null;
|
|
}
|
|
function typeForAttributes(attributes) {
|
|
if (typeof attributes !== "object" || attributes === null) return 0;
|
|
return typeByAttribute[attributes.type] || 0;
|
|
}
|
|
function mixinImports(target, imports, url) {
|
|
if (typeof imports === "object" && imports !== null && "imports" in imports) {
|
|
imports = imports.imports;
|
|
}
|
|
if (typeof imports !== "object" || imports === null) {
|
|
throw errors.INVALID_IMPORTS_MAP(`Imports map at '${url.href}' is not valid`);
|
|
}
|
|
return { ...target, ...imports };
|
|
}
|
|
function cacheResolution(resolutions, parentURL, specifier, condition, resolved) {
|
|
if (resolutions === null) return;
|
|
let imports = resolutions[parentURL.href];
|
|
if (typeof imports !== "object" || imports === null) {
|
|
imports = resolutions[parentURL.href] = /* @__PURE__ */ Object.create(null);
|
|
}
|
|
if (specifier in imports) return;
|
|
imports[specifier] = { [condition]: resolved.href };
|
|
}
|
|
exports.Protocol = Protocol;
|
|
exports.constants = constants;
|
|
exports.builtinModules = [];
|
|
exports.isBuiltin = function isBuiltin() {
|
|
return false;
|
|
};
|
|
exports.createRequire = function createRequire(parentURL, opts = {}) {
|
|
const inherited = inherit(opts.referrer);
|
|
const {
|
|
type = constants.types.SCRIPT,
|
|
defaultType = inherited.defaultType || constants.types.SCRIPT,
|
|
cache = inherited.cache,
|
|
main = inherited.main,
|
|
protocol = inherited.protocol,
|
|
imports = inherited.imports,
|
|
resolutions = inherited.resolutions,
|
|
builtins = inherited.builtins,
|
|
conditions = inherited.conditions
|
|
} = opts;
|
|
let module2 = opts.module || null;
|
|
if (module2 === null) {
|
|
module2 = new Module(toURL(parentURL));
|
|
module2._type = type;
|
|
module2._defaultType = defaultType;
|
|
module2._cache = cache;
|
|
module2._main = main || module2;
|
|
module2._protocol = protocol;
|
|
module2._imports = imports;
|
|
module2._resolutions = resolutions;
|
|
module2._builtins = builtins;
|
|
module2._conditions = conditions;
|
|
}
|
|
const referrer = module2;
|
|
function require2(specifier, opts2 = {}) {
|
|
const attributes = opts2 && opts2.with;
|
|
const resolved = Module.resolve(specifier, referrer._url, {
|
|
referrer,
|
|
attributes
|
|
});
|
|
const module3 = Module.load(resolved, { referrer, attributes });
|
|
return module3._exports;
|
|
}
|
|
require2.main = module2._main;
|
|
require2.cache = module2._cache;
|
|
require2.resolve = function resolve2(specifier, parentURL2 = referrer._url) {
|
|
return urlToPath(Module.resolve(specifier, toURL(parentURL2, referrer._url), { referrer }));
|
|
};
|
|
require2.addon = function addon(specifier = ".", parentURL2 = referrer._url) {
|
|
const resolved = Bare.Addon.resolve(specifier, toURL(parentURL2, referrer._url), { referrer });
|
|
const addon2 = Bare.Addon.load(resolved, { referrer });
|
|
return addon2._exports;
|
|
};
|
|
require2.addon.host = Bare.Addon.host;
|
|
require2.addon.resolve = function resolve2(specifier = ".", parentURL2 = referrer._url) {
|
|
return urlToPath(
|
|
Bare.Addon.resolve(specifier, toURL(parentURL2, referrer._url), {
|
|
referrer
|
|
})
|
|
);
|
|
};
|
|
require2.asset = function asset(specifier, parentURL2 = referrer._url) {
|
|
return urlToPath(Module.asset(specifier, toURL(parentURL2, referrer._url), { referrer }));
|
|
};
|
|
return require2;
|
|
};
|
|
function readSource(module2, source) {
|
|
if (source === null) source = module2._protocol.read(module2._url);
|
|
if (typeof source === "string") source = Buffer.from(source);
|
|
return source;
|
|
}
|
|
Module._extensions[".js"] = function(module2, source, referrer) {
|
|
const cache = module2._cache;
|
|
const protocol = module2._protocol;
|
|
const resolutions = module2._resolutions;
|
|
let pkg;
|
|
for (const packageURL of resolve.lookupPackageScope(module2._url, {
|
|
resolutions
|
|
})) {
|
|
if (cache[packageURL.href]) {
|
|
pkg = cache[packageURL.href];
|
|
break;
|
|
}
|
|
if (protocol.exists(packageURL, constants.types.JSON)) {
|
|
pkg = Module.load(packageURL, { protocol, cache });
|
|
break;
|
|
}
|
|
}
|
|
const info = pkg && pkg._exports || {};
|
|
const isESM = (
|
|
// The default type is ES modules.
|
|
constants.types.MODULE === module2._defaultType || // The package is explicitly declared as an ES module.
|
|
info && info.type === "module"
|
|
);
|
|
return Module._extensions[isESM ? ".mjs" : ".cjs"](module2, source, referrer);
|
|
};
|
|
Module._extensions[".cjs"] = function(module2, source, referrer) {
|
|
module2._type = constants.types.SCRIPT;
|
|
source = readSource(module2, source);
|
|
module2._source = source;
|
|
module2._function = binding.createFunction(
|
|
module2._url.href,
|
|
["require", "module", "exports", "__filename", "__dirname"],
|
|
source.toString(),
|
|
0
|
|
);
|
|
const id = binding.getFunctionID(module2._function);
|
|
Module._registry.set(id, module2);
|
|
};
|
|
Module._extensions[".mjs"] = function(module2, source, referrer) {
|
|
module2._type = constants.types.MODULE;
|
|
source = readSource(module2, source);
|
|
module2._source = source;
|
|
module2._handle = binding.createModule(module2._url.href, source.toString(), 0, Module._handle);
|
|
const id = binding.getModuleID(module2._handle);
|
|
Module._registry.set(id, module2);
|
|
};
|
|
for (const [typescript, javascript] of [
|
|
[".ts", ".js"],
|
|
[".cts", ".cjs"],
|
|
[".mts", ".mjs"]
|
|
]) {
|
|
Module._extensions[typescript] = function(module2, source, referrer) {
|
|
return Module._extensions[javascript](module2, strip(readSource(module2, source)), referrer);
|
|
};
|
|
}
|
|
Module._extensions[".json"] = function(module2, source, referrer) {
|
|
module2._type = constants.types.JSON;
|
|
source = readSource(module2, source);
|
|
module2._source = source;
|
|
module2._exports = JSON.parse(source.toString());
|
|
};
|
|
Module._extensions[".bare"] = Module._extensions[".node"] = function(module2, source, referrer) {
|
|
module2._type = constants.types.ADDON;
|
|
referrer = module2;
|
|
module2._exports = Bare.Addon.load(module2._url, { referrer }).exports;
|
|
};
|
|
Module._extensions[".bundle"] = function(module2, source, referrer) {
|
|
const protocol = module2._protocol;
|
|
module2._type = constants.types.BUNDLE;
|
|
source = readSource(module2, source);
|
|
referrer = module2;
|
|
const bundle = Bundle.from(source).mount(module2._url.href + "/");
|
|
module2._source = source;
|
|
module2._imports = bundle.imports;
|
|
module2._resolutions = bundle.resolutions;
|
|
module2._protocol = protocol.extend({
|
|
postresolve(context, url) {
|
|
return bundle.exists(url.href) ? url : context.postresolve(url);
|
|
},
|
|
exists(context, url, type) {
|
|
return bundle.exists(url.href) || context.exists(url, type);
|
|
},
|
|
read(context, url) {
|
|
return bundle.read(url.href) || context.read(url);
|
|
}
|
|
});
|
|
if (bundle.main) {
|
|
module2._exports = Module.load(new URL(bundle.main), bundle.read(bundle.main), {
|
|
referrer
|
|
})._exports;
|
|
}
|
|
};
|
|
Module._extensions[".bin"] = function(module2, source, referrer) {
|
|
module2._type = constants.types.BINARY;
|
|
source = readSource(module2, source);
|
|
module2._source = module2._exports = source;
|
|
};
|
|
Module._extensions[".txt"] = function(module2, source, referrer) {
|
|
module2._type = constants.types.TEXT;
|
|
source = readSource(module2, source);
|
|
module2._source = source;
|
|
module2._exports = source.toString();
|
|
};
|
|
Module._protocol = new Protocol({
|
|
postresolve(url) {
|
|
switch (url.protocol) {
|
|
case "file:":
|
|
return pathToFileURL(binding.realpath(path.toNamespacedPath(fileURLToPath(url))));
|
|
default:
|
|
return url;
|
|
}
|
|
},
|
|
exists(url, type = 0) {
|
|
switch (url.protocol) {
|
|
case "file:":
|
|
return binding.exists(
|
|
path.toNamespacedPath(fileURLToPath(url)),
|
|
type === constants.types.ASSET ? binding.FILE | binding.DIR : binding.FILE
|
|
);
|
|
default:
|
|
return false;
|
|
}
|
|
},
|
|
read(url) {
|
|
switch (url.protocol) {
|
|
case "file:":
|
|
return Buffer.from(binding.read(path.toNamespacedPath(fileURLToPath(url))));
|
|
default:
|
|
throw errors.UNKNOWN_PROTOCOL(`Cannot load module '${url.href}'`);
|
|
}
|
|
}
|
|
});
|
|
function toURL(value, base) {
|
|
if (isURL(value)) return value;
|
|
if (startsWithWindowsDriveLetter(value)) {
|
|
return pathToFileURL(value);
|
|
}
|
|
return URL.parse(value, base) || pathToFileURL(value);
|
|
}
|
|
function urlToPath(url) {
|
|
if (url.protocol === "file:") return fileURLToPath(url);
|
|
assertValidURLPath(url);
|
|
return decodeURIComponent(url.pathname);
|
|
}
|
|
function urlToDirname(url) {
|
|
if (url.protocol === "file:") return path.dirname(fileURLToPath(url));
|
|
assertValidURLPath(url);
|
|
return decodeURIComponent(new URL(".", url).pathname).replace(/\/$/, "");
|
|
}
|
|
function assertValidURLPath(url) {
|
|
if (isWindows) {
|
|
if (/%2f|%5c/i.test(url.pathname)) {
|
|
throw errors.INVALID_URL_PATH("The URL path must not include encoded \\ or / characters");
|
|
}
|
|
} else {
|
|
if (/%2f/i.test(url.pathname)) {
|
|
throw errors.INVALID_URL_PATH("The URL path must not include encoded / characters");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// ../../bare-lib-entry-bareModule.js
|
|
var bare_lib_entry_bareModule_exports = {};
|
|
__export(bare_lib_entry_bareModule_exports, {
|
|
default: () => bare_lib_entry_bareModule_default
|
|
});
|
|
var import_bare_module = __toESM(require_bare_module());
|
|
var bare_lib_entry_bareModule_default = import_bare_module.default;
|
|
return __toCommonJS(bare_lib_entry_bareModule_exports);
|
|
})();
|
|
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};var e=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;var v=e!=null&&typeof e==="object"&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;g[s]["bareModule"]=v;})();
|