Commit c81ba88f authored by Natthaphong Malaphan's avatar Natthaphong Malaphan 😊

week 4 good

parent 967e01e5

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

"use strict";
exports.__esModule = true;
var electron_1 = require("electron");
var win = null;
electron_1.app.on('ready', function () {
win = new electron_1.BrowserWindow({ width: 500, height: 400 });
win.setTitle('หน้าต่าง');
win.on('close', function () { win = null; });
});
import { app, BrowserWindow } from "electron"
let win = null
app.on('ready', () => {
win = new BrowserWindow ({ width: 500, height: 400})
win.setTitle('หน้าต่าง')
win.on('close',() => { win = null })
})
\ No newline at end of file
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) 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
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\electron\cli.js" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../electron/cli.js" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../electron/cli.js" $args
$ret=$LASTEXITCODE
}
exit $ret
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) 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
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\extract-zip\cli.js" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../extract-zip/cli.js" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../extract-zip/cli.js" $args
$ret=$LASTEXITCODE
}
exit $ret
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../mkdirp/bin/cmd.js" "$@"
ret=$?
else
node "$basedir/../mkdirp/bin/cmd.js" "$@"
ret=$?
fi
exit $ret
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\mkdirp\bin\cmd.js" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
$ret=$LASTEXITCODE
}
exit $ret
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) 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
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\semver\bin\semver.js" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../semver/bin/semver.js" $args
$ret=$LASTEXITCODE
}
exit $ret
# @electron/get
> Download Electron release artifacts
[![CircleCI](https://circleci.com/gh/electron/get.svg?style=svg)](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. A different
proxy module is used, depending on the version of Node in use, and as such, there are slightly
different ways to set the proxy environment variables. For Node 10 and above,
[`global-agent`](https://github.com/gajus/global-agent#environment-variables) is used. Otherwise,
[`global-tunnel-ng`](https://github.com/np-maintain/global-tunnel#auto-config) is used. Refer to the
appropriate linked module to determine how to configure proxy support.
export declare class Cache {
private cacheRoot;
constructor(cacheRoot?: string);
getCachePath(downloadUrl: string, fileName: string): string;
getPathForFileInCache(url: string, fileName: string): Promise<string | null>;
putFileInCache(url: string, currentPath: string, fileName: string): Promise<string>;
}
"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 sanitize = require("sanitize-filename");
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;
}
getCachePath(downloadUrl, fileName) {
const _a = url.parse(downloadUrl), { search, hash } = _a, rest = __rest(_a, ["search", "hash"]);
const strippedUrl = url.format(rest);
const sanitizedUrl = sanitize(strippedUrl);
return path.resolve(this.cacheRoot, sanitizedUrl, 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
\ No newline at end of file
{"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,8CAA8C;AAE9C,MAAM,CAAC,GAAG,eAAK,CAAC,qBAAqB,CAAC,CAAC;AAEvC,MAAM,gBAAgB,GAAG,mBAAQ,CAAC,UAAU,EAAE;IAC5C,MAAM,EAAE,EAAE;CACX,CAAC,CAAC,KAAK,CAAC;AAET,MAAa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
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Downloader.js.map
\ No newline at end of file
{"version":3,"file":"Downloader.js","sourceRoot":"","sources":["../../src/Downloader.ts"],"names":[],"mappings":""}
\ No newline at end of file
import * as got from 'got';
import { Downloader } from './Downloader';
/**
* See [`got#options`](https://github.com/sindresorhus/got#options) for possible keys/values.
*/
export declare type GotDownloaderOptions = got.GotOptions<string | null> & {
/**
* if defined, triggers every time `got`'s `downloadProgress` event callback is triggered.
*/
getProgressCallback?: (progress: got.Progress) => 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>;
}
"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 = 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
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.name === 'HTTPError' && error.statusCode === 404) {
error.message += ` for ${error.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
\ No newline at end of file
{"version":3,"file":"GotDownloader.js","sourceRoot":"","sources":["../../src/GotDownloader.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+BAA+B;AAC/B,2BAA2B;AAC3B,6BAA6B;AAC7B,wCAAwC;AAIxC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAiBzC,MAAa,aAAa;IACxB,KAAK,CAAC,QAAQ,CAAC,GAAW,EAAE,cAAsB,EAAE,OAA8B;QAChF,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,EAAE,KAAK,EAAE,mBAAmB,KAAoB,OAAO,EAAzB,8DAAyB,CAAC;QAC9D,IAAI,iBAAiB,GAAG,KAAK,CAAC;QAC9B,IAAI,GAA4B,CAAC;QACjC,IAAI,eAAuB,CAAC;QAC5B,IAAI,OAAO,GAA+B,SAAS,CAAC;QACpD,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;QAC9C,MAAM,WAAW,GAAG,EAAE,CAAC,iBAAiB,CAAC,cA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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;AA7DD,sCA6DC"}
\ No newline at end of file
import { ElectronArtifactDetails } from './types';
export declare function getArtifactFileName(details: ElectronArtifactDetails): string;
export declare function getArtifactRemoteURL(details: ElectronArtifactDetails): Promise<string>;
"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 lowerName = name.replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}_${b}`).toLowerCase();
return (process.env[`NPM_CONFIG_ELECTRON_${lowerName.toUpperCase()}`] ||
process.env[`npm_config_electron_${lowerName}`] ||
process.env[`npm_package_config_electron_${lowerName}`] ||
process.env[`ELECTRON_${lowerName.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;
//# sourceMappingURL=artifact-utils.js.map
\ No newline at end of file
{"version":3,"file":"artifact-utils.js","sourceRoot":"","sources":["../../src/artifact-utils.ts"],"names":[],"mappings":";;AACA,mCAA+C;AAE/C,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,4BAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACtC,4BAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC1C,4BAAoB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAEzC,OAAO,GAAG;QACR,OAAO,CAAC,YAAY;QACpB,OAAO,CAAC,OAAO;QACf,OAAO,CAAC,QAAQ;QAChB,OAAO,CAAC,IAAI;QACZ,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,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B,CAAC,CAAC;SAC3D;KACF;IACD,MAAM,IAAI,GAAG,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAChE,eAAe,EACf,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAClC,CAAC;IACF,MAAM,IAAI,GAAG,SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IAE7E,4CAA4C;IAC5C,IAAI,IAAI,CAAC,eAAe,EAAE;QACxB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAChD,OAAO,GAAG,CAAC;KACZ;IAED,OAAO,GAAG,IAAI,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC;AAClC,CAAC;AAzBD,oDAyBC"}
\ No newline at end of file
import { Downloader } from './Downloader';
export declare function getDownloaderForSystem(): Promise<Downloader<any>>;
"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
\ No newline at end of file
{"version":3,"file":"downloader-resolver.js","sourceRoot":"","sources":["../../src/downloader-resolver.ts"],"names":[],"mappings":";;AAEO,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"}
\ No newline at end of file
import { ElectronDownloadRequestOptions, ElectronPlatformArtifactDetailsWithDefaults } from './types';
export { getHostArch } from './utils';
export { initializeProxy } from './proxy';
export * from './types';
/**
* 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>;
/**
* 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>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const debug_1 = require("debug");
const path = require("path");
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 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;
/**
* 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 = utils_1.normalizeVersion(process.env.ELECTRON_CUSTOM_VERSION || artifactDetails.version);
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
if (!artifactDetails.artifactName.startsWith('SHASUMS256') &&
!artifactDetails.unsafelyDisableChecksums) {
const 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,
});
await sumchecker('sha256', shasumPath, path.dirname(tempDownloadPath), [
path.basename(tempDownloadPath),
]);
}
return await cache.putFileInCache(url, tempDownloadPath, fileName);
});
}
exports.downloadArtifact = downloadArtifact;
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version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AAsB,EAAE,CAAC,CAAC;QAClF,CAAC,CACC,eAAe,GAAG,OAAO,gBAAgB,kBAAkB,IAAI,CAAC,SAAS,CACvE,eAAe,CAAC,eAAe,CAChC,EAAE,CACJ,CAAC;QACF,MAAM,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,gBAAgB,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;QAElF,uDAAuD;QACvD,IACE,CAAC,eAAe,CAAC,YAAY,CAAC,UAAU,CAAC,YAAY,CAAC;YACtD,CAAC,eAAe,CAAC,wBAAwB,EACzC;YACA,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC;gBACxC,SAAS,EAAE,IAAI;gBACf,OAAO,EAAE,eAAe,CAAC,OAAO;gBAChC,YAAY,EAAE,gBAAgB;gBAC9B,KAAK,EAAE,eAAe,CAAC,KAAK;gBAC5B,eAAe,EAAE,eAAe,CAAC,eAAe;gBAChD,SAAS,EAAE,eAAe,CAAC,SAAS;gBACpC,UAAU,EAAE,eAAe,CAAC,UAAU;gBACtC,aAAa,EAAE,eAAe,CAAC,aAAa;aAC7C,CAAC,CAAC;YACH,MAAM,UAAU,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;gBACrE,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;aAChC,CAAC,CAAC;SACJ;QAED,OAAO,MAAM,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC;AAvFD,4CAuFC"}
\ No newline at end of file
/**
* Initializes a third-party proxy module for HTTP(S) requests.
*/
export declare function initializeProxy(): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const debug = require("debug");
const d = debug('@electron/get:proxy');
/**
* Initializes a third-party proxy module for HTTP(S) requests.
*/
function initializeProxy() {
try {
// Code originally from https://github.com/yeoman/yo/blob/b2eea87e/lib/cli.js#L19-L28
const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);
if (MAJOR_NODEJS_VERSION >= 10) {
// `global-agent` works with Node.js v10 and above.
require('global-agent').bootstrap();
}
else {
// `global-tunnel-ng` works with Node.js v10 and below.
require('global-tunnel-ng').initialize();
}
}
catch (e) {
d('Could not load either proxy modules, built-in proxy support not available:', e);
}
}
exports.initializeProxy = initializeProxy;
//# sourceMappingURL=proxy.js.map
\ No newline at end of file
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/proxy.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAE/B,MAAM,CAAC,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAEvC;;GAEG;AACH,SAAgB,eAAe;IAC7B,IAAI;QACF,qFAAqF;QACrF,MAAM,oBAAoB,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAElF,IAAI,oBAAoB,IAAI,EAAE,EAAE;YAC9B,mDAAmD;YACnD,OAAO,CAAC,cAAc,CAAC,CAAC,SAAS,EAAE,CAAC;SACrC;aAAM;YACL,uDAAuD;YACvD,OAAO,CAAC,kBAAkB,CAAC,CAAC,UAAU,EAAE,CAAC;SAC1C;KACF;IAAC,OAAO,CAAC,EAAE;QACV,CAAC,CAAC,4EAA4E,EAAE,CAAC,CAAC,CAAC;KACpF;AACH,CAAC;AAfD,0CAeC"}
\ No newline at end of file
import { Downloader } from './Downloader';
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;
/**
* 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;
/**
* 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<any>;
/**
* 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;
export declare type DownloadOptions = any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map
\ No newline at end of file
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
\ No newline at end of file
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, from the `process` module information.
*/
export declare function getHostArch(): 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;
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;
"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, from the `process` module information.
*/
function getHostArch() {
return getNodeArch(process.arch);
}
exports.getHostArch = getHostArch;
/**
* Generates an architecture name that would be used in an Electron or Node.js
* download file name.
*/
function getNodeArch(arch) {
if (arch === 'arm') {
switch (process.config.variables.arm_version) {
case '6':
return uname();
case '7':
default:
return 'armv7l';
}
}
return arch;
}
exports.getNodeArch = getNodeArch;
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;
//# sourceMappingURL=utils.js.map
\ No newline at end of file
{"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;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,MAAM,CAAC;AAChB,CAAC;AAEM,KAAK,UAAU,mBAAmB,CACvC,kBAA0B,EAAE,CAAC,MAAM,EAAE,EACrC,EAAqC;IAErC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;IACjD,MAAM,aAAa,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAC3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,OAAe,EACf,aAAsB;IAEtB,OAAO,CACL,QAAQ,KAAK,OAAO;QACpB,IAAI,KAAK,MAAM;QACf,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3C,OAAO,aAAa,KAAK,WAAW,CACrC,CAAC;AACJ,CAAC;AAZD,kEAYC"}
\ No newline at end of file
export declare class Cache {
private cacheRoot;
constructor(cacheRoot?: string);
getCachePath(downloadUrl: string, fileName: string): string;
getPathForFileInCache(url: string, fileName: string): Promise<string | null>;
putFileInCache(url: string, currentPath: string, fileName: string): Promise<string>;
}
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 sanitize from 'sanitize-filename';
const d = debug('@electron/get:cache');
const defaultCacheRoot = envPaths('electron', {
suffix: '',
}).cache;
export class Cache {
constructor(cacheRoot = defaultCacheRoot) {
this.cacheRoot = cacheRoot;
}
getCachePath(downloadUrl, fileName) {
const _a = url.parse(downloadUrl), { search, hash } = _a, rest = __rest(_a, ["search", "hash"]);
const strippedUrl = url.format(rest);
const sanitizedUrl = sanitize(strippedUrl);
return path.resolve(this.cacheRoot, sanitizedUrl, 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
\ No newline at end of file
{"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,KAAK,CAAC;AAC3B,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAE9C,MAAM,CAAC,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAEvC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,UAAU,EAAE;IAC5C,MAAM,EAAE,EAAE;CACX,CAAC,CAAC,KAAK,CAAC;AAET,MAAM,OAAO,KAAK;IAChB,YAAoB,YAAY,gBAAgB;QAA5B,cAAS,GAAT,SAAS,CAAmB;IAAG,CAAC;IAE7C,YAAY,CAAC,WAAmB,EAAE,QAAgB;QACvD,MAAM,2BAAkD,EAAlD,EAAE,MAAM,EAAE,IAAI,OAAoC,EAAlC,qCAAkC,CAAC;QACzD,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAErC,MAAM,YAAY,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAAC,GAAW,EAAE,QAAgB;QAC9D,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACnD,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YAClC,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,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"}
\ No newline at end of file
export interface Downloader<T> {
download(url: string, targetFilePath: string, options: T): Promise<void>;
}
//# sourceMappingURL=Downloader.js.map
\ No newline at end of file
{"version":3,"file":"Downloader.js","sourceRoot":"","sources":["../../src/Downloader.ts"],"names":[],"mappings":""}
\ No newline at end of file
import * as got from 'got';
import { Downloader } from './Downloader';
/**
* See [`got#options`](https://github.com/sindresorhus/got#options) for possible keys/values.
*/
export declare type GotDownloaderOptions = got.GotOptions<string | null> & {
/**
* if defined, triggers every time `got`'s `downloadProgress` event callback is triggered.
*/
getProgressCallback?: (progress: got.Progress) => 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>;
}
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 * as got 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
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.name === 'HTTPError' && error.statusCode === 404) {
error.message += ` for ${error.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
\ No newline at end of file
{"version":3,"file":"GotDownloader.js","sourceRoot":"","sources":["../../src/GotDownloader.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OA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cAAc,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;YACnD,cAAc,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,EAAC,QAAQ,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,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,UAAU,KAAK,GAAG,EAAE;oBAC1D,KAAK,CAAC,OAAO,IAAI,QAAQ,KAAK,CAAC,GAAG,EAAE,CAAC;iBACtC;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"}
\ No newline at end of file
import { ElectronArtifactDetails } from './types';
export declare function getArtifactFileName(details: ElectronArtifactDetails): string;
export declare function getArtifactRemoteURL(details: ElectronArtifactDetails): Promise<string>;
import { ensureIsTruthyString } 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 lowerName = name.replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}_${b}`).toLowerCase();
return (process.env[`NPM_CONFIG_ELECTRON_${lowerName.toUpperCase()}`] ||
process.env[`npm_config_electron_${lowerName}`] ||
process.env[`npm_package_config_electron_${lowerName}`] ||
process.env[`ELECTRON_${lowerName.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}`;
}
//# sourceMappingURL=artifact-utils.js.map
\ No newline at end of file
{"version":3,"file":"artifact-utils.js","sourceRoot":"","sources":["../../src/artifact-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,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AAC;QACb,YAAY,CACb,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAgC;IACzE,MAAM,IAAI,GAAkB,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC;IACxD,IAAI,IAAI,GAAG,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/C,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACvC,MAAM,iBAAiB,GAAG,SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAChE,IAAI,iBAAiB,EAAE;YACrB,IAAI,GAAG,iBAAiB,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;SACxE;aAAM;YACL,IAAI,GAAG,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC;SAC3D;KACF;IACD,MAAM,IAAI,GAAG,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAChE,eAAe,EACf,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAClC,CAAC;IACF,MAAM,IAAI,GAAG,SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IAE7E,4CAA4C;IAC5C,IAAI,IAAI,CAAC,eAAe,EAAE;QACxB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAChD,OAAO,GAAG,CAAC;KACZ;IAED,OAAO,GAAG,IAAI,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC;AAClC,CAAC"}
\ No newline at end of file
import { Downloader } from './Downloader';
export declare function getDownloaderForSystem(): Promise<Downloader<any>>;
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
\ No newline at end of file
{"version":3,"file":"downloader-resolver.js","sourceRoot":"","sources":["../../src/downloader-resolver.ts"],"names":[],"mappings":"AAEA,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"}
\ No newline at end of file
import { ElectronDownloadRequestOptions, ElectronPlatformArtifactDetailsWithDefaults } from './types';
export { getHostArch } from './utils';
export { initializeProxy } from './proxy';
export * from './types';
/**
* 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>;
/**
* 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>;
import debug from 'debug';
import * as path from 'path';
import * as sumchecker from 'sumchecker';
import { getArtifactFileName, getArtifactRemoteURL } from './artifact-utils';
import { Cache } from './Cache';
import { getDownloaderForSystem } from './downloader-resolver';
import { initializeProxy } from './proxy';
import { withTempDirectoryIn, normalizeVersion, getHostArch, getNodeArch, ensureIsTruthyString, isOfficialLinuxIA32Download, } 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 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' }));
}
/**
* 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 = normalizeVersion(process.env.ELECTRON_CUSTOM_VERSION || artifactDetails.version);
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
if (!artifactDetails.artifactName.startsWith('SHASUMS256') &&
!artifactDetails.unsafelyDisableChecksums) {
const 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,
});
await sumchecker('sha256', shasumPath, path.dirname(tempDownloadPath), [
path.basename(tempDownloadPath),
]);
}
return await cache.putFileInCache(url, tempDownloadPath, fileName);
});
}
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAO7E,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,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,2BAA2B,GAC5B,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,UAAU,QAAQ,CACtB,OAAe,EACf,OAAwC;IAExC,OAAO,gBAAgB,iCAClB,OAAO,KACV,OAAO,EACP,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,I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,eAAe;gBAChD,SAAS,EAAE,eAAe,CAAC,SAAS;gBACpC,UAAU,EAAE,eAAe,CAAC,UAAU;gBACtC,aAAa,EAAE,eAAe,CAAC,aAAa;aAC7C,CAAC,CAAC;YACH,MAAM,UAAU,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;gBACrE,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;aAChC,CAAC,CAAC;SACJ;QAED,OAAO,MAAM,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC"}
\ No newline at end of file
/**
* Initializes a third-party proxy module for HTTP(S) requests.
*/
export declare function initializeProxy(): void;
import * as debug from 'debug';
const d = debug('@electron/get:proxy');
/**
* Initializes a third-party proxy module for HTTP(S) requests.
*/
export function initializeProxy() {
try {
// Code originally from https://github.com/yeoman/yo/blob/b2eea87e/lib/cli.js#L19-L28
const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);
if (MAJOR_NODEJS_VERSION >= 10) {
// `global-agent` works with Node.js v10 and above.
require('global-agent').bootstrap();
}
else {
// `global-tunnel-ng` works with Node.js v10 and below.
require('global-tunnel-ng').initialize();
}
}
catch (e) {
d('Could not load either proxy modules, built-in proxy support not available:', e);
}
}
//# sourceMappingURL=proxy.js.map
\ No newline at end of file
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,CAAC,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAEvC;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI;QACF,qFAAqF;QACrF,MAAM,oBAAoB,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAElF,IAAI,oBAAoB,IAAI,EAAE,EAAE;YAC9B,mDAAmD;YACnD,OAAO,CAAC,cAAc,CAAC,CAAC,SAAS,EAAE,CAAC;SACrC;aAAM;YACL,uDAAuD;YACvD,OAAO,CAAC,kBAAkB,CAAC,CAAC,UAAU,EAAE,CAAC;SAC1C;KACF;IAAC,OAAO,CAAC,EAAE;QACV,CAAC,CAAC,4EAA4E,EAAE,CAAC,CAAC,CAAC;KACpF;AACH,CAAC"}
\ No newline at end of file
import { Downloader } from './Downloader';
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;
/**
* 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;
/**
* 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<any>;
/**
* 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;
export declare type DownloadOptions = any;
//# sourceMappingURL=types.js.map
\ No newline at end of file
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
\ No newline at end of file
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, from the `process` module information.
*/
export declare function getHostArch(): 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;
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;
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, from the `process` module information.
*/
export function getHostArch() {
return getNodeArch(process.arch);
}
/**
* Generates an architecture name that would be used in an Electron or Node.js
* download file name.
*/
export function getNodeArch(arch) {
if (arch === 'arm') {
switch (process.config.variables.arm_version) {
case '6':
return uname();
case '7':
default:
return 'armv7l';
}
}
return 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');
}
//# sourceMappingURL=utils.js.map
\ No newline at end of file
{"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,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EAAE;YACrD,KAAK,GAAG;gBACN,OAAO,KAAK,EAAE,CAAC;YACjB,KAAK,GAAG,CAAC;YACT;gBACE,OAAO,QAAQ,CAAC;SACnB;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAuB,GAAM,EAAE,GAAM;IACvE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;QAC7C,MAAM,IAAI,KAAK,CAAC,sBAAsB,GAAG,6CAA6C,CAAC,CAAC;KACzF;AACH,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,QAAgB,EAChB,IAAY,EACZ,OAAe,EACf,aAAsB;IAEtB,OAAO,CACL,QAAQ,KAAK,OAAO;QACpB,IAAI,KAAK,MAAM;QACf,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3C,OAAO,aAAa,KAAK,WAAW,CACrC,CAAC;AACJ,CAAC"}
\ No newline at end of file
{
"_from": "@electron/get@^1.0.1",
"_id": "@electron/get@1.12.2",
"_inBundle": false,
"_integrity": "sha512-vAuHUbfvBQpYTJ5wB7uVIDq5c/Ry0fiTBMs7lnEYAo/qXXppIVcWdfBr57u6eRnKdVso7KSiH6p/LbQAG6Izrg==",
"_location": "/@electron/get",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@electron/get@^1.0.1",
"name": "@electron/get",
"escapedName": "@electron%2fget",
"scope": "@electron",
"rawSpec": "^1.0.1",
"saveSpec": null,
"fetchSpec": "^1.0.1"
},
"_requiredBy": [
"/electron"
],
"_resolved": "https://registry.npmjs.org/@electron/get/-/get-1.12.2.tgz",
"_shasum": "6442066afb99be08cefb9a281e4b4692b33764f3",
"_spec": "@electron/get@^1.0.1",
"_where": "C:\\Users\\nnat_\\Desktop\\topic-1-63\\topic-1-63\\15-july\\csubuapp-0501\\node_modules\\electron",
"author": {
"name": "Samuel Attard"
},
"bugs": {
"url": "https://github.com/electron/get/issues"
},
"bundleDependencies": false,
"dependencies": {
"debug": "^4.1.1",
"env-paths": "^2.2.0",
"fs-extra": "^8.1.0",
"global-agent": "^2.0.2",
"global-tunnel-ng": "^2.7.1",
"got": "^9.6.0",
"progress": "^2.0.3",
"sanitize-filename": "^1.6.2",
"sumchecker": "^3.0.1"
},
"deprecated": false,
"description": "Utility for downloading artifacts from different versions of Electron",
"devDependencies": {
"@continuous-auth/semantic-release-npm": "^2.0.0",
"@types/debug": "^4.1.4",
"@types/fs-extra": "^8.0.0",
"@types/got": "^9.4.4",
"@types/jest": "^24.0.13",
"@types/node": "^12.0.2",
"@types/progress": "^2.0.3",
"@types/sanitize-filename": "^1.1.28",
"husky": "^2.3.0",
"jest": "^24.8.0",
"lint-staged": "^8.1.7",
"prettier": "^1.17.1",
"semantic-release": "^15.13.12",
"ts-jest": "^24.0.0",
"typedoc": "^0.17.2",
"typescript": "^3.8.0"
},
"engines": {
"node": ">=8.6"
},
"files": [
"dist/*",
"README.md"
],
"homepage": "https://github.com/electron/get#readme",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"keywords": [
"electron",
"download",
"prebuild",
"get",
"artifact",
"release"
],
"license": "MIT",
"lint-staged": {
"*.ts": [
"prettier --write",
"git add"
]
},
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"name": "@electron/get",
"optionalDependencies": {
"global-agent": "^2.0.2",
"global-tunnel-ng": "^2.7.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/electron/get.git"
},
"scripts": {
"build": "tsc && tsc -p tsconfig.esm.json",
"build:docs": "typedoc --out docs",
"jest": "jest --coverage",
"lint": "prettier --check \"src/**/*.ts\"",
"prepublishOnly": "npm run build",
"test": "npm run lint && npm run jest",
"test:nonetwork": "npm run lint && npm run jest -- --testPathIgnorePatterns network.spec"
},
"version": "1.12.2"
}
/// <reference types="node" />
/// <reference lib="es2016" />
/// <reference lib="es2017.sharedmemory" />
/// <reference lib="esnext.asynciterable" />
/// <reference lib="dom" />
declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
declare type Primitive = null | undefined | string | number | boolean | Symbol;
export interface ArrayLike {
length: number;
}
export interface Class<T = unknown> {
new (...args: any[]): T;
}
declare type DomElement = object & {
nodeType: 1;
nodeName: string;
};
declare type NodeStream = object & {
pipe: Function;
};
export declare const enum TypeName {
null = "null",
boolean = "boolean",
undefined = "undefined",
string = "string",
number = "number",
symbol = "symbol",
Function = "Function",
GeneratorFunction = "GeneratorFunction",
AsyncFunction = "AsyncFunction",
Observable = "Observable",
Array = "Array",
Buffer = "Buffer",
Object = "Object",
RegExp = "RegExp",
Date = "Date",
Error = "Error",
Map = "Map",
Set = "Set",
WeakMap = "WeakMap",
WeakSet = "WeakSet",
Int8Array = "Int8Array",
Uint8Array = "Uint8Array",
Uint8ClampedArray = "Uint8ClampedArray",
Int16Array = "Int16Array",
Uint16Array = "Uint16Array",
Int32Array = "Int32Array",
Uint32Array = "Uint32Array",
Float32Array = "Float32Array",
Float64Array = "Float64Array",
ArrayBuffer = "ArrayBuffer",
SharedArrayBuffer = "SharedArrayBuffer",
DataView = "DataView",
Promise = "Promise",
URL = "URL"
}
declare function is(value: unknown): TypeName;
declare namespace is {
const undefined: (value: unknown) => value is undefined;
const string: (value: unknown) => value is string;
const number: (value: unknown) => value is number;
const function_: (value: unknown) => value is Function;
const null_: (value: unknown) => value is null;
const class_: (value: unknown) => value is Class<unknown>;
const boolean: (value: unknown) => value is boolean;
const symbol: (value: unknown) => value is Symbol;
const numericString: (value: unknown) => boolean;
const array: (arg: any) => arg is any[];
const buffer: (input: unknown) => input is Buffer;
const nullOrUndefined: (value: unknown) => value is null | undefined;
const object: (value: unknown) => value is object;
const iterable: (value: unknown) => value is IterableIterator<unknown>;
const asyncIterable: (value: unknown) => value is AsyncIterableIterator<unknown>;
const generator: (value: unknown) => value is Generator;
const nativePromise: (value: unknown) => value is Promise<unknown>;
const promise: (value: unknown) => value is Promise<unknown>;
const generatorFunction: (value: unknown) => value is GeneratorFunction;
const asyncFunction: (value: unknown) => value is Function;
const boundFunction: (value: unknown) => value is Function;
const regExp: (value: unknown) => value is RegExp;
const date: (value: unknown) => value is Date;
const error: (value: unknown) => value is Error;
const map: (value: unknown) => value is Map<unknown, unknown>;
const set: (value: unknown) => value is Set<unknown>;
const weakMap: (value: unknown) => value is WeakMap<object, unknown>;
const weakSet: (value: unknown) => value is WeakSet<object>;
const int8Array: (value: unknown) => value is Int8Array;
const uint8Array: (value: unknown) => value is Uint8Array;
const uint8ClampedArray: (value: unknown) => value is Uint8ClampedArray;
const int16Array: (value: unknown) => value is Int16Array;
const uint16Array: (value: unknown) => value is Uint16Array;
const int32Array: (value: unknown) => value is Int32Array;
const uint32Array: (value: unknown) => value is Uint32Array;
const float32Array: (value: unknown) => value is Float32Array;
const float64Array: (value: unknown) => value is Float64Array;
const arrayBuffer: (value: unknown) => value is ArrayBuffer;
const sharedArrayBuffer: (value: unknown) => value is SharedArrayBuffer;
const dataView: (value: unknown) => value is DataView;
const directInstanceOf: <T>(instance: unknown, klass: Class<T>) => instance is T;
const urlInstance: (value: unknown) => value is URL;
const urlString: (value: unknown) => boolean;
const truthy: (value: unknown) => boolean;
const falsy: (value: unknown) => boolean;
const nan: (value: unknown) => boolean;
const primitive: (value: unknown) => value is Primitive;
const integer: (value: unknown) => value is number;
const safeInteger: (value: unknown) => value is number;
const plainObject: (value: unknown) => boolean;
const typedArray: (value: unknown) => value is TypedArray;
const arrayLike: (value: unknown) => value is ArrayLike;
const inRange: (value: number, range: number | number[]) => boolean;
const domElement: (value: unknown) => value is DomElement;
const observable: (value: unknown) => boolean;
const nodeStream: (value: unknown) => value is NodeStream;
const infinite: (value: unknown) => boolean;
const even: (value: number) => boolean;
const odd: (value: number) => boolean;
const emptyArray: (value: unknown) => boolean;
const nonEmptyArray: (value: unknown) => boolean;
const emptyString: (value: unknown) => boolean;
const nonEmptyString: (value: unknown) => boolean;
const emptyStringOrWhitespace: (value: unknown) => boolean;
const emptyObject: (value: unknown) => boolean;
const nonEmptyObject: (value: unknown) => boolean;
const emptySet: (value: unknown) => boolean;
const nonEmptySet: (value: unknown) => boolean;
const emptyMap: (value: unknown) => boolean;
const nonEmptyMap: (value: unknown) => boolean;
const any: (predicate: unknown, ...values: unknown[]) => boolean;
const all: (predicate: unknown, ...values: unknown[]) => boolean;
}
export default is;
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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.
{
"_from": "@sindresorhus/is@^0.14.0",
"_id": "@sindresorhus/is@0.14.0",
"_inBundle": false,
"_integrity": "sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==",
"_location": "/@sindresorhus/is",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@sindresorhus/is@^0.14.0",
"name": "@sindresorhus/is",
"escapedName": "@sindresorhus%2fis",
"scope": "@sindresorhus",
"rawSpec": "^0.14.0",
"saveSpec": null,
"fetchSpec": "^0.14.0"
},
"_requiredBy": [
"/got"
],
"_resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz",
"_shasum": "9fb3a3cf3132328151f353de4632e01e52102bea",
"_spec": "@sindresorhus/is@^0.14.0",
"_where": "C:\\Users\\nnat_\\Desktop\\topic-1-63\\topic-1-63\\15-july\\csubuapp-0501\\node_modules\\got",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/is/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Type check values: `is.string('🦄') //=> true`",
"devDependencies": {
"@sindresorhus/tsconfig": "^0.1.0",
"@types/jsdom": "^11.12.0",
"@types/node": "^10.12.10",
"@types/tempy": "^0.2.0",
"@types/zen-observable": "^0.8.0",
"ava": "^0.25.0",
"del-cli": "^1.1.0",
"jsdom": "^11.6.2",
"rxjs": "^6.3.3",
"tempy": "^0.2.1",
"tslint": "^5.9.1",
"tslint-xo": "^0.10.0",
"typescript": "^3.2.1",
"zen-observable": "^0.8.8"
},
"engines": {
"node": ">=6"
},
"files": [
"dist"
],
"homepage": "https://github.com/sindresorhus/is#readme",
"keywords": [
"type",
"types",
"is",
"check",
"checking",
"validate",
"validation",
"utility",
"util",
"typeof",
"instanceof",
"object",
"assert",
"assertion",
"test",
"kind",
"primitive",
"verify",
"compare"
],
"license": "MIT",
"main": "dist/index.js",
"name": "@sindresorhus/is",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/is.git"
},
"scripts": {
"build": "del dist && tsc",
"lint": "tslint --format stylish --project .",
"prepublish": "npm run build && del dist/tests",
"test": "npm run lint && npm run build && ava dist/tests"
},
"types": "dist/index.d.ts",
"version": "0.14.0"
}
This diff is collapsed.
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.
# http-timer
> Timings for HTTP requests
[![Build Status](https://travis-ci.org/szmarczak/http-timer.svg?branch=master)](https://travis-ci.org/szmarczak/http-timer)
[![Coverage Status](https://coveralls.io/repos/github/szmarczak/http-timer/badge.svg?branch=master)](https://coveralls.io/github/szmarczak/http-timer?branch=master)
[![install size](https://packagephobia.now.sh/badge?p=@szmarczak/http-timer)](https://packagephobia.now.sh/result?p=@szmarczak/http-timer)
Inspired by the [`request` package](https://github.com/request/request).
## Usage
```js
'use strict';
const https = require('https');
const timer = require('@szmarczak/http-timer');
const request = https.get('https://httpbin.org/anything');
const timings = timer(request);
request.on('response', response => {
response.on('data', () => {}); // Consume the data somehow
response.on('end', () => {
console.log(timings);
});
});
// { start: 1535708511443,
// socket: 1535708511444,
// lookup: 1535708511444,
// connect: 1535708511582,
// upload: 1535708511887,
// response: 1535708512037,
// end: 1535708512040,
// phases:
// { wait: 1,
// dns: 0,
// tcp: 138,
// request: 305,
// firstByte: 150,
// download: 3,
// total: 597 } }
```
## API
### timer(request)
Returns: `Object`
- `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.
- `upload` - Time when the request finished uploading.
- `response` - Time when the request fired the `response` event.
- `end` - Time when the response fired the `end` event.
- `error` - Time when the request fired the `error` event.
- `phases`
- `wait` - `timings.socket - timings.start`
- `dns` - `timings.lookup - timings.socket`
- `tcp` - `timings.connect - timings.lookup`
- `request` - `timings.upload - timings.connect`
- `firstByte` - `timings.response - timings.upload`
- `download` - `timings.end - timings.response`
- `total` - `timings.end - timings.start` or `timings.error - timings.start`
**Note**: The time is a `number` representing the milliseconds elapsed since the UNIX epoch.
## License
MIT
{
"_from": "@szmarczak/http-timer@^1.1.2",
"_id": "@szmarczak/http-timer@1.1.2",
"_inBundle": false,
"_integrity": "sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==",
"_location": "/@szmarczak/http-timer",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@szmarczak/http-timer@^1.1.2",
"name": "@szmarczak/http-timer",
"escapedName": "@szmarczak%2fhttp-timer",
"scope": "@szmarczak",
"rawSpec": "^1.1.2",
"saveSpec": null,
"fetchSpec": "^1.1.2"
},
"_requiredBy": [
"/got"
],
"_resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz",
"_shasum": "b1665e2c461a2cd92f4c1bbf50d5454de0d4b421",
"_spec": "@szmarczak/http-timer@^1.1.2",
"_where": "C:\\Users\\nnat_\\Desktop\\topic-1-63\\topic-1-63\\15-july\\csubuapp-0501\\node_modules\\got",
"author": {
"name": "Szymon Marczak"
},
"bugs": {
"url": "https://github.com/szmarczak/http-timer/issues"
},
"bundleDependencies": false,
"dependencies": {
"defer-to-connect": "^1.0.1"
},
"deprecated": false,
"description": "Timings for HTTP requests",
"devDependencies": {
"ava": "^0.25.0",
"coveralls": "^3.0.2",
"nyc": "^12.0.2",
"p-event": "^2.1.0",
"xo": "^0.22.0"
},
"engines": {
"node": ">=6"
},
"files": [
"source"
],
"homepage": "https://github.com/szmarczak/http-timer#readme",
"keywords": [
"http",
"https",
"timer",
"timings"
],
"license": "MIT",
"main": "source",
"name": "@szmarczak/http-timer",
"repository": {
"type": "git",
"url": "git+https://github.com/szmarczak/http-timer.git"
},
"scripts": {
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"test": "xo && nyc ava"
},
"version": "1.1.2",
"xo": {
"rules": {
"unicorn/filename-case": "camelCase"
}
}
}
'use strict';
const deferToConnect = require('defer-to-connect');
module.exports = request => {
const timings = {
start: Date.now(),
socket: null,
lookup: null,
connect: null,
upload: null,
response: null,
end: null,
error: null,
phases: {
wait: null,
dns: null,
tcp: null,
request: null,
firstByte: null,
download: null,
total: null
}
};
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);
};
};
let uploadFinished = false;
const onUpload = () => {
timings.upload = Date.now();
timings.phases.request = timings.upload - timings.connect;
};
handleError(request);
request.once('socket', socket => {
timings.socket = Date.now();
timings.phases.wait = timings.socket - timings.start;
const lookupListener = () => {
timings.lookup = Date.now();
timings.phases.dns = timings.lookup - timings.socket;
};
socket.once('lookup', lookupListener);
deferToConnect(socket, () => {
timings.connect = Date.now();
if (timings.lookup === null) {
socket.removeListener('lookup', lookupListener);
timings.lookup = timings.connect;
timings.phases.dns = timings.lookup - timings.socket;
}
timings.phases.tcp = timings.connect - timings.lookup;
if (uploadFinished && !timings.upload) {
onUpload();
}
});
});
request.once('finish', () => {
uploadFinished = true;
if (timings.connect) {
onUpload();
}
});
request.once('response', response => {
timings.response = Date.now();
timings.phases.firstByte = timings.response - timings.upload;
handleError(response);
response.once('end', () => {
timings.end = Date.now();
timings.phases.download = timings.end - timings.response;
timings.phases.total = timings.end - timings.start;
});
});
return timings;
};
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
# Installation
> `npm install --save @types/node`
# Summary
This package contains type definitions for Node.js (http://nodejs.org/).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v12.
### Additional Details
* Last updated: Fri, 10 Jul 2020 16:11:12 GMT
* Dependencies: none
* Global values: `Buffer`, `NodeJS`, `Symbol`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
# Credits
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alexander T.](https://github.com/a-tarasyuk), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Bruno Scheufler](https://github.com/brunoscheufler), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Flarna](https://github.com/Flarna), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Hoàng Văn Khải](https://github.com/KSXGitHub), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nicolas Voigt](https://github.com/octo-sniffle), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Zane Hannan AU](https://github.com/ZaneHannanAU), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Jordi Oliveras Rovira](https://github.com/j-oliveras), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Minh Son Nguyen](https://github.com/nguymin4), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), and [Jason Kwok](https://github.com/JasonHK).
declare module "assert" {
function assert(value: any, message?: string | Error): void;
namespace assert {
class AssertionError implements Error {
name: string;
message: string;
actual: any;
expected: any;
operator: string;
generatedMessage: boolean;
code: 'ERR_ASSERTION';
constructor(options?: {
message?: string; actual?: any; expected?: any;
operator?: string; stackStartFn?: Function
});
}
function fail(message?: string | Error): never;
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
function fail(actual: any, expected: any, message?: string | Error, operator?: string, stackStartFn?: Function): never;
function ok(value: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use strictEqual() instead. */
function equal(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use notStrictEqual() instead. */
function notEqual(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
function deepEqual(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
function strictEqual(actual: any, expected: any, message?: string | Error): void;
function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
function deepStrictEqual(actual: any, expected: any, message?: string | Error): void;
function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void;
function throws(block: () => any, message?: string | Error): void;
function throws(block: () => any, error: RegExp | Function | Object | Error, message?: string | Error): void;
function doesNotThrow(block: () => any, message?: string | Error): void;
function doesNotThrow(block: () => any, error: RegExp | Function, message?: string | Error): void;
function ifError(value: any): void;
function rejects(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
function rejects(block: (() => Promise<any>) | Promise<any>, error: RegExp | Function | Object | Error, message?: string | Error): Promise<void>;
function doesNotReject(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
function doesNotReject(block: (() => Promise<any>) | Promise<any>, error: RegExp | Function, message?: string | Error): Promise<void>;
const strict: typeof assert;
}
export = assert;
}
// base definitions for all NodeJS modules that are not specific to any version of TypeScript
/// <reference path="globals.d.ts" />
/// <reference path="async_hooks.d.ts" />
/// <reference path="buffer.d.ts" />
/// <reference path="child_process.d.ts" />
/// <reference path="cluster.d.ts" />
/// <reference path="console.d.ts" />
/// <reference path="constants.d.ts" />
/// <reference path="crypto.d.ts" />
/// <reference path="dgram.d.ts" />
/// <reference path="dns.d.ts" />
/// <reference path="domain.d.ts" />
/// <reference path="events.d.ts" />
/// <reference path="fs.d.ts" />
/// <reference path="http.d.ts" />
/// <reference path="http2.d.ts" />
/// <reference path="https.d.ts" />
/// <reference path="inspector.d.ts" />
/// <reference path="module.d.ts" />
/// <reference path="net.d.ts" />
/// <reference path="os.d.ts" />
/// <reference path="path.d.ts" />
/// <reference path="perf_hooks.d.ts" />
/// <reference path="process.d.ts" />
/// <reference path="punycode.d.ts" />
/// <reference path="querystring.d.ts" />
/// <reference path="readline.d.ts" />
/// <reference path="repl.d.ts" />
/// <reference path="stream.d.ts" />
/// <reference path="string_decoder.d.ts" />
/// <reference path="timers.d.ts" />
/// <reference path="tls.d.ts" />
/// <reference path="trace_events.d.ts" />
/// <reference path="tty.d.ts" />
/// <reference path="url.d.ts" />
/// <reference path="util.d.ts" />
/// <reference path="v8.d.ts" />
/// <reference path="vm.d.ts" />
/// <reference path="worker_threads.d.ts" />
/// <reference path="zlib.d.ts" />
declare module "buffer" {
export const INSPECT_MAX_BYTES: number;
export const kMaxLength: number;
export const kStringMaxLength: number;
export const constants: {
MAX_LENGTH: number;
MAX_STRING_LENGTH: number;
};
const BuffType: typeof Buffer;
export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary";
export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
export const SlowBuffer: {
/** @deprecated since v6.0.0, use Buffer.allocUnsafeSlow() */
new(size: number): Buffer;
prototype: Buffer;
};
export { BuffType as Buffer };
}
This diff is collapsed.
declare module "console" {
export = console;
}
This diff is collapsed.
This diff is collapsed.
declare module "dgram" {
import { AddressInfo } from "net";
import * as dns from "dns";
import * as events from "events";
interface RemoteInfo {
address: string;
family: 'IPv4' | 'IPv6';
port: number;
size: number;
}
interface BindOptions {
port?: number;
address?: string;
exclusive?: boolean;
fd?: number;
}
type SocketType = "udp4" | "udp6";
interface SocketOptions {
type: SocketType;
reuseAddr?: boolean;
/**
* @default false
*/
ipv6Only?: boolean;
recvBufferSize?: number;
sendBufferSize?: number;
lookup?: (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
}
function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
class Socket extends events.EventEmitter {
addMembership(multicastAddress: string, multicastInterface?: string): void;
address(): AddressInfo;
bind(port?: number, address?: string, callback?: () => void): void;
bind(port?: number, callback?: () => void): void;
bind(callback?: () => void): void;
bind(options: BindOptions, callback?: () => void): void;
close(callback?: () => void): void;
connect(port: number, address?: string, callback?: () => void): void;
connect(port: number, callback: () => void): void;
disconnect(): void;
dropMembership(multicastAddress: string, multicastInterface?: string): void;
getRecvBufferSize(): number;
getSendBufferSize(): number;
ref(): this;
remoteAddress(): AddressInfo;
send(msg: string | Uint8Array | any[], port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
send(msg: string | Uint8Array | any[], port?: number, callback?: (error: Error | null, bytes: number) => void): void;
send(msg: string | Uint8Array | any[], callback?: (error: Error | null, bytes: number) => void): void;
send(msg: string | Uint8Array, offset: number, length: number, port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
send(msg: string | Uint8Array, offset: number, length: number, port?: number, callback?: (error: Error | null, bytes: number) => void): void;
send(msg: string | Uint8Array, offset: number, length: number, callback?: (error: Error | null, bytes: number) => void): void;
setBroadcast(flag: boolean): void;
setMulticastInterface(multicastInterface: string): void;
setMulticastLoopback(flag: boolean): void;
setMulticastTTL(ttl: number): void;
setRecvBufferSize(size: number): void;
setSendBufferSize(size: number): void;
setTTL(ttl: number): void;
unref(): this;
/**
* events.EventEmitter
* 1. close
* 2. connect
* 3. error
* 4. listening
* 5. message
*/
addListener(event: string, listener: (...args: any[]) => void): this;
addListener(event: "close", listener: () => void): this;
addListener(event: "connect", listener: () => void): this;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: "listening", listener: () => void): this;
addListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
emit(event: string | symbol, ...args: any[]): boolean;
emit(event: "close"): boolean;
emit(event: "connect"): boolean;
emit(event: "error", err: Error): boolean;
emit(event: "listening"): boolean;
emit(event: "message", msg: Buffer, rinfo: RemoteInfo): boolean;
on(event: string, listener: (...args: any[]) => void): this;
on(event: "close", listener: () => void): this;
on(event: "connect", listener: () => void): this;
on(event: "error", listener: (err: Error) => void): this;
on(event: "listening", listener: () => void): this;
on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
once(event: string, listener: (...args: any[]) => void): this;
once(event: "close", listener: () => void): this;
once(event: "connect", listener: () => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: "listening", listener: () => void): this;
once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
prependListener(event: string, listener: (...args: any[]) => void): this;
prependListener(event: "close", listener: () => void): this;
prependListener(event: "connect", listener: () => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: "listening", listener: () => void): this;
prependListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
prependOnceListener(event: "close", listener: () => void): this;
prependOnceListener(event: "connect", listener: () => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: "listening", listener: () => void): this;
prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
}
}
This diff is collapsed.
declare module "domain" {
import * as events from "events";
class Domain extends events.EventEmitter implements NodeJS.Domain {
run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
add(emitter: events.EventEmitter | NodeJS.Timer): void;
remove(emitter: events.EventEmitter | NodeJS.Timer): void;
bind<T extends Function>(cb: T): T;
intercept<T extends Function>(cb: T): T;
members: Array<events.EventEmitter | NodeJS.Timer>;
enter(): void;
exit(): void;
}
function create(): Domain;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment