hardware-example
Advanced tools
Comparing version 1.0.0-alpha.12 to 1.0.0
/* eslint-disable no-template-curly-in-string */ | ||
// eslint-disable-next-line import/no-import-module-exports, @typescript-eslint/no-var-requires | ||
const { version } = require('./package.json'); | ||
module.exports = { | ||
extraMetadata: { | ||
main: 'dist/index.js', | ||
version: '1', | ||
version, | ||
}, | ||
@@ -11,3 +14,3 @@ appId: 'so.onekey.example.hardware-desktop', | ||
asar: true, | ||
buildVersion: '1', | ||
buildVersion: version, | ||
directories: { | ||
@@ -24,2 +27,3 @@ output: 'out', | ||
'package.json', | ||
'!scripts/**', | ||
], | ||
@@ -69,4 +73,4 @@ extraResources: [ | ||
target: [ | ||
// { target: 'dmg', arch: ['x64', 'arm64'] }, | ||
{ target: 'zip', arch: ['x64', 'arm64'] }, | ||
{ target: 'dmg', arch: ['x64', 'arm64'] }, | ||
// { target: 'zip', arch: ['x64', 'arm64'] }, | ||
], | ||
@@ -88,3 +92,8 @@ entitlements: 'entitlements.mac.plist', | ||
verifyUpdateCodeSignature: false, | ||
target: ['nsis'], | ||
target: [ | ||
{ | ||
target: 'nsis', | ||
arch: ['x64'], | ||
}, | ||
], | ||
}, | ||
@@ -104,2 +113,11 @@ linux: { | ||
}, | ||
publish: [ | ||
{ | ||
provider: 'github', | ||
owner: 'OneKeyHQ', | ||
repo: 'hardware-js-sdk', | ||
private: false, | ||
vPrefixedTagName: true, | ||
}, | ||
], | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"executableName": "onekey-hardware-example", | ||
"version": "1.0.0-alpha.12", | ||
"version": "1.0.0", | ||
"author": "OneKey", | ||
@@ -18,5 +18,4 @@ "description": "End-to-end encrypted workspaces for teams", | ||
"dev:electron": "electron --inspect=5858 dist/index.js", | ||
"build:package": "yarn build-electron-web && electron-forge package", | ||
"build:main": "webpack --config webpack.config.ts", | ||
"make": "yarn clean:build && yarn build-electron-web && electron-builder build -mw --config electron-builder.config.js --publish never", | ||
"make": "yarn clean:build && yarn build-electron-web && electron-builder build -mw --config electron-builder.config.js --publish always", | ||
"lint": "eslint --ext .tsx --ext .ts ./", | ||
@@ -28,2 +27,5 @@ "ts:check": "yarn tsc --noEmit" | ||
"electron-is-dev": "^3.0.1", | ||
"electron-log": "^5.1.5", | ||
"electron-updater": "^6.2.1", | ||
"fs-extra": "^11.2.0", | ||
"node-fetch": "^2.6.7" | ||
@@ -41,3 +43,3 @@ }, | ||
}, | ||
"gitHead": "6d0a628ca0e177cdb2052b8c141cb94cf0875d7a" | ||
"gitHead": "95900f4bc9cb2a286b154e2e742cfe97c5c31b1e" | ||
} |
@@ -1,7 +0,15 @@ | ||
import { screen, app, BrowserWindow, session } from 'electron'; | ||
import { screen, app, BrowserWindow, session, ipcMain } from 'electron'; | ||
import path from 'path'; | ||
import isDevelopment from 'electron-is-dev'; | ||
import { format as formatUrl } from 'url'; | ||
import initProcess from './process'; | ||
import log from 'electron-log'; | ||
import { autoUpdater } from 'electron-updater'; | ||
import initProcess, { restartBridge } from './process'; | ||
import { ipcMessageKeys } from './config'; | ||
// Set log level | ||
log.transports.file.level = 'info'; | ||
log.transports.console.level = 'info'; | ||
autoUpdater.logger = log; | ||
const isMac = process.platform === 'darwin'; | ||
@@ -89,3 +97,3 @@ const isWin = process.platform === 'win32'; | ||
console.log('browserWindow >>>> did-finish-load'); | ||
browserWindow.webContents.send('SET_ONEKEY_DESKTOP_GLOBALS', { | ||
browserWindow.webContents.send(ipcMessageKeys.INJECT_ONEKEY_DESKTOP_GLOBALS, { | ||
resourcesPath: (global as any).resourcesPath, | ||
@@ -214,2 +222,38 @@ staticPath: `file://${staticPath}`, | ||
ipcMain.on(ipcMessageKeys.UPDATE_RESTART, () => { | ||
log.info('App Quit And Install'); | ||
autoUpdater.quitAndInstall(); | ||
}); | ||
ipcMain.on(ipcMessageKeys.APP_RELOAD_BRIDGE_PROCESS, () => { | ||
restartBridge(); | ||
}); | ||
// 配置 GitHub 发布提供者 | ||
autoUpdater.setFeedURL({ | ||
provider: 'github', | ||
owner: 'OneKeyHQ', | ||
repo: 'hardware-js-sdk', | ||
private: false, | ||
releaseType: 'release', | ||
}); | ||
// 检查更新 | ||
app.on('ready', () => { | ||
autoUpdater.on('update-available', () => { | ||
log.info('Update available.'); | ||
mainWindow?.webContents?.send(ipcMessageKeys.UPDATE_AVAILABLE); | ||
}); | ||
autoUpdater.on('update-downloaded', () => { | ||
log.info('Update downloaded.'); | ||
mainWindow?.webContents?.send(ipcMessageKeys.UPDATE_DOWNLOADED); | ||
}); | ||
setTimeout(() => { | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
autoUpdater.checkForUpdatesAndNotify(); | ||
}, 5000); | ||
}); | ||
// wuit when all windows are closed, except on macOS. There, it's common | ||
@@ -216,0 +260,0 @@ // for applications and their menu bar to stay active until the user quits |
/* eslint-disable @typescript-eslint/no-unsafe-return */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars,@typescript-eslint/require-await */ | ||
import { ipcRenderer, contextBridge } from 'electron'; | ||
import { off } from 'process'; | ||
import { ipcMessageKeys } from './config'; | ||
@@ -15,3 +17,9 @@ export type DesktopAPI = { | ||
ipcRenderer.on('SET_ONEKEY_DESKTOP_GLOBALS', (_, globals) => { | ||
const validChannels = [ | ||
// Update events | ||
ipcMessageKeys.UPDATE_AVAILABLE, | ||
ipcMessageKeys.UPDATE_DOWNLOADED, | ||
]; | ||
ipcRenderer.on(ipcMessageKeys.INJECT_ONEKEY_DESKTOP_GLOBALS, (_, globals) => { | ||
// @ts-expect-error | ||
@@ -23,4 +31,12 @@ window.ONEKEY_DESKTOP_GLOBALS = globals; | ||
const desktopApi = { | ||
on: (channel: string, func: (...args: any[]) => any) => { | ||
if (validChannels.includes(channel)) { | ||
ipcRenderer.on(channel, (_, ...args) => func(...args)); | ||
} | ||
}, | ||
updateReload: () => { | ||
ipcRenderer.send(ipcMessageKeys.UPDATE_RESTART); | ||
}, | ||
reloadBridgeProcess: () => { | ||
ipcRenderer.send('app/reloadBridgeProcess'); | ||
ipcRenderer.send(ipcMessageKeys.APP_RELOAD_BRIDGE_PROCESS); | ||
}, | ||
@@ -27,0 +43,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
61139982
805
1
2
6
+ Addedelectron-log@^5.1.5
+ Addedelectron-updater@^6.2.1
+ Addedfs-extra@^11.2.0
+ Addedargparse@2.0.1(transitive)
+ Addedbuilder-util-runtime@9.2.10(transitive)
+ Addedelectron-log@5.2.2(transitive)
+ Addedelectron-updater@6.3.9(transitive)
+ Addedfs-extra@10.1.011.2.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedjs-yaml@4.1.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addedlazy-val@1.0.5(transitive)
+ Addedlodash.escaperegexp@4.1.2(transitive)
+ Addedlodash.isequal@4.5.0(transitive)
+ Addedsax@1.4.1(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addedtiny-typed-emitter@2.1.0(transitive)
+ Addeduniversalify@2.0.1(transitive)