lakutata
Version:
An IoC-based universal application framework.
435 lines (392 loc) • 11.6 kB
JavaScript
/* Build Date: Mon Jan 05 2026 23:52:23 GMT+0800 (China Standard Time) */
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
const e = require("../../../vendor/Package.internal.2.cjs");
var t = function e(t, s) {
s = s.split(":")[0];
t = +t;
if (!t) return false;
switch (s) {
case "http":
case "ws":
return t !== 80;
case "https":
case "wss":
return t !== 443;
case "ftp":
return t !== 21;
case "gopher":
return t !== 70;
case "file":
return false;
}
return t !== 0;
};
var s = {};
var o = Object.prototype.hasOwnProperty, r;
function n(e) {
try {
return decodeURIComponent(e.replace(/\+/g, " "));
} catch (e) {
return null;
}
}
function i(e) {
try {
return encodeURIComponent(e);
} catch (e) {
return null;
}
}
function a(e) {
var t = /([^=?#&]+)=?([^&]*)/g, s = {}, o;
while (o = t.exec(e)) {
var r = n(o[1]), i = n(o[2]);
if (r === null || i === null || r in s) continue;
s[r] = i;
}
return s;
}
function h(e, t) {
t = t || "";
var s = [], n, a;
if ("string" !== typeof t) t = "?";
for (a in e) {
if (o.call(e, a)) {
n = e[a];
if (!n && (n === null || n === r || isNaN(n))) {
n = "";
}
a = i(a);
n = i(n);
if (a === null || n === null) continue;
s.push(a + "=" + n);
}
}
return s.length ? t + s.join("&") : "";
}
s.stringify = h;
s.parse = a;
var l = t, c = s, f = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/, u = /[\n\r\t]/g, p = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//, d = /:\d+$/, m = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i, g = /^[a-zA-Z]:/;
function w(e) {
return (e ? e : "").toString().replace(f, "");
}
var y = [ [ "#", "hash" ], [ "?", "query" ], function e(t, s) {
return j(s.protocol) ? t.replace(/\\/g, "/") : t;
}, [ "/", "pathname" ], [ "@", "auth", 1 ], [ NaN, "host", undefined, 1, 1 ], [ /:(\d*)$/, "port", undefined, 1 ], [ NaN, "hostname", undefined, 1, 1 ] ];
var b = {
hash: 1,
query: 1
};
function v(t) {
var s;
if (typeof window !== "undefined") s = window; else if (typeof e.commonjsGlobal !== "undefined") s = e.commonjsGlobal; else if (typeof self !== "undefined") s = self; else s = {};
var o = s.location || {};
t = t || o;
var r = {}, n = typeof t, i;
if ("blob:" === t.protocol) {
r = new R(unescape(t.pathname), {});
} else if ("string" === n) {
r = new R(t, {});
for (i in b) delete r[i];
} else if ("object" === n) {
for (i in t) {
if (i in b) continue;
r[i] = t[i];
}
if (r.slashes === undefined) {
r.slashes = p.test(t.href);
}
}
return r;
}
function j(e) {
return e === "file:" || e === "ftp:" || e === "http:" || e === "https:" || e === "ws:" || e === "wss:";
}
function O(e, t) {
e = w(e);
e = e.replace(u, "");
t = t || {};
var s = m.exec(e);
var o = s[1] ? s[1].toLowerCase() : "";
var r = !!s[2];
var n = !!s[3];
var i = 0;
var a;
if (r) {
if (n) {
a = s[2] + s[3] + s[4];
i = s[2].length + s[3].length;
} else {
a = s[2] + s[4];
i = s[2].length;
}
} else {
if (n) {
a = s[3] + s[4];
i = s[3].length;
} else {
a = s[4];
}
}
if (o === "file:") {
if (i >= 2) {
a = a.slice(2);
}
} else if (j(o)) {
a = s[4];
} else if (o) {
if (r) {
a = a.slice(2);
}
} else if (i >= 2 && j(t.protocol)) {
a = s[4];
}
return {
protocol: o,
slashes: r || j(o),
slashesCount: i,
rest: a
};
}
function C(e, t) {
if (e === "") return t;
var s = (t || "/").split("/").slice(0, -1).concat(e.split("/")), o = s.length, r = s[o - 1], n = false, i = 0;
while (o--) {
if (s[o] === ".") {
s.splice(o, 1);
} else if (s[o] === "..") {
s.splice(o, 1);
i++;
} else if (i) {
if (o === 0) n = true;
s.splice(o, 1);
i--;
}
}
if (n) s.unshift("");
if (r === "." || r === "..") s.push("");
return s.join("/");
}
function R(e, t, s) {
e = w(e);
e = e.replace(u, "");
if (!(this instanceof R)) {
return new R(e, t, s);
}
var o, r, n, i, a, h, f = y.slice(), p = typeof t, d = this, m = 0;
if ("object" !== p && "string" !== p) {
s = t;
t = null;
}
if (s && "function" !== typeof s) s = c.parse;
t = v(t);
r = O(e || "", t);
o = !r.protocol && !r.slashes;
d.slashes = r.slashes || o && t.slashes;
d.protocol = r.protocol || t.protocol || "";
e = r.rest;
if (r.protocol === "file:" && (r.slashesCount !== 2 || g.test(e)) || !r.slashes && (r.protocol || r.slashesCount < 2 || !j(d.protocol))) {
f[3] = [ /(.*)/, "pathname" ];
}
for (;m < f.length; m++) {
i = f[m];
if (typeof i === "function") {
e = i(e, d);
continue;
}
n = i[0];
h = i[1];
if (n !== n) {
d[h] = e;
} else if ("string" === typeof n) {
a = n === "@" ? e.lastIndexOf(n) : e.indexOf(n);
if (~a) {
if ("number" === typeof i[2]) {
d[h] = e.slice(0, a);
e = e.slice(a + i[2]);
} else {
d[h] = e.slice(a);
e = e.slice(0, a);
}
}
} else if (a = n.exec(e)) {
d[h] = a[1];
e = e.slice(0, a.index);
}
d[h] = d[h] || (o && i[3] ? t[h] || "" : "");
if (i[4]) d[h] = d[h].toLowerCase();
}
if (s) d.query = s(d.query);
if (o && t.slashes && d.pathname.charAt(0) !== "/" && (d.pathname !== "" || t.pathname !== "")) {
d.pathname = C(d.pathname, t.pathname);
}
if (d.pathname.charAt(0) !== "/" && j(d.protocol)) {
d.pathname = "/" + d.pathname;
}
if (!l(d.port, d.protocol)) {
d.host = d.hostname;
d.port = "";
}
d.username = d.password = "";
if (d.auth) {
a = d.auth.indexOf(":");
if (~a) {
d.username = d.auth.slice(0, a);
d.username = encodeURIComponent(decodeURIComponent(d.username));
d.password = d.auth.slice(a + 1);
d.password = encodeURIComponent(decodeURIComponent(d.password));
} else {
d.username = encodeURIComponent(decodeURIComponent(d.auth));
}
d.auth = d.password ? d.username + ":" + d.password : d.username;
}
d.origin = d.protocol !== "file:" && j(d.protocol) && d.host ? d.protocol + "//" + d.host : "null";
d.href = d.toString();
}
function U(e, t, s) {
var o = this;
switch (e) {
case "query":
if ("string" === typeof t && t.length) {
t = (s || c.parse)(t);
}
o[e] = t;
break;
case "port":
o[e] = t;
if (!l(t, o.protocol)) {
o.host = o.hostname;
o[e] = "";
} else if (t) {
o.host = o.hostname + ":" + t;
}
break;
case "hostname":
o[e] = t;
if (o.port) t += ":" + o.port;
o.host = t;
break;
case "host":
o[e] = t;
if (d.test(t)) {
t = t.split(":");
o.port = t.pop();
o.hostname = t.join(":");
} else {
o.hostname = t;
o.port = "";
}
break;
case "protocol":
o.protocol = t.toLowerCase();
o.slashes = !s;
break;
case "pathname":
case "hash":
if (t) {
var r = e === "pathname" ? "/" : "#";
o[e] = t.charAt(0) !== r ? r + t : t;
} else {
o[e] = t;
}
break;
case "username":
case "password":
o[e] = encodeURIComponent(t);
break;
case "auth":
var n = t.indexOf(":");
if (~n) {
o.username = t.slice(0, n);
o.username = encodeURIComponent(decodeURIComponent(o.username));
o.password = t.slice(n + 1);
o.password = encodeURIComponent(decodeURIComponent(o.password));
} else {
o.username = encodeURIComponent(decodeURIComponent(t));
}
}
for (var i = 0; i < y.length; i++) {
var a = y[i];
if (a[4]) o[a[1]] = o[a[1]].toLowerCase();
}
o.auth = o.password ? o.username + ":" + o.password : o.username;
o.origin = o.protocol !== "file:" && j(o.protocol) && o.host ? o.protocol + "//" + o.host : "null";
o.href = o.toString();
return o;
}
function I(e) {
if (!e || "function" !== typeof e) e = c.stringify;
var t, s = this, o = s.host, r = s.protocol;
if (r && r.charAt(r.length - 1) !== ":") r += ":";
var n = r + (s.protocol && s.slashes || j(s.protocol) ? "//" : "");
if (s.username) {
n += s.username;
if (s.password) n += ":" + s.password;
n += "@";
} else if (s.password) {
n += ":" + s.password;
n += "@";
} else if (s.protocol !== "file:" && j(s.protocol) && !o && s.pathname !== "/") {
n += "@";
}
if (o[o.length - 1] === ":" || d.test(s.hostname) && !s.port) {
o += ":";
}
n += o + s.pathname;
t = "object" === typeof s.query ? e(s.query) : s.query;
if (t) n += "?" !== t.charAt(0) ? "?" + t : t;
if (s.hash) n += s.hash;
return n;
}
R.prototype = {
set: U,
toString: I
};
R.extractProtocol = O;
R.location = v;
R.trimLeft = w;
R.qs = c;
var q = R;
const x = e.getDefaultExportFromCjs(q);
class URLBuilder {
static parse(e) {
return new URLBuilder(JSON.parse(JSON.stringify(x(e, true))));
}
#e;
constructor(e = {}) {
this.#e = x("");
this.auth = e.auth;
this.hash = e.hash;
this.host = e.host;
this.hostname = e.hostname;
this.href = e.href;
this.origin = e.origin;
this.password = e.password;
this.pathname = e.pathname;
this.port = e.port;
this.protocol = e.protocol;
this.query = e.query;
this.slashes = e.slashes;
this.username = e.username;
}
toString() {
if (this.auth) this.#e.set("auth", this.auth);
if (this.hash) this.#e.set("hash", this.hash);
if (this.host) this.#e.set("host", this.host);
if (this.hostname) this.#e.set("hostname", this.hostname);
if (this.href) this.#e.set("href", this.href);
if (this.origin !== undefined) this.#e.set("origin", this.origin.toString());
if (this.password) this.#e.set("password", this.password);
if (this.pathname) this.#e.set("pathname", this.pathname);
if (this.port !== undefined) this.#e.set("port", this.port);
if (this.protocol) this.#e.set("protocol", this.protocol);
if (this.query) this.#e.set("query", this.query);
if (this.slashes !== undefined) this.#e.set("slashes", this.slashes);
if (this.username) this.#e.set("username", this.username);
return this.#e.toString();
}
}
exports.URLBuilder = URLBuilder;