@dxos/client-services 0.1.53-next.e9dc2bc → 0.1.54-main.270ec56
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-3EI4PM2V.mjs → chunk-F4BHRFH4.mjs} +74 -20
- package/dist/lib/browser/chunk-F4BHRFH4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -59
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/index.cjs +101 -87
- 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 +62 -57
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/services/index.d.ts +1 -0
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/package.json +32 -32
- package/src/packlets/services/index.ts +1 -0
- package/src/packlets/vault/worker-session.ts +5 -4
- package/dist/lib/browser/chunk-3EI4PM2V.mjs.map +0 -7
|
@@ -2082,6 +2082,59 @@ var SpaceInvitationProtocol = class {
|
|
|
2082
2082
|
}
|
|
2083
2083
|
};
|
|
2084
2084
|
|
|
2085
|
+
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
2086
|
+
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
2087
|
+
import { raise } from "@dxos/debug";
|
|
2088
|
+
import { parseMethodName, RpcPeer } from "@dxos/rpc";
|
|
2089
|
+
var ClientRpcServer = class {
|
|
2090
|
+
constructor(params) {
|
|
2091
|
+
this._handlerCache = /* @__PURE__ */ new Map();
|
|
2092
|
+
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
2093
|
+
this._handleCall = handleCall;
|
|
2094
|
+
this._handleStream = handleStream;
|
|
2095
|
+
this._serviceRegistry = serviceRegistry;
|
|
2096
|
+
this._rpcPeer = new RpcPeer({
|
|
2097
|
+
...rpcOptions,
|
|
2098
|
+
callHandler: (method, params2) => {
|
|
2099
|
+
const [serviceName, methodName] = parseMethodName(method);
|
|
2100
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
|
|
2101
|
+
if (this._handleCall) {
|
|
2102
|
+
return this._handleCall(methodName, params2, handler);
|
|
2103
|
+
} else {
|
|
2104
|
+
return handler(methodName, params2);
|
|
2105
|
+
}
|
|
2106
|
+
},
|
|
2107
|
+
streamHandler: (method, params2) => {
|
|
2108
|
+
const [serviceName, methodName] = parseMethodName(method);
|
|
2109
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
2110
|
+
if (this._handleStream) {
|
|
2111
|
+
return Stream9.unwrapPromise(this._handleStream(methodName, params2, handler));
|
|
2112
|
+
} else {
|
|
2113
|
+
return handler(methodName, params2);
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
2118
|
+
async open() {
|
|
2119
|
+
await this._rpcPeer.open();
|
|
2120
|
+
}
|
|
2121
|
+
async close() {
|
|
2122
|
+
await this._rpcPeer.close();
|
|
2123
|
+
}
|
|
2124
|
+
_getServiceHandler(serviceName) {
|
|
2125
|
+
var _a;
|
|
2126
|
+
if (!this._handlerCache.has(serviceName)) {
|
|
2127
|
+
const [key, descriptor] = (_a = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName)) != null ? _a : raise(new Error(`Service not available: ${serviceName}`));
|
|
2128
|
+
const service = this._serviceRegistry.services[key];
|
|
2129
|
+
if (!service) {
|
|
2130
|
+
throw new Error(`Service not available: ${serviceName}`);
|
|
2131
|
+
}
|
|
2132
|
+
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
2133
|
+
}
|
|
2134
|
+
return this._handlerCache.get(serviceName);
|
|
2135
|
+
}
|
|
2136
|
+
};
|
|
2137
|
+
|
|
2085
2138
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2086
2139
|
import { Event as Event5, scheduleTask as scheduleTask4, synchronized, trackLeaks } from "@dxos/async";
|
|
2087
2140
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
@@ -3016,8 +3069,8 @@ DataSpaceManager = _ts_decorate2([
|
|
|
3016
3069
|
|
|
3017
3070
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
3018
3071
|
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
3019
|
-
import { Stream as
|
|
3020
|
-
import { raise } from "@dxos/debug";
|
|
3072
|
+
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
3073
|
+
import { raise as raise2 } from "@dxos/debug";
|
|
3021
3074
|
import { SpaceNotFoundError } from "@dxos/echo-pipeline";
|
|
3022
3075
|
import { ApiError } from "@dxos/errors";
|
|
3023
3076
|
import { log as log11 } from "@dxos/log";
|
|
@@ -3043,7 +3096,7 @@ var SpacesServiceImpl = class {
|
|
|
3043
3096
|
async updateSpace({ spaceKey, state }) {
|
|
3044
3097
|
var _a;
|
|
3045
3098
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3046
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3099
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3047
3100
|
if (state) {
|
|
3048
3101
|
switch (state) {
|
|
3049
3102
|
case SpaceState3.ACTIVE:
|
|
@@ -3058,7 +3111,7 @@ var SpacesServiceImpl = class {
|
|
|
3058
3111
|
}
|
|
3059
3112
|
}
|
|
3060
3113
|
querySpaces() {
|
|
3061
|
-
return new
|
|
3114
|
+
return new Stream10(({ next, ctx }) => {
|
|
3062
3115
|
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
3063
3116
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3064
3117
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
@@ -3109,15 +3162,15 @@ var SpacesServiceImpl = class {
|
|
|
3109
3162
|
async postMessage({ spaceKey, channel, message }) {
|
|
3110
3163
|
var _a;
|
|
3111
3164
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3112
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3165
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3113
3166
|
await space.postMessage(getChannelId(channel), message);
|
|
3114
3167
|
}
|
|
3115
3168
|
subscribeMessages({ spaceKey, channel }) {
|
|
3116
|
-
return new
|
|
3169
|
+
return new Stream10(({ ctx, next }) => {
|
|
3117
3170
|
scheduleTask5(ctx, async () => {
|
|
3118
3171
|
var _a;
|
|
3119
3172
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3120
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3173
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3121
3174
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3122
3175
|
next(message);
|
|
3123
3176
|
});
|
|
@@ -3126,9 +3179,9 @@ var SpacesServiceImpl = class {
|
|
|
3126
3179
|
});
|
|
3127
3180
|
}
|
|
3128
3181
|
queryCredentials({ spaceKey }) {
|
|
3129
|
-
return new
|
|
3182
|
+
return new Stream10(({ ctx, next }) => {
|
|
3130
3183
|
var _a;
|
|
3131
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3184
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3132
3185
|
const processor = {
|
|
3133
3186
|
processCredential: async (credential) => {
|
|
3134
3187
|
next(credential);
|
|
@@ -3140,7 +3193,7 @@ var SpacesServiceImpl = class {
|
|
|
3140
3193
|
}
|
|
3141
3194
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3142
3195
|
var _a;
|
|
3143
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3196
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3144
3197
|
for (const credential of credentials != null ? credentials : []) {
|
|
3145
3198
|
await space.controlPipeline.writer.write({
|
|
3146
3199
|
credential: {
|
|
@@ -3152,7 +3205,7 @@ var SpacesServiceImpl = class {
|
|
|
3152
3205
|
async createEpoch({ spaceKey }) {
|
|
3153
3206
|
var _a;
|
|
3154
3207
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3155
|
-
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a :
|
|
3208
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3156
3209
|
await space.createEpoch();
|
|
3157
3210
|
}
|
|
3158
3211
|
_serializeSpace(space) {
|
|
@@ -3635,7 +3688,7 @@ import { TextModel } from "@dxos/text-model";
|
|
|
3635
3688
|
|
|
3636
3689
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3637
3690
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
3638
|
-
import { Stream as
|
|
3691
|
+
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
3639
3692
|
import { DeviceKind } from "@dxos/protocols/proto/dxos/client/services";
|
|
3640
3693
|
var DevicesServiceImpl = class {
|
|
3641
3694
|
constructor(_identityManager) {
|
|
@@ -3645,7 +3698,7 @@ var DevicesServiceImpl = class {
|
|
|
3645
3698
|
throw new Error("Method not implemented.");
|
|
3646
3699
|
}
|
|
3647
3700
|
queryDevices() {
|
|
3648
|
-
return new
|
|
3701
|
+
return new Stream11(({ next }) => {
|
|
3649
3702
|
const update = () => {
|
|
3650
3703
|
var _a;
|
|
3651
3704
|
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
@@ -3682,7 +3735,7 @@ var DevicesServiceImpl = class {
|
|
|
3682
3735
|
|
|
3683
3736
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
3684
3737
|
import { Event as Event7 } from "@dxos/async";
|
|
3685
|
-
import { Stream as
|
|
3738
|
+
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
3686
3739
|
import { getContextFromEntry, log as log14 } from "@dxos/log";
|
|
3687
3740
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
3688
3741
|
import { jsonify } from "@dxos/util";
|
|
@@ -3701,7 +3754,7 @@ var LoggingServiceImpl = class {
|
|
|
3701
3754
|
log14.runtimeConfig.processors.splice(index, 1);
|
|
3702
3755
|
}
|
|
3703
3756
|
queryLogs(request) {
|
|
3704
|
-
return new
|
|
3757
|
+
return new Stream12(({ ctx, next }) => {
|
|
3705
3758
|
const handler = (entry2) => {
|
|
3706
3759
|
var _a, _b, _c, _d, _e;
|
|
3707
3760
|
if (LOG_PROCESSING > 0) {
|
|
@@ -3757,14 +3810,14 @@ var shouldLog = (entry2, request) => {
|
|
|
3757
3810
|
var LOG_PROCESSING = 0;
|
|
3758
3811
|
|
|
3759
3812
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
3760
|
-
import { Stream as
|
|
3813
|
+
import { Stream as Stream13 } from "@dxos/codec-protobuf";
|
|
3761
3814
|
var NetworkServiceImpl = class {
|
|
3762
3815
|
constructor(networkManager, signalManager) {
|
|
3763
3816
|
this.networkManager = networkManager;
|
|
3764
3817
|
this.signalManager = signalManager;
|
|
3765
3818
|
}
|
|
3766
3819
|
queryStatus() {
|
|
3767
|
-
return new
|
|
3820
|
+
return new Stream13(({ next }) => {
|
|
3768
3821
|
const update = () => {
|
|
3769
3822
|
next({
|
|
3770
3823
|
swarm: this.networkManager.connectionState,
|
|
@@ -3789,7 +3842,7 @@ var NetworkServiceImpl = class {
|
|
|
3789
3842
|
};
|
|
3790
3843
|
|
|
3791
3844
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
3792
|
-
import { Stream as
|
|
3845
|
+
import { Stream as Stream14 } from "@dxos/codec-protobuf";
|
|
3793
3846
|
var SystemServiceImpl = class {
|
|
3794
3847
|
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
3795
3848
|
this._config = config;
|
|
@@ -3806,7 +3859,7 @@ var SystemServiceImpl = class {
|
|
|
3806
3859
|
await this._onUpdateStatus(status);
|
|
3807
3860
|
}
|
|
3808
3861
|
queryStatus() {
|
|
3809
|
-
return new
|
|
3862
|
+
return new Stream14(({ next }) => {
|
|
3810
3863
|
const update = () => {
|
|
3811
3864
|
next({
|
|
3812
3865
|
status: this._getCurrentStatus()
|
|
@@ -4101,6 +4154,7 @@ export {
|
|
|
4101
4154
|
InvitationsHandler,
|
|
4102
4155
|
InvitationsServiceImpl,
|
|
4103
4156
|
SpaceInvitationProtocol,
|
|
4157
|
+
ClientRpcServer,
|
|
4104
4158
|
DataSpace,
|
|
4105
4159
|
DataSpaceManager,
|
|
4106
4160
|
SpacesServiceImpl,
|
|
@@ -4112,4 +4166,4 @@ export {
|
|
|
4112
4166
|
createDefaultModelFactory,
|
|
4113
4167
|
ClientServicesHost
|
|
4114
4168
|
};
|
|
4115
|
-
//# sourceMappingURL=chunk-
|
|
4169
|
+
//# sourceMappingURL=chunk-F4BHRFH4.mjs.map
|