hardware-example 1.0.38-alpha.0 → 1.0.39-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "hardware-example",
3
3
  "productName": "HardwareExample",
4
4
  "executableName": "onekey-hardware-example",
5
- "version": "1.0.38-alpha.0",
5
+ "version": "1.0.39-alpha.0",
6
6
  "author": "OneKey",
7
7
  "description": "End-to-end encrypted workspaces for teams",
8
8
  "main": "dist/index.js",
@@ -20,7 +20,6 @@
20
20
  "ts:check": "yarn tsc --noEmit"
21
21
  },
22
22
  "dependencies": {
23
- "@abandonware/noble": "^1.9.2-26",
24
23
  "debug": "4.3.4",
25
24
  "electron-is-dev": "^3.0.1",
26
25
  "electron-log": "^5.1.5",
@@ -38,8 +37,5 @@
38
37
  "webpack": "^5.90.2",
39
38
  "webpack-node-externals": "^3.0.0"
40
39
  },
41
- "resolutions": {
42
- "**/node-gyp": "^10.0.1"
43
- },
44
- "gitHead": "d33215ecb015dcaf397d2ad4787a641299932cf4"
40
+ "gitHead": "bf0cead4d7cd495de65024fda80a1ae748400be2"
45
41
  }
package/src/config.ts CHANGED
@@ -7,6 +7,4 @@ export const ipcMessageKeys = {
7
7
  APP_RELOAD_BRIDGE_PROCESS: 'app/reloadBridgeProcess',
8
8
 
9
9
  INJECT_ONEKEY_DESKTOP_GLOBALS: 'inject/onekeyDesktop',
10
-
11
- APP_RESTART: 'app/restart',
12
10
  };
package/src/index.ts CHANGED
@@ -1,10 +1,18 @@
1
- import { screen, app, BrowserWindow, session, ipcMain } from 'electron';
1
+ import {
2
+ screen,
3
+ app,
4
+ BrowserWindow,
5
+ session,
6
+ ipcMain,
7
+ USBDevice,
8
+ SerialPort,
9
+ HIDDevice,
10
+ } from 'electron';
2
11
  import path from 'path';
3
12
  import isDevelopment from 'electron-is-dev';
4
13
  import { format as formatUrl } from 'url';
5
14
  import log from 'electron-log';
6
15
  import { autoUpdater } from 'electron-updater';
7
- import { initNobleBleSupport } from '@onekeyfe/hd-transport-electron';
8
16
  import initProcess, { restartBridge } from './process';
9
17
  import { ipcMessageKeys } from './config';
10
18
 
@@ -80,7 +88,6 @@ function createMainWindow() {
80
88
  spellcheck: false,
81
89
  webviewTag: true,
82
90
  webSecurity: !isDevelopment,
83
- // @ts-expect-error
84
91
  nativeWindowOpen: true,
85
92
  allowRunningInsecureContent: isDevelopment,
86
93
  // webview injected js needs isolation=false, because property can not be exposeInMainWorld() when isolation enabled.
@@ -256,12 +263,6 @@ function createMainWindow() {
256
263
  }
257
264
  });
258
265
 
259
- initNobleBleSupport(browserWindow.webContents);
260
-
261
- ipcMain.on(ipcMessageKeys.APP_RESTART, () => {
262
- browserWindow?.reload();
263
- });
264
-
265
266
  return browserWindow;
266
267
  }
267
268
 
package/src/preload.ts CHANGED
@@ -1,24 +1,12 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-return */
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars,@typescript-eslint/require-await */
3
3
  import { ipcRenderer, contextBridge } from 'electron';
4
- import { EOneKeyBleMessageKeys } from '@onekeyfe/hd-shared';
5
- import type { DesktopAPI as BaseDesktopAPI, NobleBleAPI } from '@onekeyfe/hd-transport-electron';
4
+ import { off } from 'process';
6
5
  import { ipcMessageKeys } from './config';
7
6
 
8
- // Extend the base DesktopAPI with this specific application's needs
9
- export interface DesktopAPI extends BaseDesktopAPI {
10
- restart: () => void;
7
+ export type DesktopAPI = {
11
8
  reloadBridgeProcess: () => void;
12
-
13
- // Generic IPC methods
14
- invoke: (channel: string, ...args: any[]) => Promise<any>;
15
- on: (channel: string, callback: (...args: any[]) => void) => () => void;
16
- off?: (channel: string, callback?: (...args: any[]) => void) => void;
17
-
18
- // Make nobleBle required for this app
19
- nobleBle: NobleBleAPI;
20
- }
21
-
9
+ };
22
10
  declare global {
23
11
  interface Window {
24
12
  desktopApi: DesktopAPI;
@@ -33,30 +21,16 @@ const validChannels = [
33
21
  ];
34
22
 
35
23
  ipcRenderer.on(ipcMessageKeys.INJECT_ONEKEY_DESKTOP_GLOBALS, (_, globals) => {
36
- try {
37
- contextBridge.exposeInMainWorld('ONEKEY_DESKTOP_GLOBALS', globals);
38
- } catch (error) {
39
- // Fallback for development or when contextBridge is not available
40
- console.warn('Failed to expose ONEKEY_DESKTOP_GLOBALS via contextBridge:', error);
41
- }
24
+ // @ts-expect-error
25
+ window.ONEKEY_DESKTOP_GLOBALS = globals;
26
+ // contextBridge.exposeInMainWorld('ONEKEY_DESKTOP_GLOBALS', globals);
42
27
  });
43
28
 
44
29
  const desktopApi = {
45
- // Generic IPC methods
46
- invoke: (channel: string, ...args: any[]) => ipcRenderer.invoke(channel, ...args),
47
30
  on: (channel: string, func: (...args: any[]) => any) => {
48
31
  if (validChannels.includes(channel)) {
49
32
  ipcRenderer.on(channel, (_, ...args) => func(...args));
50
33
  }
51
- // For other channels, set up listener and return cleanup function
52
- const listener = (_: any, ...args: any[]) => func(...args);
53
- ipcRenderer.on(channel, listener);
54
- return () => {
55
- ipcRenderer.removeListener(channel, listener);
56
- };
57
- },
58
- restart: () => {
59
- ipcRenderer.send(ipcMessageKeys.APP_RESTART);
60
34
  },
61
35
  updateReload: () => {
62
36
  ipcRenderer.send(ipcMessageKeys.UPDATE_RESTART);
@@ -64,47 +38,7 @@ const desktopApi = {
64
38
  reloadBridgeProcess: () => {
65
39
  ipcRenderer.send(ipcMessageKeys.APP_RELOAD_BRIDGE_PROCESS);
66
40
  },
67
-
68
- // Noble BLE specific methods
69
- nobleBle: {
70
- enumerate: () => ipcRenderer.invoke(EOneKeyBleMessageKeys.NOBLE_BLE_ENUMERATE),
71
- getDevice: (uuid: string) =>
72
- ipcRenderer.invoke(EOneKeyBleMessageKeys.NOBLE_BLE_GET_DEVICE, uuid),
73
- connect: (uuid: string) => ipcRenderer.invoke(EOneKeyBleMessageKeys.NOBLE_BLE_CONNECT, uuid),
74
- disconnect: (uuid: string) =>
75
- ipcRenderer.invoke(EOneKeyBleMessageKeys.NOBLE_BLE_DISCONNECT, uuid),
76
- subscribe: (uuid: string) =>
77
- ipcRenderer.invoke(EOneKeyBleMessageKeys.NOBLE_BLE_SUBSCRIBE, uuid),
78
- unsubscribe: (uuid: string) =>
79
- ipcRenderer.invoke(EOneKeyBleMessageKeys.NOBLE_BLE_UNSUBSCRIBE, uuid),
80
- write: (uuid: string, data: string) =>
81
- ipcRenderer.invoke(EOneKeyBleMessageKeys.NOBLE_BLE_WRITE, uuid, data),
82
- onNotification: (callback: (deviceId: string, data: string) => void) => {
83
- const subscription = (_: unknown, deviceId: string, data: string) => {
84
- callback(deviceId, data);
85
- };
86
- ipcRenderer.on(EOneKeyBleMessageKeys.NOBLE_BLE_NOTIFICATION, subscription);
87
- return () => {
88
- ipcRenderer.removeListener(EOneKeyBleMessageKeys.NOBLE_BLE_NOTIFICATION, subscription);
89
- };
90
- },
91
- onDeviceDisconnected: (callback: (device: { id: string; name: string }) => void) => {
92
- const subscription = (_: unknown, device: { id: string; name: string }) => {
93
- callback(device);
94
- };
95
- ipcRenderer.on(EOneKeyBleMessageKeys.BLE_DEVICE_DISCONNECTED, subscription);
96
- return () => {
97
- ipcRenderer.removeListener(EOneKeyBleMessageKeys.BLE_DEVICE_DISCONNECTED, subscription);
98
- };
99
- },
100
- },
101
41
  };
102
42
 
103
- // Use contextBridge to safely expose the API
104
- try {
105
- contextBridge.exposeInMainWorld('desktopApi', desktopApi);
106
- } catch (error) {
107
- // Fallback for development or when contextBridge is not available
108
- console.warn('Failed to expose desktopApi via contextBridge:', error);
109
- (window as any).desktopApi = desktopApi;
110
- }
43
+ window.desktopApi = desktopApi;
44
+ // contextBridge.exposeInMainWorld('desktopApi', desktopApi);
package/webpack.config.ts CHANGED
@@ -47,12 +47,6 @@ module.exports = {
47
47
  ...pkg.devDependencies,
48
48
  }),
49
49
  }),
50
- {
51
- '@abandonware/noble': 'commonjs @abandonware/noble',
52
- '@abandonware/bluetooth-hci-socket': 'commonjs @abandonware/bluetooth-hci-socket',
53
- bufferutil: 'commonjs bufferutil',
54
- 'utf-8-validate': 'commonjs utf-8-validate',
55
- },
56
50
  ],
57
51
  output: {
58
52
  path: path.resolve(__dirname, 'dist'),