Dmitry S 4 years ago
commit
8c2bef5fdf
81 changed files with 10017 additions and 0 deletions
  1. 3 0
      .gitignore
  2. BIN
      data/emu/100/baseData.res
  3. 1 0
      data/emu/100/battleNotifications.res
  4. BIN
      data/emu/100/denylistData.res
  5. BIN
      data/emu/100/effects-override.res
  6. BIN
      data/emu/100/effects.res
  7. BIN
      data/emu/100/items-override.res
  8. BIN
      data/emu/100/items.res
  9. BIN
      data/emu/100/movements-tba.res
  10. BIN
      data/emu/100/movements.res
  11. BIN
      data/emu/100/skills-override-tba.res
  12. BIN
      data/emu/100/skills-override.res
  13. BIN
      data/emu/100/skills-tba.res
  14. BIN
      data/emu/100/skills.res
  15. 0 0
      data/internal/controlUI/index.html
  16. 328 0
      data/internal/controlUI/index.js
  17. 1110 0
      data/internal/controlUI/smoothie.js
  18. 7 0
      data/internal/controlUI/ubuntu-regular.css
  19. BIN
      data/internal/controlUI/ubuntu-v14-regular-full.woff2
  20. 0 0
      data/internal/definitions.js
  21. 0 0
      data/internal/settingsData.json
  22. 0 0
      data/internal/settingsSchema.js
  23. 0 0
      data/internal/strings.json
  24. 109 0
      index.js
  25. 0 0
      lib/core.js
  26. BIN
      lib/io/NextGenPingTool.exe
  27. 0 0
      lib/io/fetch.js
  28. 0 0
      lib/io/logger.js
  29. 0 0
      lib/state.js
  30. 0 0
      lib/submodules/abnormals.js
  31. 0 0
      lib/submodules/area.js
  32. 0 0
      lib/submodules/cd.js
  33. 0 0
      lib/submodules/control.js
  34. 0 0
      lib/submodules/defs.js
  35. 0 0
      lib/submodules/jitter.js
  36. 0 0
      lib/submodules/nap.js
  37. 0 0
      lib/submodules/notifications.js
  38. 0 0
      lib/submodules/ping.js
  39. 0 0
      lib/submodules/player.js
  40. 0 0
      lib/utils.js
  41. 0 0
      logs/.gitkeep
  42. 88 0
      manifest.json
  43. 11 0
      module.json
  44. 115 0
      node_modules/compare-versions/index.js
  45. 38 0
      node_modules/compare-versions/package.json
  46. 133 0
      node_modules/deepmerge/dist/cjs.js
  47. 139 0
      node_modules/deepmerge/dist/umd.js
  48. 106 0
      node_modules/deepmerge/index.js
  49. 21 0
      node_modules/deepmerge/license.txt
  50. 47 0
      node_modules/deepmerge/package.json
  51. 22 0
      node_modules/node-fetch/LICENSE.md
  52. 23 0
      node_modules/node-fetch/browser.js
  53. 1633 0
      node_modules/node-fetch/lib/index.es.js
  54. 1642 0
      node_modules/node-fetch/lib/index.js
  55. 1631 0
      node_modules/node-fetch/lib/index.mjs
  56. 70 0
      node_modules/node-fetch/package.json
  57. 147 0
      node_modules/rfdc/index.js
  58. 67 0
      node_modules/rfdc/package.json
  59. 117 0
      node_modules/schema-typed/es/ArrayType.js
  60. 45 0
      node_modules/schema-typed/es/BooleanType.js
  61. 71 0
      node_modules/schema-typed/es/DateType.js
  62. 99 0
      node_modules/schema-typed/es/NumberType.js
  63. 78 0
      node_modules/schema-typed/es/ObjectType.js
  64. 103 0
      node_modules/schema-typed/es/Schema.js
  65. 171 0
      node_modules/schema-typed/es/StringType.js
  66. 205 0
      node_modules/schema-typed/es/Type.js
  67. 76 0
      node_modules/schema-typed/es/index.js
  68. 117 0
      node_modules/schema-typed/lib/ArrayType.js
  69. 45 0
      node_modules/schema-typed/lib/BooleanType.js
  70. 71 0
      node_modules/schema-typed/lib/DateType.js
  71. 99 0
      node_modules/schema-typed/lib/NumberType.js
  72. 78 0
      node_modules/schema-typed/lib/ObjectType.js
  73. 103 0
      node_modules/schema-typed/lib/Schema.js
  74. 171 0
      node_modules/schema-typed/lib/StringType.js
  75. 205 0
      node_modules/schema-typed/lib/Type.js
  76. 76 0
      node_modules/schema-typed/lib/index.js
  77. 113 0
      node_modules/schema-typed/package.json
  78. 1 0
      package-lock.json
  79. 1 0
      package.json
  80. 433 0
      settings/emulation.js
  81. 48 0
      settings/settings.json

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+.eslintrc.json
+manifest-generator.bat
+manifest-generator.js

BIN
data/emu/100/baseData.res


+ 1 - 0
data/emu/100/battleNotifications.res

@@ -0,0 +1 @@
+¥SMk„0ý+’cèL5zí©¥=ô¶ìA³q+»jIÔ¶,ûß˸ÐC*ÛË›|À{“÷2g�"ßžEQ¶�ojD¾%D‰„H¨v 웳ÇǶw~,N"ODS·Ïnt'‘'1ˆÆ…PœÈŦ¡nQè‹Ö:q�ßܤÿAj�!ª|×D¯â²!gí+D¥n–èFçß»ç'ötÆž"&ˆ0ºy-ŠKz½K‘n}£õuƒ/fÞ¥ÓÃXeÑB³*—ÍË2¹LI.˜fâ5a»v?xÎ;*‡ªšœ#šYGH±ÆÛ£©:;„‰ünÆ­Q09h”ðVÆ4j>Ó|¦%ÿ&\e`Û…ÞÍ,mXÜpFIÚ°¤1	h“è,V1HB”(D¤ŸE<ÿ2ÄM�pŸö4ìÝSWò|&�îþÀÒ£ó_÷¶hçc˜I„LdR.ˆÊ•FØžã¸|

BIN
data/emu/100/denylistData.res


BIN
data/emu/100/effects-override.res


BIN
data/emu/100/effects.res


BIN
data/emu/100/items-override.res


BIN
data/emu/100/items.res


BIN
data/emu/100/movements-tba.res


BIN
data/emu/100/movements.res


BIN
data/emu/100/skills-override-tba.res


BIN
data/emu/100/skills-override.res


BIN
data/emu/100/skills-tba.res


BIN
data/emu/100/skills.res


File diff suppressed because it is too large
+ 0 - 0
data/internal/controlUI/index.html


+ 328 - 0
data/internal/controlUI/index.js

@@ -0,0 +1,328 @@
+"use strict";
+/* eslint-disable default-case */
+/* eslint-disable no-undef */
+document.addEventListener("DOMContentLoaded", () => {
+	//-----------------------
+	// IMPORTS
+	//-----------------------
+	// eslint-disable-next-line global-require
+	const smoothie = require("./smoothie");
+	// eslint-disable-next-line global-require
+	const { Renderer } = require("tera-mod-ui");
+	// eslint-disable-next-line global-require
+	const { showItemInFolder } = require("electron").shell;
+	let mod = new Renderer;
+
+	//-----------------------
+	// VARIABLES
+	//-----------------------
+	let visibleStructure = {};
+	let settings = {};
+	let modPathVar = "";
+	let runtimeInfoVar = {};
+	let softInfoVar = {};
+	let ngspInfoVar = {};
+	let graph = undefined;
+	let graphData = new smoothie.TimeSeries();
+	//-----------------------
+	// GENERATE EMPTY DIVS EXAMPLES
+	//-----------------------
+	let emptySettingTextDiv = document.createElement("div");
+	emptySettingTextDiv.className = "setting-text";
+	let emptyInputControl = document.createElement("input");
+	emptyInputControl.className = "setting-control";
+
+	//------------------------
+	// UI ELEMENTS REFS
+	//-------------------------
+	const canvasRef = document.getElementById("chart");
+
+	const settingsContainer = document.getElementsByClassName("settings-container")[0];
+
+	const uiCloseButton = document.getElementById("control-close");
+
+	const uiOpenNgspFolderButton = document.getElementById("btn-openNgspFolder");
+	const uiOpenLogsFolderButton = document.getElementById("btn-openLogsFolder");
+	const uiOpenSettingsFolderButton = document.getElementById("btn-openSettingsFolder");
+	const uiOpenEmulationFolderButton = document.getElementById("btn-openEmulationFolder");
+
+	const uiNgspVerLabel = document.getElementById("ngsp-ver");
+
+	const uiRuntimeLabel = document.getElementById("soft-runtime");
+	const uiModuleLabel = document.getElementById("soft-modulever");
+	const uiPlatformLabel = document.getElementById("soft-platform");
+
+	const uiAdminLabel = document.getElementById("game-admin");
+	const uiPatchLabel = document.getElementById("game-patch");
+	const uiProtoLabel = document.getElementById("game-proto");
+
+	const uiPingMinLabel = document.getElementById("ping-min");
+	const uiPingAvgLabel = document.getElementById("ping-avg");
+	const uiPingMaxLabel = document.getElementById("ping-max");
+
+	const uiPingEffLabel = document.getElementById("ping-eff");
+	const uiPingSpreadLabel = document.getElementById("ping-spread");
+	const uiPingMedianLabel = document.getElementById("ping-median");
+
+
+	const uiJitterAvgLabel = document.getElementById("jitter-avg");
+	const uiJitterMaxLabel = document.getElementById("jitter-max");
+
+	const uiTemplateLabel = document.getElementById("templ");
+	const uiClassLabel = document.getElementById("templ-class");
+	const uiRaceLabel = document.getElementById("templ-race");
+
+	//-----------------------
+	// Configure canvas
+	//-----------------------
+
+	graph = new smoothie.SmoothieChart({ "responsive": true, "grid": { "sharpLines": true, "verticalSections": 5, "borderVisible": false } });
+	graph.addTimeSeries(graphData, { "strokeStyle": "rgba(255, 0, 0, 1)", "fillStyle": "rgba(255, 0, 0, 0.2)", "lineWidth": 2 });
+	graph.streamTo(canvasRef, 500);
+
+	//-----------------------
+	// MENU TABS HANDLERS
+	//-----------------------
+	function handleTabs() {
+		// Setup event listeners for tab controls
+		// Alternatively, you could add `onchange="onTabChange"` to the HTML
+		const buttons = document.querySelectorAll("input[name=\"tabs\"]");
+		for (const button of buttons) button.addEventListener("change", onTabChange);
+	}
+
+	function onTabChange($e) {
+		// https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes
+		// Get `data-tab` parameter from HTML, we'll use it to determine which tab should become active
+		const tab = $e.target.dataset.tab;
+
+		// Deactivate previously activated tab
+		const tabs = document.querySelectorAll(".tab--active");
+		for (const tab of tabs) tab.classList.remove("tab--active");
+
+		// Activate selected tab, found using `data-tab` parameter
+		const contentElement = document.querySelector(`.tab[data-tab="${tab}"]`);
+		contentElement.classList.add("tab--active");
+	}
+
+	handleTabs();
+
+	//--------------------
+	//CLOSE BUTTON HANDLER
+	//--------------------
+	uiCloseButton.addEventListener("click", () => {
+		mod.send("close");
+	});
+
+	//--------------------
+	//FS BUTTONS HANDLERS
+	//--------------------
+	uiOpenEmulationFolderButton.addEventListener("click", () => {
+		showItemInFolder(modPathVar.presetPath);
+	});
+	uiOpenSettingsFolderButton.addEventListener("click", () => {
+		showItemInFolder(modPathVar.configPath);
+	});
+	uiOpenLogsFolderButton.addEventListener("click", () => {
+		showItemInFolder(modPathVar.logPath);
+	});
+	uiOpenNgspFolderButton.addEventListener("click", () => {
+		showItemInFolder(modPathVar.configPath.replace("/settings.json", ""));
+	});
+
+	//--------------------
+	// EXT SETTINGS UPDATE
+	//--------------------
+	function ipcSettingsChange(newSettings) {
+		settings = newSettings;
+		Object.keys(settings).forEach(key => {
+			let vsObj = visibleStructure[key];
+			if (vsObj) {
+				let elemRef = document.getElementById(key);
+				switch (vsObj.type) {
+				case ("bool"):
+					elemRef.checked = settings[key];
+					break;
+				case ("number"):
+					elemRef.value = settings[key];
+					break;
+				case ("select"):
+					elemRef.value = settings[key];
+					break;
+				}
+			}
+		});
+	}
+
+	//--------------------
+	// INTERNAL SETTINGS UPDATE
+	//--------------------
+	function uiSettingsChange(event) {
+		//if(!settings[event.target.id]) return;
+		switch (visibleStructure[event.target.id].type) {
+		case ("bool"):
+			settings[event.target.id] = event.target.checked;
+			break;
+		case ("number"):
+			settings[event.target.id] = Number(event.target.value);
+			break;
+		case ("select"):
+			settings[event.target.id] = event.target.value;
+			break;
+		}
+		//send update event
+		mod.send("uisettings", { ...settings });
+	}
+
+	function compileView() {
+		//generate grid root style
+		let style = document.getElementsByTagName("style")[0];
+		style.innerHTML += `.settings-container {
+			display: grid;
+			grid-template-columns: 1fr 70px;
+			grid-template-rows: repeat(${Object.keys(visibleStructure).length}, 1fr);
+			grid-column-gap: 0px;
+			grid-row-gap: 3px;
+		}`;
+		document.head.appendChild(style);
+
+		//generate static text style  (column 1)
+		let counter = 1;
+		for (let key of Object.keys(visibleStructure)) {
+			//placement style
+			style.innerHTML += `
+				#${key}-text {
+					grid-area: ${counter} / 1 / ${counter + 1} / 2;
+				}
+			`;
+			document.head.appendChild(style);
+			counter++;
+			//add in DOM text element with created class
+			let newText = emptySettingTextDiv.cloneNode(false);
+			newText.id = `${key}-text`;
+			newText.innerText = visibleStructure[key]["name"];
+			settingsContainer.appendChild(newText);
+		}
+
+		//generate controls (column 2)
+		counter = 1;
+		for (let key of Object.keys(visibleStructure)) {
+			//placement style
+			style.innerHTML += `
+				#${key}-div {
+					grid-area: ${counter} / 2 / ${counter + 1} / 3;
+				}
+			`;
+			document.head.appendChild(style);
+			counter++;
+
+			//add in DOM control with created class
+			let data = visibleStructure[key];
+			let type = data["type"];
+			let newControl = null;
+
+			let newControlDiv = emptySettingTextDiv.cloneNode(false);
+			newControlDiv.id = `${key}-div`;
+			newControlDiv.classList.add("setting-value");
+			switch (type) {
+			case ("bool"):
+				newControl = emptyInputControl.cloneNode(false);
+				newControl.id = key;
+				newControl.type = "checkbox";
+				newControl.classList.add("setting-control");
+
+				settingsContainer.appendChild(newControlDiv);
+				newControlDiv.appendChild(newControl);
+				newControl.addEventListener("change", uiSettingsChange);
+				break;
+			case ("number"):
+				newControl = emptyInputControl.cloneNode(false);
+				newControl.id = key;
+				newControl.min = data.min;
+				newControl.max = data.max;
+				newControl.step = data.step;
+				newControl.type = "number";
+				newControl.classList.add("setting-control");
+
+				settingsContainer.appendChild(newControlDiv);
+				newControlDiv.appendChild(newControl);
+				newControl.addEventListener("change", uiSettingsChange);
+				break;
+			case ("select"):
+				newControl = document.createElement("select");
+				newControl.id = key;
+				newControl.classList.add("setting-control");
+				data.options.forEach(element => {
+					let option = document.createElement("option");
+					option.text = element.name;
+					option.value = element.key;
+					newControl.appendChild(option);
+				});
+
+				settingsContainer.appendChild(newControlDiv);
+				newControlDiv.appendChild(newControl);
+				newControl.addEventListener("change", uiSettingsChange);
+				break;
+			}
+		}
+	}
+
+	//--------------------
+	// PING ELEMENTS UPDATE EVENT
+	//--------------------
+	mod.on("ping", statsObj => {
+		uiPingMinLabel.innerText = `Min: ${statsObj.ping.minValue}`;
+		uiPingAvgLabel.innerText = `Avg: ${statsObj.ping.avgValue}`;
+		uiPingMaxLabel.innerText = `Max: ${statsObj.ping.maxValue}`;
+		uiPingEffLabel.innerText = `EffSpread: ${statsObj.ping.avgValue - statsObj.ping.minValue}`;
+		uiPingSpreadLabel.innerText = `Spread: ${statsObj.ping.maxValue - statsObj.ping.minValue}`;
+		uiPingMedianLabel.innerText = `Median: ${statsObj.ping.avgValue}`;
+
+		uiJitterAvgLabel.innerText = `Avg: ${statsObj.jitter.avgValue}`;
+		uiJitterMaxLabel.innerText = `Max: ${statsObj.jitter.maxValue}`;
+
+		graphData.append(new Date().getTime(), statsObj.ping.raw);
+	});
+
+	//--------------------
+	// INITIAL ELEMENTS UPDATE EVENT
+	//--------------------
+	mod.on("static", event => {
+
+		//place variables to reduce future params usage
+		visibleStructure = event.map;
+		settings = event.config;
+		//TODO usage
+		modPathVar = event.modInfo;
+		runtimeInfoVar = event.runtime;
+		softInfoVar = event.soft;
+		ngspInfoVar = event.ngsp;
+		//place static data about runtime
+		uiNgspVerLabel.innerHTML = `Version: ${ngspInfoVar.ver}`;
+
+		uiAdminLabel.innerText = `Admin: ${runtimeInfoVar.isAdmin}`;
+		uiPatchLabel.innerText = `Client: ${runtimeInfoVar.patch}`;
+		uiProtoLabel.innerText = `Proto: ${runtimeInfoVar.proto}`;
+		uiRuntimeLabel.innerText = `Runtime: ${runtimeInfoVar.proxyAuthor == "caali" && runtimeInfoVar.clientInterface ? "TB" : "Other"}`;
+
+		uiModuleLabel.innerText = `ModVer: ${softInfoVar.modVer}`;
+		uiPlatformLabel.innerText = `Platform: ${softInfoVar.platform}`;
+
+		//player 
+		uiClassLabel.innerText = `Class: ${event.player.job}`;
+		uiRaceLabel.innerText = ` Race: ${event.player.race}`;
+		uiTemplateLabel.innerText = `Template: ${event.player.template}`;
+
+		//reconfigure settings UI
+		compileView();
+		ipcSettingsChange(settings);
+	});
+
+	//--------------------
+	// SETTINGS UPDATE EVENT
+	//--------------------
+	mod.on("extsettings", settingsObj => {
+		ipcSettingsChange(settingsObj);
+	});
+
+	mod.send("ready");
+});

+ 1110 - 0
data/internal/controlUI/smoothie.js

@@ -0,0 +1,1110 @@
+// MIT License:
+//
+// Copyright (c) 2010-2013, Joe Walnes
+//               2013-2018, Drew Noakes
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+/**
+ * Smoothie Charts - http://smoothiecharts.org/
+ * (c) 2010-2013, Joe Walnes
+ *     2013-2018, Drew Noakes
+ *
+ * v1.0: Main charting library, by Joe Walnes
+ * v1.1: Auto scaling of axis, by Neil Dunn
+ * v1.2: fps (frames per second) option, by Mathias Petterson
+ * v1.3: Fix for divide by zero, by Paul Nikitochkin
+ * v1.4: Set minimum, top-scale padding, remove timeseries, add optional timer to reset bounds, by Kelley Reynolds
+ * v1.5: Set default frames per second to 50... smoother.
+ *       .start(), .stop() methods for conserving CPU, by Dmitry Vyal
+ *       options.interpolation = 'bezier' or 'line', by Dmitry Vyal
+ *       options.maxValue to fix scale, by Dmitry Vyal
+ * v1.6: minValue/maxValue will always get converted to floats, by Przemek Matylla
+ * v1.7: options.grid.fillStyle may be a transparent color, by Dmitry A. Shashkin
+ *       Smooth rescaling, by Kostas Michalopoulos
+ * v1.8: Set max length to customize number of live points in the dataset with options.maxDataSetLength, by Krishna Narni
+ * v1.9: Display timestamps along the bottom, by Nick and Stev-io
+ *       (https://groups.google.com/forum/?fromgroups#!topic/smoothie-charts/-Ywse8FCpKI%5B1-25%5D)
+ *       Refactored by Krishna Narni, to support timestamp formatting function
+ * v1.10: Switch to requestAnimationFrame, removed the now obsoleted options.fps, by Gergely Imreh
+ * v1.11: options.grid.sharpLines option added, by @drewnoakes
+ *        Addressed warning seen in Firefox when seriesOption.fillStyle undefined, by @drewnoakes
+ * v1.12: Support for horizontalLines added, by @drewnoakes
+ *        Support for yRangeFunction callback added, by @drewnoakes
+ * v1.13: Fixed typo (#32), by @alnikitich
+ * v1.14: Timer cleared when last TimeSeries removed (#23), by @davidgaleano
+ *        Fixed diagonal line on chart at start/end of data stream, by @drewnoakes
+ * v1.15: Support for npm package (#18), by @dominictarr
+ *        Fixed broken removeTimeSeries function (#24) by @davidgaleano
+ *        Minor performance and tidying, by @drewnoakes
+ * v1.16: Bug fix introduced in v1.14 relating to timer creation/clearance (#23), by @drewnoakes
+ *        TimeSeries.append now deals with out-of-order timestamps, and can merge duplicates, by @zacwitte (#12)
+ *        Documentation and some local variable renaming for clarity, by @drewnoakes
+ * v1.17: Allow control over font size (#10), by @drewnoakes
+ *        Timestamp text won't overlap, by @drewnoakes
+ * v1.18: Allow control of max/min label precision, by @drewnoakes
+ *        Added 'borderVisible' chart option, by @drewnoakes
+ *        Allow drawing series with fill but no stroke (line), by @drewnoakes
+ * v1.19: Avoid unnecessary repaints, and fixed flicker in old browsers having multiple charts in document (#40), by @asbai
+ * v1.20: Add SmoothieChart.getTimeSeriesOptions and SmoothieChart.bringToFront functions, by @drewnoakes
+ * v1.21: Add 'step' interpolation mode, by @drewnoakes
+ * v1.22: Add support for different pixel ratios. Also add optional y limit formatters, by @copacetic
+ * v1.23: Fix bug introduced in v1.22 (#44), by @drewnoakes
+ * v1.24: Fix bug introduced in v1.23, re-adding parseFloat to y-axis formatter defaults, by @siggy_sf
+ * v1.25: Fix bug seen when adding a data point to TimeSeries which is older than the current data, by @Nking92
+ *        Draw time labels on top of series, by @comolosabia
+ *        Add TimeSeries.clear function, by @drewnoakes
+ * v1.26: Add support for resizing on high device pixel ratio screens, by @copacetic
+ * v1.27: Fix bug introduced in v1.26 for non whole number devicePixelRatio values, by @zmbush
+ * v1.28: Add 'minValueScale' option, by @megawac
+ *        Fix 'labelPos' for different size of 'minValueString' 'maxValueString', by @henryn
+ * v1.29: Support responsive sizing, by @drewnoakes
+ * v1.29.1: Include types in package, and make property optional, by @TrentHouliston
+ * v1.30: Fix inverted logic in devicePixelRatio support, by @scanlime
+ * v1.31: Support tooltips, by @Sly1024 and @drewnoakes
+ * v1.32: Support frame rate limit, by @dpuyosa
+ * v1.33: Use Date static method instead of instance, by @nnnoel
+ *        Fix bug with tooltips when multiple charts on a page, by @jpmbiz70
+ * v1.34: Add disabled option to TimeSeries, by @TechGuard (#91)
+ *        Add nonRealtimeData option, by @annazhelt (#92, #93)
+ *        Add showIntermediateLabels option, by @annazhelt (#94)
+ *        Add displayDataFromPercentile option, by @annazhelt (#95)
+ *        Fix bug when hiding tooltip element, by @ralphwetzel (#96)
+ *        Support intermediate y-axis labels, by @beikeland (#99)
+ * v1.35: Fix issue with responsive mode at high DPI, by @drewnoakes (#101)
+ * v1.36: Add tooltipLabel to ITimeSeriesPresentationOptions.
+ *        If tooltipLabel is present, tooltipLabel displays inside tooltip
+ *        next to value, by @jackdesert (#102)
+ *        Fix bug rendering issue in series fill when using scroll backwards, by @olssonfredrik
+ *        Add title option, by @mesca
+ *        Fix data drop stoppage by rejecting NaNs in append(), by @timdrysdale
+ */
+
+;(function(exports) {
+
+	// Date.now polyfill
+	Date.now = Date.now || function() { return new Date().getTime(); };
+  
+	var Util = {
+	  extend: function() {
+		arguments[0] = arguments[0] || {};
+		for (var i = 1; i < arguments.length; i++)
+		{
+		  for (var key in arguments[i])
+		  {
+			if (arguments[i].hasOwnProperty(key))
+			{
+			  if (typeof(arguments[i][key]) === 'object') {
+				if (arguments[i][key] instanceof Array) {
+				  arguments[0][key] = arguments[i][key];
+				} else {
+				  arguments[0][key] = Util.extend(arguments[0][key], arguments[i][key]);
+				}
+			  } else {
+				arguments[0][key] = arguments[i][key];
+			  }
+			}
+		  }
+		}
+		return arguments[0];
+	  },
+	  binarySearch: function(data, value) {
+		var low = 0,
+			high = data.length;
+		while (low < high) {
+		  var mid = (low + high) >> 1;
+		  if (value < data[mid][0])
+			high = mid;
+		  else
+			low = mid + 1;
+		}
+		return low;
+	  }
+	};
+  
+	/**
+	 * Initialises a new <code>TimeSeries</code> with optional data options.
+	 *
+	 * Options are of the form (defaults shown):
+	 *
+	 * <pre>
+	 * {
+	 *   resetBounds: true,        // enables/disables automatic scaling of the y-axis
+	 *   resetBoundsInterval: 3000 // the period between scaling calculations, in millis
+	 * }
+	 * </pre>
+	 *
+	 * Presentation options for TimeSeries are specified as an argument to <code>SmoothieChart.addTimeSeries</code>.
+	 *
+	 * @constructor
+	 */
+	function TimeSeries(options) {
+	  this.options = Util.extend({}, TimeSeries.defaultOptions, options);
+	  this.disabled = false;
+	  this.clear();
+	}
+  
+	TimeSeries.defaultOptions = {
+	  resetBoundsInterval: 3000,
+	  resetBounds: true
+	};
+  
+	/**
+	 * Clears all data and state from this TimeSeries object.
+	 */
+	TimeSeries.prototype.clear = function() {
+	  this.data = [];
+	  this.maxValue = Number.NaN; // The maximum value ever seen in this TimeSeries.
+	  this.minValue = Number.NaN; // The minimum value ever seen in this TimeSeries.
+	};
+  
+	/**
+	 * Recalculate the min/max values for this <code>TimeSeries</code> object.
+	 *
+	 * This causes the graph to scale itself in the y-axis.
+	 */
+	TimeSeries.prototype.resetBounds = function() {
+	  if (this.data.length) {
+		// Walk through all data points, finding the min/max value
+		this.maxValue = this.data[0][1];
+		this.minValue = this.data[0][1];
+		for (var i = 1; i < this.data.length; i++) {
+		  var value = this.data[i][1];
+		  if (value > this.maxValue) {
+			this.maxValue = value;
+		  }
+		  if (value < this.minValue) {
+			this.minValue = value;
+		  }
+		}
+	  } else {
+		// No data exists, so set min/max to NaN
+		this.maxValue = Number.NaN;
+		this.minValue = Number.NaN;
+	  }
+	};
+  
+	/**
+	 * Adds a new data point to the <code>TimeSeries</code>, preserving chronological order.
+	 *
+	 * @param timestamp the position, in time, of this data point
+	 * @param value the value of this data point
+	 * @param sumRepeatedTimeStampValues if <code>timestamp</code> has an exact match in the series, this flag controls
+	 * whether it is replaced, or the values summed (defaults to false.)
+	 */
+	TimeSeries.prototype.append = function(timestamp, value, sumRepeatedTimeStampValues) {
+	  // Reject NaN
+	  if (isNaN(timestamp) || isNaN(value)){
+		  return
+	  }  
+	  // Rewind until we hit an older timestamp
+	  var i = this.data.length - 1;
+	  while (i >= 0 && this.data[i][0] > timestamp) {
+		i--;
+	  }
+  
+	  if (i === -1) {
+		// This new item is the oldest data
+		this.data.splice(0, 0, [timestamp, value]);
+	  } else if (this.data.length > 0 && this.data[i][0] === timestamp) {
+		// Update existing values in the array
+		if (sumRepeatedTimeStampValues) {
+		  // Sum this value into the existing 'bucket'
+		  this.data[i][1] += value;
+		  value = this.data[i][1];
+		} else {
+		  // Replace the previous value
+		  this.data[i][1] = value;
+		}
+	  } else if (i < this.data.length - 1) {
+		// Splice into the correct position to keep timestamps in order
+		this.data.splice(i + 1, 0, [timestamp, value]);
+	  } else {
+		// Add to the end of the array
+		this.data.push([timestamp, value]);
+	  }
+  
+	  this.maxValue = isNaN(this.maxValue) ? value : Math.max(this.maxValue, value);
+	  this.minValue = isNaN(this.minValue) ? value : Math.min(this.minValue, value);
+	};
+  
+	TimeSeries.prototype.dropOldData = function(oldestValidTime, maxDataSetLength) {
+	  // We must always keep one expired data point as we need this to draw the
+	  // line that comes into the chart from the left, but any points prior to that can be removed.
+	  var removeCount = 0;
+	  while (this.data.length - removeCount >= maxDataSetLength && this.data[removeCount + 1][0] < oldestValidTime) {
+		removeCount++;
+	  }
+	  if (removeCount !== 0) {
+		this.data.splice(0, removeCount);
+	  }
+	};
+  
+	/**
+	 * Initialises a new <code>SmoothieChart</code>.
+	 *
+	 * Options are optional, and should be of the form below. Just specify the values you
+	 * need and the rest will be given sensible defaults as shown:
+	 *
+	 * <pre>
+	 * {
+	 *   minValue: undefined,                      // specify to clamp the lower y-axis to a given value
+	 *   maxValue: undefined,                      // specify to clamp the upper y-axis to a given value
+	 *   maxValueScale: 1,                         // allows proportional padding to be added above the chart. for 10% padding, specify 1.1.
+	 *   minValueScale: 1,                         // allows proportional padding to be added below the chart. for 10% padding, specify 1.1.
+	 *   yRangeFunction: undefined,                // function({min: , max: }) { return {min: , max: }; }
+	 *   scaleSmoothing: 0.125,                    // controls the rate at which y-value zoom animation occurs
+	 *   millisPerPixel: 20,                       // sets the speed at which the chart pans by
+	 *   enableDpiScaling: true,                   // support rendering at different DPI depending on the device
+	 *   yMinFormatter: function(min, precision) { // callback function that formats the min y value label
+	 *     return parseFloat(min).toFixed(precision);
+	 *   },
+	 *   yMaxFormatter: function(max, precision) { // callback function that formats the max y value label
+	 *     return parseFloat(max).toFixed(precision);
+	 *   },
+	 *   yIntermediateFormatter: function(intermediate, precision) { // callback function that formats the intermediate y value labels
+	 *     return parseFloat(intermediate).toFixed(precision);
+	 *   },
+	 *   maxDataSetLength: 2,
+	 *   interpolation: 'bezier'                   // one of 'bezier', 'linear', or 'step'
+	 *   timestampFormatter: null,                 // optional function to format time stamps for bottom of chart
+	 *                                             // you may use SmoothieChart.timeFormatter, or your own: function(date) { return ''; }
+	 *   scrollBackwards: false,                   // reverse the scroll direction of the chart
+	 *   horizontalLines: [],                      // [ { value: 0, color: '#ffffff', lineWidth: 1 } ]
+	 *   grid:
+	 *   {
+	 *     fillStyle: '#000000',                   // the background colour of the chart
+	 *     lineWidth: 1,                           // the pixel width of grid lines
+	 *     strokeStyle: '#777777',                 // colour of grid lines
+	 *     millisPerLine: 1000,                    // distance between vertical grid lines
+	 *     sharpLines: false,                      // controls whether grid lines are 1px sharp, or softened
+	 *     verticalSections: 2,                    // number of vertical sections marked out by horizontal grid lines
+	 *     borderVisible: true                     // whether the grid lines trace the border of the chart or not
+	 *   },
+	 *   labels
+	 *   {
+	 *     disabled: false,                        // enables/disables labels showing the min/max values
+	 *     fillStyle: '#ffffff',                   // colour for text of labels,
+	 *     fontSize: 15,
+	 *     fontFamily: 'sans-serif',
+	 *     precision: 2,
+	 *     showIntermediateLabels: false,          // shows intermediate labels between min and max values along y axis
+	 *     intermediateLabelSameAxis: true,
+	 *   },
+	 *   title
+	 *   {
+	 *     text: '',                               // the text to display on the left side of the chart
+	 *     fillStyle: '#ffffff',                   // colour for text
+	 *     fontSize: 15,
+	 *     fontFamily: 'sans-serif',
+	 *     verticalAlign: 'middle'                 // one of 'top', 'middle', or 'bottom'
+	 *   },
+	 *   tooltip: false                            // show tooltip when mouse is over the chart
+	 *   tooltipLine: {                            // properties for a vertical line at the cursor position
+	 *     lineWidth: 1,
+	 *     strokeStyle: '#BBBBBB'
+	 *   },
+	 *   tooltipFormatter: SmoothieChart.tooltipFormatter, // formatter function for tooltip text
+	 *   nonRealtimeData: false,                   // use time of latest data as current time
+	 *   displayDataFromPercentile: 1,             // display not latest data, but data from the given percentile
+	 *                                             // useful when trying to see old data saved by setting a high value for maxDataSetLength
+	 *                                             // should be a value between 0 and 1
+	 *   responsive: false,                        // whether the chart should adapt to the size of the canvas
+	 *   limitFPS: 0                               // maximum frame rate the chart will render at, in FPS (zero means no limit)
+	 * }
+	 * </pre>
+	 *
+	 * @constructor
+	 */
+	function SmoothieChart(options) {
+	  this.options = Util.extend({}, SmoothieChart.defaultChartOptions, options);
+	  this.seriesSet = [];
+	  this.currentValueRange = 1;
+	  this.currentVisMinValue = 0;
+	  this.lastRenderTimeMillis = 0;
+	  this.lastChartTimestamp = 0;
+  
+	  this.mousemove = this.mousemove.bind(this);
+	  this.mouseout = this.mouseout.bind(this);
+	}
+  
+	/** Formats the HTML string content of the tooltip. */
+	SmoothieChart.tooltipFormatter = function (timestamp, data) {
+		var timestampFormatter = this.options.timestampFormatter || SmoothieChart.timeFormatter,
+			lines = [timestampFormatter(new Date(timestamp))],
+			label;
+  
+		for (var i = 0; i < data.length; ++i) {
+		  label = data[i].series.options.tooltipLabel || ''
+		  if (label !== ''){
+			  label = label + ' ';
+		  }
+		  lines.push('<span style="color:' + data[i].series.options.strokeStyle + '">' +
+		  label +
+		  this.options.yMaxFormatter(data[i].value, this.options.labels.precision) + '</span>');
+		}
+  
+		return lines.join('<br>');
+	};
+  
+	SmoothieChart.defaultChartOptions = {
+	  millisPerPixel: 20,
+	  enableDpiScaling: true,
+	  yMinFormatter: function(min, precision) {
+		return parseFloat(min).toFixed(precision);
+	  },
+	  yMaxFormatter: function(max, precision) {
+		return parseFloat(max).toFixed(precision);
+	  },
+	  yIntermediateFormatter: function(intermediate, precision) {
+		return parseFloat(intermediate).toFixed(precision);
+	  },
+	  maxValueScale: 1,
+	  minValueScale: 1,
+	  interpolation: 'bezier',
+	  scaleSmoothing: 0.125,
+	  maxDataSetLength: 2,
+	  scrollBackwards: false,
+	  displayDataFromPercentile: 1,
+	  grid: {
+		fillStyle: '#000000',
+		strokeStyle: '#777777',
+		lineWidth: 1,
+		sharpLines: false,
+		millisPerLine: 1000,
+		verticalSections: 2,
+		borderVisible: true
+	  },
+	  labels: {
+		fillStyle: '#ffffff',
+		disabled: false,
+		fontSize: 10,
+		fontFamily: 'monospace',
+		precision: 2,
+		showIntermediateLabels: false,
+		intermediateLabelSameAxis: true,
+	  },
+	  title: {
+		text: '',
+		fillStyle: '#ffffff',
+		fontSize: 15,
+		fontFamily: 'monospace',
+		verticalAlign: 'middle'
+	  },
+	  horizontalLines: [],
+	  tooltip: false,
+	  tooltipLine: {
+		lineWidth: 1,
+		strokeStyle: '#BBBBBB'
+	  },
+	  tooltipFormatter: SmoothieChart.tooltipFormatter,
+	  nonRealtimeData: false,
+	  responsive: false,
+	  limitFPS: 0
+	};
+  
+	// Based on http://inspirit.github.com/jsfeat/js/compatibility.js
+	SmoothieChart.AnimateCompatibility = (function() {
+	  var requestAnimationFrame = function(callback, element) {
+			var requestAnimationFrame =
+			  window.requestAnimationFrame        ||
+			  window.webkitRequestAnimationFrame  ||
+			  window.mozRequestAnimationFrame     ||
+			  window.oRequestAnimationFrame       ||
+			  window.msRequestAnimationFrame      ||
+			  function(callback) {
+				return window.setTimeout(function() {
+				  callback(Date.now());
+				}, 16);
+			  };
+			return requestAnimationFrame.call(window, callback, element);
+		  },
+		  cancelAnimationFrame = function(id) {
+			var cancelAnimationFrame =
+			  window.cancelAnimationFrame ||
+			  function(id) {
+				clearTimeout(id);
+			  };
+			return cancelAnimationFrame.call(window, id);
+		  };
+  
+	  return {
+		requestAnimationFrame: requestAnimationFrame,
+		cancelAnimationFrame: cancelAnimationFrame
+	  };
+	})();
+  
+	SmoothieChart.defaultSeriesPresentationOptions = {
+	  lineWidth: 1,
+	  strokeStyle: '#ffffff'
+	};
+  
+	/**
+	 * Adds a <code>TimeSeries</code> to this chart, with optional presentation options.
+	 *
+	 * Presentation options should be of the form (defaults shown):
+	 *
+	 * <pre>
+	 * {
+	 *   lineWidth: 1,
+	 *   strokeStyle: '#ffffff',
+	 *   fillStyle: undefined,
+	 *   tooltipLabel: undefined
+	 * }
+	 * </pre>
+	 */
+	SmoothieChart.prototype.addTimeSeries = function(timeSeries, options) {
+	  this.seriesSet.push({timeSeries: timeSeries, options: Util.extend({}, SmoothieChart.defaultSeriesPresentationOptions, options)});
+	  if (timeSeries.options.resetBounds && timeSeries.options.resetBoundsInterval > 0) {
+		timeSeries.resetBoundsTimerId = setInterval(
+		  function() {
+			timeSeries.resetBounds();
+		  },
+		  timeSeries.options.resetBoundsInterval
+		);
+	  }
+	};
+  
+	/**
+	 * Removes the specified <code>TimeSeries</code> from the chart.
+	 */
+	SmoothieChart.prototype.removeTimeSeries = function(timeSeries) {
+	  // Find the correct timeseries to remove, and remove it
+	  var numSeries = this.seriesSet.length;
+	  for (var i = 0; i < numSeries; i++) {
+		if (this.seriesSet[i].timeSeries === timeSeries) {
+		  this.seriesSet.splice(i, 1);
+		  break;
+		}
+	  }
+	  // If a timer was operating for that timeseries, remove it
+	  if (timeSeries.resetBoundsTimerId) {
+		// Stop resetting the bounds, if we were
+		clearInterval(timeSeries.resetBoundsTimerId);
+	  }
+	};
+  
+	/**
+	 * Gets render options for the specified <code>TimeSeries</code>.
+	 *
+	 * As you may use a single <code>TimeSeries</code> in multiple charts with different formatting in each usage,
+	 * these settings are stored in the chart.
+	 */
+	SmoothieChart.prototype.getTimeSeriesOptions = function(timeSeries) {
+	  // Find the correct timeseries to remove, and remove it
+	  var numSeries = this.seriesSet.length;
+	  for (var i = 0; i < numSeries; i++) {
+		if (this.seriesSet[i].timeSeries === timeSeries) {
+		  return this.seriesSet[i].options;
+		}
+	  }
+	};
+  
+	/**
+	 * Brings the specified <code>TimeSeries</code> to the top of the chart. It will be rendered last.
+	 */
+	SmoothieChart.prototype.bringToFront = function(timeSeries) {
+	  // Find the correct timeseries to remove, and remove it
+	  var numSeries = this.seriesSet.length;
+	  for (var i = 0; i < numSeries; i++) {
+		if (this.seriesSet[i].timeSeries === timeSeries) {
+		  var set = this.seriesSet.splice(i, 1);
+		  this.seriesSet.push(set[0]);
+		  break;
+		}
+	  }
+	};
+  
+	/**
+	 * Instructs the <code>SmoothieChart</code> to start rendering to the provided canvas, with specified delay.
+	 *
+	 * @param canvas the target canvas element
+	 * @param delayMillis an amount of time to wait before a data point is shown. This can prevent the end of the series
+	 * from appearing on screen, with new values flashing into view, at the expense of some latency.
+	 */
+	SmoothieChart.prototype.streamTo = function(canvas, delayMillis) {
+	  this.canvas = canvas;
+	  this.delay = delayMillis;
+	  this.start();
+	};
+  
+	SmoothieChart.prototype.getTooltipEl = function () {
+	  // Create the tool tip element lazily
+	  if (!this.tooltipEl) {
+		this.tooltipEl = document.createElement('div');
+		this.tooltipEl.className = 'smoothie-chart-tooltip';
+		this.tooltipEl.style.position = 'absolute';
+		this.tooltipEl.style.display = 'none';
+		document.body.appendChild(this.tooltipEl);
+	  }
+	  return this.tooltipEl;
+	};
+  
+	SmoothieChart.prototype.updateTooltip = function () {
+	  if(!this.options.tooltip){
+	   return; 
+	  }
+	  var el = this.getTooltipEl();
+  
+	  if (!this.mouseover || !this.options.tooltip) {
+		el.style.display = 'none';
+		return;
+	  }
+  
+	  var time = this.lastChartTimestamp;
+  
+	  // x pixel to time
+	  var t = this.options.scrollBackwards
+		? time - this.mouseX * this.options.millisPerPixel
+		: time - (this.canvas.offsetWidth - this.mouseX) * this.options.millisPerPixel;
+  
+	  var data = [];
+  
+	   // For each data set...
+	  for (var d = 0; d < this.seriesSet.length; d++) {
+		var timeSeries = this.seriesSet[d].timeSeries;
+		if (timeSeries.disabled) {
+			continue;
+		}
+  
+		// find datapoint closest to time 't'
+		var closeIdx = Util.binarySearch(timeSeries.data, t);
+		if (closeIdx > 0 && closeIdx < timeSeries.data.length) {
+		  data.push({ series: this.seriesSet[d], index: closeIdx, value: timeSeries.data[closeIdx][1] });
+		}
+	  }
+  
+	  if (data.length) {
+		el.innerHTML = this.options.tooltipFormatter.call(this, t, data);
+		el.style.display = 'block';
+	  } else {
+		el.style.display = 'none';
+	  }
+	};
+  
+	SmoothieChart.prototype.mousemove = function (evt) {
+	  this.mouseover = true;
+	  this.mouseX = evt.offsetX;
+	  this.mouseY = evt.offsetY;
+	  this.mousePageX = evt.pageX;
+	  this.mousePageY = evt.pageY;
+	  if(!this.options.tooltip){
+	   return; 
+	  }
+	  var el = this.getTooltipEl();
+	  el.style.top = Math.round(this.mousePageY) + 'px';
+	  el.style.left = Math.round(this.mousePageX) + 'px';
+	  this.updateTooltip();
+	};
+  
+	SmoothieChart.prototype.mouseout = function () {
+	  this.mouseover = false;
+	  this.mouseX = this.mouseY = -1;
+	  if (this.tooltipEl)
+		this.tooltipEl.style.display = 'none';
+	};
+  
+	/**
+	 * Make sure the canvas has the optimal resolution for the device's pixel ratio.
+	 */
+	SmoothieChart.prototype.resize = function () {
+	  var dpr = !this.options.enableDpiScaling || !window ? 1 : window.devicePixelRatio,
+		  width, height;
+	  if (this.options.responsive) {
+		// Newer behaviour: Use the canvas's size in the layout, and set the internal
+		// resolution according to that size and the device pixel ratio (eg: high DPI)
+		width = this.canvas.offsetWidth;
+		height = this.canvas.offsetHeight;
+  
+		if (width !== this.lastWidth) {
+		  this.lastWidth = width;
+		  this.canvas.setAttribute('width', (Math.floor(width * dpr)).toString());
+		  this.canvas.getContext('2d').scale(dpr, dpr);
+		}
+		if (height !== this.lastHeight) {
+		  this.lastHeight = height;
+		  this.canvas.setAttribute('height', (Math.floor(height * dpr)).toString());
+		  this.canvas.getContext('2d').scale(dpr, dpr);
+		}
+	  } else if (dpr !== 1) {
+		// Older behaviour: use the canvas's inner dimensions and scale the element's size
+		// according to that size and the device pixel ratio (eg: high DPI)
+		width = parseInt(this.canvas.getAttribute('width'));
+		height = parseInt(this.canvas.getAttribute('height'));
+  
+		if (!this.originalWidth || (Math.floor(this.originalWidth * dpr) !== width)) {
+		  this.originalWidth = width;
+		  this.canvas.setAttribute('width', (Math.floor(width * dpr)).toString());
+		  this.canvas.style.width = width + 'px';
+		  this.canvas.getContext('2d').scale(dpr, dpr);
+		}
+  
+		if (!this.originalHeight || (Math.floor(this.originalHeight * dpr) !== height)) {
+		  this.originalHeight = height;
+		  this.canvas.setAttribute('height', (Math.floor(height * dpr)).toString());
+		  this.canvas.style.height = height + 'px';
+		  this.canvas.getContext('2d').scale(dpr, dpr);
+		}
+	  }
+	};
+  
+	/**
+	 * Starts the animation of this chart.
+	 */
+	SmoothieChart.prototype.start = function() {
+	  if (this.frame) {
+		// We're already running, so just return
+		return;
+	  }
+  
+	  this.canvas.addEventListener('mousemove', this.mousemove);
+	  this.canvas.addEventListener('mouseout', this.mouseout);
+  
+	  // Renders a frame, and queues the next frame for later rendering
+	  var animate = function() {
+		this.frame = SmoothieChart.AnimateCompatibility.requestAnimationFrame(function() {
+		  if(this.options.nonRealtimeData){
+			 var dateZero = new Date(0);
+			 // find the data point with the latest timestamp
+			 var maxTimeStamp = this.seriesSet.reduce(function(max, series){
+			   var dataSet = series.timeSeries.data;
+			   var indexToCheck = Math.round(this.options.displayDataFromPercentile * dataSet.length) - 1;
+			   indexToCheck = indexToCheck >= 0 ? indexToCheck : 0;
+			   indexToCheck = indexToCheck <= dataSet.length -1 ? indexToCheck : dataSet.length -1;
+			   if(dataSet && dataSet.length > 0)
+			   {
+				// timestamp corresponds to element 0 of the data point
+				var lastDataTimeStamp = dataSet[indexToCheck][0];
+				max = max > lastDataTimeStamp ? max : lastDataTimeStamp;
+			   }
+			   return max;
+			}.bind(this), dateZero);
+			// use the max timestamp as current time
+			this.render(this.canvas, maxTimeStamp > dateZero ? maxTimeStamp : null);
+		  } else {
+			this.render();
+		  }
+		  animate();
+		}.bind(this));
+	  }.bind(this);
+  
+	  animate();
+	};
+  
+	/**
+	 * Stops the animation of this chart.
+	 */
+	SmoothieChart.prototype.stop = function() {
+	  if (this.frame) {
+		SmoothieChart.AnimateCompatibility.cancelAnimationFrame(this.frame);
+		delete this.frame;
+		this.canvas.removeEventListener('mousemove', this.mousemove);
+		this.canvas.removeEventListener('mouseout', this.mouseout);
+	  }
+	};
+  
+	SmoothieChart.prototype.updateValueRange = function() {
+	  // Calculate the current scale of the chart, from all time series.
+	  var chartOptions = this.options,
+		  chartMaxValue = Number.NaN,
+		  chartMinValue = Number.NaN;
+  
+	  for (var d = 0; d < this.seriesSet.length; d++) {
+		// TODO(ndunn): We could calculate / track these values as they stream in.
+		var timeSeries = this.seriesSet[d].timeSeries;
+		if (timeSeries.disabled) {
+			continue;
+		}
+  
+		if (!isNaN(timeSeries.maxValue)) {
+		  chartMaxValue = !isNaN(chartMaxValue) ? Math.max(chartMaxValue, timeSeries.maxValue) : timeSeries.maxValue;
+		}
+  
+		if (!isNaN(timeSeries.minValue)) {
+		  chartMinValue = !isNaN(chartMinValue) ? Math.min(chartMinValue, timeSeries.minValue) : timeSeries.minValue;
+		}
+	  }
+  
+	  // Scale the chartMaxValue to add padding at the top if required
+	  if (chartOptions.maxValue != null) {
+		chartMaxValue = chartOptions.maxValue;
+	  } else {
+		chartMaxValue *= chartOptions.maxValueScale;
+	  }
+  
+	  // Set the minimum if we've specified one
+	  if (chartOptions.minValue != null) {
+		chartMinValue = chartOptions.minValue;
+	  } else {
+		chartMinValue -= Math.abs(chartMinValue * chartOptions.minValueScale - chartMinValue);
+	  }
+  
+	  // If a custom range function is set, call it
+	  if (this.options.yRangeFunction) {
+		var range = this.options.yRangeFunction({min: chartMinValue, max: chartMaxValue});
+		chartMinValue = range.min;
+		chartMaxValue = range.max;
+	  }
+  
+	  if (!isNaN(chartMaxValue) && !isNaN(chartMinValue)) {
+		var targetValueRange = chartMaxValue - chartMinValue;
+		var valueRangeDiff = (targetValueRange - this.currentValueRange);
+		var minValueDiff = (chartMinValue - this.currentVisMinValue);
+		this.isAnimatingScale = Math.abs(valueRangeDiff) > 0.1 || Math.abs(minValueDiff) > 0.1;
+		this.currentValueRange += chartOptions.scaleSmoothing * valueRangeDiff;
+		this.currentVisMinValue += chartOptions.scaleSmoothing * minValueDiff;
+	  }
+  
+	  this.valueRange = { min: chartMinValue, max: chartMaxValue };
+	};
+  
+	SmoothieChart.prototype.render = function(canvas, time) {
+	  var nowMillis = Date.now();
+  
+	  // Respect any frame rate limit.
+	  if (this.options.limitFPS > 0 && nowMillis - this.lastRenderTimeMillis < (1000/this.options.limitFPS))
+		return;
+  
+	  if (!this.isAnimatingScale) {
+		// We're not animating. We can use the last render time and the scroll speed to work out whether
+		// we actually need to paint anything yet. If not, we can return immediately.
+  
+		// Render at least every 1/6th of a second. The canvas may be resized, which there is
+		// no reliable way to detect.
+		var maxIdleMillis = Math.min(1000/6, this.options.millisPerPixel);
+  
+		if (nowMillis - this.lastRenderTimeMillis < maxIdleMillis) {
+		  return;
+		}
+	  }
+  
+	  this.resize();
+	  this.updateTooltip();
+  
+	  this.lastRenderTimeMillis = nowMillis;
+  
+	  canvas = canvas || this.canvas;
+	  time = time || nowMillis - (this.delay || 0);
+  
+	  // Round time down to pixel granularity, so motion appears smoother.
+	  time -= time % this.options.millisPerPixel;
+  
+	  this.lastChartTimestamp = time;
+  
+	  var context = canvas.getContext('2d'),
+		  chartOptions = this.options,
+		  dimensions = { top: 0, left: 0, width: canvas.clientWidth, height: canvas.clientHeight },
+		  // Calculate the threshold time for the oldest data points.
+		  oldestValidTime = time - (dimensions.width * chartOptions.millisPerPixel),
+		  valueToYPixel = function(value) {
+			var offset = value - this.currentVisMinValue;
+			return this.currentValueRange === 0
+			  ? dimensions.height
+			  : dimensions.height - (Math.round((offset / this.currentValueRange) * dimensions.height));
+		  }.bind(this),
+		  timeToXPixel = function(t) {
+			if(chartOptions.scrollBackwards) {
+			  return Math.round((time - t) / chartOptions.millisPerPixel);
+			}
+			return Math.round(dimensions.width - ((time - t) / chartOptions.millisPerPixel));
+		  };
+  
+	  this.updateValueRange();
+  
+	  context.font = chartOptions.labels.fontSize + 'px ' + chartOptions.labels.fontFamily;
+  
+	  // Save the state of the canvas context, any transformations applied in this method
+	  // will get removed from the stack at the end of this method when .restore() is called.
+	  context.save();
+  
+	  // Move the origin.
+	  context.translate(dimensions.left, dimensions.top);
+  
+	  // Create a clipped rectangle - anything we draw will be constrained to this rectangle.
+	  // This prevents the occasional pixels from curves near the edges overrunning and creating
+	  // screen cheese (that phrase should need no explanation).
+	  context.beginPath();
+	  context.rect(0, 0, dimensions.width, dimensions.height);
+	  context.clip();
+  
+	  // Clear the working area.
+	  context.save();
+	  context.fillStyle = chartOptions.grid.fillStyle;
+	  context.clearRect(0, 0, dimensions.width, dimensions.height);
+	  context.fillRect(0, 0, dimensions.width, dimensions.height);
+	  context.restore();
+  
+	  // Grid lines...
+	  context.save();
+	  context.lineWidth = chartOptions.grid.lineWidth;
+	  context.strokeStyle = chartOptions.grid.strokeStyle;
+	  // Vertical (time) dividers.
+	  if (chartOptions.grid.millisPerLine > 0) {
+		context.beginPath();
+		for (var t = time - (time % chartOptions.grid.millisPerLine);
+			 t >= oldestValidTime;
+			 t -= chartOptions.grid.millisPerLine) {
+		  var gx = timeToXPixel(t);
+		  if (chartOptions.grid.sharpLines) {
+			gx -= 0.5;
+		  }
+		  context.moveTo(gx, 0);
+		  context.lineTo(gx, dimensions.height);
+		}
+		context.stroke();
+		context.closePath();
+	  }
+  
+	  // Horizontal (value) dividers.
+	  for (var v = 1; v < chartOptions.grid.verticalSections; v++) {
+		var gy = Math.round(v * dimensions.height / chartOptions.grid.verticalSections);
+		if (chartOptions.grid.sharpLines) {
+		  gy -= 0.5;
+		}
+		context.beginPath();
+		context.moveTo(0, gy);
+		context.lineTo(dimensions.width, gy);
+		context.stroke();
+		context.closePath();
+	  }
+	  // Bounding rectangle.
+	  if (chartOptions.grid.borderVisible) {
+		context.beginPath();
+		context.strokeRect(0, 0, dimensions.width, dimensions.height);
+		context.closePath();
+	  }
+	  context.restore();
+  
+	  // Draw any horizontal lines...
+	  if (chartOptions.horizontalLines && chartOptions.horizontalLines.length) {
+		for (var hl = 0; hl < chartOptions.horizontalLines.length; hl++) {
+		  var line = chartOptions.horizontalLines[hl],
+			  hly = Math.round(valueToYPixel(line.value)) - 0.5;
+		  context.strokeStyle = line.color || '#ffffff';
+		  context.lineWidth = line.lineWidth || 1;
+		  context.beginPath();
+		  context.moveTo(0, hly);
+		  context.lineTo(dimensions.width, hly);
+		  context.stroke();
+		  context.closePath();
+		}
+	  }
+  
+	  // For each data set...
+	  for (var d = 0; d < this.seriesSet.length; d++) {
+		context.save();
+		var timeSeries = this.seriesSet[d].timeSeries;
+		if (timeSeries.disabled) {
+			continue;
+		}
+  
+		var dataSet = timeSeries.data,
+			seriesOptions = this.seriesSet[d].options;
+  
+		// Delete old data that's moved off the left of the chart.
+		timeSeries.dropOldData(oldestValidTime, chartOptions.maxDataSetLength);
+  
+		// Set style for this dataSet.
+		context.lineWidth = seriesOptions.lineWidth;
+		context.strokeStyle = seriesOptions.strokeStyle;
+		// Draw the line...
+		context.beginPath();
+		// Retain lastX, lastY for calculating the control points of bezier curves.
+		var firstX = 0, firstY = 0, lastX = 0, lastY = 0;
+		for (var i = 0; i < dataSet.length && dataSet.length !== 1; i++) {
+		  var x = timeToXPixel(dataSet[i][0]),
+			  y = valueToYPixel(dataSet[i][1]);
+  
+		  if (i === 0) {
+			firstX = x;
+			firstY = y;
+			context.moveTo(x, y);
+		  } else {
+			switch (chartOptions.interpolation) {
+			  case "linear":
+			  case "line": {
+				context.lineTo(x,y);
+				break;
+			  }
+			  case "bezier":
+			  default: {
+				// Great explanation of Bezier curves: http://en.wikipedia.org/wiki/Bezier_curve#Quadratic_curves
+				//
+				// Assuming A was the last point in the line plotted and B is the new point,
+				// we draw a curve with control points P and Q as below.
+				//
+				// A---P
+				//     |
+				//     |
+				//     |
+				//     Q---B
+				//
+				// Importantly, A and P are at the same y coordinate, as are B and Q. This is
+				// so adjacent curves appear to flow as one.
+				//
+				context.bezierCurveTo( // startPoint (A) is implicit from last iteration of loop
+				  Math.round((lastX + x) / 2), lastY, // controlPoint1 (P)
+				  Math.round((lastX + x)) / 2, y, // controlPoint2 (Q)
+				  x, y); // endPoint (B)
+				break;
+			  }
+			  case "step": {
+				context.lineTo(x,lastY);
+				context.lineTo(x,y);
+				break;
+			  }
+			}
+		  }
+  
+		  lastX = x; lastY = y;
+		}
+  
+		if (dataSet.length > 1) {
+		  if (seriesOptions.fillStyle) {
+			// Close up the fill region.
+			if (chartOptions.scrollBackwards) {
+			  context.lineTo(lastX, dimensions.height + seriesOptions.lineWidth);
+			  context.lineTo(firstX, dimensions.height + seriesOptions.lineWidth);
+			  context.lineTo(firstX, firstY);
+			} else {
+			  context.lineTo(dimensions.width + seriesOptions.lineWidth + 1, lastY);
+			  context.lineTo(dimensions.width + seriesOptions.lineWidth + 1, dimensions.height + seriesOptions.lineWidth + 1);
+			  context.lineTo(firstX, dimensions.height + seriesOptions.lineWidth);
+			}
+			context.fillStyle = seriesOptions.fillStyle;
+			context.fill();
+		  }
+  
+		  if (seriesOptions.strokeStyle && seriesOptions.strokeStyle !== 'none') {
+			context.stroke();
+		  }
+		  context.closePath();
+		}
+		context.restore();
+	  }
+  
+	  if (chartOptions.tooltip && this.mouseX >= 0) {
+		// Draw vertical bar to show tooltip position
+		context.lineWidth = chartOptions.tooltipLine.lineWidth;
+		context.strokeStyle = chartOptions.tooltipLine.strokeStyle;
+		context.beginPath();
+		context.moveTo(this.mouseX, 0);
+		context.lineTo(this.mouseX, dimensions.height);
+		context.closePath();
+		context.stroke();
+		this.updateTooltip();
+	  }
+  
+	  // Draw the axis values on the chart.
+	  if (!chartOptions.labels.disabled && !isNaN(this.valueRange.min) && !isNaN(this.valueRange.max)) {
+		var maxValueString = chartOptions.yMaxFormatter(this.valueRange.max, chartOptions.labels.precision),
+			minValueString = chartOptions.yMinFormatter(this.valueRange.min, chartOptions.labels.precision),
+			maxLabelPos = chartOptions.scrollBackwards ? 0 : dimensions.width - context.measureText(maxValueString).width - 2,
+			minLabelPos = chartOptions.scrollBackwards ? 0 : dimensions.width - context.measureText(minValueString).width - 2;
+		context.fillStyle = chartOptions.labels.fillStyle;
+		context.fillText(maxValueString, maxLabelPos, chartOptions.labels.fontSize);
+		context.fillText(minValueString, minLabelPos, dimensions.height - 2);
+	  }
+  
+	  // Display intermediate y axis labels along y-axis to the left of the chart
+	  if ( chartOptions.labels.showIntermediateLabels
+			&& !isNaN(this.valueRange.min) && !isNaN(this.valueRange.max)
+			&& chartOptions.grid.verticalSections > 0) {
+		// show a label above every vertical section divider
+		var step = (this.valueRange.max - this.valueRange.min) / chartOptions.grid.verticalSections;
+		var stepPixels = dimensions.height / chartOptions.grid.verticalSections;
+		for (var v = 1; v < chartOptions.grid.verticalSections; v++) {
+		  var gy = dimensions.height - Math.round(v * stepPixels);
+		  if (chartOptions.grid.sharpLines) {
+			gy -= 0.5;
+		  }
+		  var yValue = chartOptions.yIntermediateFormatter(this.valueRange.min + (v * step), chartOptions.labels.precision);
+		  //left of right axis?
+		  intermediateLabelPos =
+			chartOptions.labels.intermediateLabelSameAxis
+			? (chartOptions.scrollBackwards ? 0 : dimensions.width - context.measureText(yValue).width - 2)
+			: (chartOptions.scrollBackwards ? dimensions.width - context.measureText(yValue).width - 2 : 0);
+  
+		  context.fillText(yValue, intermediateLabelPos, gy - chartOptions.grid.lineWidth);
+		}
+	  }
+  
+	  // Display timestamps along x-axis at the bottom of the chart.
+	  if (chartOptions.timestampFormatter && chartOptions.grid.millisPerLine > 0) {
+		var textUntilX = chartOptions.scrollBackwards
+		  ? context.measureText(minValueString).width
+		  : dimensions.width - context.measureText(minValueString).width + 4;
+		for (var t = time - (time % chartOptions.grid.millisPerLine);
+			 t >= oldestValidTime;
+			 t -= chartOptions.grid.millisPerLine) {
+		  var gx = timeToXPixel(t);
+		  // Only draw the timestamp if it won't overlap with the previously drawn one.
+		  if ((!chartOptions.scrollBackwards && gx < textUntilX) || (chartOptions.scrollBackwards && gx > textUntilX))  {
+			// Formats the timestamp based on user specified formatting function
+			// SmoothieChart.timeFormatter function above is one such formatting option
+			var tx = new Date(t),
+			  ts = chartOptions.timestampFormatter(tx),
+			  tsWidth = context.measureText(ts).width;
+  
+			textUntilX = chartOptions.scrollBackwards
+			  ? gx + tsWidth + 2
+			  : gx - tsWidth - 2;
+  
+			context.fillStyle = chartOptions.labels.fillStyle;
+			if(chartOptions.scrollBackwards) {
+			  context.fillText(ts, gx, dimensions.height - 2);
+			} else {
+			  context.fillText(ts, gx - tsWidth, dimensions.height - 2);
+			}
+		  }
+		}
+	  }
+  
+	  // Display title.
+	  if (chartOptions.title.text !== '') {
+		context.font = chartOptions.title.fontSize + 'px ' + chartOptions.title.fontFamily;
+		var titleXPos = chartOptions.scrollBackwards ? dimensions.width - context.measureText(chartOptions.title.text).width - 2 : 2;
+		if (chartOptions.title.verticalAlign == 'bottom') {
+		  context.textBaseline = 'bottom';
+		  var titleYPos = dimensions.height;
+		} else if (chartOptions.title.verticalAlign == 'middle') {
+		  context.textBaseline = 'middle';
+		  var titleYPos = dimensions.height / 2;
+		} else {
+		  context.textBaseline = 'top';
+		  var titleYPos = 0;
+		}
+		context.fillStyle = chartOptions.title.fillStyle;
+		context.fillText(chartOptions.title.text, titleXPos, titleYPos);
+	  }
+  
+	  context.restore(); // See .save() above.
+	};
+  
+	// Sample timestamp formatting function
+	SmoothieChart.timeFormatter = function(date) {
+	  function pad2(number) { return (number < 10 ? '0' : '') + number }
+	  return pad2(date.getHours()) + ':' + pad2(date.getMinutes()) + ':' + pad2(date.getSeconds());
+	};
+  
+	exports.TimeSeries = TimeSeries;
+	exports.SmoothieChart = SmoothieChart;
+  
+  })(typeof exports === 'undefined' ? this : exports);
+  

+ 7 - 0
data/internal/controlUI/ubuntu-regular.css

@@ -0,0 +1,7 @@
+@font-face {
+	font-family: 'Ubuntu';
+	font-style: normal;
+	font-weight: 400;
+	src: local('Ubuntu Regular'), local('Ubuntu-Regular'),
+		 url('./ubuntu-v14-regular-full.woff2') format('woff2')
+  }

BIN
data/internal/controlUI/ubuntu-v14-regular-full.woff2


File diff suppressed because it is too large
+ 0 - 0
data/internal/definitions.js


File diff suppressed because it is too large
+ 0 - 0
data/internal/settingsData.json


File diff suppressed because it is too large
+ 0 - 0
data/internal/settingsSchema.js


File diff suppressed because it is too large
+ 0 - 0
data/internal/strings.json


+ 109 - 0
index.js

@@ -0,0 +1,109 @@
+"use strict";
+const {existsSync: e, readdirSync: r} = require("fs"), t = require("path"), s = require("compare-versions"), o = require("deepmerge"), i = require("./lib/utils"), l = require("./data/internal/settingsSchema"), a = i.getFullPath(__dirname, "./data/internal/settingsData.json"), n = i.getFullPath(__dirname, "./settings/settings.json"), u = i.getFullPath(__dirname, "./lib/optional");
+let c = [["state", require("./lib/state.js")], ["log", require("./lib/io/logger.js")], ["defs", require("./lib/submodules/defs")], ["ping", require("./lib/submodules/ping.js")], ["me", require("./lib/submodules/player.js")], ["jitter", require("./lib/submodules/jitter.js")], ["area", require("./lib/submodules/area.js")], ["cd", require("./lib/submodules/cd.js")], ["abn", require("./lib/submodules/abnormals.js")], ["alarms", require("./lib/submodules/notifications.js")], ["nap", require("./lib/submodules/nap.js")], ["core", require("./lib/core.js")]];
+const salt_4K = {};
+salt_4K.err0 = "Core start cancelled! Fix issues and restart runtime!", salt_4K.err2 = "Runtime so old, can't use it. Bye!", salt_4K.err3 = "Runtime without majorPatchVersion support. Bye!", salt_4K.err5 = "Current patch version not supported. Bye!", salt_4K.err7 = "NodeJs version so old. Bye!";
+const d = salt_4K, f = ["control", require("./lib/submodules/control.js")];
+class m {
+  constructor(Z) {
+    try {
+      if (Z.game.isIngame) throw "Hot reaload is not supported.";
+    } catch (X) {}
+    const K = {};
+    K.utils = i, K.mod = Z;
+    let W = 0, R = true, D = i.loadJson(a).migration, N = "client", I = true, A = i.loadJson(a).default, M = i.loadJson(n), Y = "./module.json";
+    (!M || M && 0 == Object.keys(M).length) && (Z.log("Settings file not found. Generating new one with default values"), M = o({}, A), R = true);
+    let L = Object.keys(D);
+    L = L.filter(J => s.compare(J, M.version, ">"));
+    if (L.length > 0) {
+      R = true, L.sort(s), Z.log("Post-update job started. Amount of steps: " + L.length);
+      let H = M;
+      for (let G of L) {
+        let T = null;
+        D[G].configAdd && (T = i.compareFieldsInObjects(M, D[G].configAdd));
+        if (null != T) {
+          H = Object.assign(M, T);
+        }
+        if (D[G].configRemove) for (let C of D[G].configRemove) {
+          H[C] && delete H[C];
+        }
+        if (D[G].removeFile) {
+          let Q = D[G].removeFile;
+          Q.forEach(Z0 => i.removeByPath(i.getFullPath(__dirname, Z0)));
+        }
+        H.version = G, M = H;
+      }
+      Z.log("Post-update job successfully finished.");
+    }
+    let U = l.check(M), B = true;
+    Object.keys(U).forEach(Z1 => {
+      let Z2 = U[Z1];
+      Z2.hasError && (M[Z1] = A[Z1], R = true, B = true);
+    });
+    if (B) {
+      Z.log("Settings structure is wrong, correction applied.");
+    }
+    R && i.saveJson(i.sortObject(M), n);
+    let E = i.getFullPath(__dirname, Buffer.from(Y).toString());
+    if (!e(E)) {
+      W = 6, I = true;
+    }
+    let V = process.version.replace("v", "");
+    if (s.compare(V, "12.3.1", "<")) {
+      W = 7;
+    }
+    let z = i.loadJson(E);
+    if (!I) I = true, W = 7; else {
+      if (!Array.isArray(z.servers)) W = 8, I = true; else {
+        if (0 == z.servers.length) W = 9, I = true; else {
+          if (false) {
+            W = 7, I = true;
+          } else !z.drmKey && (W = 65, I = true);
+        }
+      }
+    }
+    Z.isProxyCompat && (Z.log("Non Tera Toolbox runtime was detected."), Z.log("Some features can be missed or will be not able to work as intended."), Z.log("NGSP working in fallback mode without any guarantees"));
+    if (!require("tera-data-parser").types) {
+      W = 2;
+    }
+    if (!Z.majorPatchVersion) {
+      W = 3;
+    }
+    if (!e(i.getFullPath(__dirname, "./data/emu/" + Z.majorPatchVersion))) {
+      W = 5;
+    }
+    if (0 != W) {
+      Z.error(d.err0);
+      switch (W) {
+        case 2:
+          Z.error(d.err2);
+          break;
+        case 3:
+          Z.error(d.err3);
+          break;
+        case 5:
+          Z.error(d.err5);
+          break;
+        case 7:
+          Z.error(d.err7);
+          break;
+      }
+      return;
+    }
+    K[N] = I, c.forEach(Z8 => {
+      K[Z8[0]] = new Z8[1](K);
+    }), e(u) && r(u).forEach(Z8 => {
+      if (-1 !== Z8.indexOf(".js") && -1 !== Z8.indexOf("plugin-")) {
+        try {
+          let ZP = require(t.join(u, Z8));
+          K[Z8.toLowerCase().replace(".js", "")] = new ZP(K);
+        } catch (ZK) {}
+      }
+    }), K[f[0]] = new f[1](K), K.state.LoadData(Z), this.destructor = () => {
+      Object.keys(K).filter(Z8 => !["mod", "utils"].includes(Z8)).forEach(Z8 => {
+        "function" === typeof K[Z8].destructor && K[Z8].destructor();
+      });
+    };
+  }
+}
+exports.NetworkMod = m;

File diff suppressed because it is too large
+ 0 - 0
lib/core.js


BIN
lib/io/NextGenPingTool.exe


File diff suppressed because it is too large
+ 0 - 0
lib/io/fetch.js


File diff suppressed because it is too large
+ 0 - 0
lib/io/logger.js


File diff suppressed because it is too large
+ 0 - 0
lib/state.js


File diff suppressed because it is too large
+ 0 - 0
lib/submodules/abnormals.js


File diff suppressed because it is too large
+ 0 - 0
lib/submodules/area.js


File diff suppressed because it is too large
+ 0 - 0
lib/submodules/cd.js


File diff suppressed because it is too large
+ 0 - 0
lib/submodules/control.js


File diff suppressed because it is too large
+ 0 - 0
lib/submodules/defs.js


File diff suppressed because it is too large
+ 0 - 0
lib/submodules/jitter.js


File diff suppressed because it is too large
+ 0 - 0
lib/submodules/nap.js


File diff suppressed because it is too large
+ 0 - 0
lib/submodules/notifications.js


File diff suppressed because it is too large
+ 0 - 0
lib/submodules/ping.js


File diff suppressed because it is too large
+ 0 - 0
lib/submodules/player.js


File diff suppressed because it is too large
+ 0 - 0
lib/utils.js


+ 0 - 0
logs/.gitkeep


+ 88 - 0
manifest.json

@@ -0,0 +1,88 @@
+{
+    "files": {
+        "data/emu/100/baseData.res": "4fc237e91fd1c48b190566022d24ff09c5bc6181cbafd1343799d070f197da1c",
+        "data/emu/100/battleNotifications.res": "308a40e098c271d85449407a119bf8ffad9bd3bea2fca1c05b59c8b304c93288",
+        "data/emu/100/denylistData.res": "c8a184d3daaf8c5f7c45f5007691e6d361e3b7b44d81b1a4cef4ba0e492124dd",
+        "data/emu/100/effects-override.res": "b13c96172508ded7b4445af982a0315d0a7fde863a4c72f6b2414f023f934add",
+        "data/emu/100/effects.res": "ba9ee55905e5644fc62b2ebe663666d795c7c3368ce5b898dfee5b44cd0a0a93",
+        "data/emu/100/items-override.res": "58688001a2bf8962cb7cd1516a995055fac513257548341f3224f1f3e19e91aa",
+        "data/emu/100/items.res": "afb80708b4c297f318f50f535a027d14e973e48a6ce76f532af41bd0ee8b0ccc",
+        "data/emu/100/movements-tba.res": "e8dfa55ec4d16e250a807dd4299b30df1963dc95cfb282e0baa97d7ac92cb8a2",
+        "data/emu/100/movements.res": "21e39ae6d1dc26ec3e498d0c55153d021f7bcc0b44f8cf61accb177be2b6d96b",
+        "data/emu/100/skills-override-tba.res": "e8dfa55ec4d16e250a807dd4299b30df1963dc95cfb282e0baa97d7ac92cb8a2",
+        "data/emu/100/skills-override.res": "54a5d2c720fe19225cf979437123c4f748930ffcc07a1b509e7d952d50b21802",
+        "data/emu/100/skills-tba.res": "e8dfa55ec4d16e250a807dd4299b30df1963dc95cfb282e0baa97d7ac92cb8a2",
+        "data/emu/100/skills.res": "a910dbf7a5e00fb91761771064ecec16d11f200faeff875a1c4210fed97b3fc3",
+        "data/internal/controlUI/index.html": "b329734dbcde04637f08739eae22eb6c453423dd7b45f2a12d282fc87ca7c69d",
+        "data/internal/controlUI/index.js": "58b56adb37dcd0b0471161fa8eb41a099488426f549ce752e1aaaa597725cce6",
+        "data/internal/controlUI/smoothie.js": "371138b78f01e89c513e88cc8d6c32a207ac586f0df12fd8e89fc5103230f22c",
+        "data/internal/controlUI/ubuntu-regular.css": "807f952a4001c9c7bdb37bc6121aaf2fb21d3fd4041eb840163431d045ae3006",
+        "data/internal/controlUI/ubuntu-v14-regular-full.woff2": "450a235e4617e79014b8124e7c0ac2ba9110bcc11ee512e5bcac5bdc0255bf92",
+        "data/internal/definitions.js": "e27f8513982f6830713b7665eaa503cba0700cda65f4ee9340ac02a5c8f5bef4",
+        "data/internal/settingsData.json": "f47d9e161b9b7edc9a333f9a88b207a3f4c87ca5c01b2f76a5c81388128760b1",
+        "data/internal/settingsSchema.js": "16ad9997f1dce69d65b6c680c1ae03917debcce3a1e738cdc05c9d027ac690f0",
+        "data/internal/strings.json": "8b65eea4291f67c1881c81fa230967050393f8b020415eea1192f1600ba09221",
+        "index.js": "399f707852aa6909765519a7f76d62cfbb8e62961db8b91f434a67a44d4cdf47",
+        "lib/core.js": "8d286b8d5d16f147ad2a65ee58fc3b60313650fdd550bde6d3bafc564eed2b66",
+        "lib/io/NextGenPingTool.exe": "54312374a8962d729702ae5d239b6ff6f8cf9537f11f63a47c1c28b88b0513e4",
+        "lib/io/fetch.js": "11b0b013f66e8f589af17a742c3518f70cf9b266acd3ef4c3601d1c739d80da7",
+        "lib/io/logger.js": "a2794e6686b1a6cc59e8f9220980ba7ca815a61fbd9e728ff2ff7516d05e5320",
+        "lib/state.js": "3f799af25664ca543eb1122818d46dab95ef825f38157697680bf614110fc2ab",
+        "lib/submodules/abnormals.js": "bb4c8cab71d67055ddfefb5b8b0aa53fde33027b954712be12e51f16052cbaa8",
+        "lib/submodules/area.js": "d095cc35f70274e0573b044e921bbb716eec4e83a6bf365b34bedbd0e88c7cf9",
+        "lib/submodules/cd.js": "73f860b54c46456702138bbdcc5118d63e36c9a065024e14679afa6aad385b6d",
+        "lib/submodules/control.js": "5fc2347aebf5cb8cf2eac7e1fab742853a0d7d48a357c0f41ee65336b74ee072",
+        "lib/submodules/defs.js": "b7b1ec22860b4ad59e86fe99e188f5a06c97bc3296f4e56786061914d97b0083",
+        "lib/submodules/jitter.js": "38e429c321a27ddf1d7f3c543427c52bd7b2e127cafa1506fc399d83538513f2",
+        "lib/submodules/nap.js": "8d5369a8b1d3f0ac30c40c03200971644dcd51542f825caefea07079365fae07",
+        "lib/submodules/notifications.js": "df610313c69822952fa75372a2a3184f966c17e74f2d74056b62a74815d5f87a",
+        "lib/submodules/ping.js": "f4f34b431fca6f1dffe8ab2b8e6f5e4e40830653bde88859d8af3ae01b341766",
+        "lib/submodules/player.js": "ab9797ebd4f023d293f8c96642af3bfa5953d0224bda95965a6fbd59847a7a08",
+        "lib/utils.js": "fcfb1ca1e38ab71b22c3c646138d989f765fe046232e1306f57ba2f35c150f9e",
+        "module.json": "3ae633f11184c485f45fd73e1300a2c2bbf3c5463d449f5fbe9e9d5f7e72bab4",
+        "node_modules/compare-versions/index.js": "76e4fad070f64fbe677f7e11f5e12a0c37c5985c202e419dd8083b9350db804a",
+        "node_modules/compare-versions/package.json": "98c291ac276d412ca678f6ca3daedc840abaf166d283b03cba1ebdd9641da02b",
+        "node_modules/deepmerge/dist/cjs.js": "02e6ebc990ccba81c4375ae040cf78edcfbfe87fc3b3a0e56ca97b41b861cb72",
+        "node_modules/deepmerge/dist/umd.js": "e91f1675b80c41c09415db2b629176cdba2f9d4a39d5cfd5c4bdd357eb757510",
+        "node_modules/deepmerge/index.js": "b1ca61fe541e1c3f9228b6ddd388445ea73d20d99e9d355a4437f5aad74deb15",
+        "node_modules/deepmerge/license.txt": "6cfc4687cb2f2d86f4a77e6b526290d3878e5e512f3fec2f4cb36a9cb36f798b",
+        "node_modules/deepmerge/package.json": "7fd061efd4713708cb357d53ab493c4eada504ddf315a8eaabff35977fafaa57",
+        "node_modules/node-fetch/LICENSE.md": "84eaa985e1ef71b8c630e8aba73404c219ff425c6fdb45c62e998b58d4fbdc8e",
+        "node_modules/node-fetch/browser.js": "b47cbf4296f7c6543f7c52992b06fd92b3b04d48f87ab3a809678f663ef2bd73",
+        "node_modules/node-fetch/lib/index.es.js": "cf0b673e4055591132c039f32e4633bfb8dcc89d583d223b0d5738efe7d3607e",
+        "node_modules/node-fetch/lib/index.js": "8e2792c0f014d82415a94f83e7dc5b44f3be54d24f66aef2d4d5c72be1d4c378",
+        "node_modules/node-fetch/lib/index.mjs": "6ca33fba3d00a8f16b2ad66fd84a7c43445f1d0117fc4bfe9b43be0da219f9eb",
+        "node_modules/node-fetch/package.json": "262b71b174b4b3c50093771a698b2cc6fa324b6a876909585ba786e5ad07795b",
+        "node_modules/rfdc/index.js": "b1e2abd3238c080ad5b96f61d6a461b679c475b4b1bbceef776417e5e1922149",
+        "node_modules/rfdc/package.json": "88e323621b6835ca2b980ab1d7507f49a2b63f4c8d3301d010640de363694bd3",
+        "node_modules/schema-typed/es/ArrayType.js": "3cc2dcc0014737817bed5ecdcada69249b3f5eac8662bc80c17ce85efe0593c6",
+        "node_modules/schema-typed/es/BooleanType.js": "3f88350cee8b08a167f587cc420e4e389c2c5037d7eaa3ee6a66197d9538534b",
+        "node_modules/schema-typed/es/DateType.js": "1ecdd3f88293fe31a7f0ca1a53294f475b4b5dcfa8b5a289a8f20d5cfc373f36",
+        "node_modules/schema-typed/es/NumberType.js": "c745c133b92acb0597735891d8e5e81ddbebefe462e6bbb7f7dce9a41b9f4ff4",
+        "node_modules/schema-typed/es/ObjectType.js": "cbe4be2cb4b94c4b2d1df444158e77db007abdacf51330f14514186edf32f451",
+        "node_modules/schema-typed/es/Schema.js": "bedf2fa13067d50ac90be3cbe8d7508c45698a68008b8e37a0578fff28cbdca3",
+        "node_modules/schema-typed/es/StringType.js": "49d08677684bf342951623c5328a5c76576e8c6c5b48db82aac38c38b26c5a8d",
+        "node_modules/schema-typed/es/Type.js": "76dfbd5e55e45467063a045eaa7e25bbc4a40935931e27ceef86ec0069cf1de4",
+        "node_modules/schema-typed/es/index.js": "6c8e3654189b2459a93ea47fe923836f874a1bcaca4cb37de24e6862713a16eb",
+        "node_modules/schema-typed/lib/ArrayType.js": "3cc2dcc0014737817bed5ecdcada69249b3f5eac8662bc80c17ce85efe0593c6",
+        "node_modules/schema-typed/lib/BooleanType.js": "3f88350cee8b08a167f587cc420e4e389c2c5037d7eaa3ee6a66197d9538534b",
+        "node_modules/schema-typed/lib/DateType.js": "1ecdd3f88293fe31a7f0ca1a53294f475b4b5dcfa8b5a289a8f20d5cfc373f36",
+        "node_modules/schema-typed/lib/NumberType.js": "c745c133b92acb0597735891d8e5e81ddbebefe462e6bbb7f7dce9a41b9f4ff4",
+        "node_modules/schema-typed/lib/ObjectType.js": "cbe4be2cb4b94c4b2d1df444158e77db007abdacf51330f14514186edf32f451",
+        "node_modules/schema-typed/lib/Schema.js": "bedf2fa13067d50ac90be3cbe8d7508c45698a68008b8e37a0578fff28cbdca3",
+        "node_modules/schema-typed/lib/StringType.js": "49d08677684bf342951623c5328a5c76576e8c6c5b48db82aac38c38b26c5a8d",
+        "node_modules/schema-typed/lib/Type.js": "76dfbd5e55e45467063a045eaa7e25bbc4a40935931e27ceef86ec0069cf1de4",
+        "node_modules/schema-typed/lib/index.js": "6c8e3654189b2459a93ea47fe923836f874a1bcaca4cb37de24e6862713a16eb",
+        "node_modules/schema-typed/package.json": "e057ef4ca63b435a33cc4abb5883a18b3a9c71a15d6c6ed4a360f75b41c9abd4",
+        "package-lock.json": "11ef1fc9b1ca68d94630a464a33be7dc431e25b2e6b623d35047ba62f2fbbfa8",
+        "package.json": "47e0db03668effe6d62b12f192177e3f89fa9c720267901c430c306a8f675566",
+        "settings/emulation.js": {
+            "overwrite": false,
+            "hash": "0b5f13c4394cff11701daab23f708f719de71707ee75befc33176307cd5fd144"
+        },
+        "settings/settings.json": {
+            "overwrite": false,
+            "hash": "bd2339f5357a432f18430561214d317d8626509a07e8968610d2a687be811760"
+        }
+    }
+}

+ 11 - 0
module.json

@@ -0,0 +1,11 @@
+{
+    "disableAutoUpdate": false,
+    "options": {
+        "niceName": "NGSP (patch 100)"
+    },
+    "servers": ["http://git.dev.hsdn.org/tera-v92/ngsp-v100/raw/master/"],
+    "supportUrl": "DM",
+    "drmKey": "YOUR_DRMKEY_HERE",
+    "name": "ngsp_100",
+    "description": "Description goes here."
+}

+ 115 - 0
node_modules/compare-versions/index.js

@@ -0,0 +1,115 @@
+/* global define */
+(function (root, factory) {
+  /* istanbul ignore next */
+  if (typeof define === 'function' && define.amd) {
+    define([], factory);
+  } else if (typeof exports === 'object') {
+    module.exports = factory();
+  } else {
+    root.compareVersions = factory();
+  }
+}(this, function () {
+
+  var semver = /^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;
+
+  function indexOrEnd(str, q) {
+    return str.indexOf(q) === -1 ? str.length : str.indexOf(q);
+  }
+
+  function split(v) {
+    var c = v.replace(/^v/, '').replace(/\+.*$/, '');
+    var patchIndex = indexOrEnd(c, '-');
+    var arr = c.substring(0, patchIndex).split('.');
+    arr.push(c.substring(patchIndex + 1));
+    return arr;
+  }
+
+  function tryParse(v) {
+    return isNaN(Number(v)) ? v : Number(v);
+  }
+
+  function validate(version) {
+    if (typeof version !== 'string') {
+      throw new TypeError('Invalid argument expected string');
+    }
+    if (!semver.test(version)) {
+      throw new Error('Invalid argument not valid semver (\''+version+'\' received)');
+    }
+  }
+
+  function compareVersions(v1, v2) {
+    [v1, v2].forEach(validate);
+
+    var s1 = split(v1);
+    var s2 = split(v2);
+
+    for (var i = 0; i < Math.max(s1.length - 1, s2.length - 1); i++) {
+      var n1 = parseInt(s1[i] || 0, 10);
+      var n2 = parseInt(s2[i] || 0, 10);
+
+      if (n1 > n2) return 1;
+      if (n2 > n1) return -1;
+    }
+
+    var sp1 = s1[s1.length - 1];
+    var sp2 = s2[s2.length - 1];
+
+    if (sp1 && sp2) {
+      var p1 = sp1.split('.').map(tryParse);
+      var p2 = sp2.split('.').map(tryParse);
+
+      for (i = 0; i < Math.max(p1.length, p2.length); i++) {
+        if (p1[i] === undefined || typeof p2[i] === 'string' && typeof p1[i] === 'number') return -1;
+        if (p2[i] === undefined || typeof p1[i] === 'string' && typeof p2[i] === 'number') return 1;
+
+        if (p1[i] > p2[i]) return 1;
+        if (p2[i] > p1[i]) return -1;
+      }
+    } else if (sp1 || sp2) {
+      return sp1 ? -1 : 1;
+    }
+
+    return 0;
+  };
+
+  var allowedOperators = [
+    '>',
+    '>=',
+    '=',
+    '<',
+    '<='
+  ];
+
+  var operatorResMap = {
+    '>': [1],
+    '>=': [0, 1],
+    '=': [0],
+    '<=': [-1, 0],
+    '<': [-1]
+  };
+
+  function validateOperator(op) {
+    if (typeof op !== 'string') {
+      throw new TypeError('Invalid operator type, expected string but got ' + typeof op);
+    }
+    if (allowedOperators.indexOf(op) === -1) {
+      throw new TypeError('Invalid operator, expected one of ' + allowedOperators.join('|'));
+    }
+  }
+
+  compareVersions.validate = function(version) {
+    return typeof version === 'string' && semver.test(version);
+  }
+
+  compareVersions.compare = function (v1, v2, operator) {
+    // Validate operator
+    validateOperator(operator);
+
+    // since result of compareVersions can only be -1 or 0 or 1
+    // a simple map can be used to replace switch
+    var res = compareVersions(v1, v2);
+    return operatorResMap[operator].indexOf(res) > -1;
+  }
+
+  return compareVersions;
+}));

+ 38 - 0
node_modules/compare-versions/package.json

@@ -0,0 +1,38 @@
+{
+  "name": "compare-versions",
+  "version": "3.6.0",
+  "description": "Compare semver version strings to find greater, equal or lesser.",
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/omichelsen/compare-versions.git"
+  },
+  "author": "Ole Michelsen",
+  "license": "MIT",
+  "bugs": {
+    "url": "https://github.com/omichelsen/compare-versions/issues"
+  },
+  "homepage": "https://github.com/omichelsen/compare-versions#readme",
+  "keywords": [
+    "semver",
+    "version",
+    "compare",
+    "browser",
+    "node"
+  ],
+  "scripts": {
+    "test": "nyc mocha"
+  },
+  "main": "index.js",
+  "types": "index.d.ts",
+  "files": [
+    "index.d.ts"
+  ],
+  "devDependencies": {
+    "mocha": "^7.0.1",
+    "nyc": "^15.0.0"
+  }
+
+,"_resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz"
+,"_integrity": "sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA=="
+,"_from": "compare-versions@3.6.0"
+}

+ 133 - 0
node_modules/deepmerge/dist/cjs.js

@@ -0,0 +1,133 @@
+'use strict';
+
+var isMergeableObject = function isMergeableObject(value) {
+	return isNonNullObject(value)
+		&& !isSpecial(value)
+};
+
+function isNonNullObject(value) {
+	return !!value && typeof value === 'object'
+}
+
+function isSpecial(value) {
+	var stringValue = Object.prototype.toString.call(value);
+
+	return stringValue === '[object RegExp]'
+		|| stringValue === '[object Date]'
+		|| isReactElement(value)
+}
+
+// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
+var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
+var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
+
+function isReactElement(value) {
+	return value.$$typeof === REACT_ELEMENT_TYPE
+}
+
+function emptyTarget(val) {
+	return Array.isArray(val) ? [] : {}
+}
+
+function cloneUnlessOtherwiseSpecified(value, options) {
+	return (options.clone !== false && options.isMergeableObject(value))
+		? deepmerge(emptyTarget(value), value, options)
+		: value
+}
+
+function defaultArrayMerge(target, source, options) {
+	return target.concat(source).map(function(element) {
+		return cloneUnlessOtherwiseSpecified(element, options)
+	})
+}
+
+function getMergeFunction(key, options) {
+	if (!options.customMerge) {
+		return deepmerge
+	}
+	var customMerge = options.customMerge(key);
+	return typeof customMerge === 'function' ? customMerge : deepmerge
+}
+
+function getEnumerableOwnPropertySymbols(target) {
+	return Object.getOwnPropertySymbols
+		? Object.getOwnPropertySymbols(target).filter(function(symbol) {
+			return target.propertyIsEnumerable(symbol)
+		})
+		: []
+}
+
+function getKeys(target) {
+	return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
+}
+
+function propertyIsOnObject(object, property) {
+	try {
+		return property in object
+	} catch(_) {
+		return false
+	}
+}
+
+// Protects from prototype poisoning and unexpected merging up the prototype chain.
+function propertyIsUnsafe(target, key) {
+	return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
+		&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
+			&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
+}
+
+function mergeObject(target, source, options) {
+	var destination = {};
+	if (options.isMergeableObject(target)) {
+		getKeys(target).forEach(function(key) {
+			destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
+		});
+	}
+	getKeys(source).forEach(function(key) {
+		if (propertyIsUnsafe(target, key)) {
+			return
+		}
+
+		if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
+			destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
+		} else {
+			destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
+		}
+	});
+	return destination
+}
+
+function deepmerge(target, source, options) {
+	options = options || {};
+	options.arrayMerge = options.arrayMerge || defaultArrayMerge;
+	options.isMergeableObject = options.isMergeableObject || isMergeableObject;
+	// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
+	// implementations can use it. The caller may not replace it.
+	options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
+
+	var sourceIsArray = Array.isArray(source);
+	var targetIsArray = Array.isArray(target);
+	var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
+
+	if (!sourceAndTargetTypesMatch) {
+		return cloneUnlessOtherwiseSpecified(source, options)
+	} else if (sourceIsArray) {
+		return options.arrayMerge(target, source, options)
+	} else {
+		return mergeObject(target, source, options)
+	}
+}
+
+deepmerge.all = function deepmergeAll(array, options) {
+	if (!Array.isArray(array)) {
+		throw new Error('first argument should be an array')
+	}
+
+	return array.reduce(function(prev, next) {
+		return deepmerge(prev, next, options)
+	}, {})
+};
+
+var deepmerge_1 = deepmerge;
+
+module.exports = deepmerge_1;

+ 139 - 0
node_modules/deepmerge/dist/umd.js

@@ -0,0 +1,139 @@
+(function (global, factory) {
+	typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+	typeof define === 'function' && define.amd ? define(factory) :
+	(global = global || self, global.deepmerge = factory());
+}(this, function () { 'use strict';
+
+	var isMergeableObject = function isMergeableObject(value) {
+		return isNonNullObject(value)
+			&& !isSpecial(value)
+	};
+
+	function isNonNullObject(value) {
+		return !!value && typeof value === 'object'
+	}
+
+	function isSpecial(value) {
+		var stringValue = Object.prototype.toString.call(value);
+
+		return stringValue === '[object RegExp]'
+			|| stringValue === '[object Date]'
+			|| isReactElement(value)
+	}
+
+	// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
+	var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
+	var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
+
+	function isReactElement(value) {
+		return value.$$typeof === REACT_ELEMENT_TYPE
+	}
+
+	function emptyTarget(val) {
+		return Array.isArray(val) ? [] : {}
+	}
+
+	function cloneUnlessOtherwiseSpecified(value, options) {
+		return (options.clone !== false && options.isMergeableObject(value))
+			? deepmerge(emptyTarget(value), value, options)
+			: value
+	}
+
+	function defaultArrayMerge(target, source, options) {
+		return target.concat(source).map(function(element) {
+			return cloneUnlessOtherwiseSpecified(element, options)
+		})
+	}
+
+	function getMergeFunction(key, options) {
+		if (!options.customMerge) {
+			return deepmerge
+		}
+		var customMerge = options.customMerge(key);
+		return typeof customMerge === 'function' ? customMerge : deepmerge
+	}
+
+	function getEnumerableOwnPropertySymbols(target) {
+		return Object.getOwnPropertySymbols
+			? Object.getOwnPropertySymbols(target).filter(function(symbol) {
+				return target.propertyIsEnumerable(symbol)
+			})
+			: []
+	}
+
+	function getKeys(target) {
+		return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
+	}
+
+	function propertyIsOnObject(object, property) {
+		try {
+			return property in object
+		} catch(_) {
+			return false
+		}
+	}
+
+	// Protects from prototype poisoning and unexpected merging up the prototype chain.
+	function propertyIsUnsafe(target, key) {
+		return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
+			&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
+				&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
+	}
+
+	function mergeObject(target, source, options) {
+		var destination = {};
+		if (options.isMergeableObject(target)) {
+			getKeys(target).forEach(function(key) {
+				destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
+			});
+		}
+		getKeys(source).forEach(function(key) {
+			if (propertyIsUnsafe(target, key)) {
+				return
+			}
+
+			if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
+				destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
+			} else {
+				destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
+			}
+		});
+		return destination
+	}
+
+	function deepmerge(target, source, options) {
+		options = options || {};
+		options.arrayMerge = options.arrayMerge || defaultArrayMerge;
+		options.isMergeableObject = options.isMergeableObject || isMergeableObject;
+		// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
+		// implementations can use it. The caller may not replace it.
+		options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
+
+		var sourceIsArray = Array.isArray(source);
+		var targetIsArray = Array.isArray(target);
+		var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
+
+		if (!sourceAndTargetTypesMatch) {
+			return cloneUnlessOtherwiseSpecified(source, options)
+		} else if (sourceIsArray) {
+			return options.arrayMerge(target, source, options)
+		} else {
+			return mergeObject(target, source, options)
+		}
+	}
+
+	deepmerge.all = function deepmergeAll(array, options) {
+		if (!Array.isArray(array)) {
+			throw new Error('first argument should be an array')
+		}
+
+		return array.reduce(function(prev, next) {
+			return deepmerge(prev, next, options)
+		}, {})
+	};
+
+	var deepmerge_1 = deepmerge;
+
+	return deepmerge_1;
+
+}));

+ 106 - 0
node_modules/deepmerge/index.js

@@ -0,0 +1,106 @@
+var defaultIsMergeableObject = require('is-mergeable-object')
+
+function emptyTarget(val) {
+	return Array.isArray(val) ? [] : {}
+}
+
+function cloneUnlessOtherwiseSpecified(value, options) {
+	return (options.clone !== false && options.isMergeableObject(value))
+		? deepmerge(emptyTarget(value), value, options)
+		: value
+}
+
+function defaultArrayMerge(target, source, options) {
+	return target.concat(source).map(function(element) {
+		return cloneUnlessOtherwiseSpecified(element, options)
+	})
+}
+
+function getMergeFunction(key, options) {
+	if (!options.customMerge) {
+		return deepmerge
+	}
+	var customMerge = options.customMerge(key)
+	return typeof customMerge === 'function' ? customMerge : deepmerge
+}
+
+function getEnumerableOwnPropertySymbols(target) {
+	return Object.getOwnPropertySymbols
+		? Object.getOwnPropertySymbols(target).filter(function(symbol) {
+			return target.propertyIsEnumerable(symbol)
+		})
+		: []
+}
+
+function getKeys(target) {
+	return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
+}
+
+function propertyIsOnObject(object, property) {
+	try {
+		return property in object
+	} catch(_) {
+		return false
+	}
+}
+
+// Protects from prototype poisoning and unexpected merging up the prototype chain.
+function propertyIsUnsafe(target, key) {
+	return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
+		&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
+			&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
+}
+
+function mergeObject(target, source, options) {
+	var destination = {}
+	if (options.isMergeableObject(target)) {
+		getKeys(target).forEach(function(key) {
+			destination[key] = cloneUnlessOtherwiseSpecified(target[key], options)
+		})
+	}
+	getKeys(source).forEach(function(key) {
+		if (propertyIsUnsafe(target, key)) {
+			return
+		}
+
+		if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
+			destination[key] = getMergeFunction(key, options)(target[key], source[key], options)
+		} else {
+			destination[key] = cloneUnlessOtherwiseSpecified(source[key], options)
+		}
+	})
+	return destination
+}
+
+function deepmerge(target, source, options) {
+	options = options || {}
+	options.arrayMerge = options.arrayMerge || defaultArrayMerge
+	options.isMergeableObject = options.isMergeableObject || defaultIsMergeableObject
+	// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
+	// implementations can use it. The caller may not replace it.
+	options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified
+
+	var sourceIsArray = Array.isArray(source)
+	var targetIsArray = Array.isArray(target)
+	var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray
+
+	if (!sourceAndTargetTypesMatch) {
+		return cloneUnlessOtherwiseSpecified(source, options)
+	} else if (sourceIsArray) {
+		return options.arrayMerge(target, source, options)
+	} else {
+		return mergeObject(target, source, options)
+	}
+}
+
+deepmerge.all = function deepmergeAll(array, options) {
+	if (!Array.isArray(array)) {
+		throw new Error('first argument should be an array')
+	}
+
+	return array.reduce(function(prev, next) {
+		return deepmerge(prev, next, options)
+	}, {})
+}
+
+module.exports = deepmerge

+ 21 - 0
node_modules/deepmerge/license.txt

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2012 James Halliday, Josh Duff, and other contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

+ 47 - 0
node_modules/deepmerge/package.json

@@ -0,0 +1,47 @@
+{
+  "name": "deepmerge",
+  "description": "A library for deep (recursive) merging of Javascript objects",
+  "keywords": [
+    "merge",
+    "deep",
+    "extend",
+    "copy",
+    "clone",
+    "recursive"
+  ],
+  "version": "4.2.2",
+  "homepage": "https://github.com/TehShrike/deepmerge",
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/TehShrike/deepmerge.git"
+  },
+  "main": "dist/cjs.js",
+  "engines": {
+    "node": ">=0.10.0"
+  },
+  "scripts": {
+    "build": "rollup -c",
+    "test": "npm run build && tape test/*.js && jsmd readme.md && npm run test:typescript",
+    "test:typescript": "tsc --noEmit test/typescript.ts && ts-node test/typescript.ts",
+    "size": "npm run build && uglifyjs --compress --mangle -- ./dist/umd.js | gzip -c | wc -c"
+  },
+  "devDependencies": {
+    "@types/node": "^8.10.54",
+    "is-mergeable-object": "1.1.0",
+    "is-plain-object": "^2.0.4",
+    "jsmd": "^1.0.2",
+    "rollup": "^1.23.1",
+    "rollup-plugin-commonjs": "^10.1.0",
+    "rollup-plugin-node-resolve": "^5.2.0",
+    "tape": "^4.11.0",
+    "ts-node": "7.0.1",
+    "typescript": "=2.2.2",
+    "uglify-js": "^3.6.1"
+  },
+  "license": "MIT",
+  "dependencies": {}
+
+,"_resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz"
+,"_integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg=="
+,"_from": "deepmerge@4.2.2"
+}

+ 22 - 0
node_modules/node-fetch/LICENSE.md

@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 David Frank
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+

+ 23 - 0
node_modules/node-fetch/browser.js

@@ -0,0 +1,23 @@
+"use strict";
+
+// ref: https://github.com/tc39/proposal-global
+var getGlobal = function () {
+	// the only reliable means to get the global object is
+	// `Function('return this')()`
+	// However, this causes CSP violations in Chrome apps.
+	if (typeof self !== 'undefined') { return self; }
+	if (typeof window !== 'undefined') { return window; }
+	if (typeof global !== 'undefined') { return global; }
+	throw new Error('unable to locate global object');
+}
+
+var global = getGlobal();
+
+module.exports = exports = global.fetch;
+
+// Needed for TypeScript and Webpack.
+exports.default = global.fetch.bind(global);
+
+exports.Headers = global.Headers;
+exports.Request = global.Request;
+exports.Response = global.Response;

+ 1633 - 0
node_modules/node-fetch/lib/index.es.js

@@ -0,0 +1,1633 @@
+process.emitWarning("The .es.js file is deprecated. Use .mjs instead.");
+
+import Stream from 'stream';
+import http from 'http';
+import Url from 'url';
+import https from 'https';
+import zlib from 'zlib';
+
+// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js
+
+// fix for "Readable" isn't a named export issue
+const Readable = Stream.Readable;
+
+const BUFFER = Symbol('buffer');
+const TYPE = Symbol('type');
+
+class Blob {
+	constructor() {
+		this[TYPE] = '';
+
+		const blobParts = arguments[0];
+		const options = arguments[1];
+
+		const buffers = [];
+		let size = 0;
+
+		if (blobParts) {
+			const a = blobParts;
+			const length = Number(a.length);
+			for (let i = 0; i < length; i++) {
+				const element = a[i];
+				let buffer;
+				if (element instanceof Buffer) {
+					buffer = element;
+				} else if (ArrayBuffer.isView(element)) {
+					buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength);
+				} else if (element instanceof ArrayBuffer) {
+					buffer = Buffer.from(element);
+				} else if (element instanceof Blob) {
+					buffer = element[BUFFER];
+				} else {
+					buffer = Buffer.from(typeof element === 'string' ? element : String(element));
+				}
+				size += buffer.length;
+				buffers.push(buffer);
+			}
+		}
+
+		this[BUFFER] = Buffer.concat(buffers);
+
+		let type = options && options.type !== undefined && String(options.type).toLowerCase();
+		if (type && !/[^\u0020-\u007E]/.test(type)) {
+			this[TYPE] = type;
+		}
+	}
+	get size() {
+		return this[BUFFER].length;
+	}
+	get type() {
+		return this[TYPE];
+	}
+	text() {
+		return Promise.resolve(this[BUFFER].toString());
+	}
+	arrayBuffer() {
+		const buf = this[BUFFER];
+		const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
+		return Promise.resolve(ab);
+	}
+	stream() {
+		const readable = new Readable();
+		readable._read = function () {};
+		readable.push(this[BUFFER]);
+		readable.push(null);
+		return readable;
+	}
+	toString() {
+		return '[object Blob]';
+	}
+	slice() {
+		const size = this.size;
+
+		const start = arguments[0];
+		const end = arguments[1];
+		let relativeStart, relativeEnd;
+		if (start === undefined) {
+			relativeStart = 0;
+		} else if (start < 0) {
+			relativeStart = Math.max(size + start, 0);
+		} else {
+			relativeStart = Math.min(start, size);
+		}
+		if (end === undefined) {
+			relativeEnd = size;
+		} else if (end < 0) {
+			relativeEnd = Math.max(size + end, 0);
+		} else {
+			relativeEnd = Math.min(end, size);
+		}
+		const span = Math.max(relativeEnd - relativeStart, 0);
+
+		const buffer = this[BUFFER];
+		const slicedBuffer = buffer.slice(relativeStart, relativeStart + span);
+		const blob = new Blob([], { type: arguments[2] });
+		blob[BUFFER] = slicedBuffer;
+		return blob;
+	}
+}
+
+Object.defineProperties(Blob.prototype, {
+	size: { enumerable: true },
+	type: { enumerable: true },
+	slice: { enumerable: true }
+});
+
+Object.defineProperty(Blob.prototype, Symbol.toStringTag, {
+	value: 'Blob',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+/**
+ * fetch-error.js
+ *
+ * FetchError interface for operational errors
+ */
+
+/**
+ * Create FetchError instance
+ *
+ * @param   String      message      Error message for human
+ * @param   String      type         Error type for machine
+ * @param   String      systemError  For Node.js system error
+ * @return  FetchError
+ */
+function FetchError(message, type, systemError) {
+  Error.call(this, message);
+
+  this.message = message;
+  this.type = type;
+
+  // when err.type is `system`, err.code contains system error code
+  if (systemError) {
+    this.code = this.errno = systemError.code;
+  }
+
+  // hide custom error implementation details from end-users
+  Error.captureStackTrace(this, this.constructor);
+}
+
+FetchError.prototype = Object.create(Error.prototype);
+FetchError.prototype.constructor = FetchError;
+FetchError.prototype.name = 'FetchError';
+
+let convert;
+try {
+	convert = require('encoding').convert;
+} catch (e) {}
+
+const INTERNALS = Symbol('Body internals');
+
+// fix an issue where "PassThrough" isn't a named export for node <10
+const PassThrough = Stream.PassThrough;
+
+/**
+ * Body mixin
+ *
+ * Ref: https://fetch.spec.whatwg.org/#body
+ *
+ * @param   Stream  body  Readable stream
+ * @param   Object  opts  Response options
+ * @return  Void
+ */
+function Body(body) {
+	var _this = this;
+
+	var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+	    _ref$size = _ref.size;
+
+	let size = _ref$size === undefined ? 0 : _ref$size;
+	var _ref$timeout = _ref.timeout;
+	let timeout = _ref$timeout === undefined ? 0 : _ref$timeout;
+
+	if (body == null) {
+		// body is undefined or null
+		body = null;
+	} else if (isURLSearchParams(body)) {
+		// body is a URLSearchParams
+		body = Buffer.from(body.toString());
+	} else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') {
+		// body is ArrayBuffer
+		body = Buffer.from(body);
+	} else if (ArrayBuffer.isView(body)) {
+		// body is ArrayBufferView
+		body = Buffer.from(body.buffer, body.byteOffset, body.byteLength);
+	} else if (body instanceof Stream) ; else {
+		// none of the above
+		// coerce to string then buffer
+		body = Buffer.from(String(body));
+	}
+	this[INTERNALS] = {
+		body,
+		disturbed: false,
+		error: null
+	};
+	this.size = size;
+	this.timeout = timeout;
+
+	if (body instanceof Stream) {
+		body.on('error', function (err) {
+			const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err);
+			_this[INTERNALS].error = error;
+		});
+	}
+}
+
+Body.prototype = {
+	get body() {
+		return this[INTERNALS].body;
+	},
+
+	get bodyUsed() {
+		return this[INTERNALS].disturbed;
+	},
+
+	/**
+  * Decode response as ArrayBuffer
+  *
+  * @return  Promise
+  */
+	arrayBuffer() {
+		return consumeBody.call(this).then(function (buf) {
+			return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
+		});
+	},
+
+	/**
+  * Return raw response as Blob
+  *
+  * @return Promise
+  */
+	blob() {
+		let ct = this.headers && this.headers.get('content-type') || '';
+		return consumeBody.call(this).then(function (buf) {
+			return Object.assign(
+			// Prevent copying
+			new Blob([], {
+				type: ct.toLowerCase()
+			}), {
+				[BUFFER]: buf
+			});
+		});
+	},
+
+	/**
+  * Decode response as json
+  *
+  * @return  Promise
+  */
+	json() {
+		var _this2 = this;
+
+		return consumeBody.call(this).then(function (buffer) {
+			try {
+				return JSON.parse(buffer.toString());
+			} catch (err) {
+				return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));
+			}
+		});
+	},
+
+	/**
+  * Decode response as text
+  *
+  * @return  Promise
+  */
+	text() {
+		return consumeBody.call(this).then(function (buffer) {
+			return buffer.toString();
+		});
+	},
+
+	/**
+  * Decode response as buffer (non-spec api)
+  *
+  * @return  Promise
+  */
+	buffer() {
+		return consumeBody.call(this);
+	},
+
+	/**
+  * Decode response as text, while automatically detecting the encoding and
+  * trying to decode to UTF-8 (non-spec api)
+  *
+  * @return  Promise
+  */
+	textConverted() {
+		var _this3 = this;
+
+		return consumeBody.call(this).then(function (buffer) {
+			return convertBody(buffer, _this3.headers);
+		});
+	}
+};
+
+// In browsers, all properties are enumerable.
+Object.defineProperties(Body.prototype, {
+	body: { enumerable: true },
+	bodyUsed: { enumerable: true },
+	arrayBuffer: { enumerable: true },
+	blob: { enumerable: true },
+	json: { enumerable: true },
+	text: { enumerable: true }
+});
+
+Body.mixIn = function (proto) {
+	for (const name of Object.getOwnPropertyNames(Body.prototype)) {
+		// istanbul ignore else: future proof
+		if (!(name in proto)) {
+			const desc = Object.getOwnPropertyDescriptor(Body.prototype, name);
+			Object.defineProperty(proto, name, desc);
+		}
+	}
+};
+
+/**
+ * Consume and convert an entire Body to a Buffer.
+ *
+ * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body
+ *
+ * @return  Promise
+ */
+function consumeBody() {
+	var _this4 = this;
+
+	if (this[INTERNALS].disturbed) {
+		return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`));
+	}
+
+	this[INTERNALS].disturbed = true;
+
+	if (this[INTERNALS].error) {
+		return Body.Promise.reject(this[INTERNALS].error);
+	}
+
+	let body = this.body;
+
+	// body is null
+	if (body === null) {
+		return Body.Promise.resolve(Buffer.alloc(0));
+	}
+
+	// body is blob
+	if (isBlob(body)) {
+		body = body.stream();
+	}
+
+	// body is buffer
+	if (Buffer.isBuffer(body)) {
+		return Body.Promise.resolve(body);
+	}
+
+	// istanbul ignore if: should never happen
+	if (!(body instanceof Stream)) {
+		return Body.Promise.resolve(Buffer.alloc(0));
+	}
+
+	// body is stream
+	// get ready to actually consume the body
+	let accum = [];
+	let accumBytes = 0;
+	let abort = false;
+
+	return new Body.Promise(function (resolve, reject) {
+		let resTimeout;
+
+		// allow timeout on slow response body
+		if (_this4.timeout) {
+			resTimeout = setTimeout(function () {
+				abort = true;
+				reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout'));
+			}, _this4.timeout);
+		}
+
+		// handle stream errors
+		body.on('error', function (err) {
+			if (err.name === 'AbortError') {
+				// if the request was aborted, reject with this Error
+				abort = true;
+				reject(err);
+			} else {
+				// other errors, such as incorrect content-encoding
+				reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err));
+			}
+		});
+
+		body.on('data', function (chunk) {
+			if (abort || chunk === null) {
+				return;
+			}
+
+			if (_this4.size && accumBytes + chunk.length > _this4.size) {
+				abort = true;
+				reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size'));
+				return;
+			}
+
+			accumBytes += chunk.length;
+			accum.push(chunk);
+		});
+
+		body.on('end', function () {
+			if (abort) {
+				return;
+			}
+
+			clearTimeout(resTimeout);
+
+			try {
+				resolve(Buffer.concat(accum, accumBytes));
+			} catch (err) {
+				// handle streams that have accumulated too much data (issue #414)
+				reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err));
+			}
+		});
+	});
+}
+
+/**
+ * Detect buffer encoding and convert to target encoding
+ * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding
+ *
+ * @param   Buffer  buffer    Incoming buffer
+ * @param   String  encoding  Target encoding
+ * @return  String
+ */
+function convertBody(buffer, headers) {
+	if (typeof convert !== 'function') {
+		throw new Error('The package `encoding` must be installed to use the textConverted() function');
+	}
+
+	const ct = headers.get('content-type');
+	let charset = 'utf-8';
+	let res, str;
+
+	// header
+	if (ct) {
+		res = /charset=([^;]*)/i.exec(ct);
+	}
+
+	// no charset in content type, peek at response body for at most 1024 bytes
+	str = buffer.slice(0, 1024).toString();
+
+	// html5
+	if (!res && str) {
+		res = /<meta.+?charset=(['"])(.+?)\1/i.exec(str);
+	}
+
+	// html4
+	if (!res && str) {
+		res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str);
+
+		if (res) {
+			res = /charset=(.*)/i.exec(res.pop());
+		}
+	}
+
+	// xml
+	if (!res && str) {
+		res = /<\?xml.+?encoding=(['"])(.+?)\1/i.exec(str);
+	}
+
+	// found charset
+	if (res) {
+		charset = res.pop();
+
+		// prevent decode issues when sites use incorrect encoding
+		// ref: https://hsivonen.fi/encoding-menu/
+		if (charset === 'gb2312' || charset === 'gbk') {
+			charset = 'gb18030';
+		}
+	}
+
+	// turn raw buffers into a single utf-8 buffer
+	return convert(buffer, 'UTF-8', charset).toString();
+}
+
+/**
+ * Detect a URLSearchParams object
+ * ref: https://github.com/bitinn/node-fetch/issues/296#issuecomment-307598143
+ *
+ * @param   Object  obj     Object to detect by type or brand
+ * @return  String
+ */
+function isURLSearchParams(obj) {
+	// Duck-typing as a necessary condition.
+	if (typeof obj !== 'object' || typeof obj.append !== 'function' || typeof obj.delete !== 'function' || typeof obj.get !== 'function' || typeof obj.getAll !== 'function' || typeof obj.has !== 'function' || typeof obj.set !== 'function') {
+		return false;
+	}
+
+	// Brand-checking and more duck-typing as optional condition.
+	return obj.constructor.name === 'URLSearchParams' || Object.prototype.toString.call(obj) === '[object URLSearchParams]' || typeof obj.sort === 'function';
+}
+
+/**
+ * Check if `obj` is a W3C `Blob` object (which `File` inherits from)
+ * @param  {*} obj
+ * @return {boolean}
+ */
+function isBlob(obj) {
+	return typeof obj === 'object' && typeof obj.arrayBuffer === 'function' && typeof obj.type === 'string' && typeof obj.stream === 'function' && typeof obj.constructor === 'function' && typeof obj.constructor.name === 'string' && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
+}
+
+/**
+ * Clone body given Res/Req instance
+ *
+ * @param   Mixed  instance  Response or Request instance
+ * @return  Mixed
+ */
+function clone(instance) {
+	let p1, p2;
+	let body = instance.body;
+
+	// don't allow cloning a used body
+	if (instance.bodyUsed) {
+		throw new Error('cannot clone body after it is used');
+	}
+
+	// check that body is a stream and not form-data object
+	// note: we can't clone the form-data object without having it as a dependency
+	if (body instanceof Stream && typeof body.getBoundary !== 'function') {
+		// tee instance body
+		p1 = new PassThrough();
+		p2 = new PassThrough();
+		body.pipe(p1);
+		body.pipe(p2);
+		// set instance body to teed body and return the other teed body
+		instance[INTERNALS].body = p1;
+		body = p2;
+	}
+
+	return body;
+}
+
+/**
+ * Performs the operation "extract a `Content-Type` value from |object|" as
+ * specified in the specification:
+ * https://fetch.spec.whatwg.org/#concept-bodyinit-extract
+ *
+ * This function assumes that instance.body is present.
+ *
+ * @param   Mixed  instance  Any options.body input
+ */
+function extractContentType(body) {
+	if (body === null) {
+		// body is null
+		return null;
+	} else if (typeof body === 'string') {
+		// body is string
+		return 'text/plain;charset=UTF-8';
+	} else if (isURLSearchParams(body)) {
+		// body is a URLSearchParams
+		return 'application/x-www-form-urlencoded;charset=UTF-8';
+	} else if (isBlob(body)) {
+		// body is blob
+		return body.type || null;
+	} else if (Buffer.isBuffer(body)) {
+		// body is buffer
+		return null;
+	} else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') {
+		// body is ArrayBuffer
+		return null;
+	} else if (ArrayBuffer.isView(body)) {
+		// body is ArrayBufferView
+		return null;
+	} else if (typeof body.getBoundary === 'function') {
+		// detect form data input from form-data module
+		return `multipart/form-data;boundary=${body.getBoundary()}`;
+	} else if (body instanceof Stream) {
+		// body is stream
+		// can't really do much about this
+		return null;
+	} else {
+		// Body constructor defaults other things to string
+		return 'text/plain;charset=UTF-8';
+	}
+}
+
+/**
+ * The Fetch Standard treats this as if "total bytes" is a property on the body.
+ * For us, we have to explicitly get it with a function.
+ *
+ * ref: https://fetch.spec.whatwg.org/#concept-body-total-bytes
+ *
+ * @param   Body    instance   Instance of Body
+ * @return  Number?            Number of bytes, or null if not possible
+ */
+function getTotalBytes(instance) {
+	const body = instance.body;
+
+
+	if (body === null) {
+		// body is null
+		return 0;
+	} else if (isBlob(body)) {
+		return body.size;
+	} else if (Buffer.isBuffer(body)) {
+		// body is buffer
+		return body.length;
+	} else if (body && typeof body.getLengthSync === 'function') {
+		// detect form data input from form-data module
+		if (body._lengthRetrievers && body._lengthRetrievers.length == 0 || // 1.x
+		body.hasKnownLength && body.hasKnownLength()) {
+			// 2.x
+			return body.getLengthSync();
+		}
+		return null;
+	} else {
+		// body is stream
+		return null;
+	}
+}
+
+/**
+ * Write a Body to a Node.js WritableStream (e.g. http.Request) object.
+ *
+ * @param   Body    instance   Instance of Body
+ * @return  Void
+ */
+function writeToStream(dest, instance) {
+	const body = instance.body;
+
+
+	if (body === null) {
+		// body is null
+		dest.end();
+	} else if (isBlob(body)) {
+		body.stream().pipe(dest);
+	} else if (Buffer.isBuffer(body)) {
+		// body is buffer
+		dest.write(body);
+		dest.end();
+	} else {
+		// body is stream
+		body.pipe(dest);
+	}
+}
+
+// expose Promise
+Body.Promise = global.Promise;
+
+/**
+ * headers.js
+ *
+ * Headers class offers convenient helpers
+ */
+
+const invalidTokenRegex = /[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/;
+const invalidHeaderCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
+
+function validateName(name) {
+	name = `${name}`;
+	if (invalidTokenRegex.test(name) || name === '') {
+		throw new TypeError(`${name} is not a legal HTTP header name`);
+	}
+}
+
+function validateValue(value) {
+	value = `${value}`;
+	if (invalidHeaderCharRegex.test(value)) {
+		throw new TypeError(`${value} is not a legal HTTP header value`);
+	}
+}
+
+/**
+ * Find the key in the map object given a header name.
+ *
+ * Returns undefined if not found.
+ *
+ * @param   String  name  Header name
+ * @return  String|Undefined
+ */
+function find(map, name) {
+	name = name.toLowerCase();
+	for (const key in map) {
+		if (key.toLowerCase() === name) {
+			return key;
+		}
+	}
+	return undefined;
+}
+
+const MAP = Symbol('map');
+class Headers {
+	/**
+  * Headers class
+  *
+  * @param   Object  headers  Response headers
+  * @return  Void
+  */
+	constructor() {
+		let init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
+
+		this[MAP] = Object.create(null);
+
+		if (init instanceof Headers) {
+			const rawHeaders = init.raw();
+			const headerNames = Object.keys(rawHeaders);
+
+			for (const headerName of headerNames) {
+				for (const value of rawHeaders[headerName]) {
+					this.append(headerName, value);
+				}
+			}
+
+			return;
+		}
+
+		// We don't worry about converting prop to ByteString here as append()
+		// will handle it.
+		if (init == null) ; else if (typeof init === 'object') {
+			const method = init[Symbol.iterator];
+			if (method != null) {
+				if (typeof method !== 'function') {
+					throw new TypeError('Header pairs must be iterable');
+				}
+
+				// sequence<sequence<ByteString>>
+				// Note: per spec we have to first exhaust the lists then process them
+				const pairs = [];
+				for (const pair of init) {
+					if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') {
+						throw new TypeError('Each header pair must be iterable');
+					}
+					pairs.push(Array.from(pair));
+				}
+
+				for (const pair of pairs) {
+					if (pair.length !== 2) {
+						throw new TypeError('Each header pair must be a name/value tuple');
+					}
+					this.append(pair[0], pair[1]);
+				}
+			} else {
+				// record<ByteString, ByteString>
+				for (const key of Object.keys(init)) {
+					const value = init[key];
+					this.append(key, value);
+				}
+			}
+		} else {
+			throw new TypeError('Provided initializer must be an object');
+		}
+	}
+
+	/**
+  * Return combined header value given name
+  *
+  * @param   String  name  Header name
+  * @return  Mixed
+  */
+	get(name) {
+		name = `${name}`;
+		validateName(name);
+		const key = find(this[MAP], name);
+		if (key === undefined) {
+			return null;
+		}
+
+		return this[MAP][key].join(', ');
+	}
+
+	/**
+  * Iterate over all headers
+  *
+  * @param   Function  callback  Executed for each item with parameters (value, name, thisArg)
+  * @param   Boolean   thisArg   `this` context for callback function
+  * @return  Void
+  */
+	forEach(callback) {
+		let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
+
+		let pairs = getHeaders(this);
+		let i = 0;
+		while (i < pairs.length) {
+			var _pairs$i = pairs[i];
+			const name = _pairs$i[0],
+			      value = _pairs$i[1];
+
+			callback.call(thisArg, value, name, this);
+			pairs = getHeaders(this);
+			i++;
+		}
+	}
+
+	/**
+  * Overwrite header values given name
+  *
+  * @param   String  name   Header name
+  * @param   String  value  Header value
+  * @return  Void
+  */
+	set(name, value) {
+		name = `${name}`;
+		value = `${value}`;
+		validateName(name);
+		validateValue(value);
+		const key = find(this[MAP], name);
+		this[MAP][key !== undefined ? key : name] = [value];
+	}
+
+	/**
+  * Append a value onto existing header
+  *
+  * @param   String  name   Header name
+  * @param   String  value  Header value
+  * @return  Void
+  */
+	append(name, value) {
+		name = `${name}`;
+		value = `${value}`;
+		validateName(name);
+		validateValue(value);
+		const key = find(this[MAP], name);
+		if (key !== undefined) {
+			this[MAP][key].push(value);
+		} else {
+			this[MAP][name] = [value];
+		}
+	}
+
+	/**
+  * Check for header name existence
+  *
+  * @param   String   name  Header name
+  * @return  Boolean
+  */
+	has(name) {
+		name = `${name}`;
+		validateName(name);
+		return find(this[MAP], name) !== undefined;
+	}
+
+	/**
+  * Delete all header values given name
+  *
+  * @param   String  name  Header name
+  * @return  Void
+  */
+	delete(name) {
+		name = `${name}`;
+		validateName(name);
+		const key = find(this[MAP], name);
+		if (key !== undefined) {
+			delete this[MAP][key];
+		}
+	}
+
+	/**
+  * Return raw headers (non-spec api)
+  *
+  * @return  Object
+  */
+	raw() {
+		return this[MAP];
+	}
+
+	/**
+  * Get an iterator on keys.
+  *
+  * @return  Iterator
+  */
+	keys() {
+		return createHeadersIterator(this, 'key');
+	}
+
+	/**
+  * Get an iterator on values.
+  *
+  * @return  Iterator
+  */
+	values() {
+		return createHeadersIterator(this, 'value');
+	}
+
+	/**
+  * Get an iterator on entries.
+  *
+  * This is the default iterator of the Headers object.
+  *
+  * @return  Iterator
+  */
+	[Symbol.iterator]() {
+		return createHeadersIterator(this, 'key+value');
+	}
+}
+Headers.prototype.entries = Headers.prototype[Symbol.iterator];
+
+Object.defineProperty(Headers.prototype, Symbol.toStringTag, {
+	value: 'Headers',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+Object.defineProperties(Headers.prototype, {
+	get: { enumerable: true },
+	forEach: { enumerable: true },
+	set: { enumerable: true },
+	append: { enumerable: true },
+	has: { enumerable: true },
+	delete: { enumerable: true },
+	keys: { enumerable: true },
+	values: { enumerable: true },
+	entries: { enumerable: true }
+});
+
+function getHeaders(headers) {
+	let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value';
+
+	const keys = Object.keys(headers[MAP]).sort();
+	return keys.map(kind === 'key' ? function (k) {
+		return k.toLowerCase();
+	} : kind === 'value' ? function (k) {
+		return headers[MAP][k].join(', ');
+	} : function (k) {
+		return [k.toLowerCase(), headers[MAP][k].join(', ')];
+	});
+}
+
+const INTERNAL = Symbol('internal');
+
+function createHeadersIterator(target, kind) {
+	const iterator = Object.create(HeadersIteratorPrototype);
+	iterator[INTERNAL] = {
+		target,
+		kind,
+		index: 0
+	};
+	return iterator;
+}
+
+const HeadersIteratorPrototype = Object.setPrototypeOf({
+	next() {
+		// istanbul ignore if
+		if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) {
+			throw new TypeError('Value of `this` is not a HeadersIterator');
+		}
+
+		var _INTERNAL = this[INTERNAL];
+		const target = _INTERNAL.target,
+		      kind = _INTERNAL.kind,
+		      index = _INTERNAL.index;
+
+		const values = getHeaders(target, kind);
+		const len = values.length;
+		if (index >= len) {
+			return {
+				value: undefined,
+				done: true
+			};
+		}
+
+		this[INTERNAL].index = index + 1;
+
+		return {
+			value: values[index],
+			done: false
+		};
+	}
+}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));
+
+Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, {
+	value: 'HeadersIterator',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+/**
+ * Export the Headers object in a form that Node.js can consume.
+ *
+ * @param   Headers  headers
+ * @return  Object
+ */
+function exportNodeCompatibleHeaders(headers) {
+	const obj = Object.assign({ __proto__: null }, headers[MAP]);
+
+	// http.request() only supports string as Host header. This hack makes
+	// specifying custom Host header possible.
+	const hostHeaderKey = find(headers[MAP], 'Host');
+	if (hostHeaderKey !== undefined) {
+		obj[hostHeaderKey] = obj[hostHeaderKey][0];
+	}
+
+	return obj;
+}
+
+/**
+ * Create a Headers object from an object of headers, ignoring those that do
+ * not conform to HTTP grammar productions.
+ *
+ * @param   Object  obj  Object of headers
+ * @return  Headers
+ */
+function createHeadersLenient(obj) {
+	const headers = new Headers();
+	for (const name of Object.keys(obj)) {
+		if (invalidTokenRegex.test(name)) {
+			continue;
+		}
+		if (Array.isArray(obj[name])) {
+			for (const val of obj[name]) {
+				if (invalidHeaderCharRegex.test(val)) {
+					continue;
+				}
+				if (headers[MAP][name] === undefined) {
+					headers[MAP][name] = [val];
+				} else {
+					headers[MAP][name].push(val);
+				}
+			}
+		} else if (!invalidHeaderCharRegex.test(obj[name])) {
+			headers[MAP][name] = [obj[name]];
+		}
+	}
+	return headers;
+}
+
+const INTERNALS$1 = Symbol('Response internals');
+
+// fix an issue where "STATUS_CODES" aren't a named export for node <10
+const STATUS_CODES = http.STATUS_CODES;
+
+/**
+ * Response class
+ *
+ * @param   Stream  body  Readable stream
+ * @param   Object  opts  Response options
+ * @return  Void
+ */
+class Response {
+	constructor() {
+		let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
+		let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+
+		Body.call(this, body, opts);
+
+		const status = opts.status || 200;
+		const headers = new Headers(opts.headers);
+
+		if (body != null && !headers.has('Content-Type')) {
+			const contentType = extractContentType(body);
+			if (contentType) {
+				headers.append('Content-Type', contentType);
+			}
+		}
+
+		this[INTERNALS$1] = {
+			url: opts.url,
+			status,
+			statusText: opts.statusText || STATUS_CODES[status],
+			headers,
+			counter: opts.counter
+		};
+	}
+
+	get url() {
+		return this[INTERNALS$1].url || '';
+	}
+
+	get status() {
+		return this[INTERNALS$1].status;
+	}
+
+	/**
+  * Convenience property representing if the request ended normally
+  */
+	get ok() {
+		return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300;
+	}
+
+	get redirected() {
+		return this[INTERNALS$1].counter > 0;
+	}
+
+	get statusText() {
+		return this[INTERNALS$1].statusText;
+	}
+
+	get headers() {
+		return this[INTERNALS$1].headers;
+	}
+
+	/**
+  * Clone this response
+  *
+  * @return  Response
+  */
+	clone() {
+		return new Response(clone(this), {
+			url: this.url,
+			status: this.status,
+			statusText: this.statusText,
+			headers: this.headers,
+			ok: this.ok,
+			redirected: this.redirected
+		});
+	}
+}
+
+Body.mixIn(Response.prototype);
+
+Object.defineProperties(Response.prototype, {
+	url: { enumerable: true },
+	status: { enumerable: true },
+	ok: { enumerable: true },
+	redirected: { enumerable: true },
+	statusText: { enumerable: true },
+	headers: { enumerable: true },
+	clone: { enumerable: true }
+});
+
+Object.defineProperty(Response.prototype, Symbol.toStringTag, {
+	value: 'Response',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+const INTERNALS$2 = Symbol('Request internals');
+
+// fix an issue where "format", "parse" aren't a named export for node <10
+const parse_url = Url.parse;
+const format_url = Url.format;
+
+const streamDestructionSupported = 'destroy' in Stream.Readable.prototype;
+
+/**
+ * Check if a value is an instance of Request.
+ *
+ * @param   Mixed   input
+ * @return  Boolean
+ */
+function isRequest(input) {
+	return typeof input === 'object' && typeof input[INTERNALS$2] === 'object';
+}
+
+function isAbortSignal(signal) {
+	const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal);
+	return !!(proto && proto.constructor.name === 'AbortSignal');
+}
+
+/**
+ * Request class
+ *
+ * @param   Mixed   input  Url or Request instance
+ * @param   Object  init   Custom options
+ * @return  Void
+ */
+class Request {
+	constructor(input) {
+		let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+
+		let parsedURL;
+
+		// normalize input
+		if (!isRequest(input)) {
+			if (input && input.href) {
+				// in order to support Node.js' Url objects; though WHATWG's URL objects
+				// will fall into this branch also (since their `toString()` will return
+				// `href` property anyway)
+				parsedURL = parse_url(input.href);
+			} else {
+				// coerce input to a string before attempting to parse
+				parsedURL = parse_url(`${input}`);
+			}
+			input = {};
+		} else {
+			parsedURL = parse_url(input.url);
+		}
+
+		let method = init.method || input.method || 'GET';
+		method = method.toUpperCase();
+
+		if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) {
+			throw new TypeError('Request with GET/HEAD method cannot have body');
+		}
+
+		let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
+
+		Body.call(this, inputBody, {
+			timeout: init.timeout || input.timeout || 0,
+			size: init.size || input.size || 0
+		});
+
+		const headers = new Headers(init.headers || input.headers || {});
+
+		if (inputBody != null && !headers.has('Content-Type')) {
+			const contentType = extractContentType(inputBody);
+			if (contentType) {
+				headers.append('Content-Type', contentType);
+			}
+		}
+
+		let signal = isRequest(input) ? input.signal : null;
+		if ('signal' in init) signal = init.signal;
+
+		if (signal != null && !isAbortSignal(signal)) {
+			throw new TypeError('Expected signal to be an instanceof AbortSignal');
+		}
+
+		this[INTERNALS$2] = {
+			method,
+			redirect: init.redirect || input.redirect || 'follow',
+			headers,
+			parsedURL,
+			signal
+		};
+
+		// node-fetch-only options
+		this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20;
+		this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true;
+		this.counter = init.counter || input.counter || 0;
+		this.agent = init.agent || input.agent;
+	}
+
+	get method() {
+		return this[INTERNALS$2].method;
+	}
+
+	get url() {
+		return format_url(this[INTERNALS$2].parsedURL);
+	}
+
+	get headers() {
+		return this[INTERNALS$2].headers;
+	}
+
+	get redirect() {
+		return this[INTERNALS$2].redirect;
+	}
+
+	get signal() {
+		return this[INTERNALS$2].signal;
+	}
+
+	/**
+  * Clone this request
+  *
+  * @return  Request
+  */
+	clone() {
+		return new Request(this);
+	}
+}
+
+Body.mixIn(Request.prototype);
+
+Object.defineProperty(Request.prototype, Symbol.toStringTag, {
+	value: 'Request',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+Object.defineProperties(Request.prototype, {
+	method: { enumerable: true },
+	url: { enumerable: true },
+	headers: { enumerable: true },
+	redirect: { enumerable: true },
+	clone: { enumerable: true },
+	signal: { enumerable: true }
+});
+
+/**
+ * Convert a Request to Node.js http request options.
+ *
+ * @param   Request  A Request instance
+ * @return  Object   The options object to be passed to http.request
+ */
+function getNodeRequestOptions(request) {
+	const parsedURL = request[INTERNALS$2].parsedURL;
+	const headers = new Headers(request[INTERNALS$2].headers);
+
+	// fetch step 1.3
+	if (!headers.has('Accept')) {
+		headers.set('Accept', '*/*');
+	}
+
+	// Basic fetch
+	if (!parsedURL.protocol || !parsedURL.hostname) {
+		throw new TypeError('Only absolute URLs are supported');
+	}
+
+	if (!/^https?:$/.test(parsedURL.protocol)) {
+		throw new TypeError('Only HTTP(S) protocols are supported');
+	}
+
+	if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) {
+		throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8');
+	}
+
+	// HTTP-network-or-cache fetch steps 2.4-2.7
+	let contentLengthValue = null;
+	if (request.body == null && /^(POST|PUT)$/i.test(request.method)) {
+		contentLengthValue = '0';
+	}
+	if (request.body != null) {
+		const totalBytes = getTotalBytes(request);
+		if (typeof totalBytes === 'number') {
+			contentLengthValue = String(totalBytes);
+		}
+	}
+	if (contentLengthValue) {
+		headers.set('Content-Length', contentLengthValue);
+	}
+
+	// HTTP-network-or-cache fetch step 2.11
+	if (!headers.has('User-Agent')) {
+		headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)');
+	}
+
+	// HTTP-network-or-cache fetch step 2.15
+	if (request.compress && !headers.has('Accept-Encoding')) {
+		headers.set('Accept-Encoding', 'gzip,deflate');
+	}
+
+	let agent = request.agent;
+	if (typeof agent === 'function') {
+		agent = agent(parsedURL);
+	}
+
+	if (!headers.has('Connection') && !agent) {
+		headers.set('Connection', 'close');
+	}
+
+	// HTTP-network fetch step 4.2
+	// chunked encoding is handled by Node.js
+
+	return Object.assign({}, parsedURL, {
+		method: request.method,
+		headers: exportNodeCompatibleHeaders(headers),
+		agent
+	});
+}
+
+/**
+ * abort-error.js
+ *
+ * AbortError interface for cancelled requests
+ */
+
+/**
+ * Create AbortError instance
+ *
+ * @param   String      message      Error message for human
+ * @return  AbortError
+ */
+function AbortError(message) {
+  Error.call(this, message);
+
+  this.type = 'aborted';
+  this.message = message;
+
+  // hide custom error implementation details from end-users
+  Error.captureStackTrace(this, this.constructor);
+}
+
+AbortError.prototype = Object.create(Error.prototype);
+AbortError.prototype.constructor = AbortError;
+AbortError.prototype.name = 'AbortError';
+
+// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
+const PassThrough$1 = Stream.PassThrough;
+const resolve_url = Url.resolve;
+
+/**
+ * Fetch function
+ *
+ * @param   Mixed    url   Absolute url or Request instance
+ * @param   Object   opts  Fetch options
+ * @return  Promise
+ */
+function fetch(url, opts) {
+
+	// allow custom promise
+	if (!fetch.Promise) {
+		throw new Error('native promise missing, set fetch.Promise to your favorite alternative');
+	}
+
+	Body.Promise = fetch.Promise;
+
+	// wrap http.request into fetch
+	return new fetch.Promise(function (resolve, reject) {
+		// build request object
+		const request = new Request(url, opts);
+		const options = getNodeRequestOptions(request);
+
+		const send = (options.protocol === 'https:' ? https : http).request;
+		const signal = request.signal;
+
+		let response = null;
+
+		const abort = function abort() {
+			let error = new AbortError('The user aborted a request.');
+			reject(error);
+			if (request.body && request.body instanceof Stream.Readable) {
+				request.body.destroy(error);
+			}
+			if (!response || !response.body) return;
+			response.body.emit('error', error);
+		};
+
+		if (signal && signal.aborted) {
+			abort();
+			return;
+		}
+
+		const abortAndFinalize = function abortAndFinalize() {
+			abort();
+			finalize();
+		};
+
+		// send request
+		const req = send(options);
+		let reqTimeout;
+
+		if (signal) {
+			signal.addEventListener('abort', abortAndFinalize);
+		}
+
+		function finalize() {
+			req.abort();
+			if (signal) signal.removeEventListener('abort', abortAndFinalize);
+			clearTimeout(reqTimeout);
+		}
+
+		if (request.timeout) {
+			req.once('socket', function (socket) {
+				reqTimeout = setTimeout(function () {
+					reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout'));
+					finalize();
+				}, request.timeout);
+			});
+		}
+
+		req.on('error', function (err) {
+			reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
+			finalize();
+		});
+
+		req.on('response', function (res) {
+			clearTimeout(reqTimeout);
+
+			const headers = createHeadersLenient(res.headers);
+
+			// HTTP fetch step 5
+			if (fetch.isRedirect(res.statusCode)) {
+				// HTTP fetch step 5.2
+				const location = headers.get('Location');
+
+				// HTTP fetch step 5.3
+				const locationURL = location === null ? null : resolve_url(request.url, location);
+
+				// HTTP fetch step 5.5
+				switch (request.redirect) {
+					case 'error':
+						reject(new FetchError(`redirect mode is set to error: ${request.url}`, 'no-redirect'));
+						finalize();
+						return;
+					case 'manual':
+						// node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL.
+						if (locationURL !== null) {
+							// handle corrupted header
+							try {
+								headers.set('Location', locationURL);
+							} catch (err) {
+								// istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request
+								reject(err);
+							}
+						}
+						break;
+					case 'follow':
+						// HTTP-redirect fetch step 2
+						if (locationURL === null) {
+							break;
+						}
+
+						// HTTP-redirect fetch step 5
+						if (request.counter >= request.follow) {
+							reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect'));
+							finalize();
+							return;
+						}
+
+						// HTTP-redirect fetch step 6 (counter increment)
+						// Create a new Request object.
+						const requestOpts = {
+							headers: new Headers(request.headers),
+							follow: request.follow,
+							counter: request.counter + 1,
+							agent: request.agent,
+							compress: request.compress,
+							method: request.method,
+							body: request.body,
+							signal: request.signal,
+							timeout: request.timeout
+						};
+
+						// HTTP-redirect fetch step 9
+						if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
+							reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
+							finalize();
+							return;
+						}
+
+						// HTTP-redirect fetch step 11
+						if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') {
+							requestOpts.method = 'GET';
+							requestOpts.body = undefined;
+							requestOpts.headers.delete('content-length');
+						}
+
+						// HTTP-redirect fetch step 15
+						resolve(fetch(new Request(locationURL, requestOpts)));
+						finalize();
+						return;
+				}
+			}
+
+			// prepare response
+			res.once('end', function () {
+				if (signal) signal.removeEventListener('abort', abortAndFinalize);
+			});
+			let body = res.pipe(new PassThrough$1());
+
+			const response_options = {
+				url: request.url,
+				status: res.statusCode,
+				statusText: res.statusMessage,
+				headers: headers,
+				size: request.size,
+				timeout: request.timeout,
+				counter: request.counter
+			};
+
+			// HTTP-network fetch step 12.1.1.3
+			const codings = headers.get('Content-Encoding');
+
+			// HTTP-network fetch step 12.1.1.4: handle content codings
+
+			// in following scenarios we ignore compression support
+			// 1. compression support is disabled
+			// 2. HEAD request
+			// 3. no Content-Encoding header
+			// 4. no content response (204)
+			// 5. content not modified response (304)
+			if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) {
+				response = new Response(body, response_options);
+				resolve(response);
+				return;
+			}
+
+			// For Node v6+
+			// Be less strict when decoding compressed responses, since sometimes
+			// servers send slightly invalid responses that are still accepted
+			// by common browsers.
+			// Always using Z_SYNC_FLUSH is what cURL does.
+			const zlibOptions = {
+				flush: zlib.Z_SYNC_FLUSH,
+				finishFlush: zlib.Z_SYNC_FLUSH
+			};
+
+			// for gzip
+			if (codings == 'gzip' || codings == 'x-gzip') {
+				body = body.pipe(zlib.createGunzip(zlibOptions));
+				response = new Response(body, response_options);
+				resolve(response);
+				return;
+			}
+
+			// for deflate
+			if (codings == 'deflate' || codings == 'x-deflate') {
+				// handle the infamous raw deflate response from old servers
+				// a hack for old IIS and Apache servers
+				const raw = res.pipe(new PassThrough$1());
+				raw.once('data', function (chunk) {
+					// see http://stackoverflow.com/questions/37519828
+					if ((chunk[0] & 0x0F) === 0x08) {
+						body = body.pipe(zlib.createInflate());
+					} else {
+						body = body.pipe(zlib.createInflateRaw());
+					}
+					response = new Response(body, response_options);
+					resolve(response);
+				});
+				return;
+			}
+
+			// for br
+			if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') {
+				body = body.pipe(zlib.createBrotliDecompress());
+				response = new Response(body, response_options);
+				resolve(response);
+				return;
+			}
+
+			// otherwise, use response as-is
+			response = new Response(body, response_options);
+			resolve(response);
+		});
+
+		writeToStream(req, request);
+	});
+}
+/**
+ * Redirect code matching
+ *
+ * @param   Number   code  Status code
+ * @return  Boolean
+ */
+fetch.isRedirect = function (code) {
+	return code === 301 || code === 302 || code === 303 || code === 307 || code === 308;
+};
+
+// expose Promise
+fetch.Promise = global.Promise;
+
+export default fetch;
+export { Headers, Request, Response, FetchError };

+ 1642 - 0
node_modules/node-fetch/lib/index.js

@@ -0,0 +1,1642 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
+
+var Stream = _interopDefault(require('stream'));
+var http = _interopDefault(require('http'));
+var Url = _interopDefault(require('url'));
+var https = _interopDefault(require('https'));
+var zlib = _interopDefault(require('zlib'));
+
+// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js
+
+// fix for "Readable" isn't a named export issue
+const Readable = Stream.Readable;
+
+const BUFFER = Symbol('buffer');
+const TYPE = Symbol('type');
+
+class Blob {
+	constructor() {
+		this[TYPE] = '';
+
+		const blobParts = arguments[0];
+		const options = arguments[1];
+
+		const buffers = [];
+		let size = 0;
+
+		if (blobParts) {
+			const a = blobParts;
+			const length = Number(a.length);
+			for (let i = 0; i < length; i++) {
+				const element = a[i];
+				let buffer;
+				if (element instanceof Buffer) {
+					buffer = element;
+				} else if (ArrayBuffer.isView(element)) {
+					buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength);
+				} else if (element instanceof ArrayBuffer) {
+					buffer = Buffer.from(element);
+				} else if (element instanceof Blob) {
+					buffer = element[BUFFER];
+				} else {
+					buffer = Buffer.from(typeof element === 'string' ? element : String(element));
+				}
+				size += buffer.length;
+				buffers.push(buffer);
+			}
+		}
+
+		this[BUFFER] = Buffer.concat(buffers);
+
+		let type = options && options.type !== undefined && String(options.type).toLowerCase();
+		if (type && !/[^\u0020-\u007E]/.test(type)) {
+			this[TYPE] = type;
+		}
+	}
+	get size() {
+		return this[BUFFER].length;
+	}
+	get type() {
+		return this[TYPE];
+	}
+	text() {
+		return Promise.resolve(this[BUFFER].toString());
+	}
+	arrayBuffer() {
+		const buf = this[BUFFER];
+		const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
+		return Promise.resolve(ab);
+	}
+	stream() {
+		const readable = new Readable();
+		readable._read = function () {};
+		readable.push(this[BUFFER]);
+		readable.push(null);
+		return readable;
+	}
+	toString() {
+		return '[object Blob]';
+	}
+	slice() {
+		const size = this.size;
+
+		const start = arguments[0];
+		const end = arguments[1];
+		let relativeStart, relativeEnd;
+		if (start === undefined) {
+			relativeStart = 0;
+		} else if (start < 0) {
+			relativeStart = Math.max(size + start, 0);
+		} else {
+			relativeStart = Math.min(start, size);
+		}
+		if (end === undefined) {
+			relativeEnd = size;
+		} else if (end < 0) {
+			relativeEnd = Math.max(size + end, 0);
+		} else {
+			relativeEnd = Math.min(end, size);
+		}
+		const span = Math.max(relativeEnd - relativeStart, 0);
+
+		const buffer = this[BUFFER];
+		const slicedBuffer = buffer.slice(relativeStart, relativeStart + span);
+		const blob = new Blob([], { type: arguments[2] });
+		blob[BUFFER] = slicedBuffer;
+		return blob;
+	}
+}
+
+Object.defineProperties(Blob.prototype, {
+	size: { enumerable: true },
+	type: { enumerable: true },
+	slice: { enumerable: true }
+});
+
+Object.defineProperty(Blob.prototype, Symbol.toStringTag, {
+	value: 'Blob',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+/**
+ * fetch-error.js
+ *
+ * FetchError interface for operational errors
+ */
+
+/**
+ * Create FetchError instance
+ *
+ * @param   String      message      Error message for human
+ * @param   String      type         Error type for machine
+ * @param   String      systemError  For Node.js system error
+ * @return  FetchError
+ */
+function FetchError(message, type, systemError) {
+  Error.call(this, message);
+
+  this.message = message;
+  this.type = type;
+
+  // when err.type is `system`, err.code contains system error code
+  if (systemError) {
+    this.code = this.errno = systemError.code;
+  }
+
+  // hide custom error implementation details from end-users
+  Error.captureStackTrace(this, this.constructor);
+}
+
+FetchError.prototype = Object.create(Error.prototype);
+FetchError.prototype.constructor = FetchError;
+FetchError.prototype.name = 'FetchError';
+
+let convert;
+try {
+	convert = require('encoding').convert;
+} catch (e) {}
+
+const INTERNALS = Symbol('Body internals');
+
+// fix an issue where "PassThrough" isn't a named export for node <10
+const PassThrough = Stream.PassThrough;
+
+/**
+ * Body mixin
+ *
+ * Ref: https://fetch.spec.whatwg.org/#body
+ *
+ * @param   Stream  body  Readable stream
+ * @param   Object  opts  Response options
+ * @return  Void
+ */
+function Body(body) {
+	var _this = this;
+
+	var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+	    _ref$size = _ref.size;
+
+	let size = _ref$size === undefined ? 0 : _ref$size;
+	var _ref$timeout = _ref.timeout;
+	let timeout = _ref$timeout === undefined ? 0 : _ref$timeout;
+
+	if (body == null) {
+		// body is undefined or null
+		body = null;
+	} else if (isURLSearchParams(body)) {
+		// body is a URLSearchParams
+		body = Buffer.from(body.toString());
+	} else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') {
+		// body is ArrayBuffer
+		body = Buffer.from(body);
+	} else if (ArrayBuffer.isView(body)) {
+		// body is ArrayBufferView
+		body = Buffer.from(body.buffer, body.byteOffset, body.byteLength);
+	} else if (body instanceof Stream) ; else {
+		// none of the above
+		// coerce to string then buffer
+		body = Buffer.from(String(body));
+	}
+	this[INTERNALS] = {
+		body,
+		disturbed: false,
+		error: null
+	};
+	this.size = size;
+	this.timeout = timeout;
+
+	if (body instanceof Stream) {
+		body.on('error', function (err) {
+			const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err);
+			_this[INTERNALS].error = error;
+		});
+	}
+}
+
+Body.prototype = {
+	get body() {
+		return this[INTERNALS].body;
+	},
+
+	get bodyUsed() {
+		return this[INTERNALS].disturbed;
+	},
+
+	/**
+  * Decode response as ArrayBuffer
+  *
+  * @return  Promise
+  */
+	arrayBuffer() {
+		return consumeBody.call(this).then(function (buf) {
+			return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
+		});
+	},
+
+	/**
+  * Return raw response as Blob
+  *
+  * @return Promise
+  */
+	blob() {
+		let ct = this.headers && this.headers.get('content-type') || '';
+		return consumeBody.call(this).then(function (buf) {
+			return Object.assign(
+			// Prevent copying
+			new Blob([], {
+				type: ct.toLowerCase()
+			}), {
+				[BUFFER]: buf
+			});
+		});
+	},
+
+	/**
+  * Decode response as json
+  *
+  * @return  Promise
+  */
+	json() {
+		var _this2 = this;
+
+		return consumeBody.call(this).then(function (buffer) {
+			try {
+				return JSON.parse(buffer.toString());
+			} catch (err) {
+				return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));
+			}
+		});
+	},
+
+	/**
+  * Decode response as text
+  *
+  * @return  Promise
+  */
+	text() {
+		return consumeBody.call(this).then(function (buffer) {
+			return buffer.toString();
+		});
+	},
+
+	/**
+  * Decode response as buffer (non-spec api)
+  *
+  * @return  Promise
+  */
+	buffer() {
+		return consumeBody.call(this);
+	},
+
+	/**
+  * Decode response as text, while automatically detecting the encoding and
+  * trying to decode to UTF-8 (non-spec api)
+  *
+  * @return  Promise
+  */
+	textConverted() {
+		var _this3 = this;
+
+		return consumeBody.call(this).then(function (buffer) {
+			return convertBody(buffer, _this3.headers);
+		});
+	}
+};
+
+// In browsers, all properties are enumerable.
+Object.defineProperties(Body.prototype, {
+	body: { enumerable: true },
+	bodyUsed: { enumerable: true },
+	arrayBuffer: { enumerable: true },
+	blob: { enumerable: true },
+	json: { enumerable: true },
+	text: { enumerable: true }
+});
+
+Body.mixIn = function (proto) {
+	for (const name of Object.getOwnPropertyNames(Body.prototype)) {
+		// istanbul ignore else: future proof
+		if (!(name in proto)) {
+			const desc = Object.getOwnPropertyDescriptor(Body.prototype, name);
+			Object.defineProperty(proto, name, desc);
+		}
+	}
+};
+
+/**
+ * Consume and convert an entire Body to a Buffer.
+ *
+ * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body
+ *
+ * @return  Promise
+ */
+function consumeBody() {
+	var _this4 = this;
+
+	if (this[INTERNALS].disturbed) {
+		return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`));
+	}
+
+	this[INTERNALS].disturbed = true;
+
+	if (this[INTERNALS].error) {
+		return Body.Promise.reject(this[INTERNALS].error);
+	}
+
+	let body = this.body;
+
+	// body is null
+	if (body === null) {
+		return Body.Promise.resolve(Buffer.alloc(0));
+	}
+
+	// body is blob
+	if (isBlob(body)) {
+		body = body.stream();
+	}
+
+	// body is buffer
+	if (Buffer.isBuffer(body)) {
+		return Body.Promise.resolve(body);
+	}
+
+	// istanbul ignore if: should never happen
+	if (!(body instanceof Stream)) {
+		return Body.Promise.resolve(Buffer.alloc(0));
+	}
+
+	// body is stream
+	// get ready to actually consume the body
+	let accum = [];
+	let accumBytes = 0;
+	let abort = false;
+
+	return new Body.Promise(function (resolve, reject) {
+		let resTimeout;
+
+		// allow timeout on slow response body
+		if (_this4.timeout) {
+			resTimeout = setTimeout(function () {
+				abort = true;
+				reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout'));
+			}, _this4.timeout);
+		}
+
+		// handle stream errors
+		body.on('error', function (err) {
+			if (err.name === 'AbortError') {
+				// if the request was aborted, reject with this Error
+				abort = true;
+				reject(err);
+			} else {
+				// other errors, such as incorrect content-encoding
+				reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err));
+			}
+		});
+
+		body.on('data', function (chunk) {
+			if (abort || chunk === null) {
+				return;
+			}
+
+			if (_this4.size && accumBytes + chunk.length > _this4.size) {
+				abort = true;
+				reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size'));
+				return;
+			}
+
+			accumBytes += chunk.length;
+			accum.push(chunk);
+		});
+
+		body.on('end', function () {
+			if (abort) {
+				return;
+			}
+
+			clearTimeout(resTimeout);
+
+			try {
+				resolve(Buffer.concat(accum, accumBytes));
+			} catch (err) {
+				// handle streams that have accumulated too much data (issue #414)
+				reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err));
+			}
+		});
+	});
+}
+
+/**
+ * Detect buffer encoding and convert to target encoding
+ * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding
+ *
+ * @param   Buffer  buffer    Incoming buffer
+ * @param   String  encoding  Target encoding
+ * @return  String
+ */
+function convertBody(buffer, headers) {
+	if (typeof convert !== 'function') {
+		throw new Error('The package `encoding` must be installed to use the textConverted() function');
+	}
+
+	const ct = headers.get('content-type');
+	let charset = 'utf-8';
+	let res, str;
+
+	// header
+	if (ct) {
+		res = /charset=([^;]*)/i.exec(ct);
+	}
+
+	// no charset in content type, peek at response body for at most 1024 bytes
+	str = buffer.slice(0, 1024).toString();
+
+	// html5
+	if (!res && str) {
+		res = /<meta.+?charset=(['"])(.+?)\1/i.exec(str);
+	}
+
+	// html4
+	if (!res && str) {
+		res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str);
+
+		if (res) {
+			res = /charset=(.*)/i.exec(res.pop());
+		}
+	}
+
+	// xml
+	if (!res && str) {
+		res = /<\?xml.+?encoding=(['"])(.+?)\1/i.exec(str);
+	}
+
+	// found charset
+	if (res) {
+		charset = res.pop();
+
+		// prevent decode issues when sites use incorrect encoding
+		// ref: https://hsivonen.fi/encoding-menu/
+		if (charset === 'gb2312' || charset === 'gbk') {
+			charset = 'gb18030';
+		}
+	}
+
+	// turn raw buffers into a single utf-8 buffer
+	return convert(buffer, 'UTF-8', charset).toString();
+}
+
+/**
+ * Detect a URLSearchParams object
+ * ref: https://github.com/bitinn/node-fetch/issues/296#issuecomment-307598143
+ *
+ * @param   Object  obj     Object to detect by type or brand
+ * @return  String
+ */
+function isURLSearchParams(obj) {
+	// Duck-typing as a necessary condition.
+	if (typeof obj !== 'object' || typeof obj.append !== 'function' || typeof obj.delete !== 'function' || typeof obj.get !== 'function' || typeof obj.getAll !== 'function' || typeof obj.has !== 'function' || typeof obj.set !== 'function') {
+		return false;
+	}
+
+	// Brand-checking and more duck-typing as optional condition.
+	return obj.constructor.name === 'URLSearchParams' || Object.prototype.toString.call(obj) === '[object URLSearchParams]' || typeof obj.sort === 'function';
+}
+
+/**
+ * Check if `obj` is a W3C `Blob` object (which `File` inherits from)
+ * @param  {*} obj
+ * @return {boolean}
+ */
+function isBlob(obj) {
+	return typeof obj === 'object' && typeof obj.arrayBuffer === 'function' && typeof obj.type === 'string' && typeof obj.stream === 'function' && typeof obj.constructor === 'function' && typeof obj.constructor.name === 'string' && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
+}
+
+/**
+ * Clone body given Res/Req instance
+ *
+ * @param   Mixed  instance  Response or Request instance
+ * @return  Mixed
+ */
+function clone(instance) {
+	let p1, p2;
+	let body = instance.body;
+
+	// don't allow cloning a used body
+	if (instance.bodyUsed) {
+		throw new Error('cannot clone body after it is used');
+	}
+
+	// check that body is a stream and not form-data object
+	// note: we can't clone the form-data object without having it as a dependency
+	if (body instanceof Stream && typeof body.getBoundary !== 'function') {
+		// tee instance body
+		p1 = new PassThrough();
+		p2 = new PassThrough();
+		body.pipe(p1);
+		body.pipe(p2);
+		// set instance body to teed body and return the other teed body
+		instance[INTERNALS].body = p1;
+		body = p2;
+	}
+
+	return body;
+}
+
+/**
+ * Performs the operation "extract a `Content-Type` value from |object|" as
+ * specified in the specification:
+ * https://fetch.spec.whatwg.org/#concept-bodyinit-extract
+ *
+ * This function assumes that instance.body is present.
+ *
+ * @param   Mixed  instance  Any options.body input
+ */
+function extractContentType(body) {
+	if (body === null) {
+		// body is null
+		return null;
+	} else if (typeof body === 'string') {
+		// body is string
+		return 'text/plain;charset=UTF-8';
+	} else if (isURLSearchParams(body)) {
+		// body is a URLSearchParams
+		return 'application/x-www-form-urlencoded;charset=UTF-8';
+	} else if (isBlob(body)) {
+		// body is blob
+		return body.type || null;
+	} else if (Buffer.isBuffer(body)) {
+		// body is buffer
+		return null;
+	} else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') {
+		// body is ArrayBuffer
+		return null;
+	} else if (ArrayBuffer.isView(body)) {
+		// body is ArrayBufferView
+		return null;
+	} else if (typeof body.getBoundary === 'function') {
+		// detect form data input from form-data module
+		return `multipart/form-data;boundary=${body.getBoundary()}`;
+	} else if (body instanceof Stream) {
+		// body is stream
+		// can't really do much about this
+		return null;
+	} else {
+		// Body constructor defaults other things to string
+		return 'text/plain;charset=UTF-8';
+	}
+}
+
+/**
+ * The Fetch Standard treats this as if "total bytes" is a property on the body.
+ * For us, we have to explicitly get it with a function.
+ *
+ * ref: https://fetch.spec.whatwg.org/#concept-body-total-bytes
+ *
+ * @param   Body    instance   Instance of Body
+ * @return  Number?            Number of bytes, or null if not possible
+ */
+function getTotalBytes(instance) {
+	const body = instance.body;
+
+
+	if (body === null) {
+		// body is null
+		return 0;
+	} else if (isBlob(body)) {
+		return body.size;
+	} else if (Buffer.isBuffer(body)) {
+		// body is buffer
+		return body.length;
+	} else if (body && typeof body.getLengthSync === 'function') {
+		// detect form data input from form-data module
+		if (body._lengthRetrievers && body._lengthRetrievers.length == 0 || // 1.x
+		body.hasKnownLength && body.hasKnownLength()) {
+			// 2.x
+			return body.getLengthSync();
+		}
+		return null;
+	} else {
+		// body is stream
+		return null;
+	}
+}
+
+/**
+ * Write a Body to a Node.js WritableStream (e.g. http.Request) object.
+ *
+ * @param   Body    instance   Instance of Body
+ * @return  Void
+ */
+function writeToStream(dest, instance) {
+	const body = instance.body;
+
+
+	if (body === null) {
+		// body is null
+		dest.end();
+	} else if (isBlob(body)) {
+		body.stream().pipe(dest);
+	} else if (Buffer.isBuffer(body)) {
+		// body is buffer
+		dest.write(body);
+		dest.end();
+	} else {
+		// body is stream
+		body.pipe(dest);
+	}
+}
+
+// expose Promise
+Body.Promise = global.Promise;
+
+/**
+ * headers.js
+ *
+ * Headers class offers convenient helpers
+ */
+
+const invalidTokenRegex = /[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/;
+const invalidHeaderCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
+
+function validateName(name) {
+	name = `${name}`;
+	if (invalidTokenRegex.test(name) || name === '') {
+		throw new TypeError(`${name} is not a legal HTTP header name`);
+	}
+}
+
+function validateValue(value) {
+	value = `${value}`;
+	if (invalidHeaderCharRegex.test(value)) {
+		throw new TypeError(`${value} is not a legal HTTP header value`);
+	}
+}
+
+/**
+ * Find the key in the map object given a header name.
+ *
+ * Returns undefined if not found.
+ *
+ * @param   String  name  Header name
+ * @return  String|Undefined
+ */
+function find(map, name) {
+	name = name.toLowerCase();
+	for (const key in map) {
+		if (key.toLowerCase() === name) {
+			return key;
+		}
+	}
+	return undefined;
+}
+
+const MAP = Symbol('map');
+class Headers {
+	/**
+  * Headers class
+  *
+  * @param   Object  headers  Response headers
+  * @return  Void
+  */
+	constructor() {
+		let init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
+
+		this[MAP] = Object.create(null);
+
+		if (init instanceof Headers) {
+			const rawHeaders = init.raw();
+			const headerNames = Object.keys(rawHeaders);
+
+			for (const headerName of headerNames) {
+				for (const value of rawHeaders[headerName]) {
+					this.append(headerName, value);
+				}
+			}
+
+			return;
+		}
+
+		// We don't worry about converting prop to ByteString here as append()
+		// will handle it.
+		if (init == null) ; else if (typeof init === 'object') {
+			const method = init[Symbol.iterator];
+			if (method != null) {
+				if (typeof method !== 'function') {
+					throw new TypeError('Header pairs must be iterable');
+				}
+
+				// sequence<sequence<ByteString>>
+				// Note: per spec we have to first exhaust the lists then process them
+				const pairs = [];
+				for (const pair of init) {
+					if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') {
+						throw new TypeError('Each header pair must be iterable');
+					}
+					pairs.push(Array.from(pair));
+				}
+
+				for (const pair of pairs) {
+					if (pair.length !== 2) {
+						throw new TypeError('Each header pair must be a name/value tuple');
+					}
+					this.append(pair[0], pair[1]);
+				}
+			} else {
+				// record<ByteString, ByteString>
+				for (const key of Object.keys(init)) {
+					const value = init[key];
+					this.append(key, value);
+				}
+			}
+		} else {
+			throw new TypeError('Provided initializer must be an object');
+		}
+	}
+
+	/**
+  * Return combined header value given name
+  *
+  * @param   String  name  Header name
+  * @return  Mixed
+  */
+	get(name) {
+		name = `${name}`;
+		validateName(name);
+		const key = find(this[MAP], name);
+		if (key === undefined) {
+			return null;
+		}
+
+		return this[MAP][key].join(', ');
+	}
+
+	/**
+  * Iterate over all headers
+  *
+  * @param   Function  callback  Executed for each item with parameters (value, name, thisArg)
+  * @param   Boolean   thisArg   `this` context for callback function
+  * @return  Void
+  */
+	forEach(callback) {
+		let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
+
+		let pairs = getHeaders(this);
+		let i = 0;
+		while (i < pairs.length) {
+			var _pairs$i = pairs[i];
+			const name = _pairs$i[0],
+			      value = _pairs$i[1];
+
+			callback.call(thisArg, value, name, this);
+			pairs = getHeaders(this);
+			i++;
+		}
+	}
+
+	/**
+  * Overwrite header values given name
+  *
+  * @param   String  name   Header name
+  * @param   String  value  Header value
+  * @return  Void
+  */
+	set(name, value) {
+		name = `${name}`;
+		value = `${value}`;
+		validateName(name);
+		validateValue(value);
+		const key = find(this[MAP], name);
+		this[MAP][key !== undefined ? key : name] = [value];
+	}
+
+	/**
+  * Append a value onto existing header
+  *
+  * @param   String  name   Header name
+  * @param   String  value  Header value
+  * @return  Void
+  */
+	append(name, value) {
+		name = `${name}`;
+		value = `${value}`;
+		validateName(name);
+		validateValue(value);
+		const key = find(this[MAP], name);
+		if (key !== undefined) {
+			this[MAP][key].push(value);
+		} else {
+			this[MAP][name] = [value];
+		}
+	}
+
+	/**
+  * Check for header name existence
+  *
+  * @param   String   name  Header name
+  * @return  Boolean
+  */
+	has(name) {
+		name = `${name}`;
+		validateName(name);
+		return find(this[MAP], name) !== undefined;
+	}
+
+	/**
+  * Delete all header values given name
+  *
+  * @param   String  name  Header name
+  * @return  Void
+  */
+	delete(name) {
+		name = `${name}`;
+		validateName(name);
+		const key = find(this[MAP], name);
+		if (key !== undefined) {
+			delete this[MAP][key];
+		}
+	}
+
+	/**
+  * Return raw headers (non-spec api)
+  *
+  * @return  Object
+  */
+	raw() {
+		return this[MAP];
+	}
+
+	/**
+  * Get an iterator on keys.
+  *
+  * @return  Iterator
+  */
+	keys() {
+		return createHeadersIterator(this, 'key');
+	}
+
+	/**
+  * Get an iterator on values.
+  *
+  * @return  Iterator
+  */
+	values() {
+		return createHeadersIterator(this, 'value');
+	}
+
+	/**
+  * Get an iterator on entries.
+  *
+  * This is the default iterator of the Headers object.
+  *
+  * @return  Iterator
+  */
+	[Symbol.iterator]() {
+		return createHeadersIterator(this, 'key+value');
+	}
+}
+Headers.prototype.entries = Headers.prototype[Symbol.iterator];
+
+Object.defineProperty(Headers.prototype, Symbol.toStringTag, {
+	value: 'Headers',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+Object.defineProperties(Headers.prototype, {
+	get: { enumerable: true },
+	forEach: { enumerable: true },
+	set: { enumerable: true },
+	append: { enumerable: true },
+	has: { enumerable: true },
+	delete: { enumerable: true },
+	keys: { enumerable: true },
+	values: { enumerable: true },
+	entries: { enumerable: true }
+});
+
+function getHeaders(headers) {
+	let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value';
+
+	const keys = Object.keys(headers[MAP]).sort();
+	return keys.map(kind === 'key' ? function (k) {
+		return k.toLowerCase();
+	} : kind === 'value' ? function (k) {
+		return headers[MAP][k].join(', ');
+	} : function (k) {
+		return [k.toLowerCase(), headers[MAP][k].join(', ')];
+	});
+}
+
+const INTERNAL = Symbol('internal');
+
+function createHeadersIterator(target, kind) {
+	const iterator = Object.create(HeadersIteratorPrototype);
+	iterator[INTERNAL] = {
+		target,
+		kind,
+		index: 0
+	};
+	return iterator;
+}
+
+const HeadersIteratorPrototype = Object.setPrototypeOf({
+	next() {
+		// istanbul ignore if
+		if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) {
+			throw new TypeError('Value of `this` is not a HeadersIterator');
+		}
+
+		var _INTERNAL = this[INTERNAL];
+		const target = _INTERNAL.target,
+		      kind = _INTERNAL.kind,
+		      index = _INTERNAL.index;
+
+		const values = getHeaders(target, kind);
+		const len = values.length;
+		if (index >= len) {
+			return {
+				value: undefined,
+				done: true
+			};
+		}
+
+		this[INTERNAL].index = index + 1;
+
+		return {
+			value: values[index],
+			done: false
+		};
+	}
+}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));
+
+Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, {
+	value: 'HeadersIterator',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+/**
+ * Export the Headers object in a form that Node.js can consume.
+ *
+ * @param   Headers  headers
+ * @return  Object
+ */
+function exportNodeCompatibleHeaders(headers) {
+	const obj = Object.assign({ __proto__: null }, headers[MAP]);
+
+	// http.request() only supports string as Host header. This hack makes
+	// specifying custom Host header possible.
+	const hostHeaderKey = find(headers[MAP], 'Host');
+	if (hostHeaderKey !== undefined) {
+		obj[hostHeaderKey] = obj[hostHeaderKey][0];
+	}
+
+	return obj;
+}
+
+/**
+ * Create a Headers object from an object of headers, ignoring those that do
+ * not conform to HTTP grammar productions.
+ *
+ * @param   Object  obj  Object of headers
+ * @return  Headers
+ */
+function createHeadersLenient(obj) {
+	const headers = new Headers();
+	for (const name of Object.keys(obj)) {
+		if (invalidTokenRegex.test(name)) {
+			continue;
+		}
+		if (Array.isArray(obj[name])) {
+			for (const val of obj[name]) {
+				if (invalidHeaderCharRegex.test(val)) {
+					continue;
+				}
+				if (headers[MAP][name] === undefined) {
+					headers[MAP][name] = [val];
+				} else {
+					headers[MAP][name].push(val);
+				}
+			}
+		} else if (!invalidHeaderCharRegex.test(obj[name])) {
+			headers[MAP][name] = [obj[name]];
+		}
+	}
+	return headers;
+}
+
+const INTERNALS$1 = Symbol('Response internals');
+
+// fix an issue where "STATUS_CODES" aren't a named export for node <10
+const STATUS_CODES = http.STATUS_CODES;
+
+/**
+ * Response class
+ *
+ * @param   Stream  body  Readable stream
+ * @param   Object  opts  Response options
+ * @return  Void
+ */
+class Response {
+	constructor() {
+		let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
+		let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+
+		Body.call(this, body, opts);
+
+		const status = opts.status || 200;
+		const headers = new Headers(opts.headers);
+
+		if (body != null && !headers.has('Content-Type')) {
+			const contentType = extractContentType(body);
+			if (contentType) {
+				headers.append('Content-Type', contentType);
+			}
+		}
+
+		this[INTERNALS$1] = {
+			url: opts.url,
+			status,
+			statusText: opts.statusText || STATUS_CODES[status],
+			headers,
+			counter: opts.counter
+		};
+	}
+
+	get url() {
+		return this[INTERNALS$1].url || '';
+	}
+
+	get status() {
+		return this[INTERNALS$1].status;
+	}
+
+	/**
+  * Convenience property representing if the request ended normally
+  */
+	get ok() {
+		return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300;
+	}
+
+	get redirected() {
+		return this[INTERNALS$1].counter > 0;
+	}
+
+	get statusText() {
+		return this[INTERNALS$1].statusText;
+	}
+
+	get headers() {
+		return this[INTERNALS$1].headers;
+	}
+
+	/**
+  * Clone this response
+  *
+  * @return  Response
+  */
+	clone() {
+		return new Response(clone(this), {
+			url: this.url,
+			status: this.status,
+			statusText: this.statusText,
+			headers: this.headers,
+			ok: this.ok,
+			redirected: this.redirected
+		});
+	}
+}
+
+Body.mixIn(Response.prototype);
+
+Object.defineProperties(Response.prototype, {
+	url: { enumerable: true },
+	status: { enumerable: true },
+	ok: { enumerable: true },
+	redirected: { enumerable: true },
+	statusText: { enumerable: true },
+	headers: { enumerable: true },
+	clone: { enumerable: true }
+});
+
+Object.defineProperty(Response.prototype, Symbol.toStringTag, {
+	value: 'Response',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+const INTERNALS$2 = Symbol('Request internals');
+
+// fix an issue where "format", "parse" aren't a named export for node <10
+const parse_url = Url.parse;
+const format_url = Url.format;
+
+const streamDestructionSupported = 'destroy' in Stream.Readable.prototype;
+
+/**
+ * Check if a value is an instance of Request.
+ *
+ * @param   Mixed   input
+ * @return  Boolean
+ */
+function isRequest(input) {
+	return typeof input === 'object' && typeof input[INTERNALS$2] === 'object';
+}
+
+function isAbortSignal(signal) {
+	const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal);
+	return !!(proto && proto.constructor.name === 'AbortSignal');
+}
+
+/**
+ * Request class
+ *
+ * @param   Mixed   input  Url or Request instance
+ * @param   Object  init   Custom options
+ * @return  Void
+ */
+class Request {
+	constructor(input) {
+		let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+
+		let parsedURL;
+
+		// normalize input
+		if (!isRequest(input)) {
+			if (input && input.href) {
+				// in order to support Node.js' Url objects; though WHATWG's URL objects
+				// will fall into this branch also (since their `toString()` will return
+				// `href` property anyway)
+				parsedURL = parse_url(input.href);
+			} else {
+				// coerce input to a string before attempting to parse
+				parsedURL = parse_url(`${input}`);
+			}
+			input = {};
+		} else {
+			parsedURL = parse_url(input.url);
+		}
+
+		let method = init.method || input.method || 'GET';
+		method = method.toUpperCase();
+
+		if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) {
+			throw new TypeError('Request with GET/HEAD method cannot have body');
+		}
+
+		let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
+
+		Body.call(this, inputBody, {
+			timeout: init.timeout || input.timeout || 0,
+			size: init.size || input.size || 0
+		});
+
+		const headers = new Headers(init.headers || input.headers || {});
+
+		if (inputBody != null && !headers.has('Content-Type')) {
+			const contentType = extractContentType(inputBody);
+			if (contentType) {
+				headers.append('Content-Type', contentType);
+			}
+		}
+
+		let signal = isRequest(input) ? input.signal : null;
+		if ('signal' in init) signal = init.signal;
+
+		if (signal != null && !isAbortSignal(signal)) {
+			throw new TypeError('Expected signal to be an instanceof AbortSignal');
+		}
+
+		this[INTERNALS$2] = {
+			method,
+			redirect: init.redirect || input.redirect || 'follow',
+			headers,
+			parsedURL,
+			signal
+		};
+
+		// node-fetch-only options
+		this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20;
+		this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true;
+		this.counter = init.counter || input.counter || 0;
+		this.agent = init.agent || input.agent;
+	}
+
+	get method() {
+		return this[INTERNALS$2].method;
+	}
+
+	get url() {
+		return format_url(this[INTERNALS$2].parsedURL);
+	}
+
+	get headers() {
+		return this[INTERNALS$2].headers;
+	}
+
+	get redirect() {
+		return this[INTERNALS$2].redirect;
+	}
+
+	get signal() {
+		return this[INTERNALS$2].signal;
+	}
+
+	/**
+  * Clone this request
+  *
+  * @return  Request
+  */
+	clone() {
+		return new Request(this);
+	}
+}
+
+Body.mixIn(Request.prototype);
+
+Object.defineProperty(Request.prototype, Symbol.toStringTag, {
+	value: 'Request',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+Object.defineProperties(Request.prototype, {
+	method: { enumerable: true },
+	url: { enumerable: true },
+	headers: { enumerable: true },
+	redirect: { enumerable: true },
+	clone: { enumerable: true },
+	signal: { enumerable: true }
+});
+
+/**
+ * Convert a Request to Node.js http request options.
+ *
+ * @param   Request  A Request instance
+ * @return  Object   The options object to be passed to http.request
+ */
+function getNodeRequestOptions(request) {
+	const parsedURL = request[INTERNALS$2].parsedURL;
+	const headers = new Headers(request[INTERNALS$2].headers);
+
+	// fetch step 1.3
+	if (!headers.has('Accept')) {
+		headers.set('Accept', '*/*');
+	}
+
+	// Basic fetch
+	if (!parsedURL.protocol || !parsedURL.hostname) {
+		throw new TypeError('Only absolute URLs are supported');
+	}
+
+	if (!/^https?:$/.test(parsedURL.protocol)) {
+		throw new TypeError('Only HTTP(S) protocols are supported');
+	}
+
+	if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) {
+		throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8');
+	}
+
+	// HTTP-network-or-cache fetch steps 2.4-2.7
+	let contentLengthValue = null;
+	if (request.body == null && /^(POST|PUT)$/i.test(request.method)) {
+		contentLengthValue = '0';
+	}
+	if (request.body != null) {
+		const totalBytes = getTotalBytes(request);
+		if (typeof totalBytes === 'number') {
+			contentLengthValue = String(totalBytes);
+		}
+	}
+	if (contentLengthValue) {
+		headers.set('Content-Length', contentLengthValue);
+	}
+
+	// HTTP-network-or-cache fetch step 2.11
+	if (!headers.has('User-Agent')) {
+		headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)');
+	}
+
+	// HTTP-network-or-cache fetch step 2.15
+	if (request.compress && !headers.has('Accept-Encoding')) {
+		headers.set('Accept-Encoding', 'gzip,deflate');
+	}
+
+	let agent = request.agent;
+	if (typeof agent === 'function') {
+		agent = agent(parsedURL);
+	}
+
+	if (!headers.has('Connection') && !agent) {
+		headers.set('Connection', 'close');
+	}
+
+	// HTTP-network fetch step 4.2
+	// chunked encoding is handled by Node.js
+
+	return Object.assign({}, parsedURL, {
+		method: request.method,
+		headers: exportNodeCompatibleHeaders(headers),
+		agent
+	});
+}
+
+/**
+ * abort-error.js
+ *
+ * AbortError interface for cancelled requests
+ */
+
+/**
+ * Create AbortError instance
+ *
+ * @param   String      message      Error message for human
+ * @return  AbortError
+ */
+function AbortError(message) {
+  Error.call(this, message);
+
+  this.type = 'aborted';
+  this.message = message;
+
+  // hide custom error implementation details from end-users
+  Error.captureStackTrace(this, this.constructor);
+}
+
+AbortError.prototype = Object.create(Error.prototype);
+AbortError.prototype.constructor = AbortError;
+AbortError.prototype.name = 'AbortError';
+
+// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
+const PassThrough$1 = Stream.PassThrough;
+const resolve_url = Url.resolve;
+
+/**
+ * Fetch function
+ *
+ * @param   Mixed    url   Absolute url or Request instance
+ * @param   Object   opts  Fetch options
+ * @return  Promise
+ */
+function fetch(url, opts) {
+
+	// allow custom promise
+	if (!fetch.Promise) {
+		throw new Error('native promise missing, set fetch.Promise to your favorite alternative');
+	}
+
+	Body.Promise = fetch.Promise;
+
+	// wrap http.request into fetch
+	return new fetch.Promise(function (resolve, reject) {
+		// build request object
+		const request = new Request(url, opts);
+		const options = getNodeRequestOptions(request);
+
+		const send = (options.protocol === 'https:' ? https : http).request;
+		const signal = request.signal;
+
+		let response = null;
+
+		const abort = function abort() {
+			let error = new AbortError('The user aborted a request.');
+			reject(error);
+			if (request.body && request.body instanceof Stream.Readable) {
+				request.body.destroy(error);
+			}
+			if (!response || !response.body) return;
+			response.body.emit('error', error);
+		};
+
+		if (signal && signal.aborted) {
+			abort();
+			return;
+		}
+
+		const abortAndFinalize = function abortAndFinalize() {
+			abort();
+			finalize();
+		};
+
+		// send request
+		const req = send(options);
+		let reqTimeout;
+
+		if (signal) {
+			signal.addEventListener('abort', abortAndFinalize);
+		}
+
+		function finalize() {
+			req.abort();
+			if (signal) signal.removeEventListener('abort', abortAndFinalize);
+			clearTimeout(reqTimeout);
+		}
+
+		if (request.timeout) {
+			req.once('socket', function (socket) {
+				reqTimeout = setTimeout(function () {
+					reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout'));
+					finalize();
+				}, request.timeout);
+			});
+		}
+
+		req.on('error', function (err) {
+			reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
+			finalize();
+		});
+
+		req.on('response', function (res) {
+			clearTimeout(reqTimeout);
+
+			const headers = createHeadersLenient(res.headers);
+
+			// HTTP fetch step 5
+			if (fetch.isRedirect(res.statusCode)) {
+				// HTTP fetch step 5.2
+				const location = headers.get('Location');
+
+				// HTTP fetch step 5.3
+				const locationURL = location === null ? null : resolve_url(request.url, location);
+
+				// HTTP fetch step 5.5
+				switch (request.redirect) {
+					case 'error':
+						reject(new FetchError(`redirect mode is set to error: ${request.url}`, 'no-redirect'));
+						finalize();
+						return;
+					case 'manual':
+						// node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL.
+						if (locationURL !== null) {
+							// handle corrupted header
+							try {
+								headers.set('Location', locationURL);
+							} catch (err) {
+								// istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request
+								reject(err);
+							}
+						}
+						break;
+					case 'follow':
+						// HTTP-redirect fetch step 2
+						if (locationURL === null) {
+							break;
+						}
+
+						// HTTP-redirect fetch step 5
+						if (request.counter >= request.follow) {
+							reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect'));
+							finalize();
+							return;
+						}
+
+						// HTTP-redirect fetch step 6 (counter increment)
+						// Create a new Request object.
+						const requestOpts = {
+							headers: new Headers(request.headers),
+							follow: request.follow,
+							counter: request.counter + 1,
+							agent: request.agent,
+							compress: request.compress,
+							method: request.method,
+							body: request.body,
+							signal: request.signal,
+							timeout: request.timeout
+						};
+
+						// HTTP-redirect fetch step 9
+						if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
+							reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
+							finalize();
+							return;
+						}
+
+						// HTTP-redirect fetch step 11
+						if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') {
+							requestOpts.method = 'GET';
+							requestOpts.body = undefined;
+							requestOpts.headers.delete('content-length');
+						}
+
+						// HTTP-redirect fetch step 15
+						resolve(fetch(new Request(locationURL, requestOpts)));
+						finalize();
+						return;
+				}
+			}
+
+			// prepare response
+			res.once('end', function () {
+				if (signal) signal.removeEventListener('abort', abortAndFinalize);
+			});
+			let body = res.pipe(new PassThrough$1());
+
+			const response_options = {
+				url: request.url,
+				status: res.statusCode,
+				statusText: res.statusMessage,
+				headers: headers,
+				size: request.size,
+				timeout: request.timeout,
+				counter: request.counter
+			};
+
+			// HTTP-network fetch step 12.1.1.3
+			const codings = headers.get('Content-Encoding');
+
+			// HTTP-network fetch step 12.1.1.4: handle content codings
+
+			// in following scenarios we ignore compression support
+			// 1. compression support is disabled
+			// 2. HEAD request
+			// 3. no Content-Encoding header
+			// 4. no content response (204)
+			// 5. content not modified response (304)
+			if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) {
+				response = new Response(body, response_options);
+				resolve(response);
+				return;
+			}
+
+			// For Node v6+
+			// Be less strict when decoding compressed responses, since sometimes
+			// servers send slightly invalid responses that are still accepted
+			// by common browsers.
+			// Always using Z_SYNC_FLUSH is what cURL does.
+			const zlibOptions = {
+				flush: zlib.Z_SYNC_FLUSH,
+				finishFlush: zlib.Z_SYNC_FLUSH
+			};
+
+			// for gzip
+			if (codings == 'gzip' || codings == 'x-gzip') {
+				body = body.pipe(zlib.createGunzip(zlibOptions));
+				response = new Response(body, response_options);
+				resolve(response);
+				return;
+			}
+
+			// for deflate
+			if (codings == 'deflate' || codings == 'x-deflate') {
+				// handle the infamous raw deflate response from old servers
+				// a hack for old IIS and Apache servers
+				const raw = res.pipe(new PassThrough$1());
+				raw.once('data', function (chunk) {
+					// see http://stackoverflow.com/questions/37519828
+					if ((chunk[0] & 0x0F) === 0x08) {
+						body = body.pipe(zlib.createInflate());
+					} else {
+						body = body.pipe(zlib.createInflateRaw());
+					}
+					response = new Response(body, response_options);
+					resolve(response);
+				});
+				return;
+			}
+
+			// for br
+			if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') {
+				body = body.pipe(zlib.createBrotliDecompress());
+				response = new Response(body, response_options);
+				resolve(response);
+				return;
+			}
+
+			// otherwise, use response as-is
+			response = new Response(body, response_options);
+			resolve(response);
+		});
+
+		writeToStream(req, request);
+	});
+}
+/**
+ * Redirect code matching
+ *
+ * @param   Number   code  Status code
+ * @return  Boolean
+ */
+fetch.isRedirect = function (code) {
+	return code === 301 || code === 302 || code === 303 || code === 307 || code === 308;
+};
+
+// expose Promise
+fetch.Promise = global.Promise;
+
+module.exports = exports = fetch;
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.default = exports;
+exports.Headers = Headers;
+exports.Request = Request;
+exports.Response = Response;
+exports.FetchError = FetchError;

+ 1631 - 0
node_modules/node-fetch/lib/index.mjs

@@ -0,0 +1,1631 @@
+import Stream from 'stream';
+import http from 'http';
+import Url from 'url';
+import https from 'https';
+import zlib from 'zlib';
+
+// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js
+
+// fix for "Readable" isn't a named export issue
+const Readable = Stream.Readable;
+
+const BUFFER = Symbol('buffer');
+const TYPE = Symbol('type');
+
+class Blob {
+	constructor() {
+		this[TYPE] = '';
+
+		const blobParts = arguments[0];
+		const options = arguments[1];
+
+		const buffers = [];
+		let size = 0;
+
+		if (blobParts) {
+			const a = blobParts;
+			const length = Number(a.length);
+			for (let i = 0; i < length; i++) {
+				const element = a[i];
+				let buffer;
+				if (element instanceof Buffer) {
+					buffer = element;
+				} else if (ArrayBuffer.isView(element)) {
+					buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength);
+				} else if (element instanceof ArrayBuffer) {
+					buffer = Buffer.from(element);
+				} else if (element instanceof Blob) {
+					buffer = element[BUFFER];
+				} else {
+					buffer = Buffer.from(typeof element === 'string' ? element : String(element));
+				}
+				size += buffer.length;
+				buffers.push(buffer);
+			}
+		}
+
+		this[BUFFER] = Buffer.concat(buffers);
+
+		let type = options && options.type !== undefined && String(options.type).toLowerCase();
+		if (type && !/[^\u0020-\u007E]/.test(type)) {
+			this[TYPE] = type;
+		}
+	}
+	get size() {
+		return this[BUFFER].length;
+	}
+	get type() {
+		return this[TYPE];
+	}
+	text() {
+		return Promise.resolve(this[BUFFER].toString());
+	}
+	arrayBuffer() {
+		const buf = this[BUFFER];
+		const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
+		return Promise.resolve(ab);
+	}
+	stream() {
+		const readable = new Readable();
+		readable._read = function () {};
+		readable.push(this[BUFFER]);
+		readable.push(null);
+		return readable;
+	}
+	toString() {
+		return '[object Blob]';
+	}
+	slice() {
+		const size = this.size;
+
+		const start = arguments[0];
+		const end = arguments[1];
+		let relativeStart, relativeEnd;
+		if (start === undefined) {
+			relativeStart = 0;
+		} else if (start < 0) {
+			relativeStart = Math.max(size + start, 0);
+		} else {
+			relativeStart = Math.min(start, size);
+		}
+		if (end === undefined) {
+			relativeEnd = size;
+		} else if (end < 0) {
+			relativeEnd = Math.max(size + end, 0);
+		} else {
+			relativeEnd = Math.min(end, size);
+		}
+		const span = Math.max(relativeEnd - relativeStart, 0);
+
+		const buffer = this[BUFFER];
+		const slicedBuffer = buffer.slice(relativeStart, relativeStart + span);
+		const blob = new Blob([], { type: arguments[2] });
+		blob[BUFFER] = slicedBuffer;
+		return blob;
+	}
+}
+
+Object.defineProperties(Blob.prototype, {
+	size: { enumerable: true },
+	type: { enumerable: true },
+	slice: { enumerable: true }
+});
+
+Object.defineProperty(Blob.prototype, Symbol.toStringTag, {
+	value: 'Blob',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+/**
+ * fetch-error.js
+ *
+ * FetchError interface for operational errors
+ */
+
+/**
+ * Create FetchError instance
+ *
+ * @param   String      message      Error message for human
+ * @param   String      type         Error type for machine
+ * @param   String      systemError  For Node.js system error
+ * @return  FetchError
+ */
+function FetchError(message, type, systemError) {
+  Error.call(this, message);
+
+  this.message = message;
+  this.type = type;
+
+  // when err.type is `system`, err.code contains system error code
+  if (systemError) {
+    this.code = this.errno = systemError.code;
+  }
+
+  // hide custom error implementation details from end-users
+  Error.captureStackTrace(this, this.constructor);
+}
+
+FetchError.prototype = Object.create(Error.prototype);
+FetchError.prototype.constructor = FetchError;
+FetchError.prototype.name = 'FetchError';
+
+let convert;
+try {
+	convert = require('encoding').convert;
+} catch (e) {}
+
+const INTERNALS = Symbol('Body internals');
+
+// fix an issue where "PassThrough" isn't a named export for node <10
+const PassThrough = Stream.PassThrough;
+
+/**
+ * Body mixin
+ *
+ * Ref: https://fetch.spec.whatwg.org/#body
+ *
+ * @param   Stream  body  Readable stream
+ * @param   Object  opts  Response options
+ * @return  Void
+ */
+function Body(body) {
+	var _this = this;
+
+	var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+	    _ref$size = _ref.size;
+
+	let size = _ref$size === undefined ? 0 : _ref$size;
+	var _ref$timeout = _ref.timeout;
+	let timeout = _ref$timeout === undefined ? 0 : _ref$timeout;
+
+	if (body == null) {
+		// body is undefined or null
+		body = null;
+	} else if (isURLSearchParams(body)) {
+		// body is a URLSearchParams
+		body = Buffer.from(body.toString());
+	} else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') {
+		// body is ArrayBuffer
+		body = Buffer.from(body);
+	} else if (ArrayBuffer.isView(body)) {
+		// body is ArrayBufferView
+		body = Buffer.from(body.buffer, body.byteOffset, body.byteLength);
+	} else if (body instanceof Stream) ; else {
+		// none of the above
+		// coerce to string then buffer
+		body = Buffer.from(String(body));
+	}
+	this[INTERNALS] = {
+		body,
+		disturbed: false,
+		error: null
+	};
+	this.size = size;
+	this.timeout = timeout;
+
+	if (body instanceof Stream) {
+		body.on('error', function (err) {
+			const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err);
+			_this[INTERNALS].error = error;
+		});
+	}
+}
+
+Body.prototype = {
+	get body() {
+		return this[INTERNALS].body;
+	},
+
+	get bodyUsed() {
+		return this[INTERNALS].disturbed;
+	},
+
+	/**
+  * Decode response as ArrayBuffer
+  *
+  * @return  Promise
+  */
+	arrayBuffer() {
+		return consumeBody.call(this).then(function (buf) {
+			return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
+		});
+	},
+
+	/**
+  * Return raw response as Blob
+  *
+  * @return Promise
+  */
+	blob() {
+		let ct = this.headers && this.headers.get('content-type') || '';
+		return consumeBody.call(this).then(function (buf) {
+			return Object.assign(
+			// Prevent copying
+			new Blob([], {
+				type: ct.toLowerCase()
+			}), {
+				[BUFFER]: buf
+			});
+		});
+	},
+
+	/**
+  * Decode response as json
+  *
+  * @return  Promise
+  */
+	json() {
+		var _this2 = this;
+
+		return consumeBody.call(this).then(function (buffer) {
+			try {
+				return JSON.parse(buffer.toString());
+			} catch (err) {
+				return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));
+			}
+		});
+	},
+
+	/**
+  * Decode response as text
+  *
+  * @return  Promise
+  */
+	text() {
+		return consumeBody.call(this).then(function (buffer) {
+			return buffer.toString();
+		});
+	},
+
+	/**
+  * Decode response as buffer (non-spec api)
+  *
+  * @return  Promise
+  */
+	buffer() {
+		return consumeBody.call(this);
+	},
+
+	/**
+  * Decode response as text, while automatically detecting the encoding and
+  * trying to decode to UTF-8 (non-spec api)
+  *
+  * @return  Promise
+  */
+	textConverted() {
+		var _this3 = this;
+
+		return consumeBody.call(this).then(function (buffer) {
+			return convertBody(buffer, _this3.headers);
+		});
+	}
+};
+
+// In browsers, all properties are enumerable.
+Object.defineProperties(Body.prototype, {
+	body: { enumerable: true },
+	bodyUsed: { enumerable: true },
+	arrayBuffer: { enumerable: true },
+	blob: { enumerable: true },
+	json: { enumerable: true },
+	text: { enumerable: true }
+});
+
+Body.mixIn = function (proto) {
+	for (const name of Object.getOwnPropertyNames(Body.prototype)) {
+		// istanbul ignore else: future proof
+		if (!(name in proto)) {
+			const desc = Object.getOwnPropertyDescriptor(Body.prototype, name);
+			Object.defineProperty(proto, name, desc);
+		}
+	}
+};
+
+/**
+ * Consume and convert an entire Body to a Buffer.
+ *
+ * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body
+ *
+ * @return  Promise
+ */
+function consumeBody() {
+	var _this4 = this;
+
+	if (this[INTERNALS].disturbed) {
+		return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`));
+	}
+
+	this[INTERNALS].disturbed = true;
+
+	if (this[INTERNALS].error) {
+		return Body.Promise.reject(this[INTERNALS].error);
+	}
+
+	let body = this.body;
+
+	// body is null
+	if (body === null) {
+		return Body.Promise.resolve(Buffer.alloc(0));
+	}
+
+	// body is blob
+	if (isBlob(body)) {
+		body = body.stream();
+	}
+
+	// body is buffer
+	if (Buffer.isBuffer(body)) {
+		return Body.Promise.resolve(body);
+	}
+
+	// istanbul ignore if: should never happen
+	if (!(body instanceof Stream)) {
+		return Body.Promise.resolve(Buffer.alloc(0));
+	}
+
+	// body is stream
+	// get ready to actually consume the body
+	let accum = [];
+	let accumBytes = 0;
+	let abort = false;
+
+	return new Body.Promise(function (resolve, reject) {
+		let resTimeout;
+
+		// allow timeout on slow response body
+		if (_this4.timeout) {
+			resTimeout = setTimeout(function () {
+				abort = true;
+				reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout'));
+			}, _this4.timeout);
+		}
+
+		// handle stream errors
+		body.on('error', function (err) {
+			if (err.name === 'AbortError') {
+				// if the request was aborted, reject with this Error
+				abort = true;
+				reject(err);
+			} else {
+				// other errors, such as incorrect content-encoding
+				reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err));
+			}
+		});
+
+		body.on('data', function (chunk) {
+			if (abort || chunk === null) {
+				return;
+			}
+
+			if (_this4.size && accumBytes + chunk.length > _this4.size) {
+				abort = true;
+				reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size'));
+				return;
+			}
+
+			accumBytes += chunk.length;
+			accum.push(chunk);
+		});
+
+		body.on('end', function () {
+			if (abort) {
+				return;
+			}
+
+			clearTimeout(resTimeout);
+
+			try {
+				resolve(Buffer.concat(accum, accumBytes));
+			} catch (err) {
+				// handle streams that have accumulated too much data (issue #414)
+				reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err));
+			}
+		});
+	});
+}
+
+/**
+ * Detect buffer encoding and convert to target encoding
+ * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding
+ *
+ * @param   Buffer  buffer    Incoming buffer
+ * @param   String  encoding  Target encoding
+ * @return  String
+ */
+function convertBody(buffer, headers) {
+	if (typeof convert !== 'function') {
+		throw new Error('The package `encoding` must be installed to use the textConverted() function');
+	}
+
+	const ct = headers.get('content-type');
+	let charset = 'utf-8';
+	let res, str;
+
+	// header
+	if (ct) {
+		res = /charset=([^;]*)/i.exec(ct);
+	}
+
+	// no charset in content type, peek at response body for at most 1024 bytes
+	str = buffer.slice(0, 1024).toString();
+
+	// html5
+	if (!res && str) {
+		res = /<meta.+?charset=(['"])(.+?)\1/i.exec(str);
+	}
+
+	// html4
+	if (!res && str) {
+		res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str);
+
+		if (res) {
+			res = /charset=(.*)/i.exec(res.pop());
+		}
+	}
+
+	// xml
+	if (!res && str) {
+		res = /<\?xml.+?encoding=(['"])(.+?)\1/i.exec(str);
+	}
+
+	// found charset
+	if (res) {
+		charset = res.pop();
+
+		// prevent decode issues when sites use incorrect encoding
+		// ref: https://hsivonen.fi/encoding-menu/
+		if (charset === 'gb2312' || charset === 'gbk') {
+			charset = 'gb18030';
+		}
+	}
+
+	// turn raw buffers into a single utf-8 buffer
+	return convert(buffer, 'UTF-8', charset).toString();
+}
+
+/**
+ * Detect a URLSearchParams object
+ * ref: https://github.com/bitinn/node-fetch/issues/296#issuecomment-307598143
+ *
+ * @param   Object  obj     Object to detect by type or brand
+ * @return  String
+ */
+function isURLSearchParams(obj) {
+	// Duck-typing as a necessary condition.
+	if (typeof obj !== 'object' || typeof obj.append !== 'function' || typeof obj.delete !== 'function' || typeof obj.get !== 'function' || typeof obj.getAll !== 'function' || typeof obj.has !== 'function' || typeof obj.set !== 'function') {
+		return false;
+	}
+
+	// Brand-checking and more duck-typing as optional condition.
+	return obj.constructor.name === 'URLSearchParams' || Object.prototype.toString.call(obj) === '[object URLSearchParams]' || typeof obj.sort === 'function';
+}
+
+/**
+ * Check if `obj` is a W3C `Blob` object (which `File` inherits from)
+ * @param  {*} obj
+ * @return {boolean}
+ */
+function isBlob(obj) {
+	return typeof obj === 'object' && typeof obj.arrayBuffer === 'function' && typeof obj.type === 'string' && typeof obj.stream === 'function' && typeof obj.constructor === 'function' && typeof obj.constructor.name === 'string' && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
+}
+
+/**
+ * Clone body given Res/Req instance
+ *
+ * @param   Mixed  instance  Response or Request instance
+ * @return  Mixed
+ */
+function clone(instance) {
+	let p1, p2;
+	let body = instance.body;
+
+	// don't allow cloning a used body
+	if (instance.bodyUsed) {
+		throw new Error('cannot clone body after it is used');
+	}
+
+	// check that body is a stream and not form-data object
+	// note: we can't clone the form-data object without having it as a dependency
+	if (body instanceof Stream && typeof body.getBoundary !== 'function') {
+		// tee instance body
+		p1 = new PassThrough();
+		p2 = new PassThrough();
+		body.pipe(p1);
+		body.pipe(p2);
+		// set instance body to teed body and return the other teed body
+		instance[INTERNALS].body = p1;
+		body = p2;
+	}
+
+	return body;
+}
+
+/**
+ * Performs the operation "extract a `Content-Type` value from |object|" as
+ * specified in the specification:
+ * https://fetch.spec.whatwg.org/#concept-bodyinit-extract
+ *
+ * This function assumes that instance.body is present.
+ *
+ * @param   Mixed  instance  Any options.body input
+ */
+function extractContentType(body) {
+	if (body === null) {
+		// body is null
+		return null;
+	} else if (typeof body === 'string') {
+		// body is string
+		return 'text/plain;charset=UTF-8';
+	} else if (isURLSearchParams(body)) {
+		// body is a URLSearchParams
+		return 'application/x-www-form-urlencoded;charset=UTF-8';
+	} else if (isBlob(body)) {
+		// body is blob
+		return body.type || null;
+	} else if (Buffer.isBuffer(body)) {
+		// body is buffer
+		return null;
+	} else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') {
+		// body is ArrayBuffer
+		return null;
+	} else if (ArrayBuffer.isView(body)) {
+		// body is ArrayBufferView
+		return null;
+	} else if (typeof body.getBoundary === 'function') {
+		// detect form data input from form-data module
+		return `multipart/form-data;boundary=${body.getBoundary()}`;
+	} else if (body instanceof Stream) {
+		// body is stream
+		// can't really do much about this
+		return null;
+	} else {
+		// Body constructor defaults other things to string
+		return 'text/plain;charset=UTF-8';
+	}
+}
+
+/**
+ * The Fetch Standard treats this as if "total bytes" is a property on the body.
+ * For us, we have to explicitly get it with a function.
+ *
+ * ref: https://fetch.spec.whatwg.org/#concept-body-total-bytes
+ *
+ * @param   Body    instance   Instance of Body
+ * @return  Number?            Number of bytes, or null if not possible
+ */
+function getTotalBytes(instance) {
+	const body = instance.body;
+
+
+	if (body === null) {
+		// body is null
+		return 0;
+	} else if (isBlob(body)) {
+		return body.size;
+	} else if (Buffer.isBuffer(body)) {
+		// body is buffer
+		return body.length;
+	} else if (body && typeof body.getLengthSync === 'function') {
+		// detect form data input from form-data module
+		if (body._lengthRetrievers && body._lengthRetrievers.length == 0 || // 1.x
+		body.hasKnownLength && body.hasKnownLength()) {
+			// 2.x
+			return body.getLengthSync();
+		}
+		return null;
+	} else {
+		// body is stream
+		return null;
+	}
+}
+
+/**
+ * Write a Body to a Node.js WritableStream (e.g. http.Request) object.
+ *
+ * @param   Body    instance   Instance of Body
+ * @return  Void
+ */
+function writeToStream(dest, instance) {
+	const body = instance.body;
+
+
+	if (body === null) {
+		// body is null
+		dest.end();
+	} else if (isBlob(body)) {
+		body.stream().pipe(dest);
+	} else if (Buffer.isBuffer(body)) {
+		// body is buffer
+		dest.write(body);
+		dest.end();
+	} else {
+		// body is stream
+		body.pipe(dest);
+	}
+}
+
+// expose Promise
+Body.Promise = global.Promise;
+
+/**
+ * headers.js
+ *
+ * Headers class offers convenient helpers
+ */
+
+const invalidTokenRegex = /[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/;
+const invalidHeaderCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
+
+function validateName(name) {
+	name = `${name}`;
+	if (invalidTokenRegex.test(name) || name === '') {
+		throw new TypeError(`${name} is not a legal HTTP header name`);
+	}
+}
+
+function validateValue(value) {
+	value = `${value}`;
+	if (invalidHeaderCharRegex.test(value)) {
+		throw new TypeError(`${value} is not a legal HTTP header value`);
+	}
+}
+
+/**
+ * Find the key in the map object given a header name.
+ *
+ * Returns undefined if not found.
+ *
+ * @param   String  name  Header name
+ * @return  String|Undefined
+ */
+function find(map, name) {
+	name = name.toLowerCase();
+	for (const key in map) {
+		if (key.toLowerCase() === name) {
+			return key;
+		}
+	}
+	return undefined;
+}
+
+const MAP = Symbol('map');
+class Headers {
+	/**
+  * Headers class
+  *
+  * @param   Object  headers  Response headers
+  * @return  Void
+  */
+	constructor() {
+		let init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
+
+		this[MAP] = Object.create(null);
+
+		if (init instanceof Headers) {
+			const rawHeaders = init.raw();
+			const headerNames = Object.keys(rawHeaders);
+
+			for (const headerName of headerNames) {
+				for (const value of rawHeaders[headerName]) {
+					this.append(headerName, value);
+				}
+			}
+
+			return;
+		}
+
+		// We don't worry about converting prop to ByteString here as append()
+		// will handle it.
+		if (init == null) ; else if (typeof init === 'object') {
+			const method = init[Symbol.iterator];
+			if (method != null) {
+				if (typeof method !== 'function') {
+					throw new TypeError('Header pairs must be iterable');
+				}
+
+				// sequence<sequence<ByteString>>
+				// Note: per spec we have to first exhaust the lists then process them
+				const pairs = [];
+				for (const pair of init) {
+					if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') {
+						throw new TypeError('Each header pair must be iterable');
+					}
+					pairs.push(Array.from(pair));
+				}
+
+				for (const pair of pairs) {
+					if (pair.length !== 2) {
+						throw new TypeError('Each header pair must be a name/value tuple');
+					}
+					this.append(pair[0], pair[1]);
+				}
+			} else {
+				// record<ByteString, ByteString>
+				for (const key of Object.keys(init)) {
+					const value = init[key];
+					this.append(key, value);
+				}
+			}
+		} else {
+			throw new TypeError('Provided initializer must be an object');
+		}
+	}
+
+	/**
+  * Return combined header value given name
+  *
+  * @param   String  name  Header name
+  * @return  Mixed
+  */
+	get(name) {
+		name = `${name}`;
+		validateName(name);
+		const key = find(this[MAP], name);
+		if (key === undefined) {
+			return null;
+		}
+
+		return this[MAP][key].join(', ');
+	}
+
+	/**
+  * Iterate over all headers
+  *
+  * @param   Function  callback  Executed for each item with parameters (value, name, thisArg)
+  * @param   Boolean   thisArg   `this` context for callback function
+  * @return  Void
+  */
+	forEach(callback) {
+		let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
+
+		let pairs = getHeaders(this);
+		let i = 0;
+		while (i < pairs.length) {
+			var _pairs$i = pairs[i];
+			const name = _pairs$i[0],
+			      value = _pairs$i[1];
+
+			callback.call(thisArg, value, name, this);
+			pairs = getHeaders(this);
+			i++;
+		}
+	}
+
+	/**
+  * Overwrite header values given name
+  *
+  * @param   String  name   Header name
+  * @param   String  value  Header value
+  * @return  Void
+  */
+	set(name, value) {
+		name = `${name}`;
+		value = `${value}`;
+		validateName(name);
+		validateValue(value);
+		const key = find(this[MAP], name);
+		this[MAP][key !== undefined ? key : name] = [value];
+	}
+
+	/**
+  * Append a value onto existing header
+  *
+  * @param   String  name   Header name
+  * @param   String  value  Header value
+  * @return  Void
+  */
+	append(name, value) {
+		name = `${name}`;
+		value = `${value}`;
+		validateName(name);
+		validateValue(value);
+		const key = find(this[MAP], name);
+		if (key !== undefined) {
+			this[MAP][key].push(value);
+		} else {
+			this[MAP][name] = [value];
+		}
+	}
+
+	/**
+  * Check for header name existence
+  *
+  * @param   String   name  Header name
+  * @return  Boolean
+  */
+	has(name) {
+		name = `${name}`;
+		validateName(name);
+		return find(this[MAP], name) !== undefined;
+	}
+
+	/**
+  * Delete all header values given name
+  *
+  * @param   String  name  Header name
+  * @return  Void
+  */
+	delete(name) {
+		name = `${name}`;
+		validateName(name);
+		const key = find(this[MAP], name);
+		if (key !== undefined) {
+			delete this[MAP][key];
+		}
+	}
+
+	/**
+  * Return raw headers (non-spec api)
+  *
+  * @return  Object
+  */
+	raw() {
+		return this[MAP];
+	}
+
+	/**
+  * Get an iterator on keys.
+  *
+  * @return  Iterator
+  */
+	keys() {
+		return createHeadersIterator(this, 'key');
+	}
+
+	/**
+  * Get an iterator on values.
+  *
+  * @return  Iterator
+  */
+	values() {
+		return createHeadersIterator(this, 'value');
+	}
+
+	/**
+  * Get an iterator on entries.
+  *
+  * This is the default iterator of the Headers object.
+  *
+  * @return  Iterator
+  */
+	[Symbol.iterator]() {
+		return createHeadersIterator(this, 'key+value');
+	}
+}
+Headers.prototype.entries = Headers.prototype[Symbol.iterator];
+
+Object.defineProperty(Headers.prototype, Symbol.toStringTag, {
+	value: 'Headers',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+Object.defineProperties(Headers.prototype, {
+	get: { enumerable: true },
+	forEach: { enumerable: true },
+	set: { enumerable: true },
+	append: { enumerable: true },
+	has: { enumerable: true },
+	delete: { enumerable: true },
+	keys: { enumerable: true },
+	values: { enumerable: true },
+	entries: { enumerable: true }
+});
+
+function getHeaders(headers) {
+	let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value';
+
+	const keys = Object.keys(headers[MAP]).sort();
+	return keys.map(kind === 'key' ? function (k) {
+		return k.toLowerCase();
+	} : kind === 'value' ? function (k) {
+		return headers[MAP][k].join(', ');
+	} : function (k) {
+		return [k.toLowerCase(), headers[MAP][k].join(', ')];
+	});
+}
+
+const INTERNAL = Symbol('internal');
+
+function createHeadersIterator(target, kind) {
+	const iterator = Object.create(HeadersIteratorPrototype);
+	iterator[INTERNAL] = {
+		target,
+		kind,
+		index: 0
+	};
+	return iterator;
+}
+
+const HeadersIteratorPrototype = Object.setPrototypeOf({
+	next() {
+		// istanbul ignore if
+		if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) {
+			throw new TypeError('Value of `this` is not a HeadersIterator');
+		}
+
+		var _INTERNAL = this[INTERNAL];
+		const target = _INTERNAL.target,
+		      kind = _INTERNAL.kind,
+		      index = _INTERNAL.index;
+
+		const values = getHeaders(target, kind);
+		const len = values.length;
+		if (index >= len) {
+			return {
+				value: undefined,
+				done: true
+			};
+		}
+
+		this[INTERNAL].index = index + 1;
+
+		return {
+			value: values[index],
+			done: false
+		};
+	}
+}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));
+
+Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, {
+	value: 'HeadersIterator',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+/**
+ * Export the Headers object in a form that Node.js can consume.
+ *
+ * @param   Headers  headers
+ * @return  Object
+ */
+function exportNodeCompatibleHeaders(headers) {
+	const obj = Object.assign({ __proto__: null }, headers[MAP]);
+
+	// http.request() only supports string as Host header. This hack makes
+	// specifying custom Host header possible.
+	const hostHeaderKey = find(headers[MAP], 'Host');
+	if (hostHeaderKey !== undefined) {
+		obj[hostHeaderKey] = obj[hostHeaderKey][0];
+	}
+
+	return obj;
+}
+
+/**
+ * Create a Headers object from an object of headers, ignoring those that do
+ * not conform to HTTP grammar productions.
+ *
+ * @param   Object  obj  Object of headers
+ * @return  Headers
+ */
+function createHeadersLenient(obj) {
+	const headers = new Headers();
+	for (const name of Object.keys(obj)) {
+		if (invalidTokenRegex.test(name)) {
+			continue;
+		}
+		if (Array.isArray(obj[name])) {
+			for (const val of obj[name]) {
+				if (invalidHeaderCharRegex.test(val)) {
+					continue;
+				}
+				if (headers[MAP][name] === undefined) {
+					headers[MAP][name] = [val];
+				} else {
+					headers[MAP][name].push(val);
+				}
+			}
+		} else if (!invalidHeaderCharRegex.test(obj[name])) {
+			headers[MAP][name] = [obj[name]];
+		}
+	}
+	return headers;
+}
+
+const INTERNALS$1 = Symbol('Response internals');
+
+// fix an issue where "STATUS_CODES" aren't a named export for node <10
+const STATUS_CODES = http.STATUS_CODES;
+
+/**
+ * Response class
+ *
+ * @param   Stream  body  Readable stream
+ * @param   Object  opts  Response options
+ * @return  Void
+ */
+class Response {
+	constructor() {
+		let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
+		let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+
+		Body.call(this, body, opts);
+
+		const status = opts.status || 200;
+		const headers = new Headers(opts.headers);
+
+		if (body != null && !headers.has('Content-Type')) {
+			const contentType = extractContentType(body);
+			if (contentType) {
+				headers.append('Content-Type', contentType);
+			}
+		}
+
+		this[INTERNALS$1] = {
+			url: opts.url,
+			status,
+			statusText: opts.statusText || STATUS_CODES[status],
+			headers,
+			counter: opts.counter
+		};
+	}
+
+	get url() {
+		return this[INTERNALS$1].url || '';
+	}
+
+	get status() {
+		return this[INTERNALS$1].status;
+	}
+
+	/**
+  * Convenience property representing if the request ended normally
+  */
+	get ok() {
+		return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300;
+	}
+
+	get redirected() {
+		return this[INTERNALS$1].counter > 0;
+	}
+
+	get statusText() {
+		return this[INTERNALS$1].statusText;
+	}
+
+	get headers() {
+		return this[INTERNALS$1].headers;
+	}
+
+	/**
+  * Clone this response
+  *
+  * @return  Response
+  */
+	clone() {
+		return new Response(clone(this), {
+			url: this.url,
+			status: this.status,
+			statusText: this.statusText,
+			headers: this.headers,
+			ok: this.ok,
+			redirected: this.redirected
+		});
+	}
+}
+
+Body.mixIn(Response.prototype);
+
+Object.defineProperties(Response.prototype, {
+	url: { enumerable: true },
+	status: { enumerable: true },
+	ok: { enumerable: true },
+	redirected: { enumerable: true },
+	statusText: { enumerable: true },
+	headers: { enumerable: true },
+	clone: { enumerable: true }
+});
+
+Object.defineProperty(Response.prototype, Symbol.toStringTag, {
+	value: 'Response',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+const INTERNALS$2 = Symbol('Request internals');
+
+// fix an issue where "format", "parse" aren't a named export for node <10
+const parse_url = Url.parse;
+const format_url = Url.format;
+
+const streamDestructionSupported = 'destroy' in Stream.Readable.prototype;
+
+/**
+ * Check if a value is an instance of Request.
+ *
+ * @param   Mixed   input
+ * @return  Boolean
+ */
+function isRequest(input) {
+	return typeof input === 'object' && typeof input[INTERNALS$2] === 'object';
+}
+
+function isAbortSignal(signal) {
+	const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal);
+	return !!(proto && proto.constructor.name === 'AbortSignal');
+}
+
+/**
+ * Request class
+ *
+ * @param   Mixed   input  Url or Request instance
+ * @param   Object  init   Custom options
+ * @return  Void
+ */
+class Request {
+	constructor(input) {
+		let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+
+		let parsedURL;
+
+		// normalize input
+		if (!isRequest(input)) {
+			if (input && input.href) {
+				// in order to support Node.js' Url objects; though WHATWG's URL objects
+				// will fall into this branch also (since their `toString()` will return
+				// `href` property anyway)
+				parsedURL = parse_url(input.href);
+			} else {
+				// coerce input to a string before attempting to parse
+				parsedURL = parse_url(`${input}`);
+			}
+			input = {};
+		} else {
+			parsedURL = parse_url(input.url);
+		}
+
+		let method = init.method || input.method || 'GET';
+		method = method.toUpperCase();
+
+		if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) {
+			throw new TypeError('Request with GET/HEAD method cannot have body');
+		}
+
+		let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
+
+		Body.call(this, inputBody, {
+			timeout: init.timeout || input.timeout || 0,
+			size: init.size || input.size || 0
+		});
+
+		const headers = new Headers(init.headers || input.headers || {});
+
+		if (inputBody != null && !headers.has('Content-Type')) {
+			const contentType = extractContentType(inputBody);
+			if (contentType) {
+				headers.append('Content-Type', contentType);
+			}
+		}
+
+		let signal = isRequest(input) ? input.signal : null;
+		if ('signal' in init) signal = init.signal;
+
+		if (signal != null && !isAbortSignal(signal)) {
+			throw new TypeError('Expected signal to be an instanceof AbortSignal');
+		}
+
+		this[INTERNALS$2] = {
+			method,
+			redirect: init.redirect || input.redirect || 'follow',
+			headers,
+			parsedURL,
+			signal
+		};
+
+		// node-fetch-only options
+		this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20;
+		this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true;
+		this.counter = init.counter || input.counter || 0;
+		this.agent = init.agent || input.agent;
+	}
+
+	get method() {
+		return this[INTERNALS$2].method;
+	}
+
+	get url() {
+		return format_url(this[INTERNALS$2].parsedURL);
+	}
+
+	get headers() {
+		return this[INTERNALS$2].headers;
+	}
+
+	get redirect() {
+		return this[INTERNALS$2].redirect;
+	}
+
+	get signal() {
+		return this[INTERNALS$2].signal;
+	}
+
+	/**
+  * Clone this request
+  *
+  * @return  Request
+  */
+	clone() {
+		return new Request(this);
+	}
+}
+
+Body.mixIn(Request.prototype);
+
+Object.defineProperty(Request.prototype, Symbol.toStringTag, {
+	value: 'Request',
+	writable: false,
+	enumerable: false,
+	configurable: true
+});
+
+Object.defineProperties(Request.prototype, {
+	method: { enumerable: true },
+	url: { enumerable: true },
+	headers: { enumerable: true },
+	redirect: { enumerable: true },
+	clone: { enumerable: true },
+	signal: { enumerable: true }
+});
+
+/**
+ * Convert a Request to Node.js http request options.
+ *
+ * @param   Request  A Request instance
+ * @return  Object   The options object to be passed to http.request
+ */
+function getNodeRequestOptions(request) {
+	const parsedURL = request[INTERNALS$2].parsedURL;
+	const headers = new Headers(request[INTERNALS$2].headers);
+
+	// fetch step 1.3
+	if (!headers.has('Accept')) {
+		headers.set('Accept', '*/*');
+	}
+
+	// Basic fetch
+	if (!parsedURL.protocol || !parsedURL.hostname) {
+		throw new TypeError('Only absolute URLs are supported');
+	}
+
+	if (!/^https?:$/.test(parsedURL.protocol)) {
+		throw new TypeError('Only HTTP(S) protocols are supported');
+	}
+
+	if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) {
+		throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8');
+	}
+
+	// HTTP-network-or-cache fetch steps 2.4-2.7
+	let contentLengthValue = null;
+	if (request.body == null && /^(POST|PUT)$/i.test(request.method)) {
+		contentLengthValue = '0';
+	}
+	if (request.body != null) {
+		const totalBytes = getTotalBytes(request);
+		if (typeof totalBytes === 'number') {
+			contentLengthValue = String(totalBytes);
+		}
+	}
+	if (contentLengthValue) {
+		headers.set('Content-Length', contentLengthValue);
+	}
+
+	// HTTP-network-or-cache fetch step 2.11
+	if (!headers.has('User-Agent')) {
+		headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)');
+	}
+
+	// HTTP-network-or-cache fetch step 2.15
+	if (request.compress && !headers.has('Accept-Encoding')) {
+		headers.set('Accept-Encoding', 'gzip,deflate');
+	}
+
+	let agent = request.agent;
+	if (typeof agent === 'function') {
+		agent = agent(parsedURL);
+	}
+
+	if (!headers.has('Connection') && !agent) {
+		headers.set('Connection', 'close');
+	}
+
+	// HTTP-network fetch step 4.2
+	// chunked encoding is handled by Node.js
+
+	return Object.assign({}, parsedURL, {
+		method: request.method,
+		headers: exportNodeCompatibleHeaders(headers),
+		agent
+	});
+}
+
+/**
+ * abort-error.js
+ *
+ * AbortError interface for cancelled requests
+ */
+
+/**
+ * Create AbortError instance
+ *
+ * @param   String      message      Error message for human
+ * @return  AbortError
+ */
+function AbortError(message) {
+  Error.call(this, message);
+
+  this.type = 'aborted';
+  this.message = message;
+
+  // hide custom error implementation details from end-users
+  Error.captureStackTrace(this, this.constructor);
+}
+
+AbortError.prototype = Object.create(Error.prototype);
+AbortError.prototype.constructor = AbortError;
+AbortError.prototype.name = 'AbortError';
+
+// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
+const PassThrough$1 = Stream.PassThrough;
+const resolve_url = Url.resolve;
+
+/**
+ * Fetch function
+ *
+ * @param   Mixed    url   Absolute url or Request instance
+ * @param   Object   opts  Fetch options
+ * @return  Promise
+ */
+function fetch(url, opts) {
+
+	// allow custom promise
+	if (!fetch.Promise) {
+		throw new Error('native promise missing, set fetch.Promise to your favorite alternative');
+	}
+
+	Body.Promise = fetch.Promise;
+
+	// wrap http.request into fetch
+	return new fetch.Promise(function (resolve, reject) {
+		// build request object
+		const request = new Request(url, opts);
+		const options = getNodeRequestOptions(request);
+
+		const send = (options.protocol === 'https:' ? https : http).request;
+		const signal = request.signal;
+
+		let response = null;
+
+		const abort = function abort() {
+			let error = new AbortError('The user aborted a request.');
+			reject(error);
+			if (request.body && request.body instanceof Stream.Readable) {
+				request.body.destroy(error);
+			}
+			if (!response || !response.body) return;
+			response.body.emit('error', error);
+		};
+
+		if (signal && signal.aborted) {
+			abort();
+			return;
+		}
+
+		const abortAndFinalize = function abortAndFinalize() {
+			abort();
+			finalize();
+		};
+
+		// send request
+		const req = send(options);
+		let reqTimeout;
+
+		if (signal) {
+			signal.addEventListener('abort', abortAndFinalize);
+		}
+
+		function finalize() {
+			req.abort();
+			if (signal) signal.removeEventListener('abort', abortAndFinalize);
+			clearTimeout(reqTimeout);
+		}
+
+		if (request.timeout) {
+			req.once('socket', function (socket) {
+				reqTimeout = setTimeout(function () {
+					reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout'));
+					finalize();
+				}, request.timeout);
+			});
+		}
+
+		req.on('error', function (err) {
+			reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
+			finalize();
+		});
+
+		req.on('response', function (res) {
+			clearTimeout(reqTimeout);
+
+			const headers = createHeadersLenient(res.headers);
+
+			// HTTP fetch step 5
+			if (fetch.isRedirect(res.statusCode)) {
+				// HTTP fetch step 5.2
+				const location = headers.get('Location');
+
+				// HTTP fetch step 5.3
+				const locationURL = location === null ? null : resolve_url(request.url, location);
+
+				// HTTP fetch step 5.5
+				switch (request.redirect) {
+					case 'error':
+						reject(new FetchError(`redirect mode is set to error: ${request.url}`, 'no-redirect'));
+						finalize();
+						return;
+					case 'manual':
+						// node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL.
+						if (locationURL !== null) {
+							// handle corrupted header
+							try {
+								headers.set('Location', locationURL);
+							} catch (err) {
+								// istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request
+								reject(err);
+							}
+						}
+						break;
+					case 'follow':
+						// HTTP-redirect fetch step 2
+						if (locationURL === null) {
+							break;
+						}
+
+						// HTTP-redirect fetch step 5
+						if (request.counter >= request.follow) {
+							reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect'));
+							finalize();
+							return;
+						}
+
+						// HTTP-redirect fetch step 6 (counter increment)
+						// Create a new Request object.
+						const requestOpts = {
+							headers: new Headers(request.headers),
+							follow: request.follow,
+							counter: request.counter + 1,
+							agent: request.agent,
+							compress: request.compress,
+							method: request.method,
+							body: request.body,
+							signal: request.signal,
+							timeout: request.timeout
+						};
+
+						// HTTP-redirect fetch step 9
+						if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
+							reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
+							finalize();
+							return;
+						}
+
+						// HTTP-redirect fetch step 11
+						if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') {
+							requestOpts.method = 'GET';
+							requestOpts.body = undefined;
+							requestOpts.headers.delete('content-length');
+						}
+
+						// HTTP-redirect fetch step 15
+						resolve(fetch(new Request(locationURL, requestOpts)));
+						finalize();
+						return;
+				}
+			}
+
+			// prepare response
+			res.once('end', function () {
+				if (signal) signal.removeEventListener('abort', abortAndFinalize);
+			});
+			let body = res.pipe(new PassThrough$1());
+
+			const response_options = {
+				url: request.url,
+				status: res.statusCode,
+				statusText: res.statusMessage,
+				headers: headers,
+				size: request.size,
+				timeout: request.timeout,
+				counter: request.counter
+			};
+
+			// HTTP-network fetch step 12.1.1.3
+			const codings = headers.get('Content-Encoding');
+
+			// HTTP-network fetch step 12.1.1.4: handle content codings
+
+			// in following scenarios we ignore compression support
+			// 1. compression support is disabled
+			// 2. HEAD request
+			// 3. no Content-Encoding header
+			// 4. no content response (204)
+			// 5. content not modified response (304)
+			if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) {
+				response = new Response(body, response_options);
+				resolve(response);
+				return;
+			}
+
+			// For Node v6+
+			// Be less strict when decoding compressed responses, since sometimes
+			// servers send slightly invalid responses that are still accepted
+			// by common browsers.
+			// Always using Z_SYNC_FLUSH is what cURL does.
+			const zlibOptions = {
+				flush: zlib.Z_SYNC_FLUSH,
+				finishFlush: zlib.Z_SYNC_FLUSH
+			};
+
+			// for gzip
+			if (codings == 'gzip' || codings == 'x-gzip') {
+				body = body.pipe(zlib.createGunzip(zlibOptions));
+				response = new Response(body, response_options);
+				resolve(response);
+				return;
+			}
+
+			// for deflate
+			if (codings == 'deflate' || codings == 'x-deflate') {
+				// handle the infamous raw deflate response from old servers
+				// a hack for old IIS and Apache servers
+				const raw = res.pipe(new PassThrough$1());
+				raw.once('data', function (chunk) {
+					// see http://stackoverflow.com/questions/37519828
+					if ((chunk[0] & 0x0F) === 0x08) {
+						body = body.pipe(zlib.createInflate());
+					} else {
+						body = body.pipe(zlib.createInflateRaw());
+					}
+					response = new Response(body, response_options);
+					resolve(response);
+				});
+				return;
+			}
+
+			// for br
+			if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') {
+				body = body.pipe(zlib.createBrotliDecompress());
+				response = new Response(body, response_options);
+				resolve(response);
+				return;
+			}
+
+			// otherwise, use response as-is
+			response = new Response(body, response_options);
+			resolve(response);
+		});
+
+		writeToStream(req, request);
+	});
+}
+/**
+ * Redirect code matching
+ *
+ * @param   Number   code  Status code
+ * @return  Boolean
+ */
+fetch.isRedirect = function (code) {
+	return code === 301 || code === 302 || code === 303 || code === 307 || code === 308;
+};
+
+// expose Promise
+fetch.Promise = global.Promise;
+
+export default fetch;
+export { Headers, Request, Response, FetchError };

+ 70 - 0
node_modules/node-fetch/package.json

@@ -0,0 +1,70 @@
+{
+  "name": "node-fetch",
+  "version": "2.6.0",
+  "description": "A light-weight module that brings window.fetch to node.js",
+  "main": "lib/index",
+  "browser": "./browser.js",
+  "module": "lib/index.mjs",
+  "files": [
+    "lib/index.js",
+    "lib/index.mjs",
+    "lib/index.es.js",
+    "browser.js"
+  ],
+  "engines": {
+    "node": "4.x || >=6.0.0"
+  },
+  "scripts": {
+    "build": "cross-env BABEL_ENV=rollup rollup -c",
+    "prepare": "npm run build",
+    "test": "cross-env BABEL_ENV=test mocha --require babel-register --throw-deprecation test/test.js",
+    "report": "cross-env BABEL_ENV=coverage nyc --reporter lcov --reporter text mocha -R spec test/test.js",
+    "coverage": "cross-env BABEL_ENV=coverage nyc --reporter json --reporter text mocha -R spec test/test.js && codecov -f coverage/coverage-final.json"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/bitinn/node-fetch.git"
+  },
+  "keywords": [
+    "fetch",
+    "http",
+    "promise"
+  ],
+  "author": "David Frank",
+  "license": "MIT",
+  "bugs": {
+    "url": "https://github.com/bitinn/node-fetch/issues"
+  },
+  "homepage": "https://github.com/bitinn/node-fetch",
+  "devDependencies": {
+    "@ungap/url-search-params": "^0.1.2",
+    "abort-controller": "^1.1.0",
+    "abortcontroller-polyfill": "^1.3.0",
+    "babel-core": "^6.26.3",
+    "babel-plugin-istanbul": "^4.1.6",
+    "babel-preset-env": "^1.6.1",
+    "babel-register": "^6.16.3",
+    "chai": "^3.5.0",
+    "chai-as-promised": "^7.1.1",
+    "chai-iterator": "^1.1.1",
+    "chai-string": "~1.3.0",
+    "codecov": "^3.3.0",
+    "cross-env": "^5.2.0",
+    "form-data": "^2.3.3",
+    "is-builtin-module": "^1.0.0",
+    "mocha": "^5.0.0",
+    "nyc": "11.9.0",
+    "parted": "^0.1.1",
+    "promise": "^8.0.3",
+    "resumer": "0.0.0",
+    "rollup": "^0.63.4",
+    "rollup-plugin-babel": "^3.0.7",
+    "string-to-arraybuffer": "^1.0.2",
+    "whatwg-url": "^5.0.0"
+  },
+  "dependencies": {}
+
+,"_resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz"
+,"_integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
+,"_from": "node-fetch@2.6.0"
+}

+ 147 - 0
node_modules/rfdc/index.js

@@ -0,0 +1,147 @@
+'use strict'
+module.exports = rfdc
+
+function rfdc (opts) {
+  opts = opts || {}
+
+  if (opts.circles) return rfdcCircles(opts)
+  return opts.proto ? cloneProto : clone
+
+  function cloneArray (a, fn) {
+    var keys = Object.keys(a)
+    var a2 = new Array(keys.length)
+    for (var i = 0; i < keys.length; i++) {
+      var k = keys[i]
+      var cur = a[k]
+      if (typeof cur !== 'object' || cur === null) {
+        a2[k] = cur
+      } else if (cur instanceof Date) {
+        a2[k] = new Date(cur)
+      } else {
+        a2[k] = fn(cur)
+      }
+    }
+    return a2
+  }
+
+  function clone (o) {
+    if (typeof o !== 'object' || o === null) return o
+    if (o instanceof Date) return new Date(o)
+    if (Array.isArray(o)) return cloneArray(o, clone)
+    var o2 = {}
+    for (var k in o) {
+      if (Object.hasOwnProperty.call(o, k) === false) continue
+      var cur = o[k]
+      if (typeof cur !== 'object' || cur === null) {
+        o2[k] = cur
+      } else if (cur instanceof Date) {
+        o2[k] = new Date(cur)
+      } else {
+        o2[k] = clone(cur)
+      }
+    }
+    return o2
+  }
+
+  function cloneProto (o) {
+    if (typeof o !== 'object' || o === null) return o
+    if (o instanceof Date) return new Date(o)
+    if (Array.isArray(o)) return cloneArray(o, cloneProto)
+    var o2 = {}
+    for (var k in o) {
+      var cur = o[k]
+      if (typeof cur !== 'object' || cur === null) {
+        o2[k] = cur
+      } else if (cur instanceof Date) {
+        o2[k] = new Date(cur)
+      } else {
+        o2[k] = cloneProto(cur)
+      }
+    }
+    return o2
+  }
+}
+
+function rfdcCircles (opts) {
+  var refs = []
+  var refsNew = []
+
+  return opts.proto ? cloneProto : clone
+
+  function cloneArray (a, fn) {
+    var keys = Object.keys(a)
+    var a2 = new Array(keys.length)
+    for (var i = 0; i < keys.length; i++) {
+      var k = keys[i]
+      var cur = a[k]
+      if (typeof cur !== 'object' || cur === null) {
+        a2[k] = cur
+      } else if (cur instanceof Date) {
+        a2[k] = new Date(cur)
+      } else {
+        var index = refs.indexOf(cur)
+        if (index !== -1) {
+          a2[k] = refsNew[index]
+        } else {
+          a2[k] = fn(cur)
+        }
+      }
+    }
+    return a2
+  }
+
+  function clone (o) {
+    if (typeof o !== 'object' || o === null) return o
+    if (o instanceof Date) return new Date(o)
+    if (Array.isArray(o)) return cloneArray(o, clone)
+    var o2 = {}
+    refs.push(o)
+    refsNew.push(o2)
+    for (var k in o) {
+      if (Object.hasOwnProperty.call(o, k) === false) continue
+      var cur = o[k]
+      if (typeof cur !== 'object' || cur === null) {
+        o2[k] = cur
+      } else if (cur instanceof Date) {
+        o2[k] = new Date(cur)
+      } else {
+        var i = refs.indexOf(cur)
+        if (i !== -1) {
+          o2[k] = refsNew[i]
+        } else {
+          o2[k] = clone(cur)
+        }
+      }
+    }
+    refs.pop()
+    refsNew.pop()
+    return o2
+  }
+
+  function cloneProto (o) {
+    if (typeof o !== 'object' || o === null) return o
+    if (o instanceof Date) return new Date(o)
+    if (Array.isArray(o)) return cloneArray(o, cloneProto)
+    var o2 = {}
+    refs.push(o)
+    refsNew.push(o2)
+    for (var k in o) {
+      var cur = o[k]
+      if (typeof cur !== 'object' || cur === null) {
+        o2[k] = cur
+      } else if (cur instanceof Date) {
+        o2[k] = new Date(cur)
+      } else {
+        var i = refs.indexOf(cur)
+        if (i !== -1) {
+          o2[k] = refsNew[i]
+        } else {
+          o2[k] = cloneProto(cur)
+        }
+      }
+    }
+    refs.pop()
+    refsNew.pop()
+    return o2
+  }
+}

+ 67 - 0
node_modules/rfdc/package.json

@@ -0,0 +1,67 @@
+{
+  "name": "rfdc",
+  "version": "1.1.4",
+  "description": "Really Fast Deep Clone",
+  "main": "index.js",
+  "scripts": {
+    "test": "tap -R min test && npm run lint",
+    "bench": "node benchmark",
+    "lint": "standard --fix",
+    "cov": "tap --100 test",
+    "cov-ui": "tap --coverage-report=html test",
+    "ci": "standard && tap --100 --coverage-report=text-lcov test | codecov --pipe"
+  },
+  "keywords": [
+    "object",
+    "obj",
+    "properties",
+    "clone",
+    "copy",
+    "deep",
+    "recursive",
+    "key",
+    "keys",
+    "values",
+    "prop",
+    "deep-clone",
+    "deepclone",
+    "deep-copy",
+    "deepcopy",
+    "fast",
+    "performance",
+    "performant",
+    "fastclone",
+    "fastcopy",
+    "fast-clone",
+    "fast-deep-clone",
+    "fast-copy",
+    "fast-deep-copy"
+  ],
+  "author": "David Mark Clements <david.clements@nearform.com>",
+  "license": "MIT",
+  "devDependencies": {
+    "codecov": "^3.4.0",
+    "deep-copy": "^1.4.2",
+    "fast-copy": "^1.2.1",
+    "fastbench": "^1.0.1",
+    "lodash.clonedeep": "^4.5.0",
+    "standard": "^11.0.1",
+    "tap": "^12.0.1"
+  },
+  "directories": {
+    "test": "test"
+  },
+  "dependencies": {},
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/davidmarkclements/rfdc.git"
+  },
+  "bugs": {
+    "url": "https://github.com/davidmarkclements/rfdc/issues"
+  },
+  "homepage": "https://github.com/davidmarkclements/rfdc#readme"
+
+,"_resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.4.tgz"
+,"_integrity": "sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug=="
+,"_from": "rfdc@1.1.4"
+}

+ 117 - 0
node_modules/schema-typed/es/ArrayType.js

@@ -0,0 +1,117 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+var _Type2 = _interopRequireDefault(require("./Type"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
+
+var ArrayType = /*#__PURE__*/function (_Type) {
+  _inheritsLoose(ArrayType, _Type);
+
+  ArrayType.from = function from(n) {
+    return n;
+  };
+
+  function ArrayType() {
+    var _this;
+
+    var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Please enter a valid array';
+    _this = _Type.call(this, 'array') || this;
+
+    _Type.prototype.pushRule.call(_assertThisInitialized(_this), function (v) {
+      return Array.isArray(v);
+    }, errorMessage);
+
+    return _this;
+  }
+
+  var _proto = ArrayType.prototype;
+
+  _proto.rangeLength = function rangeLength(minLength, maxLength, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return value.length >= minLength && value.length <= maxLength;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.minLength = function minLength(_minLength, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return value.length >= _minLength;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.maxLength = function maxLength(_maxLength, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return value.length <= _maxLength;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.unrepeatable = function unrepeatable(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (items) {
+      var hash = {};
+      /* eslint-disable */
+
+      for (var i in items) {
+        if (hash[items[i]]) {
+          return false;
+        }
+
+        hash[items[i]] = true;
+      }
+
+      return true;
+    }, errorMessage);
+
+    return this;
+  }
+  /**
+   * @example
+   * ArrayType('这是一个数组').of(
+   *      StringType().isOneOf(['数码','体育','游戏','旅途','其他'],
+   *      '只能是选择中的值'
+   * )
+   */
+  ;
+
+  _proto.of = function of(type, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (items) {
+      var valids = items.map(function (value) {
+        return type.check(value);
+      });
+      var errors = valids.filter(function (item) {
+        return item.hasError;
+      }) || [];
+
+      if (errors.length) {
+        return errors[0];
+      }
+
+      return errors.length === 0;
+    }, errorMessage);
+
+    return this;
+  };
+
+  return ArrayType;
+}(_Type2["default"]);
+
+var _default = function _default(errorMessage) {
+  return new ArrayType(errorMessage);
+};
+
+exports["default"] = _default;

+ 45 - 0
node_modules/schema-typed/es/BooleanType.js

@@ -0,0 +1,45 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+var _Type2 = _interopRequireDefault(require("./Type"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
+
+var BooleanType = /*#__PURE__*/function (_Type) {
+  _inheritsLoose(BooleanType, _Type);
+
+  BooleanType.from = function from(n) {
+    return n;
+  };
+
+  function BooleanType() {
+    var _this;
+
+    var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Please enter a valid `boolean`';
+    _this = _Type.call(this, 'boolean') || this;
+
+    _Type.prototype.pushRule.call(_assertThisInitialized(_this), function (v) {
+      return typeof v === 'boolean';
+    }, errorMessage);
+
+    return _this;
+  }
+
+  return BooleanType;
+}(_Type2["default"]);
+
+var _default = function _default(errorMessage) {
+  return new BooleanType(errorMessage);
+};
+
+exports["default"] = _default;

+ 71 - 0
node_modules/schema-typed/es/DateType.js

@@ -0,0 +1,71 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+var _Type2 = _interopRequireDefault(require("./Type"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
+
+var DateType = /*#__PURE__*/function (_Type) {
+  _inheritsLoose(DateType, _Type);
+
+  DateType.from = function from(n) {
+    return n;
+  };
+
+  function DateType() {
+    var _this;
+
+    var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Please enter a valid date';
+    _this = _Type.call(this, 'date') || this;
+
+    _Type.prototype.pushRule.call(_assertThisInitialized(_this), function (value) {
+      return !/Invalid|NaN/.test(new Date(value));
+    }, errorMessage);
+
+    return _this;
+  }
+
+  var _proto = DateType.prototype;
+
+  _proto.range = function range(min, max, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return new Date(value) >= new Date(min) && new Date(value) <= new Date(max);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.min = function min(_min, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return new Date(value) >= new Date(_min);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.max = function max(_max, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return new Date(value) <= new Date(_max);
+    }, errorMessage);
+
+    return this;
+  };
+
+  return DateType;
+}(_Type2["default"]);
+
+var _default = function _default(errorMessage) {
+  return new DateType(errorMessage);
+};
+
+exports["default"] = _default;

+ 99 - 0
node_modules/schema-typed/es/NumberType.js

@@ -0,0 +1,99 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+var _Type2 = _interopRequireDefault(require("./Type"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
+
+function FN(value) {
+  return +value;
+}
+
+var NumberType = /*#__PURE__*/function (_Type) {
+  _inheritsLoose(NumberType, _Type);
+
+  NumberType.from = function from(n) {
+    return n;
+  };
+
+  function NumberType() {
+    var _this;
+
+    var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Please enter a valid number';
+    _this = _Type.call(this, 'number') || this;
+
+    _Type.prototype.pushRule.call(_assertThisInitialized(_this), function (value) {
+      return /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);
+    }, errorMessage);
+
+    return _this;
+  }
+
+  var _proto = NumberType.prototype;
+
+  _proto.isInteger = function isInteger(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return /^-?\d+$/.test(value);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.pattern = function pattern(regexp, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return regexp.test(value);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.isOneOf = function isOneOf(numLst, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return numLst.includes(FN(value));
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.range = function range(min, max, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return FN(value) >= min && FN(value) <= max;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.min = function min(_min, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return FN(value) >= _min;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.max = function max(_max, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return FN(value) <= _max;
+    }, errorMessage);
+
+    return this;
+  };
+
+  return NumberType;
+}(_Type2["default"]);
+
+var _default = function _default(errorMessage) {
+  return new NumberType(errorMessage);
+};
+
+exports["default"] = _default;

+ 78 - 0
node_modules/schema-typed/es/ObjectType.js

@@ -0,0 +1,78 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+var _Type2 = _interopRequireDefault(require("./Type"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
+
+function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
+
+var ObjectType = /*#__PURE__*/function (_Type) {
+  _inheritsLoose(ObjectType, _Type);
+
+  ObjectType.from = function from(n) {
+    return n;
+  };
+
+  function ObjectType() {
+    var _this;
+
+    var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Please enter a valid `object`';
+    _this = _Type.call(this, 'object') || this;
+
+    _Type.prototype.pushRule.call(_assertThisInitialized(_this), function (v) {
+      return _typeof(v) === 'object';
+    }, errorMessage);
+
+    return _this;
+  }
+  /**
+   * @example
+   * ObjectType('这是一个对象').shape({
+   *  name: StringType(),
+   *  age: NumberType()
+   * })
+   */
+
+
+  var _proto = ObjectType.prototype;
+
+  _proto.shape = function shape(types) {
+    _Type.prototype.pushRule.call(this, function (values) {
+      var valids = Object.entries(types).map(function (item) {
+        var key = item[0];
+        var type = item[1];
+        return type.check(values[key]);
+      });
+      var errors = valids.filter(function (item) {
+        return item.hasError;
+      }) || [];
+
+      if (errors.length) {
+        return errors[0];
+      }
+
+      return errors.length === 0;
+    }, null);
+
+    return this;
+  };
+
+  return ObjectType;
+}(_Type2["default"]);
+
+var _default = function _default(errorMessage) {
+  return new ObjectType(errorMessage);
+};
+
+exports["default"] = _default;

+ 103 - 0
node_modules/schema-typed/es/Schema.js

@@ -0,0 +1,103 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.SchemaModel = exports.Schema = void 0;
+
+var _StringType = _interopRequireDefault(require("./StringType"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+var Schema = /*#__PURE__*/function () {
+  function Schema(schema) {
+    this.schema = schema;
+  }
+
+  var _proto = Schema.prototype;
+
+  _proto.getFieldType = function getFieldType(fieldName) {
+    return this.schema[fieldName] || new _StringType["default"]();
+  };
+
+  _proto.getKeys = function getKeys() {
+    return Object.keys(this.schema);
+  };
+
+  _proto.checkForField = function checkForField(fieldName, fieldValue, data) {
+    var fieldChecker = this.schema[fieldName];
+
+    if (!fieldChecker) {
+      // fieldValue can be anything if no schema defined
+      return {
+        hasError: false
+      };
+    }
+
+    return fieldChecker.check(fieldValue, data);
+  };
+
+  _proto.check = function check(data) {
+    var _this = this;
+
+    var checkResult = {};
+    Object.keys(this.schema).forEach(function (key) {
+      checkResult[key] = _this.checkForField(key, data[key], data);
+    });
+    return checkResult;
+  };
+
+  _proto.checkForFieldAsync = function checkForFieldAsync(fieldName, fieldValue, data) {
+    var fieldChecker = this.schema[fieldName];
+
+    if (!fieldChecker) {
+      // fieldValue can be anything if no schema defined
+      return Promise.resolve({
+        hasError: false
+      });
+    }
+
+    return fieldChecker.checkAsync(fieldValue, data);
+  };
+
+  _proto.checkAsync = function checkAsync(data) {
+    var _this2 = this;
+
+    var checkResult = {};
+    var promises = [];
+    var keys = [];
+    Object.keys(this.schema).forEach(function (key) {
+      keys.push(key);
+      promises.push(_this2.checkForFieldAsync(key, data[key], data));
+    });
+    return Promise.all(promises).then(function (values) {
+      for (var i = 0; i < values.length; i += 1) {
+        checkResult[keys[i]] = values[i];
+      }
+
+      return checkResult;
+    });
+  };
+
+  return Schema;
+}();
+
+exports.Schema = Schema;
+
+var SchemaModel = function SchemaModel(o) {
+  return new Schema(o);
+};
+
+exports.SchemaModel = SchemaModel;
+
+SchemaModel.combine = function () {
+  for (var _len = arguments.length, models = new Array(_len), _key = 0; _key < _len; _key++) {
+    models[_key] = arguments[_key];
+  }
+
+  return new Schema(models.map(function (model) {
+    return model.schema;
+  }).reduce(function (accumulator, currentValue) {
+    return Object.assign(accumulator, currentValue);
+  }, {}));
+};

+ 171 - 0
node_modules/schema-typed/es/StringType.js

@@ -0,0 +1,171 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+var _Type2 = _interopRequireDefault(require("./Type"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
+
+function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
+
+function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+
+function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
+
+function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
+
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
+
+/* eslint-disable */
+var StringType = /*#__PURE__*/function (_Type) {
+  _inheritsLoose(StringType, _Type);
+
+  StringType.from = function from(s) {
+    return "".concat(s);
+  };
+
+  function StringType() {
+    var _this;
+
+    var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Please enter a valid string';
+    _this = _Type.call(this, 'string') || this;
+
+    _Type.prototype.pushRule.call(_assertThisInitialized(_this), function (v) {
+      return typeof v === 'string';
+    }, errorMessage);
+
+    return _this;
+  }
+
+  var _proto = StringType.prototype;
+
+  _proto.containsLetter = function containsLetter(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (v) {
+      return /[a-zA-Z]/.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.containsUppercaseLetter = function containsUppercaseLetter(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (v) {
+      return /[A-Z]/.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.containsLowercaseLetter = function containsLowercaseLetter(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (v) {
+      return /[a-z]/.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.containsLetterOnly = function containsLetterOnly(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (v) {
+      return /^[a-zA-Z]+$/.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.containsNumber = function containsNumber(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (v) {
+      return /[0-9]/.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.isOneOf = function isOneOf(strArr, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (v) {
+      return !!~strArr.indexOf(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.isEmail = function isEmail(errorMessage) {
+    //http://emailregex.com/
+    var regexp = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+
+    _Type.prototype.pushRule.call(this, function (v) {
+      return regexp.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.isURL = function isURL(errorMessage) {
+    var regexp = new RegExp("^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$", 'i');
+
+    _Type.prototype.pushRule.call(this, function (v) {
+      return regexp.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.isHex = function isHex(errorMessage) {
+    var regexp = /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i;
+
+    _Type.prototype.pushRule.call(this, function (v) {
+      return regexp.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.pattern = function pattern(regexp, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return regexp.test(value);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.rangeLength = function rangeLength(minLength, maxLength, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return value.length >= minLength && value.length <= maxLength;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.minLength = function minLength(_minLength, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return _toConsumableArray(value).length >= _minLength;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.maxLength = function maxLength(_maxLength, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return _toConsumableArray(value).length <= _maxLength;
+    }, errorMessage);
+
+    return this;
+  };
+
+  return StringType;
+}(_Type2["default"]);
+
+var _default = function _default(errorMessage) {
+  return new StringType(errorMessage);
+};
+
+exports["default"] = _default;

+ 205 - 0
node_modules/schema-typed/es/Type.js

@@ -0,0 +1,205 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+function isEmpty(value) {
+  return typeof value === 'undefined' || value === null || value === '';
+}
+
+function basicEmptyCheck(value) {
+  return typeof value === 'undefined' || value === null;
+}
+
+function checkRequired(value, trim, emptyAllowed) {
+  // String trim
+  if (trim && typeof value === 'string') {
+    value = value.replace(/(^\s*)|(\s*$)/g, '');
+  }
+
+  if (emptyAllowed) {
+    return !basicEmptyCheck(value);
+  } // Array
+
+
+  if (Array.isArray(value)) {
+    return !!value.length;
+  }
+
+  return !isEmpty(value);
+}
+
+function createValidator(data) {
+  return function (value, rules) {
+    for (var i = 0; i < rules.length; i += 1) {
+      var _rules$i = rules[i],
+          onValid = _rules$i.onValid,
+          errorMessage = _rules$i.errorMessage;
+      var checkResult = onValid(value, data);
+
+      if (checkResult === false) {
+        return {
+          hasError: true,
+          errorMessage: errorMessage
+        };
+      } else if (_typeof(checkResult) === 'object' && checkResult.hasError) {
+        return checkResult;
+      }
+    }
+
+    return null;
+  };
+}
+
+function createValidatorAsync(data) {
+  function check(errorMessage) {
+    return function (checkResult) {
+      if (checkResult === false) {
+        return {
+          hasError: true,
+          errorMessage: errorMessage
+        };
+      } else if (_typeof(checkResult) === 'object' && checkResult.hasError) {
+        return checkResult;
+      }
+
+      return null;
+    };
+  }
+
+  return function (value, rules) {
+    var promises = rules.map(function (rule) {
+      var onValid = rule.onValid,
+          errorMessage = rule.errorMessage;
+      return Promise.resolve(onValid(value, data)).then(check(errorMessage));
+    });
+    return Promise.all(promises).then(function (results) {
+      return results.find(function (item) {
+        return item && item.hasError;
+      });
+    });
+  };
+}
+
+var Type = /*#__PURE__*/function () {
+  function Type(name) {
+    this.name = name;
+    this.required = false;
+    this.requiredMessage = '';
+    this.trim = false;
+    this.emptyAllowed = false;
+    this.rules = [];
+    this.priorityRules = []; // Priority check rule
+  }
+
+  var _proto = Type.prototype;
+
+  _proto.check = function check(value, data) {
+    if (this.required && !checkRequired(value, this.trim, this.emptyAllowed)) {
+      return {
+        hasError: true,
+        errorMessage: this.requiredMessage
+      };
+    }
+
+    var validator = createValidator(data);
+    var checkStatus = validator(value, this.priorityRules);
+
+    if (checkStatus) {
+      return checkStatus;
+    }
+
+    if (!this.required && isEmpty(value)) {
+      return {
+        hasError: false
+      };
+    }
+
+    return validator(value, this.rules) || {
+      hasError: false
+    };
+  };
+
+  _proto.checkAsync = function checkAsync(value, data) {
+    var _this = this;
+
+    if (this.required && !checkRequired(value, this.trim, this.emptyAllowed)) {
+      return Promise.resolve({
+        hasError: true,
+        errorMessage: this.requiredMessage
+      });
+    }
+
+    var validator = createValidatorAsync(data);
+    return new Promise(function (resolve) {
+      return validator(value, _this.priorityRules).then(function (checkStatus) {
+        if (checkStatus) {
+          resolve(checkStatus);
+        }
+      }).then(function () {
+        if (!_this.required && isEmpty(value)) {
+          resolve({
+            hasError: false
+          });
+        }
+      }).then(function () {
+        return validator(value, _this.rules);
+      }).then(function (checkStatus) {
+        if (checkStatus) {
+          resolve(checkStatus);
+        }
+
+        resolve({
+          hasError: false
+        });
+      });
+    });
+  };
+
+  _proto.pushRule = function pushRule(onValid, errorMessage, priority) {
+    errorMessage = errorMessage || this.rules[0].errorMessage;
+
+    if (priority) {
+      this.priorityRules.push({
+        onValid: onValid,
+        errorMessage: errorMessage
+      });
+    } else {
+      this.rules.push({
+        onValid: onValid,
+        errorMessage: errorMessage
+      });
+    }
+  };
+
+  _proto.addRule = function addRule(onValid, errorMessage, priority) {
+    this.pushRule(onValid, errorMessage, priority);
+    return this;
+  };
+
+  _proto.isRequired = function isRequired(errorMessage) {
+    var trim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
+    this.required = true;
+    this.trim = trim;
+    this.requiredMessage = errorMessage;
+    return this;
+  };
+
+  _proto.isRequiredOrEmpty = function isRequiredOrEmpty(errorMessage) {
+    var trim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
+    this.required = true;
+    this.trim = trim;
+    this.emptyAllowed = true;
+    this.requiredMessage = errorMessage;
+    return this;
+  };
+
+  return Type;
+}();
+
+var _default = Type;
+exports["default"] = _default;

+ 76 - 0
node_modules/schema-typed/es/index.js

@@ -0,0 +1,76 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+var _exportNames = {
+  StringType: true,
+  NumberType: true,
+  ArrayType: true,
+  DateType: true,
+  ObjectType: true,
+  BooleanType: true
+};
+Object.defineProperty(exports, "StringType", {
+  enumerable: true,
+  get: function get() {
+    return _StringType["default"];
+  }
+});
+Object.defineProperty(exports, "NumberType", {
+  enumerable: true,
+  get: function get() {
+    return _NumberType["default"];
+  }
+});
+Object.defineProperty(exports, "ArrayType", {
+  enumerable: true,
+  get: function get() {
+    return _ArrayType["default"];
+  }
+});
+Object.defineProperty(exports, "DateType", {
+  enumerable: true,
+  get: function get() {
+    return _DateType["default"];
+  }
+});
+Object.defineProperty(exports, "ObjectType", {
+  enumerable: true,
+  get: function get() {
+    return _ObjectType["default"];
+  }
+});
+Object.defineProperty(exports, "BooleanType", {
+  enumerable: true,
+  get: function get() {
+    return _BooleanType["default"];
+  }
+});
+
+var _Schema = require("./Schema");
+
+Object.keys(_Schema).forEach(function (key) {
+  if (key === "default" || key === "__esModule") return;
+  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
+  Object.defineProperty(exports, key, {
+    enumerable: true,
+    get: function get() {
+      return _Schema[key];
+    }
+  });
+});
+
+var _StringType = _interopRequireDefault(require("./StringType"));
+
+var _NumberType = _interopRequireDefault(require("./NumberType"));
+
+var _ArrayType = _interopRequireDefault(require("./ArrayType"));
+
+var _DateType = _interopRequireDefault(require("./DateType"));
+
+var _ObjectType = _interopRequireDefault(require("./ObjectType"));
+
+var _BooleanType = _interopRequireDefault(require("./BooleanType"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

+ 117 - 0
node_modules/schema-typed/lib/ArrayType.js

@@ -0,0 +1,117 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+var _Type2 = _interopRequireDefault(require("./Type"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
+
+var ArrayType = /*#__PURE__*/function (_Type) {
+  _inheritsLoose(ArrayType, _Type);
+
+  ArrayType.from = function from(n) {
+    return n;
+  };
+
+  function ArrayType() {
+    var _this;
+
+    var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Please enter a valid array';
+    _this = _Type.call(this, 'array') || this;
+
+    _Type.prototype.pushRule.call(_assertThisInitialized(_this), function (v) {
+      return Array.isArray(v);
+    }, errorMessage);
+
+    return _this;
+  }
+
+  var _proto = ArrayType.prototype;
+
+  _proto.rangeLength = function rangeLength(minLength, maxLength, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return value.length >= minLength && value.length <= maxLength;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.minLength = function minLength(_minLength, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return value.length >= _minLength;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.maxLength = function maxLength(_maxLength, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return value.length <= _maxLength;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.unrepeatable = function unrepeatable(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (items) {
+      var hash = {};
+      /* eslint-disable */
+
+      for (var i in items) {
+        if (hash[items[i]]) {
+          return false;
+        }
+
+        hash[items[i]] = true;
+      }
+
+      return true;
+    }, errorMessage);
+
+    return this;
+  }
+  /**
+   * @example
+   * ArrayType('这是一个数组').of(
+   *      StringType().isOneOf(['数码','体育','游戏','旅途','其他'],
+   *      '只能是选择中的值'
+   * )
+   */
+  ;
+
+  _proto.of = function of(type, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (items) {
+      var valids = items.map(function (value) {
+        return type.check(value);
+      });
+      var errors = valids.filter(function (item) {
+        return item.hasError;
+      }) || [];
+
+      if (errors.length) {
+        return errors[0];
+      }
+
+      return errors.length === 0;
+    }, errorMessage);
+
+    return this;
+  };
+
+  return ArrayType;
+}(_Type2["default"]);
+
+var _default = function _default(errorMessage) {
+  return new ArrayType(errorMessage);
+};
+
+exports["default"] = _default;

+ 45 - 0
node_modules/schema-typed/lib/BooleanType.js

@@ -0,0 +1,45 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+var _Type2 = _interopRequireDefault(require("./Type"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
+
+var BooleanType = /*#__PURE__*/function (_Type) {
+  _inheritsLoose(BooleanType, _Type);
+
+  BooleanType.from = function from(n) {
+    return n;
+  };
+
+  function BooleanType() {
+    var _this;
+
+    var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Please enter a valid `boolean`';
+    _this = _Type.call(this, 'boolean') || this;
+
+    _Type.prototype.pushRule.call(_assertThisInitialized(_this), function (v) {
+      return typeof v === 'boolean';
+    }, errorMessage);
+
+    return _this;
+  }
+
+  return BooleanType;
+}(_Type2["default"]);
+
+var _default = function _default(errorMessage) {
+  return new BooleanType(errorMessage);
+};
+
+exports["default"] = _default;

+ 71 - 0
node_modules/schema-typed/lib/DateType.js

@@ -0,0 +1,71 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+var _Type2 = _interopRequireDefault(require("./Type"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
+
+var DateType = /*#__PURE__*/function (_Type) {
+  _inheritsLoose(DateType, _Type);
+
+  DateType.from = function from(n) {
+    return n;
+  };
+
+  function DateType() {
+    var _this;
+
+    var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Please enter a valid date';
+    _this = _Type.call(this, 'date') || this;
+
+    _Type.prototype.pushRule.call(_assertThisInitialized(_this), function (value) {
+      return !/Invalid|NaN/.test(new Date(value));
+    }, errorMessage);
+
+    return _this;
+  }
+
+  var _proto = DateType.prototype;
+
+  _proto.range = function range(min, max, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return new Date(value) >= new Date(min) && new Date(value) <= new Date(max);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.min = function min(_min, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return new Date(value) >= new Date(_min);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.max = function max(_max, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return new Date(value) <= new Date(_max);
+    }, errorMessage);
+
+    return this;
+  };
+
+  return DateType;
+}(_Type2["default"]);
+
+var _default = function _default(errorMessage) {
+  return new DateType(errorMessage);
+};
+
+exports["default"] = _default;

+ 99 - 0
node_modules/schema-typed/lib/NumberType.js

@@ -0,0 +1,99 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+var _Type2 = _interopRequireDefault(require("./Type"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
+
+function FN(value) {
+  return +value;
+}
+
+var NumberType = /*#__PURE__*/function (_Type) {
+  _inheritsLoose(NumberType, _Type);
+
+  NumberType.from = function from(n) {
+    return n;
+  };
+
+  function NumberType() {
+    var _this;
+
+    var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Please enter a valid number';
+    _this = _Type.call(this, 'number') || this;
+
+    _Type.prototype.pushRule.call(_assertThisInitialized(_this), function (value) {
+      return /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);
+    }, errorMessage);
+
+    return _this;
+  }
+
+  var _proto = NumberType.prototype;
+
+  _proto.isInteger = function isInteger(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return /^-?\d+$/.test(value);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.pattern = function pattern(regexp, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return regexp.test(value);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.isOneOf = function isOneOf(numLst, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return numLst.includes(FN(value));
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.range = function range(min, max, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return FN(value) >= min && FN(value) <= max;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.min = function min(_min, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return FN(value) >= _min;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.max = function max(_max, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return FN(value) <= _max;
+    }, errorMessage);
+
+    return this;
+  };
+
+  return NumberType;
+}(_Type2["default"]);
+
+var _default = function _default(errorMessage) {
+  return new NumberType(errorMessage);
+};
+
+exports["default"] = _default;

+ 78 - 0
node_modules/schema-typed/lib/ObjectType.js

@@ -0,0 +1,78 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+var _Type2 = _interopRequireDefault(require("./Type"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
+
+function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
+
+var ObjectType = /*#__PURE__*/function (_Type) {
+  _inheritsLoose(ObjectType, _Type);
+
+  ObjectType.from = function from(n) {
+    return n;
+  };
+
+  function ObjectType() {
+    var _this;
+
+    var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Please enter a valid `object`';
+    _this = _Type.call(this, 'object') || this;
+
+    _Type.prototype.pushRule.call(_assertThisInitialized(_this), function (v) {
+      return _typeof(v) === 'object';
+    }, errorMessage);
+
+    return _this;
+  }
+  /**
+   * @example
+   * ObjectType('这是一个对象').shape({
+   *  name: StringType(),
+   *  age: NumberType()
+   * })
+   */
+
+
+  var _proto = ObjectType.prototype;
+
+  _proto.shape = function shape(types) {
+    _Type.prototype.pushRule.call(this, function (values) {
+      var valids = Object.entries(types).map(function (item) {
+        var key = item[0];
+        var type = item[1];
+        return type.check(values[key]);
+      });
+      var errors = valids.filter(function (item) {
+        return item.hasError;
+      }) || [];
+
+      if (errors.length) {
+        return errors[0];
+      }
+
+      return errors.length === 0;
+    }, null);
+
+    return this;
+  };
+
+  return ObjectType;
+}(_Type2["default"]);
+
+var _default = function _default(errorMessage) {
+  return new ObjectType(errorMessage);
+};
+
+exports["default"] = _default;

+ 103 - 0
node_modules/schema-typed/lib/Schema.js

@@ -0,0 +1,103 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.SchemaModel = exports.Schema = void 0;
+
+var _StringType = _interopRequireDefault(require("./StringType"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+var Schema = /*#__PURE__*/function () {
+  function Schema(schema) {
+    this.schema = schema;
+  }
+
+  var _proto = Schema.prototype;
+
+  _proto.getFieldType = function getFieldType(fieldName) {
+    return this.schema[fieldName] || new _StringType["default"]();
+  };
+
+  _proto.getKeys = function getKeys() {
+    return Object.keys(this.schema);
+  };
+
+  _proto.checkForField = function checkForField(fieldName, fieldValue, data) {
+    var fieldChecker = this.schema[fieldName];
+
+    if (!fieldChecker) {
+      // fieldValue can be anything if no schema defined
+      return {
+        hasError: false
+      };
+    }
+
+    return fieldChecker.check(fieldValue, data);
+  };
+
+  _proto.check = function check(data) {
+    var _this = this;
+
+    var checkResult = {};
+    Object.keys(this.schema).forEach(function (key) {
+      checkResult[key] = _this.checkForField(key, data[key], data);
+    });
+    return checkResult;
+  };
+
+  _proto.checkForFieldAsync = function checkForFieldAsync(fieldName, fieldValue, data) {
+    var fieldChecker = this.schema[fieldName];
+
+    if (!fieldChecker) {
+      // fieldValue can be anything if no schema defined
+      return Promise.resolve({
+        hasError: false
+      });
+    }
+
+    return fieldChecker.checkAsync(fieldValue, data);
+  };
+
+  _proto.checkAsync = function checkAsync(data) {
+    var _this2 = this;
+
+    var checkResult = {};
+    var promises = [];
+    var keys = [];
+    Object.keys(this.schema).forEach(function (key) {
+      keys.push(key);
+      promises.push(_this2.checkForFieldAsync(key, data[key], data));
+    });
+    return Promise.all(promises).then(function (values) {
+      for (var i = 0; i < values.length; i += 1) {
+        checkResult[keys[i]] = values[i];
+      }
+
+      return checkResult;
+    });
+  };
+
+  return Schema;
+}();
+
+exports.Schema = Schema;
+
+var SchemaModel = function SchemaModel(o) {
+  return new Schema(o);
+};
+
+exports.SchemaModel = SchemaModel;
+
+SchemaModel.combine = function () {
+  for (var _len = arguments.length, models = new Array(_len), _key = 0; _key < _len; _key++) {
+    models[_key] = arguments[_key];
+  }
+
+  return new Schema(models.map(function (model) {
+    return model.schema;
+  }).reduce(function (accumulator, currentValue) {
+    return Object.assign(accumulator, currentValue);
+  }, {}));
+};

+ 171 - 0
node_modules/schema-typed/lib/StringType.js

@@ -0,0 +1,171 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+var _Type2 = _interopRequireDefault(require("./Type"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
+
+function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
+
+function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+
+function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
+
+function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
+
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
+
+function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
+
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
+
+/* eslint-disable */
+var StringType = /*#__PURE__*/function (_Type) {
+  _inheritsLoose(StringType, _Type);
+
+  StringType.from = function from(s) {
+    return "".concat(s);
+  };
+
+  function StringType() {
+    var _this;
+
+    var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Please enter a valid string';
+    _this = _Type.call(this, 'string') || this;
+
+    _Type.prototype.pushRule.call(_assertThisInitialized(_this), function (v) {
+      return typeof v === 'string';
+    }, errorMessage);
+
+    return _this;
+  }
+
+  var _proto = StringType.prototype;
+
+  _proto.containsLetter = function containsLetter(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (v) {
+      return /[a-zA-Z]/.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.containsUppercaseLetter = function containsUppercaseLetter(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (v) {
+      return /[A-Z]/.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.containsLowercaseLetter = function containsLowercaseLetter(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (v) {
+      return /[a-z]/.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.containsLetterOnly = function containsLetterOnly(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (v) {
+      return /^[a-zA-Z]+$/.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.containsNumber = function containsNumber(errorMessage) {
+    _Type.prototype.pushRule.call(this, function (v) {
+      return /[0-9]/.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.isOneOf = function isOneOf(strArr, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (v) {
+      return !!~strArr.indexOf(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.isEmail = function isEmail(errorMessage) {
+    //http://emailregex.com/
+    var regexp = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+
+    _Type.prototype.pushRule.call(this, function (v) {
+      return regexp.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.isURL = function isURL(errorMessage) {
+    var regexp = new RegExp("^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$", 'i');
+
+    _Type.prototype.pushRule.call(this, function (v) {
+      return regexp.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.isHex = function isHex(errorMessage) {
+    var regexp = /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i;
+
+    _Type.prototype.pushRule.call(this, function (v) {
+      return regexp.test(v);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.pattern = function pattern(regexp, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return regexp.test(value);
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.rangeLength = function rangeLength(minLength, maxLength, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return value.length >= minLength && value.length <= maxLength;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.minLength = function minLength(_minLength, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return _toConsumableArray(value).length >= _minLength;
+    }, errorMessage);
+
+    return this;
+  };
+
+  _proto.maxLength = function maxLength(_maxLength, errorMessage) {
+    _Type.prototype.pushRule.call(this, function (value) {
+      return _toConsumableArray(value).length <= _maxLength;
+    }, errorMessage);
+
+    return this;
+  };
+
+  return StringType;
+}(_Type2["default"]);
+
+var _default = function _default(errorMessage) {
+  return new StringType(errorMessage);
+};
+
+exports["default"] = _default;

+ 205 - 0
node_modules/schema-typed/lib/Type.js

@@ -0,0 +1,205 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports["default"] = void 0;
+
+function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+function isEmpty(value) {
+  return typeof value === 'undefined' || value === null || value === '';
+}
+
+function basicEmptyCheck(value) {
+  return typeof value === 'undefined' || value === null;
+}
+
+function checkRequired(value, trim, emptyAllowed) {
+  // String trim
+  if (trim && typeof value === 'string') {
+    value = value.replace(/(^\s*)|(\s*$)/g, '');
+  }
+
+  if (emptyAllowed) {
+    return !basicEmptyCheck(value);
+  } // Array
+
+
+  if (Array.isArray(value)) {
+    return !!value.length;
+  }
+
+  return !isEmpty(value);
+}
+
+function createValidator(data) {
+  return function (value, rules) {
+    for (var i = 0; i < rules.length; i += 1) {
+      var _rules$i = rules[i],
+          onValid = _rules$i.onValid,
+          errorMessage = _rules$i.errorMessage;
+      var checkResult = onValid(value, data);
+
+      if (checkResult === false) {
+        return {
+          hasError: true,
+          errorMessage: errorMessage
+        };
+      } else if (_typeof(checkResult) === 'object' && checkResult.hasError) {
+        return checkResult;
+      }
+    }
+
+    return null;
+  };
+}
+
+function createValidatorAsync(data) {
+  function check(errorMessage) {
+    return function (checkResult) {
+      if (checkResult === false) {
+        return {
+          hasError: true,
+          errorMessage: errorMessage
+        };
+      } else if (_typeof(checkResult) === 'object' && checkResult.hasError) {
+        return checkResult;
+      }
+
+      return null;
+    };
+  }
+
+  return function (value, rules) {
+    var promises = rules.map(function (rule) {
+      var onValid = rule.onValid,
+          errorMessage = rule.errorMessage;
+      return Promise.resolve(onValid(value, data)).then(check(errorMessage));
+    });
+    return Promise.all(promises).then(function (results) {
+      return results.find(function (item) {
+        return item && item.hasError;
+      });
+    });
+  };
+}
+
+var Type = /*#__PURE__*/function () {
+  function Type(name) {
+    this.name = name;
+    this.required = false;
+    this.requiredMessage = '';
+    this.trim = false;
+    this.emptyAllowed = false;
+    this.rules = [];
+    this.priorityRules = []; // Priority check rule
+  }
+
+  var _proto = Type.prototype;
+
+  _proto.check = function check(value, data) {
+    if (this.required && !checkRequired(value, this.trim, this.emptyAllowed)) {
+      return {
+        hasError: true,
+        errorMessage: this.requiredMessage
+      };
+    }
+
+    var validator = createValidator(data);
+    var checkStatus = validator(value, this.priorityRules);
+
+    if (checkStatus) {
+      return checkStatus;
+    }
+
+    if (!this.required && isEmpty(value)) {
+      return {
+        hasError: false
+      };
+    }
+
+    return validator(value, this.rules) || {
+      hasError: false
+    };
+  };
+
+  _proto.checkAsync = function checkAsync(value, data) {
+    var _this = this;
+
+    if (this.required && !checkRequired(value, this.trim, this.emptyAllowed)) {
+      return Promise.resolve({
+        hasError: true,
+        errorMessage: this.requiredMessage
+      });
+    }
+
+    var validator = createValidatorAsync(data);
+    return new Promise(function (resolve) {
+      return validator(value, _this.priorityRules).then(function (checkStatus) {
+        if (checkStatus) {
+          resolve(checkStatus);
+        }
+      }).then(function () {
+        if (!_this.required && isEmpty(value)) {
+          resolve({
+            hasError: false
+          });
+        }
+      }).then(function () {
+        return validator(value, _this.rules);
+      }).then(function (checkStatus) {
+        if (checkStatus) {
+          resolve(checkStatus);
+        }
+
+        resolve({
+          hasError: false
+        });
+      });
+    });
+  };
+
+  _proto.pushRule = function pushRule(onValid, errorMessage, priority) {
+    errorMessage = errorMessage || this.rules[0].errorMessage;
+
+    if (priority) {
+      this.priorityRules.push({
+        onValid: onValid,
+        errorMessage: errorMessage
+      });
+    } else {
+      this.rules.push({
+        onValid: onValid,
+        errorMessage: errorMessage
+      });
+    }
+  };
+
+  _proto.addRule = function addRule(onValid, errorMessage, priority) {
+    this.pushRule(onValid, errorMessage, priority);
+    return this;
+  };
+
+  _proto.isRequired = function isRequired(errorMessage) {
+    var trim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
+    this.required = true;
+    this.trim = trim;
+    this.requiredMessage = errorMessage;
+    return this;
+  };
+
+  _proto.isRequiredOrEmpty = function isRequiredOrEmpty(errorMessage) {
+    var trim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
+    this.required = true;
+    this.trim = trim;
+    this.emptyAllowed = true;
+    this.requiredMessage = errorMessage;
+    return this;
+  };
+
+  return Type;
+}();
+
+var _default = Type;
+exports["default"] = _default;

+ 76 - 0
node_modules/schema-typed/lib/index.js

@@ -0,0 +1,76 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+var _exportNames = {
+  StringType: true,
+  NumberType: true,
+  ArrayType: true,
+  DateType: true,
+  ObjectType: true,
+  BooleanType: true
+};
+Object.defineProperty(exports, "StringType", {
+  enumerable: true,
+  get: function get() {
+    return _StringType["default"];
+  }
+});
+Object.defineProperty(exports, "NumberType", {
+  enumerable: true,
+  get: function get() {
+    return _NumberType["default"];
+  }
+});
+Object.defineProperty(exports, "ArrayType", {
+  enumerable: true,
+  get: function get() {
+    return _ArrayType["default"];
+  }
+});
+Object.defineProperty(exports, "DateType", {
+  enumerable: true,
+  get: function get() {
+    return _DateType["default"];
+  }
+});
+Object.defineProperty(exports, "ObjectType", {
+  enumerable: true,
+  get: function get() {
+    return _ObjectType["default"];
+  }
+});
+Object.defineProperty(exports, "BooleanType", {
+  enumerable: true,
+  get: function get() {
+    return _BooleanType["default"];
+  }
+});
+
+var _Schema = require("./Schema");
+
+Object.keys(_Schema).forEach(function (key) {
+  if (key === "default" || key === "__esModule") return;
+  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
+  Object.defineProperty(exports, key, {
+    enumerable: true,
+    get: function get() {
+      return _Schema[key];
+    }
+  });
+});
+
+var _StringType = _interopRequireDefault(require("./StringType"));
+
+var _NumberType = _interopRequireDefault(require("./NumberType"));
+
+var _ArrayType = _interopRequireDefault(require("./ArrayType"));
+
+var _DateType = _interopRequireDefault(require("./DateType"));
+
+var _ObjectType = _interopRequireDefault(require("./ObjectType"));
+
+var _BooleanType = _interopRequireDefault(require("./BooleanType"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

+ 113 - 0
node_modules/schema-typed/package.json

@@ -0,0 +1,113 @@
+{
+  "_from": "schema-typed@1.5.1",
+  "_id": "schema-typed@1.5.1",
+  "_inBundle": false,
+  "_integrity": "sha512-sx34fDSv08ubC9fTPKr3ba8YYs6nwqqRAITj6BXaxEaudJdjqtH7ZCe5wZQnQhbAGjKF4LcEwH15Oxf00pcSeg==",
+  "_location": "/schema-typed",
+  "_phantomChildren": {},
+  "_requested": {
+    "type": "version",
+    "registry": true,
+    "raw": "schema-typed@1.5.1",
+    "name": "schema-typed",
+    "escapedName": "schema-typed",
+    "rawSpec": "1.5.1",
+    "saveSpec": null,
+    "fetchSpec": "1.5.1"
+  },
+  "_requiredBy": [
+    "#USER",
+    "/"
+  ],
+  "_resolved": "https://registry.npmjs.org/schema-typed/-/schema-typed-1.5.1.tgz",
+  "_shasum": "37480e034800e15f82c8489e408f2bd0a9df657f",
+  "_spec": "schema-typed@1.5.1",
+  "_where": "D:\\!Git\\NextGenSP",
+  "bugs": {
+    "url": "https://github.com/rsuite/schema-typed/issues"
+  },
+  "bundleDependencies": false,
+  "contributors": [
+    {
+      "name": "A2ZH"
+    },
+    {
+      "name": "Simon Guo",
+      "email": "simonguo.2009@gmail.com"
+    }
+  ],
+  "deprecated": false,
+  "description": "Schema for data modeling & validation",
+  "devDependencies": {
+    "@babel/cli": "^7.0.0",
+    "@babel/core": "^7.0.0",
+    "@babel/plugin-proposal-class-properties": "^7.0.0",
+    "@babel/plugin-proposal-decorators": "^7.0.0",
+    "@babel/plugin-proposal-do-expressions": "^7.0.0",
+    "@babel/plugin-proposal-export-default-from": "^7.0.0",
+    "@babel/plugin-proposal-export-namespace-from": "^7.0.0",
+    "@babel/plugin-proposal-function-bind": "^7.0.0",
+    "@babel/plugin-proposal-function-sent": "^7.0.0",
+    "@babel/plugin-proposal-json-strings": "^7.0.0",
+    "@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
+    "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
+    "@babel/plugin-proposal-numeric-separator": "^7.0.0",
+    "@babel/plugin-proposal-optional-chaining": "^7.0.0",
+    "@babel/plugin-proposal-pipeline-operator": "^7.0.0",
+    "@babel/plugin-proposal-throw-expressions": "^7.0.0",
+    "@babel/plugin-syntax-dynamic-import": "^7.0.0",
+    "@babel/plugin-syntax-import-meta": "^7.0.0",
+    "@babel/plugin-transform-classes": "^7.0.0",
+    "@babel/plugin-transform-proto-to-assign": "^7.0.0",
+    "@babel/preset-env": "^7.0.0",
+    "@babel/register": "^7.0.0",
+    "babel-eslint": "^9.0.0",
+    "chai": "^3.5.0",
+    "coveralls": "^2.13.1",
+    "cross-env": "^6.0.3",
+    "dtslint": "^0.9.9",
+    "eslint": "^4.19.1",
+    "eslint-config-airbnb": "^15.0.1",
+    "eslint-plugin-babel": "^3.2.0",
+    "eslint-plugin-flowtype": "^2.46.1",
+    "eslint-plugin-import": "^2.7.0",
+    "eslint-plugin-json": "^1.2.0",
+    "eslint-plugin-jsx-a11y": "^6.0.2",
+    "eslint-plugin-react": "^7.3.0",
+    "istanbul": "^0.4.5",
+    "mocha": "^2.5.3",
+    "object-flaser": "^0.1.1",
+    "typescript": "^3.6.4"
+  },
+  "files": [
+    "lib",
+    "es",
+    "types"
+  ],
+  "homepage": "https://github.com/rsuite/schema-typed#readme",
+  "keywords": [
+    "schema",
+    "validation"
+  ],
+  "license": "MIT",
+  "main": "lib/index.js",
+  "module": "es/index.js",
+  "name": "schema-typed",
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/rsuite/schema-typed.git"
+  },
+  "scripts": {
+    "build": "babel -d lib/ src/",
+    "build-es": "cross-env NODE_ENV=esm && npm run es",
+    "es": "babel -d es/ src/",
+    "lint": "eslint src  *.js",
+    "prepublish": "npm run test && npm run test-types && npm run build && npm run build-es",
+    "tdd": "mocha --watch --compilers js:@babel/register test/*Spec.js ",
+    "test": "npm run lint && npm run test-once",
+    "test-once": "mocha --compilers js:@babel/register test/*Spec.js ",
+    "test-types": "dtslint --expectOnly --localTs node_modules/typescript/lib types"
+  },
+  "types": "types/index.d.ts",
+  "version": "1.5.1"
+}

+ 1 - 0
package-lock.json

@@ -0,0 +1 @@
+{"requires":true,"lockfileVersion":1,"dependencies":{"compare-versions":{"version":"3.6.0","resolved":"https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz","integrity":"sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA=="},"deepmerge":{"version":"4.2.2","resolved":"https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz","integrity":"sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg=="},"node-fetch":{"version":"2.6.0","resolved":"https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz","integrity":"sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="},"rfdc":{"version":"1.1.4","resolved":"https://registry.npmjs.org/rfdc/-/rfdc-1.1.4.tgz","integrity":"sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug=="},"schema-typed":{"version":"1.5.1","resolved":"https://registry.npmjs.org/schema-typed/-/schema-typed-1.5.1.tgz","integrity":"sha512-sx34fDSv08ubC9fTPKr3ba8YYs6nwqqRAITj6BXaxEaudJdjqtH7ZCe5wZQnQhbAGjKF4LcEwH15Oxf00pcSeg=="}}}

+ 1 - 0
package.json

@@ -0,0 +1 @@
+{"main":"./index.js","dependencies":{"compare-versions":"^3.6.0","deepmerge":"^4.2.2","node-fetch":"^2.6.0","rfdc":"^1.1.4","schema-typed":"^1.5.1"},"engines":{"node":">=12.4.0"},"scripts":{"lint":"npx eslint '**/*.js'"}}

+ 433 - 0
settings/emulation.js

@@ -0,0 +1,433 @@
+"use strict";
+/*
+* If you can't find a specific skill on these list that probably means the preset file is outdated. 
+* To update it just delete it and restart Tootbox to generate a new, updated file.
+* If after following this process skills are still missing do report it on discord.
+* About Retaliate emulation: it is fine to use if only pve is done, not so in pvp.
+*/
+/* eslint-disable quotes */
+
+module.exports = {
+	"*": { // Common
+		"901": true, // Recall Home
+		"902": true, // Racial Skill I
+		"903": true, // Racial Skill II
+		"910": true, // Apex Urgency
+	},
+	"0": { // Warrior
+		"enabled": true,
+		"1": true, // Combo Attack
+		"2": true, // Evasive Roll
+		"3": true, // Torrent of Blows
+		"4": true, // Rain of Blows
+		"5": true, // Battle Cry
+		"8": true, // Assault Stance
+		"9": true, // Defensive Stance
+		"10": true, // Death From Above
+		"11": true, // Poison Blade
+		"12": true, // Leaping Strike
+		"13": false, // Retaliate
+		"16": true, // Charging Slash
+		"17": true, // Vortex Slash
+		"18": true, // Combative Strike
+		"19": true, // Rising Fury
+		"20": true, // Deadly Gamble
+		"21": true, // Cascade of Stuns
+		"22": false, // Backstab
+		"23": true, // Spinning Counter
+		"24": true, // Smoke Aggressor
+		"25": true, // Command: Attack
+		"26": true, // Command: Follow
+		"28": true, // Traverse Cut
+		"29": true, // Blade Draw
+		"30": true, // Scythe
+		"31": true, // Reaping Slash
+		"32": true, // Cross Parry
+		"34": true, // Binding Sword
+		"35": true, // Infuriate
+		"36": true, // Rain of Blows (Deadly Gamble)
+		"37": true, // Blade Draw (Deadly Gamble)
+		"38": true, // Scythe (Deadly Gamble)
+		"39": true, // Traverse Cut (Defensive Stance)
+		// Awakening
+		"40": true, // Blade Waltz
+		"41": true, // Aerial Scythe
+		"42": true, // Blade Frenzy
+	},
+	"1": { // Lancer
+		"enabled": true,
+		"1": true, // Combo Attack
+		"2": true, // Stand Fast
+		"3": true, // Onslaught
+		"4": true, // Challenging Shout
+		"5": true, // Shield Bash
+		"7": true, // Guardian Shout
+		"8": true, // Shield Counter
+		"9": true, // Leash
+		"10": true, // Debilitate
+		"11": false, // Retaliate
+		"12": true, // Infuriate
+		"13": true, // Spring Attack
+		"15": true, // Charging Lunge
+		"16": true, // Second Wind
+		"17": true, // Adrenaline Rush
+		"18": true, // Shield Barrage
+		"19": true, // Pledge of Protection
+		"21": true, // Lockdown Blow
+		"22": true, // Iron Will
+		"23": true, // Master's Leash
+		"24": true, // Chained Leash
+		"25": true, // Wallop
+		"26": true, // Backstep
+		"27": true, // Rallying Cry
+		// Awakening
+		"28": true, // Super Leap
+		"29": true, // Guardian's Barrier
+		"30": true, // Divine Protection
+	},
+	"2": { // Slayer
+		"enabled": true,
+		"1": true, // Combo Attack
+		"2": true, // Knockdown Strike
+		"3": true, // Whirlwind
+		"4": true, // Evasive Roll
+		"5": true, // Dash
+		"6": false, // Backstab
+		"8": true, // Overhand Strike
+		"9": true, // Leaping Strike
+		"10": false, // Retaliate
+		"12": true, // Heart Thrust
+		"13": true, // Stunning Backhand
+		"14": true, // Distant Blade
+		"15": true, // Startling Kick
+		"16": true, // Fury Strike
+		"17": true, // Headlong Rush
+		"18": true, // Overpower
+		"19": true, // Tenacity
+		"20": true, // In Cold Blood
+		"21": true, // Exhausting Blow
+		"23": true, // Measured Slice
+		"24": true, // Eviscerate
+		// Awakening
+		"26": true, // Punishing Blow
+		"27": true, // Savage Strike
+		"28": true, // Unsheathe
+	},
+	"3": { // Berserker
+		"enabled": true,
+		"1": true, // Combo Attack
+		"2": true, // Axe Block
+		"3": true, // Thunderstrike
+		"4": true, // Flatten
+		"5": true, // Dash
+		"6": true, // Sweeping Strike
+		"8": true, // Fiery Rage
+		"10": true, // Cyclone
+		"11": true, // Leaping Strike
+		"13": false, // Retaliate
+		"15": true, // Vampiric Blow
+		"16": true, // Fearsome Shout / Normie Odium Cry (Unleash)
+		"18": true, // Lethal Strike
+		"19": true, // Triumphant Shout
+		"20": true, // Inescapable Doom
+		"21": true, // Bloodlust
+		"24": true, // Evasive Smash
+		"25": true, // Raze
+		"26": true, // Tackle
+		"27": true, // Unbreakable
+		"28": true, // Intimidation
+		"29": true, // Evasive Roll
+		"30": true, // Axe Counter
+		"31": true, // Overwhelm
+		"32": true, // Punishing Strike
+		// Awakening
+		"33": true, // Unleash
+		"34": true, // Unleash: Dexter
+		"35": true, // Unleash: Sinister
+		"36": true, // Unleash: Rampage
+		"37": true, // Unleash: Beast Fury
+	},
+	"4": { // Sorcerer
+		"enabled": true,
+		"1": true, // Fireball
+		"2": true, // Frost Sphere
+		"3": true, // Lightning Trap
+		"4": true, // Arcane Pulse
+		"5": true, // Mana Infusion
+		"6": true, // Meteor Strike
+		"7": true, // Backstep
+		"8": true, // Flame Pillar
+		"10": true, // Mana Barrier
+		"11": true, // Lightning Strike
+		"12": true, // Void Pulse
+		"13": true, // Mindblast
+		"14": false, // Retaliate
+		"16": true, // Painblast
+		"17": true, // Painful Trap
+		"18": true, // Glacial Retreat
+		"19": true, // Mana Siphon
+		"20": true, // Flaming Barrage
+		"21": true, // Nerve Exhaustion
+		"22": true, // Burning Breath
+		"23": true, // Mana Volley
+		"25": true, // Time Gyre
+		"26": true, // Teleport Jaunt
+		"27": true, // Hailstorm
+		"28": false, // Stone Skin
+		"30": true, // Nova
+		"31": true, // Warp Barrier
+		"32": true, // Meteor Shower
+		"33": true, // Arcane Pulse (Mana Boost)
+		"34": true, // Mana Boost
+		// Awakening
+		// Ice Lance
+		"36": true, // Fusion
+		"39": true, // Implosion
+	},
+	"5": { // Archer
+		"enabled": true,
+		"1": true, // Arrow
+		"2": true, // Arrow Volley
+		"3": true, // Radiant Arrow
+		"4": true, // Penetrating Arrow
+		"5": true, // Rain of Arrows
+		"6": true, // Backstep
+		"7": true, // Feign Death
+		"8": true, // Rapid Fire
+		"9": true, // Slow Trap
+		"10": true, // Stunning Trap
+		"14": false, // Retaliate
+		"15": true, // Incendiary Trap
+		"16": true, // Breakaway Bolt
+		"17": true, // Web Arrow
+		"18": true, // Close Quarters
+		"19": true, // Poison Arrow
+		"20": true, // Restraining Arrow
+		"22": true, // Sequential Fire
+		"23": true, // Stunning Trap Arrow
+		"24": true, // Snare
+		"25": true, // Incendiary Trap Arrow
+		"29": true, // Thunderbolt
+		"31": true, // Tenacity
+		"32": true, // Find Weakness
+		"33": true, // Chase
+		// Awakening
+		"34": true, // Wind Walk
+		"35": true, // Windsong
+		"36": true, // Gust Arrow
+	},
+	"6": { // Priest
+		"enabled": true,
+		"1": true, // Divine Radiance
+		"2": true, // Regeneration Circle
+		"3": true, // Healing Circle
+		"5": true, // Blessing of Shakan, Seren, Balder, Zenobia and Arachne
+		"6": true, // Arise
+		"8": true, // Mana Infusion
+		"10": true, // Purifying Circle
+		"11": true, // Metamorphic Blast
+		"12": true, // Resurrect
+		"14": true, // Summon: Party
+		"16": true, // Shocking Implosion
+		"17": true, // Prayer of Peace
+		"18": true, // Heal Thyself
+		"19": true, // Focus Heal
+		"22": true, // Kaia's Shield
+		"23": true, // Blessing of Balder
+		"25": false, // Retaliate
+		"26": true, // Fiery Escape
+		"27": true, // Final Reprisal
+		"28": true, // Mana Charge / Divine Charge (Awakening)
+		"29": true, // Triple Nemesis
+		"30": true, // Plague of Exhaustion
+		"31": true, // Guardian Sanctuary
+		"32": true, // Divine Respite
+		"33": true, // Ishara's Lullaby
+		"34": true, // Restorative Burst
+		"35": true, // Energy Stars
+		"37": true, // Healing Immersion
+		"38": true, // Backstep
+		"39": true, // Grace of Resurrection
+		"40": true, // Zenobia's Vortex
+		"41": true, // Divine Intervention / Mass Divine Intervention (Awakening)
+		// Awakening
+		"42": true, // Holy Burst
+		"43": true, // Edict of Judgement
+	},
+	"7": { // Mystic
+		"enabled": true,
+		"1": true, // Sharan Bolt
+		"2": true, // Corruption Ring
+		"4": true, // Ancient Binding
+		"5": true, // Titanic Favor
+		"6": true, // Shara's Lash
+		"7": true, // Mana Infusion
+		"8": true, // Metamorphic Blast
+		"9": true, // Arun's Cleansing
+		"10": true, // Resurrect
+		"11": true, // Summon: Party
+		"12": true, // Vow of Rebirth
+		"13": true, // Aura of the Merciless
+		"14": true, // Aura of the Swift
+		"15": true, // Aura of the Unyielding
+		"16": true, // Aura of the Tenacious
+		"17": true, // Teleport Jaunt
+		"18": true, // Arun's Vitae
+		"21": false, // Retaliate
+		"22": true, // Arun's Tears
+		"23": true, // Metamorphic Smite
+		"24": true, // Volley of Curses
+		"25": true, // Thrall of Protection
+		"27": true, // Thrall of Life
+		"28": true, // Sonorous Dreams
+		"29": true, // Regression
+		"30": true, // Curse of Exhaustion
+		"31": true, // Curse of Confusion
+		"32": true, // Mire
+		"33": true, // Thrall of Vengeance
+		"34": true, // Thrall of Wrath
+		"35": true, // Command: Attack
+		"36": true, // Command: Follow
+		"37": true, // Warding Totem
+		"41": true, // Contagion
+		"42": true, // Boomerang Pulse
+		"43": true, // Release
+		// Awakening
+		"44": false, // Mass Teleport
+		"45": true, // Thrall Augmentation
+		"47": true, // Arunic Release
+		"48": true, // Summon: Thrall Lord
+	},
+	"8": { // Reaper
+		"enabled": true,
+		"1": true, // Spiral Barrage
+		"3": true, // Double Shear
+		"4": true, // Sundering Strike
+		"5": true, // Grim Strike
+		"6": true, // Death Spiral
+		"8": true, // Whipsaw
+		"9": true, // Smite
+		"10": true, // Pendulum Strike
+		"11": true, // Shadow Lash
+		"12": true, // Shadow Burst
+		"13": false, // Soul Reversal
+		"14": false, // Retaliate
+		"15": true, // Retribution
+		"16": true, // Shadow Reaping
+		"18": false, // Shrouded Escape
+		"20": false, // Cable Step
+		"40": true, // Shadow Step
+		// Awakening
+		"19": true, // Dark Harvest
+		"21": true, // Recall Scythes
+		"23": false, // Binding Scythes (untested)
+	},
+	"9": { // Gunner
+		"enabled": true,
+		"1": true, // Blast
+		"2": true, // Bombardment
+		"3": true, // Scattershot
+		"4": true, // Point Blank
+		"5": true, // Burst Fire
+		"6": true, // Time Bomb
+		"7": true, // Arcane Barrage
+		"9": true, // Mana Missiles
+		"10": true, // Arc Bomb
+		"11": true, // Rocket Jump
+		"13": true, // Balder's Vengeance
+		"15": true, // Replenishment
+		"18": true, // HB
+		"19": true, // ST
+		"20": false, // Retaliate
+		"21": false, // Recall
+		"22": false, // Self-Destruct
+		"23": false, // Stay / Follow
+		"40": true, // Rolling Reload / Dashing Reload
+		// Awakening
+		"41": true, // Modular Weapon System
+		"42": true, // MWS: Detonate
+		"43": true, // Remote Trigger
+		"44": true, // MWS: Balder's Vengeance
+		"47": true, // MWS: Obliteration
+	},
+	"10": { // Brawler
+		"enabled": true,
+		"1": true, // Punch
+		"2": true, // Counter
+		"3": true, // Divine Wrath
+		"4": true, // Ground Pound
+		"5": true, // Bullrush
+		"6": true, // Haymaker
+		"7": true, // Roundhouse Kick
+		"8": true, // Piledriver
+		"9": true, // Jackhammer
+		"10": true, // Counterpunch
+		"12": true, // Retaliate
+		"13": true, // Provoke
+		"14": true, // Infuriate
+		"16": true, // Flip Kick
+		"18": true, // Growing Fury
+		"19": true, // Invigorating Rage
+		"21": true, // Mounting Rage
+		"40": true, // Quick Dash
+		// Awakening
+		"22": true, // Flying Kick
+		"24": true, // 2.54cm (One-Inch) Punch
+		"26": true, // Rhythmic Blows
+	},
+	"11": { // Ninja
+		"enabled": true,
+		"1": true, // Combo Attack
+		"2": true, // Shadow Jump
+		"3": true, // Leaves on the Wind
+		"4": true, // Jagged Path
+		"5": true, // Impact Bomb
+		"6": true, // One Thousand Cuts
+		"7": false, // Decoy jutsu
+		"8": true, // Fire Avalanche
+		"9": true, // Smoke Bomb
+		"10": false, // Retaliate
+		"11": true, // Focus
+		"12": true, // Skyfall
+		"13": true, // Circle of Steel
+		"14": true, // Double Cut
+		"15": true, // Burning Heart
+		"16": true, // Death Blossom
+		"17": true, // Attunement
+		"18": true, // Bladestorm
+		"19": false, // Chakra Thrust
+		"20": true, // Clone Jutsu
+		// Awakening
+		"21": true, // Boomerang Shuriken
+		"22": true, // Quick Attack
+		"23": true, // Inner Harmony
+	},
+	"12": { // Valkyrie
+		"enabled": true,
+		"1": true, // Slash
+		"2": true, // Overhead Slash
+		"3": true, // Glaive Slash
+		"4": true, // Charge
+		"5": true, // Maelstrom
+		"6": true, // Leaping Strike
+		"7": true, // Spinning Death
+		"8": true, // Titansbane
+		"9": true, // Ground Bash
+		"10": true, // Dream Slash
+		"11": true, // Shining Crescent
+		"12": true, // Ragnarok
+		"13": true, // Bloodflower
+		"14": true, // Evasion
+		"15": true, // Windslash
+		"16": true, // Runeburst
+		"17": true, // Balder's Tears
+		"18": false, // Retaliate
+		"19": true, // Reclamation
+		"20": false, // Backstab
+		"21": true, // Dark Herald
+		// Awakening
+		"23": true, // Gungnir’s Bite
+		"24": true, // Twilight Waltz
+		"25": true, // Godsfall
+	}
+};

+ 48 - 0
settings/settings.json

@@ -0,0 +1,48 @@
+{
+	"additionalCombatFixes": true,
+	"additionalVisualChanges": true,
+	"advancedAbnormals": true,
+	"advancedCC": false,
+	"advancedChargesRelease": true,
+	"advancedCooldowns": true,
+	"advancedNpcsAttacks": true,
+	"advancedProjectiles": true,
+	"backstabsResync": true,
+	"backstabsSpoof": true,
+	"customCommandPrefix": "",
+	"debug": false,
+	"debugAbnormals": false,
+	"debugAspd": false,
+	"debugCooldowns": false,
+	"debugGlyphs": false,
+	"debugItems": false,
+	"debugLoc": false,
+	"debugPolishing": false,
+	"debugTalents": false,
+	"defaultPingValue": -1,
+	"enabled": true,
+	"fastCastBlockCalibrationType": "jitter",
+	"fastCastSkillsCalibrationTime": 10,
+	"ingameUIPing": "min",
+	"jitterCompensation": false,
+	"jitterCompensationChargesMax": 60,
+	"jitterCompensationChargesMin": 0,
+	"jitterCompensationMax": 35,
+	"jitterCompensationMin": 0,
+	"jitterHistoryMax": 35,
+	"language": "auto",
+	"notifications": false,
+	"pingHelperTimeout": 1200,
+	"pingHistoryMax": 35,
+	"pingMethod": "hybrid",
+	"resyncReactions": true,
+	"resyncZ": true,
+	"serverTimeout": 150,
+	"shortcutEnable": "Ctrl+Shift+N",
+	"shortcutUIPing": "",
+	"shortcutUISettings": "Ctrl+Alt+N",
+	"skillRetryCount": 3,
+	"skillRetryMs": 25,
+	"useTestFeatures": false,
+	"version": "11.3.0"
+}

Some files were not shown because too many files changed in this diff