@todesktop/runtime
Advanced tools
Comparing version 0.5.4 to 0.6.0
@@ -15,2 +15,3 @@ "use strict"; | ||
const electron = require("electron"); | ||
const electronUpdater = require("electron-updater"); | ||
const eventemitter2_1 = require("eventemitter2"); | ||
@@ -306,4 +307,20 @@ const fs = require("fs"); | ||
}); | ||
electronUpdater.autoUpdater.on("checking-for-update", (...args) => { | ||
this._log("info", "checking-for-update", ...args); | ||
this.emit("checking-for-update", ...args); | ||
}); | ||
electronUpdater.autoUpdater.on("download-progress", (...args) => { | ||
this._log("info", "download-progress", ...args); | ||
this.emit("download-progress", ...args); | ||
}); | ||
electronUpdater.autoUpdater.on("update-available", (...args) => { | ||
this._log("info", "update-available", ...args); | ||
this.emit("update-available", ...args); | ||
}); | ||
electronUpdater.autoUpdater.on("update-not-available", (...args) => { | ||
this._log("info", "update-not-available", ...args); | ||
this.emit("update-not-available", ...args); | ||
}); | ||
} | ||
} | ||
exports.default = AutoUpdater; |
@@ -23,12 +23,2 @@ "use strict"; | ||
} | ||
// Errors should be handled within, but let's be safe | ||
try { | ||
Promise.resolve().then(() => require("./smokeTests")).then(({ default: acceptSmokeTests }) => acceptSmokeTests()) | ||
.catch(() => { | ||
// Ignore | ||
}); | ||
} | ||
catch (e) { | ||
// Ignore | ||
} | ||
} | ||
@@ -35,0 +25,0 @@ } |
@@ -7,3 +7,3 @@ { | ||
"name": "@todesktop/runtime", | ||
"version": "0.5.4", | ||
"version": "0.6.0", | ||
"license": "MIT", | ||
@@ -13,3 +13,3 @@ "author": "ToDesktop <hi@todesktop.com> (https://www.todesktop.com/)", | ||
"bugs": { | ||
"email": "adam@todesktop.com" | ||
"email": "dave@todesktop.com" | ||
}, | ||
@@ -53,3 +53,3 @@ "main": "dist/index.js", | ||
"builder-util-runtime": "^8.7.3", | ||
"electron": "^8.2.4", | ||
"electron": "^12.0.7", | ||
"eslint": "^6.8.0", | ||
@@ -65,3 +65,3 @@ "eslint-config-prettier": "^6.11.0", | ||
"lint-staged": "^10.4.0", | ||
"np": "6.2.4", | ||
"np": "^6.5.0", | ||
"prettier": "^2.0.5", | ||
@@ -68,0 +68,0 @@ "promise-polyfill": "^8.1.3", |
@@ -28,3 +28,2 @@ # @todesktop/runtime | ||
## Minimal usage | ||
@@ -46,4 +45,4 @@ | ||
webPreferences: { | ||
nodeIntegration: true | ||
} | ||
nodeIntegration: true, | ||
}, | ||
}); | ||
@@ -62,3 +61,2 @@ | ||
## Default behaviour | ||
@@ -72,3 +70,2 @@ | ||
### Disabling the default auto-update behaviour | ||
@@ -82,3 +79,2 @@ | ||
## API | ||
@@ -113,3 +109,2 @@ | ||
##### `options.customLogger` (Optional) | ||
@@ -119,3 +114,3 @@ | ||
To debug, you can pass a custom logger object. You can pass [electron-log](https://www.npmjs.com/package/electron-log) (recommended), [winston](https://www.npmjs.com/package/winston), or another logger with the following interface: `{ error(), info(), warn() }`. Include a `debug()` method to get even more information. | ||
To debug, you can pass a custom logger object. You can pass [electron-log](https://www.npmjs.com/package/electron-log) (recommended), [winston](https://www.npmjs.com/package/winston), or another logger with the following interface: `{ error(), info(), warn() }`. Include a `debug()` method to get even more information. | ||
@@ -130,3 +125,3 @@ Example using electron-log: | ||
todesktop.init({ | ||
customLogger: electronLog | ||
customLogger: electronLog, | ||
}); | ||
@@ -175,8 +170,7 @@ ``` | ||
const result = await todesktop.autoUpdater.checkForUpdates(); | ||
if(result.updateInfo) { | ||
if (result.updateInfo) { | ||
console.log("Update found:", result.updateInfo.version); | ||
todesktop.autoUpdater.restartAndInstall(); | ||
} | ||
} | ||
catch(e) { | ||
} catch (e) { | ||
console.log("Update check failed:", e); | ||
@@ -186,3 +180,2 @@ } | ||
### `.autoUpdater.on(eventName, callback)` | ||
@@ -202,3 +195,2 @@ | ||
### `.autoUpdater.restartAndInstall()` | ||
@@ -212,3 +204,2 @@ | ||
## Events | ||
@@ -220,2 +211,38 @@ | ||
### `checking-for-update` | ||
Emitted when checking if an update has started. | ||
### `update-available` | ||
Emitted when there is an available update. Callback contains the following object: | ||
```javascript | ||
{ | ||
releaseDate: "2011-10-05T14:48:00.000Z", | ||
version: "2.1.3" | ||
} | ||
``` | ||
### `update-not-available` | ||
Emitted when there is no available update. Callback contains the following object: | ||
```javascript | ||
{ | ||
releaseDate: "2011-10-05T14:48:00.000Z", | ||
version: "2.1.3" | ||
} | ||
``` | ||
### `download-progress` | ||
Emitted on progress. Callback contains the following object: | ||
- `progress` | ||
- `bytesPerSecond` | ||
- `percent` | ||
- `total` | ||
- `transferred` | ||
### `update-downloaded` | ||
@@ -248,3 +275,3 @@ | ||
console.log("Update found:", event.updateInfo.version); | ||
if(event.sources.includes("my-custom-source")) { | ||
if (event.sources.includes("my-custom-source")) { | ||
return false; | ||
@@ -267,3 +294,3 @@ todesktop.autoUpdater.restartAndInstall(); | ||
const todesktop = require("@todesktop/runtime"); | ||
const { ipcMain } = require('electron'); | ||
const { ipcMain } = require("electron"); | ||
@@ -277,3 +304,3 @@ todesktop.init(); | ||
todesktop.autoUpdater.on("update-downloaded", (event) => { | ||
win.webContents.send('update-downloaded', event); | ||
win.webContents.send("update-downloaded", event); | ||
}); | ||
@@ -283,3 +310,3 @@ | ||
// do a restart and install of the app | ||
ipcMain.on('restart-and-install', () => { | ||
ipcMain.on("restart-and-install", () => { | ||
todesktop.autoUpdater.restartAndInstall(); | ||
@@ -295,4 +322,4 @@ }); | ||
<a href="#" class="click-to-install"> | ||
Click here to restart the app and install the update | ||
</a>. | ||
Click here to restart the app and install the update </a | ||
>. | ||
</div> | ||
@@ -304,9 +331,9 @@ ``` | ||
```js | ||
const { ipcRenderer } = require('electron'); | ||
const { ipcRenderer } = require("electron"); | ||
// First let's hook up our click-to-install link | ||
const installLink = document.querySelector('.click-to-install'); | ||
installLink.addEventListener('click', (e) => { | ||
const installLink = document.querySelector(".click-to-install"); | ||
installLink.addEventListener("click", (e) => { | ||
e.preventDefault(); | ||
ipcRenderer.send('restart-and-install'); | ||
ipcRenderer.send("restart-and-install"); | ||
}); | ||
@@ -316,4 +343,4 @@ | ||
// update-available div on our UI | ||
const updateAvailableDiv = document.querySelector('.update-available'); | ||
const appVersionSpan = document.querySelector('.app-version'); | ||
const updateAvailableDiv = document.querySelector(".update-available"); | ||
const appVersionSpan = document.querySelector(".app-version"); | ||
ipcRenderer.on("update-downloaded", (e, { updateInfo }) => { | ||
@@ -324,3 +351,3 @@ // Update the version text | ||
// Show the update-available div | ||
updateAvailableDiv.style.display = 'block'; | ||
updateAvailableDiv.style.display = "block"; | ||
}); | ||
@@ -351,5 +378,4 @@ ``` | ||
## More documentation | ||
For documentation on ToDesktop CLI See https://www.npmjs.com/package/@todesktop/cli |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
59272
1098
360