@onekeyfe/hd-transport-electron 1.2.2-alpha.8 → 1.2.3-alpha.1
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/dist/{index-00297050.js → index-985e2bf3.js} +33 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/{noble-ble-handler-95c5cf0d.js → noble-ble-handler-263d4736.js} +374 -88
- package/dist/noble-ble-handler.d.ts +11 -1
- package/dist/noble-ble-handler.d.ts.map +1 -1
- package/dist/noble-ble-timeouts.d.ts +1 -1
- package/dist/noble-ble-timeouts.d.ts.map +1 -1
- package/dist/types/desktop-api.d.ts +13 -0
- package/dist/types/desktop-api.d.ts.map +1 -1
- package/dist/types/noble-extended.d.ts +2 -0
- package/dist/types/noble-extended.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/noble-ble-handler.test.ts +653 -18
- package/src/index.ts +14 -1
- package/src/noble-ble-handler.ts +438 -109
- package/src/noble-ble-timeouts.ts +1 -1
- package/src/types/desktop-api.ts +44 -0
- package/src/types/noble-extended.ts +2 -0
|
@@ -30,12 +30,44 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
30
30
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
function isNobleBleIpcErrorResponse(response) {
|
|
34
|
+
var _a;
|
|
35
|
+
if (!response || typeof response !== 'object') {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
const candidate = response;
|
|
39
|
+
return (candidate.type === 'NobleBleIpcError' &&
|
|
40
|
+
candidate.success === false &&
|
|
41
|
+
Boolean(candidate.error) &&
|
|
42
|
+
typeof ((_a = candidate.error) === null || _a === void 0 ? void 0 : _a.name) === 'string' &&
|
|
43
|
+
typeof candidate.error.message === 'string' &&
|
|
44
|
+
typeof candidate.error.errorCode === 'number');
|
|
45
|
+
}
|
|
46
|
+
function invokeNobleBleIpc(request) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const response = yield request;
|
|
49
|
+
if (isNobleBleIpcErrorResponse(response)) {
|
|
50
|
+
return Promise.reject(response.error);
|
|
51
|
+
}
|
|
52
|
+
return response;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
33
56
|
function initNobleBleSupport(webContents) {
|
|
34
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const { setupNobleBleHandlers } = yield Promise.resolve().then(function () { return require('./noble-ble-handler-
|
|
58
|
+
const { setupNobleBleHandlers } = yield Promise.resolve().then(function () { return require('./noble-ble-handler-263d4736.js'); });
|
|
36
59
|
setupNobleBleHandlers(webContents);
|
|
37
60
|
});
|
|
38
61
|
}
|
|
62
|
+
function disposeNobleBleSupport(releaseNoble) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const handler = yield Promise.resolve().then(function () { return require('./noble-ble-handler-263d4736.js'); });
|
|
65
|
+
yield handler.disposeNobleBleSupport(releaseNoble);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
39
68
|
|
|
40
69
|
exports.__awaiter = __awaiter;
|
|
70
|
+
exports.disposeNobleBleSupport = disposeNobleBleSupport;
|
|
41
71
|
exports.initNobleBleSupport = initNobleBleSupport;
|
|
72
|
+
exports.invokeNobleBleIpc = invokeNobleBleIpc;
|
|
73
|
+
exports.isNobleBleIpcErrorResponse = isNobleBleIpcErrorResponse;
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ interface NobleModule {
|
|
|
17
17
|
state: string;
|
|
18
18
|
startScanning(serviceUUIDs: string[], allowDuplicates: boolean, callback?: (error?: Error) => void): void;
|
|
19
19
|
stopScanning(callback?: () => void): void;
|
|
20
|
+
stop(): void;
|
|
21
|
+
cancelConnect?(id: string): void;
|
|
20
22
|
on(event: 'stateChange', listener: (state: string) => void): void;
|
|
21
23
|
on(event: 'discover', listener: (peripheral: Peripheral) => void): void;
|
|
22
24
|
removeListener(event: 'stateChange', listener: (state: string) => void): void;
|
|
@@ -37,6 +39,23 @@ interface Logger {
|
|
|
37
39
|
interface NobleBleWriteOptions {
|
|
38
40
|
pacingDelayMs?: number;
|
|
39
41
|
}
|
|
42
|
+
type NobleBleIpcErrorPayload = {
|
|
43
|
+
name: string;
|
|
44
|
+
message: string;
|
|
45
|
+
errorCode: number;
|
|
46
|
+
params?: unknown;
|
|
47
|
+
};
|
|
48
|
+
type NobleBleIpcErrorResponse = {
|
|
49
|
+
type: 'NobleBleIpcError';
|
|
50
|
+
success: false;
|
|
51
|
+
error: NobleBleIpcErrorPayload;
|
|
52
|
+
};
|
|
53
|
+
declare function isNobleBleIpcErrorResponse(response: unknown): response is NobleBleIpcErrorResponse;
|
|
54
|
+
/**
|
|
55
|
+
* Keeps structured Noble errors intact across Electron's IPC and contextBridge
|
|
56
|
+
* boundaries. Every preload implementation must use this for Noble invokes.
|
|
57
|
+
*/
|
|
58
|
+
declare function invokeNobleBleIpc<T>(request: Promise<T | NobleBleIpcErrorResponse>): Promise<T>;
|
|
40
59
|
interface NobleBleAPI {
|
|
41
60
|
enumerate: () => Promise<{
|
|
42
61
|
id: string;
|
|
@@ -81,5 +100,9 @@ interface DesktopAPI {
|
|
|
81
100
|
}
|
|
82
101
|
|
|
83
102
|
declare function initNobleBleSupport(webContents: WebContents): Promise<void>;
|
|
103
|
+
/** Terminal process cleanup. A host sharing Noble can defer native stop until all users are idle. */
|
|
104
|
+
declare function disposeNobleBleSupport(releaseNoble?: (noble: {
|
|
105
|
+
stop(): void;
|
|
106
|
+
}) => void): Promise<void>;
|
|
84
107
|
|
|
85
|
-
export { CharacteristicPair, DesktopAPI, DeviceInfo, Logger, NobleBleAPI, NobleBleWriteOptions, NobleModule, initNobleBleSupport };
|
|
108
|
+
export { CharacteristicPair, DesktopAPI, DeviceInfo, Logger, NobleBleAPI, NobleBleIpcErrorPayload, NobleBleIpcErrorResponse, NobleBleWriteOptions, NobleModule, disposeNobleBleSupport, initNobleBleSupport, invokeNobleBleIpc, isNobleBleIpcErrorResponse };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,cAAc,SAAS,CAAC;AAGxB,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,cAAc,SAAS,CAAC;AAGxB,YAAY,EACV,UAAU,EACV,WAAW,EACX,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEpF,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,WAAW,iBAGjE;AAGD,wBAAsB,sBAAsB,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE;IAAE,IAAI,IAAI,IAAI,CAAA;CAAE,KAAK,IAAI,iBAG5F"}
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-985e2bf3.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
exports.disposeNobleBleSupport = index.disposeNobleBleSupport;
|
|
9
10
|
exports.initNobleBleSupport = index.initNobleBleSupport;
|
|
11
|
+
exports.invokeNobleBleIpc = index.invokeNobleBleIpc;
|
|
12
|
+
exports.isNobleBleIpcErrorResponse = index.isNobleBleIpcErrorResponse;
|