@dxos/client-services 0.8.4-main.8342792842 → 0.8.4-main.8360d9e660
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-JUKRMLXU.mjs → chunk-FRMIC6UB.mjs} +521 -123
- package/dist/lib/browser/{chunk-JUKRMLXU.mjs.map → chunk-FRMIC6UB.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +5 -5
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node-esm/{chunk-JTTSIM6K.mjs → chunk-6ONWVRY5.mjs} +521 -123
- package/dist/lib/node-esm/{chunk-JTTSIM6K.mjs.map → chunk-6ONWVRY5.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +5 -5
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/types/src/packlets/services/feed-syncer.d.ts +21 -3
- package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -1
- package/dist/types/src/packlets/services/feed-syncer.test.d.ts +2 -0
- package/dist/types/src/packlets/services/feed-syncer.test.d.ts.map +1 -0
- package/dist/types/src/packlets/services/service-context.d.ts +0 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +39 -39
- package/src/packlets/services/feed-syncer.test.ts +340 -0
- package/src/packlets/services/feed-syncer.ts +123 -20
- package/src/packlets/services/service-context.ts +65 -7
- package/src/packlets/services/service-host.ts +5 -3
- package/src/packlets/worker/worker-session.ts +4 -4
- package/src/version.ts +1 -1
|
@@ -403,7 +403,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
|
403
403
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
404
404
|
|
|
405
405
|
// src/version.ts
|
|
406
|
-
var DXOS_VERSION = "0.8.4-main.
|
|
406
|
+
var DXOS_VERSION = "0.8.4-main.8360d9e660";
|
|
407
407
|
|
|
408
408
|
// src/packlets/services/platform.ts
|
|
409
409
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -7667,7 +7667,7 @@ import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2
|
|
|
7667
7667
|
import { EchoEdgeReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
7668
7668
|
import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from "@dxos/edge-client";
|
|
7669
7669
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
7670
|
-
import { invariant as
|
|
7670
|
+
import { invariant as invariant23 } from "@dxos/invariant";
|
|
7671
7671
|
import { Keyring } from "@dxos/keyring";
|
|
7672
7672
|
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
7673
7673
|
import { log as log23 } from "@dxos/log";
|
|
@@ -7907,22 +7907,28 @@ import { Resource as Resource8 } from "@dxos/context";
|
|
|
7907
7907
|
import { MessageSchema } from "@dxos/edge-client";
|
|
7908
7908
|
import { RuntimeProvider } from "@dxos/effect";
|
|
7909
7909
|
import { SyncClient } from "@dxos/feed";
|
|
7910
|
+
import { invariant as invariant22 } from "@dxos/invariant";
|
|
7911
|
+
import { SpaceId as SpaceId4 } from "@dxos/keys";
|
|
7910
7912
|
import { FeedProtocol } from "@dxos/protocols";
|
|
7911
7913
|
import { EdgeService as EdgeService2 } from "@dxos/protocols";
|
|
7912
7914
|
import { createBuf } from "@dxos/protocols/buf";
|
|
7913
7915
|
import { bufferToArray as bufferToArray2 } from "@dxos/util";
|
|
7916
|
+
var __dxlog_file27 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/feed-syncer.ts";
|
|
7914
7917
|
var encoder = new Encoder({
|
|
7915
7918
|
tagUint8Array: false,
|
|
7916
7919
|
useRecords: false
|
|
7917
7920
|
});
|
|
7918
7921
|
var DEFAULT_MESSAGE_BLOCKS_LIMIT = 50;
|
|
7919
7922
|
var DEFAULT_SYNC_CONCURRENCY = 5;
|
|
7920
|
-
var DEFAULT_POLLING_INTERVAL =
|
|
7923
|
+
var DEFAULT_POLLING_INTERVAL = 5e3;
|
|
7924
|
+
var DEFAULT_POLL_REQUEST_THROTTLE_MS = 250;
|
|
7925
|
+
var MAX_BLOCKING_SYNC_ITERATIONS = 100;
|
|
7921
7926
|
var FeedSyncer = class extends Resource8 {
|
|
7922
|
-
#
|
|
7927
|
+
#syncNamespaces;
|
|
7923
7928
|
#messageBlocksLimit;
|
|
7924
7929
|
#syncConcurrency;
|
|
7925
7930
|
#pollingInterval;
|
|
7931
|
+
#pollRequestThrottleMs;
|
|
7926
7932
|
#runtime;
|
|
7927
7933
|
#feedStore;
|
|
7928
7934
|
#edgeClient;
|
|
@@ -7931,6 +7937,8 @@ var FeedSyncer = class extends Resource8 {
|
|
|
7931
7937
|
#spacesToPoll = /* @__PURE__ */ new Set();
|
|
7932
7938
|
/** Last time full poll was completed. */
|
|
7933
7939
|
#lastFullPoll = null;
|
|
7940
|
+
#throttledPollScheduled = false;
|
|
7941
|
+
#lastRequestedPollAt = null;
|
|
7934
7942
|
constructor(options) {
|
|
7935
7943
|
super();
|
|
7936
7944
|
this.#runtime = options.runtime;
|
|
@@ -7942,10 +7950,11 @@ var FeedSyncer = class extends Resource8 {
|
|
|
7942
7950
|
sendMessage: this.#sendMessage.bind(this)
|
|
7943
7951
|
});
|
|
7944
7952
|
this.#getSpaceIds = options.getSpaceIds;
|
|
7945
|
-
this.#
|
|
7953
|
+
this.#syncNamespaces = options.syncNamespaces;
|
|
7946
7954
|
this.#messageBlocksLimit = options.messageBlocksLimit ?? DEFAULT_MESSAGE_BLOCKS_LIMIT;
|
|
7947
7955
|
this.#syncConcurrency = options.syncConcurrency ?? DEFAULT_SYNC_CONCURRENCY;
|
|
7948
7956
|
this.#pollingInterval = options.pollingInterval ?? DEFAULT_POLLING_INTERVAL;
|
|
7957
|
+
this.#pollRequestThrottleMs = options.pollRequestThrottleMs ?? DEFAULT_POLL_REQUEST_THROTTLE_MS;
|
|
7949
7958
|
}
|
|
7950
7959
|
async _open() {
|
|
7951
7960
|
this._ctx.onDispose(this.#edgeClient.onMessage((msg) => {
|
|
@@ -7961,7 +7970,7 @@ var FeedSyncer = class extends Resource8 {
|
|
|
7961
7970
|
try: () => cborXdecode(msg.payload.value),
|
|
7962
7971
|
catch: (error) => new Error(`Failed to decode feed sync message: ${error}`)
|
|
7963
7972
|
});
|
|
7964
|
-
const payload = yield* Schema.
|
|
7973
|
+
const payload = yield* Schema.validate(FeedProtocol.ProtocolMessage)(decoded);
|
|
7965
7974
|
yield* this.#syncClient.handleMessage(payload);
|
|
7966
7975
|
});
|
|
7967
7976
|
void RuntimeProvider.runPromise(this.#runtime)(handleMessageEffect);
|
|
@@ -7977,11 +7986,82 @@ var FeedSyncer = class extends Resource8 {
|
|
|
7977
7986
|
await this.#pollTask.open();
|
|
7978
7987
|
await this.#pushTask.open();
|
|
7979
7988
|
this.#resetSpacesToPoll();
|
|
7989
|
+
this.#pollTask.schedule();
|
|
7980
7990
|
}
|
|
7981
7991
|
async _close() {
|
|
7982
7992
|
await this.#pollTask.close();
|
|
7983
7993
|
await this.#pushTask.close();
|
|
7984
7994
|
}
|
|
7995
|
+
/**
|
|
7996
|
+
* Schedules a best-effort pull without blocking the caller.
|
|
7997
|
+
*/
|
|
7998
|
+
schedulePoll() {
|
|
7999
|
+
this.#resetSpacesToPoll();
|
|
8000
|
+
if (this.#throttledPollScheduled) {
|
|
8001
|
+
return;
|
|
8002
|
+
}
|
|
8003
|
+
const now = Date.now();
|
|
8004
|
+
const delay = this.#lastRequestedPollAt == null ? 0 : Math.max(this.#pollRequestThrottleMs - (now - this.#lastRequestedPollAt), 0);
|
|
8005
|
+
this.#throttledPollScheduled = true;
|
|
8006
|
+
scheduleTask9(this._ctx, () => {
|
|
8007
|
+
this.#throttledPollScheduled = false;
|
|
8008
|
+
this.#lastRequestedPollAt = Date.now();
|
|
8009
|
+
this.#pollTask.schedule();
|
|
8010
|
+
}, delay);
|
|
8011
|
+
}
|
|
8012
|
+
/**
|
|
8013
|
+
* Performs queue sync and blocks until there are no pending sync batches.
|
|
8014
|
+
*/
|
|
8015
|
+
async syncBlocking({ spaceId, subspaceTag, shouldPush = true, shouldPull = true }) {
|
|
8016
|
+
invariant22(SpaceId4.isValid(spaceId), void 0, {
|
|
8017
|
+
F: __dxlog_file27,
|
|
8018
|
+
L: 190,
|
|
8019
|
+
S: this,
|
|
8020
|
+
A: [
|
|
8021
|
+
"SpaceId.isValid(spaceId)",
|
|
8022
|
+
""
|
|
8023
|
+
]
|
|
8024
|
+
});
|
|
8025
|
+
invariant22(FeedProtocol.isWellKnownNamespace(subspaceTag), void 0, {
|
|
8026
|
+
F: __dxlog_file27,
|
|
8027
|
+
L: 191,
|
|
8028
|
+
S: this,
|
|
8029
|
+
A: [
|
|
8030
|
+
"FeedProtocol.isWellKnownNamespace(subspaceTag)",
|
|
8031
|
+
""
|
|
8032
|
+
]
|
|
8033
|
+
});
|
|
8034
|
+
if (!shouldPush && !shouldPull) {
|
|
8035
|
+
return;
|
|
8036
|
+
}
|
|
8037
|
+
await RuntimeProvider.runPromise(this.#runtime)(Effect.gen(this, function* () {
|
|
8038
|
+
let done = false;
|
|
8039
|
+
let iterations = 0;
|
|
8040
|
+
while (!done) {
|
|
8041
|
+
done = true;
|
|
8042
|
+
if (shouldPull) {
|
|
8043
|
+
const pullResult = yield* this.#syncClient.pull({
|
|
8044
|
+
spaceId,
|
|
8045
|
+
feedNamespace: subspaceTag,
|
|
8046
|
+
limit: this.#messageBlocksLimit
|
|
8047
|
+
});
|
|
8048
|
+
done &&= pullResult.done;
|
|
8049
|
+
}
|
|
8050
|
+
if (shouldPush) {
|
|
8051
|
+
const pushResult = yield* this.#syncClient.push({
|
|
8052
|
+
spaceId,
|
|
8053
|
+
feedNamespace: subspaceTag,
|
|
8054
|
+
limit: this.#messageBlocksLimit
|
|
8055
|
+
});
|
|
8056
|
+
done &&= pushResult.done;
|
|
8057
|
+
}
|
|
8058
|
+
iterations++;
|
|
8059
|
+
if (iterations > MAX_BLOCKING_SYNC_ITERATIONS) {
|
|
8060
|
+
throw new Error("Blocking sync exceeded max iterations.");
|
|
8061
|
+
}
|
|
8062
|
+
}
|
|
8063
|
+
}));
|
|
8064
|
+
}
|
|
7985
8065
|
#resetSpacesToPoll() {
|
|
7986
8066
|
this.#spacesToPoll.clear();
|
|
7987
8067
|
this.#getSpaceIds().forEach((spaceId) => {
|
|
@@ -8009,12 +8089,18 @@ var FeedSyncer = class extends Resource8 {
|
|
|
8009
8089
|
}
|
|
8010
8090
|
#pollTask = new AsyncTask(async () => Effect.gen(this, function* () {
|
|
8011
8091
|
yield* Effect.forEach(this.#spacesToPoll, (spaceId) => Effect.gen(this, function* () {
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8092
|
+
let doneForAllNamespaces = true;
|
|
8093
|
+
for (const feedNamespace of this.#syncNamespaces) {
|
|
8094
|
+
const { done } = yield* this.#syncClient.pull({
|
|
8095
|
+
spaceId,
|
|
8096
|
+
feedNamespace,
|
|
8097
|
+
limit: this.#messageBlocksLimit
|
|
8098
|
+
});
|
|
8099
|
+
if (!done) {
|
|
8100
|
+
doneForAllNamespaces = false;
|
|
8101
|
+
}
|
|
8102
|
+
}
|
|
8103
|
+
if (doneForAllNamespaces) {
|
|
8018
8104
|
this.#spacesToPoll.delete(spaceId);
|
|
8019
8105
|
}
|
|
8020
8106
|
}), {
|
|
@@ -8032,12 +8118,18 @@ var FeedSyncer = class extends Resource8 {
|
|
|
8032
8118
|
}).pipe(RuntimeProvider.runPromise(this.#runtime)));
|
|
8033
8119
|
#pushTask = new AsyncTask(async () => Effect.gen(this, function* () {
|
|
8034
8120
|
yield* Effect.forEach(this.#getSpaceIds(), (spaceId) => Effect.gen(this, function* () {
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8121
|
+
let doneForAllNamespaces = true;
|
|
8122
|
+
for (const feedNamespace of this.#syncNamespaces) {
|
|
8123
|
+
const { done } = yield* this.#syncClient.push({
|
|
8124
|
+
spaceId,
|
|
8125
|
+
feedNamespace,
|
|
8126
|
+
limit: this.#messageBlocksLimit
|
|
8127
|
+
});
|
|
8128
|
+
if (!done) {
|
|
8129
|
+
doneForAllNamespaces = false;
|
|
8130
|
+
}
|
|
8131
|
+
}
|
|
8132
|
+
if (!doneForAllNamespaces) {
|
|
8041
8133
|
this.#pushTask.schedule();
|
|
8042
8134
|
}
|
|
8043
8135
|
}), {
|
|
@@ -8118,7 +8210,7 @@ function _ts_dispose_resources4(env) {
|
|
|
8118
8210
|
return next();
|
|
8119
8211
|
})(env);
|
|
8120
8212
|
}
|
|
8121
|
-
var
|
|
8213
|
+
var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
8122
8214
|
var ServiceContext = class extends Resource9 {
|
|
8123
8215
|
storage;
|
|
8124
8216
|
level;
|
|
@@ -8153,14 +8245,14 @@ var ServiceContext = class extends Resource9 {
|
|
|
8153
8245
|
constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtime, _runtimeProps, _edgeFeatures) {
|
|
8154
8246
|
super(), this.storage = storage, this.level = level, this.networkManager = networkManager, this.signalManager = signalManager, this._edgeConnection = _edgeConnection, this._edgeHttpClient = _edgeHttpClient, this._runtime = _runtime, this._runtimeProps = _runtimeProps, this._edgeFeatures = _edgeFeatures;
|
|
8155
8247
|
log23("runtimeProps", this._runtimeProps, {
|
|
8156
|
-
F:
|
|
8157
|
-
L:
|
|
8248
|
+
F: __dxlog_file28,
|
|
8249
|
+
L: 122,
|
|
8158
8250
|
S: this,
|
|
8159
8251
|
C: (f, a) => f(...a)
|
|
8160
8252
|
});
|
|
8161
8253
|
log23("edgeFeatures", this._edgeFeatures, {
|
|
8162
|
-
F:
|
|
8163
|
-
L:
|
|
8254
|
+
F: __dxlog_file28,
|
|
8255
|
+
L: 123,
|
|
8164
8256
|
S: this,
|
|
8165
8257
|
C: (f, a) => f(...a)
|
|
8166
8258
|
});
|
|
@@ -8200,7 +8292,14 @@ var ServiceContext = class extends Resource9 {
|
|
|
8200
8292
|
peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
|
|
8201
8293
|
getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
|
|
8202
8294
|
runtime: this._runtime,
|
|
8203
|
-
|
|
8295
|
+
syncQueue: async (request) => {
|
|
8296
|
+
return this._feedSyncer?.syncBlocking({
|
|
8297
|
+
spaceId: request.spaceId,
|
|
8298
|
+
subspaceTag: request.subspaceTag,
|
|
8299
|
+
shouldPush: request.shouldPush,
|
|
8300
|
+
shouldPull: request.shouldPull
|
|
8301
|
+
});
|
|
8302
|
+
}
|
|
8204
8303
|
});
|
|
8205
8304
|
this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeProps?.invitationConnectionDefaultProps);
|
|
8206
8305
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
@@ -8221,73 +8320,247 @@ var ServiceContext = class extends Resource9 {
|
|
|
8221
8320
|
edgeClient: this._edgeConnection,
|
|
8222
8321
|
peerId: this.identityManager.identity?.deviceKey?.toHex() ?? "",
|
|
8223
8322
|
getSpaceIds: () => this.echoHost.spaceIds,
|
|
8224
|
-
|
|
8323
|
+
syncNamespaces: [
|
|
8324
|
+
FeedProtocol2.WellKnownNamespaces.data,
|
|
8325
|
+
FeedProtocol2.WellKnownNamespaces.trace
|
|
8326
|
+
]
|
|
8225
8327
|
});
|
|
8226
8328
|
}
|
|
8227
8329
|
}
|
|
8228
8330
|
async _open(ctx) {
|
|
8229
8331
|
await this._checkStorageVersion();
|
|
8230
8332
|
log23("opening...", void 0, {
|
|
8231
|
-
F:
|
|
8232
|
-
L:
|
|
8333
|
+
F: __dxlog_file28,
|
|
8334
|
+
L: 231,
|
|
8233
8335
|
S: this,
|
|
8234
8336
|
C: (f, a) => f(...a)
|
|
8235
8337
|
});
|
|
8236
8338
|
log23.trace("dxos.sdk.service-context.open", trace9.begin({
|
|
8237
8339
|
id: this._instanceId
|
|
8238
8340
|
}), {
|
|
8239
|
-
F:
|
|
8240
|
-
L:
|
|
8341
|
+
F: __dxlog_file28,
|
|
8342
|
+
L: 232,
|
|
8343
|
+
S: this,
|
|
8344
|
+
C: (f, a) => f(...a)
|
|
8345
|
+
});
|
|
8346
|
+
log23("opening identityManager...", void 0, {
|
|
8347
|
+
F: __dxlog_file28,
|
|
8348
|
+
L: 234,
|
|
8241
8349
|
S: this,
|
|
8242
8350
|
C: (f, a) => f(...a)
|
|
8243
8351
|
});
|
|
8244
8352
|
await this.identityManager.open(ctx);
|
|
8353
|
+
log23("identityManager opened", {
|
|
8354
|
+
hasIdentity: !!this.identityManager.identity
|
|
8355
|
+
}, {
|
|
8356
|
+
F: __dxlog_file28,
|
|
8357
|
+
L: 236,
|
|
8358
|
+
S: this,
|
|
8359
|
+
C: (f, a) => f(...a)
|
|
8360
|
+
});
|
|
8361
|
+
log23("setting network identity...", void 0, {
|
|
8362
|
+
F: __dxlog_file28,
|
|
8363
|
+
L: 238,
|
|
8364
|
+
S: this,
|
|
8365
|
+
C: (f, a) => f(...a)
|
|
8366
|
+
});
|
|
8245
8367
|
await this._setNetworkIdentity();
|
|
8368
|
+
log23("network identity set", void 0, {
|
|
8369
|
+
F: __dxlog_file28,
|
|
8370
|
+
L: 240,
|
|
8371
|
+
S: this,
|
|
8372
|
+
C: (f, a) => f(...a)
|
|
8373
|
+
});
|
|
8374
|
+
log23("opening edge connection...", void 0, {
|
|
8375
|
+
F: __dxlog_file28,
|
|
8376
|
+
L: 242,
|
|
8377
|
+
S: this,
|
|
8378
|
+
C: (f, a) => f(...a)
|
|
8379
|
+
});
|
|
8246
8380
|
await this._edgeConnection?.open();
|
|
8381
|
+
log23("edge connection opened", void 0, {
|
|
8382
|
+
F: __dxlog_file28,
|
|
8383
|
+
L: 244,
|
|
8384
|
+
S: this,
|
|
8385
|
+
C: (f, a) => f(...a)
|
|
8386
|
+
});
|
|
8387
|
+
log23("opening signal manager...", void 0, {
|
|
8388
|
+
F: __dxlog_file28,
|
|
8389
|
+
L: 246,
|
|
8390
|
+
S: this,
|
|
8391
|
+
C: (f, a) => f(...a)
|
|
8392
|
+
});
|
|
8247
8393
|
await this.signalManager.open();
|
|
8394
|
+
log23("signal manager opened", void 0, {
|
|
8395
|
+
F: __dxlog_file28,
|
|
8396
|
+
L: 248,
|
|
8397
|
+
S: this,
|
|
8398
|
+
C: (f, a) => f(...a)
|
|
8399
|
+
});
|
|
8400
|
+
log23("opening network manager...", void 0, {
|
|
8401
|
+
F: __dxlog_file28,
|
|
8402
|
+
L: 250,
|
|
8403
|
+
S: this,
|
|
8404
|
+
C: (f, a) => f(...a)
|
|
8405
|
+
});
|
|
8248
8406
|
await this.networkManager.open();
|
|
8407
|
+
log23("network manager opened", void 0, {
|
|
8408
|
+
F: __dxlog_file28,
|
|
8409
|
+
L: 252,
|
|
8410
|
+
S: this,
|
|
8411
|
+
C: (f, a) => f(...a)
|
|
8412
|
+
});
|
|
8413
|
+
log23("opening echo host...", void 0, {
|
|
8414
|
+
F: __dxlog_file28,
|
|
8415
|
+
L: 254,
|
|
8416
|
+
S: this,
|
|
8417
|
+
C: (f, a) => f(...a)
|
|
8418
|
+
});
|
|
8249
8419
|
await this.echoHost.open(ctx);
|
|
8420
|
+
log23("echo host opened", void 0, {
|
|
8421
|
+
F: __dxlog_file28,
|
|
8422
|
+
L: 256,
|
|
8423
|
+
S: this,
|
|
8424
|
+
C: (f, a) => f(...a)
|
|
8425
|
+
});
|
|
8250
8426
|
if (this._meshReplicator) {
|
|
8427
|
+
log23("adding mesh replicator...", void 0, {
|
|
8428
|
+
F: __dxlog_file28,
|
|
8429
|
+
L: 259,
|
|
8430
|
+
S: this,
|
|
8431
|
+
C: (f, a) => f(...a)
|
|
8432
|
+
});
|
|
8251
8433
|
await this.echoHost.addReplicator(this._meshReplicator);
|
|
8434
|
+
log23("mesh replicator added", void 0, {
|
|
8435
|
+
F: __dxlog_file28,
|
|
8436
|
+
L: 261,
|
|
8437
|
+
S: this,
|
|
8438
|
+
C: (f, a) => f(...a)
|
|
8439
|
+
});
|
|
8252
8440
|
}
|
|
8253
8441
|
if (this._echoEdgeReplicator) {
|
|
8442
|
+
log23("adding edge replicator...", void 0, {
|
|
8443
|
+
F: __dxlog_file28,
|
|
8444
|
+
L: 264,
|
|
8445
|
+
S: this,
|
|
8446
|
+
C: (f, a) => f(...a)
|
|
8447
|
+
});
|
|
8254
8448
|
await this.echoHost.addReplicator(this._echoEdgeReplicator);
|
|
8449
|
+
log23("edge replicator added", void 0, {
|
|
8450
|
+
F: __dxlog_file28,
|
|
8451
|
+
L: 266,
|
|
8452
|
+
S: this,
|
|
8453
|
+
C: (f, a) => f(...a)
|
|
8454
|
+
});
|
|
8255
8455
|
}
|
|
8456
|
+
log23("loading metadata store...", void 0, {
|
|
8457
|
+
F: __dxlog_file28,
|
|
8458
|
+
L: 269,
|
|
8459
|
+
S: this,
|
|
8460
|
+
C: (f, a) => f(...a)
|
|
8461
|
+
});
|
|
8256
8462
|
await this.metadataStore.load();
|
|
8463
|
+
log23("metadata store loaded", void 0, {
|
|
8464
|
+
F: __dxlog_file28,
|
|
8465
|
+
L: 271,
|
|
8466
|
+
S: this,
|
|
8467
|
+
C: (f, a) => f(...a)
|
|
8468
|
+
});
|
|
8469
|
+
log23("opening space manager...", void 0, {
|
|
8470
|
+
F: __dxlog_file28,
|
|
8471
|
+
L: 273,
|
|
8472
|
+
S: this,
|
|
8473
|
+
C: (f, a) => f(...a)
|
|
8474
|
+
});
|
|
8257
8475
|
await this.spaceManager.open();
|
|
8476
|
+
log23("space manager opened", void 0, {
|
|
8477
|
+
F: __dxlog_file28,
|
|
8478
|
+
L: 275,
|
|
8479
|
+
S: this,
|
|
8480
|
+
C: (f, a) => f(...a)
|
|
8481
|
+
});
|
|
8258
8482
|
if (this.identityManager.identity) {
|
|
8483
|
+
log23("joining network...", void 0, {
|
|
8484
|
+
F: __dxlog_file28,
|
|
8485
|
+
L: 278,
|
|
8486
|
+
S: this,
|
|
8487
|
+
C: (f, a) => f(...a)
|
|
8488
|
+
});
|
|
8259
8489
|
await this.identityManager.identity.joinNetwork();
|
|
8490
|
+
log23("network joined", void 0, {
|
|
8491
|
+
F: __dxlog_file28,
|
|
8492
|
+
L: 280,
|
|
8493
|
+
S: this,
|
|
8494
|
+
C: (f, a) => f(...a)
|
|
8495
|
+
});
|
|
8496
|
+
log23("initializing spaces...(calling _initialize)", void 0, {
|
|
8497
|
+
F: __dxlog_file28,
|
|
8498
|
+
L: 282,
|
|
8499
|
+
S: this,
|
|
8500
|
+
C: (f, a) => f(...a)
|
|
8501
|
+
});
|
|
8260
8502
|
await this._initialize(ctx);
|
|
8503
|
+
log23("spaces initialized", void 0, {
|
|
8504
|
+
F: __dxlog_file28,
|
|
8505
|
+
L: 284,
|
|
8506
|
+
S: this,
|
|
8507
|
+
C: (f, a) => f(...a)
|
|
8508
|
+
});
|
|
8509
|
+
} else {
|
|
8510
|
+
log23("no identity, skipping network join and space initialization", void 0, {
|
|
8511
|
+
F: __dxlog_file28,
|
|
8512
|
+
L: 286,
|
|
8513
|
+
S: this,
|
|
8514
|
+
C: (f, a) => f(...a)
|
|
8515
|
+
});
|
|
8261
8516
|
}
|
|
8517
|
+
log23("opening feed syncer...", void 0, {
|
|
8518
|
+
F: __dxlog_file28,
|
|
8519
|
+
L: 289,
|
|
8520
|
+
S: this,
|
|
8521
|
+
C: (f, a) => f(...a)
|
|
8522
|
+
});
|
|
8262
8523
|
await this._feedSyncer?.open();
|
|
8524
|
+
log23("feed syncer opened", void 0, {
|
|
8525
|
+
F: __dxlog_file28,
|
|
8526
|
+
L: 291,
|
|
8527
|
+
S: this,
|
|
8528
|
+
C: (f, a) => f(...a)
|
|
8529
|
+
});
|
|
8530
|
+
log23("loading persistent invitations...", void 0, {
|
|
8531
|
+
F: __dxlog_file28,
|
|
8532
|
+
L: 293,
|
|
8533
|
+
S: this,
|
|
8534
|
+
C: (f, a) => f(...a)
|
|
8535
|
+
});
|
|
8263
8536
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
8264
8537
|
log23("loaded persistent invitations", {
|
|
8265
8538
|
count: loadedInvitations.invitations?.length
|
|
8266
8539
|
}, {
|
|
8267
|
-
F:
|
|
8268
|
-
L:
|
|
8540
|
+
F: __dxlog_file28,
|
|
8541
|
+
L: 295,
|
|
8269
8542
|
S: this,
|
|
8270
8543
|
C: (f, a) => f(...a)
|
|
8271
8544
|
});
|
|
8272
8545
|
log23.trace("dxos.sdk.service-context.open", trace9.end({
|
|
8273
8546
|
id: this._instanceId
|
|
8274
8547
|
}), {
|
|
8275
|
-
F:
|
|
8276
|
-
L:
|
|
8548
|
+
F: __dxlog_file28,
|
|
8549
|
+
L: 297,
|
|
8277
8550
|
S: this,
|
|
8278
8551
|
C: (f, a) => f(...a)
|
|
8279
8552
|
});
|
|
8280
8553
|
log23("opened", void 0, {
|
|
8281
|
-
F:
|
|
8282
|
-
L:
|
|
8554
|
+
F: __dxlog_file28,
|
|
8555
|
+
L: 298,
|
|
8283
8556
|
S: this,
|
|
8284
8557
|
C: (f, a) => f(...a)
|
|
8285
8558
|
});
|
|
8286
8559
|
}
|
|
8287
8560
|
async _close(ctx) {
|
|
8288
8561
|
log23("closing...", void 0, {
|
|
8289
|
-
F:
|
|
8290
|
-
L:
|
|
8562
|
+
F: __dxlog_file28,
|
|
8563
|
+
L: 302,
|
|
8291
8564
|
S: this,
|
|
8292
8565
|
C: (f, a) => f(...a)
|
|
8293
8566
|
});
|
|
@@ -8306,8 +8579,8 @@ var ServiceContext = class extends Resource9 {
|
|
|
8306
8579
|
await this.feedStore.close();
|
|
8307
8580
|
await this.metadataStore.close();
|
|
8308
8581
|
log23("closed", void 0, {
|
|
8309
|
-
F:
|
|
8310
|
-
L:
|
|
8582
|
+
F: __dxlog_file28,
|
|
8583
|
+
L: 321,
|
|
8311
8584
|
S: this,
|
|
8312
8585
|
C: (f, a) => f(...a)
|
|
8313
8586
|
});
|
|
@@ -8317,8 +8590,8 @@ var ServiceContext = class extends Resource9 {
|
|
|
8317
8590
|
await this._setNetworkIdentity();
|
|
8318
8591
|
await identity.joinNetwork();
|
|
8319
8592
|
await this._initialize(new Context10(void 0, {
|
|
8320
|
-
F:
|
|
8321
|
-
L:
|
|
8593
|
+
F: __dxlog_file28,
|
|
8594
|
+
L: 328
|
|
8322
8595
|
}));
|
|
8323
8596
|
return identity;
|
|
8324
8597
|
}
|
|
@@ -8327,9 +8600,9 @@ var ServiceContext = class extends Resource9 {
|
|
|
8327
8600
|
throw new Error("Identity must be created before joining a space.");
|
|
8328
8601
|
}
|
|
8329
8602
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
8330
|
-
|
|
8331
|
-
F:
|
|
8332
|
-
L:
|
|
8603
|
+
invariant23(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
8604
|
+
F: __dxlog_file28,
|
|
8605
|
+
L: 337,
|
|
8333
8606
|
S: this,
|
|
8334
8607
|
A: [
|
|
8335
8608
|
"factory",
|
|
@@ -8354,8 +8627,8 @@ var ServiceContext = class extends Resource9 {
|
|
|
8354
8627
|
await identity.joinNetwork();
|
|
8355
8628
|
await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
|
|
8356
8629
|
await this._initialize(new Context10(void 0, {
|
|
8357
|
-
F:
|
|
8358
|
-
L:
|
|
8630
|
+
F: __dxlog_file28,
|
|
8631
|
+
L: 356
|
|
8359
8632
|
}));
|
|
8360
8633
|
return identity;
|
|
8361
8634
|
}
|
|
@@ -8367,9 +8640,9 @@ var ServiceContext = class extends Resource9 {
|
|
|
8367
8640
|
}
|
|
8368
8641
|
// Called when identity is created.
|
|
8369
8642
|
async _initialize(ctx) {
|
|
8370
|
-
log23("
|
|
8371
|
-
F:
|
|
8372
|
-
L:
|
|
8643
|
+
log23("_initialize: start", void 0, {
|
|
8644
|
+
F: __dxlog_file28,
|
|
8645
|
+
L: 371,
|
|
8373
8646
|
S: this,
|
|
8374
8647
|
C: (f, a) => f(...a)
|
|
8375
8648
|
});
|
|
@@ -8387,6 +8660,12 @@ var ServiceContext = class extends Resource9 {
|
|
|
8387
8660
|
});
|
|
8388
8661
|
}
|
|
8389
8662
|
};
|
|
8663
|
+
log23("_initialize: creating DataSpaceManager", void 0, {
|
|
8664
|
+
F: __dxlog_file28,
|
|
8665
|
+
L: 383,
|
|
8666
|
+
S: this,
|
|
8667
|
+
C: (f, a) => f(...a)
|
|
8668
|
+
});
|
|
8390
8669
|
this.dataSpaceManager = new DataSpaceManager({
|
|
8391
8670
|
spaceManager: this.spaceManager,
|
|
8392
8671
|
metadataStore: this.metadataStore,
|
|
@@ -8402,13 +8681,37 @@ var ServiceContext = class extends Resource9 {
|
|
|
8402
8681
|
runtimeProps: this._runtimeProps,
|
|
8403
8682
|
edgeFeatures: this._edgeFeatures
|
|
8404
8683
|
});
|
|
8684
|
+
log23("_initialize: opening DataSpaceManager...", void 0, {
|
|
8685
|
+
F: __dxlog_file28,
|
|
8686
|
+
L: 399,
|
|
8687
|
+
S: this,
|
|
8688
|
+
C: (f, a) => f(...a)
|
|
8689
|
+
});
|
|
8405
8690
|
await this.dataSpaceManager.open();
|
|
8691
|
+
log23("_initialize: DataSpaceManager opened", void 0, {
|
|
8692
|
+
F: __dxlog_file28,
|
|
8693
|
+
L: 401,
|
|
8694
|
+
S: this,
|
|
8695
|
+
C: (f, a) => f(...a)
|
|
8696
|
+
});
|
|
8406
8697
|
this.edgeAgentManager = new EdgeAgentManager(this._edgeFeatures, this._edgeHttpClient, this.dataSpaceManager, identity);
|
|
8698
|
+
log23("_initialize: opening EdgeAgentManager...", void 0, {
|
|
8699
|
+
F: __dxlog_file28,
|
|
8700
|
+
L: 409,
|
|
8701
|
+
S: this,
|
|
8702
|
+
C: (f, a) => f(...a)
|
|
8703
|
+
});
|
|
8407
8704
|
await this.edgeAgentManager.open();
|
|
8705
|
+
log23("_initialize: EdgeAgentManager opened", void 0, {
|
|
8706
|
+
F: __dxlog_file28,
|
|
8707
|
+
L: 411,
|
|
8708
|
+
S: this,
|
|
8709
|
+
C: (f, a) => f(...a)
|
|
8710
|
+
});
|
|
8408
8711
|
this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
|
|
8409
|
-
|
|
8410
|
-
F:
|
|
8411
|
-
L:
|
|
8712
|
+
invariant23(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
8713
|
+
F: __dxlog_file28,
|
|
8714
|
+
L: 414,
|
|
8412
8715
|
S: this,
|
|
8413
8716
|
A: [
|
|
8414
8717
|
"this.dataSpaceManager",
|
|
@@ -8418,6 +8721,12 @@ var ServiceContext = class extends Resource9 {
|
|
|
8418
8721
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
8419
8722
|
});
|
|
8420
8723
|
this.initialized.wake();
|
|
8724
|
+
log23("_initialize: initialized.wake() called", void 0, {
|
|
8725
|
+
F: __dxlog_file28,
|
|
8726
|
+
L: 418,
|
|
8727
|
+
S: this,
|
|
8728
|
+
C: (f, a) => f(...a)
|
|
8729
|
+
});
|
|
8421
8730
|
this._deviceSpaceSync = {
|
|
8422
8731
|
processCredential: async (credential) => {
|
|
8423
8732
|
const assertion = getCredentialAssertion6(credential);
|
|
@@ -8431,8 +8740,8 @@ var ServiceContext = class extends Resource9 {
|
|
|
8431
8740
|
log23("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
8432
8741
|
details: assertion
|
|
8433
8742
|
}, {
|
|
8434
|
-
F:
|
|
8435
|
-
L:
|
|
8743
|
+
F: __dxlog_file28,
|
|
8744
|
+
L: 431,
|
|
8436
8745
|
S: this,
|
|
8437
8746
|
C: (f, a) => f(...a)
|
|
8438
8747
|
});
|
|
@@ -8442,8 +8751,8 @@ var ServiceContext = class extends Resource9 {
|
|
|
8442
8751
|
log23("space already exists, ignoring space admission", {
|
|
8443
8752
|
details: assertion
|
|
8444
8753
|
}, {
|
|
8445
|
-
F:
|
|
8446
|
-
L:
|
|
8754
|
+
F: __dxlog_file28,
|
|
8755
|
+
L: 435,
|
|
8447
8756
|
S: this,
|
|
8448
8757
|
C: (f, a) => f(...a)
|
|
8449
8758
|
});
|
|
@@ -8453,8 +8762,8 @@ var ServiceContext = class extends Resource9 {
|
|
|
8453
8762
|
log23("accepting space recorded in halo", {
|
|
8454
8763
|
details: assertion
|
|
8455
8764
|
}, {
|
|
8456
|
-
F:
|
|
8457
|
-
L:
|
|
8765
|
+
F: __dxlog_file28,
|
|
8766
|
+
L: 440,
|
|
8458
8767
|
S: this,
|
|
8459
8768
|
C: (f, a) => f(...a)
|
|
8460
8769
|
});
|
|
@@ -8464,8 +8773,8 @@ var ServiceContext = class extends Resource9 {
|
|
|
8464
8773
|
});
|
|
8465
8774
|
} catch (err) {
|
|
8466
8775
|
log23.catch(err, void 0, {
|
|
8467
|
-
F:
|
|
8468
|
-
L:
|
|
8776
|
+
F: __dxlog_file28,
|
|
8777
|
+
L: 446,
|
|
8469
8778
|
S: this,
|
|
8470
8779
|
C: (f, a) => f(...a)
|
|
8471
8780
|
});
|
|
@@ -8481,40 +8790,102 @@ var ServiceContext = class extends Resource9 {
|
|
|
8481
8790
|
hasError: false
|
|
8482
8791
|
};
|
|
8483
8792
|
try {
|
|
8793
|
+
log23("_setNetworkIdentity: acquiring mutex...", void 0, {
|
|
8794
|
+
F: __dxlog_file28,
|
|
8795
|
+
L: 455,
|
|
8796
|
+
S: this,
|
|
8797
|
+
C: (f, a) => f(...a)
|
|
8798
|
+
});
|
|
8484
8799
|
const _ = _ts_add_disposable_resource4(env, await this._edgeIdentityUpdateMutex.acquire(), false);
|
|
8800
|
+
log23("_setNetworkIdentity: mutex acquired", void 0, {
|
|
8801
|
+
F: __dxlog_file28,
|
|
8802
|
+
L: 457,
|
|
8803
|
+
S: this,
|
|
8804
|
+
C: (f, a) => f(...a)
|
|
8805
|
+
});
|
|
8485
8806
|
let edgeIdentity;
|
|
8486
8807
|
const identity = this.identityManager.identity;
|
|
8487
8808
|
if (identity) {
|
|
8488
|
-
log23("
|
|
8809
|
+
log23("_setNetworkIdentity: has identity", {
|
|
8489
8810
|
identity: identity.identityKey.toHex(),
|
|
8490
|
-
|
|
8811
|
+
hasDeviceCredential: !!params?.deviceCredential
|
|
8491
8812
|
}, {
|
|
8492
|
-
F:
|
|
8493
|
-
L:
|
|
8813
|
+
F: __dxlog_file28,
|
|
8814
|
+
L: 462,
|
|
8494
8815
|
S: this,
|
|
8495
8816
|
C: (f, a) => f(...a)
|
|
8496
8817
|
});
|
|
8497
8818
|
if (params?.deviceCredential) {
|
|
8819
|
+
log23("_setNetworkIdentity: creating chain edge identity with device credential...", void 0, {
|
|
8820
|
+
F: __dxlog_file28,
|
|
8821
|
+
L: 468,
|
|
8822
|
+
S: this,
|
|
8823
|
+
C: (f, a) => f(...a)
|
|
8824
|
+
});
|
|
8498
8825
|
edgeIdentity = await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, params?.deviceCredential && {
|
|
8499
8826
|
credential: params.deviceCredential
|
|
8500
8827
|
}, []);
|
|
8828
|
+
log23("_setNetworkIdentity: chain edge identity created", void 0, {
|
|
8829
|
+
F: __dxlog_file28,
|
|
8830
|
+
L: 476,
|
|
8831
|
+
S: this,
|
|
8832
|
+
C: (f, a) => f(...a)
|
|
8833
|
+
});
|
|
8501
8834
|
} else {
|
|
8835
|
+
log23("_setNetworkIdentity: waiting for identity.ready()...", void 0, {
|
|
8836
|
+
F: __dxlog_file28,
|
|
8837
|
+
L: 478,
|
|
8838
|
+
S: this,
|
|
8839
|
+
C: (f, a) => f(...a)
|
|
8840
|
+
});
|
|
8502
8841
|
await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
|
|
8503
8842
|
await identity.ready();
|
|
8504
8843
|
});
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8844
|
+
log23("_setNetworkIdentity: identity.ready() resolved", {
|
|
8845
|
+
hasDeviceCredentialChain: !!identity.deviceCredentialChain
|
|
8846
|
+
}, {
|
|
8847
|
+
F: __dxlog_file28,
|
|
8848
|
+
L: 483,
|
|
8849
|
+
S: this,
|
|
8850
|
+
C: (f, a) => f(...a)
|
|
8851
|
+
});
|
|
8852
|
+
invariant23(identity.deviceCredentialChain, void 0, {
|
|
8853
|
+
F: __dxlog_file28,
|
|
8854
|
+
L: 487,
|
|
8508
8855
|
S: this,
|
|
8509
8856
|
A: [
|
|
8510
8857
|
"identity.deviceCredentialChain",
|
|
8511
8858
|
""
|
|
8512
8859
|
]
|
|
8513
8860
|
});
|
|
8861
|
+
log23("_setNetworkIdentity: creating chain edge identity...", void 0, {
|
|
8862
|
+
F: __dxlog_file28,
|
|
8863
|
+
L: 489,
|
|
8864
|
+
S: this,
|
|
8865
|
+
C: (f, a) => f(...a)
|
|
8866
|
+
});
|
|
8514
8867
|
edgeIdentity = await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, identity.deviceCredentialChain, []);
|
|
8868
|
+
log23("_setNetworkIdentity: chain edge identity created", void 0, {
|
|
8869
|
+
F: __dxlog_file28,
|
|
8870
|
+
L: 497,
|
|
8871
|
+
S: this,
|
|
8872
|
+
C: (f, a) => f(...a)
|
|
8873
|
+
});
|
|
8515
8874
|
}
|
|
8516
8875
|
} else {
|
|
8876
|
+
log23("_setNetworkIdentity: no identity, creating ephemeral edge identity...", void 0, {
|
|
8877
|
+
F: __dxlog_file28,
|
|
8878
|
+
L: 500,
|
|
8879
|
+
S: this,
|
|
8880
|
+
C: (f, a) => f(...a)
|
|
8881
|
+
});
|
|
8517
8882
|
edgeIdentity = await createEphemeralEdgeIdentity();
|
|
8883
|
+
log23("_setNetworkIdentity: ephemeral edge identity created", void 0, {
|
|
8884
|
+
F: __dxlog_file28,
|
|
8885
|
+
L: 502,
|
|
8886
|
+
S: this,
|
|
8887
|
+
C: (f, a) => f(...a)
|
|
8888
|
+
});
|
|
8518
8889
|
}
|
|
8519
8890
|
this._edgeConnection?.setIdentity(edgeIdentity);
|
|
8520
8891
|
this._edgeHttpClient?.setIdentity(edgeIdentity);
|
|
@@ -8522,6 +8893,12 @@ var ServiceContext = class extends Resource9 {
|
|
|
8522
8893
|
identityKey: edgeIdentity.identityKey,
|
|
8523
8894
|
peerKey: edgeIdentity.peerKey
|
|
8524
8895
|
});
|
|
8896
|
+
log23("_setNetworkIdentity: done", void 0, {
|
|
8897
|
+
F: __dxlog_file28,
|
|
8898
|
+
L: 511,
|
|
8899
|
+
S: this,
|
|
8900
|
+
C: (f, a) => f(...a)
|
|
8901
|
+
});
|
|
8525
8902
|
} catch (e) {
|
|
8526
8903
|
env.error = e;
|
|
8527
8904
|
env.hasError = true;
|
|
@@ -8657,7 +9034,7 @@ import { clientServiceBundle } from "@dxos/client-protocol";
|
|
|
8657
9034
|
import { Context as Context11 } from "@dxos/context";
|
|
8658
9035
|
import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity } from "@dxos/edge-client";
|
|
8659
9036
|
import { RuntimeProvider as RuntimeProvider2 } from "@dxos/effect";
|
|
8660
|
-
import { invariant as
|
|
9037
|
+
import { invariant as invariant25 } from "@dxos/invariant";
|
|
8661
9038
|
import { PublicKey as PublicKey19 } from "@dxos/keys";
|
|
8662
9039
|
import { log as log25 } from "@dxos/log";
|
|
8663
9040
|
import { EdgeSignalManager, WebsocketSignalManager } from "@dxos/messaging";
|
|
@@ -8671,9 +9048,9 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
|
8671
9048
|
// src/packlets/devices/devices-service.ts
|
|
8672
9049
|
import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
|
|
8673
9050
|
import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
|
|
8674
|
-
import { invariant as
|
|
9051
|
+
import { invariant as invariant24 } from "@dxos/invariant";
|
|
8675
9052
|
import { Device as Device2, DeviceKind as DeviceKind2, EdgeStatus as EdgeStatus3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
8676
|
-
var
|
|
9053
|
+
var __dxlog_file29 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
8677
9054
|
var DevicesServiceImpl = class {
|
|
8678
9055
|
_identityManager;
|
|
8679
9056
|
_edgeConnection;
|
|
@@ -8693,8 +9070,8 @@ var DevicesServiceImpl = class {
|
|
|
8693
9070
|
devices: []
|
|
8694
9071
|
});
|
|
8695
9072
|
} else {
|
|
8696
|
-
|
|
8697
|
-
F:
|
|
9073
|
+
invariant24(this._identityManager.identity?.presence, "presence not present", {
|
|
9074
|
+
F: __dxlog_file29,
|
|
8698
9075
|
L: 37,
|
|
8699
9076
|
S: this,
|
|
8700
9077
|
A: [
|
|
@@ -9102,7 +9479,7 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
9102
9479
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
9103
9480
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9104
9481
|
}
|
|
9105
|
-
var
|
|
9482
|
+
var __dxlog_file30 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
9106
9483
|
var ClientServicesHost = class {
|
|
9107
9484
|
_resourceLock;
|
|
9108
9485
|
_serviceRegistry;
|
|
@@ -9156,7 +9533,7 @@ var ClientServicesHost = class {
|
|
|
9156
9533
|
onAcquire: () => {
|
|
9157
9534
|
if (!this._opening) {
|
|
9158
9535
|
void this.open(new Context11(void 0, {
|
|
9159
|
-
F:
|
|
9536
|
+
F: __dxlog_file30,
|
|
9160
9537
|
L: 147
|
|
9161
9538
|
}));
|
|
9162
9539
|
}
|
|
@@ -9231,8 +9608,8 @@ var ClientServicesHost = class {
|
|
|
9231
9608
|
* Can only be called once.
|
|
9232
9609
|
*/
|
|
9233
9610
|
initialize({ config, ...options }) {
|
|
9234
|
-
|
|
9235
|
-
F:
|
|
9611
|
+
invariant25(!this._open, "service host is open", {
|
|
9612
|
+
F: __dxlog_file30,
|
|
9236
9613
|
L: 237,
|
|
9237
9614
|
S: this,
|
|
9238
9615
|
A: [
|
|
@@ -9241,7 +9618,7 @@ var ClientServicesHost = class {
|
|
|
9241
9618
|
]
|
|
9242
9619
|
});
|
|
9243
9620
|
log25("initializing...", void 0, {
|
|
9244
|
-
F:
|
|
9621
|
+
F: __dxlog_file30,
|
|
9245
9622
|
L: 238,
|
|
9246
9623
|
S: this,
|
|
9247
9624
|
C: (f, a) => f(...a)
|
|
@@ -9253,12 +9630,9 @@ var ClientServicesHost = class {
|
|
|
9253
9630
|
if (this._runtimeProps.enableVectorIndexing === void 0) {
|
|
9254
9631
|
this._runtimeProps.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
|
|
9255
9632
|
}
|
|
9256
|
-
|
|
9257
|
-
|
|
9258
|
-
|
|
9259
|
-
invariant24(!this._config, "config already set", {
|
|
9260
|
-
F: __dxlog_file29,
|
|
9261
|
-
L: 251,
|
|
9633
|
+
invariant25(!this._config, "config already set", {
|
|
9634
|
+
F: __dxlog_file30,
|
|
9635
|
+
L: 248,
|
|
9262
9636
|
S: this,
|
|
9263
9637
|
A: [
|
|
9264
9638
|
"!this._config",
|
|
@@ -9285,9 +9659,9 @@ var ClientServicesHost = class {
|
|
|
9285
9659
|
edgeConnection: this._edgeConnection
|
|
9286
9660
|
}) : new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
9287
9661
|
this._signalManager = signalManager;
|
|
9288
|
-
|
|
9289
|
-
F:
|
|
9290
|
-
L:
|
|
9662
|
+
invariant25(!this._networkManager, "network manager already set", {
|
|
9663
|
+
F: __dxlog_file30,
|
|
9664
|
+
L: 279,
|
|
9291
9665
|
S: this,
|
|
9292
9666
|
A: [
|
|
9293
9667
|
"!this._networkManager",
|
|
@@ -9304,8 +9678,8 @@ var ClientServicesHost = class {
|
|
|
9304
9678
|
} : void 0
|
|
9305
9679
|
});
|
|
9306
9680
|
log25("initialized", void 0, {
|
|
9307
|
-
F:
|
|
9308
|
-
L:
|
|
9681
|
+
F: __dxlog_file30,
|
|
9682
|
+
L: 292,
|
|
9309
9683
|
S: this,
|
|
9310
9684
|
C: (f, a) => f(...a)
|
|
9311
9685
|
});
|
|
@@ -9318,41 +9692,41 @@ var ClientServicesHost = class {
|
|
|
9318
9692
|
log25.trace("dxos.client-services.host.open", trace10.begin({
|
|
9319
9693
|
id: traceId
|
|
9320
9694
|
}), {
|
|
9321
|
-
F:
|
|
9322
|
-
L:
|
|
9695
|
+
F: __dxlog_file30,
|
|
9696
|
+
L: 303,
|
|
9323
9697
|
S: this,
|
|
9324
9698
|
C: (f, a) => f(...a)
|
|
9325
9699
|
});
|
|
9326
|
-
|
|
9327
|
-
F:
|
|
9328
|
-
L:
|
|
9700
|
+
invariant25(this._config, "config not set", {
|
|
9701
|
+
F: __dxlog_file30,
|
|
9702
|
+
L: 305,
|
|
9329
9703
|
S: this,
|
|
9330
9704
|
A: [
|
|
9331
9705
|
"this._config",
|
|
9332
9706
|
"'config not set'"
|
|
9333
9707
|
]
|
|
9334
9708
|
});
|
|
9335
|
-
|
|
9336
|
-
F:
|
|
9337
|
-
L:
|
|
9709
|
+
invariant25(this._storage, "storage not set", {
|
|
9710
|
+
F: __dxlog_file30,
|
|
9711
|
+
L: 306,
|
|
9338
9712
|
S: this,
|
|
9339
9713
|
A: [
|
|
9340
9714
|
"this._storage",
|
|
9341
9715
|
"'storage not set'"
|
|
9342
9716
|
]
|
|
9343
9717
|
});
|
|
9344
|
-
|
|
9345
|
-
F:
|
|
9346
|
-
L:
|
|
9718
|
+
invariant25(this._signalManager, "signal manager not set", {
|
|
9719
|
+
F: __dxlog_file30,
|
|
9720
|
+
L: 307,
|
|
9347
9721
|
S: this,
|
|
9348
9722
|
A: [
|
|
9349
9723
|
"this._signalManager",
|
|
9350
9724
|
"'signal manager not set'"
|
|
9351
9725
|
]
|
|
9352
9726
|
});
|
|
9353
|
-
|
|
9354
|
-
F:
|
|
9355
|
-
L:
|
|
9727
|
+
invariant25(this._networkManager, "network manager not set", {
|
|
9728
|
+
F: __dxlog_file30,
|
|
9729
|
+
L: 308,
|
|
9356
9730
|
S: this,
|
|
9357
9731
|
A: [
|
|
9358
9732
|
"this._networkManager",
|
|
@@ -9363,8 +9737,8 @@ var ClientServicesHost = class {
|
|
|
9363
9737
|
log25("opening...", {
|
|
9364
9738
|
lockKey: this._resourceLock?.lockKey
|
|
9365
9739
|
}, {
|
|
9366
|
-
F:
|
|
9367
|
-
L:
|
|
9740
|
+
F: __dxlog_file30,
|
|
9741
|
+
L: 311,
|
|
9368
9742
|
S: this,
|
|
9369
9743
|
C: (f, a) => f(...a)
|
|
9370
9744
|
});
|
|
@@ -9405,8 +9779,32 @@ var ClientServicesHost = class {
|
|
|
9405
9779
|
}),
|
|
9406
9780
|
EdgeAgentService: new EdgeAgentServiceImpl(agentManagerProvider, this._edgeConnection)
|
|
9407
9781
|
});
|
|
9782
|
+
log25("service-host: opening service context...", void 0, {
|
|
9783
|
+
F: __dxlog_file30,
|
|
9784
|
+
L: 395,
|
|
9785
|
+
S: this,
|
|
9786
|
+
C: (f, a) => f(...a)
|
|
9787
|
+
});
|
|
9408
9788
|
await this._serviceContext.open(ctx);
|
|
9789
|
+
log25("service-host: service context opened", void 0, {
|
|
9790
|
+
F: __dxlog_file30,
|
|
9791
|
+
L: 397,
|
|
9792
|
+
S: this,
|
|
9793
|
+
C: (f, a) => f(...a)
|
|
9794
|
+
});
|
|
9795
|
+
log25("service-host: opening identity service...", void 0, {
|
|
9796
|
+
F: __dxlog_file30,
|
|
9797
|
+
L: 399,
|
|
9798
|
+
S: this,
|
|
9799
|
+
C: (f, a) => f(...a)
|
|
9800
|
+
});
|
|
9409
9801
|
await identityService.open();
|
|
9802
|
+
log25("service-host: identity service opened", void 0, {
|
|
9803
|
+
F: __dxlog_file30,
|
|
9804
|
+
L: 401,
|
|
9805
|
+
S: this,
|
|
9806
|
+
C: (f, a) => f(...a)
|
|
9807
|
+
});
|
|
9410
9808
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
9411
9809
|
if (devtoolsProxy) {
|
|
9412
9810
|
this._devtoolsProxy = new WebsocketRpcClient({
|
|
@@ -9425,16 +9823,16 @@ var ClientServicesHost = class {
|
|
|
9425
9823
|
log25("opened", {
|
|
9426
9824
|
deviceKey
|
|
9427
9825
|
}, {
|
|
9428
|
-
F:
|
|
9429
|
-
L:
|
|
9826
|
+
F: __dxlog_file30,
|
|
9827
|
+
L: 419,
|
|
9430
9828
|
S: this,
|
|
9431
9829
|
C: (f, a) => f(...a)
|
|
9432
9830
|
});
|
|
9433
9831
|
log25.trace("dxos.client-services.host.open", trace10.end({
|
|
9434
9832
|
id: traceId
|
|
9435
9833
|
}), {
|
|
9436
|
-
F:
|
|
9437
|
-
L:
|
|
9834
|
+
F: __dxlog_file30,
|
|
9835
|
+
L: 420,
|
|
9438
9836
|
S: this,
|
|
9439
9837
|
C: (f, a) => f(...a)
|
|
9440
9838
|
});
|
|
@@ -9447,8 +9845,8 @@ var ClientServicesHost = class {
|
|
|
9447
9845
|
log25("closing...", {
|
|
9448
9846
|
deviceKey
|
|
9449
9847
|
}, {
|
|
9450
|
-
F:
|
|
9451
|
-
L:
|
|
9848
|
+
F: __dxlog_file30,
|
|
9849
|
+
L: 431,
|
|
9452
9850
|
S: this,
|
|
9453
9851
|
C: (f, a) => f(...a)
|
|
9454
9852
|
});
|
|
@@ -9465,8 +9863,8 @@ var ClientServicesHost = class {
|
|
|
9465
9863
|
log25("closed", {
|
|
9466
9864
|
deviceKey
|
|
9467
9865
|
}, {
|
|
9468
|
-
F:
|
|
9469
|
-
L:
|
|
9866
|
+
F: __dxlog_file30,
|
|
9867
|
+
L: 440,
|
|
9470
9868
|
S: this,
|
|
9471
9869
|
C: (f, a) => f(...a)
|
|
9472
9870
|
});
|
|
@@ -9476,14 +9874,14 @@ var ClientServicesHost = class {
|
|
|
9476
9874
|
log25.trace("dxos.sdk.client-services-host.reset", trace10.begin({
|
|
9477
9875
|
id: traceId
|
|
9478
9876
|
}), {
|
|
9479
|
-
F:
|
|
9480
|
-
L:
|
|
9877
|
+
F: __dxlog_file30,
|
|
9878
|
+
L: 445,
|
|
9481
9879
|
S: this,
|
|
9482
9880
|
C: (f, a) => f(...a)
|
|
9483
9881
|
});
|
|
9484
9882
|
log25.info("resetting...", void 0, {
|
|
9485
|
-
F:
|
|
9486
|
-
L:
|
|
9883
|
+
F: __dxlog_file30,
|
|
9884
|
+
L: 447,
|
|
9487
9885
|
S: this,
|
|
9488
9886
|
C: (f, a) => f(...a)
|
|
9489
9887
|
});
|
|
@@ -9496,24 +9894,24 @@ var ClientServicesHost = class {
|
|
|
9496
9894
|
log25.warn("failed to clear leveldb during reset", {
|
|
9497
9895
|
err
|
|
9498
9896
|
}, {
|
|
9499
|
-
F:
|
|
9500
|
-
L:
|
|
9897
|
+
F: __dxlog_file30,
|
|
9898
|
+
L: 457,
|
|
9501
9899
|
S: this,
|
|
9502
9900
|
C: (f, a) => f(...a)
|
|
9503
9901
|
});
|
|
9504
9902
|
}
|
|
9505
9903
|
await this._storage.reset();
|
|
9506
9904
|
log25.info("reset", void 0, {
|
|
9507
|
-
F:
|
|
9508
|
-
L:
|
|
9905
|
+
F: __dxlog_file30,
|
|
9906
|
+
L: 460,
|
|
9509
9907
|
S: this,
|
|
9510
9908
|
C: (f, a) => f(...a)
|
|
9511
9909
|
});
|
|
9512
9910
|
log25.trace("dxos.sdk.client-services-host.reset", trace10.end({
|
|
9513
9911
|
id: traceId
|
|
9514
9912
|
}), {
|
|
9515
|
-
F:
|
|
9516
|
-
L:
|
|
9913
|
+
F: __dxlog_file30,
|
|
9914
|
+
L: 461,
|
|
9517
9915
|
S: this,
|
|
9518
9916
|
C: (f, a) => f(...a)
|
|
9519
9917
|
});
|
|
@@ -9584,4 +9982,4 @@ export {
|
|
|
9584
9982
|
ServiceRegistry,
|
|
9585
9983
|
ClientServicesHost
|
|
9586
9984
|
};
|
|
9587
|
-
//# sourceMappingURL=chunk-
|
|
9985
|
+
//# sourceMappingURL=chunk-FRMIC6UB.mjs.map
|