core-3nweb-client-lib 0.31.4 → 0.31.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.
|
@@ -32,7 +32,7 @@ declare namespace web3n.caps.common {
|
|
|
32
32
|
mail?: MailCAPSetting;
|
|
33
33
|
storage?: StorageCAPSetting;
|
|
34
34
|
mailerid?: true;
|
|
35
|
-
|
|
35
|
+
logToPlatform?: true;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
interface StorageCAPSetting {
|
|
@@ -65,12 +65,10 @@ declare namespace web3n.caps.common {
|
|
|
65
65
|
receivingFrom?: 'all' | { whitelist: string[]; };
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
type LogCAPSetting = 'all';
|
|
69
|
-
|
|
70
68
|
interface W3N {
|
|
69
|
+
log: Logger;
|
|
71
70
|
mail?: asmail.Service;
|
|
72
71
|
storage?: storage.Service;
|
|
73
|
-
log?: Logger;
|
|
74
72
|
mailerid?: mailerid.Service;
|
|
75
73
|
}
|
|
76
74
|
|
package/build/core/index.js
CHANGED
|
@@ -44,15 +44,49 @@ function makeW3Nclient(clientSide, extraCAPs) {
|
|
|
44
44
|
mailerid: mailerid_cap_ipc_1.makeMailerIdCaller,
|
|
45
45
|
storage: storage_cap_ipc_1.makeStorageCaller,
|
|
46
46
|
};
|
|
47
|
-
|
|
47
|
+
const clientW3N = (0, generic_1.makeClientSide)(clientSide, mainCAPs, extraCAPs);
|
|
48
|
+
addLogToConsoleIfNoCap(clientW3N);
|
|
49
|
+
return clientW3N;
|
|
48
50
|
}
|
|
49
|
-
function promiseW3Nclient(clientSide, extraCAPs) {
|
|
51
|
+
async function promiseW3Nclient(clientSide, extraCAPs) {
|
|
50
52
|
const mainCAPs = {
|
|
51
53
|
log: log_cap_1.makeLogCaller,
|
|
52
54
|
mail: asmail_cap_ipc_1.makeASMailCaller,
|
|
53
55
|
mailerid: mailerid_cap_ipc_1.makeMailerIdCaller,
|
|
54
56
|
storage: storage_cap_ipc_1.promiseStorageCaller,
|
|
55
57
|
};
|
|
56
|
-
|
|
58
|
+
const clientW3N = await (0, generic_1.promiseClientSide)(clientSide, mainCAPs, extraCAPs);
|
|
59
|
+
addLogToConsoleIfNoCap(clientW3N);
|
|
60
|
+
return clientW3N;
|
|
61
|
+
}
|
|
62
|
+
function addLogToConsoleIfNoCap(clientW3N) {
|
|
63
|
+
if (!clientW3N.log) {
|
|
64
|
+
clientW3N.log = async (type, msg, err) => {
|
|
65
|
+
if (type === 'error') {
|
|
66
|
+
if (err === undefined) {
|
|
67
|
+
console.error(msg);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
console.error(msg, err);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else if (type === 'warning') {
|
|
74
|
+
if (err === undefined) {
|
|
75
|
+
console.warn(msg);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
console.warn(msg, err);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
if (err === undefined) {
|
|
83
|
+
console.log(msg);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
console.log(msg, err);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
57
91
|
}
|
|
58
92
|
Object.freeze(exports);
|