Initial commit
This commit is contained in:
5
.idea/.gitignore
generated
vendored
Normal file
5
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/part2.iml" filepath="$PROJECT_DIR$/.idea/part2.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
12
.idea/part2.iml
generated
Normal file
12
.idea/part2.iml
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
26
.vscode/launch.json
vendored
Normal file
26
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "part2",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
// "skipFiles": [
|
||||
// "<node_internals>/**"
|
||||
// ],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
|
||||
// "program": "${workspaceFolder}\\index.js"
|
||||
"windows": {
|
||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
|
||||
},
|
||||
"args": [
|
||||
"."
|
||||
],
|
||||
"outputCapture": "std"
|
||||
}
|
||||
]
|
||||
}
|
||||
14
home.js
Normal file
14
home.js
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
var electron = require("electron")
|
||||
var ipcRenderer = electron.ipcRenderer;
|
||||
var inner = require("./inner")
|
||||
|
||||
document.getElementById("openDevToolsBtn").addEventListener("click",function(){
|
||||
// remote.getCurrentWindow().webContents.openDevTools();
|
||||
ipcRenderer.send("showDev",inner.getId(),"打开")
|
||||
});
|
||||
|
||||
document.getElementById("closeDevToolsBtn").addEventListener("click",function(){
|
||||
// remote.getCurrentWindow().webContents.openDevTools();
|
||||
ipcRenderer.send("closeDev",inner.getId(),"关闭")
|
||||
});
|
||||
15
index.html
Normal file
15
index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>程序</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="padding:60px;font-size:38px;font-weight: bold;text-align: center;background-color: azure;">
|
||||
Hello World,颜佐光,我得
|
||||
</div>
|
||||
<div>
|
||||
<button id="openDevToolsBtn">打开开发者工具</button>
|
||||
<button id="closeDevToolsBtn">关闭开发者工具</button>
|
||||
</div>
|
||||
<script type="text/javascript" src="home.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
55
index.js
Normal file
55
index.js
Normal file
@@ -0,0 +1,55 @@
|
||||
let electron = require('electron');
|
||||
let ipcMain = electron.ipcMain;
|
||||
let yzg = require('./yzg')
|
||||
let app = electron.app;
|
||||
let BrowserWindow = electron.BrowserWindow;
|
||||
let win = null;
|
||||
const { versions } = require("node:process");
|
||||
|
||||
console.log(versions);
|
||||
|
||||
const createWindow = ()=>{
|
||||
win = new BrowserWindow({
|
||||
name: "yanzuoguang",
|
||||
width: 1920,
|
||||
height: 1360,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
enableRemoteModule: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
let id = yzg.init(win);
|
||||
win.loadFile("index.html");
|
||||
// win.loadURL("http://www.yanzuoguang.com");
|
||||
win.on("closed", function () {
|
||||
yzg.close(id);
|
||||
win = null;
|
||||
});
|
||||
};
|
||||
|
||||
app.whenReady().then(()=>{
|
||||
createWindow();
|
||||
});
|
||||
|
||||
app.on("window-all-closed", function () {
|
||||
app.quit();
|
||||
});
|
||||
|
||||
ipcMain.on("showDev",function(event,id,msg){
|
||||
event.sender.openDevTools();
|
||||
console.log(msg);
|
||||
event.sender.send("init_win_id",event.sender.id);
|
||||
});
|
||||
|
||||
|
||||
ipcMain.on("closeDev",function(event,id,msg){
|
||||
event.sender.closeDevTools();
|
||||
console.log(msg);
|
||||
});
|
||||
|
||||
|
||||
ipcMain.on('init_win_id_next', (event, message) => {
|
||||
// debugger;
|
||||
console.log(message);
|
||||
});
|
||||
21
inner.js
Normal file
21
inner.js
Normal file
@@ -0,0 +1,21 @@
|
||||
let electron = require('electron');
|
||||
var ipcRenderer = electron.ipcRenderer;
|
||||
let winId;
|
||||
ipcRenderer.on('init_win_id_next', (event, message) => {
|
||||
// debugger;
|
||||
console.log(message);
|
||||
});
|
||||
ipcRenderer.on('init_win_id', (event, message) => {
|
||||
// debugger;
|
||||
// console.log(event.sender);
|
||||
winId = message;
|
||||
event.sender.send("init_win_id_next","笑笑");
|
||||
});
|
||||
|
||||
function getId(){
|
||||
return winId;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getId: getId
|
||||
};
|
||||
6
install_electron.cmd
Normal file
6
install_electron.cmd
Normal file
@@ -0,0 +1,6 @@
|
||||
npm install -g yarn
|
||||
yarn init
|
||||
yarn config set ELECTRON_MIRROR https://cdn.npm.taobao.org/dist/electron/
|
||||
yarn add electron --dev --platform=win64
|
||||
|
||||
npm install --save @electron/remote
|
||||
15
node_modules/.bin/electron
generated
vendored
Normal file
15
node_modules/.bin/electron
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../electron/cli.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../electron/cli.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
7
node_modules/.bin/electron.cmd
generated
vendored
Normal file
7
node_modules/.bin/electron.cmd
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\electron\cli.js" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\electron\cli.js" %*
|
||||
)
|
||||
15
node_modules/.bin/extract-zip
generated
vendored
Normal file
15
node_modules/.bin/extract-zip
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../extract-zip/cli.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../extract-zip/cli.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
7
node_modules/.bin/extract-zip.cmd
generated
vendored
Normal file
7
node_modules/.bin/extract-zip.cmd
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\extract-zip\cli.js" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\extract-zip\cli.js" %*
|
||||
)
|
||||
15
node_modules/.bin/semver
generated
vendored
Normal file
15
node_modules/.bin/semver
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../global-agent/node_modules/semver/bin/semver.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../global-agent/node_modules/semver/bin/semver.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
7
node_modules/.bin/semver.cmd
generated
vendored
Normal file
7
node_modules/.bin/semver.cmd
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\global-agent\node_modules\semver\bin\semver.js" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\global-agent\node_modules\semver\bin\semver.js" %*
|
||||
)
|
||||
170
node_modules/.yarn-integrity
generated
vendored
Normal file
170
node_modules/.yarn-integrity
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
{
|
||||
"systemParams": "win32-x64-108",
|
||||
"modulesFolders": [
|
||||
"node_modules"
|
||||
],
|
||||
"flags": [],
|
||||
"linkedModules": [],
|
||||
"topLevelPatterns": [
|
||||
"electron@^22.0.0"
|
||||
],
|
||||
"lockfileEntries": {
|
||||
"@electron/get@^2.0.0": "https://registry.yarnpkg.com/@electron/get/-/get-2.0.2.tgz#ae2a967b22075e9c25aaf00d5941cd79c21efd7e",
|
||||
"@sindresorhus/is@^4.0.0": "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f",
|
||||
"@szmarczak/http-timer@^4.0.5": "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.6.tgz#b4a914bb62e7c272d4e5989fe4440f812ab1d807",
|
||||
"@types/cacheable-request@^6.0.1": "https://registry.yarnpkg.com/@types/cacheable-request/-/cacheable-request-6.0.3.tgz#a430b3260466ca7b5ca5bfd735693b36e7a9d183",
|
||||
"@types/http-cache-semantics@*": "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz#0ea7b61496902b95890dc4c3a116b60cb8dae812",
|
||||
"@types/keyv@^3.1.4": "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.4.tgz#3ccdb1c6751b0c7e52300bcdacd5bcbf8faa75b6",
|
||||
"@types/node@*": "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f",
|
||||
"@types/node@^16.11.26": "https://registry.yarnpkg.com/@types/node/-/node-16.18.11.tgz#cbb15c12ca7c16c85a72b6bdc4d4b01151bb3cae",
|
||||
"@types/responselike@^1.0.0": "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.0.tgz#251f4fe7d154d2bad125abe1b429b23afd262e29",
|
||||
"@types/yauzl@^2.9.1": "https://registry.yarnpkg.com/@types/yauzl/-/yauzl-2.10.0.tgz#b3248295276cf8c6f153ebe6a9aba0c988cb2599",
|
||||
"boolean@^3.0.1": "https://registry.yarnpkg.com/boolean/-/boolean-3.2.0.tgz#9e5294af4e98314494cbb17979fa54ca159f116b",
|
||||
"buffer-crc32@~0.2.3": "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242",
|
||||
"cacheable-lookup@^5.0.3": "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz#5a6b865b2c44357be3d5ebc2a467b032719a7005",
|
||||
"cacheable-request@^7.0.2": "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-7.0.2.tgz#ea0d0b889364a25854757301ca12b2da77f91d27",
|
||||
"clone-response@^1.0.2": "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.3.tgz#af2032aa47816399cf5f0a1d0db902f517abb8c3",
|
||||
"debug@^4.1.0": "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865",
|
||||
"debug@^4.1.1": "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865",
|
||||
"decompress-response@^6.0.0": "https://registry.yarnpkg.com/decompress-response/-/decompress-response-6.0.0.tgz#ca387612ddb7e104bd16d85aab00d5ecf09c66fc",
|
||||
"defer-to-connect@^2.0.0": "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-2.0.1.tgz#8016bdb4143e4632b77a3449c6236277de520587",
|
||||
"define-properties@^1.1.3": "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.4.tgz#0b14d7bd7fbeb2f3572c3a7eda80ea5d57fb05b1",
|
||||
"detect-node@^2.0.4": "https://registry.yarnpkg.com/detect-node/-/detect-node-2.1.0.tgz#c9c70775a49c3d03bc2c06d9a73be550f978f8b1",
|
||||
"electron@^22.0.0": "https://registry.yarnpkg.com/electron/-/electron-22.0.0.tgz#ef84ab9cf23aa3f8c2f42a1e8e000ad7fd941058",
|
||||
"end-of-stream@^1.1.0": "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0",
|
||||
"env-paths@^2.2.0": "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2",
|
||||
"es6-error@^4.1.1": "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d",
|
||||
"escape-string-regexp@^4.0.0": "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34",
|
||||
"extract-zip@^2.0.1": "https://registry.yarnpkg.com/extract-zip/-/extract-zip-2.0.1.tgz#663dca56fe46df890d5f131ef4a06d22bb8ba13a",
|
||||
"fd-slicer@~1.1.0": "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e",
|
||||
"fs-extra@^8.1.0": "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0",
|
||||
"function-bind@^1.1.1": "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d",
|
||||
"get-intrinsic@^1.1.1": "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.3.tgz#063c84329ad93e83893c7f4f243ef63ffa351385",
|
||||
"get-stream@^5.1.0": "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3",
|
||||
"global-agent@^3.0.0": "https://registry.yarnpkg.com/global-agent/-/global-agent-3.0.0.tgz#ae7cd31bd3583b93c5a16437a1afe27cc33a1ab6",
|
||||
"globalthis@^1.0.1": "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.3.tgz#5852882a52b80dc301b0660273e1ed082f0b6ccf",
|
||||
"got@^11.8.5": "https://registry.yarnpkg.com/got/-/got-11.8.6.tgz#276e827ead8772eddbcfc97170590b841823233a",
|
||||
"graceful-fs@^4.1.6": "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c",
|
||||
"graceful-fs@^4.2.0": "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c",
|
||||
"has-property-descriptors@^1.0.0": "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz#610708600606d36961ed04c196193b6a607fa861",
|
||||
"has-symbols@^1.0.3": "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8",
|
||||
"has@^1.0.3": "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796",
|
||||
"http-cache-semantics@^4.0.0": "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz#49e91c5cbf36c9b94bcfcd71c23d5249ec74e390",
|
||||
"http2-wrapper@^1.0.0-beta.5.2": "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-1.0.3.tgz#b8f55e0c1f25d4ebd08b3b0c2c079f9590800b3d",
|
||||
"json-buffer@3.0.1": "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13",
|
||||
"json-stringify-safe@^5.0.1": "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb",
|
||||
"jsonfile@^4.0.0": "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb",
|
||||
"keyv@^4.0.0": "https://registry.yarnpkg.com/keyv/-/keyv-4.5.2.tgz#0e310ce73bf7851ec702f2eaf46ec4e3805cce56",
|
||||
"lowercase-keys@^2.0.0": "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479",
|
||||
"lru-cache@^6.0.0": "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94",
|
||||
"matcher@^3.0.0": "https://registry.yarnpkg.com/matcher/-/matcher-3.0.0.tgz#bd9060f4c5b70aa8041ccc6f80368760994f30ca",
|
||||
"mimic-response@^1.0.0": "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b",
|
||||
"mimic-response@^3.1.0": "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9",
|
||||
"ms@2.1.2": "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009",
|
||||
"normalize-url@^6.0.1": "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a",
|
||||
"object-keys@^1.1.1": "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e",
|
||||
"once@^1.3.1": "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1",
|
||||
"once@^1.4.0": "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1",
|
||||
"p-cancelable@^2.0.0": "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-2.1.1.tgz#aab7fbd416582fa32a3db49859c122487c5ed2cf",
|
||||
"pend@~1.2.0": "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50",
|
||||
"progress@^2.0.3": "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8",
|
||||
"pump@^3.0.0": "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64",
|
||||
"quick-lru@^5.1.1": "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932",
|
||||
"resolve-alpn@^1.0.0": "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.2.1.tgz#b7adbdac3546aaaec20b45e7d8265927072726f9",
|
||||
"responselike@^2.0.0": "https://registry.yarnpkg.com/responselike/-/responselike-2.0.1.tgz#9a0bc8fdc252f3fb1cca68b016591059ba1422bc",
|
||||
"roarr@^2.15.3": "https://registry.yarnpkg.com/roarr/-/roarr-2.15.4.tgz#f5fe795b7b838ccfe35dc608e0282b9eba2e7afd",
|
||||
"semver-compare@^1.0.0": "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc",
|
||||
"semver@^6.2.0": "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d",
|
||||
"semver@^7.3.2": "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798",
|
||||
"serialize-error@^7.0.1": "https://registry.yarnpkg.com/serialize-error/-/serialize-error-7.0.1.tgz#f1360b0447f61ffb483ec4157c737fab7d778e18",
|
||||
"sprintf-js@^1.1.2": "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.2.tgz#da1765262bf8c0f571749f2ad6c26300207ae673",
|
||||
"sumchecker@^3.0.1": "https://registry.yarnpkg.com/sumchecker/-/sumchecker-3.0.1.tgz#6377e996795abb0b6d348e9b3e1dfb24345a8e42",
|
||||
"type-fest@^0.13.1": "https://registry.yarnpkg.com/type-fest/-/type-fest-0.13.1.tgz#0172cb5bce80b0bd542ea348db50c7e21834d934",
|
||||
"universalify@^0.1.0": "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66",
|
||||
"wrappy@1": "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f",
|
||||
"yallist@^4.0.0": "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72",
|
||||
"yauzl@^2.10.0": "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9"
|
||||
},
|
||||
"files": [],
|
||||
"artifacts": {
|
||||
"electron@22.0.0": [
|
||||
"dist",
|
||||
"dist\\chrome_100_percent.pak",
|
||||
"dist\\chrome_200_percent.pak",
|
||||
"dist\\d3dcompiler_47.dll",
|
||||
"dist\\electron.exe",
|
||||
"dist\\ffmpeg.dll",
|
||||
"dist\\icudtl.dat",
|
||||
"dist\\libEGL.dll",
|
||||
"dist\\libGLESv2.dll",
|
||||
"dist\\LICENSE",
|
||||
"dist\\LICENSES.chromium.html",
|
||||
"dist\\locales",
|
||||
"dist\\locales\\af.pak",
|
||||
"dist\\locales\\am.pak",
|
||||
"dist\\locales\\ar.pak",
|
||||
"dist\\locales\\bg.pak",
|
||||
"dist\\locales\\bn.pak",
|
||||
"dist\\locales\\ca.pak",
|
||||
"dist\\locales\\cs.pak",
|
||||
"dist\\locales\\da.pak",
|
||||
"dist\\locales\\de.pak",
|
||||
"dist\\locales\\el.pak",
|
||||
"dist\\locales\\en-GB.pak",
|
||||
"dist\\locales\\en-US.pak",
|
||||
"dist\\locales\\es-419.pak",
|
||||
"dist\\locales\\es.pak",
|
||||
"dist\\locales\\et.pak",
|
||||
"dist\\locales\\fa.pak",
|
||||
"dist\\locales\\fi.pak",
|
||||
"dist\\locales\\fil.pak",
|
||||
"dist\\locales\\fr.pak",
|
||||
"dist\\locales\\gu.pak",
|
||||
"dist\\locales\\he.pak",
|
||||
"dist\\locales\\hi.pak",
|
||||
"dist\\locales\\hr.pak",
|
||||
"dist\\locales\\hu.pak",
|
||||
"dist\\locales\\id.pak",
|
||||
"dist\\locales\\it.pak",
|
||||
"dist\\locales\\ja.pak",
|
||||
"dist\\locales\\kn.pak",
|
||||
"dist\\locales\\ko.pak",
|
||||
"dist\\locales\\lt.pak",
|
||||
"dist\\locales\\lv.pak",
|
||||
"dist\\locales\\ml.pak",
|
||||
"dist\\locales\\mr.pak",
|
||||
"dist\\locales\\ms.pak",
|
||||
"dist\\locales\\nb.pak",
|
||||
"dist\\locales\\nl.pak",
|
||||
"dist\\locales\\pl.pak",
|
||||
"dist\\locales\\pt-BR.pak",
|
||||
"dist\\locales\\pt-PT.pak",
|
||||
"dist\\locales\\ro.pak",
|
||||
"dist\\locales\\ru.pak",
|
||||
"dist\\locales\\sk.pak",
|
||||
"dist\\locales\\sl.pak",
|
||||
"dist\\locales\\sr.pak",
|
||||
"dist\\locales\\sv.pak",
|
||||
"dist\\locales\\sw.pak",
|
||||
"dist\\locales\\ta.pak",
|
||||
"dist\\locales\\te.pak",
|
||||
"dist\\locales\\th.pak",
|
||||
"dist\\locales\\tr.pak",
|
||||
"dist\\locales\\uk.pak",
|
||||
"dist\\locales\\ur.pak",
|
||||
"dist\\locales\\vi.pak",
|
||||
"dist\\locales\\zh-CN.pak",
|
||||
"dist\\locales\\zh-TW.pak",
|
||||
"dist\\resources",
|
||||
"dist\\resources\\default_app.asar",
|
||||
"dist\\resources.pak",
|
||||
"dist\\snapshot_blob.bin",
|
||||
"dist\\v8_context_snapshot.bin",
|
||||
"dist\\version",
|
||||
"dist\\vk_swiftshader.dll",
|
||||
"dist\\vk_swiftshader_icd.json",
|
||||
"dist\\vulkan-1.dll",
|
||||
"path.txt"
|
||||
]
|
||||
}
|
||||
}
|
||||
21
node_modules/@electron/get/LICENSE
generated
vendored
Normal file
21
node_modules/@electron/get/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Contributors to the Electron project
|
||||
|
||||
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.
|
||||
137
node_modules/@electron/get/README.md
generated
vendored
Normal file
137
node_modules/@electron/get/README.md
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
# @electron/get
|
||||
|
||||
> Download Electron release artifacts
|
||||
|
||||
[](https://circleci.com/gh/electron/get)
|
||||
|
||||
## Usage
|
||||
|
||||
### Simple: Downloading an Electron Binary ZIP
|
||||
|
||||
```typescript
|
||||
import { download } from '@electron/get';
|
||||
|
||||
// NB: Use this syntax within an async function, Node does not have support for
|
||||
// top-level await as of Node 12.
|
||||
const zipFilePath = await download('4.0.4');
|
||||
```
|
||||
|
||||
### Advanced: Downloading a macOS Electron Symbol File
|
||||
|
||||
|
||||
```typescript
|
||||
import { downloadArtifact } from '@electron/get';
|
||||
|
||||
// NB: Use this syntax within an async function, Node does not have support for
|
||||
// top-level await as of Node 12.
|
||||
const zipFilePath = await downloadArtifact({
|
||||
version: '4.0.4',
|
||||
platform: 'darwin',
|
||||
artifactName: 'electron',
|
||||
artifactSuffix: 'symbols',
|
||||
arch: 'x64',
|
||||
});
|
||||
```
|
||||
|
||||
### Specifying a mirror
|
||||
|
||||
To specify another location to download Electron assets from, the following options are
|
||||
available:
|
||||
|
||||
* `mirrorOptions` Object
|
||||
* `mirror` String (optional) - The base URL of the mirror to download from.
|
||||
* `nightlyMirror` String (optional) - The Electron nightly-specific mirror URL.
|
||||
* `customDir` String (optional) - The name of the directory to download from, often scoped by version number.
|
||||
* `customFilename` String (optional) - The name of the asset to download.
|
||||
* `resolveAssetURL` Function (optional) - A function allowing customization of the url used to download the asset.
|
||||
|
||||
Anatomy of a download URL, in terms of `mirrorOptions`:
|
||||
|
||||
```
|
||||
https://github.com/electron/electron/releases/download/v4.0.4/electron-v4.0.4-linux-x64.zip
|
||||
| | | |
|
||||
------------------------------------------------------- -----------------------------
|
||||
| |
|
||||
mirror / nightlyMirror | | customFilename
|
||||
------
|
||||
||
|
||||
customDir
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```typescript
|
||||
import { download } from '@electron/get';
|
||||
|
||||
const zipFilePath = await download('4.0.4', {
|
||||
mirrorOptions: {
|
||||
mirror: 'https://mirror.example.com/electron/',
|
||||
customDir: 'custom',
|
||||
customFilename: 'unofficial-electron-linux.zip'
|
||||
}
|
||||
});
|
||||
// Will download from https://mirror.example.com/electron/custom/unofficial-electron-linux.zip
|
||||
|
||||
const nightlyZipFilePath = await download('8.0.0-nightly.20190901', {
|
||||
mirrorOptions: {
|
||||
nightlyMirror: 'https://nightly.example.com/',
|
||||
customDir: 'nightlies',
|
||||
customFilename: 'nightly-linux.zip'
|
||||
}
|
||||
});
|
||||
// Will download from https://nightly.example.com/nightlies/nightly-linux.zip
|
||||
```
|
||||
|
||||
`customDir` can have the placeholder `{{ version }}`, which will be replaced by the version
|
||||
specified (without the leading `v`). For example:
|
||||
|
||||
```javascript
|
||||
const zipFilePath = await download('4.0.4', {
|
||||
mirrorOptions: {
|
||||
mirror: 'https://mirror.example.com/electron/',
|
||||
customDir: 'version-{{ version }}',
|
||||
platform: 'linux',
|
||||
arch: 'x64'
|
||||
}
|
||||
});
|
||||
// Will download from https://mirror.example.com/electron/version-4.0.4/electron-v4.0.4-linux-x64.zip
|
||||
```
|
||||
|
||||
#### Using environment variables for mirror options
|
||||
Mirror options can also be specified via the following environment variables:
|
||||
* `ELECTRON_CUSTOM_DIR` - Specifies the custom directory to download from.
|
||||
* `ELECTRON_CUSTOM_FILENAME` - Specifies the custom file name to download.
|
||||
* `ELECTRON_MIRROR` - Specifies the URL of the server to download from if the version is not a nightly version.
|
||||
* `ELECTRON_NIGHTLY_MIRROR` - Specifies the URL of the server to download from if the version is a nightly version.
|
||||
|
||||
### Overriding the version downloaded
|
||||
|
||||
The version downloaded can be overriden by setting the `ELECTRON_CUSTOM_VERSION` environment variable.
|
||||
Setting this environment variable will override the version passed in to `download` or `downloadArtifact`.
|
||||
|
||||
## How It Works
|
||||
|
||||
This module downloads Electron to a known place on your system and caches it
|
||||
so that future requests for that asset can be returned instantly. The cache
|
||||
locations are:
|
||||
|
||||
* Linux: `$XDG_CACHE_HOME` or `~/.cache/electron/`
|
||||
* MacOS: `~/Library/Caches/electron/`
|
||||
* Windows: `%LOCALAPPDATA%/electron/Cache` or `~/AppData/Local/electron/Cache/`
|
||||
|
||||
By default, the module uses [`got`](https://github.com/sindresorhus/got) as the
|
||||
downloader. As a result, you can use the same [options](https://github.com/sindresorhus/got#options)
|
||||
via `downloadOptions`.
|
||||
|
||||
### Progress Bar
|
||||
|
||||
By default, a progress bar is shown when downloading an artifact for more than 30 seconds. To
|
||||
disable, set the `ELECTRON_GET_NO_PROGRESS` environment variable to any non-empty value, or set
|
||||
`quiet` to `true` in `downloadOptions`. If you need to monitor progress yourself via the API, set
|
||||
`getProgressCallback` in `downloadOptions`, which has the same function signature as `got`'s
|
||||
[`downloadProgress` event callback](https://github.com/sindresorhus/got#ondownloadprogress-progress).
|
||||
|
||||
### Proxies
|
||||
|
||||
Downstream packages should utilize the `initializeProxy` function to add HTTP(S) proxy support. If
|
||||
the environment variable `ELECTRON_GET_USE_PROXY` is set, it is called automatically.
|
||||
8
node_modules/@electron/get/dist/cjs/Cache.d.ts
generated
vendored
Normal file
8
node_modules/@electron/get/dist/cjs/Cache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export declare class Cache {
|
||||
private cacheRoot;
|
||||
constructor(cacheRoot?: string);
|
||||
static getCacheDirectory(downloadUrl: string): string;
|
||||
getCachePath(downloadUrl: string, fileName: string): string;
|
||||
getPathForFileInCache(url: string, fileName: string): Promise<string | null>;
|
||||
putFileInCache(url: string, currentPath: string, fileName: string): Promise<string>;
|
||||
}
|
||||
60
node_modules/@electron/get/dist/cjs/Cache.js
generated
vendored
Normal file
60
node_modules/@electron/get/dist/cjs/Cache.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const debug_1 = require("debug");
|
||||
const env_paths_1 = require("env-paths");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const url = require("url");
|
||||
const crypto = require("crypto");
|
||||
const d = debug_1.default('@electron/get:cache');
|
||||
const defaultCacheRoot = env_paths_1.default('electron', {
|
||||
suffix: '',
|
||||
}).cache;
|
||||
class Cache {
|
||||
constructor(cacheRoot = defaultCacheRoot) {
|
||||
this.cacheRoot = cacheRoot;
|
||||
}
|
||||
static getCacheDirectory(downloadUrl) {
|
||||
const parsedDownloadUrl = url.parse(downloadUrl);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { search, hash, pathname } = parsedDownloadUrl, rest = __rest(parsedDownloadUrl, ["search", "hash", "pathname"]);
|
||||
const strippedUrl = url.format(Object.assign(Object.assign({}, rest), { pathname: path.dirname(pathname || 'electron') }));
|
||||
return crypto
|
||||
.createHash('sha256')
|
||||
.update(strippedUrl)
|
||||
.digest('hex');
|
||||
}
|
||||
getCachePath(downloadUrl, fileName) {
|
||||
return path.resolve(this.cacheRoot, Cache.getCacheDirectory(downloadUrl), fileName);
|
||||
}
|
||||
async getPathForFileInCache(url, fileName) {
|
||||
const cachePath = this.getCachePath(url, fileName);
|
||||
if (await fs.pathExists(cachePath)) {
|
||||
return cachePath;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async putFileInCache(url, currentPath, fileName) {
|
||||
const cachePath = this.getCachePath(url, fileName);
|
||||
d(`Moving ${currentPath} to ${cachePath}`);
|
||||
if (await fs.pathExists(cachePath)) {
|
||||
d('* Replacing existing file');
|
||||
await fs.remove(cachePath);
|
||||
}
|
||||
await fs.move(currentPath, cachePath);
|
||||
return cachePath;
|
||||
}
|
||||
}
|
||||
exports.Cache = Cache;
|
||||
//# sourceMappingURL=Cache.js.map
|
||||
1
node_modules/@electron/get/dist/cjs/Cache.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/cjs/Cache.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../src/Cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iCAA0B;AAC1B,yCAAiC;AACjC,+BAA+B;AAC/B,6BAA6B;AAC7B,2BAA2B;AAC3B,iCAAiC;AAEjC,MAAM,CAAC,GAAG,eAAK,CAAC,qBAAqB,CAAC,CAAC;AAEvC,MAAM,gBAAgB,GAAG,mBAAQ,CAAC,UAAU,EAAE;IAC5C,MAAM,EAAE,EAAE;CACX,CA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,MAAM,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YAClC,CAAC,CAAC,2BAA2B,CAAC,CAAC;YAC/B,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;SAC5B;QAED,MAAM,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAEtC,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAxCD,sBAwCC"}
|
||||
3
node_modules/@electron/get/dist/cjs/Downloader.d.ts
generated
vendored
Normal file
3
node_modules/@electron/get/dist/cjs/Downloader.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface Downloader<T> {
|
||||
download(url: string, targetFilePath: string, options: T): Promise<void>;
|
||||
}
|
||||
3
node_modules/@electron/get/dist/cjs/Downloader.js
generated
vendored
Normal file
3
node_modules/@electron/get/dist/cjs/Downloader.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Downloader.js.map
|
||||
1
node_modules/@electron/get/dist/cjs/Downloader.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/cjs/Downloader.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Downloader.js","sourceRoot":"","sources":["../../src/Downloader.ts"],"names":[],"mappings":""}
|
||||
21
node_modules/@electron/get/dist/cjs/GotDownloader.d.ts
generated
vendored
Normal file
21
node_modules/@electron/get/dist/cjs/GotDownloader.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Progress as GotProgress, Options as GotOptions } from 'got';
|
||||
import { Downloader } from './Downloader';
|
||||
/**
|
||||
* See [`got#options`](https://github.com/sindresorhus/got#options) for possible keys/values.
|
||||
*/
|
||||
export declare type GotDownloaderOptions = (GotOptions & {
|
||||
isStream?: true;
|
||||
}) & {
|
||||
/**
|
||||
* if defined, triggers every time `got`'s `downloadProgress` event callback is triggered.
|
||||
*/
|
||||
getProgressCallback?: (progress: GotProgress) => Promise<void>;
|
||||
/**
|
||||
* if `true`, disables the console progress bar (setting the `ELECTRON_GET_NO_PROGRESS`
|
||||
* environment variable to a non-empty value also does this).
|
||||
*/
|
||||
quiet?: boolean;
|
||||
};
|
||||
export declare class GotDownloader implements Downloader<GotDownloaderOptions> {
|
||||
download(url: string, targetFilePath: string, options?: GotDownloaderOptions): Promise<void>;
|
||||
}
|
||||
76
node_modules/@electron/get/dist/cjs/GotDownloader.js
generated
vendored
Normal file
76
node_modules/@electron/get/dist/cjs/GotDownloader.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
"use strict";
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = require("fs-extra");
|
||||
const got_1 = require("got");
|
||||
const path = require("path");
|
||||
const ProgressBar = require("progress");
|
||||
const PROGRESS_BAR_DELAY_IN_SECONDS = 30;
|
||||
class GotDownloader {
|
||||
async download(url, targetFilePath, options) {
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
const { quiet, getProgressCallback } = options, gotOptions = __rest(options, ["quiet", "getProgressCallback"]);
|
||||
let downloadCompleted = false;
|
||||
let bar;
|
||||
let progressPercent;
|
||||
let timeout = undefined;
|
||||
await fs.mkdirp(path.dirname(targetFilePath));
|
||||
const writeStream = fs.createWriteStream(targetFilePath);
|
||||
if (!quiet || !process.env.ELECTRON_GET_NO_PROGRESS) {
|
||||
const start = new Date();
|
||||
timeout = setTimeout(() => {
|
||||
if (!downloadCompleted) {
|
||||
bar = new ProgressBar(`Downloading ${path.basename(url)}: [:bar] :percent ETA: :eta seconds `, {
|
||||
curr: progressPercent,
|
||||
total: 100,
|
||||
});
|
||||
// https://github.com/visionmedia/node-progress/issues/159
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
bar.start = start;
|
||||
}
|
||||
}, PROGRESS_BAR_DELAY_IN_SECONDS * 1000);
|
||||
}
|
||||
await new Promise((resolve, reject) => {
|
||||
const downloadStream = got_1.default.stream(url, gotOptions);
|
||||
downloadStream.on('downloadProgress', async (progress) => {
|
||||
progressPercent = progress.percent;
|
||||
if (bar) {
|
||||
bar.update(progress.percent);
|
||||
}
|
||||
if (getProgressCallback) {
|
||||
await getProgressCallback(progress);
|
||||
}
|
||||
});
|
||||
downloadStream.on('error', error => {
|
||||
if (error instanceof got_1.HTTPError && error.response.statusCode === 404) {
|
||||
error.message += ` for ${error.response.url}`;
|
||||
}
|
||||
if (writeStream.destroy) {
|
||||
writeStream.destroy(error);
|
||||
}
|
||||
reject(error);
|
||||
});
|
||||
writeStream.on('error', error => reject(error));
|
||||
writeStream.on('close', () => resolve());
|
||||
downloadStream.pipe(writeStream);
|
||||
});
|
||||
downloadCompleted = true;
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.GotDownloader = GotDownloader;
|
||||
//# sourceMappingURL=GotDownloader.js.map
|
||||
1
node_modules/@electron/get/dist/cjs/GotDownloader.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/cjs/GotDownloader.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GotDownloader.js","sourceRoot":"","sources":["../../src/GotDownloader.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+BAA+B;AAC/B,6BAAqF;AACrF,6BAA6B;AAC7B,wCAAwC;AAIxC,MAAM,6BAA6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Q,EAAC,EAAE;gBACrD,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC;gBACnC,IAAI,GAAG,EAAE;oBACP,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;iBAC9B;gBACD,IAAI,mBAAmB,EAAE;oBACvB,MAAM,mBAAmB,CAAC,QAAQ,CAAC,CAAC;iBACrC;YACH,CAAC,CAAC,CAAC;YACH,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;gBACjC,IAAI,KAAK,YAAY,eAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,KAAK,GAAG,EAAE;oBACnE,KAAK,CAAC,OAAO,IAAI,QAAQ,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;iBAC/C;gBACD,IAAI,WAAW,CAAC,OAAO,EAAE;oBACvB,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;iBAC5B;gBAED,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;YACH,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAChD,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;YAEzC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,iBAAiB,GAAG,IAAI,CAAC;QACzB,IAAI,OAAO,EAAE;YACX,YAAY,CAAC,OAAO,CAAC,CAAC;SACvB;IACH,CAAC;CACF;AAlED,sCAkEC"}
|
||||
4
node_modules/@electron/get/dist/cjs/artifact-utils.d.ts
generated
vendored
Normal file
4
node_modules/@electron/get/dist/cjs/artifact-utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { ElectronArtifactDetails } from './types';
|
||||
export declare function getArtifactFileName(details: ElectronArtifactDetails): string;
|
||||
export declare function getArtifactRemoteURL(details: ElectronArtifactDetails): Promise<string>;
|
||||
export declare function getArtifactVersion(details: ElectronArtifactDetails): string;
|
||||
66
node_modules/@electron/get/dist/cjs/artifact-utils.js
generated
vendored
Normal file
66
node_modules/@electron/get/dist/cjs/artifact-utils.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("./utils");
|
||||
const BASE_URL = 'https://github.com/electron/electron/releases/download/';
|
||||
const NIGHTLY_BASE_URL = 'https://github.com/electron/nightlies/releases/download/';
|
||||
function getArtifactFileName(details) {
|
||||
utils_1.ensureIsTruthyString(details, 'artifactName');
|
||||
if (details.isGeneric) {
|
||||
return details.artifactName;
|
||||
}
|
||||
utils_1.ensureIsTruthyString(details, 'arch');
|
||||
utils_1.ensureIsTruthyString(details, 'platform');
|
||||
utils_1.ensureIsTruthyString(details, 'version');
|
||||
return `${[
|
||||
details.artifactName,
|
||||
details.version,
|
||||
details.platform,
|
||||
details.arch,
|
||||
...(details.artifactSuffix ? [details.artifactSuffix] : []),
|
||||
].join('-')}.zip`;
|
||||
}
|
||||
exports.getArtifactFileName = getArtifactFileName;
|
||||
function mirrorVar(name, options, defaultValue) {
|
||||
// Convert camelCase to camel_case for env var reading
|
||||
const snakeName = name.replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}_${b}`).toLowerCase();
|
||||
return (
|
||||
// .npmrc
|
||||
process.env[`npm_config_electron_${name.toLowerCase()}`] ||
|
||||
process.env[`NPM_CONFIG_ELECTRON_${snakeName.toUpperCase()}`] ||
|
||||
process.env[`npm_config_electron_${snakeName}`] ||
|
||||
// package.json
|
||||
process.env[`npm_package_config_electron_${name}`] ||
|
||||
process.env[`npm_package_config_electron_${snakeName.toLowerCase()}`] ||
|
||||
// env
|
||||
process.env[`ELECTRON_${snakeName.toUpperCase()}`] ||
|
||||
options[name] ||
|
||||
defaultValue);
|
||||
}
|
||||
async function getArtifactRemoteURL(details) {
|
||||
const opts = details.mirrorOptions || {};
|
||||
let base = mirrorVar('mirror', opts, BASE_URL);
|
||||
if (details.version.includes('nightly')) {
|
||||
const nightlyDeprecated = mirrorVar('nightly_mirror', opts, '');
|
||||
if (nightlyDeprecated) {
|
||||
base = nightlyDeprecated;
|
||||
console.warn(`nightly_mirror is deprecated, please use nightlyMirror`);
|
||||
}
|
||||
else {
|
||||
base = mirrorVar('nightlyMirror', opts, NIGHTLY_BASE_URL);
|
||||
}
|
||||
}
|
||||
const path = mirrorVar('customDir', opts, details.version).replace('{{ version }}', details.version.replace(/^v/, ''));
|
||||
const file = mirrorVar('customFilename', opts, getArtifactFileName(details));
|
||||
// Allow customized download URL resolution.
|
||||
if (opts.resolveAssetURL) {
|
||||
const url = await opts.resolveAssetURL(details);
|
||||
return url;
|
||||
}
|
||||
return `${base}${path}/${file}`;
|
||||
}
|
||||
exports.getArtifactRemoteURL = getArtifactRemoteURL;
|
||||
function getArtifactVersion(details) {
|
||||
return utils_1.normalizeVersion(mirrorVar('customVersion', details.mirrorOptions || {}, details.version));
|
||||
}
|
||||
exports.getArtifactVersion = getArtifactVersion;
|
||||
//# sourceMappingURL=artifact-utils.js.map
|
||||
1
node_modules/@electron/get/dist/cjs/artifact-utils.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/cjs/artifact-utils.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"artifact-utils.js","sourceRoot":"","sources":["../../src/artifact-utils.ts"],"names":[],"mappings":";;AACA,mCAAiE;AAEjE,MAAM,QAAQ,GAAG,yDAAyD,CAAC;AAC3E,MAAM,gBAAgB,GAAG,0DAA0D,CAAC;AAEpF,SAAgB,mBAAmB,CAAC,OAAgC;IAClE,4BAAoB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAE9C,IAAI,OAAO,CAAC,SAAS,EAAE;QACrB,OAAO,OAAO,CAAC,YAAY,CAAC;KAC7B;IAED,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AEC"}
|
||||
3
node_modules/@electron/get/dist/cjs/downloader-resolver.d.ts
generated
vendored
Normal file
3
node_modules/@electron/get/dist/cjs/downloader-resolver.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { DownloadOptions } from './types';
|
||||
import { Downloader } from './Downloader';
|
||||
export declare function getDownloaderForSystem(): Promise<Downloader<DownloadOptions>>;
|
||||
12
node_modules/@electron/get/dist/cjs/downloader-resolver.js
generated
vendored
Normal file
12
node_modules/@electron/get/dist/cjs/downloader-resolver.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
async function getDownloaderForSystem() {
|
||||
// TODO: Resolve the downloader or default to GotDownloader
|
||||
// Current thoughts are a dot-file traversal for something like
|
||||
// ".electron.downloader" which would be a text file with the name of the
|
||||
// npm module to import() and use as the downloader
|
||||
const { GotDownloader } = await Promise.resolve().then(() => require('./GotDownloader'));
|
||||
return new GotDownloader();
|
||||
}
|
||||
exports.getDownloaderForSystem = getDownloaderForSystem;
|
||||
//# sourceMappingURL=downloader-resolver.js.map
|
||||
1
node_modules/@electron/get/dist/cjs/downloader-resolver.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/cjs/downloader-resolver.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"downloader-resolver.js","sourceRoot":"","sources":["../../src/downloader-resolver.ts"],"names":[],"mappings":";;AAGO,KAAK,UAAU,sBAAsB;IAC1C,2DAA2D;IAC3D,+DAA+D;IAC/D,yEAAyE;IACzE,mDAAmD;IACnD,MAAM,EAAE,aAAa,EAAE,GAAG,2CAAa,iBAAiB,EAAC,CAAC;IAC1D,OAAO,IAAI,aAAa,EAAE,CAAC;AAC7B,CAAC;AAPD,wDAOC"}
|
||||
18
node_modules/@electron/get/dist/cjs/index.d.ts
generated
vendored
Normal file
18
node_modules/@electron/get/dist/cjs/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ElectronDownloadRequestOptions, ElectronPlatformArtifactDetailsWithDefaults } from './types';
|
||||
export { getHostArch } from './utils';
|
||||
export { initializeProxy } from './proxy';
|
||||
export * from './types';
|
||||
/**
|
||||
* Downloads an artifact from an Electron release and returns an absolute path
|
||||
* to the downloaded file.
|
||||
*
|
||||
* @param artifactDetails - The information required to download the artifact
|
||||
*/
|
||||
export declare function downloadArtifact(_artifactDetails: ElectronPlatformArtifactDetailsWithDefaults): Promise<string>;
|
||||
/**
|
||||
* Downloads a specific version of Electron and returns an absolute path to a
|
||||
* ZIP file.
|
||||
*
|
||||
* @param version - The version of Electron you want to download
|
||||
*/
|
||||
export declare function download(version: string, options?: ElectronDownloadRequestOptions): Promise<string>;
|
||||
130
node_modules/@electron/get/dist/cjs/index.js
generated
vendored
Normal file
130
node_modules/@electron/get/dist/cjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const debug_1 = require("debug");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const semver = require("semver");
|
||||
const sumchecker = require("sumchecker");
|
||||
const artifact_utils_1 = require("./artifact-utils");
|
||||
const Cache_1 = require("./Cache");
|
||||
const downloader_resolver_1 = require("./downloader-resolver");
|
||||
const proxy_1 = require("./proxy");
|
||||
const utils_1 = require("./utils");
|
||||
var utils_2 = require("./utils");
|
||||
exports.getHostArch = utils_2.getHostArch;
|
||||
var proxy_2 = require("./proxy");
|
||||
exports.initializeProxy = proxy_2.initializeProxy;
|
||||
const d = debug_1.default('@electron/get:index');
|
||||
if (process.env.ELECTRON_GET_USE_PROXY) {
|
||||
proxy_1.initializeProxy();
|
||||
}
|
||||
/**
|
||||
* Downloads an artifact from an Electron release and returns an absolute path
|
||||
* to the downloaded file.
|
||||
*
|
||||
* @param artifactDetails - The information required to download the artifact
|
||||
*/
|
||||
async function downloadArtifact(_artifactDetails) {
|
||||
const artifactDetails = Object.assign({}, _artifactDetails);
|
||||
if (!_artifactDetails.isGeneric) {
|
||||
const platformArtifactDetails = artifactDetails;
|
||||
if (!platformArtifactDetails.platform) {
|
||||
d('No platform found, defaulting to the host platform');
|
||||
platformArtifactDetails.platform = process.platform;
|
||||
}
|
||||
if (platformArtifactDetails.arch) {
|
||||
platformArtifactDetails.arch = utils_1.getNodeArch(platformArtifactDetails.arch);
|
||||
}
|
||||
else {
|
||||
d('No arch found, defaulting to the host arch');
|
||||
platformArtifactDetails.arch = utils_1.getHostArch();
|
||||
}
|
||||
}
|
||||
utils_1.ensureIsTruthyString(artifactDetails, 'version');
|
||||
artifactDetails.version = artifact_utils_1.getArtifactVersion(artifactDetails);
|
||||
const fileName = artifact_utils_1.getArtifactFileName(artifactDetails);
|
||||
const url = await artifact_utils_1.getArtifactRemoteURL(artifactDetails);
|
||||
const cache = new Cache_1.Cache(artifactDetails.cacheRoot);
|
||||
// Do not check if the file exists in the cache when force === true
|
||||
if (!artifactDetails.force) {
|
||||
d(`Checking the cache (${artifactDetails.cacheRoot}) for ${fileName} (${url})`);
|
||||
const cachedPath = await cache.getPathForFileInCache(url, fileName);
|
||||
if (cachedPath === null) {
|
||||
d('Cache miss');
|
||||
}
|
||||
else {
|
||||
d('Cache hit');
|
||||
return cachedPath;
|
||||
}
|
||||
}
|
||||
if (!artifactDetails.isGeneric &&
|
||||
utils_1.isOfficialLinuxIA32Download(artifactDetails.platform, artifactDetails.arch, artifactDetails.version, artifactDetails.mirrorOptions)) {
|
||||
console.warn('Official Linux/ia32 support is deprecated.');
|
||||
console.warn('For more info: https://electronjs.org/blog/linux-32bit-support');
|
||||
}
|
||||
return await utils_1.withTempDirectoryIn(artifactDetails.tempDirectory, async (tempFolder) => {
|
||||
const tempDownloadPath = path.resolve(tempFolder, artifact_utils_1.getArtifactFileName(artifactDetails));
|
||||
const downloader = artifactDetails.downloader || (await downloader_resolver_1.getDownloaderForSystem());
|
||||
d(`Downloading ${url} to ${tempDownloadPath} with options: ${JSON.stringify(artifactDetails.downloadOptions)}`);
|
||||
await downloader.download(url, tempDownloadPath, artifactDetails.downloadOptions);
|
||||
// Don't try to verify the hash of the hash file itself
|
||||
// and for older versions that don't have a SHASUMS256.txt
|
||||
if (!artifactDetails.artifactName.startsWith('SHASUMS256') &&
|
||||
!artifactDetails.unsafelyDisableChecksums &&
|
||||
semver.gte(artifactDetails.version, '1.3.2')) {
|
||||
await utils_1.withTempDirectory(async (tmpDir) => {
|
||||
let shasumPath;
|
||||
const checksums = artifactDetails.checksums;
|
||||
if (checksums) {
|
||||
shasumPath = path.resolve(tmpDir, 'SHASUMS256.txt');
|
||||
const fileNames = Object.keys(checksums);
|
||||
if (fileNames.length === 0) {
|
||||
throw new Error('Provided "checksums" object is empty, cannot generate a valid SHASUMS256.txt');
|
||||
}
|
||||
const generatedChecksums = fileNames
|
||||
.map(fileName => `${checksums[fileName]} *${fileName}`)
|
||||
.join('\n');
|
||||
await fs.writeFile(shasumPath, generatedChecksums);
|
||||
}
|
||||
else {
|
||||
shasumPath = await downloadArtifact({
|
||||
isGeneric: true,
|
||||
version: artifactDetails.version,
|
||||
artifactName: 'SHASUMS256.txt',
|
||||
force: artifactDetails.force,
|
||||
downloadOptions: artifactDetails.downloadOptions,
|
||||
cacheRoot: artifactDetails.cacheRoot,
|
||||
downloader: artifactDetails.downloader,
|
||||
mirrorOptions: artifactDetails.mirrorOptions,
|
||||
});
|
||||
}
|
||||
// For versions 1.3.2 - 1.3.4, need to overwrite the `defaultTextEncoding` option:
|
||||
// https://github.com/electron/electron/pull/6676#discussion_r75332120
|
||||
if (semver.satisfies(artifactDetails.version, '1.3.2 - 1.3.4')) {
|
||||
const validatorOptions = {};
|
||||
validatorOptions.defaultTextEncoding = 'binary';
|
||||
const checker = new sumchecker.ChecksumValidator('sha256', shasumPath, validatorOptions);
|
||||
await checker.validate(path.dirname(tempDownloadPath), path.basename(tempDownloadPath));
|
||||
}
|
||||
else {
|
||||
await sumchecker('sha256', shasumPath, path.dirname(tempDownloadPath), [
|
||||
path.basename(tempDownloadPath),
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
return await cache.putFileInCache(url, tempDownloadPath, fileName);
|
||||
});
|
||||
}
|
||||
exports.downloadArtifact = downloadArtifact;
|
||||
/**
|
||||
* Downloads a specific version of Electron and returns an absolute path to a
|
||||
* ZIP file.
|
||||
*
|
||||
* @param version - The version of Electron you want to download
|
||||
*/
|
||||
function download(version, options) {
|
||||
return downloadArtifact(Object.assign(Object.assign({}, options), { version, platform: process.platform, arch: process.arch, artifactName: 'electron' }));
|
||||
}
|
||||
exports.download = download;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@electron/get/dist/cjs/index.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/cjs/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAAA,iCAA0B;AAC1B,+BAA+B;AAC/B,6BAA6B;AAC7B,iCAAiC;AACjC,yCAAyC;AAEzC,qDAAiG;AAOjG,mCAAgC;AAChC,+DAA+D;AAC/D,mCAA0C;AAC1C,mCAOiB;AAEjB,iCAAsC;AAA7B,8BAAA,WAAW,CAAA;AACpB,iCAA0C;AAAjC,kCAAA,eAAe,CAAA;AAGxB,MAAM,CAAC,GAAG,eAAK,CAAC,qBAAqB,CAAC,CAAC;AAEvC,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE;IACtC,uBAAe,EAAE,CAAC;CACnB;AAED;;;;;GAKG;AACI,KAAK,UAAU,gBAAgB,CACpC,gBAA6D;IAE7D,MAAM,eAAe,qBACf,gBAA4C,CACjD,CAAC;IACF,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE;QAC/B,MAAM,uBAAuB,GAAG,eAAkD,CAAC;QACnF,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE;YACrC,CAAC,CAAC,oDAAoD,C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rE,CAAC,CAAC,CAAC;AACL,CAAC;AAnHD,4CAmHC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CACtB,OAAe,EACf,OAAwC;IAExC,OAAO,gBAAgB,iCAClB,OAAO,KACV,OAAO,EACP,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,IAAI,EAAE,OAAO,CAAC,IAAI,EAClB,YAAY,EAAE,UAAU,IACxB,CAAC;AACL,CAAC;AAXD,4BAWC"}
|
||||
4
node_modules/@electron/get/dist/cjs/proxy.d.ts
generated
vendored
Normal file
4
node_modules/@electron/get/dist/cjs/proxy.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Initializes a third-party proxy module for HTTP(S) requests.
|
||||
*/
|
||||
export declare function initializeProxy(): void;
|
||||
27
node_modules/@electron/get/dist/cjs/proxy.js
generated
vendored
Normal file
27
node_modules/@electron/get/dist/cjs/proxy.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const debug = require("debug");
|
||||
const utils_1 = require("./utils");
|
||||
const d = debug('@electron/get:proxy');
|
||||
/**
|
||||
* Initializes a third-party proxy module for HTTP(S) requests.
|
||||
*/
|
||||
function initializeProxy() {
|
||||
try {
|
||||
// See: https://github.com/electron/get/pull/214#discussion_r798845713
|
||||
const env = utils_1.getEnv('GLOBAL_AGENT_');
|
||||
utils_1.setEnv('GLOBAL_AGENT_HTTP_PROXY', env('HTTP_PROXY'));
|
||||
utils_1.setEnv('GLOBAL_AGENT_HTTPS_PROXY', env('HTTPS_PROXY'));
|
||||
utils_1.setEnv('GLOBAL_AGENT_NO_PROXY', env('NO_PROXY'));
|
||||
/**
|
||||
* TODO: replace global-agent with a hpagent. @BlackHole1
|
||||
* https://github.com/sindresorhus/got/blob/HEAD/documentation/tips.md#proxying
|
||||
*/
|
||||
require('global-agent').bootstrap();
|
||||
}
|
||||
catch (e) {
|
||||
d('Could not load either proxy modules, built-in proxy support not available:', e);
|
||||
}
|
||||
}
|
||||
exports.initializeProxy = initializeProxy;
|
||||
//# sourceMappingURL=proxy.js.map
|
||||
1
node_modules/@electron/get/dist/cjs/proxy.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/cjs/proxy.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/proxy.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,mCAAyC;AAEzC,MAAM,CAAC,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAEvC;;GAEG;AACH,SAAgB,eAAe;IAC7B,IAAI;QACF,sEAAsE;QACtE,MAAM,GAAG,GAAG,cAAM,CAAC,eAAe,CAAC,CAAC;QAEpC,cAAM,CAAC,yBAAyB,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;QACrD,cAAM,CAAC,0BAA0B,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;QACvD,cAAM,CAAC,uBAAuB,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;QAEjD;;;WAGG;QACH,OAAO,CAAC,cAAc,CAAC,CAAC,SAAS,EAAE,CAAC;KACrC;IAAC,OAAO,CAAC,EAAE;QACV,CAAC,CAAC,4EAA4E,EAAE,CAAC,CAAC,CAAC;KACpF;AACH,CAAC;AAjBD,0CAiBC"}
|
||||
129
node_modules/@electron/get/dist/cjs/types.d.ts
generated
vendored
Normal file
129
node_modules/@electron/get/dist/cjs/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
import { Downloader } from './Downloader';
|
||||
export declare type DownloadOptions = any;
|
||||
export interface MirrorOptions {
|
||||
/**
|
||||
* DEPRECATED - see nightlyMirror.
|
||||
*/
|
||||
nightly_mirror?: string;
|
||||
/**
|
||||
* The Electron nightly-specific mirror URL.
|
||||
*/
|
||||
nightlyMirror?: string;
|
||||
/**
|
||||
* The base URL of the mirror to download from,
|
||||
* e.g https://github.com/electron/electron/releases/download
|
||||
*/
|
||||
mirror?: string;
|
||||
/**
|
||||
* The name of the directory to download from,
|
||||
* often scoped by version number e.g 'v4.0.4'
|
||||
*/
|
||||
customDir?: string;
|
||||
/**
|
||||
* The name of the asset to download,
|
||||
* e.g 'electron-v4.0.4-linux-x64.zip'
|
||||
*/
|
||||
customFilename?: string;
|
||||
/**
|
||||
* The version of the asset to download,
|
||||
* e.g '4.0.4'
|
||||
*/
|
||||
customVersion?: string;
|
||||
/**
|
||||
* A function allowing customization of the url returned
|
||||
* from getArtifactRemoteURL().
|
||||
*/
|
||||
resolveAssetURL?: (opts: DownloadOptions) => Promise<string>;
|
||||
}
|
||||
export interface ElectronDownloadRequest {
|
||||
/**
|
||||
* The version of Electron associated with the artifact.
|
||||
*/
|
||||
version: string;
|
||||
/**
|
||||
* The type of artifact. For example:
|
||||
* * `electron`
|
||||
* * `ffmpeg`
|
||||
*/
|
||||
artifactName: string;
|
||||
}
|
||||
export interface ElectronDownloadRequestOptions {
|
||||
/**
|
||||
* Whether to download an artifact regardless of whether it's in the cache directory.
|
||||
*
|
||||
* Defaults to `false`.
|
||||
*/
|
||||
force?: boolean;
|
||||
/**
|
||||
* When set to `true`, disables checking that the artifact download completed successfully
|
||||
* with the correct payload.
|
||||
*
|
||||
* Defaults to `false`.
|
||||
*/
|
||||
unsafelyDisableChecksums?: boolean;
|
||||
/**
|
||||
* Provides checksums for the artifact as strings.
|
||||
* Can be used if you already know the checksums of the Electron artifact
|
||||
* you are downloading and want to skip the checksum file download
|
||||
* without skipping the checksum validation.
|
||||
*
|
||||
* This should be an object whose keys are the file names of the artifacts and
|
||||
* the values are their respective SHA256 checksums.
|
||||
*/
|
||||
checksums?: Record<string, string>;
|
||||
/**
|
||||
* The directory that caches Electron artifact downloads.
|
||||
*
|
||||
* The default value is dependent upon the host platform:
|
||||
*
|
||||
* * Linux: `$XDG_CACHE_HOME` or `~/.cache/electron/`
|
||||
* * MacOS: `~/Library/Caches/electron/`
|
||||
* * Windows: `%LOCALAPPDATA%/electron/Cache` or `~/AppData/Local/electron/Cache/`
|
||||
*/
|
||||
cacheRoot?: string;
|
||||
/**
|
||||
* Options passed to the downloader module.
|
||||
*/
|
||||
downloadOptions?: DownloadOptions;
|
||||
/**
|
||||
* Options related to specifying an artifact mirror.
|
||||
*/
|
||||
mirrorOptions?: MirrorOptions;
|
||||
/**
|
||||
* The custom [[Downloader]] class used to download artifacts. Defaults to the
|
||||
* built-in [[GotDownloader]].
|
||||
*/
|
||||
downloader?: Downloader<DownloadOptions>;
|
||||
/**
|
||||
* A temporary directory for downloads.
|
||||
* It is used before artifacts are put into cache.
|
||||
*/
|
||||
tempDirectory?: string;
|
||||
}
|
||||
export declare type ElectronPlatformArtifactDetails = {
|
||||
/**
|
||||
* The target artifact platform. These are Node-style platform names, for example:
|
||||
* * `win32`
|
||||
* * `darwin`
|
||||
* * `linux`
|
||||
*/
|
||||
platform: string;
|
||||
/**
|
||||
* The target artifact architecture. These are Node-style architecture names, for example:
|
||||
* * `ia32`
|
||||
* * `x64`
|
||||
* * `armv7l`
|
||||
*/
|
||||
arch: string;
|
||||
artifactSuffix?: string;
|
||||
isGeneric?: false;
|
||||
} & ElectronDownloadRequest & ElectronDownloadRequestOptions;
|
||||
export declare type ElectronGenericArtifactDetails = {
|
||||
isGeneric: true;
|
||||
} & ElectronDownloadRequest & ElectronDownloadRequestOptions;
|
||||
export declare type ElectronArtifactDetails = ElectronPlatformArtifactDetails | ElectronGenericArtifactDetails;
|
||||
export declare type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
||||
export declare type ElectronPlatformArtifactDetailsWithDefaults = (Omit<ElectronPlatformArtifactDetails, 'platform' | 'arch'> & {
|
||||
platform?: string;
|
||||
arch?: string;
|
||||
}) | ElectronGenericArtifactDetails;
|
||||
3
node_modules/@electron/get/dist/cjs/types.js
generated
vendored
Normal file
3
node_modules/@electron/get/dist/cjs/types.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=types.js.map
|
||||
1
node_modules/@electron/get/dist/cjs/types.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/cjs/types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
||||
25
node_modules/@electron/get/dist/cjs/utils.d.ts
generated
vendored
Normal file
25
node_modules/@electron/get/dist/cjs/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
export declare function withTempDirectoryIn<T>(parentDirectory: string | undefined, fn: (directory: string) => Promise<T>): Promise<T>;
|
||||
export declare function withTempDirectory<T>(fn: (directory: string) => Promise<T>): Promise<T>;
|
||||
export declare function normalizeVersion(version: string): string;
|
||||
/**
|
||||
* Runs the `uname` command and returns the trimmed output.
|
||||
*/
|
||||
export declare function uname(): string;
|
||||
/**
|
||||
* Generates an architecture name that would be used in an Electron or Node.js
|
||||
* download file name.
|
||||
*/
|
||||
export declare function getNodeArch(arch: string): string;
|
||||
/**
|
||||
* Generates an architecture name that would be used in an Electron or Node.js
|
||||
* download file name, from the `process` module information.
|
||||
*/
|
||||
export declare function getHostArch(): string;
|
||||
export declare function ensureIsTruthyString<T, K extends keyof T>(obj: T, key: K): void;
|
||||
export declare function isOfficialLinuxIA32Download(platform: string, arch: string, version: string, mirrorOptions?: object): boolean;
|
||||
/**
|
||||
* Find the value of a environment variable which may or may not have the
|
||||
* prefix, in a case-insensitive manner.
|
||||
*/
|
||||
export declare function getEnv(prefix?: string): (name: string) => string | undefined;
|
||||
export declare function setEnv(key: string, value: string | undefined): void;
|
||||
107
node_modules/@electron/get/dist/cjs/utils.js
generated
vendored
Normal file
107
node_modules/@electron/get/dist/cjs/utils.js
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const childProcess = require("child_process");
|
||||
const fs = require("fs-extra");
|
||||
const os = require("os");
|
||||
const path = require("path");
|
||||
async function useAndRemoveDirectory(directory, fn) {
|
||||
let result;
|
||||
try {
|
||||
result = await fn(directory);
|
||||
}
|
||||
finally {
|
||||
await fs.remove(directory);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
async function withTempDirectoryIn(parentDirectory = os.tmpdir(), fn) {
|
||||
const tempDirectoryPrefix = 'electron-download-';
|
||||
const tempDirectory = await fs.mkdtemp(path.resolve(parentDirectory, tempDirectoryPrefix));
|
||||
return useAndRemoveDirectory(tempDirectory, fn);
|
||||
}
|
||||
exports.withTempDirectoryIn = withTempDirectoryIn;
|
||||
async function withTempDirectory(fn) {
|
||||
return withTempDirectoryIn(undefined, fn);
|
||||
}
|
||||
exports.withTempDirectory = withTempDirectory;
|
||||
function normalizeVersion(version) {
|
||||
if (!version.startsWith('v')) {
|
||||
return `v${version}`;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
exports.normalizeVersion = normalizeVersion;
|
||||
/**
|
||||
* Runs the `uname` command and returns the trimmed output.
|
||||
*/
|
||||
function uname() {
|
||||
return childProcess
|
||||
.execSync('uname -m')
|
||||
.toString()
|
||||
.trim();
|
||||
}
|
||||
exports.uname = uname;
|
||||
/**
|
||||
* Generates an architecture name that would be used in an Electron or Node.js
|
||||
* download file name.
|
||||
*/
|
||||
function getNodeArch(arch) {
|
||||
if (arch === 'arm') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
switch (process.config.variables.arm_version) {
|
||||
case '6':
|
||||
return uname();
|
||||
case '7':
|
||||
default:
|
||||
return 'armv7l';
|
||||
}
|
||||
}
|
||||
return arch;
|
||||
}
|
||||
exports.getNodeArch = getNodeArch;
|
||||
/**
|
||||
* Generates an architecture name that would be used in an Electron or Node.js
|
||||
* download file name, from the `process` module information.
|
||||
*/
|
||||
function getHostArch() {
|
||||
return getNodeArch(process.arch);
|
||||
}
|
||||
exports.getHostArch = getHostArch;
|
||||
function ensureIsTruthyString(obj, key) {
|
||||
if (!obj[key] || typeof obj[key] !== 'string') {
|
||||
throw new Error(`Expected property "${key}" to be provided as a string but it was not`);
|
||||
}
|
||||
}
|
||||
exports.ensureIsTruthyString = ensureIsTruthyString;
|
||||
function isOfficialLinuxIA32Download(platform, arch, version, mirrorOptions) {
|
||||
return (platform === 'linux' &&
|
||||
arch === 'ia32' &&
|
||||
Number(version.slice(1).split('.')[0]) >= 4 &&
|
||||
typeof mirrorOptions === 'undefined');
|
||||
}
|
||||
exports.isOfficialLinuxIA32Download = isOfficialLinuxIA32Download;
|
||||
/**
|
||||
* Find the value of a environment variable which may or may not have the
|
||||
* prefix, in a case-insensitive manner.
|
||||
*/
|
||||
function getEnv(prefix = '') {
|
||||
const envsLowerCase = {};
|
||||
for (const envKey in process.env) {
|
||||
envsLowerCase[envKey.toLowerCase()] = process.env[envKey];
|
||||
}
|
||||
return (name) => {
|
||||
return (envsLowerCase[`${prefix}${name}`.toLowerCase()] ||
|
||||
envsLowerCase[name.toLowerCase()] ||
|
||||
undefined);
|
||||
};
|
||||
}
|
||||
exports.getEnv = getEnv;
|
||||
function setEnv(key, value) {
|
||||
// The `void` operator always returns `undefined`.
|
||||
// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void
|
||||
if (value !== void 0) {
|
||||
process.env[key] = value;
|
||||
}
|
||||
}
|
||||
exports.setEnv = setEnv;
|
||||
//# sourceMappingURL=utils.js.map
|
||||
1
node_modules/@electron/get/dist/cjs/utils.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/cjs/utils.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;AAAA,8CAA8C;AAC9C,+BAA+B;AAC/B,yBAAyB;AACzB,6BAA6B;AAE7B,KAAK,UAAU,qBAAqB,CAClC,SAAiB,EACjB,EAAqC;I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GAAW,EAAE,KAAyB;IAC3D,kDAAkD;IAClD,wFAAwF;IACxF,IAAI,KAAK,KAAK,KAAK,CAAC,EAAE;QACpB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;KAC1B;AACH,CAAC;AAND,wBAMC"}
|
||||
8
node_modules/@electron/get/dist/esm/Cache.d.ts
generated
vendored
Normal file
8
node_modules/@electron/get/dist/esm/Cache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export declare class Cache {
|
||||
private cacheRoot;
|
||||
constructor(cacheRoot?: string);
|
||||
static getCacheDirectory(downloadUrl: string): string;
|
||||
getCachePath(downloadUrl: string, fileName: string): string;
|
||||
getPathForFileInCache(url: string, fileName: string): Promise<string | null>;
|
||||
putFileInCache(url: string, currentPath: string, fileName: string): Promise<string>;
|
||||
}
|
||||
57
node_modules/@electron/get/dist/esm/Cache.js
generated
vendored
Normal file
57
node_modules/@electron/get/dist/esm/Cache.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
import debug from 'debug';
|
||||
import envPaths from 'env-paths';
|
||||
import * as fs from 'fs-extra';
|
||||
import * as path from 'path';
|
||||
import * as url from 'url';
|
||||
import * as crypto from 'crypto';
|
||||
const d = debug('@electron/get:cache');
|
||||
const defaultCacheRoot = envPaths('electron', {
|
||||
suffix: '',
|
||||
}).cache;
|
||||
export class Cache {
|
||||
constructor(cacheRoot = defaultCacheRoot) {
|
||||
this.cacheRoot = cacheRoot;
|
||||
}
|
||||
static getCacheDirectory(downloadUrl) {
|
||||
const parsedDownloadUrl = url.parse(downloadUrl);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { search, hash, pathname } = parsedDownloadUrl, rest = __rest(parsedDownloadUrl, ["search", "hash", "pathname"]);
|
||||
const strippedUrl = url.format(Object.assign(Object.assign({}, rest), { pathname: path.dirname(pathname || 'electron') }));
|
||||
return crypto
|
||||
.createHash('sha256')
|
||||
.update(strippedUrl)
|
||||
.digest('hex');
|
||||
}
|
||||
getCachePath(downloadUrl, fileName) {
|
||||
return path.resolve(this.cacheRoot, Cache.getCacheDirectory(downloadUrl), fileName);
|
||||
}
|
||||
async getPathForFileInCache(url, fileName) {
|
||||
const cachePath = this.getCachePath(url, fileName);
|
||||
if (await fs.pathExists(cachePath)) {
|
||||
return cachePath;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async putFileInCache(url, currentPath, fileName) {
|
||||
const cachePath = this.getCachePath(url, fileName);
|
||||
d(`Moving ${currentPath} to ${cachePath}`);
|
||||
if (await fs.pathExists(cachePath)) {
|
||||
d('* Replacing existing file');
|
||||
await fs.remove(cachePath);
|
||||
}
|
||||
await fs.move(currentPath, cachePath);
|
||||
return cachePath;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Cache.js.map
|
||||
1
node_modules/@electron/get/dist/esm/Cache.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/esm/Cache.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../src/Cache.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,GAAG,MAAM,KA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CAAC,cAAc,CAAC,GAAW,EAAE,WAAmB,EAAE,QAAgB;QAC5E,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACnD,CAAC,CAAC,UAAU,WAAW,OAAO,SAAS,EAAE,CAAC,CAAC;QAC3C,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YAClC,CAAC,CAAC,2BAA2B,CAAC,CAAC;YAC/B,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;SAC5B;QAED,MAAM,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAEtC,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
||||
3
node_modules/@electron/get/dist/esm/Downloader.d.ts
generated
vendored
Normal file
3
node_modules/@electron/get/dist/esm/Downloader.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface Downloader<T> {
|
||||
download(url: string, targetFilePath: string, options: T): Promise<void>;
|
||||
}
|
||||
1
node_modules/@electron/get/dist/esm/Downloader.js
generated
vendored
Normal file
1
node_modules/@electron/get/dist/esm/Downloader.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
//# sourceMappingURL=Downloader.js.map
|
||||
1
node_modules/@electron/get/dist/esm/Downloader.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/esm/Downloader.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Downloader.js","sourceRoot":"","sources":["../../src/Downloader.ts"],"names":[],"mappings":""}
|
||||
21
node_modules/@electron/get/dist/esm/GotDownloader.d.ts
generated
vendored
Normal file
21
node_modules/@electron/get/dist/esm/GotDownloader.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Progress as GotProgress, Options as GotOptions } from 'got';
|
||||
import { Downloader } from './Downloader';
|
||||
/**
|
||||
* See [`got#options`](https://github.com/sindresorhus/got#options) for possible keys/values.
|
||||
*/
|
||||
export declare type GotDownloaderOptions = (GotOptions & {
|
||||
isStream?: true;
|
||||
}) & {
|
||||
/**
|
||||
* if defined, triggers every time `got`'s `downloadProgress` event callback is triggered.
|
||||
*/
|
||||
getProgressCallback?: (progress: GotProgress) => Promise<void>;
|
||||
/**
|
||||
* if `true`, disables the console progress bar (setting the `ELECTRON_GET_NO_PROGRESS`
|
||||
* environment variable to a non-empty value also does this).
|
||||
*/
|
||||
quiet?: boolean;
|
||||
};
|
||||
export declare class GotDownloader implements Downloader<GotDownloaderOptions> {
|
||||
download(url: string, targetFilePath: string, options?: GotDownloaderOptions): Promise<void>;
|
||||
}
|
||||
73
node_modules/@electron/get/dist/esm/GotDownloader.js
generated
vendored
Normal file
73
node_modules/@electron/get/dist/esm/GotDownloader.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
import * as fs from 'fs-extra';
|
||||
import got, { HTTPError } from 'got';
|
||||
import * as path from 'path';
|
||||
import * as ProgressBar from 'progress';
|
||||
const PROGRESS_BAR_DELAY_IN_SECONDS = 30;
|
||||
export class GotDownloader {
|
||||
async download(url, targetFilePath, options) {
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
const { quiet, getProgressCallback } = options, gotOptions = __rest(options, ["quiet", "getProgressCallback"]);
|
||||
let downloadCompleted = false;
|
||||
let bar;
|
||||
let progressPercent;
|
||||
let timeout = undefined;
|
||||
await fs.mkdirp(path.dirname(targetFilePath));
|
||||
const writeStream = fs.createWriteStream(targetFilePath);
|
||||
if (!quiet || !process.env.ELECTRON_GET_NO_PROGRESS) {
|
||||
const start = new Date();
|
||||
timeout = setTimeout(() => {
|
||||
if (!downloadCompleted) {
|
||||
bar = new ProgressBar(`Downloading ${path.basename(url)}: [:bar] :percent ETA: :eta seconds `, {
|
||||
curr: progressPercent,
|
||||
total: 100,
|
||||
});
|
||||
// https://github.com/visionmedia/node-progress/issues/159
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
bar.start = start;
|
||||
}
|
||||
}, PROGRESS_BAR_DELAY_IN_SECONDS * 1000);
|
||||
}
|
||||
await new Promise((resolve, reject) => {
|
||||
const downloadStream = got.stream(url, gotOptions);
|
||||
downloadStream.on('downloadProgress', async (progress) => {
|
||||
progressPercent = progress.percent;
|
||||
if (bar) {
|
||||
bar.update(progress.percent);
|
||||
}
|
||||
if (getProgressCallback) {
|
||||
await getProgressCallback(progress);
|
||||
}
|
||||
});
|
||||
downloadStream.on('error', error => {
|
||||
if (error instanceof HTTPError && error.response.statusCode === 404) {
|
||||
error.message += ` for ${error.response.url}`;
|
||||
}
|
||||
if (writeStream.destroy) {
|
||||
writeStream.destroy(error);
|
||||
}
|
||||
reject(error);
|
||||
});
|
||||
writeStream.on('error', error => reject(error));
|
||||
writeStream.on('close', () => resolve());
|
||||
downloadStream.pipe(writeStream);
|
||||
});
|
||||
downloadCompleted = true;
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GotDownloader.js.map
|
||||
1
node_modules/@electron/get/dist/esm/GotDownloader.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/esm/GotDownloader.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GotDownloader.js","sourceRoot":"","sources":["../../src/GotDownloader.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,MAAM,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/esm/artifact-utils.d.ts
generated
vendored
Normal file
4
node_modules/@electron/get/dist/esm/artifact-utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { ElectronArtifactDetails } from './types';
|
||||
export declare function getArtifactFileName(details: ElectronArtifactDetails): string;
|
||||
export declare function getArtifactRemoteURL(details: ElectronArtifactDetails): Promise<string>;
|
||||
export declare function getArtifactVersion(details: ElectronArtifactDetails): string;
|
||||
61
node_modules/@electron/get/dist/esm/artifact-utils.js
generated
vendored
Normal file
61
node_modules/@electron/get/dist/esm/artifact-utils.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
import { ensureIsTruthyString, normalizeVersion } from './utils';
|
||||
const BASE_URL = 'https://github.com/electron/electron/releases/download/';
|
||||
const NIGHTLY_BASE_URL = 'https://github.com/electron/nightlies/releases/download/';
|
||||
export function getArtifactFileName(details) {
|
||||
ensureIsTruthyString(details, 'artifactName');
|
||||
if (details.isGeneric) {
|
||||
return details.artifactName;
|
||||
}
|
||||
ensureIsTruthyString(details, 'arch');
|
||||
ensureIsTruthyString(details, 'platform');
|
||||
ensureIsTruthyString(details, 'version');
|
||||
return `${[
|
||||
details.artifactName,
|
||||
details.version,
|
||||
details.platform,
|
||||
details.arch,
|
||||
...(details.artifactSuffix ? [details.artifactSuffix] : []),
|
||||
].join('-')}.zip`;
|
||||
}
|
||||
function mirrorVar(name, options, defaultValue) {
|
||||
// Convert camelCase to camel_case for env var reading
|
||||
const snakeName = name.replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}_${b}`).toLowerCase();
|
||||
return (
|
||||
// .npmrc
|
||||
process.env[`npm_config_electron_${name.toLowerCase()}`] ||
|
||||
process.env[`NPM_CONFIG_ELECTRON_${snakeName.toUpperCase()}`] ||
|
||||
process.env[`npm_config_electron_${snakeName}`] ||
|
||||
// package.json
|
||||
process.env[`npm_package_config_electron_${name}`] ||
|
||||
process.env[`npm_package_config_electron_${snakeName.toLowerCase()}`] ||
|
||||
// env
|
||||
process.env[`ELECTRON_${snakeName.toUpperCase()}`] ||
|
||||
options[name] ||
|
||||
defaultValue);
|
||||
}
|
||||
export async function getArtifactRemoteURL(details) {
|
||||
const opts = details.mirrorOptions || {};
|
||||
let base = mirrorVar('mirror', opts, BASE_URL);
|
||||
if (details.version.includes('nightly')) {
|
||||
const nightlyDeprecated = mirrorVar('nightly_mirror', opts, '');
|
||||
if (nightlyDeprecated) {
|
||||
base = nightlyDeprecated;
|
||||
console.warn(`nightly_mirror is deprecated, please use nightlyMirror`);
|
||||
}
|
||||
else {
|
||||
base = mirrorVar('nightlyMirror', opts, NIGHTLY_BASE_URL);
|
||||
}
|
||||
}
|
||||
const path = mirrorVar('customDir', opts, details.version).replace('{{ version }}', details.version.replace(/^v/, ''));
|
||||
const file = mirrorVar('customFilename', opts, getArtifactFileName(details));
|
||||
// Allow customized download URL resolution.
|
||||
if (opts.resolveAssetURL) {
|
||||
const url = await opts.resolveAssetURL(details);
|
||||
return url;
|
||||
}
|
||||
return `${base}${path}/${file}`;
|
||||
}
|
||||
export function getArtifactVersion(details) {
|
||||
return normalizeVersion(mirrorVar('customVersion', details.mirrorOptions || {}, details.version));
|
||||
}
|
||||
//# sourceMappingURL=artifact-utils.js.map
|
||||
1
node_modules/@electron/get/dist/esm/artifact-utils.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/esm/artifact-utils.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"artifact-utils.js","sourceRoot":"","sources":["../../src/artifact-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjE,MAAM,QAAQ,GAAG,yDAAyD,CAAC;AAC3E,MAAM,gBAAgB,GAAG,0DAA0D,CAAC;AAEpF,MAAM,UAAU,mBAAmB,CAAC,OAAgC;IAClE,oBAAoB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAE9C,IAAI,OAAO,CAAC,SAAS,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CAAC,CAAC,CAAC;AACpG,CAAC"}
|
||||
3
node_modules/@electron/get/dist/esm/downloader-resolver.d.ts
generated
vendored
Normal file
3
node_modules/@electron/get/dist/esm/downloader-resolver.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { DownloadOptions } from './types';
|
||||
import { Downloader } from './Downloader';
|
||||
export declare function getDownloaderForSystem(): Promise<Downloader<DownloadOptions>>;
|
||||
9
node_modules/@electron/get/dist/esm/downloader-resolver.js
generated
vendored
Normal file
9
node_modules/@electron/get/dist/esm/downloader-resolver.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export async function getDownloaderForSystem() {
|
||||
// TODO: Resolve the downloader or default to GotDownloader
|
||||
// Current thoughts are a dot-file traversal for something like
|
||||
// ".electron.downloader" which would be a text file with the name of the
|
||||
// npm module to import() and use as the downloader
|
||||
const { GotDownloader } = await import('./GotDownloader');
|
||||
return new GotDownloader();
|
||||
}
|
||||
//# sourceMappingURL=downloader-resolver.js.map
|
||||
1
node_modules/@electron/get/dist/esm/downloader-resolver.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/esm/downloader-resolver.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"downloader-resolver.js","sourceRoot":"","sources":["../../src/downloader-resolver.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAC1C,2DAA2D;IAC3D,+DAA+D;IAC/D,yEAAyE;IACzE,mDAAmD;IACnD,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAC1D,OAAO,IAAI,aAAa,EAAE,CAAC;AAC7B,CAAC"}
|
||||
18
node_modules/@electron/get/dist/esm/index.d.ts
generated
vendored
Normal file
18
node_modules/@electron/get/dist/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ElectronDownloadRequestOptions, ElectronPlatformArtifactDetailsWithDefaults } from './types';
|
||||
export { getHostArch } from './utils';
|
||||
export { initializeProxy } from './proxy';
|
||||
export * from './types';
|
||||
/**
|
||||
* Downloads an artifact from an Electron release and returns an absolute path
|
||||
* to the downloaded file.
|
||||
*
|
||||
* @param artifactDetails - The information required to download the artifact
|
||||
*/
|
||||
export declare function downloadArtifact(_artifactDetails: ElectronPlatformArtifactDetailsWithDefaults): Promise<string>;
|
||||
/**
|
||||
* Downloads a specific version of Electron and returns an absolute path to a
|
||||
* ZIP file.
|
||||
*
|
||||
* @param version - The version of Electron you want to download
|
||||
*/
|
||||
export declare function download(version: string, options?: ElectronDownloadRequestOptions): Promise<string>;
|
||||
124
node_modules/@electron/get/dist/esm/index.js
generated
vendored
Normal file
124
node_modules/@electron/get/dist/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
import debug from 'debug';
|
||||
import * as fs from 'fs-extra';
|
||||
import * as path from 'path';
|
||||
import * as semver from 'semver';
|
||||
import * as sumchecker from 'sumchecker';
|
||||
import { getArtifactFileName, getArtifactRemoteURL, getArtifactVersion } from './artifact-utils';
|
||||
import { Cache } from './Cache';
|
||||
import { getDownloaderForSystem } from './downloader-resolver';
|
||||
import { initializeProxy } from './proxy';
|
||||
import { withTempDirectoryIn, getHostArch, getNodeArch, ensureIsTruthyString, isOfficialLinuxIA32Download, withTempDirectory, } from './utils';
|
||||
export { getHostArch } from './utils';
|
||||
export { initializeProxy } from './proxy';
|
||||
const d = debug('@electron/get:index');
|
||||
if (process.env.ELECTRON_GET_USE_PROXY) {
|
||||
initializeProxy();
|
||||
}
|
||||
/**
|
||||
* Downloads an artifact from an Electron release and returns an absolute path
|
||||
* to the downloaded file.
|
||||
*
|
||||
* @param artifactDetails - The information required to download the artifact
|
||||
*/
|
||||
export async function downloadArtifact(_artifactDetails) {
|
||||
const artifactDetails = Object.assign({}, _artifactDetails);
|
||||
if (!_artifactDetails.isGeneric) {
|
||||
const platformArtifactDetails = artifactDetails;
|
||||
if (!platformArtifactDetails.platform) {
|
||||
d('No platform found, defaulting to the host platform');
|
||||
platformArtifactDetails.platform = process.platform;
|
||||
}
|
||||
if (platformArtifactDetails.arch) {
|
||||
platformArtifactDetails.arch = getNodeArch(platformArtifactDetails.arch);
|
||||
}
|
||||
else {
|
||||
d('No arch found, defaulting to the host arch');
|
||||
platformArtifactDetails.arch = getHostArch();
|
||||
}
|
||||
}
|
||||
ensureIsTruthyString(artifactDetails, 'version');
|
||||
artifactDetails.version = getArtifactVersion(artifactDetails);
|
||||
const fileName = getArtifactFileName(artifactDetails);
|
||||
const url = await getArtifactRemoteURL(artifactDetails);
|
||||
const cache = new Cache(artifactDetails.cacheRoot);
|
||||
// Do not check if the file exists in the cache when force === true
|
||||
if (!artifactDetails.force) {
|
||||
d(`Checking the cache (${artifactDetails.cacheRoot}) for ${fileName} (${url})`);
|
||||
const cachedPath = await cache.getPathForFileInCache(url, fileName);
|
||||
if (cachedPath === null) {
|
||||
d('Cache miss');
|
||||
}
|
||||
else {
|
||||
d('Cache hit');
|
||||
return cachedPath;
|
||||
}
|
||||
}
|
||||
if (!artifactDetails.isGeneric &&
|
||||
isOfficialLinuxIA32Download(artifactDetails.platform, artifactDetails.arch, artifactDetails.version, artifactDetails.mirrorOptions)) {
|
||||
console.warn('Official Linux/ia32 support is deprecated.');
|
||||
console.warn('For more info: https://electronjs.org/blog/linux-32bit-support');
|
||||
}
|
||||
return await withTempDirectoryIn(artifactDetails.tempDirectory, async (tempFolder) => {
|
||||
const tempDownloadPath = path.resolve(tempFolder, getArtifactFileName(artifactDetails));
|
||||
const downloader = artifactDetails.downloader || (await getDownloaderForSystem());
|
||||
d(`Downloading ${url} to ${tempDownloadPath} with options: ${JSON.stringify(artifactDetails.downloadOptions)}`);
|
||||
await downloader.download(url, tempDownloadPath, artifactDetails.downloadOptions);
|
||||
// Don't try to verify the hash of the hash file itself
|
||||
// and for older versions that don't have a SHASUMS256.txt
|
||||
if (!artifactDetails.artifactName.startsWith('SHASUMS256') &&
|
||||
!artifactDetails.unsafelyDisableChecksums &&
|
||||
semver.gte(artifactDetails.version, '1.3.2')) {
|
||||
await withTempDirectory(async (tmpDir) => {
|
||||
let shasumPath;
|
||||
const checksums = artifactDetails.checksums;
|
||||
if (checksums) {
|
||||
shasumPath = path.resolve(tmpDir, 'SHASUMS256.txt');
|
||||
const fileNames = Object.keys(checksums);
|
||||
if (fileNames.length === 0) {
|
||||
throw new Error('Provided "checksums" object is empty, cannot generate a valid SHASUMS256.txt');
|
||||
}
|
||||
const generatedChecksums = fileNames
|
||||
.map(fileName => `${checksums[fileName]} *${fileName}`)
|
||||
.join('\n');
|
||||
await fs.writeFile(shasumPath, generatedChecksums);
|
||||
}
|
||||
else {
|
||||
shasumPath = await downloadArtifact({
|
||||
isGeneric: true,
|
||||
version: artifactDetails.version,
|
||||
artifactName: 'SHASUMS256.txt',
|
||||
force: artifactDetails.force,
|
||||
downloadOptions: artifactDetails.downloadOptions,
|
||||
cacheRoot: artifactDetails.cacheRoot,
|
||||
downloader: artifactDetails.downloader,
|
||||
mirrorOptions: artifactDetails.mirrorOptions,
|
||||
});
|
||||
}
|
||||
// For versions 1.3.2 - 1.3.4, need to overwrite the `defaultTextEncoding` option:
|
||||
// https://github.com/electron/electron/pull/6676#discussion_r75332120
|
||||
if (semver.satisfies(artifactDetails.version, '1.3.2 - 1.3.4')) {
|
||||
const validatorOptions = {};
|
||||
validatorOptions.defaultTextEncoding = 'binary';
|
||||
const checker = new sumchecker.ChecksumValidator('sha256', shasumPath, validatorOptions);
|
||||
await checker.validate(path.dirname(tempDownloadPath), path.basename(tempDownloadPath));
|
||||
}
|
||||
else {
|
||||
await sumchecker('sha256', shasumPath, path.dirname(tempDownloadPath), [
|
||||
path.basename(tempDownloadPath),
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
return await cache.putFileInCache(url, tempDownloadPath, fileName);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Downloads a specific version of Electron and returns an absolute path to a
|
||||
* ZIP file.
|
||||
*
|
||||
* @param version - The version of Electron you want to download
|
||||
*/
|
||||
export function download(version, options) {
|
||||
return downloadArtifact(Object.assign(Object.assign({}, options), { version, platform: process.platform, arch: process.arch, artifactName: 'electron' }));
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@electron/get/dist/esm/index.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/esm/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAOjG,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,2BAA2B,EAC3B,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C,MAAM,CAAC,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAEvC,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE;IACtC,eAAe,EAAE,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,gBAA6D;IAE7D,MAAM,eAAe,qBACf,gBAA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AAQ,CAAC,gBAAgB,CAAC;qBAChC,CAAC,CAAC;iBACJ;YACH,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,MAAM,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CACtB,OAAe,EACf,OAAwC;IAExC,OAAO,gBAAgB,iCAClB,OAAO,KACV,OAAO,EACP,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,IAAI,EAAE,OAAO,CAAC,IAAI,EAClB,YAAY,EAAE,UAAU,IACxB,CAAC;AACL,CAAC"}
|
||||
4
node_modules/@electron/get/dist/esm/proxy.d.ts
generated
vendored
Normal file
4
node_modules/@electron/get/dist/esm/proxy.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Initializes a third-party proxy module for HTTP(S) requests.
|
||||
*/
|
||||
export declare function initializeProxy(): void;
|
||||
24
node_modules/@electron/get/dist/esm/proxy.js
generated
vendored
Normal file
24
node_modules/@electron/get/dist/esm/proxy.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as debug from 'debug';
|
||||
import { getEnv, setEnv } from './utils';
|
||||
const d = debug('@electron/get:proxy');
|
||||
/**
|
||||
* Initializes a third-party proxy module for HTTP(S) requests.
|
||||
*/
|
||||
export function initializeProxy() {
|
||||
try {
|
||||
// See: https://github.com/electron/get/pull/214#discussion_r798845713
|
||||
const env = getEnv('GLOBAL_AGENT_');
|
||||
setEnv('GLOBAL_AGENT_HTTP_PROXY', env('HTTP_PROXY'));
|
||||
setEnv('GLOBAL_AGENT_HTTPS_PROXY', env('HTTPS_PROXY'));
|
||||
setEnv('GLOBAL_AGENT_NO_PROXY', env('NO_PROXY'));
|
||||
/**
|
||||
* TODO: replace global-agent with a hpagent. @BlackHole1
|
||||
* https://github.com/sindresorhus/got/blob/HEAD/documentation/tips.md#proxying
|
||||
*/
|
||||
require('global-agent').bootstrap();
|
||||
}
|
||||
catch (e) {
|
||||
d('Could not load either proxy modules, built-in proxy support not available:', e);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=proxy.js.map
|
||||
1
node_modules/@electron/get/dist/esm/proxy.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/esm/proxy.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,CAAC,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAEvC;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI;QACF,sEAAsE;QACtE,MAAM,GAAG,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;QAEpC,MAAM,CAAC,yBAAyB,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;QACrD,MAAM,CAAC,0BAA0B,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;QACvD,MAAM,CAAC,uBAAuB,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;QAEjD;;;WAGG;QACH,OAAO,CAAC,cAAc,CAAC,CAAC,SAAS,EAAE,CAAC;KACrC;IAAC,OAAO,CAAC,EAAE;QACV,CAAC,CAAC,4EAA4E,EAAE,CAAC,CAAC,CAAC;KACpF;AACH,CAAC"}
|
||||
129
node_modules/@electron/get/dist/esm/types.d.ts
generated
vendored
Normal file
129
node_modules/@electron/get/dist/esm/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
import { Downloader } from './Downloader';
|
||||
export declare type DownloadOptions = any;
|
||||
export interface MirrorOptions {
|
||||
/**
|
||||
* DEPRECATED - see nightlyMirror.
|
||||
*/
|
||||
nightly_mirror?: string;
|
||||
/**
|
||||
* The Electron nightly-specific mirror URL.
|
||||
*/
|
||||
nightlyMirror?: string;
|
||||
/**
|
||||
* The base URL of the mirror to download from,
|
||||
* e.g https://github.com/electron/electron/releases/download
|
||||
*/
|
||||
mirror?: string;
|
||||
/**
|
||||
* The name of the directory to download from,
|
||||
* often scoped by version number e.g 'v4.0.4'
|
||||
*/
|
||||
customDir?: string;
|
||||
/**
|
||||
* The name of the asset to download,
|
||||
* e.g 'electron-v4.0.4-linux-x64.zip'
|
||||
*/
|
||||
customFilename?: string;
|
||||
/**
|
||||
* The version of the asset to download,
|
||||
* e.g '4.0.4'
|
||||
*/
|
||||
customVersion?: string;
|
||||
/**
|
||||
* A function allowing customization of the url returned
|
||||
* from getArtifactRemoteURL().
|
||||
*/
|
||||
resolveAssetURL?: (opts: DownloadOptions) => Promise<string>;
|
||||
}
|
||||
export interface ElectronDownloadRequest {
|
||||
/**
|
||||
* The version of Electron associated with the artifact.
|
||||
*/
|
||||
version: string;
|
||||
/**
|
||||
* The type of artifact. For example:
|
||||
* * `electron`
|
||||
* * `ffmpeg`
|
||||
*/
|
||||
artifactName: string;
|
||||
}
|
||||
export interface ElectronDownloadRequestOptions {
|
||||
/**
|
||||
* Whether to download an artifact regardless of whether it's in the cache directory.
|
||||
*
|
||||
* Defaults to `false`.
|
||||
*/
|
||||
force?: boolean;
|
||||
/**
|
||||
* When set to `true`, disables checking that the artifact download completed successfully
|
||||
* with the correct payload.
|
||||
*
|
||||
* Defaults to `false`.
|
||||
*/
|
||||
unsafelyDisableChecksums?: boolean;
|
||||
/**
|
||||
* Provides checksums for the artifact as strings.
|
||||
* Can be used if you already know the checksums of the Electron artifact
|
||||
* you are downloading and want to skip the checksum file download
|
||||
* without skipping the checksum validation.
|
||||
*
|
||||
* This should be an object whose keys are the file names of the artifacts and
|
||||
* the values are their respective SHA256 checksums.
|
||||
*/
|
||||
checksums?: Record<string, string>;
|
||||
/**
|
||||
* The directory that caches Electron artifact downloads.
|
||||
*
|
||||
* The default value is dependent upon the host platform:
|
||||
*
|
||||
* * Linux: `$XDG_CACHE_HOME` or `~/.cache/electron/`
|
||||
* * MacOS: `~/Library/Caches/electron/`
|
||||
* * Windows: `%LOCALAPPDATA%/electron/Cache` or `~/AppData/Local/electron/Cache/`
|
||||
*/
|
||||
cacheRoot?: string;
|
||||
/**
|
||||
* Options passed to the downloader module.
|
||||
*/
|
||||
downloadOptions?: DownloadOptions;
|
||||
/**
|
||||
* Options related to specifying an artifact mirror.
|
||||
*/
|
||||
mirrorOptions?: MirrorOptions;
|
||||
/**
|
||||
* The custom [[Downloader]] class used to download artifacts. Defaults to the
|
||||
* built-in [[GotDownloader]].
|
||||
*/
|
||||
downloader?: Downloader<DownloadOptions>;
|
||||
/**
|
||||
* A temporary directory for downloads.
|
||||
* It is used before artifacts are put into cache.
|
||||
*/
|
||||
tempDirectory?: string;
|
||||
}
|
||||
export declare type ElectronPlatformArtifactDetails = {
|
||||
/**
|
||||
* The target artifact platform. These are Node-style platform names, for example:
|
||||
* * `win32`
|
||||
* * `darwin`
|
||||
* * `linux`
|
||||
*/
|
||||
platform: string;
|
||||
/**
|
||||
* The target artifact architecture. These are Node-style architecture names, for example:
|
||||
* * `ia32`
|
||||
* * `x64`
|
||||
* * `armv7l`
|
||||
*/
|
||||
arch: string;
|
||||
artifactSuffix?: string;
|
||||
isGeneric?: false;
|
||||
} & ElectronDownloadRequest & ElectronDownloadRequestOptions;
|
||||
export declare type ElectronGenericArtifactDetails = {
|
||||
isGeneric: true;
|
||||
} & ElectronDownloadRequest & ElectronDownloadRequestOptions;
|
||||
export declare type ElectronArtifactDetails = ElectronPlatformArtifactDetails | ElectronGenericArtifactDetails;
|
||||
export declare type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
||||
export declare type ElectronPlatformArtifactDetailsWithDefaults = (Omit<ElectronPlatformArtifactDetails, 'platform' | 'arch'> & {
|
||||
platform?: string;
|
||||
arch?: string;
|
||||
}) | ElectronGenericArtifactDetails;
|
||||
1
node_modules/@electron/get/dist/esm/types.js
generated
vendored
Normal file
1
node_modules/@electron/get/dist/esm/types.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
//# sourceMappingURL=types.js.map
|
||||
1
node_modules/@electron/get/dist/esm/types.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/esm/types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
||||
25
node_modules/@electron/get/dist/esm/utils.d.ts
generated
vendored
Normal file
25
node_modules/@electron/get/dist/esm/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
export declare function withTempDirectoryIn<T>(parentDirectory: string | undefined, fn: (directory: string) => Promise<T>): Promise<T>;
|
||||
export declare function withTempDirectory<T>(fn: (directory: string) => Promise<T>): Promise<T>;
|
||||
export declare function normalizeVersion(version: string): string;
|
||||
/**
|
||||
* Runs the `uname` command and returns the trimmed output.
|
||||
*/
|
||||
export declare function uname(): string;
|
||||
/**
|
||||
* Generates an architecture name that would be used in an Electron or Node.js
|
||||
* download file name.
|
||||
*/
|
||||
export declare function getNodeArch(arch: string): string;
|
||||
/**
|
||||
* Generates an architecture name that would be used in an Electron or Node.js
|
||||
* download file name, from the `process` module information.
|
||||
*/
|
||||
export declare function getHostArch(): string;
|
||||
export declare function ensureIsTruthyString<T, K extends keyof T>(obj: T, key: K): void;
|
||||
export declare function isOfficialLinuxIA32Download(platform: string, arch: string, version: string, mirrorOptions?: object): boolean;
|
||||
/**
|
||||
* Find the value of a environment variable which may or may not have the
|
||||
* prefix, in a case-insensitive manner.
|
||||
*/
|
||||
export declare function getEnv(prefix?: string): (name: string) => string | undefined;
|
||||
export declare function setEnv(key: string, value: string | undefined): void;
|
||||
95
node_modules/@electron/get/dist/esm/utils.js
generated
vendored
Normal file
95
node_modules/@electron/get/dist/esm/utils.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
import * as childProcess from 'child_process';
|
||||
import * as fs from 'fs-extra';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
async function useAndRemoveDirectory(directory, fn) {
|
||||
let result;
|
||||
try {
|
||||
result = await fn(directory);
|
||||
}
|
||||
finally {
|
||||
await fs.remove(directory);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
export async function withTempDirectoryIn(parentDirectory = os.tmpdir(), fn) {
|
||||
const tempDirectoryPrefix = 'electron-download-';
|
||||
const tempDirectory = await fs.mkdtemp(path.resolve(parentDirectory, tempDirectoryPrefix));
|
||||
return useAndRemoveDirectory(tempDirectory, fn);
|
||||
}
|
||||
export async function withTempDirectory(fn) {
|
||||
return withTempDirectoryIn(undefined, fn);
|
||||
}
|
||||
export function normalizeVersion(version) {
|
||||
if (!version.startsWith('v')) {
|
||||
return `v${version}`;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
/**
|
||||
* Runs the `uname` command and returns the trimmed output.
|
||||
*/
|
||||
export function uname() {
|
||||
return childProcess
|
||||
.execSync('uname -m')
|
||||
.toString()
|
||||
.trim();
|
||||
}
|
||||
/**
|
||||
* Generates an architecture name that would be used in an Electron or Node.js
|
||||
* download file name.
|
||||
*/
|
||||
export function getNodeArch(arch) {
|
||||
if (arch === 'arm') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
switch (process.config.variables.arm_version) {
|
||||
case '6':
|
||||
return uname();
|
||||
case '7':
|
||||
default:
|
||||
return 'armv7l';
|
||||
}
|
||||
}
|
||||
return arch;
|
||||
}
|
||||
/**
|
||||
* Generates an architecture name that would be used in an Electron or Node.js
|
||||
* download file name, from the `process` module information.
|
||||
*/
|
||||
export function getHostArch() {
|
||||
return getNodeArch(process.arch);
|
||||
}
|
||||
export function ensureIsTruthyString(obj, key) {
|
||||
if (!obj[key] || typeof obj[key] !== 'string') {
|
||||
throw new Error(`Expected property "${key}" to be provided as a string but it was not`);
|
||||
}
|
||||
}
|
||||
export function isOfficialLinuxIA32Download(platform, arch, version, mirrorOptions) {
|
||||
return (platform === 'linux' &&
|
||||
arch === 'ia32' &&
|
||||
Number(version.slice(1).split('.')[0]) >= 4 &&
|
||||
typeof mirrorOptions === 'undefined');
|
||||
}
|
||||
/**
|
||||
* Find the value of a environment variable which may or may not have the
|
||||
* prefix, in a case-insensitive manner.
|
||||
*/
|
||||
export function getEnv(prefix = '') {
|
||||
const envsLowerCase = {};
|
||||
for (const envKey in process.env) {
|
||||
envsLowerCase[envKey.toLowerCase()] = process.env[envKey];
|
||||
}
|
||||
return (name) => {
|
||||
return (envsLowerCase[`${prefix}${name}`.toLowerCase()] ||
|
||||
envsLowerCase[name.toLowerCase()] ||
|
||||
undefined);
|
||||
};
|
||||
}
|
||||
export function setEnv(key, value) {
|
||||
// The `void` operator always returns `undefined`.
|
||||
// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void
|
||||
if (value !== void 0) {
|
||||
process.env[key] = value;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=utils.js.map
|
||||
1
node_modules/@electron/get/dist/esm/utils.js.map
generated
vendored
Normal file
1
node_modules/@electron/get/dist/esm/utils.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,KAAK,UAAU,qBAAqB,CAClC,SAAiB,EACjB,EAAqC;IAErC,IAAI,MAAS,CAAC;IACd,IAAI;QACF,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC;KAC9B;YAAS;QACR,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;KAC5B;IACD,OAAO,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modules/@electron/get/node_modules/.bin/semver
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../../../../semver/bin/semver.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../../../../semver/bin/semver.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
7
node_modules/@electron/get/node_modules/.bin/semver.cmd
generated
vendored
Normal file
7
node_modules/@electron/get/node_modules/.bin/semver.cmd
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\..\..\..\semver\bin\semver.js" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\..\..\..\semver\bin\semver.js" %*
|
||||
)
|
||||
100
node_modules/@electron/get/package.json
generated
vendored
Normal file
100
node_modules/@electron/get/package.json
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
{
|
||||
"name": "@electron/get",
|
||||
"version": "2.0.2",
|
||||
"description": "Utility for downloading artifacts from different versions of Electron",
|
||||
"main": "dist/cjs/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
"repository": "https://github.com/electron/get",
|
||||
"author": "Samuel Attard",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "tsc && tsc -p tsconfig.esm.json",
|
||||
"build:docs": "typedoc --out docs",
|
||||
"eslint": "eslint --ext .ts src test",
|
||||
"jest": "jest --coverage",
|
||||
"lint": "npm run prettier && npm run eslint",
|
||||
"prettier": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"prepublishOnly": "npm run build",
|
||||
"test": "npm run lint && npm run jest",
|
||||
"test:nonetwork": "npm run lint && npm run jest -- --testPathIgnorePatterns network.spec"
|
||||
},
|
||||
"files": [
|
||||
"dist/*",
|
||||
"README.md"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^4.1.1",
|
||||
"env-paths": "^2.2.0",
|
||||
"fs-extra": "^8.1.0",
|
||||
"got": "^11.8.5",
|
||||
"progress": "^2.0.3",
|
||||
"semver": "^6.2.0",
|
||||
"sumchecker": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@continuous-auth/semantic-release-npm": "^2.0.0",
|
||||
"@types/debug": "^4.1.4",
|
||||
"@types/fs-extra": "^8.0.0",
|
||||
"@types/jest": "^24.0.13",
|
||||
"@types/node": "^12.20.55",
|
||||
"@types/progress": "^2.0.3",
|
||||
"@types/semver": "^6.2.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
||||
"@typescript-eslint/parser": "^2.34.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.15.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-jest": "< 24.0.0",
|
||||
"husky": "^2.3.0",
|
||||
"jest": "^24.8.0",
|
||||
"lint-staged": "^8.1.7",
|
||||
"prettier": "^1.17.1",
|
||||
"ts-jest": "^24.0.0",
|
||||
"typedoc": "^0.17.2",
|
||||
"typescript": "^3.8.0"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:jest/recommended",
|
||||
"plugin:import/errors",
|
||||
"plugin:import/warnings",
|
||||
"plugin:import/typescript",
|
||||
"prettier",
|
||||
"prettier/@typescript-eslint"
|
||||
]
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.ts": [
|
||||
"eslint --fix",
|
||||
"prettier --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"keywords": [
|
||||
"electron",
|
||||
"download",
|
||||
"prebuild",
|
||||
"get",
|
||||
"artifact",
|
||||
"release"
|
||||
],
|
||||
"optionalDependencies": {
|
||||
"global-agent": "^3.0.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"eslint/inquirer": "< 7.3.0",
|
||||
"**/@typescript-eslint/typescript-estree/semver": "^6.3.0"
|
||||
}
|
||||
}
|
||||
232
node_modules/@sindresorhus/is/dist/index.d.ts
generated
vendored
Normal file
232
node_modules/@sindresorhus/is/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference lib="es2018" />
|
||||
/// <reference lib="dom" />
|
||||
import { Class, Falsy, TypedArray, ObservableLike, Primitive } from './types';
|
||||
declare const objectTypeNames: readonly ["Function", "Generator", "AsyncGenerator", "GeneratorFunction", "AsyncGeneratorFunction", "AsyncFunction", "Observable", "Array", "Buffer", "Blob", "Object", "RegExp", "Date", "Error", "Map", "Set", "WeakMap", "WeakSet", "ArrayBuffer", "SharedArrayBuffer", "DataView", "Promise", "URL", "FormData", "URLSearchParams", "HTMLElement", ...("Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array")[]];
|
||||
declare type ObjectTypeName = typeof objectTypeNames[number];
|
||||
declare const primitiveTypeNames: readonly ["null", "undefined", "string", "number", "bigint", "boolean", "symbol"];
|
||||
declare type PrimitiveTypeName = typeof primitiveTypeNames[number];
|
||||
export declare type TypeName = ObjectTypeName | PrimitiveTypeName;
|
||||
declare function is(value: unknown): TypeName;
|
||||
declare namespace is {
|
||||
var undefined: (value: unknown) => value is undefined;
|
||||
var string: (value: unknown) => value is string;
|
||||
var number: (value: unknown) => value is number;
|
||||
var bigint: (value: unknown) => value is bigint;
|
||||
var function_: (value: unknown) => value is Function;
|
||||
var null_: (value: unknown) => value is null;
|
||||
var class_: (value: unknown) => value is Class<unknown, any[]>;
|
||||
var boolean: (value: unknown) => value is boolean;
|
||||
var symbol: (value: unknown) => value is symbol;
|
||||
var numericString: (value: unknown) => value is string;
|
||||
var array: <T = unknown>(value: unknown, assertion?: ((value: T) => value is T) | undefined) => value is T[];
|
||||
var buffer: (value: unknown) => value is Buffer;
|
||||
var blob: (value: unknown) => value is Blob;
|
||||
var nullOrUndefined: (value: unknown) => value is null | undefined;
|
||||
var object: (value: unknown) => value is object;
|
||||
var iterable: <T = unknown>(value: unknown) => value is Iterable<T>;
|
||||
var asyncIterable: <T = unknown>(value: unknown) => value is AsyncIterable<T>;
|
||||
var generator: (value: unknown) => value is Generator<unknown, any, unknown>;
|
||||
var asyncGenerator: (value: unknown) => value is AsyncGenerator<unknown, any, unknown>;
|
||||
var nativePromise: <T = unknown>(value: unknown) => value is Promise<T>;
|
||||
var promise: <T = unknown>(value: unknown) => value is Promise<T>;
|
||||
var generatorFunction: (value: unknown) => value is GeneratorFunction;
|
||||
var asyncGeneratorFunction: (value: unknown) => value is (...args: any[]) => Promise<unknown>;
|
||||
var asyncFunction: <T = unknown>(value: unknown) => value is (...args: any[]) => Promise<T>;
|
||||
var boundFunction: (value: unknown) => value is Function;
|
||||
var regExp: (value: unknown) => value is RegExp;
|
||||
var date: (value: unknown) => value is Date;
|
||||
var error: (value: unknown) => value is Error;
|
||||
var map: <Key = unknown, Value = unknown>(value: unknown) => value is Map<Key, Value>;
|
||||
var set: <T = unknown>(value: unknown) => value is Set<T>;
|
||||
var weakMap: <Key extends object = object, Value = unknown>(value: unknown) => value is WeakMap<Key, Value>;
|
||||
var weakSet: (value: unknown) => value is WeakSet<object>;
|
||||
var int8Array: (value: unknown) => value is Int8Array;
|
||||
var uint8Array: (value: unknown) => value is Uint8Array;
|
||||
var uint8ClampedArray: (value: unknown) => value is Uint8ClampedArray;
|
||||
var int16Array: (value: unknown) => value is Int16Array;
|
||||
var uint16Array: (value: unknown) => value is Uint16Array;
|
||||
var int32Array: (value: unknown) => value is Int32Array;
|
||||
var uint32Array: (value: unknown) => value is Uint32Array;
|
||||
var float32Array: (value: unknown) => value is Float32Array;
|
||||
var float64Array: (value: unknown) => value is Float64Array;
|
||||
var bigInt64Array: (value: unknown) => value is BigInt64Array;
|
||||
var bigUint64Array: (value: unknown) => value is BigUint64Array;
|
||||
var arrayBuffer: (value: unknown) => value is ArrayBuffer;
|
||||
var sharedArrayBuffer: (value: unknown) => value is SharedArrayBuffer;
|
||||
var dataView: (value: unknown) => value is DataView;
|
||||
var enumCase: <T = unknown>(value: unknown, targetEnum: T) => boolean;
|
||||
var directInstanceOf: <T>(instance: unknown, class_: Class<T, any[]>) => instance is T;
|
||||
var urlInstance: (value: unknown) => value is URL;
|
||||
var urlString: (value: unknown) => value is string;
|
||||
var truthy: <T>(value: false | "" | 0 | 0n | T | null | undefined) => value is T;
|
||||
var falsy: <T>(value: false | "" | 0 | 0n | T | null | undefined) => value is Falsy;
|
||||
var nan: (value: unknown) => boolean;
|
||||
var primitive: (value: unknown) => value is Primitive;
|
||||
var integer: (value: unknown) => value is number;
|
||||
var safeInteger: (value: unknown) => value is number;
|
||||
var plainObject: <Value = unknown>(value: unknown) => value is Record<string | number | symbol, Value>;
|
||||
var typedArray: (value: unknown) => value is TypedArray;
|
||||
var arrayLike: <T = unknown>(value: unknown) => value is ArrayLike<T>;
|
||||
var inRange: (value: number, range: number | number[]) => value is number;
|
||||
var domElement: (value: unknown) => value is HTMLElement;
|
||||
var observable: (value: unknown) => value is ObservableLike;
|
||||
var nodeStream: (value: unknown) => value is NodeStream;
|
||||
var infinite: (value: unknown) => value is number;
|
||||
var evenInteger: (value: number) => value is number;
|
||||
var oddInteger: (value: number) => value is number;
|
||||
var emptyArray: (value: unknown) => value is never[];
|
||||
var nonEmptyArray: (value: unknown) => value is unknown[];
|
||||
var emptyString: (value: unknown) => value is "";
|
||||
var emptyStringOrWhitespace: (value: unknown) => value is string;
|
||||
var nonEmptyString: (value: unknown) => value is string;
|
||||
var nonEmptyStringAndNotWhitespace: (value: unknown) => value is string;
|
||||
var emptyObject: <Key extends string | number | symbol = string>(value: unknown) => value is Record<Key, never>;
|
||||
var nonEmptyObject: <Key extends string | number | symbol = string, Value = unknown>(value: unknown) => value is Record<Key, Value>;
|
||||
var emptySet: (value: unknown) => value is Set<never>;
|
||||
var nonEmptySet: <T = unknown>(value: unknown) => value is Set<T>;
|
||||
var emptyMap: (value: unknown) => value is Map<never, never>;
|
||||
var nonEmptyMap: <Key = unknown, Value = unknown>(value: unknown) => value is Map<Key, Value>;
|
||||
var propertyKey: (value: unknown) => value is string | number | symbol;
|
||||
var formData: (value: unknown) => value is FormData;
|
||||
var urlSearchParams: (value: unknown) => value is URLSearchParams;
|
||||
var any: (predicate: Predicate | Predicate[], ...values: unknown[]) => boolean;
|
||||
var all: (predicate: Predicate, ...values: unknown[]) => boolean;
|
||||
}
|
||||
export interface ArrayLike<T> {
|
||||
readonly [index: number]: T;
|
||||
readonly length: number;
|
||||
}
|
||||
export interface NodeStream extends NodeJS.EventEmitter {
|
||||
pipe<T extends NodeJS.WritableStream>(destination: T, options?: {
|
||||
end?: boolean;
|
||||
}): T;
|
||||
}
|
||||
export declare type Predicate = (value: unknown) => boolean;
|
||||
export declare const enum AssertionTypeDescription {
|
||||
class_ = "Class",
|
||||
numericString = "string with a number",
|
||||
nullOrUndefined = "null or undefined",
|
||||
iterable = "Iterable",
|
||||
asyncIterable = "AsyncIterable",
|
||||
nativePromise = "native Promise",
|
||||
urlString = "string with a URL",
|
||||
truthy = "truthy",
|
||||
falsy = "falsy",
|
||||
nan = "NaN",
|
||||
primitive = "primitive",
|
||||
integer = "integer",
|
||||
safeInteger = "integer",
|
||||
plainObject = "plain object",
|
||||
arrayLike = "array-like",
|
||||
typedArray = "TypedArray",
|
||||
domElement = "HTMLElement",
|
||||
nodeStream = "Node.js Stream",
|
||||
infinite = "infinite number",
|
||||
emptyArray = "empty array",
|
||||
nonEmptyArray = "non-empty array",
|
||||
emptyString = "empty string",
|
||||
emptyStringOrWhitespace = "empty string or whitespace",
|
||||
nonEmptyString = "non-empty string",
|
||||
nonEmptyStringAndNotWhitespace = "non-empty string and not whitespace",
|
||||
emptyObject = "empty object",
|
||||
nonEmptyObject = "non-empty object",
|
||||
emptySet = "empty set",
|
||||
nonEmptySet = "non-empty set",
|
||||
emptyMap = "empty map",
|
||||
nonEmptyMap = "non-empty map",
|
||||
evenInteger = "even integer",
|
||||
oddInteger = "odd integer",
|
||||
directInstanceOf = "T",
|
||||
inRange = "in range",
|
||||
any = "predicate returns truthy for any value",
|
||||
all = "predicate returns truthy for all values"
|
||||
}
|
||||
interface Assert {
|
||||
undefined: (value: unknown) => asserts value is undefined;
|
||||
string: (value: unknown) => asserts value is string;
|
||||
number: (value: unknown) => asserts value is number;
|
||||
bigint: (value: unknown) => asserts value is bigint;
|
||||
function_: (value: unknown) => asserts value is Function;
|
||||
null_: (value: unknown) => asserts value is null;
|
||||
class_: (value: unknown) => asserts value is Class;
|
||||
boolean: (value: unknown) => asserts value is boolean;
|
||||
symbol: (value: unknown) => asserts value is symbol;
|
||||
numericString: (value: unknown) => asserts value is string;
|
||||
array: <T = unknown>(value: unknown, assertion?: (element: unknown) => asserts element is T) => asserts value is T[];
|
||||
buffer: (value: unknown) => asserts value is Buffer;
|
||||
blob: (value: unknown) => asserts value is Blob;
|
||||
nullOrUndefined: (value: unknown) => asserts value is null | undefined;
|
||||
object: <Key extends keyof any = string, Value = unknown>(value: unknown) => asserts value is Record<Key, Value>;
|
||||
iterable: <T = unknown>(value: unknown) => asserts value is Iterable<T>;
|
||||
asyncIterable: <T = unknown>(value: unknown) => asserts value is AsyncIterable<T>;
|
||||
generator: (value: unknown) => asserts value is Generator;
|
||||
asyncGenerator: (value: unknown) => asserts value is AsyncGenerator;
|
||||
nativePromise: <T = unknown>(value: unknown) => asserts value is Promise<T>;
|
||||
promise: <T = unknown>(value: unknown) => asserts value is Promise<T>;
|
||||
generatorFunction: (value: unknown) => asserts value is GeneratorFunction;
|
||||
asyncGeneratorFunction: (value: unknown) => asserts value is AsyncGeneratorFunction;
|
||||
asyncFunction: (value: unknown) => asserts value is Function;
|
||||
boundFunction: (value: unknown) => asserts value is Function;
|
||||
regExp: (value: unknown) => asserts value is RegExp;
|
||||
date: (value: unknown) => asserts value is Date;
|
||||
error: (value: unknown) => asserts value is Error;
|
||||
map: <Key = unknown, Value = unknown>(value: unknown) => asserts value is Map<Key, Value>;
|
||||
set: <T = unknown>(value: unknown) => asserts value is Set<T>;
|
||||
weakMap: <Key extends object = object, Value = unknown>(value: unknown) => asserts value is WeakMap<Key, Value>;
|
||||
weakSet: <T extends object = object>(value: unknown) => asserts value is WeakSet<T>;
|
||||
int8Array: (value: unknown) => asserts value is Int8Array;
|
||||
uint8Array: (value: unknown) => asserts value is Uint8Array;
|
||||
uint8ClampedArray: (value: unknown) => asserts value is Uint8ClampedArray;
|
||||
int16Array: (value: unknown) => asserts value is Int16Array;
|
||||
uint16Array: (value: unknown) => asserts value is Uint16Array;
|
||||
int32Array: (value: unknown) => asserts value is Int32Array;
|
||||
uint32Array: (value: unknown) => asserts value is Uint32Array;
|
||||
float32Array: (value: unknown) => asserts value is Float32Array;
|
||||
float64Array: (value: unknown) => asserts value is Float64Array;
|
||||
bigInt64Array: (value: unknown) => asserts value is BigInt64Array;
|
||||
bigUint64Array: (value: unknown) => asserts value is BigUint64Array;
|
||||
arrayBuffer: (value: unknown) => asserts value is ArrayBuffer;
|
||||
sharedArrayBuffer: (value: unknown) => asserts value is SharedArrayBuffer;
|
||||
dataView: (value: unknown) => asserts value is DataView;
|
||||
enumCase: <T = unknown>(value: unknown, targetEnum: T) => asserts value is T[keyof T];
|
||||
urlInstance: (value: unknown) => asserts value is URL;
|
||||
urlString: (value: unknown) => asserts value is string;
|
||||
truthy: (value: unknown) => asserts value is unknown;
|
||||
falsy: (value: unknown) => asserts value is unknown;
|
||||
nan: (value: unknown) => asserts value is unknown;
|
||||
primitive: (value: unknown) => asserts value is Primitive;
|
||||
integer: (value: unknown) => asserts value is number;
|
||||
safeInteger: (value: unknown) => asserts value is number;
|
||||
plainObject: <Value = unknown>(value: unknown) => asserts value is Record<PropertyKey, Value>;
|
||||
typedArray: (value: unknown) => asserts value is TypedArray;
|
||||
arrayLike: <T = unknown>(value: unknown) => asserts value is ArrayLike<T>;
|
||||
domElement: (value: unknown) => asserts value is HTMLElement;
|
||||
observable: (value: unknown) => asserts value is ObservableLike;
|
||||
nodeStream: (value: unknown) => asserts value is NodeStream;
|
||||
infinite: (value: unknown) => asserts value is number;
|
||||
emptyArray: (value: unknown) => asserts value is never[];
|
||||
nonEmptyArray: (value: unknown) => asserts value is unknown[];
|
||||
emptyString: (value: unknown) => asserts value is '';
|
||||
emptyStringOrWhitespace: (value: unknown) => asserts value is string;
|
||||
nonEmptyString: (value: unknown) => asserts value is string;
|
||||
nonEmptyStringAndNotWhitespace: (value: unknown) => asserts value is string;
|
||||
emptyObject: <Key extends keyof any = string>(value: unknown) => asserts value is Record<Key, never>;
|
||||
nonEmptyObject: <Key extends keyof any = string, Value = unknown>(value: unknown) => asserts value is Record<Key, Value>;
|
||||
emptySet: (value: unknown) => asserts value is Set<never>;
|
||||
nonEmptySet: <T = unknown>(value: unknown) => asserts value is Set<T>;
|
||||
emptyMap: (value: unknown) => asserts value is Map<never, never>;
|
||||
nonEmptyMap: <Key = unknown, Value = unknown>(value: unknown) => asserts value is Map<Key, Value>;
|
||||
propertyKey: (value: unknown) => asserts value is PropertyKey;
|
||||
formData: (value: unknown) => asserts value is FormData;
|
||||
urlSearchParams: (value: unknown) => asserts value is URLSearchParams;
|
||||
evenInteger: (value: number) => asserts value is number;
|
||||
oddInteger: (value: number) => asserts value is number;
|
||||
directInstanceOf: <T>(instance: unknown, class_: Class<T>) => asserts instance is T;
|
||||
inRange: (value: number, range: number | number[]) => asserts value is number;
|
||||
any: (predicate: Predicate | Predicate[], ...values: unknown[]) => void | never;
|
||||
all: (predicate: Predicate, ...values: unknown[]) => void | never;
|
||||
}
|
||||
export declare const assert: Assert;
|
||||
export default is;
|
||||
export { Class, TypedArray, ObservableLike, Primitive } from './types';
|
||||
434
node_modules/@sindresorhus/is/dist/index.js
generated
vendored
Normal file
434
node_modules/@sindresorhus/is/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,434 @@
|
||||
"use strict";
|
||||
/// <reference lib="es2018"/>
|
||||
/// <reference lib="dom"/>
|
||||
/// <reference types="node"/>
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const typedArrayTypeNames = [
|
||||
'Int8Array',
|
||||
'Uint8Array',
|
||||
'Uint8ClampedArray',
|
||||
'Int16Array',
|
||||
'Uint16Array',
|
||||
'Int32Array',
|
||||
'Uint32Array',
|
||||
'Float32Array',
|
||||
'Float64Array',
|
||||
'BigInt64Array',
|
||||
'BigUint64Array'
|
||||
];
|
||||
function isTypedArrayName(name) {
|
||||
return typedArrayTypeNames.includes(name);
|
||||
}
|
||||
const objectTypeNames = [
|
||||
'Function',
|
||||
'Generator',
|
||||
'AsyncGenerator',
|
||||
'GeneratorFunction',
|
||||
'AsyncGeneratorFunction',
|
||||
'AsyncFunction',
|
||||
'Observable',
|
||||
'Array',
|
||||
'Buffer',
|
||||
'Blob',
|
||||
'Object',
|
||||
'RegExp',
|
||||
'Date',
|
||||
'Error',
|
||||
'Map',
|
||||
'Set',
|
||||
'WeakMap',
|
||||
'WeakSet',
|
||||
'ArrayBuffer',
|
||||
'SharedArrayBuffer',
|
||||
'DataView',
|
||||
'Promise',
|
||||
'URL',
|
||||
'FormData',
|
||||
'URLSearchParams',
|
||||
'HTMLElement',
|
||||
...typedArrayTypeNames
|
||||
];
|
||||
function isObjectTypeName(name) {
|
||||
return objectTypeNames.includes(name);
|
||||
}
|
||||
const primitiveTypeNames = [
|
||||
'null',
|
||||
'undefined',
|
||||
'string',
|
||||
'number',
|
||||
'bigint',
|
||||
'boolean',
|
||||
'symbol'
|
||||
];
|
||||
function isPrimitiveTypeName(name) {
|
||||
return primitiveTypeNames.includes(name);
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
function isOfType(type) {
|
||||
return (value) => typeof value === type;
|
||||
}
|
||||
const { toString } = Object.prototype;
|
||||
const getObjectType = (value) => {
|
||||
const objectTypeName = toString.call(value).slice(8, -1);
|
||||
if (/HTML\w+Element/.test(objectTypeName) && is.domElement(value)) {
|
||||
return 'HTMLElement';
|
||||
}
|
||||
if (isObjectTypeName(objectTypeName)) {
|
||||
return objectTypeName;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
const isObjectOfType = (type) => (value) => getObjectType(value) === type;
|
||||
function is(value) {
|
||||
if (value === null) {
|
||||
return 'null';
|
||||
}
|
||||
switch (typeof value) {
|
||||
case 'undefined':
|
||||
return 'undefined';
|
||||
case 'string':
|
||||
return 'string';
|
||||
case 'number':
|
||||
return 'number';
|
||||
case 'boolean':
|
||||
return 'boolean';
|
||||
case 'function':
|
||||
return 'Function';
|
||||
case 'bigint':
|
||||
return 'bigint';
|
||||
case 'symbol':
|
||||
return 'symbol';
|
||||
default:
|
||||
}
|
||||
if (is.observable(value)) {
|
||||
return 'Observable';
|
||||
}
|
||||
if (is.array(value)) {
|
||||
return 'Array';
|
||||
}
|
||||
if (is.buffer(value)) {
|
||||
return 'Buffer';
|
||||
}
|
||||
const tagType = getObjectType(value);
|
||||
if (tagType) {
|
||||
return tagType;
|
||||
}
|
||||
if (value instanceof String || value instanceof Boolean || value instanceof Number) {
|
||||
throw new TypeError('Please don\'t use object wrappers for primitive types');
|
||||
}
|
||||
return 'Object';
|
||||
}
|
||||
is.undefined = isOfType('undefined');
|
||||
is.string = isOfType('string');
|
||||
const isNumberType = isOfType('number');
|
||||
is.number = (value) => isNumberType(value) && !is.nan(value);
|
||||
is.bigint = isOfType('bigint');
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
is.function_ = isOfType('function');
|
||||
is.null_ = (value) => value === null;
|
||||
is.class_ = (value) => is.function_(value) && value.toString().startsWith('class ');
|
||||
is.boolean = (value) => value === true || value === false;
|
||||
is.symbol = isOfType('symbol');
|
||||
is.numericString = (value) => is.string(value) && !is.emptyStringOrWhitespace(value) && !Number.isNaN(Number(value));
|
||||
is.array = (value, assertion) => {
|
||||
if (!Array.isArray(value)) {
|
||||
return false;
|
||||
}
|
||||
if (!is.function_(assertion)) {
|
||||
return true;
|
||||
}
|
||||
return value.every(assertion);
|
||||
};
|
||||
is.buffer = (value) => { var _a, _b, _c, _d; return (_d = (_c = (_b = (_a = value) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.isBuffer) === null || _c === void 0 ? void 0 : _c.call(_b, value)) !== null && _d !== void 0 ? _d : false; };
|
||||
is.blob = (value) => isObjectOfType('Blob')(value);
|
||||
is.nullOrUndefined = (value) => is.null_(value) || is.undefined(value);
|
||||
is.object = (value) => !is.null_(value) && (typeof value === 'object' || is.function_(value));
|
||||
is.iterable = (value) => { var _a; return is.function_((_a = value) === null || _a === void 0 ? void 0 : _a[Symbol.iterator]); };
|
||||
is.asyncIterable = (value) => { var _a; return is.function_((_a = value) === null || _a === void 0 ? void 0 : _a[Symbol.asyncIterator]); };
|
||||
is.generator = (value) => { var _a, _b; return is.iterable(value) && is.function_((_a = value) === null || _a === void 0 ? void 0 : _a.next) && is.function_((_b = value) === null || _b === void 0 ? void 0 : _b.throw); };
|
||||
is.asyncGenerator = (value) => is.asyncIterable(value) && is.function_(value.next) && is.function_(value.throw);
|
||||
is.nativePromise = (value) => isObjectOfType('Promise')(value);
|
||||
const hasPromiseAPI = (value) => {
|
||||
var _a, _b;
|
||||
return is.function_((_a = value) === null || _a === void 0 ? void 0 : _a.then) &&
|
||||
is.function_((_b = value) === null || _b === void 0 ? void 0 : _b.catch);
|
||||
};
|
||||
is.promise = (value) => is.nativePromise(value) || hasPromiseAPI(value);
|
||||
is.generatorFunction = isObjectOfType('GeneratorFunction');
|
||||
is.asyncGeneratorFunction = (value) => getObjectType(value) === 'AsyncGeneratorFunction';
|
||||
is.asyncFunction = (value) => getObjectType(value) === 'AsyncFunction';
|
||||
// eslint-disable-next-line no-prototype-builtins, @typescript-eslint/ban-types
|
||||
is.boundFunction = (value) => is.function_(value) && !value.hasOwnProperty('prototype');
|
||||
is.regExp = isObjectOfType('RegExp');
|
||||
is.date = isObjectOfType('Date');
|
||||
is.error = isObjectOfType('Error');
|
||||
is.map = (value) => isObjectOfType('Map')(value);
|
||||
is.set = (value) => isObjectOfType('Set')(value);
|
||||
is.weakMap = (value) => isObjectOfType('WeakMap')(value);
|
||||
is.weakSet = (value) => isObjectOfType('WeakSet')(value);
|
||||
is.int8Array = isObjectOfType('Int8Array');
|
||||
is.uint8Array = isObjectOfType('Uint8Array');
|
||||
is.uint8ClampedArray = isObjectOfType('Uint8ClampedArray');
|
||||
is.int16Array = isObjectOfType('Int16Array');
|
||||
is.uint16Array = isObjectOfType('Uint16Array');
|
||||
is.int32Array = isObjectOfType('Int32Array');
|
||||
is.uint32Array = isObjectOfType('Uint32Array');
|
||||
is.float32Array = isObjectOfType('Float32Array');
|
||||
is.float64Array = isObjectOfType('Float64Array');
|
||||
is.bigInt64Array = isObjectOfType('BigInt64Array');
|
||||
is.bigUint64Array = isObjectOfType('BigUint64Array');
|
||||
is.arrayBuffer = isObjectOfType('ArrayBuffer');
|
||||
is.sharedArrayBuffer = isObjectOfType('SharedArrayBuffer');
|
||||
is.dataView = isObjectOfType('DataView');
|
||||
is.enumCase = (value, targetEnum) => Object.values(targetEnum).includes(value);
|
||||
is.directInstanceOf = (instance, class_) => Object.getPrototypeOf(instance) === class_.prototype;
|
||||
is.urlInstance = (value) => isObjectOfType('URL')(value);
|
||||
is.urlString = (value) => {
|
||||
if (!is.string(value)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
new URL(value); // eslint-disable-line no-new
|
||||
return true;
|
||||
}
|
||||
catch (_a) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
// Example: `is.truthy = (value: unknown): value is (not false | not 0 | not '' | not undefined | not null) => Boolean(value);`
|
||||
is.truthy = (value) => Boolean(value);
|
||||
// Example: `is.falsy = (value: unknown): value is (not true | 0 | '' | undefined | null) => Boolean(value);`
|
||||
is.falsy = (value) => !value;
|
||||
is.nan = (value) => Number.isNaN(value);
|
||||
is.primitive = (value) => is.null_(value) || isPrimitiveTypeName(typeof value);
|
||||
is.integer = (value) => Number.isInteger(value);
|
||||
is.safeInteger = (value) => Number.isSafeInteger(value);
|
||||
is.plainObject = (value) => {
|
||||
// From: https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
|
||||
if (toString.call(value) !== '[object Object]') {
|
||||
return false;
|
||||
}
|
||||
const prototype = Object.getPrototypeOf(value);
|
||||
return prototype === null || prototype === Object.getPrototypeOf({});
|
||||
};
|
||||
is.typedArray = (value) => isTypedArrayName(getObjectType(value));
|
||||
const isValidLength = (value) => is.safeInteger(value) && value >= 0;
|
||||
is.arrayLike = (value) => !is.nullOrUndefined(value) && !is.function_(value) && isValidLength(value.length);
|
||||
is.inRange = (value, range) => {
|
||||
if (is.number(range)) {
|
||||
return value >= Math.min(0, range) && value <= Math.max(range, 0);
|
||||
}
|
||||
if (is.array(range) && range.length === 2) {
|
||||
return value >= Math.min(...range) && value <= Math.max(...range);
|
||||
}
|
||||
throw new TypeError(`Invalid range: ${JSON.stringify(range)}`);
|
||||
};
|
||||
const NODE_TYPE_ELEMENT = 1;
|
||||
const DOM_PROPERTIES_TO_CHECK = [
|
||||
'innerHTML',
|
||||
'ownerDocument',
|
||||
'style',
|
||||
'attributes',
|
||||
'nodeValue'
|
||||
];
|
||||
is.domElement = (value) => {
|
||||
return is.object(value) &&
|
||||
value.nodeType === NODE_TYPE_ELEMENT &&
|
||||
is.string(value.nodeName) &&
|
||||
!is.plainObject(value) &&
|
||||
DOM_PROPERTIES_TO_CHECK.every(property => property in value);
|
||||
};
|
||||
is.observable = (value) => {
|
||||
var _a, _b, _c, _d;
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
// eslint-disable-next-line no-use-extend-native/no-use-extend-native
|
||||
if (value === ((_b = (_a = value)[Symbol.observable]) === null || _b === void 0 ? void 0 : _b.call(_a))) {
|
||||
return true;
|
||||
}
|
||||
if (value === ((_d = (_c = value)['@@observable']) === null || _d === void 0 ? void 0 : _d.call(_c))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
is.nodeStream = (value) => is.object(value) && is.function_(value.pipe) && !is.observable(value);
|
||||
is.infinite = (value) => value === Infinity || value === -Infinity;
|
||||
const isAbsoluteMod2 = (remainder) => (value) => is.integer(value) && Math.abs(value % 2) === remainder;
|
||||
is.evenInteger = isAbsoluteMod2(0);
|
||||
is.oddInteger = isAbsoluteMod2(1);
|
||||
is.emptyArray = (value) => is.array(value) && value.length === 0;
|
||||
is.nonEmptyArray = (value) => is.array(value) && value.length > 0;
|
||||
is.emptyString = (value) => is.string(value) && value.length === 0;
|
||||
const isWhiteSpaceString = (value) => is.string(value) && !/\S/.test(value);
|
||||
is.emptyStringOrWhitespace = (value) => is.emptyString(value) || isWhiteSpaceString(value);
|
||||
// TODO: Use `not ''` when the `not` operator is available.
|
||||
is.nonEmptyString = (value) => is.string(value) && value.length > 0;
|
||||
// TODO: Use `not ''` when the `not` operator is available.
|
||||
is.nonEmptyStringAndNotWhitespace = (value) => is.string(value) && !is.emptyStringOrWhitespace(value);
|
||||
is.emptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length === 0;
|
||||
// TODO: Use `not` operator here to remove `Map` and `Set` from type guard:
|
||||
// - https://github.com/Microsoft/TypeScript/pull/29317
|
||||
is.nonEmptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length > 0;
|
||||
is.emptySet = (value) => is.set(value) && value.size === 0;
|
||||
is.nonEmptySet = (value) => is.set(value) && value.size > 0;
|
||||
is.emptyMap = (value) => is.map(value) && value.size === 0;
|
||||
is.nonEmptyMap = (value) => is.map(value) && value.size > 0;
|
||||
// `PropertyKey` is any value that can be used as an object key (string, number, or symbol)
|
||||
is.propertyKey = (value) => is.any([is.string, is.number, is.symbol], value);
|
||||
is.formData = (value) => isObjectOfType('FormData')(value);
|
||||
is.urlSearchParams = (value) => isObjectOfType('URLSearchParams')(value);
|
||||
const predicateOnArray = (method, predicate, values) => {
|
||||
if (!is.function_(predicate)) {
|
||||
throw new TypeError(`Invalid predicate: ${JSON.stringify(predicate)}`);
|
||||
}
|
||||
if (values.length === 0) {
|
||||
throw new TypeError('Invalid number of values');
|
||||
}
|
||||
return method.call(values, predicate);
|
||||
};
|
||||
is.any = (predicate, ...values) => {
|
||||
const predicates = is.array(predicate) ? predicate : [predicate];
|
||||
return predicates.some(singlePredicate => predicateOnArray(Array.prototype.some, singlePredicate, values));
|
||||
};
|
||||
is.all = (predicate, ...values) => predicateOnArray(Array.prototype.every, predicate, values);
|
||||
const assertType = (condition, description, value, options = {}) => {
|
||||
if (!condition) {
|
||||
const { multipleValues } = options;
|
||||
const valuesMessage = multipleValues ?
|
||||
`received values of types ${[
|
||||
...new Set(value.map(singleValue => `\`${is(singleValue)}\``))
|
||||
].join(', ')}` :
|
||||
`received value of type \`${is(value)}\``;
|
||||
throw new TypeError(`Expected value which is \`${description}\`, ${valuesMessage}.`);
|
||||
}
|
||||
};
|
||||
exports.assert = {
|
||||
// Unknowns.
|
||||
undefined: (value) => assertType(is.undefined(value), 'undefined', value),
|
||||
string: (value) => assertType(is.string(value), 'string', value),
|
||||
number: (value) => assertType(is.number(value), 'number', value),
|
||||
bigint: (value) => assertType(is.bigint(value), 'bigint', value),
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
function_: (value) => assertType(is.function_(value), 'Function', value),
|
||||
null_: (value) => assertType(is.null_(value), 'null', value),
|
||||
class_: (value) => assertType(is.class_(value), "Class" /* class_ */, value),
|
||||
boolean: (value) => assertType(is.boolean(value), 'boolean', value),
|
||||
symbol: (value) => assertType(is.symbol(value), 'symbol', value),
|
||||
numericString: (value) => assertType(is.numericString(value), "string with a number" /* numericString */, value),
|
||||
array: (value, assertion) => {
|
||||
const assert = assertType;
|
||||
assert(is.array(value), 'Array', value);
|
||||
if (assertion) {
|
||||
value.forEach(assertion);
|
||||
}
|
||||
},
|
||||
buffer: (value) => assertType(is.buffer(value), 'Buffer', value),
|
||||
blob: (value) => assertType(is.blob(value), 'Blob', value),
|
||||
nullOrUndefined: (value) => assertType(is.nullOrUndefined(value), "null or undefined" /* nullOrUndefined */, value),
|
||||
object: (value) => assertType(is.object(value), 'Object', value),
|
||||
iterable: (value) => assertType(is.iterable(value), "Iterable" /* iterable */, value),
|
||||
asyncIterable: (value) => assertType(is.asyncIterable(value), "AsyncIterable" /* asyncIterable */, value),
|
||||
generator: (value) => assertType(is.generator(value), 'Generator', value),
|
||||
asyncGenerator: (value) => assertType(is.asyncGenerator(value), 'AsyncGenerator', value),
|
||||
nativePromise: (value) => assertType(is.nativePromise(value), "native Promise" /* nativePromise */, value),
|
||||
promise: (value) => assertType(is.promise(value), 'Promise', value),
|
||||
generatorFunction: (value) => assertType(is.generatorFunction(value), 'GeneratorFunction', value),
|
||||
asyncGeneratorFunction: (value) => assertType(is.asyncGeneratorFunction(value), 'AsyncGeneratorFunction', value),
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
asyncFunction: (value) => assertType(is.asyncFunction(value), 'AsyncFunction', value),
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
boundFunction: (value) => assertType(is.boundFunction(value), 'Function', value),
|
||||
regExp: (value) => assertType(is.regExp(value), 'RegExp', value),
|
||||
date: (value) => assertType(is.date(value), 'Date', value),
|
||||
error: (value) => assertType(is.error(value), 'Error', value),
|
||||
map: (value) => assertType(is.map(value), 'Map', value),
|
||||
set: (value) => assertType(is.set(value), 'Set', value),
|
||||
weakMap: (value) => assertType(is.weakMap(value), 'WeakMap', value),
|
||||
weakSet: (value) => assertType(is.weakSet(value), 'WeakSet', value),
|
||||
int8Array: (value) => assertType(is.int8Array(value), 'Int8Array', value),
|
||||
uint8Array: (value) => assertType(is.uint8Array(value), 'Uint8Array', value),
|
||||
uint8ClampedArray: (value) => assertType(is.uint8ClampedArray(value), 'Uint8ClampedArray', value),
|
||||
int16Array: (value) => assertType(is.int16Array(value), 'Int16Array', value),
|
||||
uint16Array: (value) => assertType(is.uint16Array(value), 'Uint16Array', value),
|
||||
int32Array: (value) => assertType(is.int32Array(value), 'Int32Array', value),
|
||||
uint32Array: (value) => assertType(is.uint32Array(value), 'Uint32Array', value),
|
||||
float32Array: (value) => assertType(is.float32Array(value), 'Float32Array', value),
|
||||
float64Array: (value) => assertType(is.float64Array(value), 'Float64Array', value),
|
||||
bigInt64Array: (value) => assertType(is.bigInt64Array(value), 'BigInt64Array', value),
|
||||
bigUint64Array: (value) => assertType(is.bigUint64Array(value), 'BigUint64Array', value),
|
||||
arrayBuffer: (value) => assertType(is.arrayBuffer(value), 'ArrayBuffer', value),
|
||||
sharedArrayBuffer: (value) => assertType(is.sharedArrayBuffer(value), 'SharedArrayBuffer', value),
|
||||
dataView: (value) => assertType(is.dataView(value), 'DataView', value),
|
||||
enumCase: (value, targetEnum) => assertType(is.enumCase(value, targetEnum), 'EnumCase', value),
|
||||
urlInstance: (value) => assertType(is.urlInstance(value), 'URL', value),
|
||||
urlString: (value) => assertType(is.urlString(value), "string with a URL" /* urlString */, value),
|
||||
truthy: (value) => assertType(is.truthy(value), "truthy" /* truthy */, value),
|
||||
falsy: (value) => assertType(is.falsy(value), "falsy" /* falsy */, value),
|
||||
nan: (value) => assertType(is.nan(value), "NaN" /* nan */, value),
|
||||
primitive: (value) => assertType(is.primitive(value), "primitive" /* primitive */, value),
|
||||
integer: (value) => assertType(is.integer(value), "integer" /* integer */, value),
|
||||
safeInteger: (value) => assertType(is.safeInteger(value), "integer" /* safeInteger */, value),
|
||||
plainObject: (value) => assertType(is.plainObject(value), "plain object" /* plainObject */, value),
|
||||
typedArray: (value) => assertType(is.typedArray(value), "TypedArray" /* typedArray */, value),
|
||||
arrayLike: (value) => assertType(is.arrayLike(value), "array-like" /* arrayLike */, value),
|
||||
domElement: (value) => assertType(is.domElement(value), "HTMLElement" /* domElement */, value),
|
||||
observable: (value) => assertType(is.observable(value), 'Observable', value),
|
||||
nodeStream: (value) => assertType(is.nodeStream(value), "Node.js Stream" /* nodeStream */, value),
|
||||
infinite: (value) => assertType(is.infinite(value), "infinite number" /* infinite */, value),
|
||||
emptyArray: (value) => assertType(is.emptyArray(value), "empty array" /* emptyArray */, value),
|
||||
nonEmptyArray: (value) => assertType(is.nonEmptyArray(value), "non-empty array" /* nonEmptyArray */, value),
|
||||
emptyString: (value) => assertType(is.emptyString(value), "empty string" /* emptyString */, value),
|
||||
emptyStringOrWhitespace: (value) => assertType(is.emptyStringOrWhitespace(value), "empty string or whitespace" /* emptyStringOrWhitespace */, value),
|
||||
nonEmptyString: (value) => assertType(is.nonEmptyString(value), "non-empty string" /* nonEmptyString */, value),
|
||||
nonEmptyStringAndNotWhitespace: (value) => assertType(is.nonEmptyStringAndNotWhitespace(value), "non-empty string and not whitespace" /* nonEmptyStringAndNotWhitespace */, value),
|
||||
emptyObject: (value) => assertType(is.emptyObject(value), "empty object" /* emptyObject */, value),
|
||||
nonEmptyObject: (value) => assertType(is.nonEmptyObject(value), "non-empty object" /* nonEmptyObject */, value),
|
||||
emptySet: (value) => assertType(is.emptySet(value), "empty set" /* emptySet */, value),
|
||||
nonEmptySet: (value) => assertType(is.nonEmptySet(value), "non-empty set" /* nonEmptySet */, value),
|
||||
emptyMap: (value) => assertType(is.emptyMap(value), "empty map" /* emptyMap */, value),
|
||||
nonEmptyMap: (value) => assertType(is.nonEmptyMap(value), "non-empty map" /* nonEmptyMap */, value),
|
||||
propertyKey: (value) => assertType(is.propertyKey(value), 'PropertyKey', value),
|
||||
formData: (value) => assertType(is.formData(value), 'FormData', value),
|
||||
urlSearchParams: (value) => assertType(is.urlSearchParams(value), 'URLSearchParams', value),
|
||||
// Numbers.
|
||||
evenInteger: (value) => assertType(is.evenInteger(value), "even integer" /* evenInteger */, value),
|
||||
oddInteger: (value) => assertType(is.oddInteger(value), "odd integer" /* oddInteger */, value),
|
||||
// Two arguments.
|
||||
directInstanceOf: (instance, class_) => assertType(is.directInstanceOf(instance, class_), "T" /* directInstanceOf */, instance),
|
||||
inRange: (value, range) => assertType(is.inRange(value, range), "in range" /* inRange */, value),
|
||||
// Variadic functions.
|
||||
any: (predicate, ...values) => {
|
||||
return assertType(is.any(predicate, ...values), "predicate returns truthy for any value" /* any */, values, { multipleValues: true });
|
||||
},
|
||||
all: (predicate, ...values) => assertType(is.all(predicate, ...values), "predicate returns truthy for all values" /* all */, values, { multipleValues: true })
|
||||
};
|
||||
// Some few keywords are reserved, but we'll populate them for Node.js users
|
||||
// See https://github.com/Microsoft/TypeScript/issues/2536
|
||||
Object.defineProperties(is, {
|
||||
class: {
|
||||
value: is.class_
|
||||
},
|
||||
function: {
|
||||
value: is.function_
|
||||
},
|
||||
null: {
|
||||
value: is.null_
|
||||
}
|
||||
});
|
||||
Object.defineProperties(exports.assert, {
|
||||
class: {
|
||||
value: exports.assert.class_
|
||||
},
|
||||
function: {
|
||||
value: exports.assert.function_
|
||||
},
|
||||
null: {
|
||||
value: exports.assert.null_
|
||||
}
|
||||
});
|
||||
exports.default = is;
|
||||
// For CommonJS default export support
|
||||
module.exports = is;
|
||||
module.exports.default = is;
|
||||
module.exports.assert = exports.assert;
|
||||
25
node_modules/@sindresorhus/is/dist/types.d.ts
generated
vendored
Normal file
25
node_modules/@sindresorhus/is/dist/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
||||
*/
|
||||
export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
||||
/**
|
||||
Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
||||
*/
|
||||
export declare type Class<T = unknown, Arguments extends any[] = any[]> = new (...arguments_: Arguments) => T;
|
||||
/**
|
||||
Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
|
||||
*/
|
||||
export declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
||||
declare global {
|
||||
interface SymbolConstructor {
|
||||
readonly observable: symbol;
|
||||
}
|
||||
}
|
||||
/**
|
||||
Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable).
|
||||
*/
|
||||
export interface ObservableLike {
|
||||
subscribe(observer: (value: unknown) => void): void;
|
||||
[Symbol.observable](): ObservableLike;
|
||||
}
|
||||
export declare type Falsy = false | 0 | 0n | '' | null | undefined;
|
||||
3
node_modules/@sindresorhus/is/dist/types.js
generated
vendored
Normal file
3
node_modules/@sindresorhus/is/dist/types.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
// Extracted from https://github.com/sindresorhus/type-fest/blob/78019f42ea888b0cdceb41a4a78163868de57555/index.d.ts
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
9
node_modules/@sindresorhus/is/license
generated
vendored
Normal file
9
node_modules/@sindresorhus/is/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
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.
|
||||
96
node_modules/@sindresorhus/is/package.json
generated
vendored
Normal file
96
node_modules/@sindresorhus/is/package.json
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"name": "@sindresorhus/is",
|
||||
"version": "4.6.0",
|
||||
"description": "Type check values",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/is",
|
||||
"funding": "https://github.com/sindresorhus/is?sponsor=1",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "del dist && tsc",
|
||||
"test": "xo && ava",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"keywords": [
|
||||
"type",
|
||||
"types",
|
||||
"is",
|
||||
"check",
|
||||
"checking",
|
||||
"validate",
|
||||
"validation",
|
||||
"utility",
|
||||
"util",
|
||||
"typeof",
|
||||
"instanceof",
|
||||
"object",
|
||||
"assert",
|
||||
"assertion",
|
||||
"test",
|
||||
"kind",
|
||||
"primitive",
|
||||
"verify",
|
||||
"compare",
|
||||
"typescript",
|
||||
"typeguards",
|
||||
"types"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@sindresorhus/tsconfig": "^0.7.0",
|
||||
"@types/jsdom": "^16.1.0",
|
||||
"@types/node": "^14.0.13",
|
||||
"@types/zen-observable": "^0.8.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.20.0",
|
||||
"@typescript-eslint/parser": "^2.20.0",
|
||||
"ava": "^3.3.0",
|
||||
"del-cli": "^2.0.0",
|
||||
"eslint-config-xo-typescript": "^0.26.0",
|
||||
"jsdom": "^16.0.1",
|
||||
"rxjs": "^6.4.0",
|
||||
"tempy": "^0.4.0",
|
||||
"ts-node": "^8.3.0",
|
||||
"typescript": "~3.8.2",
|
||||
"xo": "^0.26.1",
|
||||
"zen-observable": "^0.8.8"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"ava": {
|
||||
"extensions": [
|
||||
"ts"
|
||||
],
|
||||
"require": [
|
||||
"ts-node/register"
|
||||
]
|
||||
},
|
||||
"xo": {
|
||||
"extends": "xo-typescript",
|
||||
"extensions": [
|
||||
"ts"
|
||||
],
|
||||
"parserOptions": {
|
||||
"project": "./tsconfig.xo.json"
|
||||
},
|
||||
"globals": [
|
||||
"BigInt",
|
||||
"BigInt64Array",
|
||||
"BigUint64Array"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/promise-function-async": "off",
|
||||
"@typescript-eslint/no-empty-function": "off",
|
||||
"@typescript-eslint/explicit-function-return-type": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
669
node_modules/@sindresorhus/is/readme.md
generated
vendored
Normal file
669
node_modules/@sindresorhus/is/readme.md
generated
vendored
Normal file
@@ -0,0 +1,669 @@
|
||||
# is
|
||||
|
||||
> Type check values
|
||||
|
||||
For example, `is.string('🦄') //=> true`
|
||||
|
||||
<img src="header.gif" width="182" align="right">
|
||||
|
||||
## Highlights
|
||||
|
||||
- Written in TypeScript
|
||||
- [Extensive use of type guards](#type-guards)
|
||||
- [Supports type assertions](#type-assertions)
|
||||
- [Aware of generic type parameters](#generic-type-parameters) (use with caution)
|
||||
- Actively maintained
|
||||
- 
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install @sindresorhus/is
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const is = require('@sindresorhus/is');
|
||||
|
||||
is('🦄');
|
||||
//=> 'string'
|
||||
|
||||
is(new Map());
|
||||
//=> 'Map'
|
||||
|
||||
is.number(6);
|
||||
//=> true
|
||||
```
|
||||
|
||||
[Assertions](#type-assertions) perform the same type checks, but throw an error if the type does not match.
|
||||
|
||||
```js
|
||||
const {assert} = require('@sindresorhus/is');
|
||||
|
||||
assert.string(2);
|
||||
//=> Error: Expected value which is `string`, received value of type `number`.
|
||||
```
|
||||
|
||||
And with TypeScript:
|
||||
|
||||
```ts
|
||||
import {assert} from '@sindresorhus/is';
|
||||
|
||||
assert.string(foo);
|
||||
// `foo` is now typed as a `string`.
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### is(value)
|
||||
|
||||
Returns the type of `value`.
|
||||
|
||||
Primitives are lowercase and object types are camelcase.
|
||||
|
||||
Example:
|
||||
|
||||
- `'undefined'`
|
||||
- `'null'`
|
||||
- `'string'`
|
||||
- `'symbol'`
|
||||
- `'Array'`
|
||||
- `'Function'`
|
||||
- `'Object'`
|
||||
|
||||
Note: It will throw an error if you try to feed it object-wrapped primitives, as that's a bad practice. For example `new String('foo')`.
|
||||
|
||||
### is.{method}
|
||||
|
||||
All the below methods accept a value and returns a boolean for whether the value is of the desired type.
|
||||
|
||||
#### Primitives
|
||||
|
||||
##### .undefined(value)
|
||||
##### .null(value)
|
||||
|
||||
**Note:** TypeScript users must use `.null_()` because of a TypeScript naming limitation.
|
||||
|
||||
##### .string(value)
|
||||
##### .number(value)
|
||||
|
||||
Note: `is.number(NaN)` returns `false`. This intentionally deviates from `typeof` behavior to increase user-friendliness of `is` type checks.
|
||||
|
||||
##### .boolean(value)
|
||||
##### .symbol(value)
|
||||
##### .bigint(value)
|
||||
|
||||
#### Built-in types
|
||||
|
||||
##### .array(value, assertion?)
|
||||
|
||||
Returns true if `value` is an array and all of its items match the assertion (if provided).
|
||||
|
||||
```js
|
||||
is.array(value); // Validate `value` is an array.
|
||||
is.array(value, is.number); // Validate `value` is an array and all of its items are numbers.
|
||||
```
|
||||
|
||||
##### .function(value)
|
||||
|
||||
**Note:** TypeScript users must use `.function_()` because of a TypeScript naming limitation.
|
||||
|
||||
##### .buffer(value)
|
||||
##### .blob(value)
|
||||
##### .object(value)
|
||||
|
||||
Keep in mind that [functions are objects too](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions).
|
||||
|
||||
##### .numericString(value)
|
||||
|
||||
Returns `true` for a string that represents a number satisfying `is.number`, for example, `'42'` and `'-8.3'`.
|
||||
|
||||
Note: `'NaN'` returns `false`, but `'Infinity'` and `'-Infinity'` return `true`.
|
||||
|
||||
##### .regExp(value)
|
||||
##### .date(value)
|
||||
##### .error(value)
|
||||
##### .nativePromise(value)
|
||||
##### .promise(value)
|
||||
|
||||
Returns `true` for any object with a `.then()` and `.catch()` method. Prefer this one over `.nativePromise()` as you usually want to allow userland promise implementations too.
|
||||
|
||||
##### .generator(value)
|
||||
|
||||
Returns `true` for any object that implements its own `.next()` and `.throw()` methods and has a function definition for `Symbol.iterator`.
|
||||
|
||||
##### .generatorFunction(value)
|
||||
|
||||
##### .asyncFunction(value)
|
||||
|
||||
Returns `true` for any `async` function that can be called with the `await` operator.
|
||||
|
||||
```js
|
||||
is.asyncFunction(async () => {});
|
||||
//=> true
|
||||
|
||||
is.asyncFunction(() => {});
|
||||
//=> false
|
||||
```
|
||||
|
||||
##### .asyncGenerator(value)
|
||||
|
||||
```js
|
||||
is.asyncGenerator(
|
||||
(async function * () {
|
||||
yield 4;
|
||||
})()
|
||||
);
|
||||
//=> true
|
||||
|
||||
is.asyncGenerator(
|
||||
(function * () {
|
||||
yield 4;
|
||||
})()
|
||||
);
|
||||
//=> false
|
||||
```
|
||||
|
||||
##### .asyncGeneratorFunction(value)
|
||||
|
||||
```js
|
||||
is.asyncGeneratorFunction(async function * () {
|
||||
yield 4;
|
||||
});
|
||||
//=> true
|
||||
|
||||
is.asyncGeneratorFunction(function * () {
|
||||
yield 4;
|
||||
});
|
||||
//=> false
|
||||
```
|
||||
|
||||
##### .boundFunction(value)
|
||||
|
||||
Returns `true` for any `bound` function.
|
||||
|
||||
```js
|
||||
is.boundFunction(() => {});
|
||||
//=> true
|
||||
|
||||
is.boundFunction(function () {}.bind(null));
|
||||
//=> true
|
||||
|
||||
is.boundFunction(function () {});
|
||||
//=> false
|
||||
```
|
||||
|
||||
##### .map(value)
|
||||
##### .set(value)
|
||||
##### .weakMap(value)
|
||||
##### .weakSet(value)
|
||||
|
||||
#### Typed arrays
|
||||
|
||||
##### .int8Array(value)
|
||||
##### .uint8Array(value)
|
||||
##### .uint8ClampedArray(value)
|
||||
##### .int16Array(value)
|
||||
##### .uint16Array(value)
|
||||
##### .int32Array(value)
|
||||
##### .uint32Array(value)
|
||||
##### .float32Array(value)
|
||||
##### .float64Array(value)
|
||||
##### .bigInt64Array(value)
|
||||
##### .bigUint64Array(value)
|
||||
|
||||
#### Structured data
|
||||
|
||||
##### .arrayBuffer(value)
|
||||
##### .sharedArrayBuffer(value)
|
||||
##### .dataView(value)
|
||||
|
||||
##### .enumCase(value, enum)
|
||||
|
||||
TypeScript-only. Returns `true` if `value` is a member of `enum`.
|
||||
|
||||
```ts
|
||||
enum Direction {
|
||||
Ascending = 'ascending',
|
||||
Descending = 'descending'
|
||||
}
|
||||
|
||||
is.enumCase('ascending', Direction);
|
||||
//=> true
|
||||
|
||||
is.enumCase('other', Direction);
|
||||
//=> false
|
||||
```
|
||||
|
||||
#### Emptiness
|
||||
|
||||
##### .emptyString(value)
|
||||
|
||||
Returns `true` if the value is a `string` and the `.length` is 0.
|
||||
|
||||
##### .emptyStringOrWhitespace(value)
|
||||
|
||||
Returns `true` if `is.emptyString(value)` or if it's a `string` that is all whitespace.
|
||||
|
||||
##### .nonEmptyString(value)
|
||||
|
||||
Returns `true` if the value is a `string` and the `.length` is more than 0.
|
||||
|
||||
##### .nonEmptyStringAndNotWhitespace(value)
|
||||
|
||||
Returns `true` if the value is a `string` that is not empty and not whitespace.
|
||||
|
||||
```js
|
||||
const values = ['property1', '', null, 'property2', ' ', undefined];
|
||||
|
||||
values.filter(is.nonEmptyStringAndNotWhitespace);
|
||||
//=> ['property1', 'property2']
|
||||
```
|
||||
|
||||
##### .emptyArray(value)
|
||||
|
||||
Returns `true` if the value is an `Array` and the `.length` is 0.
|
||||
|
||||
##### .nonEmptyArray(value)
|
||||
|
||||
Returns `true` if the value is an `Array` and the `.length` is more than 0.
|
||||
|
||||
##### .emptyObject(value)
|
||||
|
||||
Returns `true` if the value is an `Object` and `Object.keys(value).length` is 0.
|
||||
|
||||
Please note that `Object.keys` returns only own enumerable properties. Hence something like this can happen:
|
||||
|
||||
```js
|
||||
const object1 = {};
|
||||
|
||||
Object.defineProperty(object1, 'property1', {
|
||||
value: 42,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
is.emptyObject(object1);
|
||||
//=> true
|
||||
```
|
||||
|
||||
##### .nonEmptyObject(value)
|
||||
|
||||
Returns `true` if the value is an `Object` and `Object.keys(value).length` is more than 0.
|
||||
|
||||
##### .emptySet(value)
|
||||
|
||||
Returns `true` if the value is a `Set` and the `.size` is 0.
|
||||
|
||||
##### .nonEmptySet(Value)
|
||||
|
||||
Returns `true` if the value is a `Set` and the `.size` is more than 0.
|
||||
|
||||
##### .emptyMap(value)
|
||||
|
||||
Returns `true` if the value is a `Map` and the `.size` is 0.
|
||||
|
||||
##### .nonEmptyMap(value)
|
||||
|
||||
Returns `true` if the value is a `Map` and the `.size` is more than 0.
|
||||
|
||||
#### Miscellaneous
|
||||
|
||||
##### .directInstanceOf(value, class)
|
||||
|
||||
Returns `true` if `value` is a direct instance of `class`.
|
||||
|
||||
```js
|
||||
is.directInstanceOf(new Error(), Error);
|
||||
//=> true
|
||||
|
||||
class UnicornError extends Error {}
|
||||
|
||||
is.directInstanceOf(new UnicornError(), Error);
|
||||
//=> false
|
||||
```
|
||||
|
||||
##### .urlInstance(value)
|
||||
|
||||
Returns `true` if `value` is an instance of the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL).
|
||||
|
||||
```js
|
||||
const url = new URL('https://example.com');
|
||||
|
||||
is.urlInstance(url);
|
||||
//=> true
|
||||
```
|
||||
|
||||
##### .urlString(value)
|
||||
|
||||
Returns `true` if `value` is a URL string.
|
||||
|
||||
Note: this only does basic checking using the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL) constructor.
|
||||
|
||||
```js
|
||||
const url = 'https://example.com';
|
||||
|
||||
is.urlString(url);
|
||||
//=> true
|
||||
|
||||
is.urlString(new URL(url));
|
||||
//=> false
|
||||
```
|
||||
|
||||
##### .truthy(value)
|
||||
|
||||
Returns `true` for all values that evaluate to true in a boolean context:
|
||||
|
||||
```js
|
||||
is.truthy('🦄');
|
||||
//=> true
|
||||
|
||||
is.truthy(undefined);
|
||||
//=> false
|
||||
```
|
||||
|
||||
##### .falsy(value)
|
||||
|
||||
Returns `true` if `value` is one of: `false`, `0`, `''`, `null`, `undefined`, `NaN`.
|
||||
|
||||
##### .nan(value)
|
||||
##### .nullOrUndefined(value)
|
||||
##### .primitive(value)
|
||||
|
||||
JavaScript primitives are as follows: `null`, `undefined`, `string`, `number`, `boolean`, `symbol`.
|
||||
|
||||
##### .integer(value)
|
||||
|
||||
##### .safeInteger(value)
|
||||
|
||||
Returns `true` if `value` is a [safe integer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
|
||||
|
||||
##### .plainObject(value)
|
||||
|
||||
An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`.
|
||||
|
||||
##### .iterable(value)
|
||||
##### .asyncIterable(value)
|
||||
##### .class(value)
|
||||
|
||||
Returns `true` for instances created by a class.
|
||||
|
||||
**Note:** TypeScript users must use `.class_()` because of a TypeScript naming limitation.
|
||||
|
||||
##### .typedArray(value)
|
||||
|
||||
##### .arrayLike(value)
|
||||
|
||||
A `value` is array-like if it is not a function and has a `value.length` that is a safe integer greater than or equal to 0.
|
||||
|
||||
```js
|
||||
is.arrayLike(document.forms);
|
||||
//=> true
|
||||
|
||||
function foo() {
|
||||
is.arrayLike(arguments);
|
||||
//=> true
|
||||
}
|
||||
foo();
|
||||
```
|
||||
|
||||
##### .inRange(value, range)
|
||||
|
||||
Check if `value` (number) is in the given `range`. The range is an array of two values, lower bound and upper bound, in no specific order.
|
||||
|
||||
```js
|
||||
is.inRange(3, [0, 5]);
|
||||
is.inRange(3, [5, 0]);
|
||||
is.inRange(0, [-2, 2]);
|
||||
```
|
||||
|
||||
##### .inRange(value, upperBound)
|
||||
|
||||
Check if `value` (number) is in the range of `0` to `upperBound`.
|
||||
|
||||
```js
|
||||
is.inRange(3, 10);
|
||||
```
|
||||
|
||||
##### .domElement(value)
|
||||
|
||||
Returns `true` if `value` is a DOM Element.
|
||||
|
||||
##### .nodeStream(value)
|
||||
|
||||
Returns `true` if `value` is a Node.js [stream](https://nodejs.org/api/stream.html).
|
||||
|
||||
```js
|
||||
const fs = require('fs');
|
||||
|
||||
is.nodeStream(fs.createReadStream('unicorn.png'));
|
||||
//=> true
|
||||
```
|
||||
|
||||
##### .observable(value)
|
||||
|
||||
Returns `true` if `value` is an `Observable`.
|
||||
|
||||
```js
|
||||
const {Observable} = require('rxjs');
|
||||
|
||||
is.observable(new Observable());
|
||||
//=> true
|
||||
```
|
||||
|
||||
##### .infinite(value)
|
||||
|
||||
Check if `value` is `Infinity` or `-Infinity`.
|
||||
|
||||
##### .evenInteger(value)
|
||||
|
||||
Returns `true` if `value` is an even integer.
|
||||
|
||||
##### .oddInteger(value)
|
||||
|
||||
Returns `true` if `value` is an odd integer.
|
||||
|
||||
##### .propertyKey(value)
|
||||
|
||||
Returns `true` if `value` can be used as an object property key (either `string`, `number`, or `symbol`).
|
||||
|
||||
##### .formData(value)
|
||||
|
||||
Returns `true` if `value` is an instance of the [`FormData` class](https://developer.mozilla.org/en-US/docs/Web/API/FormData).
|
||||
|
||||
```js
|
||||
const data = new FormData();
|
||||
|
||||
is.formData(data);
|
||||
//=> true
|
||||
```
|
||||
|
||||
##### .urlSearchParams(value)
|
||||
|
||||
Returns `true` if `value` is an instance of the [`URLSearchParams` class](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams).
|
||||
|
||||
```js
|
||||
const searchParams = new URLSearchParams();
|
||||
|
||||
is.urlSearchParams(searchParams);
|
||||
//=> true
|
||||
```
|
||||
|
||||
##### .any(predicate | predicate[], ...values)
|
||||
|
||||
Using a single `predicate` argument, returns `true` if **any** of the input `values` returns true in the `predicate`:
|
||||
|
||||
```js
|
||||
is.any(is.string, {}, true, '🦄');
|
||||
//=> true
|
||||
|
||||
is.any(is.boolean, 'unicorns', [], new Map());
|
||||
//=> false
|
||||
```
|
||||
|
||||
Using an array of `predicate[]`, returns `true` if **any** of the input `values` returns true for **any** of the `predicates` provided in an array:
|
||||
|
||||
```js
|
||||
is.any([is.string, is.number], {}, true, '🦄');
|
||||
//=> true
|
||||
|
||||
is.any([is.boolean, is.number], 'unicorns', [], new Map());
|
||||
//=> false
|
||||
```
|
||||
|
||||
##### .all(predicate, ...values)
|
||||
|
||||
Returns `true` if **all** of the input `values` returns true in the `predicate`:
|
||||
|
||||
```js
|
||||
is.all(is.object, {}, new Map(), new Set());
|
||||
//=> true
|
||||
|
||||
is.all(is.string, '🦄', [], 'unicorns');
|
||||
//=> false
|
||||
```
|
||||
|
||||
## Type guards
|
||||
|
||||
When using `is` together with TypeScript, [type guards](http://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types) are being used extensively to infer the correct type inside if-else statements.
|
||||
|
||||
```ts
|
||||
import is from '@sindresorhus/is';
|
||||
|
||||
const padLeft = (value: string, padding: string | number) => {
|
||||
if (is.number(padding)) {
|
||||
// `padding` is typed as `number`
|
||||
return Array(padding + 1).join(' ') + value;
|
||||
}
|
||||
|
||||
if (is.string(padding)) {
|
||||
// `padding` is typed as `string`
|
||||
return padding + value;
|
||||
}
|
||||
|
||||
throw new TypeError(`Expected 'padding' to be of type 'string' or 'number', got '${is(padding)}'.`);
|
||||
}
|
||||
|
||||
padLeft('🦄', 3);
|
||||
//=> ' 🦄'
|
||||
|
||||
padLeft('🦄', '🌈');
|
||||
//=> '🌈🦄'
|
||||
```
|
||||
|
||||
## Type assertions
|
||||
|
||||
The type guards are also available as [type assertions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions), which throw an error for unexpected types. It is a convenient one-line version of the often repetitive "if-not-expected-type-throw" pattern.
|
||||
|
||||
```ts
|
||||
import {assert} from '@sindresorhus/is';
|
||||
|
||||
const handleMovieRatingApiResponse = (response: unknown) => {
|
||||
assert.plainObject(response);
|
||||
// `response` is now typed as a plain `object` with `unknown` properties.
|
||||
|
||||
assert.number(response.rating);
|
||||
// `response.rating` is now typed as a `number`.
|
||||
|
||||
assert.string(response.title);
|
||||
// `response.title` is now typed as a `string`.
|
||||
|
||||
return `${response.title} (${response.rating * 10})`;
|
||||
};
|
||||
|
||||
handleMovieRatingApiResponse({rating: 0.87, title: 'The Matrix'});
|
||||
//=> 'The Matrix (8.7)'
|
||||
|
||||
// This throws an error.
|
||||
handleMovieRatingApiResponse({rating: '🦄'});
|
||||
```
|
||||
|
||||
## Generic type parameters
|
||||
|
||||
The type guards and type assertions are aware of [generic type parameters](https://www.typescriptlang.org/docs/handbook/generics.html), such as `Promise<T>` and `Map<Key, Value>`. The default is `unknown` for most cases, since `is` cannot check them at runtime. If the generic type is known at compile-time, either implicitly (inferred) or explicitly (provided), `is` propagates the type so it can be used later.
|
||||
|
||||
Use generic type parameters with caution. They are only checked by the TypeScript compiler, and not checked by `is` at runtime. This can lead to unexpected behavior, where the generic type is _assumed_ at compile-time, but actually is something completely different at runtime. It is best to use `unknown` (default) and type-check the value of the generic type parameter at runtime with `is` or `assert`.
|
||||
|
||||
```ts
|
||||
import {assert} from '@sindresorhus/is';
|
||||
|
||||
async function badNumberAssumption(input: unknown) {
|
||||
// Bad assumption about the generic type parameter fools the compile-time type system.
|
||||
assert.promise<number>(input);
|
||||
// `input` is a `Promise` but only assumed to be `Promise<number>`.
|
||||
|
||||
const resolved = await input;
|
||||
// `resolved` is typed as `number` but was not actually checked at runtime.
|
||||
|
||||
// Multiplication will return NaN if the input promise did not actually contain a number.
|
||||
return 2 * resolved;
|
||||
}
|
||||
|
||||
async function goodNumberAssertion(input: unknown) {
|
||||
assert.promise(input);
|
||||
// `input` is typed as `Promise<unknown>`
|
||||
|
||||
const resolved = await input;
|
||||
// `resolved` is typed as `unknown`
|
||||
|
||||
assert.number(resolved);
|
||||
// `resolved` is typed as `number`
|
||||
|
||||
// Uses runtime checks so only numbers will reach the multiplication.
|
||||
return 2 * resolved;
|
||||
}
|
||||
|
||||
badNumberAssumption(Promise.resolve('An unexpected string'));
|
||||
//=> NaN
|
||||
|
||||
// This correctly throws an error because of the unexpected string value.
|
||||
goodNumberAssertion(Promise.resolve('An unexpected string'));
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
### Why yet another type checking module?
|
||||
|
||||
There are hundreds of type checking modules on npm, unfortunately, I couldn't find any that fit my needs:
|
||||
|
||||
- Includes both type methods and ability to get the type
|
||||
- Types of primitives returned as lowercase and object types as camelcase
|
||||
- Covers all built-ins
|
||||
- Unsurprising behavior
|
||||
- Well-maintained
|
||||
- Comprehensive test suite
|
||||
|
||||
For the ones I found, pick 3 of these.
|
||||
|
||||
The most common mistakes I noticed in these modules was using `instanceof` for type checking, forgetting that functions are objects, and omitting `symbol` as a primitive.
|
||||
|
||||
### Why not just use `instanceof` instead of this package?
|
||||
|
||||
`instanceof` does not work correctly for all types and it does not work across [realms](https://stackoverflow.com/a/49832343/64949). Examples of realms are iframes, windows, web workers, and the `vm` module in Node.js.
|
||||
|
||||
## For enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of @sindresorhus/is and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-sindresorhus-is?utm_source=npm-sindresorhus-is&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
||||
## Related
|
||||
|
||||
- [ow](https://github.com/sindresorhus/ow) - Function argument validation for humans
|
||||
- [is-stream](https://github.com/sindresorhus/is-stream) - Check if something is a Node.js stream
|
||||
- [is-observable](https://github.com/sindresorhus/is-observable) - Check if a value is an Observable
|
||||
- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array
|
||||
- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address
|
||||
- [is-array-sorted](https://github.com/sindresorhus/is-array-sorted) - Check if an Array is sorted
|
||||
- [is-error-constructor](https://github.com/sindresorhus/is-error-constructor) - Check if a value is an error constructor
|
||||
- [is-empty-iterable](https://github.com/sindresorhus/is-empty-iterable) - Check if an Iterable is empty
|
||||
- [is-blob](https://github.com/sindresorhus/is-blob) - Check if a value is a Blob - File-like object of immutable, raw data
|
||||
- [has-emoji](https://github.com/sindresorhus/has-emoji) - Check whether a string has any emoji
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Giora Guttsait](https://github.com/gioragutt)
|
||||
- [Brandon Smith](https://github.com/brandon93s)
|
||||
21
node_modules/@szmarczak/http-timer/LICENSE
generated
vendored
Normal file
21
node_modules/@szmarczak/http-timer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Szymon Marczak
|
||||
|
||||
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.
|
||||
93
node_modules/@szmarczak/http-timer/README.md
generated
vendored
Normal file
93
node_modules/@szmarczak/http-timer/README.md
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
# http-timer
|
||||
> Timings for HTTP requests
|
||||
|
||||
[](https://travis-ci.org/szmarczak/http-timer)
|
||||
[](https://coveralls.io/github/szmarczak/http-timer?branch=master)
|
||||
[](https://packagephobia.now.sh/result?p=@szmarczak/http-timer)
|
||||
|
||||
Inspired by the [`request` package](https://github.com/request/request).
|
||||
|
||||
## Installation
|
||||
|
||||
NPM:
|
||||
|
||||
> `npm install @szmarczak/http-timer`
|
||||
|
||||
Yarn:
|
||||
|
||||
> `yarn add @szmarczak/http-timer`
|
||||
|
||||
## Usage
|
||||
**Note:**
|
||||
> - The measured events resemble Node.js events, not the kernel ones.
|
||||
> - Sending a chunk greater than [`highWaterMark`](https://nodejs.org/api/stream.html#stream_new_stream_writable_options) will result in invalid `upload` and `response` timings. You can avoid this by splitting the payload into smaller chunks.
|
||||
|
||||
```js
|
||||
const https = require('https');
|
||||
const timer = require('@szmarczak/http-timer');
|
||||
|
||||
const request = https.get('https://httpbin.org/anything');
|
||||
timer(request);
|
||||
|
||||
request.once('response', response => {
|
||||
response.resume();
|
||||
response.once('end', () => {
|
||||
console.log(response.timings); // You can use `request.timings` as well
|
||||
});
|
||||
});
|
||||
|
||||
// {
|
||||
// start: 1572712180361,
|
||||
// socket: 1572712180362,
|
||||
// lookup: 1572712180415,
|
||||
// connect: 1572712180571,
|
||||
// upload: 1572712180884,
|
||||
// response: 1572712181037,
|
||||
// end: 1572712181039,
|
||||
// error: undefined,
|
||||
// abort: undefined,
|
||||
// phases: {
|
||||
// wait: 1,
|
||||
// dns: 53,
|
||||
// tcp: 156,
|
||||
// request: 313,
|
||||
// firstByte: 153,
|
||||
// download: 2,
|
||||
// total: 678
|
||||
// }
|
||||
// }
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### timer(request)
|
||||
|
||||
Returns: `Object`
|
||||
|
||||
**Note**: The time is a `number` representing the milliseconds elapsed since the UNIX epoch.
|
||||
|
||||
- `start` - Time when the request started.
|
||||
- `socket` - Time when a socket was assigned to the request.
|
||||
- `lookup` - Time when the DNS lookup finished.
|
||||
- `connect` - Time when the socket successfully connected.
|
||||
- `secureConnect` - Time when the socket securely connected.
|
||||
- `upload` - Time when the request finished uploading.
|
||||
- `response` - Time when the request fired `response` event.
|
||||
- `end` - Time when the response fired `end` event.
|
||||
- `error` - Time when the request fired `error` event.
|
||||
- `abort` - Time when the request fired `abort` event.
|
||||
- `phases`
|
||||
- `wait` - `timings.socket - timings.start`
|
||||
- `dns` - `timings.lookup - timings.socket`
|
||||
- `tcp` - `timings.connect - timings.lookup`
|
||||
- `tls` - `timings.secureConnect - timings.connect`
|
||||
- `request` - `timings.upload - (timings.secureConnect || timings.connect)`
|
||||
- `firstByte` - `timings.response - timings.upload`
|
||||
- `download` - `timings.end - timings.response`
|
||||
- `total` - `(timings.end || timings.error || timings.abort) - timings.start`
|
||||
|
||||
If something has not been measured yet, it will be `undefined`.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
32
node_modules/@szmarczak/http-timer/dist/source/index.d.ts
generated
vendored
Normal file
32
node_modules/@szmarczak/http-timer/dist/source/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/// <reference types="node" />
|
||||
import { ClientRequest, IncomingMessage } from 'http';
|
||||
export interface Timings {
|
||||
start: number;
|
||||
socket?: number;
|
||||
lookup?: number;
|
||||
connect?: number;
|
||||
secureConnect?: number;
|
||||
upload?: number;
|
||||
response?: number;
|
||||
end?: number;
|
||||
error?: number;
|
||||
abort?: number;
|
||||
phases: {
|
||||
wait?: number;
|
||||
dns?: number;
|
||||
tcp?: number;
|
||||
tls?: number;
|
||||
request?: number;
|
||||
firstByte?: number;
|
||||
download?: number;
|
||||
total?: number;
|
||||
};
|
||||
}
|
||||
export interface ClientRequestWithTimings extends ClientRequest {
|
||||
timings?: Timings;
|
||||
}
|
||||
export interface IncomingMessageWithTimings extends IncomingMessage {
|
||||
timings?: Timings;
|
||||
}
|
||||
declare const timer: (request: ClientRequestWithTimings) => Timings;
|
||||
export default timer;
|
||||
126
node_modules/@szmarczak/http-timer/dist/source/index.js
generated
vendored
Normal file
126
node_modules/@szmarczak/http-timer/dist/source/index.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const defer_to_connect_1 = require("defer-to-connect");
|
||||
const util_1 = require("util");
|
||||
const nodejsMajorVersion = Number(process.versions.node.split('.')[0]);
|
||||
const timer = (request) => {
|
||||
if (request.timings) {
|
||||
return request.timings;
|
||||
}
|
||||
const timings = {
|
||||
start: Date.now(),
|
||||
socket: undefined,
|
||||
lookup: undefined,
|
||||
connect: undefined,
|
||||
secureConnect: undefined,
|
||||
upload: undefined,
|
||||
response: undefined,
|
||||
end: undefined,
|
||||
error: undefined,
|
||||
abort: undefined,
|
||||
phases: {
|
||||
wait: undefined,
|
||||
dns: undefined,
|
||||
tcp: undefined,
|
||||
tls: undefined,
|
||||
request: undefined,
|
||||
firstByte: undefined,
|
||||
download: undefined,
|
||||
total: undefined
|
||||
}
|
||||
};
|
||||
request.timings = timings;
|
||||
const handleError = (origin) => {
|
||||
const emit = origin.emit.bind(origin);
|
||||
origin.emit = (event, ...args) => {
|
||||
// Catches the `error` event
|
||||
if (event === 'error') {
|
||||
timings.error = Date.now();
|
||||
timings.phases.total = timings.error - timings.start;
|
||||
origin.emit = emit;
|
||||
}
|
||||
// Saves the original behavior
|
||||
return emit(event, ...args);
|
||||
};
|
||||
};
|
||||
handleError(request);
|
||||
const onAbort = () => {
|
||||
timings.abort = Date.now();
|
||||
// Let the `end` response event be responsible for setting the total phase,
|
||||
// unless the Node.js major version is >= 13.
|
||||
if (!timings.response || nodejsMajorVersion >= 13) {
|
||||
timings.phases.total = Date.now() - timings.start;
|
||||
}
|
||||
};
|
||||
request.prependOnceListener('abort', onAbort);
|
||||
const onSocket = (socket) => {
|
||||
timings.socket = Date.now();
|
||||
timings.phases.wait = timings.socket - timings.start;
|
||||
if (util_1.types.isProxy(socket)) {
|
||||
return;
|
||||
}
|
||||
const lookupListener = () => {
|
||||
timings.lookup = Date.now();
|
||||
timings.phases.dns = timings.lookup - timings.socket;
|
||||
};
|
||||
socket.prependOnceListener('lookup', lookupListener);
|
||||
defer_to_connect_1.default(socket, {
|
||||
connect: () => {
|
||||
timings.connect = Date.now();
|
||||
if (timings.lookup === undefined) {
|
||||
socket.removeListener('lookup', lookupListener);
|
||||
timings.lookup = timings.connect;
|
||||
timings.phases.dns = timings.lookup - timings.socket;
|
||||
}
|
||||
timings.phases.tcp = timings.connect - timings.lookup;
|
||||
// This callback is called before flushing any data,
|
||||
// so we don't need to set `timings.phases.request` here.
|
||||
},
|
||||
secureConnect: () => {
|
||||
timings.secureConnect = Date.now();
|
||||
timings.phases.tls = timings.secureConnect - timings.connect;
|
||||
}
|
||||
});
|
||||
};
|
||||
if (request.socket) {
|
||||
onSocket(request.socket);
|
||||
}
|
||||
else {
|
||||
request.prependOnceListener('socket', onSocket);
|
||||
}
|
||||
const onUpload = () => {
|
||||
var _a;
|
||||
timings.upload = Date.now();
|
||||
timings.phases.request = timings.upload - ((_a = timings.secureConnect) !== null && _a !== void 0 ? _a : timings.connect);
|
||||
};
|
||||
const writableFinished = () => {
|
||||
if (typeof request.writableFinished === 'boolean') {
|
||||
return request.writableFinished;
|
||||
}
|
||||
// Node.js doesn't have `request.writableFinished` property
|
||||
return request.finished && request.outputSize === 0 && (!request.socket || request.socket.writableLength === 0);
|
||||
};
|
||||
if (writableFinished()) {
|
||||
onUpload();
|
||||
}
|
||||
else {
|
||||
request.prependOnceListener('finish', onUpload);
|
||||
}
|
||||
request.prependOnceListener('response', (response) => {
|
||||
timings.response = Date.now();
|
||||
timings.phases.firstByte = timings.response - timings.upload;
|
||||
response.timings = timings;
|
||||
handleError(response);
|
||||
response.prependOnceListener('end', () => {
|
||||
timings.end = Date.now();
|
||||
timings.phases.download = timings.end - timings.response;
|
||||
timings.phases.total = timings.end - timings.start;
|
||||
});
|
||||
response.prependOnceListener('aborted', onAbort);
|
||||
});
|
||||
return timings;
|
||||
};
|
||||
exports.default = timer;
|
||||
// For CommonJS default export support
|
||||
module.exports = timer;
|
||||
module.exports.default = timer;
|
||||
72
node_modules/@szmarczak/http-timer/package.json
generated
vendored
Normal file
72
node_modules/@szmarczak/http-timer/package.json
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"name": "@szmarczak/http-timer",
|
||||
"version": "4.0.6",
|
||||
"description": "Timings for HTTP requests",
|
||||
"main": "dist/source",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && tsc --noEmit && nyc ava",
|
||||
"build": "del-cli dist && tsc",
|
||||
"prepare": "npm run build",
|
||||
"coveralls": "nyc report --reporter=text-lcov | coveralls"
|
||||
},
|
||||
"files": [
|
||||
"dist/source"
|
||||
],
|
||||
"keywords": [
|
||||
"http",
|
||||
"https",
|
||||
"timer",
|
||||
"timings"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/szmarczak/http-timer.git"
|
||||
},
|
||||
"author": "Szymon Marczak",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/szmarczak/http-timer/issues"
|
||||
},
|
||||
"homepage": "https://github.com/szmarczak/http-timer#readme",
|
||||
"dependencies": {
|
||||
"defer-to-connect": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ava/typescript": "^2.0.0",
|
||||
"@sindresorhus/tsconfig": "^1.0.2",
|
||||
"@types/node": "^16.3.1",
|
||||
"ava": "^3.15.0",
|
||||
"coveralls": "^3.1.1",
|
||||
"del-cli": "^3.0.1",
|
||||
"http2-wrapper": "^2.0.7",
|
||||
"nyc": "^15.1.0",
|
||||
"p-event": "^4.2.0",
|
||||
"typescript": "^4.3.5",
|
||||
"xo": "^0.39.1"
|
||||
},
|
||||
"types": "dist/source",
|
||||
"nyc": {
|
||||
"extension": [
|
||||
".ts"
|
||||
],
|
||||
"exclude": [
|
||||
"**/tests/**"
|
||||
]
|
||||
},
|
||||
"xo": {
|
||||
"rules": {
|
||||
"@typescript-eslint/no-non-null-assertion": "off"
|
||||
}
|
||||
},
|
||||
"ava": {
|
||||
"typescript": {
|
||||
"compile": false,
|
||||
"rewritePaths": {
|
||||
"tests/": "dist/tests/"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
21
node_modules/@types/cacheable-request/LICENSE
generated
vendored
Normal file
21
node_modules/@types/cacheable-request/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
||||
16
node_modules/@types/cacheable-request/README.md
generated
vendored
Normal file
16
node_modules/@types/cacheable-request/README.md
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# Installation
|
||||
> `npm install --save @types/cacheable-request`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for cacheable-request (https://github.com/lukechilds/cacheable-request#readme).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cacheable-request.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Wed, 09 Nov 2022 16:32:53 GMT
|
||||
* Dependencies: [@types/http-cache-semantics](https://npmjs.com/package/@types/http-cache-semantics), [@types/keyv](https://npmjs.com/package/@types/keyv), [@types/node](https://npmjs.com/package/@types/node), [@types/responselike](https://npmjs.com/package/@types/responselike)
|
||||
* Global values: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [BendingBender](https://github.com/BendingBender), and [Paul Melnikow](https://github.com/paulmelnikow).
|
||||
137
node_modules/@types/cacheable-request/index.d.ts
generated
vendored
Normal file
137
node_modules/@types/cacheable-request/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
// Type definitions for cacheable-request 6.0
|
||||
// Project: https://github.com/lukechilds/cacheable-request#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Paul Melnikow <https://github.com/paulmelnikow>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { request, RequestOptions, ClientRequest, ServerResponse } from 'http';
|
||||
import { URL } from 'url';
|
||||
import { EventEmitter } from 'events';
|
||||
import { Store } from 'keyv';
|
||||
import { Options as CacheSemanticsOptions } from 'http-cache-semantics';
|
||||
import ResponseLike = require('responselike');
|
||||
|
||||
export = CacheableRequest;
|
||||
|
||||
declare const CacheableRequest: CacheableRequest;
|
||||
|
||||
type RequestFn = typeof request;
|
||||
|
||||
interface CacheableRequest {
|
||||
new (requestFn: RequestFn, storageAdapter?: string | CacheableRequest.StorageAdapter): (
|
||||
opts: string | URL | (RequestOptions & CacheSemanticsOptions),
|
||||
cb?: (response: ServerResponse | ResponseLike) => void
|
||||
) => CacheableRequest.Emitter;
|
||||
|
||||
RequestError: typeof RequestErrorCls;
|
||||
CacheError: typeof CacheErrorCls;
|
||||
}
|
||||
|
||||
declare namespace CacheableRequest {
|
||||
type StorageAdapter = Store<any>;
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* If the cache should be used. Setting this to `false` will completely bypass the cache for the current request.
|
||||
* @default true
|
||||
*/
|
||||
cache?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* If set to `true` once a cached resource has expired it is deleted and will have to be re-requested.
|
||||
*
|
||||
* If set to `false`, after a cached resource's TTL expires it is kept in the cache and will be revalidated
|
||||
* on the next request with `If-None-Match`/`If-Modified-Since` headers.
|
||||
* @default false
|
||||
*/
|
||||
strictTtl?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* Limits TTL. The `number` represents milliseconds.
|
||||
* @default undefined
|
||||
*/
|
||||
maxTtl?: number | undefined;
|
||||
|
||||
/**
|
||||
* When set to `true`, if the DB connection fails we will automatically fallback to a network request.
|
||||
* DB errors will still be emitted to notify you of the problem even though the request callback may succeed.
|
||||
* @default false
|
||||
*/
|
||||
automaticFailover?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* Forces refreshing the cache. If the response could be retrieved from the cache, it will perform a
|
||||
* new request and override the cache instead.
|
||||
* @default false
|
||||
*/
|
||||
forceRefresh?: boolean | undefined;
|
||||
}
|
||||
|
||||
interface Emitter extends EventEmitter {
|
||||
addListener(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
addListener(
|
||||
event: 'response',
|
||||
listener: (response: ServerResponse | ResponseLike) => void
|
||||
): this;
|
||||
addListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;
|
||||
on(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
on(event: 'response', listener: (response: ServerResponse | ResponseLike) => void): this;
|
||||
on(event: 'error', listener: (error: RequestError | CacheError) => void): this;
|
||||
once(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
once(event: 'response', listener: (response: ServerResponse | ResponseLike) => void): this;
|
||||
once(event: 'error', listener: (error: RequestError | CacheError) => void): this;
|
||||
prependListener(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
prependListener(
|
||||
event: 'response',
|
||||
listener: (response: ServerResponse | ResponseLike) => void
|
||||
): this;
|
||||
prependListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;
|
||||
prependOnceListener(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
prependOnceListener(
|
||||
event: 'response',
|
||||
listener: (response: ServerResponse | ResponseLike) => void
|
||||
): this;
|
||||
prependOnceListener(
|
||||
event: 'error',
|
||||
listener: (error: RequestError | CacheError) => void
|
||||
): this;
|
||||
removeListener(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
removeListener(
|
||||
event: 'response',
|
||||
listener: (response: ServerResponse | ResponseLike) => void
|
||||
): this;
|
||||
removeListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;
|
||||
off(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
off(event: 'response', listener: (response: ServerResponse | ResponseLike) => void): this;
|
||||
off(event: 'error', listener: (error: RequestError | CacheError) => void): this;
|
||||
removeAllListeners(event?: 'request' | 'response' | 'error'): this;
|
||||
listeners(event: 'request'): Array<(request: ClientRequest) => void>;
|
||||
listeners(event: 'response'): Array<(response: ServerResponse | ResponseLike) => void>;
|
||||
listeners(event: 'error'): Array<(error: RequestError | CacheError) => void>;
|
||||
rawListeners(event: 'request'): Array<(request: ClientRequest) => void>;
|
||||
rawListeners(event: 'response'): Array<(response: ServerResponse | ResponseLike) => void>;
|
||||
rawListeners(event: 'error'): Array<(error: RequestError | CacheError) => void>;
|
||||
emit(event: 'request', request: ClientRequest): boolean;
|
||||
emit(event: 'response', response: ServerResponse | ResponseLike): boolean;
|
||||
emit(event: 'error', error: RequestError | CacheError): boolean;
|
||||
eventNames(): Array<'request' | 'response' | 'error'>;
|
||||
listenerCount(type: 'request' | 'response' | 'error'): number;
|
||||
}
|
||||
|
||||
type RequestError = RequestErrorCls;
|
||||
type CacheError = CacheErrorCls;
|
||||
}
|
||||
|
||||
declare class RequestErrorCls extends Error {
|
||||
readonly name: 'RequestError';
|
||||
|
||||
constructor(error: Error);
|
||||
}
|
||||
declare class CacheErrorCls extends Error {
|
||||
readonly name: 'CacheError';
|
||||
|
||||
constructor(error: Error);
|
||||
}
|
||||
35
node_modules/@types/cacheable-request/package.json
generated
vendored
Normal file
35
node_modules/@types/cacheable-request/package.json
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@types/cacheable-request",
|
||||
"version": "6.0.3",
|
||||
"description": "TypeScript definitions for cacheable-request",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cacheable-request",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "BendingBender",
|
||||
"url": "https://github.com/BendingBender",
|
||||
"githubUsername": "BendingBender"
|
||||
},
|
||||
{
|
||||
"name": "Paul Melnikow",
|
||||
"url": "https://github.com/paulmelnikow",
|
||||
"githubUsername": "paulmelnikow"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/cacheable-request"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"@types/http-cache-semantics": "*",
|
||||
"@types/keyv": "^3.1.4",
|
||||
"@types/node": "*",
|
||||
"@types/responselike": "^1.0.0"
|
||||
},
|
||||
"typesPublisherContentHash": "9345f1216c9d26f9046880c34f6329b2874405d68cf13d1f1f771fbb4d96549f",
|
||||
"typeScriptVersion": "4.1"
|
||||
}
|
||||
21
node_modules/@types/http-cache-semantics/LICENSE
generated
vendored
Normal file
21
node_modules/@types/http-cache-semantics/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
||||
16
node_modules/@types/http-cache-semantics/README.md
generated
vendored
Normal file
16
node_modules/@types/http-cache-semantics/README.md
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# Installation
|
||||
> `npm install --save @types/http-cache-semantics`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for http-cache-semantics (https://github.com/kornelski/http-cache-semantics#readme).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/http-cache-semantics.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Tue, 06 Jul 2021 21:33:36 GMT
|
||||
* Dependencies: none
|
||||
* Global values: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [BendingBender](https://github.com/BendingBender).
|
||||
170
node_modules/@types/http-cache-semantics/index.d.ts
generated
vendored
Normal file
170
node_modules/@types/http-cache-semantics/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
// Type definitions for http-cache-semantics 4.0
|
||||
// Project: https://github.com/kornelski/http-cache-semantics#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = CachePolicy;
|
||||
|
||||
declare class CachePolicy {
|
||||
constructor(req: CachePolicy.Request, res: CachePolicy.Response, options?: CachePolicy.Options);
|
||||
|
||||
/**
|
||||
* Returns `true` if the response can be stored in a cache.
|
||||
* If it's `false` then you MUST NOT store either the request or the response.
|
||||
*/
|
||||
storable(): boolean;
|
||||
|
||||
/**
|
||||
* This is the most important method. Use this method to check whether the cached response is still fresh
|
||||
* in the context of the new request.
|
||||
*
|
||||
* If it returns `true`, then the given `request` matches the original response this cache policy has been
|
||||
* created with, and the response can be reused without contacting the server. Note that the old response
|
||||
* can't be returned without being updated, see `responseHeaders()`.
|
||||
*
|
||||
* If it returns `false`, then the response may not be matching at all (e.g. it's for a different URL or method),
|
||||
* or may require to be refreshed first (see `revalidationHeaders()`).
|
||||
*/
|
||||
satisfiesWithoutRevalidation(newRequest: CachePolicy.Request): boolean;
|
||||
|
||||
/**
|
||||
* Returns updated, filtered set of response headers to return to clients receiving the cached response.
|
||||
* This function is necessary, because proxies MUST always remove hop-by-hop headers (such as `TE` and `Connection`)
|
||||
* and update response's `Age` to avoid doubling cache time.
|
||||
*
|
||||
* @example
|
||||
* cachedResponse.headers = cachePolicy.responseHeaders(cachedResponse);
|
||||
*/
|
||||
responseHeaders(): CachePolicy.Headers;
|
||||
|
||||
/**
|
||||
* Returns approximate time in milliseconds until the response becomes stale (i.e. not fresh).
|
||||
*
|
||||
* After that time (when `timeToLive() <= 0`) the response might not be usable without revalidation. However,
|
||||
* there are exceptions, e.g. a client can explicitly allow stale responses, so always check with
|
||||
* `satisfiesWithoutRevalidation()`.
|
||||
*/
|
||||
timeToLive(): number;
|
||||
|
||||
/**
|
||||
* Chances are you'll want to store the `CachePolicy` object along with the cached response.
|
||||
* `obj = policy.toObject()` gives a plain JSON-serializable object.
|
||||
*/
|
||||
toObject(): CachePolicy.CachePolicyObject;
|
||||
|
||||
/**
|
||||
* `policy = CachePolicy.fromObject(obj)` creates an instance from object created by `toObject()`.
|
||||
*/
|
||||
static fromObject(obj: CachePolicy.CachePolicyObject): CachePolicy;
|
||||
|
||||
/**
|
||||
* Returns updated, filtered set of request headers to send to the origin server to check if the cached
|
||||
* response can be reused. These headers allow the origin server to return status 304 indicating the
|
||||
* response is still fresh. All headers unrelated to caching are passed through as-is.
|
||||
*
|
||||
* Use this method when updating cache from the origin server.
|
||||
*
|
||||
* @example
|
||||
* updateRequest.headers = cachePolicy.revalidationHeaders(updateRequest);
|
||||
*/
|
||||
revalidationHeaders(newRequest: CachePolicy.Request): CachePolicy.Headers;
|
||||
|
||||
/**
|
||||
* Use this method to update the cache after receiving a new response from the origin server.
|
||||
*/
|
||||
revalidatedPolicy(
|
||||
revalidationRequest: CachePolicy.Request,
|
||||
revalidationResponse: CachePolicy.Response
|
||||
): CachePolicy.RevalidationPolicy;
|
||||
}
|
||||
|
||||
declare namespace CachePolicy {
|
||||
interface Request {
|
||||
url?: string | undefined;
|
||||
method?: string | undefined;
|
||||
headers: Headers;
|
||||
}
|
||||
|
||||
interface Response {
|
||||
status?: number | undefined;
|
||||
headers: Headers;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* If `true`, then the response is evaluated from a perspective of a shared cache (i.e. `private` is not
|
||||
* cacheable and `s-maxage` is respected). If `false`, then the response is evaluated from a perspective
|
||||
* of a single-user cache (i.e. `private` is cacheable and `s-maxage` is ignored).
|
||||
* `true` is recommended for HTTP clients.
|
||||
* @default true
|
||||
*/
|
||||
shared?: boolean | undefined;
|
||||
/**
|
||||
* A fraction of response's age that is used as a fallback cache duration. The default is 0.1 (10%),
|
||||
* e.g. if a file hasn't been modified for 100 days, it'll be cached for 100*0.1 = 10 days.
|
||||
* @default 0.1
|
||||
*/
|
||||
cacheHeuristic?: number | undefined;
|
||||
/**
|
||||
* A number of milliseconds to assume as the default time to cache responses with `Cache-Control: immutable`.
|
||||
* Note that [per RFC](https://httpwg.org/specs/rfc8246.html#the-immutable-cache-control-extension)
|
||||
* these can become stale, so `max-age` still overrides the default.
|
||||
* @default 24*3600*1000 (24h)
|
||||
*/
|
||||
immutableMinTimeToLive?: number | undefined;
|
||||
/**
|
||||
* If `true`, common anti-cache directives will be completely ignored if the non-standard `pre-check`
|
||||
* and `post-check` directives are present. These two useless directives are most commonly found
|
||||
* in bad StackOverflow answers and PHP's "session limiter" defaults.
|
||||
* @default false
|
||||
*/
|
||||
ignoreCargoCult?: boolean | undefined;
|
||||
/**
|
||||
* If `false`, then server's `Date` header won't be used as the base for `max-age`. This is against the RFC,
|
||||
* but it's useful if you want to cache responses with very short `max-age`, but your local clock
|
||||
* is not exactly in sync with the server's.
|
||||
* @default true
|
||||
*/
|
||||
trustServerDate?: boolean | undefined;
|
||||
}
|
||||
|
||||
interface CachePolicyObject {
|
||||
v: number;
|
||||
t: number;
|
||||
sh: boolean;
|
||||
ch: number;
|
||||
imm: number;
|
||||
st: number;
|
||||
resh: Headers;
|
||||
rescc: { [key: string]: string };
|
||||
m: string;
|
||||
u?: string | undefined;
|
||||
h?: string | undefined;
|
||||
a: boolean;
|
||||
reqh: Headers | null;
|
||||
reqcc: { [key: string]: string };
|
||||
}
|
||||
|
||||
interface Headers {
|
||||
[header: string]: string | string[] | undefined;
|
||||
}
|
||||
|
||||
interface RevalidationPolicy {
|
||||
/**
|
||||
* A new `CachePolicy` with HTTP headers updated from `revalidationResponse`. You can always replace
|
||||
* the old cached `CachePolicy` with the new one.
|
||||
*/
|
||||
policy: CachePolicy;
|
||||
/**
|
||||
* Boolean indicating whether the response body has changed.
|
||||
*
|
||||
* - If `false`, then a valid 304 Not Modified response has been received, and you can reuse the old
|
||||
* cached response body.
|
||||
* - If `true`, you should use new response's body (if present), or make another request to the origin
|
||||
* server without any conditional headers (i.e. don't use `revalidationHeaders()` this time) to get
|
||||
* the new resource.
|
||||
*/
|
||||
modified: boolean;
|
||||
matches: boolean;
|
||||
}
|
||||
}
|
||||
25
node_modules/@types/http-cache-semantics/package.json
generated
vendored
Normal file
25
node_modules/@types/http-cache-semantics/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@types/http-cache-semantics",
|
||||
"version": "4.0.1",
|
||||
"description": "TypeScript definitions for http-cache-semantics",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/http-cache-semantics",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "BendingBender",
|
||||
"url": "https://github.com/BendingBender",
|
||||
"githubUsername": "BendingBender"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/http-cache-semantics"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {},
|
||||
"typesPublisherContentHash": "9ecb3137d8c0ede7c06f5d90c7d4759e560a26effb8846bc51a99b63f03dd2d1",
|
||||
"typeScriptVersion": "3.6"
|
||||
}
|
||||
21
node_modules/@types/keyv/LICENSE
generated
vendored
Normal file
21
node_modules/@types/keyv/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
||||
16
node_modules/@types/keyv/README.md
generated
vendored
Normal file
16
node_modules/@types/keyv/README.md
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# Installation
|
||||
> `npm install --save @types/keyv`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for keyv (https://github.com/lukechilds/keyv).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/keyv.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Thu, 17 Mar 2022 05:31:42 GMT
|
||||
* Dependencies: [@types/node](https://npmjs.com/package/@types/node)
|
||||
* Global values: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [AryloYeung](https://github.com/Arylo), and [BendingBender](https://github.com/BendingBender).
|
||||
90
node_modules/@types/keyv/index.d.ts
generated
vendored
Normal file
90
node_modules/@types/keyv/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
// Type definitions for keyv 3.1
|
||||
// Project: https://github.com/lukechilds/keyv
|
||||
// Definitions by: AryloYeung <https://github.com/Arylo>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
type WithRequiredProperties<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
||||
|
||||
declare class Keyv<TValue = any, TOpts extends { [key: string]: any } = {}> extends EventEmitter {
|
||||
/**
|
||||
* `this.opts` is an object containing at least the properties listed
|
||||
* below. However, `Keyv.Options` allows arbitrary properties as well.
|
||||
* These properties can be specified as the second type parameter to `Keyv`.
|
||||
*/
|
||||
opts: WithRequiredProperties<
|
||||
Keyv.Options<TValue>,
|
||||
'deserialize' | 'namespace' | 'serialize' | 'store' | 'uri'
|
||||
> &
|
||||
TOpts;
|
||||
|
||||
/**
|
||||
* @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options.
|
||||
*/
|
||||
constructor(opts?: Keyv.Options<TValue> & TOpts);
|
||||
/**
|
||||
* @param uri The connection string URI.
|
||||
*
|
||||
* Merged into the options object as options.uri.
|
||||
* @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options.
|
||||
*/
|
||||
constructor(uri?: string, opts?: Keyv.Options<TValue> & TOpts);
|
||||
|
||||
/** Returns the value. */
|
||||
get<TRaw extends boolean = false>(key: string, options?: { raw?: TRaw }):
|
||||
Promise<(TRaw extends false
|
||||
? TValue
|
||||
: Keyv.DeserializedData<TValue>) | undefined>;
|
||||
/**
|
||||
* Set a value.
|
||||
*
|
||||
* By default keys are persistent. You can set an expiry TTL in milliseconds.
|
||||
*/
|
||||
set(key: string, value: TValue, ttl?: number): Promise<true>;
|
||||
/**
|
||||
* Deletes an entry.
|
||||
*
|
||||
* Returns `true` if the key existed, `false` if not.
|
||||
*/
|
||||
delete(key: string): Promise<boolean>;
|
||||
/** Delete all entries in the current namespace. */
|
||||
clear(): Promise<void>;
|
||||
}
|
||||
|
||||
declare namespace Keyv {
|
||||
interface Options<TValue> {
|
||||
/** Namespace for the current instance. */
|
||||
namespace?: string | undefined;
|
||||
/** A custom serialization function. */
|
||||
serialize?: ((data: DeserializedData<TValue>) => string) | undefined;
|
||||
/** A custom deserialization function. */
|
||||
deserialize?: ((data: string) => DeserializedData<TValue> | undefined) | undefined;
|
||||
/** The connection string URI. */
|
||||
uri?: string | undefined;
|
||||
/** The storage adapter instance to be used by Keyv. */
|
||||
store?: Store<TValue> | undefined;
|
||||
/** Default TTL. Can be overridden by specififying a TTL on `.set()`. */
|
||||
ttl?: number | undefined;
|
||||
/** Specify an adapter to use. e.g `'redis'` or `'mongodb'`. */
|
||||
adapter?: 'redis' | 'mongodb' | 'mongo' | 'sqlite' | 'postgresql' | 'postgres' | 'mysql' | undefined;
|
||||
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface DeserializedData<TValue> {
|
||||
value: TValue; expires: number | null;
|
||||
}
|
||||
|
||||
interface Store<TValue> {
|
||||
get(key: string): TValue | Promise<TValue | undefined> | undefined;
|
||||
set(key: string, value: TValue, ttl?: number): any;
|
||||
delete(key: string): boolean | Promise<boolean>;
|
||||
clear(): void | Promise<void>;
|
||||
}
|
||||
}
|
||||
|
||||
export = Keyv;
|
||||
32
node_modules/@types/keyv/package.json
generated
vendored
Normal file
32
node_modules/@types/keyv/package.json
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "@types/keyv",
|
||||
"version": "3.1.4",
|
||||
"description": "TypeScript definitions for keyv",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/keyv",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "AryloYeung",
|
||||
"url": "https://github.com/Arylo",
|
||||
"githubUsername": "Arylo"
|
||||
},
|
||||
{
|
||||
"name": "BendingBender",
|
||||
"url": "https://github.com/BendingBender",
|
||||
"githubUsername": "BendingBender"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/keyv"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
},
|
||||
"typesPublisherContentHash": "e83393e0860475d12e960cede22532e18e129cf659f31f2a0298a88cb5d02d36",
|
||||
"typeScriptVersion": "3.9"
|
||||
}
|
||||
21
node_modules/@types/node/LICENSE
generated
vendored
Normal file
21
node_modules/@types/node/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user