1470 lines
51 KiB
JavaScript
1470 lines
51 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-os/binding.js
|
|
var require_binding = __commonJS({
|
|
"../../node_modules/bare-os/binding.js"(exports, module) {
|
|
module.exports = __require.addon();
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-os/lib/errors.js
|
|
var require_errors = __commonJS({
|
|
"../../node_modules/bare-os/lib/errors.js"(exports, module) {
|
|
module.exports = class OSError extends Error {
|
|
constructor(msg, code, fn = OSError) {
|
|
super(`${code}: ${msg}`);
|
|
this.code = code;
|
|
if (Error.captureStackTrace) {
|
|
Error.captureStackTrace(this, fn);
|
|
}
|
|
}
|
|
get name() {
|
|
return "OSError";
|
|
}
|
|
static UNKNOWN_SIGNAL(msg) {
|
|
return new OSError(msg, "UNKNOWN_SIGNAL", OSError.UNKNOWN_SIGNAL);
|
|
}
|
|
static TITLE_OVERFLOW(msg) {
|
|
return new OSError(msg, "TITLE_OVERFLOW", OSError.TITLE_OVERFLOW);
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-os/lib/constants.js
|
|
var require_constants = __commonJS({
|
|
"../../node_modules/bare-os/lib/constants.js"(exports, module) {
|
|
var binding = require_binding();
|
|
module.exports = {
|
|
signals: binding.signals,
|
|
errnos: binding.errnos,
|
|
priority: binding.priority
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-os/index.js
|
|
var require_bare_os = __commonJS({
|
|
"../../node_modules/bare-os/index.js"(exports) {
|
|
var binding = require_binding();
|
|
var errors = require_errors();
|
|
var constants = require_constants();
|
|
exports.constants = constants;
|
|
exports.EOL = binding.platform === "win32" ? "\r\n" : "\n";
|
|
exports.devNull = binding.platform === "win32" ? "\\\\.\\nul" : "/dev/null";
|
|
exports.platform = function platform() {
|
|
return binding.platform;
|
|
};
|
|
exports.arch = function arch() {
|
|
return binding.arch;
|
|
};
|
|
exports.type = binding.type;
|
|
exports.version = binding.version;
|
|
exports.release = binding.release;
|
|
exports.machine = binding.machine;
|
|
exports.execPath = binding.execPath;
|
|
exports.pid = binding.pid;
|
|
exports.ppid = binding.ppid;
|
|
exports.cwd = binding.cwd;
|
|
exports.chdir = binding.chdir;
|
|
exports.tmpdir = binding.tmpdir;
|
|
exports.homedir = binding.homedir;
|
|
exports.hostname = binding.hostname;
|
|
exports.userInfo = binding.userInfo;
|
|
exports.networkInterfaces = function networkInterfaces() {
|
|
const result = {};
|
|
for (const entry of binding.networkInterfaces()) {
|
|
const { name, ...properties } = entry;
|
|
if (result[name]) result[name].push(properties);
|
|
else result[name] = [properties];
|
|
}
|
|
return result;
|
|
};
|
|
exports.kill = function kill(pid, signal = constants.signals.SIGTERM) {
|
|
if (typeof signal === "string") {
|
|
if (signal in constants.signals === false) {
|
|
throw errors.UNKNOWN_SIGNAL("Unknown signal: " + signal);
|
|
}
|
|
signal = constants.signals[signal];
|
|
}
|
|
binding.kill(pid, signal);
|
|
};
|
|
exports.endianness = function endianness() {
|
|
return binding.isLittleEndian ? "LE" : "BE";
|
|
};
|
|
exports.availableParallelism = binding.availableParallelism;
|
|
exports.cpuUsage = function cpuUsage(previous) {
|
|
const current = binding.cpuUsage();
|
|
if (previous) {
|
|
return {
|
|
user: current.user - previous.user,
|
|
system: current.system - previous.system
|
|
};
|
|
}
|
|
return current;
|
|
};
|
|
exports.threadCpuUsage = function threadCpuUsage(previous) {
|
|
const current = binding.threadCpuUsage();
|
|
if (previous) {
|
|
return {
|
|
user: current.user - previous.user,
|
|
system: current.system - previous.system
|
|
};
|
|
}
|
|
return current;
|
|
};
|
|
exports.resourceUsage = binding.resourceUsage;
|
|
exports.memoryUsage = binding.memoryUsage;
|
|
exports.freemem = binding.freemem;
|
|
exports.totalmem = binding.totalmem;
|
|
exports.availableMemory = binding.availableMemory;
|
|
exports.constrainedMemory = binding.constrainedMemory;
|
|
exports.uptime = binding.uptime;
|
|
exports.loadavg = binding.loadavg;
|
|
exports.cpus = binding.cpus;
|
|
exports.getProcessTitle = binding.getProcessTitle;
|
|
exports.setProcessTitle = function setProcessTitle(title) {
|
|
if (typeof title !== "string") title = title.toString();
|
|
if (title.length >= 256) {
|
|
throw errors.TITLE_OVERFLOW("Process title is too long");
|
|
}
|
|
binding.setProcessTitle(title);
|
|
};
|
|
exports.getPriority = function getPriority(pid = 0) {
|
|
return binding.getPriority(pid);
|
|
};
|
|
exports.setPriority = function setPriority(pid, priority) {
|
|
if (priority === void 0) {
|
|
priority = pid;
|
|
pid = 0;
|
|
}
|
|
binding.setPriority(pid, priority);
|
|
};
|
|
exports.getEnvKeys = binding.getEnvKeys;
|
|
exports.getEnv = binding.getEnv;
|
|
exports.hasEnv = binding.hasEnv;
|
|
exports.setEnv = binding.setEnv;
|
|
exports.unsetEnv = binding.unsetEnv;
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-path/lib/constants.js
|
|
var require_constants2 = __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_constants2();
|
|
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 os = require_bare_os();
|
|
var { normalizeString } = require_shared();
|
|
var {
|
|
CHAR_DOT,
|
|
CHAR_FORWARD_SLASH
|
|
} = require_constants2();
|
|
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] : os.cwd();
|
|
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) {
|
|
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) {
|
|
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];
|
|
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) {
|
|
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) {
|
|
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) {
|
|
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) {
|
|
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 os = require_bare_os();
|
|
var { normalizeString } = 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_constants2();
|
|
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];
|
|
if (path.length === 0) continue;
|
|
} else if (resolvedDevice.length === 0) {
|
|
path = os.cwd();
|
|
} else {
|
|
path = os.getEnv(`=${resolvedDevice}`) || os.cwd();
|
|
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) {
|
|
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) {
|
|
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];
|
|
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) {
|
|
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 (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) {
|
|
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) {
|
|
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) {
|
|
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-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_errors2 = __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 = /* @__PURE__ */ new Map();
|
|
if (url) _URLSearchParams._urls.set(this, url);
|
|
if (typeof init === "string") {
|
|
this._parse(init);
|
|
} else 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() {
|
|
return this._params.length;
|
|
}
|
|
// 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) {
|
|
if (input[0] === "?") input = input.substring(1);
|
|
this._params = /* @__PURE__ */ new Map();
|
|
for (const sequence of input.split("&")) {
|
|
if (sequence.length === 0) continue;
|
|
let i = sequence.indexOf("=");
|
|
if (i === -1) i = sequence.length;
|
|
const name = decodeURIComponent(sequence.substring(0, i));
|
|
const value = decodeURIComponent(sequence.substring(i + 1, sequence.length));
|
|
let list = this._params.get(name);
|
|
if (list === void 0) {
|
|
list = [];
|
|
this._params.set(name, list);
|
|
}
|
|
list.push(value);
|
|
}
|
|
}
|
|
// https://url.spec.whatwg.org/#concept-urlencoded-serializer
|
|
_serialize() {
|
|
let output = "";
|
|
for (let [name, values] of this._params) {
|
|
name = encodeURIComponent(name);
|
|
for (const value of values) {
|
|
if (output) output += "&";
|
|
output += name + "=" + encodeURIComponent(value);
|
|
}
|
|
}
|
|
return output;
|
|
}
|
|
};
|
|
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];
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../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_errors2();
|
|
var URLSearchParams = require_url_search_params();
|
|
var kind = Symbol.for("bare.url.kind");
|
|
var isWindows = Bare.platform === "win32";
|
|
var URL = 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._components = new Uint32Array(8);
|
|
this._parse(input, base, opts.throw !== false);
|
|
if (this._href) this._params = new URLSearchParams(this.search, this);
|
|
}
|
|
get [kind]() {
|
|
return _URL[kind];
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-href
|
|
get href() {
|
|
return this._href;
|
|
}
|
|
set href(value) {
|
|
this._update(value);
|
|
this._params._parse(this.search);
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-protocol
|
|
get protocol() {
|
|
return this._slice(0, this._components[0]) + ":";
|
|
}
|
|
set protocol(value) {
|
|
this._update(this._replace(value.replace(/:+$/, ""), 0, this._components[0]));
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-username
|
|
get username() {
|
|
return this._slice(this._components[0] + 3, this._components[1]);
|
|
}
|
|
set username(value) {
|
|
if (cannotHaveCredentialsOrPort(this)) {
|
|
return;
|
|
}
|
|
if (this.username === "") value += "@";
|
|
this._update(this._replace(value, this._components[0] + 3, this._components[1]));
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-password
|
|
get password() {
|
|
return this._href.slice(
|
|
this._components[1] + 1,
|
|
this._components[2] - 1
|
|
/* @ */
|
|
);
|
|
}
|
|
set password(value) {
|
|
if (cannotHaveCredentialsOrPort(this)) {
|
|
return;
|
|
}
|
|
let start = this._components[1] + 1;
|
|
let end = this._components[2] - 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._components[2], this._components[5]);
|
|
}
|
|
set host(value) {
|
|
if (hasOpaquePath(this)) {
|
|
return;
|
|
}
|
|
this._update(
|
|
this._replace(value, this._components[2], this._components[value.includes(":") ? 5 : 3])
|
|
);
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-hostname
|
|
get hostname() {
|
|
return this._slice(this._components[2], this._components[3]);
|
|
}
|
|
set hostname(value) {
|
|
if (hasOpaquePath(this)) {
|
|
return;
|
|
}
|
|
this._update(this._replace(value, this._components[2], this._components[3]));
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-port
|
|
get port() {
|
|
return this._slice(this._components[3] + 1, this._components[5]);
|
|
}
|
|
set port(value) {
|
|
if (cannotHaveCredentialsOrPort(this)) {
|
|
return;
|
|
}
|
|
let start = this._components[3] + 1;
|
|
if (this.port === "") {
|
|
value = ":" + value;
|
|
start--;
|
|
}
|
|
this._update(this._replace(value, start, this._components[5]));
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-pathname
|
|
get pathname() {
|
|
return this._slice(
|
|
this._components[5],
|
|
this._components[6] - 1
|
|
/* ? */
|
|
);
|
|
}
|
|
set pathname(value) {
|
|
if (hasOpaquePath(this)) {
|
|
return;
|
|
}
|
|
if (value[0] !== "/" && value[0] !== "\\") {
|
|
value = "/" + value;
|
|
}
|
|
this._update(this._replace(
|
|
value,
|
|
this._components[5],
|
|
this._components[6] - 1
|
|
/* ? */
|
|
));
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-search
|
|
get search() {
|
|
return this._slice(
|
|
this._components[6] - 1,
|
|
this._components[7] - 1
|
|
/* # */
|
|
);
|
|
}
|
|
set search(value) {
|
|
if (value && value[0] !== "?") value = "?" + value;
|
|
this._update(
|
|
this._replace(
|
|
value,
|
|
this._components[6] - 1,
|
|
this._components[7] - 1
|
|
/* # */
|
|
)
|
|
);
|
|
this._params._parse(this.search);
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-searchparams
|
|
get searchParams() {
|
|
return this._params;
|
|
}
|
|
// https://url.spec.whatwg.org/#dom-url-hash
|
|
get hash() {
|
|
return this._slice(
|
|
this._components[7] - 1
|
|
/* # */
|
|
);
|
|
}
|
|
set hash(value) {
|
|
if (value && value[0] !== "#") value = "#" + value;
|
|
this._update(this._replace(
|
|
value,
|
|
this._components[7] - 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) {
|
|
try {
|
|
this._href = binding.parse(
|
|
String(input),
|
|
base ? String(base) : null,
|
|
this._components,
|
|
shouldThrow
|
|
);
|
|
} catch (err) {
|
|
if (err instanceof TypeError) throw err;
|
|
throw errors.INVALID_URL(`Invalid URL '${input}'`, input);
|
|
}
|
|
}
|
|
_update(input) {
|
|
try {
|
|
this._parse(input, null, true);
|
|
} catch (err) {
|
|
if (err instanceof TypeError) throw err;
|
|
}
|
|
}
|
|
};
|
|
module.exports = exports = URL;
|
|
function hasOpaquePath(url) {
|
|
return url.pathname[0] !== "/";
|
|
}
|
|
function cannotHaveCredentialsOrPort(url) {
|
|
return url.hostname === "" || url.protocol === "file:";
|
|
}
|
|
exports.URL = URL;
|
|
exports.URLSearchParams = URLSearchParams;
|
|
exports.errors = errors;
|
|
exports.isURL = function isURL(value) {
|
|
if (value instanceof URL) return true;
|
|
return typeof value === "object" && value !== null && value[kind] === URL[kind];
|
|
};
|
|
exports.isURLSearchParams = URLSearchParams.isURLSearchParams;
|
|
exports.parse = function parse(input, base) {
|
|
const url = new URL(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 URL(url);
|
|
}
|
|
if (url.protocol !== "file:") {
|
|
throw errors.INVALID_URL_SCHEME("The URL must use the file: protocol");
|
|
}
|
|
if (isWindows) {
|
|
if (/%2f|%5c/i.test(url.pathname)) {
|
|
throw errors.INVALID_FILE_URL_PATH(
|
|
"The file: URL path must not include encoded \\ or / characters"
|
|
);
|
|
}
|
|
} else {
|
|
if (url.hostname) {
|
|
throw errors.INVALID_FILE_URL_HOST("The file: URL host must be 'localhost' or empty");
|
|
}
|
|
if (/%2f/i.test(url.pathname)) {
|
|
throw errors.INVALID_FILE_URL_PATH("The file: URL path must not include encoded / characters");
|
|
}
|
|
}
|
|
const pathname = path.normalize(decodeURIComponent(url.pathname));
|
|
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 += "\\";
|
|
}
|
|
resolved = resolved.replaceAll("%", "%25").replaceAll("#", "%23").replaceAll("?", "%3f").replaceAll("\n", "%0a").replaceAll("\r", "%0d").replaceAll(" ", "%09");
|
|
if (!isWindows) {
|
|
resolved = resolved.replaceAll("\\", "%5c");
|
|
}
|
|
return new URL("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;
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../bare-lib-entry-bareUrl.js
|
|
var bare_lib_entry_bareUrl_exports = {};
|
|
__export(bare_lib_entry_bareUrl_exports, {
|
|
default: () => bare_lib_entry_bareUrl_default
|
|
});
|
|
var import_bare_url = __toESM(require_bare_url());
|
|
var bare_lib_entry_bareUrl_default = import_bare_url.default;
|
|
return __toCommonJS(bare_lib_entry_bareUrl_exports);
|
|
})();
|
|
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareUrl"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|