chore: add pkg dependencies
This commit is contained in:
200
node_modules/whatwg-url/lib/URL-impl.js
generated
vendored
Normal file
200
node_modules/whatwg-url/lib/URL-impl.js
generated
vendored
Normal file
@ -0,0 +1,200 @@
|
||||
"use strict";
|
||||
const usm = require("./url-state-machine");
|
||||
|
||||
exports.implementation = class URLImpl {
|
||||
constructor(constructorArgs) {
|
||||
const url = constructorArgs[0];
|
||||
const base = constructorArgs[1];
|
||||
|
||||
let parsedBase = null;
|
||||
if (base !== undefined) {
|
||||
parsedBase = usm.basicURLParse(base);
|
||||
if (parsedBase === "failure") {
|
||||
throw new TypeError("Invalid base URL");
|
||||
}
|
||||
}
|
||||
|
||||
const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase });
|
||||
if (parsedURL === "failure") {
|
||||
throw new TypeError("Invalid URL");
|
||||
}
|
||||
|
||||
this._url = parsedURL;
|
||||
|
||||
// TODO: query stuff
|
||||
}
|
||||
|
||||
get href() {
|
||||
return usm.serializeURL(this._url);
|
||||
}
|
||||
|
||||
set href(v) {
|
||||
const parsedURL = usm.basicURLParse(v);
|
||||
if (parsedURL === "failure") {
|
||||
throw new TypeError("Invalid URL");
|
||||
}
|
||||
|
||||
this._url = parsedURL;
|
||||
}
|
||||
|
||||
get origin() {
|
||||
return usm.serializeURLOrigin(this._url);
|
||||
}
|
||||
|
||||
get protocol() {
|
||||
return this._url.scheme + ":";
|
||||
}
|
||||
|
||||
set protocol(v) {
|
||||
usm.basicURLParse(v + ":", { url: this._url, stateOverride: "scheme start" });
|
||||
}
|
||||
|
||||
get username() {
|
||||
return this._url.username;
|
||||
}
|
||||
|
||||
set username(v) {
|
||||
if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
usm.setTheUsername(this._url, v);
|
||||
}
|
||||
|
||||
get password() {
|
||||
return this._url.password;
|
||||
}
|
||||
|
||||
set password(v) {
|
||||
if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
usm.setThePassword(this._url, v);
|
||||
}
|
||||
|
||||
get host() {
|
||||
const url = this._url;
|
||||
|
||||
if (url.host === null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (url.port === null) {
|
||||
return usm.serializeHost(url.host);
|
||||
}
|
||||
|
||||
return usm.serializeHost(url.host) + ":" + usm.serializeInteger(url.port);
|
||||
}
|
||||
|
||||
set host(v) {
|
||||
if (this._url.cannotBeABaseURL) {
|
||||
return;
|
||||
}
|
||||
|
||||
usm.basicURLParse(v, { url: this._url, stateOverride: "host" });
|
||||
}
|
||||
|
||||
get hostname() {
|
||||
if (this._url.host === null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return usm.serializeHost(this._url.host);
|
||||
}
|
||||
|
||||
set hostname(v) {
|
||||
if (this._url.cannotBeABaseURL) {
|
||||
return;
|
||||
}
|
||||
|
||||
usm.basicURLParse(v, { url: this._url, stateOverride: "hostname" });
|
||||
}
|
||||
|
||||
get port() {
|
||||
if (this._url.port === null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return usm.serializeInteger(this._url.port);
|
||||
}
|
||||
|
||||
set port(v) {
|
||||
if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (v === "") {
|
||||
this._url.port = null;
|
||||
} else {
|
||||
usm.basicURLParse(v, { url: this._url, stateOverride: "port" });
|
||||
}
|
||||
}
|
||||
|
||||
get pathname() {
|
||||
if (this._url.cannotBeABaseURL) {
|
||||
return this._url.path[0];
|
||||
}
|
||||
|
||||
if (this._url.path.length === 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "/" + this._url.path.join("/");
|
||||
}
|
||||
|
||||
set pathname(v) {
|
||||
if (this._url.cannotBeABaseURL) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._url.path = [];
|
||||
usm.basicURLParse(v, { url: this._url, stateOverride: "path start" });
|
||||
}
|
||||
|
||||
get search() {
|
||||
if (this._url.query === null || this._url.query === "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "?" + this._url.query;
|
||||
}
|
||||
|
||||
set search(v) {
|
||||
// TODO: query stuff
|
||||
|
||||
const url = this._url;
|
||||
|
||||
if (v === "") {
|
||||
url.query = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const input = v[0] === "?" ? v.substring(1) : v;
|
||||
url.query = "";
|
||||
usm.basicURLParse(input, { url, stateOverride: "query" });
|
||||
}
|
||||
|
||||
get hash() {
|
||||
if (this._url.fragment === null || this._url.fragment === "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "#" + this._url.fragment;
|
||||
}
|
||||
|
||||
set hash(v) {
|
||||
if (v === "") {
|
||||
this._url.fragment = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const input = v[0] === "#" ? v.substring(1) : v;
|
||||
this._url.fragment = "";
|
||||
usm.basicURLParse(input, { url: this._url, stateOverride: "fragment" });
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return this.href;
|
||||
}
|
||||
};
|
196
node_modules/whatwg-url/lib/URL.js
generated
vendored
Normal file
196
node_modules/whatwg-url/lib/URL.js
generated
vendored
Normal file
@ -0,0 +1,196 @@
|
||||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
const Impl = require(".//URL-impl.js");
|
||||
|
||||
const impl = utils.implSymbol;
|
||||
|
||||
function URL(url) {
|
||||
if (!this || this[impl] || !(this instanceof URL)) {
|
||||
throw new TypeError("Failed to construct 'URL': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to construct 'URL': 1 argument required, but only " + arguments.length + " present.");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 2; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
args[0] = conversions["USVString"](args[0]);
|
||||
if (args[1] !== undefined) {
|
||||
args[1] = conversions["USVString"](args[1]);
|
||||
}
|
||||
|
||||
module.exports.setup(this, args);
|
||||
}
|
||||
|
||||
URL.prototype.toJSON = function toJSON() {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
const args = [];
|
||||
for (let i = 0; i < arguments.length && i < 0; ++i) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
return this[impl].toJSON.apply(this[impl], args);
|
||||
};
|
||||
Object.defineProperty(URL.prototype, "href", {
|
||||
get() {
|
||||
return this[impl].href;
|
||||
},
|
||||
set(V) {
|
||||
V = conversions["USVString"](V);
|
||||
this[impl].href = V;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
URL.prototype.toString = function () {
|
||||
if (!this || !module.exports.is(this)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
return this.href;
|
||||
};
|
||||
|
||||
Object.defineProperty(URL.prototype, "origin", {
|
||||
get() {
|
||||
return this[impl].origin;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "protocol", {
|
||||
get() {
|
||||
return this[impl].protocol;
|
||||
},
|
||||
set(V) {
|
||||
V = conversions["USVString"](V);
|
||||
this[impl].protocol = V;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "username", {
|
||||
get() {
|
||||
return this[impl].username;
|
||||
},
|
||||
set(V) {
|
||||
V = conversions["USVString"](V);
|
||||
this[impl].username = V;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "password", {
|
||||
get() {
|
||||
return this[impl].password;
|
||||
},
|
||||
set(V) {
|
||||
V = conversions["USVString"](V);
|
||||
this[impl].password = V;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "host", {
|
||||
get() {
|
||||
return this[impl].host;
|
||||
},
|
||||
set(V) {
|
||||
V = conversions["USVString"](V);
|
||||
this[impl].host = V;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "hostname", {
|
||||
get() {
|
||||
return this[impl].hostname;
|
||||
},
|
||||
set(V) {
|
||||
V = conversions["USVString"](V);
|
||||
this[impl].hostname = V;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "port", {
|
||||
get() {
|
||||
return this[impl].port;
|
||||
},
|
||||
set(V) {
|
||||
V = conversions["USVString"](V);
|
||||
this[impl].port = V;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "pathname", {
|
||||
get() {
|
||||
return this[impl].pathname;
|
||||
},
|
||||
set(V) {
|
||||
V = conversions["USVString"](V);
|
||||
this[impl].pathname = V;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "search", {
|
||||
get() {
|
||||
return this[impl].search;
|
||||
},
|
||||
set(V) {
|
||||
V = conversions["USVString"](V);
|
||||
this[impl].search = V;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(URL.prototype, "hash", {
|
||||
get() {
|
||||
return this[impl].hash;
|
||||
},
|
||||
set(V) {
|
||||
V = conversions["USVString"](V);
|
||||
this[impl].hash = V;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
is(obj) {
|
||||
return !!obj && obj[impl] instanceof Impl.implementation;
|
||||
},
|
||||
create(constructorArgs, privateData) {
|
||||
let obj = Object.create(URL.prototype);
|
||||
this.setup(obj, constructorArgs, privateData);
|
||||
return obj;
|
||||
},
|
||||
setup(obj, constructorArgs, privateData) {
|
||||
if (!privateData) privateData = {};
|
||||
privateData.wrapper = obj;
|
||||
|
||||
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
||||
obj[impl][utils.wrapperSymbol] = obj;
|
||||
},
|
||||
interface: URL,
|
||||
expose: {
|
||||
Window: { URL: URL },
|
||||
Worker: { URL: URL }
|
||||
}
|
||||
};
|
||||
|
11
node_modules/whatwg-url/lib/public-api.js
generated
vendored
Normal file
11
node_modules/whatwg-url/lib/public-api.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
exports.URL = require("./URL").interface;
|
||||
exports.serializeURL = require("./url-state-machine").serializeURL;
|
||||
exports.serializeURLOrigin = require("./url-state-machine").serializeURLOrigin;
|
||||
exports.basicURLParse = require("./url-state-machine").basicURLParse;
|
||||
exports.setTheUsername = require("./url-state-machine").setTheUsername;
|
||||
exports.setThePassword = require("./url-state-machine").setThePassword;
|
||||
exports.serializeHost = require("./url-state-machine").serializeHost;
|
||||
exports.serializeInteger = require("./url-state-machine").serializeInteger;
|
||||
exports.parseURL = require("./url-state-machine").parseURL;
|
1297
node_modules/whatwg-url/lib/url-state-machine.js
generated
vendored
Normal file
1297
node_modules/whatwg-url/lib/url-state-machine.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
20
node_modules/whatwg-url/lib/utils.js
generated
vendored
Normal file
20
node_modules/whatwg-url/lib/utils.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
module.exports.mixin = function mixin(target, source) {
|
||||
const keys = Object.getOwnPropertyNames(source);
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i]));
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.wrapperSymbol = Symbol("wrapper");
|
||||
module.exports.implSymbol = Symbol("impl");
|
||||
|
||||
module.exports.wrapperForImpl = function (impl) {
|
||||
return impl[module.exports.wrapperSymbol];
|
||||
};
|
||||
|
||||
module.exports.implForWrapper = function (wrapper) {
|
||||
return wrapper[module.exports.implSymbol];
|
||||
};
|
||||
|
Reference in New Issue
Block a user