@dxos/client-services 0.1.29-next.ed4ce05 → 0.1.29
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/lib/browser/{chunk-ILMYW75X.mjs → chunk-ZIQUYEJS.mjs} +183 -94
- package/dist/lib/browser/{chunk-ILMYW75X.mjs.map → chunk-ZIQUYEJS.mjs.map} +4 -4
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/index.cjs +191 -104
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +196 -100
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/services/client-rpc-server.d.ts +22 -0
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -0
- package/dist/types/src/packlets/services/local-client-services.d.ts +2 -1
- package/dist/types/src/packlets/services/local-client-services.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +21 -6
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-registry.d.ts +3 -1
- package/dist/types/src/packlets/services/service-registry.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +2 -2
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +0 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts +4 -4
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/package.json +30 -30
- package/src/packlets/services/client-rpc-server.ts +91 -0
- package/src/packlets/services/local-client-services.ts +4 -0
- package/src/packlets/services/service-host.ts +51 -10
- package/src/packlets/services/service-registry.ts +9 -1
- package/src/packlets/system/system-service.ts +3 -3
- package/src/packlets/tests/shared-worker.test.ts +39 -42
- package/src/packlets/vault/iframe-host-runtime.ts +25 -34
- package/src/packlets/vault/worker-runtime.ts +5 -15
- package/src/packlets/vault/worker-session.ts +40 -28
package/dist/lib/node/index.cjs
CHANGED
|
@@ -1924,8 +1924,8 @@ var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
1924
1924
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
1925
1925
|
var import_node_assert12 = __toESM(require("node:assert"));
|
|
1926
1926
|
var import_async19 = require("@dxos/async");
|
|
1927
|
-
var
|
|
1928
|
-
var
|
|
1927
|
+
var import_client6 = require("@dxos/client");
|
|
1928
|
+
var import_debug7 = require("@dxos/debug");
|
|
1929
1929
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
1930
1930
|
var import_log15 = require("@dxos/log");
|
|
1931
1931
|
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -2757,7 +2757,8 @@ var SystemServiceImpl = class {
|
|
|
2757
2757
|
this._onReset = onReset;
|
|
2758
2758
|
}
|
|
2759
2759
|
async getConfig() {
|
|
2760
|
-
|
|
2760
|
+
var _a, _b;
|
|
2761
|
+
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
2761
2762
|
}
|
|
2762
2763
|
async updateStatus({ status }) {
|
|
2763
2764
|
await this._onUpdateStatus(status);
|
|
@@ -2785,19 +2786,70 @@ var SystemServiceImpl = class {
|
|
|
2785
2786
|
|
|
2786
2787
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
2787
2788
|
var import_async14 = require("@dxos/async");
|
|
2788
|
-
var import_client4 = require("@dxos/client");
|
|
2789
2789
|
var import_log10 = require("@dxos/log");
|
|
2790
2790
|
var import_messaging = require("@dxos/messaging");
|
|
2791
2791
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
2792
|
-
var import_rpc2 = require("@dxos/rpc");
|
|
2793
2792
|
var import_util7 = require("@dxos/util");
|
|
2794
2793
|
|
|
2794
|
+
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
2795
|
+
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
2796
|
+
var import_debug5 = require("@dxos/debug");
|
|
2797
|
+
var import_rpc = require("@dxos/rpc");
|
|
2798
|
+
var ClientRpcServer = class {
|
|
2799
|
+
constructor(params) {
|
|
2800
|
+
this._handlerCache = /* @__PURE__ */ new Map();
|
|
2801
|
+
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
2802
|
+
this._handleCall = handleCall;
|
|
2803
|
+
this._handleStream = handleStream;
|
|
2804
|
+
this._serviceRegistry = serviceRegistry;
|
|
2805
|
+
this._rpcPeer = new import_rpc.RpcPeer({
|
|
2806
|
+
...rpcOptions,
|
|
2807
|
+
callHandler: (method, params2) => {
|
|
2808
|
+
const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
|
|
2809
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
|
|
2810
|
+
if (this._handleCall) {
|
|
2811
|
+
return this._handleCall(methodName, params2, handler);
|
|
2812
|
+
} else {
|
|
2813
|
+
return handler(methodName, params2);
|
|
2814
|
+
}
|
|
2815
|
+
},
|
|
2816
|
+
streamHandler: (method, params2) => {
|
|
2817
|
+
const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
|
|
2818
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
2819
|
+
if (this._handleStream) {
|
|
2820
|
+
return import_codec_protobuf12.Stream.unwrapPromise(this._handleStream(methodName, params2, handler));
|
|
2821
|
+
} else {
|
|
2822
|
+
return handler(methodName, params2);
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
});
|
|
2826
|
+
}
|
|
2827
|
+
async open() {
|
|
2828
|
+
await this._rpcPeer.open();
|
|
2829
|
+
}
|
|
2830
|
+
async close() {
|
|
2831
|
+
await this._rpcPeer.close();
|
|
2832
|
+
}
|
|
2833
|
+
_getServiceHandler(serviceName) {
|
|
2834
|
+
var _a;
|
|
2835
|
+
if (!this._handlerCache.has(serviceName)) {
|
|
2836
|
+
const [key, descriptor] = (_a = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName)) != null ? _a : (0, import_debug5.raise)(new Error(`Service not available: ${serviceName}`));
|
|
2837
|
+
const service = this._serviceRegistry.services[key];
|
|
2838
|
+
if (!service) {
|
|
2839
|
+
throw new Error(`Service not available: ${serviceName}`);
|
|
2840
|
+
}
|
|
2841
|
+
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
2842
|
+
}
|
|
2843
|
+
return this._handlerCache.get(serviceName);
|
|
2844
|
+
}
|
|
2845
|
+
};
|
|
2846
|
+
|
|
2795
2847
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
2796
2848
|
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2797
2849
|
var import_async13 = require("@dxos/async");
|
|
2798
2850
|
var import_client3 = require("@dxos/client");
|
|
2799
2851
|
var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
|
|
2800
|
-
var
|
|
2852
|
+
var import_rpc2 = require("@dxos/rpc");
|
|
2801
2853
|
var ShellRuntimeImpl = class {
|
|
2802
2854
|
constructor(_port) {
|
|
2803
2855
|
this._port = _port;
|
|
@@ -2827,7 +2879,7 @@ var ShellRuntimeImpl = class {
|
|
|
2827
2879
|
await this._appRpc.rpc.AppService.setContext(context);
|
|
2828
2880
|
}
|
|
2829
2881
|
async open() {
|
|
2830
|
-
this._appRpc = (0,
|
|
2882
|
+
this._appRpc = (0, import_rpc2.createProtoRpcPeer)({
|
|
2831
2883
|
requested: import_client3.appServiceBundle,
|
|
2832
2884
|
exposed: import_client3.shellServiceBundle,
|
|
2833
2885
|
handlers: {
|
|
@@ -2900,17 +2952,6 @@ var IFrameHostRuntime = class {
|
|
|
2900
2952
|
this._configProvider = configProvider;
|
|
2901
2953
|
this._appPort = appPort;
|
|
2902
2954
|
this._shellPort = shellPort;
|
|
2903
|
-
this._getService = async (find) => {
|
|
2904
|
-
const error = await this._ready.wait();
|
|
2905
|
-
if (error) {
|
|
2906
|
-
throw error;
|
|
2907
|
-
}
|
|
2908
|
-
const service = await find(this._clientServices.services);
|
|
2909
|
-
if (!service) {
|
|
2910
|
-
throw new Error("Service not found");
|
|
2911
|
-
}
|
|
2912
|
-
return service;
|
|
2913
|
-
};
|
|
2914
2955
|
if (this._shellPort) {
|
|
2915
2956
|
this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
|
|
2916
2957
|
}
|
|
@@ -2925,7 +2966,7 @@ var IFrameHostRuntime = class {
|
|
|
2925
2966
|
var _a;
|
|
2926
2967
|
(0, import_log10.log)("starting...", {}, {
|
|
2927
2968
|
file: "iframe-host-runtime.ts",
|
|
2928
|
-
line:
|
|
2969
|
+
line: 67,
|
|
2929
2970
|
scope: this,
|
|
2930
2971
|
callSite: (f, a) => f(...a)
|
|
2931
2972
|
});
|
|
@@ -2943,21 +2984,30 @@ var IFrameHostRuntime = class {
|
|
|
2943
2984
|
transportFactory: this._transportFactory
|
|
2944
2985
|
})
|
|
2945
2986
|
});
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
|
|
2956
|
-
SpacesService: async () => await this._getService((services) => services.SpacesService),
|
|
2957
|
-
SystemService: async () => await this._getService((services) => services.SystemService),
|
|
2958
|
-
TracingService: async () => await this._getService((services) => services.TracingService)
|
|
2987
|
+
const middleware = {
|
|
2988
|
+
handleCall: async (method, params, handler) => {
|
|
2989
|
+
const error = await this._ready.wait({
|
|
2990
|
+
timeout: 3e3
|
|
2991
|
+
});
|
|
2992
|
+
if (error) {
|
|
2993
|
+
throw error;
|
|
2994
|
+
}
|
|
2995
|
+
return handler(method, params);
|
|
2959
2996
|
},
|
|
2960
|
-
|
|
2997
|
+
handleStream: async (method, params, handler) => {
|
|
2998
|
+
const error = await this._ready.wait({
|
|
2999
|
+
timeout: 3e3
|
|
3000
|
+
});
|
|
3001
|
+
if (error) {
|
|
3002
|
+
throw error;
|
|
3003
|
+
}
|
|
3004
|
+
return handler(method, params);
|
|
3005
|
+
}
|
|
3006
|
+
};
|
|
3007
|
+
this._clientRpc = new ClientRpcServer({
|
|
3008
|
+
serviceRegistry: this._clientServices.host.serviceRegistry,
|
|
3009
|
+
port: this._appPort,
|
|
3010
|
+
...middleware
|
|
2961
3011
|
});
|
|
2962
3012
|
await Promise.all([
|
|
2963
3013
|
this._clientServices.open(),
|
|
@@ -2967,7 +3017,7 @@ var IFrameHostRuntime = class {
|
|
|
2967
3017
|
this._ready.wake(void 0);
|
|
2968
3018
|
(0, import_log10.log)("started", {}, {
|
|
2969
3019
|
file: "iframe-host-runtime.ts",
|
|
2970
|
-
line:
|
|
3020
|
+
line: 110,
|
|
2971
3021
|
scope: this,
|
|
2972
3022
|
callSite: (f, a) => f(...a)
|
|
2973
3023
|
});
|
|
@@ -2975,7 +3025,7 @@ var IFrameHostRuntime = class {
|
|
|
2975
3025
|
this._ready.wake(err);
|
|
2976
3026
|
import_log10.log.catch(err, {}, {
|
|
2977
3027
|
file: "iframe-host-runtime.ts",
|
|
2978
|
-
line:
|
|
3028
|
+
line: 113,
|
|
2979
3029
|
scope: this,
|
|
2980
3030
|
callSite: (f, a) => f(...a)
|
|
2981
3031
|
});
|
|
@@ -2985,7 +3035,7 @@ var IFrameHostRuntime = class {
|
|
|
2985
3035
|
var _a;
|
|
2986
3036
|
(0, import_log10.log)("stopping...", {}, {
|
|
2987
3037
|
file: "iframe-host-runtime.ts",
|
|
2988
|
-
line:
|
|
3038
|
+
line: 118,
|
|
2989
3039
|
scope: this,
|
|
2990
3040
|
callSite: (f, a) => f(...a)
|
|
2991
3041
|
});
|
|
@@ -2994,7 +3044,7 @@ var IFrameHostRuntime = class {
|
|
|
2994
3044
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
2995
3045
|
(0, import_log10.log)("stopped", {}, {
|
|
2996
3046
|
file: "iframe-host-runtime.ts",
|
|
2997
|
-
line:
|
|
3047
|
+
line: 122,
|
|
2998
3048
|
scope: this,
|
|
2999
3049
|
callSite: (f, a) => f(...a)
|
|
3000
3050
|
});
|
|
@@ -3005,7 +3055,7 @@ __decorate3([
|
|
|
3005
3055
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
3006
3056
|
|
|
3007
3057
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
3008
|
-
var
|
|
3058
|
+
var import_client4 = require("@dxos/client");
|
|
3009
3059
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
3010
3060
|
var import_rpc3 = require("@dxos/rpc");
|
|
3011
3061
|
var IFrameProxyRuntime = class {
|
|
@@ -3016,8 +3066,8 @@ var IFrameProxyRuntime = class {
|
|
|
3016
3066
|
this._workerAppPort = workerAppPort;
|
|
3017
3067
|
this._shellPort = shellPort;
|
|
3018
3068
|
this._systemRpc = (0, import_rpc3.createProtoRpcPeer)({
|
|
3019
|
-
requested:
|
|
3020
|
-
exposed:
|
|
3069
|
+
requested: import_client4.workerServiceBundle,
|
|
3070
|
+
exposed: import_client4.iframeServiceBundle,
|
|
3021
3071
|
handlers: {
|
|
3022
3072
|
BridgeService: this._transportService,
|
|
3023
3073
|
IframeService: {
|
|
@@ -3143,7 +3193,7 @@ var import_network_manager5 = require("@dxos/network-manager");
|
|
|
3143
3193
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
3144
3194
|
var import_node_assert11 = __toESM(require("node:assert"));
|
|
3145
3195
|
var import_async16 = require("@dxos/async");
|
|
3146
|
-
var
|
|
3196
|
+
var import_client5 = require("@dxos/client");
|
|
3147
3197
|
var import_log12 = require("@dxos/log");
|
|
3148
3198
|
var import_rpc4 = require("@dxos/rpc");
|
|
3149
3199
|
var import_util8 = require("@dxos/util");
|
|
@@ -3158,40 +3208,48 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
3158
3208
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3159
3209
|
};
|
|
3160
3210
|
var WorkerSession = class {
|
|
3161
|
-
constructor({
|
|
3211
|
+
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal, options = {
|
|
3162
3212
|
heartbeatInterval: 1e3
|
|
3163
3213
|
} }) {
|
|
3164
3214
|
this._startTrigger = new import_async16.Trigger();
|
|
3165
3215
|
this.onClose = new import_util8.Callback();
|
|
3166
3216
|
(0, import_node_assert11.default)(options);
|
|
3167
|
-
(0, import_node_assert11.default)(
|
|
3217
|
+
(0, import_node_assert11.default)(serviceHost);
|
|
3168
3218
|
this._options = options;
|
|
3169
|
-
this.
|
|
3170
|
-
const
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3219
|
+
this._serviceHost = serviceHost;
|
|
3220
|
+
const middleware = {
|
|
3221
|
+
handleCall: async (method, params, handler) => {
|
|
3222
|
+
const error = await readySignal.wait({
|
|
3223
|
+
timeout: 3e3
|
|
3224
|
+
});
|
|
3225
|
+
if (error) {
|
|
3226
|
+
throw error;
|
|
3227
|
+
}
|
|
3228
|
+
return handler(method, params);
|
|
3229
|
+
},
|
|
3230
|
+
handleStream: async (method, params, handler) => {
|
|
3231
|
+
const error = await readySignal.wait({
|
|
3232
|
+
timeout: 3e3
|
|
3233
|
+
});
|
|
3234
|
+
if (error) {
|
|
3235
|
+
throw error;
|
|
3236
|
+
}
|
|
3237
|
+
return handler(method, params);
|
|
3238
|
+
}
|
|
3181
3239
|
};
|
|
3182
|
-
this._clientRpc =
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3240
|
+
this._clientRpc = new ClientRpcServer({
|
|
3241
|
+
serviceRegistry: this._serviceHost.serviceRegistry,
|
|
3242
|
+
port: appPort,
|
|
3243
|
+
...middleware
|
|
3186
3244
|
});
|
|
3187
|
-
this._shellClientRpc =
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3245
|
+
this._shellClientRpc = new ClientRpcServer({
|
|
3246
|
+
serviceRegistry: this._serviceHost.serviceRegistry,
|
|
3247
|
+
port: shellPort,
|
|
3248
|
+
...middleware
|
|
3191
3249
|
});
|
|
3192
3250
|
this._iframeRpc = (0, import_rpc4.createProtoRpcPeer)({
|
|
3193
|
-
requested:
|
|
3194
|
-
exposed:
|
|
3251
|
+
requested: import_client5.iframeServiceBundle,
|
|
3252
|
+
exposed: import_client5.workerServiceBundle,
|
|
3195
3253
|
handlers: {
|
|
3196
3254
|
WorkerService: {
|
|
3197
3255
|
start: async (request) => {
|
|
@@ -3205,7 +3263,7 @@ var WorkerSession = class {
|
|
|
3205
3263
|
} catch (err) {
|
|
3206
3264
|
import_log12.log.catch(err, {}, {
|
|
3207
3265
|
file: "worker-session.ts",
|
|
3208
|
-
line:
|
|
3266
|
+
line: 107,
|
|
3209
3267
|
scope: this,
|
|
3210
3268
|
callSite: (f, a) => f(...a)
|
|
3211
3269
|
});
|
|
@@ -3223,7 +3281,7 @@ var WorkerSession = class {
|
|
|
3223
3281
|
async open() {
|
|
3224
3282
|
import_log12.log.info("opening..", {}, {
|
|
3225
3283
|
file: "worker-session.ts",
|
|
3226
|
-
line:
|
|
3284
|
+
line: 121,
|
|
3227
3285
|
scope: this,
|
|
3228
3286
|
callSite: (f, a) => f(...a)
|
|
3229
3287
|
});
|
|
@@ -3243,7 +3301,7 @@ var WorkerSession = class {
|
|
|
3243
3301
|
err: err1
|
|
3244
3302
|
}, {
|
|
3245
3303
|
file: "worker-session.ts",
|
|
3246
|
-
line:
|
|
3304
|
+
line: 133,
|
|
3247
3305
|
scope: this,
|
|
3248
3306
|
callSite: (f, a) => f(...a)
|
|
3249
3307
|
});
|
|
@@ -3252,7 +3310,7 @@ var WorkerSession = class {
|
|
|
3252
3310
|
} catch (err) {
|
|
3253
3311
|
import_log12.log.catch(err, {}, {
|
|
3254
3312
|
file: "worker-session.ts",
|
|
3255
|
-
line:
|
|
3313
|
+
line: 137,
|
|
3256
3314
|
scope: this,
|
|
3257
3315
|
callSite: (f, a) => f(...a)
|
|
3258
3316
|
});
|
|
@@ -3263,7 +3321,7 @@ var WorkerSession = class {
|
|
|
3263
3321
|
async close() {
|
|
3264
3322
|
import_log12.log.info("closing..", {}, {
|
|
3265
3323
|
file: "worker-session.ts",
|
|
3266
|
-
line:
|
|
3324
|
+
line: 144,
|
|
3267
3325
|
scope: this,
|
|
3268
3326
|
callSite: (f, a) => f(...a)
|
|
3269
3327
|
});
|
|
@@ -3272,7 +3330,7 @@ var WorkerSession = class {
|
|
|
3272
3330
|
} catch (err) {
|
|
3273
3331
|
import_log12.log.catch(err, {}, {
|
|
3274
3332
|
file: "worker-session.ts",
|
|
3275
|
-
line:
|
|
3333
|
+
line: 148,
|
|
3276
3334
|
scope: this,
|
|
3277
3335
|
callSite: (f, a) => f(...a)
|
|
3278
3336
|
});
|
|
@@ -3291,7 +3349,7 @@ var WorkerSession = class {
|
|
|
3291
3349
|
} catch (e) {
|
|
3292
3350
|
import_log12.log.info("No shell connected.", {}, {
|
|
3293
3351
|
file: "worker-session.ts",
|
|
3294
|
-
line:
|
|
3352
|
+
line: 162,
|
|
3295
3353
|
scope: this,
|
|
3296
3354
|
callSite: (f, a) => f(...a)
|
|
3297
3355
|
});
|
|
@@ -3310,18 +3368,19 @@ var WorkerRuntime = class {
|
|
|
3310
3368
|
this._transportFactory = new import_network_manager5.WebRTCTransportProxyFactory();
|
|
3311
3369
|
this._ready = new import_async17.Trigger();
|
|
3312
3370
|
this.sessions = /* @__PURE__ */ new Set();
|
|
3371
|
+
this._clientServices = new ClientServicesHost();
|
|
3313
3372
|
}
|
|
3314
3373
|
async start() {
|
|
3315
3374
|
(0, import_log13.log)("starting...", {}, {
|
|
3316
3375
|
file: "worker-runtime.ts",
|
|
3317
|
-
line:
|
|
3376
|
+
line: 44,
|
|
3318
3377
|
scope: this,
|
|
3319
3378
|
callSite: (f, a) => f(...a)
|
|
3320
3379
|
});
|
|
3321
3380
|
try {
|
|
3322
3381
|
this._config = await this._configProvider();
|
|
3323
3382
|
const signalServer = this._config.get("runtime.services.signal.server");
|
|
3324
|
-
this._clientServices
|
|
3383
|
+
this._clientServices.initialize({
|
|
3325
3384
|
config: this._config,
|
|
3326
3385
|
networkManager: new import_network_manager5.NetworkManager({
|
|
3327
3386
|
log: true,
|
|
@@ -3335,7 +3394,7 @@ var WorkerRuntime = class {
|
|
|
3335
3394
|
this._ready.wake(void 0);
|
|
3336
3395
|
(0, import_log13.log)("started", {}, {
|
|
3337
3396
|
file: "worker-runtime.ts",
|
|
3338
|
-
line:
|
|
3397
|
+
line: 61,
|
|
3339
3398
|
scope: this,
|
|
3340
3399
|
callSite: (f, a) => f(...a)
|
|
3341
3400
|
});
|
|
@@ -3343,7 +3402,7 @@ var WorkerRuntime = class {
|
|
|
3343
3402
|
this._ready.wake(err);
|
|
3344
3403
|
import_log13.log.catch(err, {}, {
|
|
3345
3404
|
file: "worker-runtime.ts",
|
|
3346
|
-
line:
|
|
3405
|
+
line: 64,
|
|
3347
3406
|
scope: this,
|
|
3348
3407
|
callSite: (f, a) => f(...a)
|
|
3349
3408
|
});
|
|
@@ -3357,17 +3416,7 @@ var WorkerRuntime = class {
|
|
|
3357
3416
|
*/
|
|
3358
3417
|
async createSession({ appPort, systemPort, shellPort }) {
|
|
3359
3418
|
const session = new WorkerSession({
|
|
3360
|
-
|
|
3361
|
-
const error = await this._ready.wait();
|
|
3362
|
-
if (error) {
|
|
3363
|
-
throw error;
|
|
3364
|
-
}
|
|
3365
|
-
const service = find(this._clientServices.services);
|
|
3366
|
-
if (!service) {
|
|
3367
|
-
throw new Error("Service not found");
|
|
3368
|
-
}
|
|
3369
|
-
return service;
|
|
3370
|
-
},
|
|
3419
|
+
serviceHost: this._clientServices,
|
|
3371
3420
|
appPort,
|
|
3372
3421
|
systemPort,
|
|
3373
3422
|
shellPort,
|
|
@@ -3405,7 +3454,7 @@ var WorkerRuntime = class {
|
|
|
3405
3454
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3406
3455
|
var import_async18 = require("@dxos/async");
|
|
3407
3456
|
var import_credentials11 = require("@dxos/credentials");
|
|
3408
|
-
var
|
|
3457
|
+
var import_debug6 = require("@dxos/debug");
|
|
3409
3458
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3410
3459
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
3411
3460
|
var import_keyring = require("@dxos/keyring");
|
|
@@ -3439,7 +3488,7 @@ var ServiceContext = class {
|
|
|
3439
3488
|
networkManager: this.networkManager,
|
|
3440
3489
|
getIdentity: () => {
|
|
3441
3490
|
var _a;
|
|
3442
|
-
return (_a = this.identityManager.identity) != null ? _a : (0,
|
|
3491
|
+
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
|
|
3443
3492
|
},
|
|
3444
3493
|
acceptIdentity: this._acceptIdentity.bind(this),
|
|
3445
3494
|
keyring: this.keyring
|
|
@@ -3522,7 +3571,7 @@ var ServiceContext = class {
|
|
|
3522
3571
|
scope: this,
|
|
3523
3572
|
callSite: (f, a) => f(...a)
|
|
3524
3573
|
});
|
|
3525
|
-
const identity = (_a = this.identityManager.identity) != null ? _a : (0,
|
|
3574
|
+
const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
|
|
3526
3575
|
const signingContext = {
|
|
3527
3576
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3528
3577
|
identityKey: identity.identityKey,
|
|
@@ -3601,7 +3650,7 @@ var ServiceContext = class {
|
|
|
3601
3650
|
// packages/sdk/client-services/src/packlets/services/service-registry.ts
|
|
3602
3651
|
var ServiceRegistry = class {
|
|
3603
3652
|
// prettier-ignore
|
|
3604
|
-
constructor(_serviceBundle, _handlers) {
|
|
3653
|
+
constructor(_serviceBundle, _handlers = {}) {
|
|
3605
3654
|
this._serviceBundle = _serviceBundle;
|
|
3606
3655
|
this._handlers = _handlers;
|
|
3607
3656
|
}
|
|
@@ -3614,25 +3663,35 @@ var ServiceRegistry = class {
|
|
|
3614
3663
|
setServices(services) {
|
|
3615
3664
|
this._handlers = services;
|
|
3616
3665
|
}
|
|
3666
|
+
addService(name, service) {
|
|
3667
|
+
this._handlers[name] = service;
|
|
3668
|
+
}
|
|
3669
|
+
removeService(name) {
|
|
3670
|
+
delete this._handlers[name];
|
|
3671
|
+
}
|
|
3617
3672
|
};
|
|
3618
3673
|
|
|
3619
3674
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3620
3675
|
var ClientServicesHost = class {
|
|
3621
3676
|
constructor({
|
|
3622
3677
|
config,
|
|
3623
|
-
modelFactory = (0,
|
|
3678
|
+
modelFactory = (0, import_client6.createDefaultModelFactory)(),
|
|
3624
3679
|
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3625
3680
|
networkManager,
|
|
3626
|
-
storage
|
|
3681
|
+
storage,
|
|
3627
3682
|
// TODO(wittjosiah): Turn this on by default.
|
|
3628
3683
|
lockKey
|
|
3629
|
-
}) {
|
|
3684
|
+
} = {}) {
|
|
3630
3685
|
this._statusUpdate = new import_async19.Event();
|
|
3631
3686
|
this._open = false;
|
|
3632
|
-
this._config = config;
|
|
3633
|
-
this._modelFactory = modelFactory;
|
|
3634
|
-
this._networkManager = networkManager;
|
|
3635
3687
|
this._storage = storage;
|
|
3688
|
+
this._modelFactory = modelFactory;
|
|
3689
|
+
if (config) {
|
|
3690
|
+
this.initialize({
|
|
3691
|
+
config,
|
|
3692
|
+
networkManager
|
|
3693
|
+
});
|
|
3694
|
+
}
|
|
3636
3695
|
this._resourceLock = lockKey ? new VaultResourceLock({
|
|
3637
3696
|
lockKey,
|
|
3638
3697
|
onAcquire: () => this.open(),
|
|
@@ -3655,27 +3714,52 @@ var ClientServicesHost = class {
|
|
|
3655
3714
|
await this._serviceContext.reset();
|
|
3656
3715
|
}
|
|
3657
3716
|
});
|
|
3658
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
3717
|
+
this._serviceRegistry = new ServiceRegistry(import_client6.clientServiceBundle, {
|
|
3659
3718
|
SystemService: this._systemService
|
|
3660
3719
|
});
|
|
3661
3720
|
}
|
|
3662
3721
|
get isOpen() {
|
|
3663
3722
|
return this._open;
|
|
3664
3723
|
}
|
|
3724
|
+
get serviceRegistry() {
|
|
3725
|
+
return this._serviceRegistry;
|
|
3726
|
+
}
|
|
3665
3727
|
get descriptors() {
|
|
3666
3728
|
return this._serviceRegistry.descriptors;
|
|
3667
3729
|
}
|
|
3668
3730
|
get services() {
|
|
3669
3731
|
return this._serviceRegistry.services;
|
|
3670
3732
|
}
|
|
3733
|
+
/**
|
|
3734
|
+
* Initialize the service host with the config.
|
|
3735
|
+
* Config can also be provided in the constructor.
|
|
3736
|
+
* Can only be called once.
|
|
3737
|
+
*/
|
|
3738
|
+
initialize({ config, networkManager }) {
|
|
3739
|
+
(0, import_node_assert12.default)(!this._open, "service host is open");
|
|
3740
|
+
if (config) {
|
|
3741
|
+
(0, import_node_assert12.default)(!this._config, "config already set");
|
|
3742
|
+
this._config = config;
|
|
3743
|
+
if (!this._storage) {
|
|
3744
|
+
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3747
|
+
if (networkManager) {
|
|
3748
|
+
(0, import_node_assert12.default)(!this._networkManager, "network manager already set");
|
|
3749
|
+
this._networkManager = networkManager;
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3671
3752
|
async open() {
|
|
3672
3753
|
var _a, _b;
|
|
3673
3754
|
if (this._open) {
|
|
3674
3755
|
return;
|
|
3675
3756
|
}
|
|
3757
|
+
(0, import_node_assert12.default)(this._config, "config not set");
|
|
3758
|
+
(0, import_node_assert12.default)(this._storage, "storage not set");
|
|
3759
|
+
(0, import_node_assert12.default)(this._networkManager, "network manager not set");
|
|
3676
3760
|
(0, import_log15.log)("opening...", {}, {
|
|
3677
3761
|
file: "service-host.ts",
|
|
3678
|
-
line:
|
|
3762
|
+
line: 166,
|
|
3679
3763
|
scope: this,
|
|
3680
3764
|
callSite: (f, a) => f(...a)
|
|
3681
3765
|
});
|
|
@@ -3688,10 +3772,10 @@ var ClientServicesHost = class {
|
|
|
3688
3772
|
DeviceInvitationsService: new DeviceInvitationsServiceImpl(this._serviceContext.identityManager, this._serviceContext.deviceInvitations),
|
|
3689
3773
|
SpaceInvitationsService: new SpaceInvitationsServiceImpl(this._serviceContext.identityManager, () => {
|
|
3690
3774
|
var _a2;
|
|
3691
|
-
return (_a2 = this._serviceContext.spaceInvitations) != null ? _a2 : (0,
|
|
3775
|
+
return (_a2 = this._serviceContext.spaceInvitations) != null ? _a2 : (0, import_debug7.raise)(new Error("SpaceInvitations not initialized"));
|
|
3692
3776
|
}, () => {
|
|
3693
3777
|
var _a2;
|
|
3694
|
-
return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 : (0,
|
|
3778
|
+
return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 : (0, import_debug7.raise)(new Error("SpaceManager not initialized"));
|
|
3695
3779
|
}),
|
|
3696
3780
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
3697
3781
|
await this._serviceContext.initialized.wait();
|
|
@@ -3715,7 +3799,7 @@ var ClientServicesHost = class {
|
|
|
3715
3799
|
deviceKey
|
|
3716
3800
|
}, {
|
|
3717
3801
|
file: "service-host.ts",
|
|
3718
|
-
line:
|
|
3802
|
+
line: 219,
|
|
3719
3803
|
scope: this,
|
|
3720
3804
|
callSite: (f, a) => f(...a)
|
|
3721
3805
|
});
|
|
@@ -3730,7 +3814,7 @@ var ClientServicesHost = class {
|
|
|
3730
3814
|
deviceKey
|
|
3731
3815
|
}, {
|
|
3732
3816
|
file: "service-host.ts",
|
|
3733
|
-
line:
|
|
3817
|
+
line: 228,
|
|
3734
3818
|
scope: this,
|
|
3735
3819
|
callSite: (f, a) => f(...a)
|
|
3736
3820
|
});
|
|
@@ -3744,7 +3828,7 @@ var ClientServicesHost = class {
|
|
|
3744
3828
|
deviceKey
|
|
3745
3829
|
}, {
|
|
3746
3830
|
file: "service-host.ts",
|
|
3747
|
-
line:
|
|
3831
|
+
line: 233,
|
|
3748
3832
|
scope: this,
|
|
3749
3833
|
callSite: (f, a) => f(...a)
|
|
3750
3834
|
});
|
|
@@ -3762,6 +3846,9 @@ var LocalClientServices = class {
|
|
|
3762
3846
|
get services() {
|
|
3763
3847
|
return this._host.services;
|
|
3764
3848
|
}
|
|
3849
|
+
get host() {
|
|
3850
|
+
return this._host;
|
|
3851
|
+
}
|
|
3765
3852
|
async open() {
|
|
3766
3853
|
await this._host.open();
|
|
3767
3854
|
}
|