core-3nweb-client-lib 0.33.0 → 0.34.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/build/core-ipc/common-caps.d.ts +4 -4
- package/build/core-ipc/common-caps.js +1 -1
- package/build/core-ipc/generic.d.ts +6 -6
- package/build/core-ipc/generic.js +14 -14
- package/build/core-ipc/json-ipc-wrapping/service-side-wrap.js +9 -1
- package/build/core-ipc/startup-caps.d.ts +3 -3
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CoreSide, ClientSide } from "../ipc-via-protobuf/connector";
|
|
2
2
|
import { ClientCAPsWraps, CAPsExposures, TypeDifference } from "./generic";
|
|
3
3
|
type W3N = web3n.caps.common.W3N;
|
|
4
|
-
export declare function exposeW3N<T extends W3N>(coreSide:
|
|
5
|
-
export declare function makeW3Nclient<T extends W3N>(clientSide:
|
|
6
|
-
export declare function promiseW3Nclient<T extends W3N>(clientSide:
|
|
4
|
+
export declare function exposeW3N<T extends W3N>(coreSide: CoreSide, w3n: T, extraCAPs?: CAPsExposures<TypeDifference<T, W3N>>): void;
|
|
5
|
+
export declare function makeW3Nclient<T extends W3N>(clientSide: ClientSide, extraCAPs?: ClientCAPsWraps<TypeDifference<T, W3N>>): T;
|
|
6
|
+
export declare function promiseW3Nclient<T extends W3N>(clientSide: ClientSide, extraCAPs?: ClientCAPsWraps<TypeDifference<T, W3N>>): Promise<T>;
|
|
7
7
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2020 - 2021, 2023 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2020 - 2021, 2023 - 2024 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ExposedObj, ExposedFn, CoreSideServices, Caller } from "../ipc-via-protobuf/connector";
|
|
1
|
+
import { ExposedObj, ExposedFn, CoreSideServices, Caller, CoreSide, CallerToClient, ClientSideServices, ClientSide } from "../ipc-via-protobuf/connector";
|
|
2
2
|
export type CAPsExposures<T> = {
|
|
3
|
-
[cap in keyof Required<T>]: (cap: any, coreSide: CoreSideServices) => ExposedObj<any> | ExposedFn;
|
|
3
|
+
[cap in keyof Required<T>]: (cap: any, coreSide: CoreSideServices, callerToClient: CallerToClient) => ExposedObj<any> | ExposedFn;
|
|
4
4
|
};
|
|
5
5
|
export type TypeDifference<T extends TExc, TExc extends object> = {
|
|
6
6
|
[cap in Exclude<keyof T, keyof TExc>]: T[cap];
|
|
7
7
|
};
|
|
8
|
-
export declare function exposeCAPs<T extends W3N, W3N extends object>(coreSide:
|
|
9
|
-
export type MakeCapClient = (clientSide: Caller, objPath: string[]) => any;
|
|
8
|
+
export declare function exposeCAPs<T extends W3N, W3N extends object>(coreSide: CoreSide, w3n: T, mainCAPs: CAPsExposures<W3N>, extraCAPs: CAPsExposures<TypeDifference<T, W3N>> | undefined): void;
|
|
9
|
+
export type MakeCapClient = (clientSide: Caller, objPath: string[], expServices: ClientSideServices) => any;
|
|
10
10
|
export type ClientCAPsWraps<T> = {
|
|
11
11
|
[cap in keyof Required<T>]: MakeCapClient;
|
|
12
12
|
};
|
|
13
|
-
export declare function makeClientSide<T extends W3N, W3N extends object>(
|
|
14
|
-
export declare function promiseClientSide<T extends W3N, W3N extends object>(
|
|
13
|
+
export declare function makeClientSide<T extends W3N, W3N extends object>({ caller, exposedServices }: ClientSide, mainCAPs: ClientCAPsWraps<W3N>, extraCAPs: ClientCAPsWraps<TypeDifference<T, W3N>> | undefined): T;
|
|
14
|
+
export declare function promiseClientSide<T extends W3N, W3N extends object>({ caller, exposedServices }: ClientSide, mainCAPs: ClientCAPsWraps<W3N>, extraCAPs: ClientCAPsWraps<TypeDifference<T, W3N>> | undefined): Promise<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2021 - 2022 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2021 - 2022, 2024 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -27,55 +27,55 @@ function exposeCAPs(coreSide, w3n, mainCAPs, extraCAPs) {
|
|
|
27
27
|
if (extraCAPs) {
|
|
28
28
|
addCAPsInExposure(expW3N, coreSide, w3n, extraCAPs);
|
|
29
29
|
}
|
|
30
|
-
coreSide.exposeW3NService(expW3N);
|
|
30
|
+
coreSide.exposedServices.exposeW3NService(expW3N);
|
|
31
31
|
}
|
|
32
|
-
function addCAPsInExposure(expW3N,
|
|
32
|
+
function addCAPsInExposure(expW3N, { exposedServices, caller: callerToClient }, w3n, capExposures) {
|
|
33
33
|
for (const capName in capExposures) {
|
|
34
34
|
const expose = capExposures[capName];
|
|
35
35
|
(0, assert_1.assert)(typeof expose === 'function');
|
|
36
36
|
(0, assert_1.assert)(!expW3N[capName], `Capability ${capName} is already exposed, and we specifically have no shadowing.`);
|
|
37
37
|
const cap = w3n[capName];
|
|
38
38
|
if (cap) {
|
|
39
|
-
expW3N[capName] = expose(cap,
|
|
39
|
+
expW3N[capName] = expose(cap, exposedServices, callerToClient);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
function makeClientSide(
|
|
44
|
-
(0, assert_1.assert)(!!
|
|
43
|
+
function makeClientSide({ caller, exposedServices }, mainCAPs, extraCAPs) {
|
|
44
|
+
(0, assert_1.assert)(!!caller.listObj);
|
|
45
45
|
const objPath = [connector_1.W3N_NAME];
|
|
46
|
-
const lstOfCAPs =
|
|
46
|
+
const lstOfCAPs = caller.listObj(objPath);
|
|
47
47
|
const w3n = {};
|
|
48
48
|
for (const cap of lstOfCAPs) {
|
|
49
49
|
const capObjPath = objPath.concat(cap);
|
|
50
50
|
if (mainCAPs[cap]) {
|
|
51
51
|
const makeCap = mainCAPs[cap];
|
|
52
52
|
(0, assert_1.assert)(typeof makeCap === 'function');
|
|
53
|
-
w3n[cap] = makeCap(
|
|
53
|
+
w3n[cap] = makeCap(caller, capObjPath, exposedServices);
|
|
54
54
|
}
|
|
55
55
|
else if (extraCAPs) {
|
|
56
56
|
const makeCap = extraCAPs[cap];
|
|
57
57
|
(0, assert_1.assert)(typeof makeCap === 'function');
|
|
58
|
-
w3n[cap] = makeCap(
|
|
58
|
+
w3n[cap] = makeCap(caller, capObjPath, exposedServices);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
return w3n;
|
|
62
62
|
}
|
|
63
|
-
async function promiseClientSide(
|
|
64
|
-
(0, assert_1.assert)(!!
|
|
63
|
+
async function promiseClientSide({ caller, exposedServices }, mainCAPs, extraCAPs) {
|
|
64
|
+
(0, assert_1.assert)(!!caller.listObjAsync);
|
|
65
65
|
const objPath = [connector_1.W3N_NAME];
|
|
66
|
-
const lstOfCAPs = (await
|
|
66
|
+
const lstOfCAPs = (await caller.listObjAsync(objPath));
|
|
67
67
|
const w3n = {};
|
|
68
68
|
for (const cap of lstOfCAPs) {
|
|
69
69
|
const capObjPath = objPath.concat(cap);
|
|
70
70
|
if (mainCAPs[cap]) {
|
|
71
71
|
const makeCap = mainCAPs[cap];
|
|
72
72
|
(0, assert_1.assert)(typeof makeCap === 'function');
|
|
73
|
-
w3n[cap] = await makeCap(
|
|
73
|
+
w3n[cap] = await makeCap(caller, capObjPath, exposedServices);
|
|
74
74
|
}
|
|
75
75
|
else if (extraCAPs) {
|
|
76
76
|
const makeCap = extraCAPs[cap];
|
|
77
77
|
(0, assert_1.assert)(typeof makeCap === 'function');
|
|
78
|
-
w3n[cap] = await makeCap(
|
|
78
|
+
w3n[cap] = await makeCap(caller, capObjPath, exposedServices);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
return w3n;
|
|
@@ -41,7 +41,15 @@ function wrapReqReplyFunc(srvOrFn, funcOrTransforms, transforms) {
|
|
|
41
41
|
let promise = (args ?
|
|
42
42
|
func.call(srv, ...args) :
|
|
43
43
|
func.call(srv));
|
|
44
|
-
|
|
44
|
+
if (promise === undefined) {
|
|
45
|
+
promise = Promise.resolve();
|
|
46
|
+
}
|
|
47
|
+
else if ((promise === null) || !promise.then) {
|
|
48
|
+
promise = Promise.resolve(resultToBuffer(promise, transforms));
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
promise = promise.then(result => resultToBuffer(result, transforms));
|
|
52
|
+
}
|
|
45
53
|
return { promise };
|
|
46
54
|
};
|
|
47
55
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CoreSide, ClientSide } from "../ipc-via-protobuf/connector";
|
|
2
2
|
import { ClientCAPsWraps, CAPsExposures, TypeDifference } from "./generic";
|
|
3
3
|
type W3N = web3n.startup.W3N;
|
|
4
|
-
export declare function exposeStartupW3N<T extends W3N>(coreSide:
|
|
5
|
-
export declare function makeStartupW3Nclient<T extends W3N>(clientSide:
|
|
4
|
+
export declare function exposeStartupW3N<T extends W3N>(coreSide: CoreSide, w3n: T, extraCAPs?: CAPsExposures<TypeDifference<T, W3N>>): void;
|
|
5
|
+
export declare function makeStartupW3Nclient<T extends W3N>(clientSide: ClientSide, extraCAPs?: ClientCAPsWraps<TypeDifference<T, W3N>>): W3N;
|
|
6
6
|
export {};
|