@dxos/client-services 0.1.56-main.50c104c → 0.1.56-main.538bda2
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-GGXRN2RN.mjs → chunk-Y4AYNWBO.mjs} +162 -222
- package/dist/lib/browser/chunk-Y4AYNWBO.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +7 -12
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +30 -45
- package/dist/lib/browser/packlets/testing/index.mjs.map +2 -2
- package/dist/lib/node/index.cjs +181 -246
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +194 -265
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +34 -34
- package/src/packlets/services/service-context.test.ts +59 -0
- package/src/packlets/services/service-context.ts +3 -0
- package/src/packlets/services/service-host.ts +6 -6
- package/src/packlets/spaces/data-space.ts +16 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-GGXRN2RN.mjs.map +0 -7
|
@@ -12,7 +12,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
12
12
|
const feedMap = new ComplexMap(PublicKey.hash);
|
|
13
13
|
const update = () => {
|
|
14
14
|
const { feeds } = feedStore;
|
|
15
|
-
feeds.filter((feed) => !
|
|
15
|
+
feeds.filter((feed) => !feedKeys?.length || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
|
|
16
16
|
if (!feedMap.has(feed.key)) {
|
|
17
17
|
feedMap.set(feed.key, feed);
|
|
18
18
|
feed.on("close", update);
|
|
@@ -20,15 +20,12 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
next({
|
|
23
|
-
feeds: Array.from(feedMap.values()).map((feed) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
downloaded: (_b = (_a = feed.core.bitfield) == null ? void 0 : _a.data.toBuffer()) != null ? _b : new Uint8Array()
|
|
30
|
-
};
|
|
31
|
-
})
|
|
23
|
+
feeds: Array.from(feedMap.values()).map((feed) => ({
|
|
24
|
+
feedKey: feed.key,
|
|
25
|
+
length: feed.properties.length,
|
|
26
|
+
bytes: feed.core.byteLength,
|
|
27
|
+
downloaded: feed.core.bitfield?.data.toBuffer() ?? new Uint8Array()
|
|
28
|
+
}))
|
|
32
29
|
});
|
|
33
30
|
};
|
|
34
31
|
subscriptions.add(feedStore.feedOpened.on(update));
|
|
@@ -104,13 +101,13 @@ var subscribeToSignal = ({ signalManager }) => new Stream2(({ next }) => {
|
|
|
104
101
|
recipient: message.recipient.asUint8Array(),
|
|
105
102
|
payload: message.payload
|
|
106
103
|
},
|
|
107
|
-
receivedAt: new Date()
|
|
104
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
108
105
|
});
|
|
109
106
|
});
|
|
110
107
|
signalManager.swarmEvent.on(ctx, (swarmEvent) => {
|
|
111
108
|
next({
|
|
112
109
|
swarmEvent: swarmEvent.swarmEvent,
|
|
113
|
-
receivedAt: new Date()
|
|
110
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
114
111
|
});
|
|
115
112
|
});
|
|
116
113
|
return () => {
|
|
@@ -121,13 +118,10 @@ var subscribeToNetworkTopics = ({ networkManager }) => new Stream2(({ next, clos
|
|
|
121
118
|
const update = () => {
|
|
122
119
|
try {
|
|
123
120
|
const topics = networkManager.topics;
|
|
124
|
-
const labeledTopics = topics.map((topic) => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
label: (_b = (_a = networkManager.getSwarm(topic)) == null ? void 0 : _a.label) != null ? _b : topic.toHex()
|
|
129
|
-
};
|
|
130
|
-
});
|
|
121
|
+
const labeledTopics = topics.map((topic) => ({
|
|
122
|
+
topic,
|
|
123
|
+
label: networkManager.getSwarm(topic)?.label ?? topic.toHex()
|
|
124
|
+
}));
|
|
131
125
|
next({
|
|
132
126
|
topics: labeledTopics
|
|
133
127
|
});
|
|
@@ -139,17 +133,15 @@ var subscribeToNetworkTopics = ({ networkManager }) => new Stream2(({ next, clos
|
|
|
139
133
|
update();
|
|
140
134
|
});
|
|
141
135
|
var subscribeToSwarmInfo = ({ networkManager }) => new Stream2(({ next }) => {
|
|
142
|
-
var _a;
|
|
143
136
|
const update = () => {
|
|
144
|
-
|
|
145
|
-
const info = (_a2 = networkManager.connectionLog) == null ? void 0 : _a2.swarms;
|
|
137
|
+
const info = networkManager.connectionLog?.swarms;
|
|
146
138
|
if (info) {
|
|
147
139
|
next({
|
|
148
140
|
data: info
|
|
149
141
|
});
|
|
150
142
|
}
|
|
151
143
|
};
|
|
152
|
-
|
|
144
|
+
networkManager.connectionLog?.update.on(update);
|
|
153
145
|
update();
|
|
154
146
|
});
|
|
155
147
|
var getNetworkPeers = ({ networkManager }, request) => {
|
|
@@ -158,7 +150,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
|
|
|
158
150
|
}
|
|
159
151
|
const map = networkManager.getSwarmMap(PublicKey2.from(request.topic));
|
|
160
152
|
return {
|
|
161
|
-
peers: map
|
|
153
|
+
peers: map?.peers.map((peer) => ({
|
|
162
154
|
...peer,
|
|
163
155
|
connections: peer.connections.map((connection) => connection.asUint8Array())
|
|
164
156
|
}))
|
|
@@ -174,14 +166,14 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
174
166
|
const spaces = [
|
|
175
167
|
...context.spaceManager.spaces.values()
|
|
176
168
|
];
|
|
177
|
-
const filteredSpaces = spaces.filter((space) => !
|
|
169
|
+
const filteredSpaces = spaces.filter((space) => !spaceKeys?.length || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)));
|
|
178
170
|
next({
|
|
179
171
|
spaces: filteredSpaces.map((space) => {
|
|
180
172
|
const spaceMetadata = context.metadataStore.spaces.find((spaceMetadata2) => spaceMetadata2.key.equals(space.key));
|
|
181
173
|
return {
|
|
182
174
|
key: space.key,
|
|
183
175
|
isOpen: space.isOpen,
|
|
184
|
-
timeframe: spaceMetadata
|
|
176
|
+
timeframe: spaceMetadata?.dataTimeframe,
|
|
185
177
|
genesisFeed: space.genesisFeedKey,
|
|
186
178
|
controlFeed: space.controlFeedKey,
|
|
187
179
|
dataFeed: space.dataFeedKey
|
|
@@ -195,7 +187,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
195
187
|
await update();
|
|
196
188
|
});
|
|
197
189
|
return () => {
|
|
198
|
-
unsubscribe
|
|
190
|
+
unsubscribe?.();
|
|
199
191
|
clearTimeout(timeout);
|
|
200
192
|
};
|
|
201
193
|
});
|
|
@@ -254,16 +246,15 @@ var DevtoolsServiceImpl = class {
|
|
|
254
246
|
};
|
|
255
247
|
}
|
|
256
248
|
async getStorageInfo() {
|
|
257
|
-
|
|
258
|
-
const storageUsage = (_c = await ((_b = (_a = this.params.context.storage).getDiskInfo) == null ? void 0 : _b.call(_a))) != null ? _c : {
|
|
249
|
+
const storageUsage = await this.params.context.storage.getDiskInfo?.() ?? {
|
|
259
250
|
used: 0
|
|
260
251
|
};
|
|
261
252
|
const navigatorInfo = typeof navigator === "object" ? await navigator.storage.estimate() : void 0;
|
|
262
253
|
return {
|
|
263
254
|
type: this.params.context.storage.type,
|
|
264
255
|
storageUsage: storageUsage.used,
|
|
265
|
-
originUsage:
|
|
266
|
-
usageQuota:
|
|
256
|
+
originUsage: navigatorInfo?.usage ?? 0,
|
|
257
|
+
usageQuota: navigatorInfo?.quota ?? 0
|
|
267
258
|
};
|
|
268
259
|
}
|
|
269
260
|
async getBlobs() {
|
|
@@ -449,7 +440,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
449
440
|
return await trigger.wait({
|
|
450
441
|
timeout: this._params.authTimeout
|
|
451
442
|
});
|
|
452
|
-
} catch
|
|
443
|
+
} catch {
|
|
453
444
|
return false;
|
|
454
445
|
} finally {
|
|
455
446
|
clear();
|
|
@@ -545,11 +536,10 @@ var Identity = class Identity2 {
|
|
|
545
536
|
return this._deviceStateMachine.deviceCredentialChain;
|
|
546
537
|
}
|
|
547
538
|
getAdmissionCredentials() {
|
|
548
|
-
var _a, _b;
|
|
549
539
|
return {
|
|
550
540
|
deviceKey: this.deviceKey,
|
|
551
|
-
controlFeedKey:
|
|
552
|
-
dataFeedKey:
|
|
541
|
+
controlFeedKey: this.space.controlFeedKey ?? failUndefined(),
|
|
542
|
+
dataFeedKey: this.space.dataFeedKey ?? failUndefined()
|
|
553
543
|
};
|
|
554
544
|
}
|
|
555
545
|
/**
|
|
@@ -670,7 +660,6 @@ var IdentityManager = class IdentityManager2 {
|
|
|
670
660
|
return this._identity;
|
|
671
661
|
}
|
|
672
662
|
async open(ctx) {
|
|
673
|
-
var _a;
|
|
674
663
|
const traceId = PublicKey3.random().toHex();
|
|
675
664
|
log3.trace("dxos.halo.identity-manager.open", trace2.begin({
|
|
676
665
|
id: traceId
|
|
@@ -696,7 +685,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
696
685
|
await this._identity.ready();
|
|
697
686
|
log3.trace("dxos.halo.identity", {
|
|
698
687
|
identityKey: identityRecord.identityKey,
|
|
699
|
-
displayName:
|
|
688
|
+
displayName: this._identity.profileDocument?.displayName
|
|
700
689
|
}, {
|
|
701
690
|
F: __dxlog_file3,
|
|
702
691
|
L: 82,
|
|
@@ -715,11 +704,9 @@ var IdentityManager = class IdentityManager2 {
|
|
|
715
704
|
});
|
|
716
705
|
}
|
|
717
706
|
async close() {
|
|
718
|
-
|
|
719
|
-
await ((_a = this._identity) == null ? void 0 : _a.close(new Context3()));
|
|
707
|
+
await this._identity?.close(new Context3());
|
|
720
708
|
}
|
|
721
709
|
async createIdentity({ displayName } = {}) {
|
|
722
|
-
var _a;
|
|
723
710
|
invariant2(!this._identity, "Identity already exists.", {
|
|
724
711
|
F: __dxlog_file3,
|
|
725
712
|
L: 96,
|
|
@@ -793,7 +780,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
793
780
|
await this._identity.ready();
|
|
794
781
|
log3.trace("dxos.halo.identity", {
|
|
795
782
|
identityKey: identityRecord.identityKey,
|
|
796
|
-
displayName:
|
|
783
|
+
displayName: this._identity.profileDocument?.displayName
|
|
797
784
|
}, {
|
|
798
785
|
F: __dxlog_file3,
|
|
799
786
|
L: 152,
|
|
@@ -816,7 +803,6 @@ var IdentityManager = class IdentityManager2 {
|
|
|
816
803
|
* Accept an existing identity. Expects it's device key to be authorized (now or later).
|
|
817
804
|
*/
|
|
818
805
|
async acceptIdentity(params) {
|
|
819
|
-
var _a;
|
|
820
806
|
log3("accepting identity", {
|
|
821
807
|
params
|
|
822
808
|
}, {
|
|
@@ -852,7 +838,7 @@ var IdentityManager = class IdentityManager2 {
|
|
|
852
838
|
await this._identity.ready();
|
|
853
839
|
log3.trace("dxos.halo.identity", {
|
|
854
840
|
identityKey: identityRecord.identityKey,
|
|
855
|
-
displayName:
|
|
841
|
+
displayName: this._identity.profileDocument?.displayName
|
|
856
842
|
}, {
|
|
857
843
|
F: __dxlog_file3,
|
|
858
844
|
L: 186,
|
|
@@ -1359,7 +1345,6 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1359
1345
|
};
|
|
1360
1346
|
}
|
|
1361
1347
|
async onOpen(context) {
|
|
1362
|
-
var _a;
|
|
1363
1348
|
await super.onOpen(context);
|
|
1364
1349
|
try {
|
|
1365
1350
|
await this.rpc.InvitationHostService.options({
|
|
@@ -1368,7 +1353,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1368
1353
|
await cancelWithContext(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1369
1354
|
timeout: OPTIONS_TIMEOUT
|
|
1370
1355
|
}));
|
|
1371
|
-
if (
|
|
1356
|
+
if (this._remoteOptions?.role !== Options.Role.GUEST) {
|
|
1372
1357
|
throw new InvalidInvitationExtensionRoleError(void 0, {
|
|
1373
1358
|
expected: Options.Role.GUEST,
|
|
1374
1359
|
remoteOptions: this._remoteOptions
|
|
@@ -1426,7 +1411,6 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1426
1411
|
};
|
|
1427
1412
|
}
|
|
1428
1413
|
async onOpen(context) {
|
|
1429
|
-
var _a;
|
|
1430
1414
|
await super.onOpen(context);
|
|
1431
1415
|
try {
|
|
1432
1416
|
log4("begin options", void 0, {
|
|
@@ -1447,7 +1431,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1447
1431
|
S: this,
|
|
1448
1432
|
C: (f, a) => f(...a)
|
|
1449
1433
|
});
|
|
1450
|
-
if (
|
|
1434
|
+
if (this._remoteOptions?.role !== Options.Role.HOST) {
|
|
1451
1435
|
throw new InvalidInvitationExtensionRoleError(void 0, {
|
|
1452
1436
|
expected: Options.Role.HOST,
|
|
1453
1437
|
remoteOptions: this._remoteOptions
|
|
@@ -1486,9 +1470,8 @@ var InvitationsHandler = class {
|
|
|
1486
1470
|
this._networkManager = _networkManager;
|
|
1487
1471
|
}
|
|
1488
1472
|
createInvitation(protocol, options) {
|
|
1489
|
-
|
|
1490
|
-
const
|
|
1491
|
-
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1473
|
+
const { invitationId = PublicKey5.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey5.random() } = options ?? {};
|
|
1474
|
+
const authCode = options?.authCode ?? (authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1492
1475
|
invariant6(protocol, void 0, {
|
|
1493
1476
|
F: __dxlog_file7,
|
|
1494
1477
|
L: 76,
|
|
@@ -1541,9 +1524,8 @@ var InvitationsHandler = class {
|
|
|
1541
1524
|
return invitation;
|
|
1542
1525
|
},
|
|
1543
1526
|
admit: async (admissionRequest) => {
|
|
1544
|
-
var _a2, _b, _c;
|
|
1545
1527
|
try {
|
|
1546
|
-
const deviceKey =
|
|
1528
|
+
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1547
1529
|
invariant6(deviceKey, void 0, {
|
|
1548
1530
|
F: __dxlog_file7,
|
|
1549
1531
|
L: 119,
|
|
@@ -2242,7 +2224,6 @@ var SpaceInvitationProtocol = class {
|
|
|
2242
2224
|
};
|
|
2243
2225
|
}
|
|
2244
2226
|
async admit(request, guestProfile) {
|
|
2245
|
-
var _a;
|
|
2246
2227
|
invariant8(this._spaceKey, void 0, {
|
|
2247
2228
|
F: __dxlog_file9,
|
|
2248
2229
|
L: 42,
|
|
@@ -2306,7 +2287,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2306
2287
|
space: {
|
|
2307
2288
|
credential: spaceMemberCredential,
|
|
2308
2289
|
controlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2309
|
-
dataTimeframe:
|
|
2290
|
+
dataTimeframe: space.dataPipeline.pipelineState?.timeframe
|
|
2310
2291
|
}
|
|
2311
2292
|
};
|
|
2312
2293
|
}
|
|
@@ -2410,9 +2391,8 @@ var ClientRpcServer = class {
|
|
|
2410
2391
|
await this._rpcPeer.close();
|
|
2411
2392
|
}
|
|
2412
2393
|
_getServiceHandler(serviceName) {
|
|
2413
|
-
var _a;
|
|
2414
2394
|
if (!this._handlerCache.has(serviceName)) {
|
|
2415
|
-
const [key, descriptor] =
|
|
2395
|
+
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise(new Error(`Service not available: ${serviceName}`));
|
|
2416
2396
|
const service = this._serviceRegistry.services[key];
|
|
2417
2397
|
if (!service) {
|
|
2418
2398
|
throw new Error(`Service not available: ${serviceName}`);
|
|
@@ -2433,7 +2413,7 @@ import { STORAGE_VERSION } from "@dxos/protocols";
|
|
|
2433
2413
|
import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
2434
2414
|
|
|
2435
2415
|
// packages/sdk/client-services/src/version.ts
|
|
2436
|
-
var DXOS_VERSION = "0.1.56-main.
|
|
2416
|
+
var DXOS_VERSION = "0.1.56-main.538bda2";
|
|
2437
2417
|
|
|
2438
2418
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
2439
2419
|
var getPlatform = () => {
|
|
@@ -2467,9 +2447,8 @@ var getPlatform = () => {
|
|
|
2467
2447
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2468
2448
|
var DEFAULT_TIMEOUT = 1e3;
|
|
2469
2449
|
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2470
|
-
var _a, _b, _c;
|
|
2471
2450
|
const diagnostics = {
|
|
2472
|
-
created: new Date().toISOString(),
|
|
2451
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2473
2452
|
platform: getPlatform(),
|
|
2474
2453
|
client: {
|
|
2475
2454
|
version: DXOS_VERSION,
|
|
@@ -2499,16 +2478,16 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2499
2478
|
spaceKey: identity.space.key,
|
|
2500
2479
|
profile: identity.profileDocument
|
|
2501
2480
|
};
|
|
2502
|
-
const { devices } =
|
|
2481
|
+
const { devices } = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
|
|
2503
2482
|
timeout: DEFAULT_TIMEOUT
|
|
2504
|
-
}).catch(() => void 0)
|
|
2483
|
+
}).catch(() => void 0) ?? {};
|
|
2505
2484
|
diagnostics.devices = devices;
|
|
2506
2485
|
if (serviceContext.dataSpaceManager) {
|
|
2507
|
-
diagnostics.spaces = await Promise.all(
|
|
2486
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2508
2487
|
}
|
|
2509
|
-
const { feeds = [] } =
|
|
2488
|
+
const { feeds = [] } = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2510
2489
|
timeout: DEFAULT_TIMEOUT
|
|
2511
|
-
}).catch(() => void 0)
|
|
2490
|
+
}).catch(() => void 0) ?? {};
|
|
2512
2491
|
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2513
2492
|
feedKey,
|
|
2514
2493
|
bytes,
|
|
@@ -2521,12 +2500,9 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
2521
2500
|
var getProperties = (space) => {
|
|
2522
2501
|
let properties = {};
|
|
2523
2502
|
try {
|
|
2524
|
-
const propertiesItem = space.dataPipeline.itemManager.items.find((item) =>
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
});
|
|
2528
|
-
const state = propertiesItem == null ? void 0 : propertiesItem.state;
|
|
2529
|
-
properties = state == null ? void 0 : state.data;
|
|
2503
|
+
const propertiesItem = space.dataPipeline.itemManager.items.find((item) => item.modelMeta?.type === DocumentModel.meta.type && item.state?.type === "dxos.sdk.client.Properties");
|
|
2504
|
+
const state = propertiesItem?.state;
|
|
2505
|
+
properties = state?.data;
|
|
2530
2506
|
} catch (err) {
|
|
2531
2507
|
log8.warn(err.message, void 0, {
|
|
2532
2508
|
F: __dxlog_file10,
|
|
@@ -2538,7 +2514,6 @@ var getProperties = (space) => {
|
|
|
2538
2514
|
return properties;
|
|
2539
2515
|
};
|
|
2540
2516
|
var getSpaceStats = async (space) => {
|
|
2541
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2542
2517
|
const stats = {
|
|
2543
2518
|
key: space.key,
|
|
2544
2519
|
metrics: space.metrics,
|
|
@@ -2546,18 +2521,15 @@ var getSpaceStats = async (space) => {
|
|
|
2546
2521
|
...credential.subject.assertion,
|
|
2547
2522
|
id: credential.id
|
|
2548
2523
|
})),
|
|
2549
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
|
|
2559
|
-
};
|
|
2560
|
-
}),
|
|
2524
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2525
|
+
identity: {
|
|
2526
|
+
identityKey: member.key,
|
|
2527
|
+
profile: {
|
|
2528
|
+
displayName: member.assertion.profile?.displayName
|
|
2529
|
+
}
|
|
2530
|
+
},
|
|
2531
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
|
|
2532
|
+
})),
|
|
2561
2533
|
pipeline: {
|
|
2562
2534
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
2563
2535
|
// currentEpoch: space.dataPipeline.currentEpoch,
|
|
@@ -2567,11 +2539,11 @@ var getSpaceStats = async (space) => {
|
|
|
2567
2539
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2568
2540
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
2569
2541
|
// TODO(burdon): Empty?
|
|
2570
|
-
dataFeeds:
|
|
2571
|
-
startDataTimeframe:
|
|
2572
|
-
currentDataTimeframe:
|
|
2573
|
-
targetDataTimeframe:
|
|
2574
|
-
totalDataTimeframe:
|
|
2542
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
2543
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
2544
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
2545
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
2546
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
2575
2547
|
}
|
|
2576
2548
|
};
|
|
2577
2549
|
if (space.dataPipeline.itemManager) {
|
|
@@ -2669,7 +2641,7 @@ var NotarizationPlugin = class {
|
|
|
2669
2641
|
errors.throw(err);
|
|
2670
2642
|
}
|
|
2671
2643
|
});
|
|
2672
|
-
opCtx
|
|
2644
|
+
opCtx?.onDispose(() => ctx.dispose());
|
|
2673
2645
|
if (timeout !== 0) {
|
|
2674
2646
|
scheduleTask3(ctx, () => {
|
|
2675
2647
|
log9.warn("Notarization timeout", {
|
|
@@ -2762,11 +2734,10 @@ var NotarizationPlugin = class {
|
|
|
2762
2734
|
* Called with credentials arriving from the control pipeline.
|
|
2763
2735
|
*/
|
|
2764
2736
|
async processCredential(credential) {
|
|
2765
|
-
var _a;
|
|
2766
2737
|
if (!credential.id) {
|
|
2767
2738
|
return;
|
|
2768
2739
|
}
|
|
2769
|
-
|
|
2740
|
+
this._processCredentialsTriggers.get(credential.id)?.wake();
|
|
2770
2741
|
this._processedCredentials.add(credential.id);
|
|
2771
2742
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2772
2743
|
}
|
|
@@ -2792,11 +2763,10 @@ var NotarizationPlugin = class {
|
|
|
2792
2763
|
* Requests from other peers to notarize credentials.
|
|
2793
2764
|
*/
|
|
2794
2765
|
async _onNotarize(request) {
|
|
2795
|
-
var _a;
|
|
2796
2766
|
if (!this._writer) {
|
|
2797
2767
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2798
2768
|
}
|
|
2799
|
-
for (const credential of
|
|
2769
|
+
for (const credential of request.credentials ?? []) {
|
|
2800
2770
|
invariant10(credential.id, "Credential must have an id", {
|
|
2801
2771
|
F: __dxlog_file11,
|
|
2802
2772
|
L: 200,
|
|
@@ -2885,6 +2855,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
2885
2855
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2886
2856
|
}
|
|
2887
2857
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2858
|
+
var ENABLE_FEED_PURGE = false;
|
|
2888
2859
|
var DataSpace = class DataSpace2 {
|
|
2889
2860
|
constructor(params) {
|
|
2890
2861
|
this._ctx = new Context7();
|
|
@@ -2896,7 +2867,6 @@ var DataSpace = class DataSpace2 {
|
|
|
2896
2867
|
this.error = void 0;
|
|
2897
2868
|
this.stateUpdate = new Event5();
|
|
2898
2869
|
this.metrics = {};
|
|
2899
|
-
var _a;
|
|
2900
2870
|
this._inner = params.inner;
|
|
2901
2871
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
2902
2872
|
this._gossip = params.gossip;
|
|
@@ -2905,7 +2875,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2905
2875
|
this._feedStore = params.feedStore;
|
|
2906
2876
|
this._metadataStore = params.metadataStore;
|
|
2907
2877
|
this._signingContext = params.signingContext;
|
|
2908
|
-
this._callbacks =
|
|
2878
|
+
this._callbacks = params.callbacks ?? {};
|
|
2909
2879
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2910
2880
|
trustedKeysProvider: () => new ComplexSet2(PublicKey7.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2911
2881
|
update: this._inner.stateUpdate,
|
|
@@ -2949,14 +2919,13 @@ var DataSpace = class DataSpace2 {
|
|
|
2949
2919
|
this._state = SpaceState.CONTROL_ONLY;
|
|
2950
2920
|
this.stateUpdate.emit();
|
|
2951
2921
|
this.metrics = {};
|
|
2952
|
-
this.metrics.open = new Date();
|
|
2922
|
+
this.metrics.open = /* @__PURE__ */ new Date();
|
|
2953
2923
|
}
|
|
2954
2924
|
async close() {
|
|
2955
2925
|
await this._close();
|
|
2956
2926
|
}
|
|
2957
2927
|
async _close() {
|
|
2958
|
-
|
|
2959
|
-
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2928
|
+
await this._callbacks.beforeClose?.();
|
|
2960
2929
|
this._state = SpaceState.CLOSED;
|
|
2961
2930
|
await this._ctx.dispose();
|
|
2962
2931
|
this._ctx = new Context7();
|
|
@@ -2978,13 +2947,13 @@ var DataSpace = class DataSpace2 {
|
|
|
2978
2947
|
initializeDataPipelineAsync() {
|
|
2979
2948
|
scheduleTask4(this._ctx, async () => {
|
|
2980
2949
|
try {
|
|
2981
|
-
this.metrics.pipelineInitBegin = new Date();
|
|
2950
|
+
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
2982
2951
|
await this.initializeDataPipeline();
|
|
2983
2952
|
} catch (err) {
|
|
2984
2953
|
if (err instanceof CancelledError) {
|
|
2985
2954
|
log10("data pipeline initialization cancelled", err, {
|
|
2986
2955
|
F: __dxlog_file12,
|
|
2987
|
-
L:
|
|
2956
|
+
L: 199,
|
|
2988
2957
|
S: this,
|
|
2989
2958
|
C: (f, a) => f(...a)
|
|
2990
2959
|
});
|
|
@@ -2992,7 +2961,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2992
2961
|
}
|
|
2993
2962
|
log10.error("Error initializing data pipeline", err, {
|
|
2994
2963
|
F: __dxlog_file12,
|
|
2995
|
-
L:
|
|
2964
|
+
L: 203,
|
|
2996
2965
|
S: this,
|
|
2997
2966
|
C: (f, a) => f(...a)
|
|
2998
2967
|
});
|
|
@@ -3000,12 +2969,11 @@ var DataSpace = class DataSpace2 {
|
|
|
3000
2969
|
this.error = err;
|
|
3001
2970
|
this.stateUpdate.emit();
|
|
3002
2971
|
} finally {
|
|
3003
|
-
this.metrics.ready = new Date();
|
|
2972
|
+
this.metrics.ready = /* @__PURE__ */ new Date();
|
|
3004
2973
|
}
|
|
3005
2974
|
});
|
|
3006
2975
|
}
|
|
3007
2976
|
async initializeDataPipeline() {
|
|
3008
|
-
var _a, _b, _c, _d;
|
|
3009
2977
|
if (this._state !== SpaceState.CONTROL_ONLY) {
|
|
3010
2978
|
throw new SystemError("Invalid operation");
|
|
3011
2979
|
}
|
|
@@ -3014,11 +2982,11 @@ var DataSpace = class DataSpace2 {
|
|
|
3014
2982
|
ctx: this._ctx,
|
|
3015
2983
|
breakOnStall: false
|
|
3016
2984
|
});
|
|
3017
|
-
this.metrics.controlPipelineReady = new Date();
|
|
2985
|
+
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3018
2986
|
await this._createWritableFeeds();
|
|
3019
2987
|
log10("writable feeds created", void 0, {
|
|
3020
2988
|
F: __dxlog_file12,
|
|
3021
|
-
L:
|
|
2989
|
+
L: 227,
|
|
3022
2990
|
S: this,
|
|
3023
2991
|
C: (f, a) => f(...a)
|
|
3024
2992
|
});
|
|
@@ -3031,11 +2999,11 @@ var DataSpace = class DataSpace2 {
|
|
|
3031
2999
|
}), this._inner.controlPipeline.writer));
|
|
3032
3000
|
}
|
|
3033
3001
|
await this._inner.initializeDataPipeline();
|
|
3034
|
-
this.metrics.dataPipelineOpen = new Date();
|
|
3002
|
+
this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
|
|
3035
3003
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3036
3004
|
log10("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3037
3005
|
F: __dxlog_file12,
|
|
3038
|
-
L:
|
|
3006
|
+
L: 248,
|
|
3039
3007
|
S: this,
|
|
3040
3008
|
C: (f, a) => f(...a)
|
|
3041
3009
|
});
|
|
@@ -3043,17 +3011,17 @@ var DataSpace = class DataSpace2 {
|
|
|
3043
3011
|
ctx: this._ctx,
|
|
3044
3012
|
breakOnStall: false
|
|
3045
3013
|
});
|
|
3046
|
-
this.metrics.dataPipelineReady = new Date();
|
|
3014
|
+
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3047
3015
|
log10("data pipeline ready", void 0, {
|
|
3048
3016
|
F: __dxlog_file12,
|
|
3049
|
-
L:
|
|
3017
|
+
L: 257,
|
|
3050
3018
|
S: this,
|
|
3051
3019
|
C: (f, a) => f(...a)
|
|
3052
3020
|
});
|
|
3053
|
-
await
|
|
3021
|
+
await this._callbacks.beforeReady?.();
|
|
3054
3022
|
this._state = SpaceState.READY;
|
|
3055
3023
|
this.stateUpdate.emit();
|
|
3056
|
-
await
|
|
3024
|
+
await this._callbacks.afterReady?.();
|
|
3057
3025
|
}
|
|
3058
3026
|
async _createWritableFeeds() {
|
|
3059
3027
|
const credentials = [];
|
|
@@ -3100,7 +3068,6 @@ var DataSpace = class DataSpace2 {
|
|
|
3100
3068
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
3101
3069
|
}
|
|
3102
3070
|
async createEpoch() {
|
|
3103
|
-
var _a, _b;
|
|
3104
3071
|
const epoch = await this.dataPipeline.createEpoch();
|
|
3105
3072
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
3106
3073
|
credential: {
|
|
@@ -3119,10 +3086,13 @@ var DataSpace = class DataSpace2 {
|
|
|
3119
3086
|
receipt.seq
|
|
3120
3087
|
]
|
|
3121
3088
|
]));
|
|
3122
|
-
|
|
3123
|
-
const
|
|
3124
|
-
|
|
3125
|
-
|
|
3089
|
+
if (ENABLE_FEED_PURGE) {
|
|
3090
|
+
for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
|
|
3091
|
+
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
3092
|
+
if (indexBeforeEpoch === void 0) {
|
|
3093
|
+
continue;
|
|
3094
|
+
}
|
|
3095
|
+
await feed.safeClear(0, indexBeforeEpoch + 1);
|
|
3126
3096
|
}
|
|
3127
3097
|
}
|
|
3128
3098
|
}
|
|
@@ -3181,7 +3151,6 @@ import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
|
3181
3151
|
import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
3182
3152
|
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
3183
3153
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
3184
|
-
var _a, _b, _c, _d;
|
|
3185
3154
|
const credentials = [
|
|
3186
3155
|
await createCredential({
|
|
3187
3156
|
signer: keyring,
|
|
@@ -3201,11 +3170,11 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3201
3170
|
spaceKey: space.key,
|
|
3202
3171
|
role: SpaceMember2.Role.ADMIN,
|
|
3203
3172
|
profile: signingContext.profile,
|
|
3204
|
-
genesisFeedKey:
|
|
3173
|
+
genesisFeedKey: space.controlFeedKey ?? failUndefined2()
|
|
3205
3174
|
}
|
|
3206
3175
|
}),
|
|
3207
3176
|
await signingContext.credentialSigner.createCredential({
|
|
3208
|
-
subject:
|
|
3177
|
+
subject: space.controlFeedKey ?? failUndefined2(),
|
|
3209
3178
|
assertion: {
|
|
3210
3179
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
3211
3180
|
spaceKey: space.key,
|
|
@@ -3215,7 +3184,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3215
3184
|
}
|
|
3216
3185
|
}),
|
|
3217
3186
|
await signingContext.credentialSigner.createCredential({
|
|
3218
|
-
subject:
|
|
3187
|
+
subject: space.dataFeedKey ?? failUndefined2(),
|
|
3219
3188
|
assertion: {
|
|
3220
3189
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
3221
3190
|
spaceKey: space.key,
|
|
@@ -3225,7 +3194,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
3225
3194
|
}
|
|
3226
3195
|
}),
|
|
3227
3196
|
await signingContext.credentialSigner.createCredential({
|
|
3228
|
-
subject:
|
|
3197
|
+
subject: space.key ?? failUndefined2(),
|
|
3229
3198
|
assertion: {
|
|
3230
3199
|
"@type": "dxos.halo.credentials.Epoch",
|
|
3231
3200
|
number: 0,
|
|
@@ -3604,9 +3573,8 @@ var SpacesServiceImpl = class {
|
|
|
3604
3573
|
return this._serializeSpace(space);
|
|
3605
3574
|
}
|
|
3606
3575
|
async updateSpace({ spaceKey, state }) {
|
|
3607
|
-
var _a;
|
|
3608
3576
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3609
|
-
const space =
|
|
3577
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3610
3578
|
if (state) {
|
|
3611
3579
|
switch (state) {
|
|
3612
3580
|
case SpaceState3.ACTIVE:
|
|
@@ -3670,17 +3638,15 @@ var SpacesServiceImpl = class {
|
|
|
3670
3638
|
});
|
|
3671
3639
|
}
|
|
3672
3640
|
async postMessage({ spaceKey, channel, message }) {
|
|
3673
|
-
var _a;
|
|
3674
3641
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3675
|
-
const space =
|
|
3642
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3676
3643
|
await space.postMessage(getChannelId(channel), message);
|
|
3677
3644
|
}
|
|
3678
3645
|
subscribeMessages({ spaceKey, channel }) {
|
|
3679
3646
|
return new Stream10(({ ctx, next }) => {
|
|
3680
3647
|
scheduleTask5(ctx, async () => {
|
|
3681
|
-
var _a;
|
|
3682
3648
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3683
|
-
const space =
|
|
3649
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3684
3650
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3685
3651
|
next(message);
|
|
3686
3652
|
});
|
|
@@ -3690,8 +3656,7 @@ var SpacesServiceImpl = class {
|
|
|
3690
3656
|
}
|
|
3691
3657
|
queryCredentials({ spaceKey }) {
|
|
3692
3658
|
return new Stream10(({ ctx, next }) => {
|
|
3693
|
-
|
|
3694
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise2(new SpaceNotFoundError(spaceKey));
|
|
3659
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3695
3660
|
const processor = {
|
|
3696
3661
|
processCredential: async (credential) => {
|
|
3697
3662
|
next(credential);
|
|
@@ -3702,9 +3667,8 @@ var SpacesServiceImpl = class {
|
|
|
3702
3667
|
});
|
|
3703
3668
|
}
|
|
3704
3669
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3705
|
-
|
|
3706
|
-
const
|
|
3707
|
-
for (const credential of credentials != null ? credentials : []) {
|
|
3670
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3671
|
+
for (const credential of credentials ?? []) {
|
|
3708
3672
|
await space.controlPipeline.writer.write({
|
|
3709
3673
|
credential: {
|
|
3710
3674
|
credential
|
|
@@ -3713,13 +3677,11 @@ var SpacesServiceImpl = class {
|
|
|
3713
3677
|
}
|
|
3714
3678
|
}
|
|
3715
3679
|
async createEpoch({ spaceKey }) {
|
|
3716
|
-
var _a;
|
|
3717
3680
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3718
|
-
const space =
|
|
3681
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
3719
3682
|
await space.createEpoch();
|
|
3720
3683
|
}
|
|
3721
3684
|
_serializeSpace(space) {
|
|
3722
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3723
3685
|
return {
|
|
3724
3686
|
spaceKey: space.key,
|
|
3725
3687
|
state: space.state,
|
|
@@ -3731,16 +3693,15 @@ var SpacesServiceImpl = class {
|
|
|
3731
3693
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
3732
3694
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
3733
3695
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
3734
|
-
dataFeeds:
|
|
3735
|
-
startDataTimeframe:
|
|
3736
|
-
currentDataTimeframe:
|
|
3737
|
-
targetDataTimeframe:
|
|
3738
|
-
totalDataTimeframe:
|
|
3696
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
3697
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
3698
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
3699
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
3700
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
3739
3701
|
},
|
|
3740
3702
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
3741
|
-
var _a2, _b2, _c2;
|
|
3742
3703
|
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
3743
|
-
const isMe =
|
|
3704
|
+
const isMe = this._identityManager.identity?.identityKey.equals(member.key);
|
|
3744
3705
|
if (isMe) {
|
|
3745
3706
|
peers.push(space.presence.getLocalState());
|
|
3746
3707
|
}
|
|
@@ -3748,14 +3709,14 @@ var SpacesServiceImpl = class {
|
|
|
3748
3709
|
identity: {
|
|
3749
3710
|
identityKey: member.key,
|
|
3750
3711
|
profile: {
|
|
3751
|
-
displayName:
|
|
3712
|
+
displayName: member.assertion.profile?.displayName ?? humanize(member.key)
|
|
3752
3713
|
}
|
|
3753
3714
|
},
|
|
3754
3715
|
presence: isMe || peers.length > 0 ? SpaceMember3.PresenceState.ONLINE : SpaceMember3.PresenceState.OFFLINE,
|
|
3755
3716
|
peerStates: peers
|
|
3756
3717
|
};
|
|
3757
3718
|
}),
|
|
3758
|
-
creator:
|
|
3719
|
+
creator: space.inner.spaceState.creator?.key,
|
|
3759
3720
|
cache: space.cache,
|
|
3760
3721
|
metrics: space.metrics
|
|
3761
3722
|
};
|
|
@@ -3778,6 +3739,7 @@ import { STORAGE_VERSION as STORAGE_VERSION2, trace as trace6 } from "@dxos/prot
|
|
|
3778
3739
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3779
3740
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
3780
3741
|
import { trace as Trace2 } from "@dxos/tracing";
|
|
3742
|
+
import { safeInstanceof } from "@dxos/util";
|
|
3781
3743
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
3782
3744
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3783
3745
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -3823,16 +3785,13 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3823
3785
|
});
|
|
3824
3786
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3825
3787
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3826
|
-
this._handlerFactories.set(Invitation5.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () =>
|
|
3827
|
-
var _a;
|
|
3828
|
-
return (_a = this.identityManager.identity) != null ? _a : failUndefined3();
|
|
3829
|
-
}, this._acceptIdentity.bind(this)));
|
|
3788
|
+
this._handlerFactories.set(Invitation5.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined3(), this._acceptIdentity.bind(this)));
|
|
3830
3789
|
}
|
|
3831
3790
|
async open(ctx) {
|
|
3832
3791
|
await this._checkStorageVersion();
|
|
3833
3792
|
log13("opening...", void 0, {
|
|
3834
3793
|
F: __dxlog_file15,
|
|
3835
|
-
L:
|
|
3794
|
+
L: 134,
|
|
3836
3795
|
S: this,
|
|
3837
3796
|
C: (f, a) => f(...a)
|
|
3838
3797
|
});
|
|
@@ -3840,7 +3799,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3840
3799
|
id: this._instanceId
|
|
3841
3800
|
}), {
|
|
3842
3801
|
F: __dxlog_file15,
|
|
3843
|
-
L:
|
|
3802
|
+
L: 135,
|
|
3844
3803
|
S: this,
|
|
3845
3804
|
C: (f, a) => f(...a)
|
|
3846
3805
|
});
|
|
@@ -3855,29 +3814,28 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3855
3814
|
id: this._instanceId
|
|
3856
3815
|
}), {
|
|
3857
3816
|
F: __dxlog_file15,
|
|
3858
|
-
L:
|
|
3817
|
+
L: 143,
|
|
3859
3818
|
S: this,
|
|
3860
3819
|
C: (f, a) => f(...a)
|
|
3861
3820
|
});
|
|
3862
3821
|
log13("opened", void 0, {
|
|
3863
3822
|
F: __dxlog_file15,
|
|
3864
|
-
L:
|
|
3823
|
+
L: 144,
|
|
3865
3824
|
S: this,
|
|
3866
3825
|
C: (f, a) => f(...a)
|
|
3867
3826
|
});
|
|
3868
3827
|
}
|
|
3869
3828
|
async close() {
|
|
3870
|
-
var _a;
|
|
3871
3829
|
log13("closing...", void 0, {
|
|
3872
3830
|
F: __dxlog_file15,
|
|
3873
|
-
L:
|
|
3831
|
+
L: 148,
|
|
3874
3832
|
S: this,
|
|
3875
3833
|
C: (f, a) => f(...a)
|
|
3876
3834
|
});
|
|
3877
3835
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3878
3836
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3879
3837
|
}
|
|
3880
|
-
await
|
|
3838
|
+
await this.dataSpaceManager?.close();
|
|
3881
3839
|
await this.identityManager.close();
|
|
3882
3840
|
await this.spaceManager.close();
|
|
3883
3841
|
await this.feedStore.close();
|
|
@@ -3886,7 +3844,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3886
3844
|
this.dataServiceSubscriptions.clear();
|
|
3887
3845
|
log13("closed", void 0, {
|
|
3888
3846
|
F: __dxlog_file15,
|
|
3889
|
-
L:
|
|
3847
|
+
L: 159,
|
|
3890
3848
|
S: this,
|
|
3891
3849
|
C: (f, a) => f(...a)
|
|
3892
3850
|
});
|
|
@@ -3900,7 +3858,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3900
3858
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3901
3859
|
invariant12(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
3902
3860
|
F: __dxlog_file15,
|
|
3903
|
-
L:
|
|
3861
|
+
L: 171,
|
|
3904
3862
|
S: this,
|
|
3905
3863
|
A: [
|
|
3906
3864
|
"factory",
|
|
@@ -3922,14 +3880,13 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3922
3880
|
}
|
|
3923
3881
|
// Called when identity is created.
|
|
3924
3882
|
async _initialize(ctx) {
|
|
3925
|
-
var _a;
|
|
3926
3883
|
log13("initializing spaces...", void 0, {
|
|
3927
3884
|
F: __dxlog_file15,
|
|
3928
|
-
L:
|
|
3885
|
+
L: 193,
|
|
3929
3886
|
S: this,
|
|
3930
3887
|
C: (f, a) => f(...a)
|
|
3931
3888
|
});
|
|
3932
|
-
const identity =
|
|
3889
|
+
const identity = this.identityManager.identity ?? failUndefined3();
|
|
3933
3890
|
const signingContext = {
|
|
3934
3891
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3935
3892
|
identityKey: identity.identityKey,
|
|
@@ -3948,7 +3905,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3948
3905
|
this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
|
|
3949
3906
|
invariant12(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
3950
3907
|
F: __dxlog_file15,
|
|
3951
|
-
L:
|
|
3908
|
+
L: 216,
|
|
3952
3909
|
S: this,
|
|
3953
3910
|
A: [
|
|
3954
3911
|
"this.dataSpaceManager",
|
|
@@ -3972,7 +3929,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3972
3929
|
details: assertion
|
|
3973
3930
|
}, {
|
|
3974
3931
|
F: __dxlog_file15,
|
|
3975
|
-
L:
|
|
3932
|
+
L: 232,
|
|
3976
3933
|
S: this,
|
|
3977
3934
|
C: (f, a) => f(...a)
|
|
3978
3935
|
});
|
|
@@ -3983,7 +3940,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3983
3940
|
details: assertion
|
|
3984
3941
|
}, {
|
|
3985
3942
|
F: __dxlog_file15,
|
|
3986
|
-
L:
|
|
3943
|
+
L: 236,
|
|
3987
3944
|
S: this,
|
|
3988
3945
|
C: (f, a) => f(...a)
|
|
3989
3946
|
});
|
|
@@ -3994,7 +3951,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
3994
3951
|
details: assertion
|
|
3995
3952
|
}, {
|
|
3996
3953
|
F: __dxlog_file15,
|
|
3997
|
-
L:
|
|
3954
|
+
L: 241,
|
|
3998
3955
|
S: this,
|
|
3999
3956
|
C: (f, a) => f(...a)
|
|
4000
3957
|
});
|
|
@@ -4005,7 +3962,7 @@ var ServiceContext = class ServiceContext2 {
|
|
|
4005
3962
|
} catch (err) {
|
|
4006
3963
|
log13.catch(err, void 0, {
|
|
4007
3964
|
F: __dxlog_file15,
|
|
4008
|
-
L:
|
|
3965
|
+
L: 247,
|
|
4009
3966
|
S: this,
|
|
4010
3967
|
C: (f, a) => f(...a)
|
|
4011
3968
|
});
|
|
@@ -4022,6 +3979,7 @@ _ts_decorate5([
|
|
|
4022
3979
|
Trace2.span()
|
|
4023
3980
|
], ServiceContext.prototype, "_initialize", null);
|
|
4024
3981
|
ServiceContext = _ts_decorate5([
|
|
3982
|
+
safeInstanceof("dxos.client-services.ServiceContext"),
|
|
4025
3983
|
Trace2.resource()
|
|
4026
3984
|
], ServiceContext);
|
|
4027
3985
|
|
|
@@ -4074,7 +4032,7 @@ var Lock = class {
|
|
|
4074
4032
|
S: this,
|
|
4075
4033
|
C: (f, a) => f(...a)
|
|
4076
4034
|
});
|
|
4077
|
-
} catch
|
|
4035
|
+
} catch {
|
|
4078
4036
|
log14("stealing lock...", void 0, {
|
|
4079
4037
|
F: __dxlog_file16,
|
|
4080
4038
|
L: 46,
|
|
@@ -4111,8 +4069,7 @@ var Lock = class {
|
|
|
4111
4069
|
void navigator.locks.request(this._lockKey, {
|
|
4112
4070
|
steal
|
|
4113
4071
|
}, async () => {
|
|
4114
|
-
|
|
4115
|
-
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
4072
|
+
await this._onAcquire?.();
|
|
4116
4073
|
acquired.wake();
|
|
4117
4074
|
this._releaseTrigger = new Trigger6();
|
|
4118
4075
|
await this._releaseTrigger.wait();
|
|
@@ -4122,7 +4079,7 @@ var Lock = class {
|
|
|
4122
4079
|
S: this,
|
|
4123
4080
|
C: (f, a) => f(...a)
|
|
4124
4081
|
});
|
|
4125
|
-
await
|
|
4082
|
+
await this._onRelease?.();
|
|
4126
4083
|
log14("released lock", void 0, {
|
|
4127
4084
|
F: __dxlog_file16,
|
|
4128
4085
|
L: 74,
|
|
@@ -4130,8 +4087,7 @@ var Lock = class {
|
|
|
4130
4087
|
C: (f, a) => f(...a)
|
|
4131
4088
|
});
|
|
4132
4089
|
}).catch(async () => {
|
|
4133
|
-
|
|
4134
|
-
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
4090
|
+
await this._onRelease?.();
|
|
4135
4091
|
});
|
|
4136
4092
|
await acquired.wait();
|
|
4137
4093
|
log14("recieved lock", {
|
|
@@ -4159,7 +4115,7 @@ import { createStorage, StorageType } from "@dxos/random-access-storage";
|
|
|
4159
4115
|
import { isNode } from "@dxos/util";
|
|
4160
4116
|
var StorageDriver = Runtime.Client.Storage.StorageDriver;
|
|
4161
4117
|
var createStorageObjects = (config) => {
|
|
4162
|
-
const { path = isNode() ? DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config
|
|
4118
|
+
const { path = isNode() ? DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config ?? {};
|
|
4163
4119
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
4164
4120
|
throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4165
4121
|
}
|
|
@@ -4255,21 +4211,17 @@ var DevicesServiceImpl = class {
|
|
|
4255
4211
|
queryDevices() {
|
|
4256
4212
|
return new Stream11(({ next }) => {
|
|
4257
4213
|
const update = () => {
|
|
4258
|
-
|
|
4259
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
4214
|
+
const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
|
|
4260
4215
|
if (!deviceKeys) {
|
|
4261
4216
|
next({
|
|
4262
4217
|
devices: []
|
|
4263
4218
|
});
|
|
4264
4219
|
} else {
|
|
4265
4220
|
next({
|
|
4266
|
-
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
|
|
4271
|
-
};
|
|
4272
|
-
})
|
|
4221
|
+
devices: Array.from(deviceKeys.values()).map((key) => ({
|
|
4222
|
+
deviceKey: key,
|
|
4223
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? DeviceKind.CURRENT : DeviceKind.TRUSTED
|
|
4224
|
+
}))
|
|
4273
4225
|
});
|
|
4274
4226
|
}
|
|
4275
4227
|
};
|
|
@@ -4297,7 +4249,7 @@ import { jsonify, numericalValues, tracer } from "@dxos/util";
|
|
|
4297
4249
|
var LoggingServiceImpl = class {
|
|
4298
4250
|
constructor() {
|
|
4299
4251
|
this._logs = new Event7();
|
|
4300
|
-
this._started = new Date();
|
|
4252
|
+
this._started = /* @__PURE__ */ new Date();
|
|
4301
4253
|
this._logProcessor = (_config, entry2) => {
|
|
4302
4254
|
this._logs.emit(entry2);
|
|
4303
4255
|
};
|
|
@@ -4327,8 +4279,7 @@ var LoggingServiceImpl = class {
|
|
|
4327
4279
|
*/
|
|
4328
4280
|
queryMetrics({ interval = 5e3 }) {
|
|
4329
4281
|
const getNumericalValues = (key) => {
|
|
4330
|
-
|
|
4331
|
-
const events = (_a = tracer.get(key)) != null ? _a : [];
|
|
4282
|
+
const events = tracer.get(key) ?? [];
|
|
4332
4283
|
return {
|
|
4333
4284
|
key,
|
|
4334
4285
|
stats: numericalValues(events, "duration")
|
|
@@ -4337,14 +4288,14 @@ var LoggingServiceImpl = class {
|
|
|
4337
4288
|
return new Stream12(({ next }) => {
|
|
4338
4289
|
const update = () => {
|
|
4339
4290
|
const metrics = {
|
|
4340
|
-
timestamp: new Date(),
|
|
4291
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4341
4292
|
values: [
|
|
4342
4293
|
getNumericalValues("dxos.echo.pipeline.control"),
|
|
4343
4294
|
getNumericalValues("dxos.echo.pipeline.data")
|
|
4344
4295
|
].filter(Boolean)
|
|
4345
4296
|
};
|
|
4346
4297
|
next({
|
|
4347
|
-
timestamp: new Date(),
|
|
4298
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4348
4299
|
metrics
|
|
4349
4300
|
});
|
|
4350
4301
|
};
|
|
@@ -4358,11 +4309,10 @@ var LoggingServiceImpl = class {
|
|
|
4358
4309
|
queryLogs(request) {
|
|
4359
4310
|
return new Stream12(({ ctx, next }) => {
|
|
4360
4311
|
const handler = (entry2) => {
|
|
4361
|
-
var _a, _b, _c, _d, _e;
|
|
4362
4312
|
if (LOG_PROCESSING > 0) {
|
|
4363
4313
|
return;
|
|
4364
4314
|
}
|
|
4365
|
-
if (
|
|
4315
|
+
if (entry2.meta?.F.includes("logging-service") || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
4366
4316
|
return;
|
|
4367
4317
|
}
|
|
4368
4318
|
if (!shouldLog(entry2, request)) {
|
|
@@ -4371,11 +4321,11 @@ var LoggingServiceImpl = class {
|
|
|
4371
4321
|
const record = {
|
|
4372
4322
|
...entry2,
|
|
4373
4323
|
context: jsonify(getContextFromEntry(entry2)),
|
|
4374
|
-
timestamp: new Date(),
|
|
4324
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4375
4325
|
meta: {
|
|
4376
4326
|
// TODO(dmaretskyi): Fix proto.
|
|
4377
|
-
file:
|
|
4378
|
-
line:
|
|
4327
|
+
file: entry2.meta?.F ?? "",
|
|
4328
|
+
line: entry2.meta?.L ?? 0
|
|
4379
4329
|
}
|
|
4380
4330
|
};
|
|
4381
4331
|
try {
|
|
@@ -4398,15 +4348,11 @@ var matchFilter = (filter, level, path, options) => {
|
|
|
4398
4348
|
}
|
|
4399
4349
|
};
|
|
4400
4350
|
var shouldLog = (entry2, request) => {
|
|
4401
|
-
|
|
4402
|
-
const options = (_a = request.options) != null ? _a : QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4351
|
+
const options = request.options ?? QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4403
4352
|
if (request.filters === void 0) {
|
|
4404
4353
|
return options === QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4405
4354
|
} else {
|
|
4406
|
-
return request.filters.some((filter) =>
|
|
4407
|
-
var _a2, _b;
|
|
4408
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
4409
|
-
});
|
|
4355
|
+
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
4410
4356
|
}
|
|
4411
4357
|
};
|
|
4412
4358
|
var LOG_PROCESSING = 0;
|
|
@@ -4457,8 +4403,7 @@ var SystemServiceImpl = class {
|
|
|
4457
4403
|
this._onReset = onReset;
|
|
4458
4404
|
}
|
|
4459
4405
|
async getConfig() {
|
|
4460
|
-
|
|
4461
|
-
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
4406
|
+
return this._config?.values ?? {};
|
|
4462
4407
|
}
|
|
4463
4408
|
/**
|
|
4464
4409
|
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
@@ -4466,7 +4411,7 @@ var SystemServiceImpl = class {
|
|
|
4466
4411
|
async getDiagnostics({ keys } = {}) {
|
|
4467
4412
|
const diagnostics = await this._getDiagnostics();
|
|
4468
4413
|
return {
|
|
4469
|
-
timestamp: new Date(),
|
|
4414
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4470
4415
|
diagnostics: JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer({
|
|
4471
4416
|
truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4472
4417
|
humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
@@ -4557,11 +4502,10 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4557
4502
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4558
4503
|
},
|
|
4559
4504
|
onUpdateStatus: async (status) => {
|
|
4560
|
-
var _a, _b;
|
|
4561
4505
|
if (!this.isOpen && status === SystemStatus.ACTIVE) {
|
|
4562
|
-
await
|
|
4506
|
+
await this._resourceLock?.acquire();
|
|
4563
4507
|
} else if (this.isOpen && status === SystemStatus.INACTIVE) {
|
|
4564
|
-
await
|
|
4508
|
+
await this._resourceLock?.release();
|
|
4565
4509
|
}
|
|
4566
4510
|
},
|
|
4567
4511
|
onReset: async () => {
|
|
@@ -4598,7 +4542,6 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4598
4542
|
* Can only be called once.
|
|
4599
4543
|
*/
|
|
4600
4544
|
initialize({ config, ...options }) {
|
|
4601
|
-
var _a, _b, _c;
|
|
4602
4545
|
invariant13(!this._open, "service host is open", {
|
|
4603
4546
|
F: __dxlog_file17,
|
|
4604
4547
|
L: 181,
|
|
@@ -4608,7 +4551,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4608
4551
|
"'service host is open'"
|
|
4609
4552
|
]
|
|
4610
4553
|
});
|
|
4611
|
-
log16
|
|
4554
|
+
log16("initializing...", void 0, {
|
|
4612
4555
|
F: __dxlog_file17,
|
|
4613
4556
|
L: 182,
|
|
4614
4557
|
S: this,
|
|
@@ -4630,8 +4573,8 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4630
4573
|
}
|
|
4631
4574
|
}
|
|
4632
4575
|
const { connectionLog = true, transportFactory = createWebRTCTransportFactory({
|
|
4633
|
-
iceServers:
|
|
4634
|
-
}), signalManager = new WebsocketSignalManager(
|
|
4576
|
+
iceServers: this._config?.get("runtime.services.ice")
|
|
4577
|
+
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4635
4578
|
this._signalManager = signalManager;
|
|
4636
4579
|
invariant13(!this._networkManager, "network manager already set", {
|
|
4637
4580
|
F: __dxlog_file17,
|
|
@@ -4647,7 +4590,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4647
4590
|
transportFactory,
|
|
4648
4591
|
signalManager
|
|
4649
4592
|
});
|
|
4650
|
-
log16
|
|
4593
|
+
log16("initialized", void 0, {
|
|
4651
4594
|
F: __dxlog_file17,
|
|
4652
4595
|
L: 208,
|
|
4653
4596
|
S: this,
|
|
@@ -4655,7 +4598,6 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4655
4598
|
});
|
|
4656
4599
|
}
|
|
4657
4600
|
async open(ctx) {
|
|
4658
|
-
var _a, _b, _c;
|
|
4659
4601
|
if (this._open) {
|
|
4660
4602
|
return;
|
|
4661
4603
|
}
|
|
@@ -4705,15 +4647,15 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4705
4647
|
]
|
|
4706
4648
|
});
|
|
4707
4649
|
this._opening = true;
|
|
4708
|
-
log16
|
|
4709
|
-
lockKey:
|
|
4650
|
+
log16("opening...", {
|
|
4651
|
+
lockKey: this._resourceLock?.lockKey
|
|
4710
4652
|
}, {
|
|
4711
4653
|
F: __dxlog_file17,
|
|
4712
4654
|
L: 227,
|
|
4713
4655
|
S: this,
|
|
4714
4656
|
C: (f, a) => f(...a)
|
|
4715
4657
|
});
|
|
4716
|
-
await
|
|
4658
|
+
await this._resourceLock?.acquire();
|
|
4717
4659
|
await this._loggingService.open();
|
|
4718
4660
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4719
4661
|
this._serviceRegistry.setServices({
|
|
@@ -4740,8 +4682,8 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4740
4682
|
this._opening = false;
|
|
4741
4683
|
this._open = true;
|
|
4742
4684
|
this._statusUpdate.emit();
|
|
4743
|
-
const deviceKey =
|
|
4744
|
-
log16
|
|
4685
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4686
|
+
log16("opened", {
|
|
4745
4687
|
deviceKey
|
|
4746
4688
|
}, {
|
|
4747
4689
|
F: __dxlog_file17,
|
|
@@ -4759,12 +4701,11 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4759
4701
|
});
|
|
4760
4702
|
}
|
|
4761
4703
|
async close() {
|
|
4762
|
-
var _a;
|
|
4763
4704
|
if (!this._open) {
|
|
4764
4705
|
return;
|
|
4765
4706
|
}
|
|
4766
|
-
const deviceKey =
|
|
4767
|
-
log16
|
|
4707
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4708
|
+
log16("closing...", {
|
|
4768
4709
|
deviceKey
|
|
4769
4710
|
}, {
|
|
4770
4711
|
F: __dxlog_file17,
|
|
@@ -4779,7 +4720,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4779
4720
|
await this._serviceContext.close();
|
|
4780
4721
|
this._open = false;
|
|
4781
4722
|
this._statusUpdate.emit();
|
|
4782
|
-
log16
|
|
4723
|
+
log16("closed", {
|
|
4783
4724
|
deviceKey
|
|
4784
4725
|
}, {
|
|
4785
4726
|
F: __dxlog_file17,
|
|
@@ -4789,7 +4730,6 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4789
4730
|
});
|
|
4790
4731
|
}
|
|
4791
4732
|
async reset() {
|
|
4792
|
-
var _a, _b, _c;
|
|
4793
4733
|
const traceId = PublicKey10.random().toHex();
|
|
4794
4734
|
log16.trace("dxos.sdk.client-services-host.reset", trace7.begin({
|
|
4795
4735
|
id: traceId
|
|
@@ -4805,7 +4745,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4805
4745
|
S: this,
|
|
4806
4746
|
C: (f, a) => f(...a)
|
|
4807
4747
|
});
|
|
4808
|
-
await
|
|
4748
|
+
await this._serviceContext?.close();
|
|
4809
4749
|
await this._storage.reset();
|
|
4810
4750
|
log16("reset", void 0, {
|
|
4811
4751
|
F: __dxlog_file17,
|
|
@@ -4821,7 +4761,7 @@ var ClientServicesHost = class ClientServicesHost2 {
|
|
|
4821
4761
|
S: this,
|
|
4822
4762
|
C: (f, a) => f(...a)
|
|
4823
4763
|
});
|
|
4824
|
-
await
|
|
4764
|
+
await this._callbacks?.onReset?.();
|
|
4825
4765
|
}
|
|
4826
4766
|
};
|
|
4827
4767
|
_ts_decorate7([
|
|
@@ -4875,4 +4815,4 @@ export {
|
|
|
4875
4815
|
createDefaultModelFactory,
|
|
4876
4816
|
ClientServicesHost
|
|
4877
4817
|
};
|
|
4878
|
-
//# sourceMappingURL=chunk-
|
|
4818
|
+
//# sourceMappingURL=chunk-Y4AYNWBO.mjs.map
|