@cityofzion/bs-electron 3.0.4 → 3.0.5
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/main.js +3 -12
- package/dist/renderer.js +3 -12
- package/dist/utils.js +3 -4
- package/package.json +5 -6
package/dist/main.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -57,16 +48,16 @@ function exposeApiToRenderer(api) {
|
|
|
57
48
|
});
|
|
58
49
|
// For each asyncMethods, we need to create a listener so renderer can request the property value. We need to bind the function to the api instance to keep the context, the getValueFromPath function will do this for us
|
|
59
50
|
asyncMethods.forEach(method => {
|
|
60
|
-
electron_1.ipcMain.handle((0, utils_2.buildIpcChannelName)(apiName, method), (_event, ...args) =>
|
|
51
|
+
electron_1.ipcMain.handle((0, utils_2.buildIpcChannelName)(apiName, method), async (_event, ...args) => {
|
|
61
52
|
try {
|
|
62
53
|
const func = (0, utils_1.getValueFromPath)(api, method);
|
|
63
|
-
const data =
|
|
54
|
+
const data = await func(...args);
|
|
64
55
|
return { data };
|
|
65
56
|
}
|
|
66
57
|
catch (error) {
|
|
67
58
|
return { error: { message: error.message, stack: error.stack, name: error.name } };
|
|
68
59
|
}
|
|
69
|
-
})
|
|
60
|
+
});
|
|
70
61
|
});
|
|
71
62
|
exposedApis.set(apiName, { properties, asyncMethods, syncMethods });
|
|
72
63
|
}
|
package/dist/renderer.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.bindApiFromMain = bindApiFromMain;
|
|
13
4
|
const utils_1 = require("./utils");
|
|
@@ -57,9 +48,9 @@ function bindApiFromMain(apiName) {
|
|
|
57
48
|
// For each asyncMethods, we need to populate the api with a function that will send a sync message to main to request the method execution result
|
|
58
49
|
exposedApi.asyncMethods.forEach(method => {
|
|
59
50
|
(0, utils_1.populateObjectFromPath)(api, String(method), {
|
|
60
|
-
value: (...args) =>
|
|
51
|
+
value: async (...args) => {
|
|
61
52
|
const plainArgs = (0, utils_1.toPlainObject)(args);
|
|
62
|
-
const result =
|
|
53
|
+
const result = await window.ipcBsElectron.invoke((0, utils_1.buildIpcChannelName)(apiName, method), ...plainArgs);
|
|
63
54
|
if (result.error) {
|
|
64
55
|
const error = new Error(result.error.message);
|
|
65
56
|
error.name = result.error.name;
|
|
@@ -67,7 +58,7 @@ function bindApiFromMain(apiName) {
|
|
|
67
58
|
throw error;
|
|
68
59
|
}
|
|
69
60
|
return result.data;
|
|
70
|
-
}
|
|
61
|
+
},
|
|
71
62
|
});
|
|
72
63
|
});
|
|
73
64
|
boundApis.set(apiName, api);
|
package/dist/utils.js
CHANGED
|
@@ -106,7 +106,7 @@ function getPropertiesAndMethods(object) {
|
|
|
106
106
|
}
|
|
107
107
|
properties.add(keyString);
|
|
108
108
|
}
|
|
109
|
-
catch
|
|
109
|
+
catch {
|
|
110
110
|
continue;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
@@ -127,7 +127,6 @@ function getValueFromPath(obj, path) {
|
|
|
127
127
|
}, obj);
|
|
128
128
|
}
|
|
129
129
|
function populateObjectFromPath(obj, path, value) {
|
|
130
|
-
var _a;
|
|
131
130
|
const splittedPath = path.split('.');
|
|
132
131
|
let tempObj = obj;
|
|
133
132
|
for (let i = 0; i < splittedPath.length; i++) {
|
|
@@ -136,7 +135,7 @@ function populateObjectFromPath(obj, path, value) {
|
|
|
136
135
|
Object.defineProperty(tempObj, property, value);
|
|
137
136
|
}
|
|
138
137
|
else {
|
|
139
|
-
tempObj[property] =
|
|
138
|
+
tempObj[property] = tempObj[property] ?? {};
|
|
140
139
|
tempObj = tempObj[property];
|
|
141
140
|
}
|
|
142
141
|
}
|
|
@@ -184,7 +183,7 @@ function toPlainObject(obj) {
|
|
|
184
183
|
plain[key] = toPlainObject(obj[key]);
|
|
185
184
|
}
|
|
186
185
|
}
|
|
187
|
-
catch
|
|
186
|
+
catch {
|
|
188
187
|
// Skip properties that can't be accessed
|
|
189
188
|
continue;
|
|
190
189
|
}
|
package/package.json
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-electron",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.5",
|
|
4
4
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
5
|
-
"author": "Coz",
|
|
6
5
|
"license": "GPL-3.0-only",
|
|
6
|
+
"author": "Coz",
|
|
7
7
|
"files": [
|
|
8
8
|
"/dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"lodash.clonedeep": "~4.5.0",
|
|
12
|
-
"@cityofzion/blockchain-service": "3.0.
|
|
12
|
+
"@cityofzion/blockchain-service": "3.0.5"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
+
"@electron-toolkit/preload": "*",
|
|
15
16
|
"@types/lodash.clonedeep": "~4.5.9",
|
|
16
17
|
"@types/node": "~24.5.2",
|
|
17
|
-
"@electron-toolkit/preload": "*",
|
|
18
18
|
"electron": "*",
|
|
19
19
|
"eslint": "~9.36.0",
|
|
20
|
-
"ts-node": "~10.9.2",
|
|
21
20
|
"typescript": "~5.9.2"
|
|
22
21
|
},
|
|
23
22
|
"scripts": {
|
|
24
23
|
"build": "rm -rf ./dist && npm run typecheck && tsc",
|
|
25
|
-
"lint": "eslint .",
|
|
26
24
|
"format": "eslint --fix",
|
|
25
|
+
"lint": "eslint .",
|
|
27
26
|
"package": "npm run build && npm pack",
|
|
28
27
|
"typecheck": "tsc --noEmit"
|
|
29
28
|
}
|