Add node modules and new code for release (#39)
Co-authored-by: tbarnes94 <tbarnes94@users.noreply.github.com>
This commit is contained in:
parent
a10d84bc2e
commit
7ad2aa66bb
7655 changed files with 1763577 additions and 14 deletions
46
node_modules/whatwg-url/dist/Function.js
generated
vendored
Normal file
46
node_modules/whatwg-url/dist/Function.js
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (typeof value !== "function") {
|
||||
throw new TypeError(context + " is not a function");
|
||||
}
|
||||
|
||||
function invokeTheCallbackFunction(...args) {
|
||||
if (new.target !== undefined) {
|
||||
throw new Error("Internal error: invokeTheCallbackFunction is not a constructor");
|
||||
}
|
||||
|
||||
const thisArg = utils.tryWrapperForImpl(this);
|
||||
let callResult;
|
||||
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
args[i] = utils.tryWrapperForImpl(args[i]);
|
||||
}
|
||||
|
||||
callResult = Reflect.apply(value, thisArg, args);
|
||||
|
||||
callResult = conversions["any"](callResult, { context: context });
|
||||
|
||||
return callResult;
|
||||
}
|
||||
|
||||
invokeTheCallbackFunction.construct = (...args) => {
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
args[i] = utils.tryWrapperForImpl(args[i]);
|
||||
}
|
||||
|
||||
let callResult = Reflect.construct(value, args);
|
||||
|
||||
callResult = conversions["any"](callResult, { context: context });
|
||||
|
||||
return callResult;
|
||||
};
|
||||
|
||||
invokeTheCallbackFunction[utils.wrapperSymbol] = value;
|
||||
invokeTheCallbackFunction.objectReference = value;
|
||||
|
||||
return invokeTheCallbackFunction;
|
||||
};
|
217
node_modules/whatwg-url/dist/URL-impl.js
generated
vendored
Normal file
217
node_modules/whatwg-url/dist/URL-impl.js
generated
vendored
Normal file
|
@ -0,0 +1,217 @@
|
|||
"use strict";
|
||||
const usm = require("./url-state-machine");
|
||||
const urlencoded = require("./urlencoded");
|
||||
const URLSearchParams = require("./URLSearchParams");
|
||||
|
||||
exports.implementation = class URLImpl {
|
||||
constructor(globalObject, constructorArgs) {
|
||||
const url = constructorArgs[0];
|
||||
const base = constructorArgs[1];
|
||||
|
||||
let parsedBase = null;
|
||||
if (base !== undefined) {
|
||||
parsedBase = usm.basicURLParse(base);
|
||||
if (parsedBase === null) {
|
||||
throw new TypeError(`Invalid base URL: ${base}`);
|
||||
}
|
||||
}
|
||||
|
||||
const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase });
|
||||
if (parsedURL === null) {
|
||||
throw new TypeError(`Invalid URL: ${url}`);
|
||||
}
|
||||
|
||||
const query = parsedURL.query !== null ? parsedURL.query : "";
|
||||
|
||||
this._url = parsedURL;
|
||||
|
||||
// We cannot invoke the "new URLSearchParams object" algorithm without going through the constructor, which strips
|
||||
// question mark by default. Therefore the doNotStripQMark hack is used.
|
||||
this._query = URLSearchParams.createImpl(globalObject, [query], { doNotStripQMark: true });
|
||||
this._query._url = this;
|
||||
}
|
||||
|
||||
get href() {
|
||||
return usm.serializeURL(this._url);
|
||||
}
|
||||
|
||||
set href(v) {
|
||||
const parsedURL = usm.basicURLParse(v);
|
||||
if (parsedURL === null) {
|
||||
throw new TypeError(`Invalid URL: ${v}`);
|
||||
}
|
||||
|
||||
this._url = parsedURL;
|
||||
|
||||
this._query._list.splice(0);
|
||||
const { query } = parsedURL;
|
||||
if (query !== null) {
|
||||
this._query._list = urlencoded.parseUrlencodedString(query);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
const url = this._url;
|
||||
|
||||
if (v === "") {
|
||||
url.query = null;
|
||||
this._query._list = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const input = v[0] === "?" ? v.substring(1) : v;
|
||||
url.query = "";
|
||||
usm.basicURLParse(input, { url, stateOverride: "query" });
|
||||
this._query._list = urlencoded.parseUrlencodedString(input);
|
||||
}
|
||||
|
||||
get searchParams() {
|
||||
return this._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;
|
||||
}
|
||||
};
|
417
node_modules/whatwg-url/dist/URL.js
generated
vendored
Normal file
417
node_modules/whatwg-url/dist/URL.js
generated
vendored
Normal file
|
@ -0,0 +1,417 @@
|
|||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
const interfaceName = "URL";
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'URL'.`);
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["URL"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor URL is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class URL {
|
||||
constructor(url) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'URL': 1 argument required, but only " + arguments.length + " present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to construct 'URL': parameter 1" });
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
if (curArg !== undefined) {
|
||||
curArg = conversions["USVString"](curArg, { context: "Failed to construct 'URL': parameter 2" });
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'toJSON' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol].toJSON();
|
||||
}
|
||||
|
||||
get href() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'get href' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["href"];
|
||||
}
|
||||
|
||||
set href(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'set href' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'href' property on 'URL': The provided value" });
|
||||
|
||||
esValue[implSymbol]["href"] = V;
|
||||
}
|
||||
|
||||
toString() {
|
||||
const esValue = this;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'toString' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["href"];
|
||||
}
|
||||
|
||||
get origin() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'get origin' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["origin"];
|
||||
}
|
||||
|
||||
get protocol() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'get protocol' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["protocol"];
|
||||
}
|
||||
|
||||
set protocol(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'set protocol' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'protocol' property on 'URL': The provided value"
|
||||
});
|
||||
|
||||
esValue[implSymbol]["protocol"] = V;
|
||||
}
|
||||
|
||||
get username() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'get username' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["username"];
|
||||
}
|
||||
|
||||
set username(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'set username' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'username' property on 'URL': The provided value"
|
||||
});
|
||||
|
||||
esValue[implSymbol]["username"] = V;
|
||||
}
|
||||
|
||||
get password() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'get password' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["password"];
|
||||
}
|
||||
|
||||
set password(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'set password' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'password' property on 'URL': The provided value"
|
||||
});
|
||||
|
||||
esValue[implSymbol]["password"] = V;
|
||||
}
|
||||
|
||||
get host() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'get host' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["host"];
|
||||
}
|
||||
|
||||
set host(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'set host' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'host' property on 'URL': The provided value" });
|
||||
|
||||
esValue[implSymbol]["host"] = V;
|
||||
}
|
||||
|
||||
get hostname() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'get hostname' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["hostname"];
|
||||
}
|
||||
|
||||
set hostname(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'set hostname' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'hostname' property on 'URL': The provided value"
|
||||
});
|
||||
|
||||
esValue[implSymbol]["hostname"] = V;
|
||||
}
|
||||
|
||||
get port() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'get port' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["port"];
|
||||
}
|
||||
|
||||
set port(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'set port' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'port' property on 'URL': The provided value" });
|
||||
|
||||
esValue[implSymbol]["port"] = V;
|
||||
}
|
||||
|
||||
get pathname() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'get pathname' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["pathname"];
|
||||
}
|
||||
|
||||
set pathname(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'set pathname' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, {
|
||||
context: "Failed to set the 'pathname' property on 'URL': The provided value"
|
||||
});
|
||||
|
||||
esValue[implSymbol]["pathname"] = V;
|
||||
}
|
||||
|
||||
get search() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'get search' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["search"];
|
||||
}
|
||||
|
||||
set search(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'set search' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'search' property on 'URL': The provided value" });
|
||||
|
||||
esValue[implSymbol]["search"] = V;
|
||||
}
|
||||
|
||||
get searchParams() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'get searchParams' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return utils.getSameObject(this, "searchParams", () => {
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol]["searchParams"]);
|
||||
});
|
||||
}
|
||||
|
||||
get hash() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'get hash' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol]["hash"];
|
||||
}
|
||||
|
||||
set hash(V) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'set hash' called on an object that is not a valid instance of URL.");
|
||||
}
|
||||
|
||||
V = conversions["USVString"](V, { context: "Failed to set the 'hash' property on 'URL': The provided value" });
|
||||
|
||||
esValue[implSymbol]["hash"] = V;
|
||||
}
|
||||
}
|
||||
Object.defineProperties(URL.prototype, {
|
||||
toJSON: { enumerable: true },
|
||||
href: { enumerable: true },
|
||||
toString: { enumerable: true },
|
||||
origin: { enumerable: true },
|
||||
protocol: { enumerable: true },
|
||||
username: { enumerable: true },
|
||||
password: { enumerable: true },
|
||||
host: { enumerable: true },
|
||||
hostname: { enumerable: true },
|
||||
port: { enumerable: true },
|
||||
pathname: { enumerable: true },
|
||||
search: { enumerable: true },
|
||||
searchParams: { enumerable: true },
|
||||
hash: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "URL", configurable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = URL;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: URL
|
||||
});
|
||||
|
||||
if (globalNames.includes("Window")) {
|
||||
Object.defineProperty(globalObject, "webkitURL", {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: URL
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const Impl = require("./URL-impl.js");
|
122
node_modules/whatwg-url/dist/URLSearchParams-impl.js
generated
vendored
Normal file
122
node_modules/whatwg-url/dist/URLSearchParams-impl.js
generated
vendored
Normal file
|
@ -0,0 +1,122 @@
|
|||
"use strict";
|
||||
const stableSortBy = require("lodash.sortby");
|
||||
const urlencoded = require("./urlencoded");
|
||||
|
||||
exports.implementation = class URLSearchParamsImpl {
|
||||
constructor(globalObject, constructorArgs, { doNotStripQMark = false }) {
|
||||
let init = constructorArgs[0];
|
||||
this._list = [];
|
||||
this._url = null;
|
||||
|
||||
if (!doNotStripQMark && typeof init === "string" && init[0] === "?") {
|
||||
init = init.slice(1);
|
||||
}
|
||||
|
||||
if (Array.isArray(init)) {
|
||||
for (const pair of init) {
|
||||
if (pair.length !== 2) {
|
||||
throw new TypeError("Failed to construct 'URLSearchParams': parameter 1 sequence's element does not " +
|
||||
"contain exactly two elements.");
|
||||
}
|
||||
this._list.push([pair[0], pair[1]]);
|
||||
}
|
||||
} else if (typeof init === "object" && Object.getPrototypeOf(init) === null) {
|
||||
for (const name of Object.keys(init)) {
|
||||
const value = init[name];
|
||||
this._list.push([name, value]);
|
||||
}
|
||||
} else {
|
||||
this._list = urlencoded.parseUrlencodedString(init);
|
||||
}
|
||||
}
|
||||
|
||||
_updateSteps() {
|
||||
if (this._url !== null) {
|
||||
let query = urlencoded.serializeUrlencoded(this._list);
|
||||
if (query === "") {
|
||||
query = null;
|
||||
}
|
||||
this._url._url.query = query;
|
||||
}
|
||||
}
|
||||
|
||||
append(name, value) {
|
||||
this._list.push([name, value]);
|
||||
this._updateSteps();
|
||||
}
|
||||
|
||||
delete(name) {
|
||||
let i = 0;
|
||||
while (i < this._list.length) {
|
||||
if (this._list[i][0] === name) {
|
||||
this._list.splice(i, 1);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
this._updateSteps();
|
||||
}
|
||||
|
||||
get(name) {
|
||||
for (const tuple of this._list) {
|
||||
if (tuple[0] === name) {
|
||||
return tuple[1];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getAll(name) {
|
||||
const output = [];
|
||||
for (const tuple of this._list) {
|
||||
if (tuple[0] === name) {
|
||||
output.push(tuple[1]);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
has(name) {
|
||||
for (const tuple of this._list) {
|
||||
if (tuple[0] === name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
set(name, value) {
|
||||
let found = false;
|
||||
let i = 0;
|
||||
while (i < this._list.length) {
|
||||
if (this._list[i][0] === name) {
|
||||
if (found) {
|
||||
this._list.splice(i, 1);
|
||||
} else {
|
||||
found = true;
|
||||
this._list[i][1] = value;
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
this._list.push([name, value]);
|
||||
}
|
||||
this._updateSteps();
|
||||
}
|
||||
|
||||
sort() {
|
||||
this._list = stableSortBy(this._list, [0]);
|
||||
this._updateSteps();
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this._list[Symbol.iterator]();
|
||||
}
|
||||
|
||||
toString() {
|
||||
return urlencoded.serializeUrlencoded(this._list);
|
||||
}
|
||||
};
|
457
node_modules/whatwg-url/dist/URLSearchParams.js
generated
vendored
Normal file
457
node_modules/whatwg-url/dist/URLSearchParams.js
generated
vendored
Normal file
|
@ -0,0 +1,457 @@
|
|||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
const Function = require("./Function.js");
|
||||
const implSymbol = utils.implSymbol;
|
||||
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
|
||||
|
||||
const interfaceName = "URLSearchParams";
|
||||
|
||||
const IteratorPrototype = Object.create(utils.IteratorPrototype, {
|
||||
next: {
|
||||
value: function next() {
|
||||
const internal = this && this[utils.iterInternalSymbol];
|
||||
if (!internal) {
|
||||
throw new TypeError("next() called on a value that is not an iterator prototype object");
|
||||
}
|
||||
|
||||
const { target, kind, index } = internal;
|
||||
const values = Array.from(target[implSymbol]);
|
||||
const len = values.length;
|
||||
if (index >= len) {
|
||||
return { value: undefined, done: true };
|
||||
}
|
||||
|
||||
const pair = values[index];
|
||||
internal.index = index + 1;
|
||||
return utils.iteratorResult(pair.map(utils.tryWrapperForImpl), kind);
|
||||
},
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
},
|
||||
[Symbol.toStringTag]: {
|
||||
value: "URLSearchParams Iterator",
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
exports.is = value => {
|
||||
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
|
||||
};
|
||||
exports.isImpl = value => {
|
||||
return utils.isObject(value) && value instanceof Impl.implementation;
|
||||
};
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (exports.is(value)) {
|
||||
return utils.implForWrapper(value);
|
||||
}
|
||||
throw new TypeError(`${context} is not of type 'URLSearchParams'.`);
|
||||
};
|
||||
|
||||
exports.createDefaultIterator = (target, kind) => {
|
||||
const iterator = Object.create(IteratorPrototype);
|
||||
Object.defineProperty(iterator, utils.iterInternalSymbol, {
|
||||
value: { target, kind, index: 0 },
|
||||
configurable: true
|
||||
});
|
||||
return iterator;
|
||||
};
|
||||
|
||||
function makeWrapper(globalObject) {
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
throw new Error("Internal error: invalid global object");
|
||||
}
|
||||
|
||||
const ctor = globalObject[ctorRegistrySymbol]["URLSearchParams"];
|
||||
if (ctor === undefined) {
|
||||
throw new Error("Internal error: constructor URLSearchParams is not installed on the passed global object");
|
||||
}
|
||||
|
||||
return Object.create(ctor.prototype);
|
||||
}
|
||||
|
||||
exports.create = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
|
||||
};
|
||||
|
||||
exports.createImpl = (globalObject, constructorArgs, privateData) => {
|
||||
const wrapper = exports.create(globalObject, constructorArgs, privateData);
|
||||
return utils.implForWrapper(wrapper);
|
||||
};
|
||||
|
||||
exports._internalSetup = (wrapper, globalObject) => {};
|
||||
|
||||
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
|
||||
privateData.wrapper = wrapper;
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: new Impl.implementation(globalObject, constructorArgs, privateData),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.new = globalObject => {
|
||||
const wrapper = makeWrapper(globalObject);
|
||||
|
||||
exports._internalSetup(wrapper, globalObject);
|
||||
Object.defineProperty(wrapper, implSymbol, {
|
||||
value: Object.create(Impl.implementation.prototype),
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
|
||||
if (Impl.init) {
|
||||
Impl.init(wrapper[implSymbol]);
|
||||
}
|
||||
return wrapper[implSymbol];
|
||||
};
|
||||
|
||||
const exposed = new Set(["Window", "Worker"]);
|
||||
|
||||
exports.install = (globalObject, globalNames) => {
|
||||
if (!globalNames.some(globalName => exposed.has(globalName))) {
|
||||
return;
|
||||
}
|
||||
class URLSearchParams {
|
||||
constructor() {
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
if (curArg !== undefined) {
|
||||
if (utils.isObject(curArg)) {
|
||||
if (curArg[Symbol.iterator] !== undefined) {
|
||||
if (!utils.isObject(curArg)) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'URLSearchParams': parameter 1" + " sequence" + " is not an iterable object."
|
||||
);
|
||||
} else {
|
||||
const V = [];
|
||||
const tmp = curArg;
|
||||
for (let nextItem of tmp) {
|
||||
if (!utils.isObject(nextItem)) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'URLSearchParams': parameter 1" +
|
||||
" sequence" +
|
||||
"'s element" +
|
||||
" is not an iterable object."
|
||||
);
|
||||
} else {
|
||||
const V = [];
|
||||
const tmp = nextItem;
|
||||
for (let nextItem of tmp) {
|
||||
nextItem = conversions["USVString"](nextItem, {
|
||||
context:
|
||||
"Failed to construct 'URLSearchParams': parameter 1" +
|
||||
" sequence" +
|
||||
"'s element" +
|
||||
"'s element"
|
||||
});
|
||||
|
||||
V.push(nextItem);
|
||||
}
|
||||
nextItem = V;
|
||||
}
|
||||
|
||||
V.push(nextItem);
|
||||
}
|
||||
curArg = V;
|
||||
}
|
||||
} else {
|
||||
if (!utils.isObject(curArg)) {
|
||||
throw new TypeError(
|
||||
"Failed to construct 'URLSearchParams': parameter 1" + " record" + " is not an object."
|
||||
);
|
||||
} else {
|
||||
const result = Object.create(null);
|
||||
for (const key of Reflect.ownKeys(curArg)) {
|
||||
const desc = Object.getOwnPropertyDescriptor(curArg, key);
|
||||
if (desc && desc.enumerable) {
|
||||
let typedKey = key;
|
||||
|
||||
typedKey = conversions["USVString"](typedKey, {
|
||||
context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s key"
|
||||
});
|
||||
|
||||
let typedValue = curArg[key];
|
||||
|
||||
typedValue = conversions["USVString"](typedValue, {
|
||||
context: "Failed to construct 'URLSearchParams': parameter 1" + " record" + "'s value"
|
||||
});
|
||||
|
||||
result[typedKey] = typedValue;
|
||||
}
|
||||
}
|
||||
curArg = result;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to construct 'URLSearchParams': parameter 1"
|
||||
});
|
||||
}
|
||||
} else {
|
||||
curArg = "";
|
||||
}
|
||||
args.push(curArg);
|
||||
}
|
||||
return exports.setup(Object.create(new.target.prototype), globalObject, args);
|
||||
}
|
||||
|
||||
append(name, value) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'append' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'append' on 'URLSearchParams': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'append' on 'URLSearchParams': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'append' on 'URLSearchParams': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].append(...args);
|
||||
}
|
||||
|
||||
delete(name) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'delete' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'delete' on 'URLSearchParams': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'delete' on 'URLSearchParams': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].delete(...args);
|
||||
}
|
||||
|
||||
get(name) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'get' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'get' on 'URLSearchParams': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'get' on 'URLSearchParams': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].get(...args);
|
||||
}
|
||||
|
||||
getAll(name) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'getAll' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'getAll' on 'URLSearchParams': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'getAll' on 'URLSearchParams': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return utils.tryWrapperForImpl(esValue[implSymbol].getAll(...args));
|
||||
}
|
||||
|
||||
has(name) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'has' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'has' on 'URLSearchParams': 1 argument required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'has' on 'URLSearchParams': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].has(...args);
|
||||
}
|
||||
|
||||
set(name, value) {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'set' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw new TypeError(
|
||||
"Failed to execute 'set' on 'URLSearchParams': 2 arguments required, but only " +
|
||||
arguments.length +
|
||||
" present."
|
||||
);
|
||||
}
|
||||
const args = [];
|
||||
{
|
||||
let curArg = arguments[0];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'set' on 'URLSearchParams': parameter 1"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
{
|
||||
let curArg = arguments[1];
|
||||
curArg = conversions["USVString"](curArg, {
|
||||
context: "Failed to execute 'set' on 'URLSearchParams': parameter 2"
|
||||
});
|
||||
args.push(curArg);
|
||||
}
|
||||
return esValue[implSymbol].set(...args);
|
||||
}
|
||||
|
||||
sort() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'sort' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol].sort();
|
||||
}
|
||||
|
||||
toString() {
|
||||
const esValue = this !== null && this !== undefined ? this : globalObject;
|
||||
if (!exports.is(esValue)) {
|
||||
throw new TypeError("'toString' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
|
||||
return esValue[implSymbol].toString();
|
||||
}
|
||||
|
||||
keys() {
|
||||
if (!exports.is(this)) {
|
||||
throw new TypeError("'keys' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
return exports.createDefaultIterator(this, "key");
|
||||
}
|
||||
|
||||
values() {
|
||||
if (!exports.is(this)) {
|
||||
throw new TypeError("'values' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
return exports.createDefaultIterator(this, "value");
|
||||
}
|
||||
|
||||
entries() {
|
||||
if (!exports.is(this)) {
|
||||
throw new TypeError("'entries' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
return exports.createDefaultIterator(this, "key+value");
|
||||
}
|
||||
|
||||
forEach(callback) {
|
||||
if (!exports.is(this)) {
|
||||
throw new TypeError("'forEach' called on an object that is not a valid instance of URLSearchParams.");
|
||||
}
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError("Failed to execute 'forEach' on 'iterable': 1 argument required, " + "but only 0 present.");
|
||||
}
|
||||
callback = Function.convert(callback, {
|
||||
context: "Failed to execute 'forEach' on 'iterable': The callback provided as parameter 1"
|
||||
});
|
||||
const thisArg = arguments[1];
|
||||
let pairs = Array.from(this[implSymbol]);
|
||||
let i = 0;
|
||||
while (i < pairs.length) {
|
||||
const [key, value] = pairs[i].map(utils.tryWrapperForImpl);
|
||||
callback.call(thisArg, value, key, this);
|
||||
pairs = Array.from(this[implSymbol]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Object.defineProperties(URLSearchParams.prototype, {
|
||||
append: { enumerable: true },
|
||||
delete: { enumerable: true },
|
||||
get: { enumerable: true },
|
||||
getAll: { enumerable: true },
|
||||
has: { enumerable: true },
|
||||
set: { enumerable: true },
|
||||
sort: { enumerable: true },
|
||||
toString: { enumerable: true },
|
||||
keys: { enumerable: true },
|
||||
values: { enumerable: true },
|
||||
entries: { enumerable: true },
|
||||
forEach: { enumerable: true },
|
||||
[Symbol.toStringTag]: { value: "URLSearchParams", configurable: true },
|
||||
[Symbol.iterator]: { value: URLSearchParams.prototype.entries, configurable: true, writable: true }
|
||||
});
|
||||
if (globalObject[ctorRegistrySymbol] === undefined) {
|
||||
globalObject[ctorRegistrySymbol] = Object.create(null);
|
||||
}
|
||||
globalObject[ctorRegistrySymbol][interfaceName] = URLSearchParams;
|
||||
|
||||
Object.defineProperty(globalObject, interfaceName, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: URLSearchParams
|
||||
});
|
||||
};
|
||||
|
||||
const Impl = require("./URLSearchParams-impl.js");
|
30
node_modules/whatwg-url/dist/VoidFunction.js
generated
vendored
Normal file
30
node_modules/whatwg-url/dist/VoidFunction.js
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
"use strict";
|
||||
|
||||
const conversions = require("webidl-conversions");
|
||||
const utils = require("./utils.js");
|
||||
|
||||
exports.convert = (value, { context = "The provided value" } = {}) => {
|
||||
if (typeof value !== "function") {
|
||||
throw new TypeError(context + " is not a function");
|
||||
}
|
||||
|
||||
function invokeTheCallbackFunction() {
|
||||
if (new.target !== undefined) {
|
||||
throw new Error("Internal error: invokeTheCallbackFunction is not a constructor");
|
||||
}
|
||||
|
||||
const thisArg = utils.tryWrapperForImpl(this);
|
||||
let callResult;
|
||||
|
||||
callResult = Reflect.apply(value, thisArg, []);
|
||||
}
|
||||
|
||||
invokeTheCallbackFunction.construct = () => {
|
||||
let callResult = Reflect.construct(value, []);
|
||||
};
|
||||
|
||||
invokeTheCallbackFunction[utils.wrapperSymbol] = value;
|
||||
invokeTheCallbackFunction.objectReference = value;
|
||||
|
||||
return invokeTheCallbackFunction;
|
||||
};
|
26
node_modules/whatwg-url/dist/encoding.js
generated
vendored
Normal file
26
node_modules/whatwg-url/dist/encoding.js
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
"use strict";
|
||||
let { TextEncoder, TextDecoder } = require("util");
|
||||
// Handle browserify's lack of support (https://github.com/browserify/node-util/issues/46), which
|
||||
// is important for the live viewer:
|
||||
if (!TextEncoder) {
|
||||
TextEncoder = global.TextEncoder;
|
||||
}
|
||||
if (!TextDecoder) {
|
||||
TextDecoder = global.TextDecoder;
|
||||
}
|
||||
|
||||
const utf8Encoder = new TextEncoder();
|
||||
const utf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
||||
|
||||
function utf8Encode(string) {
|
||||
return utf8Encoder.encode(string);
|
||||
}
|
||||
|
||||
function utf8DecodeWithoutBOM(bytes) {
|
||||
return utf8Decoder.decode(bytes);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
utf8Encode,
|
||||
utf8DecodeWithoutBOM
|
||||
};
|
26
node_modules/whatwg-url/dist/infra.js
generated
vendored
Normal file
26
node_modules/whatwg-url/dist/infra.js
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
"use strict";
|
||||
|
||||
// Note that we take code points as JS numbers, not JS strings.
|
||||
|
||||
function isASCIIDigit(c) {
|
||||
return c >= 0x30 && c <= 0x39;
|
||||
}
|
||||
|
||||
function isASCIIAlpha(c) {
|
||||
return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A);
|
||||
}
|
||||
|
||||
function isASCIIAlphanumeric(c) {
|
||||
return isASCIIAlpha(c) || isASCIIDigit(c);
|
||||
}
|
||||
|
||||
function isASCIIHex(c) {
|
||||
return isASCIIDigit(c) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isASCIIDigit,
|
||||
isASCIIAlpha,
|
||||
isASCIIAlphanumeric,
|
||||
isASCIIHex
|
||||
};
|
141
node_modules/whatwg-url/dist/percent-encoding.js
generated
vendored
Normal file
141
node_modules/whatwg-url/dist/percent-encoding.js
generated
vendored
Normal file
|
@ -0,0 +1,141 @@
|
|||
"use strict";
|
||||
const { isASCIIHex } = require("./infra");
|
||||
const { utf8Encode } = require("./encoding");
|
||||
|
||||
// https://url.spec.whatwg.org/#percent-encode
|
||||
function percentEncode(c) {
|
||||
let hex = c.toString(16).toUpperCase();
|
||||
if (hex.length === 1) {
|
||||
hex = "0" + hex;
|
||||
}
|
||||
|
||||
return "%" + hex;
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#percent-decode
|
||||
function percentDecodeBytes(input) {
|
||||
const output = new Uint8Array(input.byteLength);
|
||||
let outputIndex = 0;
|
||||
for (let i = 0; i < input.byteLength; ++i) {
|
||||
const byte = input[i];
|
||||
if (byte !== 0x25) {
|
||||
output[outputIndex++] = byte;
|
||||
} else if (byte === 0x25 && (!isASCIIHex(input[i + 1]) || !isASCIIHex(input[i + 2]))) {
|
||||
output[outputIndex++] = byte;
|
||||
} else {
|
||||
const bytePoint = parseInt(String.fromCodePoint(input[i + 1], input[i + 2]), 16);
|
||||
output[outputIndex++] = bytePoint;
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: remove the Buffer.from in the next major version; it's only needed for back-compat, and sticking to standard
|
||||
// typed arrays is nicer and simpler.
|
||||
// See https://github.com/jsdom/data-urls/issues/17 for background.
|
||||
return Buffer.from(output.slice(0, outputIndex));
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#string-percent-decode
|
||||
function percentDecodeString(input) {
|
||||
const bytes = utf8Encode(input);
|
||||
return percentDecodeBytes(bytes);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#c0-control-percent-encode-set
|
||||
function isC0ControlPercentEncode(c) {
|
||||
return c <= 0x1F || c > 0x7E;
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#fragment-percent-encode-set
|
||||
const extraFragmentPercentEncodeSet = new Set([32, 34, 60, 62, 96]);
|
||||
function isFragmentPercentEncode(c) {
|
||||
return isC0ControlPercentEncode(c) || extraFragmentPercentEncodeSet.has(c);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#query-percent-encode-set
|
||||
const extraQueryPercentEncodeSet = new Set([32, 34, 35, 60, 62]);
|
||||
function isQueryPercentEncode(c) {
|
||||
return isC0ControlPercentEncode(c) || extraQueryPercentEncodeSet.has(c);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#special-query-percent-encode-set
|
||||
function isSpecialQueryPercentEncode(c) {
|
||||
return isQueryPercentEncode(c) || c === 39;
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#path-percent-encode-set
|
||||
const extraPathPercentEncodeSet = new Set([63, 96, 123, 125]);
|
||||
function isPathPercentEncode(c) {
|
||||
return isQueryPercentEncode(c) || extraPathPercentEncodeSet.has(c);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#userinfo-percent-encode-set
|
||||
const extraUserinfoPercentEncodeSet =
|
||||
new Set([47, 58, 59, 61, 64, 91, 92, 93, 94, 124]);
|
||||
function isUserinfoPercentEncode(c) {
|
||||
return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#component-percent-encode-set
|
||||
const extraComponentPercentEncodeSet = new Set([36, 37, 38, 43, 44]);
|
||||
function isComponentPercentEncode(c) {
|
||||
return isUserinfoPercentEncode(c) || extraComponentPercentEncodeSet.has(c);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#application-x-www-form-urlencoded-percent-encode-set
|
||||
const extraURLEncodedPercentEncodeSet = new Set([33, 39, 40, 41, 126]);
|
||||
function isURLEncodedPercentEncode(c) {
|
||||
return isComponentPercentEncode(c) || extraURLEncodedPercentEncodeSet.has(c);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#code-point-percent-encode-after-encoding
|
||||
// https://url.spec.whatwg.org/#utf-8-percent-encode
|
||||
// Assuming encoding is always utf-8 allows us to trim one of the logic branches. TODO: support encoding.
|
||||
// The "-Internal" variant here has code points as JS strings. The external version used by other files has code points
|
||||
// as JS numbers, like the rest of the codebase.
|
||||
function utf8PercentEncodeCodePointInternal(codePoint, percentEncodePredicate) {
|
||||
const bytes = utf8Encode(codePoint);
|
||||
let output = "";
|
||||
for (const byte of bytes) {
|
||||
// Our percentEncodePredicate operates on bytes, not code points, so this is slightly different from the spec.
|
||||
if (!percentEncodePredicate(byte)) {
|
||||
output += String.fromCharCode(byte);
|
||||
} else {
|
||||
output += percentEncode(byte);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
function utf8PercentEncodeCodePoint(codePoint, percentEncodePredicate) {
|
||||
return utf8PercentEncodeCodePointInternal(String.fromCodePoint(codePoint), percentEncodePredicate);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#string-percent-encode-after-encoding
|
||||
// https://url.spec.whatwg.org/#string-utf-8-percent-encode
|
||||
function utf8PercentEncodeString(input, percentEncodePredicate, spaceAsPlus = false) {
|
||||
let output = "";
|
||||
for (const codePoint of input) {
|
||||
if (spaceAsPlus && codePoint === " ") {
|
||||
output += "+";
|
||||
} else {
|
||||
output += utf8PercentEncodeCodePointInternal(codePoint, percentEncodePredicate);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isC0ControlPercentEncode,
|
||||
isFragmentPercentEncode,
|
||||
isQueryPercentEncode,
|
||||
isSpecialQueryPercentEncode,
|
||||
isPathPercentEncode,
|
||||
isUserinfoPercentEncode,
|
||||
isURLEncodedPercentEncode,
|
||||
percentDecodeString,
|
||||
percentDecodeBytes,
|
||||
utf8PercentEncodeString,
|
||||
utf8PercentEncodeCodePoint
|
||||
};
|
1203
node_modules/whatwg-url/dist/url-state-machine.js
generated
vendored
Normal file
1203
node_modules/whatwg-url/dist/url-state-machine.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
103
node_modules/whatwg-url/dist/urlencoded.js
generated
vendored
Normal file
103
node_modules/whatwg-url/dist/urlencoded.js
generated
vendored
Normal file
|
@ -0,0 +1,103 @@
|
|||
"use strict";
|
||||
const { utf8Encode, utf8DecodeWithoutBOM } = require("./encoding");
|
||||
const { percentDecodeBytes, utf8PercentEncodeString, isURLEncodedPercentEncode } = require("./percent-encoding");
|
||||
|
||||
// https://url.spec.whatwg.org/#concept-urlencoded-parser
|
||||
function parseUrlencoded(input) {
|
||||
const sequences = strictlySplitByteSequence(input, 38);
|
||||
const output = [];
|
||||
for (const bytes of sequences) {
|
||||
if (bytes.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let name;
|
||||
let value;
|
||||
const indexOfEqual = bytes.indexOf(61);
|
||||
|
||||
if (indexOfEqual >= 0) {
|
||||
name = bytes.slice(0, indexOfEqual);
|
||||
value = bytes.slice(indexOfEqual + 1);
|
||||
} else {
|
||||
name = bytes;
|
||||
value = new Uint8Array(0);
|
||||
}
|
||||
|
||||
name = replaceByteInByteSequence(name, 0x2B, 0x20);
|
||||
value = replaceByteInByteSequence(value, 0x2B, 0x20);
|
||||
|
||||
const nameString = utf8DecodeWithoutBOM(percentDecodeBytes(name));
|
||||
const valueString = utf8DecodeWithoutBOM(percentDecodeBytes(value));
|
||||
|
||||
output.push([nameString, valueString]);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#concept-urlencoded-string-parser
|
||||
function parseUrlencodedString(input) {
|
||||
return parseUrlencoded(utf8Encode(input));
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#concept-urlencoded-serializer
|
||||
function serializeUrlencoded(tuples, encodingOverride = undefined) {
|
||||
let encoding = "utf-8";
|
||||
if (encodingOverride !== undefined) {
|
||||
// TODO "get the output encoding", i.e. handle encoding labels vs. names.
|
||||
encoding = encodingOverride;
|
||||
}
|
||||
|
||||
let output = "";
|
||||
for (const [i, tuple] of tuples.entries()) {
|
||||
// TODO: handle encoding override
|
||||
|
||||
const name = utf8PercentEncodeString(tuple[0], isURLEncodedPercentEncode, true);
|
||||
|
||||
let value = tuple[1];
|
||||
if (tuple.length > 2 && tuple[2] !== undefined) {
|
||||
if (tuple[2] === "hidden" && name === "_charset_") {
|
||||
value = encoding;
|
||||
} else if (tuple[2] === "file") {
|
||||
// value is a File object
|
||||
value = value.name;
|
||||
}
|
||||
}
|
||||
|
||||
value = utf8PercentEncodeString(value, isURLEncodedPercentEncode, true);
|
||||
|
||||
if (i !== 0) {
|
||||
output += "&";
|
||||
}
|
||||
output += `${name}=${value}`;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
function strictlySplitByteSequence(buf, cp) {
|
||||
const list = [];
|
||||
let last = 0;
|
||||
let i = buf.indexOf(cp);
|
||||
while (i >= 0) {
|
||||
list.push(buf.slice(last, i));
|
||||
last = i + 1;
|
||||
i = buf.indexOf(cp, last);
|
||||
}
|
||||
if (last !== buf.length) {
|
||||
list.push(buf.slice(last));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
function replaceByteInByteSequence(buf, from, to) {
|
||||
let i = buf.indexOf(from);
|
||||
while (i >= 0) {
|
||||
buf[i] = to;
|
||||
i = buf.indexOf(from, i + 1);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
parseUrlencodedString,
|
||||
serializeUrlencoded
|
||||
};
|
141
node_modules/whatwg-url/dist/utils.js
generated
vendored
Normal file
141
node_modules/whatwg-url/dist/utils.js
generated
vendored
Normal file
|
@ -0,0 +1,141 @@
|
|||
"use strict";
|
||||
|
||||
// Returns "Type(value) is Object" in ES terminology.
|
||||
function isObject(value) {
|
||||
return typeof value === "object" && value !== null || typeof value === "function";
|
||||
}
|
||||
|
||||
const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
|
||||
|
||||
const wrapperSymbol = Symbol("wrapper");
|
||||
const implSymbol = Symbol("impl");
|
||||
const sameObjectCaches = Symbol("SameObject caches");
|
||||
const ctorRegistrySymbol = Symbol.for("[webidl2js] constructor registry");
|
||||
|
||||
function getSameObject(wrapper, prop, creator) {
|
||||
if (!wrapper[sameObjectCaches]) {
|
||||
wrapper[sameObjectCaches] = Object.create(null);
|
||||
}
|
||||
|
||||
if (prop in wrapper[sameObjectCaches]) {
|
||||
return wrapper[sameObjectCaches][prop];
|
||||
}
|
||||
|
||||
wrapper[sameObjectCaches][prop] = creator();
|
||||
return wrapper[sameObjectCaches][prop];
|
||||
}
|
||||
|
||||
function wrapperForImpl(impl) {
|
||||
return impl ? impl[wrapperSymbol] : null;
|
||||
}
|
||||
|
||||
function implForWrapper(wrapper) {
|
||||
return wrapper ? wrapper[implSymbol] : null;
|
||||
}
|
||||
|
||||
function tryWrapperForImpl(impl) {
|
||||
const wrapper = wrapperForImpl(impl);
|
||||
return wrapper ? wrapper : impl;
|
||||
}
|
||||
|
||||
function tryImplForWrapper(wrapper) {
|
||||
const impl = implForWrapper(wrapper);
|
||||
return impl ? impl : wrapper;
|
||||
}
|
||||
|
||||
const iterInternalSymbol = Symbol("internal");
|
||||
const IteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()));
|
||||
const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype);
|
||||
|
||||
function isArrayIndexPropName(P) {
|
||||
if (typeof P !== "string") {
|
||||
return false;
|
||||
}
|
||||
const i = P >>> 0;
|
||||
if (i === Math.pow(2, 32) - 1) {
|
||||
return false;
|
||||
}
|
||||
const s = `${i}`;
|
||||
if (P !== s) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const byteLengthGetter =
|
||||
Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
|
||||
function isArrayBuffer(value) {
|
||||
try {
|
||||
byteLengthGetter.call(value);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function iteratorResult([key, value], kind) {
|
||||
let result;
|
||||
switch (kind) {
|
||||
case "key":
|
||||
result = key;
|
||||
break;
|
||||
case "value":
|
||||
result = value;
|
||||
break;
|
||||
case "key+value":
|
||||
result = [key, value];
|
||||
break;
|
||||
}
|
||||
return { value: result, done: false };
|
||||
}
|
||||
|
||||
const supportsPropertyIndex = Symbol("supports property index");
|
||||
const supportedPropertyIndices = Symbol("supported property indices");
|
||||
const supportsPropertyName = Symbol("supports property name");
|
||||
const supportedPropertyNames = Symbol("supported property names");
|
||||
const indexedGet = Symbol("indexed property get");
|
||||
const indexedSetNew = Symbol("indexed property set new");
|
||||
const indexedSetExisting = Symbol("indexed property set existing");
|
||||
const namedGet = Symbol("named property get");
|
||||
const namedSetNew = Symbol("named property set new");
|
||||
const namedSetExisting = Symbol("named property set existing");
|
||||
const namedDelete = Symbol("named property delete");
|
||||
|
||||
const asyncIteratorNext = Symbol("async iterator get the next iteration result");
|
||||
const asyncIteratorReturn = Symbol("async iterator return steps");
|
||||
const asyncIteratorInit = Symbol("async iterator initialization steps");
|
||||
const asyncIteratorEOI = Symbol("async iterator end of iteration");
|
||||
|
||||
module.exports = exports = {
|
||||
isObject,
|
||||
hasOwn,
|
||||
wrapperSymbol,
|
||||
implSymbol,
|
||||
getSameObject,
|
||||
ctorRegistrySymbol,
|
||||
wrapperForImpl,
|
||||
implForWrapper,
|
||||
tryWrapperForImpl,
|
||||
tryImplForWrapper,
|
||||
iterInternalSymbol,
|
||||
IteratorPrototype,
|
||||
AsyncIteratorPrototype,
|
||||
isArrayBuffer,
|
||||
isArrayIndexPropName,
|
||||
supportsPropertyIndex,
|
||||
supportedPropertyIndices,
|
||||
supportsPropertyName,
|
||||
supportedPropertyNames,
|
||||
indexedGet,
|
||||
indexedSetNew,
|
||||
indexedSetExisting,
|
||||
namedGet,
|
||||
namedSetNew,
|
||||
namedSetExisting,
|
||||
namedDelete,
|
||||
asyncIteratorNext,
|
||||
asyncIteratorReturn,
|
||||
asyncIteratorInit,
|
||||
asyncIteratorEOI,
|
||||
iteratorResult
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue