1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.UpdaterSignal = exports.DOWNLOAD_PROGRESS = exports.Provider = undefined;
- exports.getDefaultChannelName = getDefaultChannelName;
- exports.getCustomChannelName = getCustomChannelName;
- exports.getCurrentPlatform = getCurrentPlatform;
- exports.getChannelFilename = getChannelFilename;
- exports.formatUrl = formatUrl;
- var _url;
- function _load_url() {
- return _url = require("url");
- }
- class Provider {
- setRequestHeaders(value) {
- this.requestHeaders = value;
- }
- }
- exports.Provider = Provider; // due to historical reasons for windows we use channel name without platform specifier
- function getDefaultChannelName() {
- return `latest${getChannelFilePrefix()}`;
- }
- function getChannelFilePrefix() {
- return getCurrentPlatform() === "darwin" ? "-mac" : "";
- }
- function getCustomChannelName(channel) {
- return `${channel}${getChannelFilePrefix()}`;
- }
- function getCurrentPlatform() {
- return process.env.TEST_UPDATER_PLATFORM || process.platform;
- }
- function getChannelFilename(channel) {
- return `${channel}.${getCurrentPlatform() === "darwin" ? "json" : "yml"}`;
- }
- const DOWNLOAD_PROGRESS = exports.DOWNLOAD_PROGRESS = "download-progress";
- class UpdaterSignal {
- constructor(emitter) {
- this.emitter = emitter;
- }
- /**
- * Emitted when an authenticating proxy is asking for user credentials.
- * @see [Electron docs](https://github.com/electron/electron/blob/master/docs/api/client-request.md#event-login)
- */
- login(handler) {
- addHandler(this.emitter, "login", handler);
- }
- progress(handler) {
- addHandler(this.emitter, DOWNLOAD_PROGRESS, handler);
- }
- updateDownloaded(handler) {
- addHandler(this.emitter, "update-downloaded", handler);
- }
- updateCancelled(handler) {
- addHandler(this.emitter, "update-cancelled", handler);
- }
- }
- exports.UpdaterSignal = UpdaterSignal;
- const isLogEvent = false;
- function addHandler(emitter, event, handler) {
- if (isLogEvent) {
- emitter.on(event, function () {
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- console.log("%s %s", event, args);
- handler.apply(null, args);
- });
- } else {
- emitter.on(event, handler);
- }
- }
- // url.format doesn't correctly use path and requires explicit pathname
- function formatUrl(url) {
- if (url.path != null && url.pathname == null) {
- url.pathname = url.path;
- }
- return (0, (_url || _load_url()).format)(url);
- }
- //# sourceMappingURL=api.js.map
|