@dxos/client-services 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7

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.
Files changed (41) hide show
  1. package/dist/lib/browser/{chunk-KBXLEVD5.mjs → chunk-CZN7GX3A.mjs} +386 -121
  2. package/dist/lib/browser/chunk-CZN7GX3A.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +23 -15
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +1 -1
  7. package/dist/lib/node-esm/{chunk-G62TR33T.mjs → chunk-F36CDLDY.mjs} +386 -121
  8. package/dist/lib/node-esm/chunk-F36CDLDY.mjs.map +7 -0
  9. package/dist/lib/node-esm/index.mjs +23 -15
  10. package/dist/lib/node-esm/index.mjs.map +3 -3
  11. package/dist/lib/node-esm/meta.json +1 -1
  12. package/dist/lib/node-esm/testing/index.mjs +1 -1
  13. package/dist/types/src/packlets/logging/logging-service.d.ts +4 -0
  14. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  15. package/dist/types/src/packlets/services/feed-syncer.d.ts +59 -0
  16. package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -0
  17. package/dist/types/src/packlets/services/feed-syncer.test.d.ts +2 -0
  18. package/dist/types/src/packlets/services/feed-syncer.test.d.ts.map +1 -0
  19. package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
  20. package/dist/types/src/packlets/services/service-context.d.ts +1 -2
  21. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  22. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  23. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  24. package/dist/types/src/packlets/worker/worker-runtime.d.ts +11 -3
  25. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
  26. package/dist/types/src/version.d.ts +1 -1
  27. package/dist/types/src/version.d.ts.map +1 -1
  28. package/dist/types/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +43 -43
  30. package/src/packlets/logging/logging-service.ts +4 -0
  31. package/src/packlets/services/feed-syncer.test.ts +340 -0
  32. package/src/packlets/services/feed-syncer.ts +330 -0
  33. package/src/packlets/services/platform.ts +7 -1
  34. package/src/packlets/services/service-context.ts +29 -8
  35. package/src/packlets/services/service-host.ts +0 -3
  36. package/src/packlets/spaces/data-space.ts +3 -0
  37. package/src/packlets/worker/worker-runtime.ts +13 -5
  38. package/src/packlets/worker/worker-session.ts +4 -4
  39. package/src/version.ts +1 -1
  40. package/dist/lib/browser/chunk-KBXLEVD5.mjs.map +0 -7
  41. package/dist/lib/node-esm/chunk-G62TR33T.mjs.map +0 -7
@@ -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.69d29f4";
406
+ var DXOS_VERSION = "0.8.4-main.6fa680abb7";
407
407
 
408
408
  // src/packlets/services/platform.ts
409
409
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -416,11 +416,16 @@ var getPlatform = () => {
416
416
  userAgent,
417
417
  uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
418
418
  };
419
- } else {
419
+ } else if (typeof SharedWorkerGlobalScope !== "undefined") {
420
420
  return {
421
421
  type: Platform.PLATFORM_TYPE.SHARED_WORKER,
422
422
  uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
423
423
  };
424
+ } else {
425
+ return {
426
+ type: Platform.PLATFORM_TYPE.DEDICATED_WORKER,
427
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
428
+ };
424
429
  }
425
430
  } else {
426
431
  const { platform: platform2, version, arch } = process;
@@ -4708,9 +4713,12 @@ var DataSpace = class {
4708
4713
  C: (f, a) => f(...a)
4709
4714
  });
4710
4715
  } catch (err) {
4716
+ if (err instanceof ContextDisposedError) {
4717
+ return;
4718
+ }
4711
4719
  log12.error("error notarizing credentials for feed admission", err, {
4712
4720
  F: __dxlog_file15,
4713
- L: 453,
4721
+ L: 456,
4714
4722
  S: this,
4715
4723
  C: (f, a) => f(...a)
4716
4724
  });
@@ -4725,7 +4733,7 @@ var DataSpace = class {
4725
4733
  rootUrl
4726
4734
  }, {
4727
4735
  F: __dxlog_file15,
4728
- L: 463,
4736
+ L: 466,
4729
4737
  S: this,
4730
4738
  C: (f, a) => f(...a)
4731
4739
  });
@@ -4741,7 +4749,7 @@ var DataSpace = class {
4741
4749
  await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
4742
4750
  handle = await cancelWithContext2(this._ctx, this._echoHost.loadDoc(Context6.default(void 0, {
4743
4751
  F: __dxlog_file15,
4744
- L: 473
4752
+ L: 476
4745
4753
  }), rootUrl, {
4746
4754
  fetchFromNetwork: true
4747
4755
  }));
@@ -4785,7 +4793,7 @@ var DataSpace = class {
4785
4793
  err
4786
4794
  }, {
4787
4795
  F: __dxlog_file15,
4788
- L: 512,
4796
+ L: 515,
4789
4797
  S: this,
4790
4798
  C: (f, a) => f(...a)
4791
4799
  });
@@ -4875,7 +4883,7 @@ var DataSpace = class {
4875
4883
  state: SpaceState4[this._state]
4876
4884
  }, {
4877
4885
  F: __dxlog_file15,
4878
- L: 594,
4886
+ L: 597,
4879
4887
  S: this,
4880
4888
  C: (f, a) => f(...a)
4881
4889
  });
@@ -7653,17 +7661,18 @@ var mapStatus = (agentStatus) => {
7653
7661
 
7654
7662
  // src/packlets/services/service-context.ts
7655
7663
  import { Mutex as Mutex4, Trigger as Trigger7 } from "@dxos/async";
7656
- import { Context as Context10, Resource as Resource8 } from "@dxos/context";
7664
+ import { Context as Context10, Resource as Resource9 } from "@dxos/context";
7657
7665
  import { getCredentialAssertion as getCredentialAssertion6 } from "@dxos/credentials";
7658
7666
  import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
7659
7667
  import { EchoEdgeReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
7660
7668
  import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from "@dxos/edge-client";
7661
7669
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
7662
- import { invariant as invariant22 } from "@dxos/invariant";
7670
+ import { invariant as invariant23 } from "@dxos/invariant";
7663
7671
  import { Keyring } from "@dxos/keyring";
7664
7672
  import { PublicKey as PublicKey15 } from "@dxos/keys";
7665
7673
  import { log as log23 } from "@dxos/log";
7666
7674
  import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
7675
+ import { FeedProtocol as FeedProtocol2 } from "@dxos/protocols";
7667
7676
  import { Invitation as Invitation10 } from "@dxos/protocols/proto/dxos/client/services";
7668
7677
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
7669
7678
  import { trace as Trace3 } from "@dxos/tracing";
@@ -7889,6 +7898,246 @@ var decodeCredential = (credentialBase64) => {
7889
7898
  return codec.decode(credentialBytes);
7890
7899
  };
7891
7900
 
7901
+ // src/packlets/services/feed-syncer.ts
7902
+ import { Encoder, decode as cborXdecode } from "cbor-x";
7903
+ import * as Effect from "effect/Effect";
7904
+ import * as Schema from "effect/Schema";
7905
+ import { AsyncTask, scheduleTask as scheduleTask9 } from "@dxos/async";
7906
+ import { Resource as Resource8 } from "@dxos/context";
7907
+ import { MessageSchema } from "@dxos/edge-client";
7908
+ import { RuntimeProvider } from "@dxos/effect";
7909
+ import { SyncClient } from "@dxos/feed";
7910
+ import { invariant as invariant22 } from "@dxos/invariant";
7911
+ import { SpaceId as SpaceId4 } from "@dxos/keys";
7912
+ import { FeedProtocol } from "@dxos/protocols";
7913
+ import { EdgeService as EdgeService2 } from "@dxos/protocols";
7914
+ import { createBuf } from "@dxos/protocols/buf";
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";
7917
+ var encoder = new Encoder({
7918
+ tagUint8Array: false,
7919
+ useRecords: false
7920
+ });
7921
+ var DEFAULT_MESSAGE_BLOCKS_LIMIT = 50;
7922
+ var DEFAULT_SYNC_CONCURRENCY = 5;
7923
+ var DEFAULT_POLLING_INTERVAL = 5e3;
7924
+ var DEFAULT_POLL_REQUEST_THROTTLE_MS = 250;
7925
+ var MAX_BLOCKING_SYNC_ITERATIONS = 100;
7926
+ var FeedSyncer = class extends Resource8 {
7927
+ #syncNamespaces;
7928
+ #messageBlocksLimit;
7929
+ #syncConcurrency;
7930
+ #pollingInterval;
7931
+ #pollRequestThrottleMs;
7932
+ #runtime;
7933
+ #feedStore;
7934
+ #edgeClient;
7935
+ #syncClient;
7936
+ #getSpaceIds;
7937
+ #spacesToPoll = /* @__PURE__ */ new Set();
7938
+ /** Last time full poll was completed. */
7939
+ #lastFullPoll = null;
7940
+ #throttledPollScheduled = false;
7941
+ #lastRequestedPollAt = null;
7942
+ constructor(options) {
7943
+ super();
7944
+ this.#runtime = options.runtime;
7945
+ this.#feedStore = options.feedStore;
7946
+ this.#edgeClient = options.edgeClient;
7947
+ this.#syncClient = new SyncClient({
7948
+ peerId: options.peerId,
7949
+ feedStore: options.feedStore,
7950
+ sendMessage: this.#sendMessage.bind(this)
7951
+ });
7952
+ this.#getSpaceIds = options.getSpaceIds;
7953
+ this.#syncNamespaces = options.syncNamespaces;
7954
+ this.#messageBlocksLimit = options.messageBlocksLimit ?? DEFAULT_MESSAGE_BLOCKS_LIMIT;
7955
+ this.#syncConcurrency = options.syncConcurrency ?? DEFAULT_SYNC_CONCURRENCY;
7956
+ this.#pollingInterval = options.pollingInterval ?? DEFAULT_POLLING_INTERVAL;
7957
+ this.#pollRequestThrottleMs = options.pollRequestThrottleMs ?? DEFAULT_POLL_REQUEST_THROTTLE_MS;
7958
+ }
7959
+ async _open() {
7960
+ this._ctx.onDispose(this.#edgeClient.onMessage((msg) => {
7961
+ if (!msg.serviceId) {
7962
+ return;
7963
+ }
7964
+ const service = msg.serviceId.split(":")[0];
7965
+ if (service !== EdgeService2.QUEUE_REPLICATOR) {
7966
+ return;
7967
+ }
7968
+ const handleMessageEffect = Effect.gen(this, function* () {
7969
+ const decoded = yield* Effect.try({
7970
+ try: () => cborXdecode(msg.payload.value),
7971
+ catch: (error) => new Error(`Failed to decode feed sync message: ${error}`)
7972
+ });
7973
+ const payload = yield* Schema.validate(FeedProtocol.ProtocolMessage)(decoded);
7974
+ yield* this.#syncClient.handleMessage(payload);
7975
+ });
7976
+ void RuntimeProvider.runPromise(this.#runtime)(handleMessageEffect);
7977
+ }));
7978
+ this._ctx.onDispose(
7979
+ // NOTE: This will fire immediately if the connection is already open.
7980
+ this.#edgeClient.onReconnected(async () => {
7981
+ })
7982
+ );
7983
+ this.#feedStore.onNewBlocks.on(this._ctx, () => {
7984
+ this.#pushTask.schedule();
7985
+ });
7986
+ await this.#pollTask.open();
7987
+ await this.#pushTask.open();
7988
+ this.#resetSpacesToPoll();
7989
+ this.#pollTask.schedule();
7990
+ }
7991
+ async _close() {
7992
+ await this.#pollTask.close();
7993
+ await this.#pushTask.close();
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
+ }
8065
+ #resetSpacesToPoll() {
8066
+ this.#spacesToPoll.clear();
8067
+ this.#getSpaceIds().forEach((spaceId) => {
8068
+ this.#spacesToPoll.add(spaceId);
8069
+ });
8070
+ this.#lastFullPoll = Date.now();
8071
+ }
8072
+ #sendMessage(message) {
8073
+ return Effect.gen(this, function* () {
8074
+ const encoded = encoder.encode(message);
8075
+ yield* Effect.tryPromise(async () => this.#edgeClient.send(createBuf(MessageSchema, {
8076
+ source: {
8077
+ identityKey: this.#edgeClient.identityKey,
8078
+ peerKey: this.#edgeClient.peerKey
8079
+ },
8080
+ serviceId: this.#getTargetServiceId(message),
8081
+ payload: {
8082
+ value: bufferToArray2(encoded)
8083
+ }
8084
+ })));
8085
+ });
8086
+ }
8087
+ #getTargetServiceId(message) {
8088
+ return FeedProtocol.encodeServiceId(message.feedNamespace, message.spaceId);
8089
+ }
8090
+ #pollTask = new AsyncTask(async () => Effect.gen(this, function* () {
8091
+ yield* Effect.forEach(this.#spacesToPoll, (spaceId) => Effect.gen(this, function* () {
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) {
8104
+ this.#spacesToPoll.delete(spaceId);
8105
+ }
8106
+ }), {
8107
+ concurrency: this.#syncConcurrency
8108
+ });
8109
+ if (this.#lastFullPoll == null || Date.now() - this.#lastFullPoll > this.#pollingInterval) {
8110
+ this.#resetSpacesToPoll();
8111
+ this.#pollTask.schedule();
8112
+ } else if (this.#spacesToPoll.size > 0) {
8113
+ this.#pollTask.schedule();
8114
+ } else {
8115
+ this.#resetSpacesToPoll();
8116
+ scheduleTask9(this._ctx, () => this.#pollTask.schedule(), Math.max(this.#pollingInterval - (Date.now() - (this.#lastFullPoll ?? 0)), 0));
8117
+ }
8118
+ }).pipe(RuntimeProvider.runPromise(this.#runtime)));
8119
+ #pushTask = new AsyncTask(async () => Effect.gen(this, function* () {
8120
+ yield* Effect.forEach(this.#getSpaceIds(), (spaceId) => Effect.gen(this, function* () {
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) {
8133
+ this.#pushTask.schedule();
8134
+ }
8135
+ }), {
8136
+ concurrency: this.#syncConcurrency
8137
+ });
8138
+ }).pipe(RuntimeProvider.runPromise(this.#runtime)));
8139
+ };
8140
+
7892
8141
  // src/packlets/services/service-context.ts
7893
8142
  function _ts_decorate8(decorators, target, key, desc) {
7894
8143
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -7961,8 +8210,8 @@ function _ts_dispose_resources4(env) {
7961
8210
  return next();
7962
8211
  })(env);
7963
8212
  }
7964
- var __dxlog_file27 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
7965
- var ServiceContext = class extends Resource8 {
8213
+ var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
8214
+ var ServiceContext = class extends Resource9 {
7966
8215
  storage;
7967
8216
  level;
7968
8217
  networkManager;
@@ -7986,6 +8235,7 @@ var ServiceContext = class extends Resource8 {
7986
8235
  echoHost;
7987
8236
  _meshReplicator = void 0;
7988
8237
  _echoEdgeReplicator = void 0;
8238
+ _feedSyncer = void 0;
7989
8239
  // Initialized after identity is initialized.
7990
8240
  dataSpaceManager;
7991
8241
  edgeAgentManager;
@@ -7995,14 +8245,14 @@ var ServiceContext = class extends Resource8 {
7995
8245
  constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtime, _runtimeProps, _edgeFeatures) {
7996
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;
7997
8247
  log23("runtimeProps", this._runtimeProps, {
7998
- F: __dxlog_file27,
7999
- L: 120,
8248
+ F: __dxlog_file28,
8249
+ L: 122,
8000
8250
  S: this,
8001
8251
  C: (f, a) => f(...a)
8002
8252
  });
8003
8253
  log23("edgeFeatures", this._edgeFeatures, {
8004
- F: __dxlog_file27,
8005
- L: 121,
8254
+ F: __dxlog_file28,
8255
+ L: 123,
8006
8256
  S: this,
8007
8257
  C: (f, a) => f(...a)
8008
8258
  });
@@ -8041,12 +8291,15 @@ var ServiceContext = class extends Resource8 {
8041
8291
  kv: this.level,
8042
8292
  peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8043
8293
  getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8044
- indexing: {
8045
- vector: this._runtimeProps?.enableVectorIndexing,
8046
- sqlIndex: this._runtimeProps?.enableSqlite
8047
- },
8048
8294
  runtime: this._runtime,
8049
- localQueues: this._runtimeProps?.enableLocalQueues
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
+ }
8050
8303
  });
8051
8304
  this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeProps?.invitationConnectionDefaultProps);
8052
8305
  this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
@@ -8060,20 +8313,33 @@ var ServiceContext = class extends Resource8 {
8060
8313
  edgeHttpClient: this._edgeHttpClient
8061
8314
  });
8062
8315
  }
8316
+ if (this.echoHost.feedStore && this._edgeConnection) {
8317
+ this._feedSyncer = new FeedSyncer({
8318
+ runtime: this._runtime,
8319
+ feedStore: this.echoHost.feedStore,
8320
+ edgeClient: this._edgeConnection,
8321
+ peerId: this.identityManager.identity?.deviceKey?.toHex() ?? "",
8322
+ getSpaceIds: () => this.echoHost.spaceIds,
8323
+ syncNamespaces: [
8324
+ FeedProtocol2.WellKnownNamespaces.data,
8325
+ FeedProtocol2.WellKnownNamespaces.trace
8326
+ ]
8327
+ });
8328
+ }
8063
8329
  }
8064
8330
  async _open(ctx) {
8065
8331
  await this._checkStorageVersion();
8066
8332
  log23("opening...", void 0, {
8067
- F: __dxlog_file27,
8068
- L: 215,
8333
+ F: __dxlog_file28,
8334
+ L: 231,
8069
8335
  S: this,
8070
8336
  C: (f, a) => f(...a)
8071
8337
  });
8072
8338
  log23.trace("dxos.sdk.service-context.open", trace9.begin({
8073
8339
  id: this._instanceId
8074
8340
  }), {
8075
- F: __dxlog_file27,
8076
- L: 216,
8341
+ F: __dxlog_file28,
8342
+ L: 232,
8077
8343
  S: this,
8078
8344
  C: (f, a) => f(...a)
8079
8345
  });
@@ -8095,37 +8361,39 @@ var ServiceContext = class extends Resource8 {
8095
8361
  await this.identityManager.identity.joinNetwork();
8096
8362
  await this._initialize(ctx);
8097
8363
  }
8364
+ await this._feedSyncer?.open();
8098
8365
  const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
8099
8366
  log23("loaded persistent invitations", {
8100
8367
  count: loadedInvitations.invitations?.length
8101
8368
  }, {
8102
- F: __dxlog_file27,
8103
- L: 244,
8369
+ F: __dxlog_file28,
8370
+ L: 262,
8104
8371
  S: this,
8105
8372
  C: (f, a) => f(...a)
8106
8373
  });
8107
8374
  log23.trace("dxos.sdk.service-context.open", trace9.end({
8108
8375
  id: this._instanceId
8109
8376
  }), {
8110
- F: __dxlog_file27,
8111
- L: 246,
8377
+ F: __dxlog_file28,
8378
+ L: 264,
8112
8379
  S: this,
8113
8380
  C: (f, a) => f(...a)
8114
8381
  });
8115
8382
  log23("opened", void 0, {
8116
- F: __dxlog_file27,
8117
- L: 247,
8383
+ F: __dxlog_file28,
8384
+ L: 265,
8118
8385
  S: this,
8119
8386
  C: (f, a) => f(...a)
8120
8387
  });
8121
8388
  }
8122
8389
  async _close(ctx) {
8123
8390
  log23("closing...", void 0, {
8124
- F: __dxlog_file27,
8125
- L: 251,
8391
+ F: __dxlog_file28,
8392
+ L: 269,
8126
8393
  S: this,
8127
8394
  C: (f, a) => f(...a)
8128
8395
  });
8396
+ await this._feedSyncer?.close();
8129
8397
  if (this._deviceSpaceSync && this.identityManager.identity) {
8130
8398
  await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
8131
8399
  }
@@ -8140,8 +8408,8 @@ var ServiceContext = class extends Resource8 {
8140
8408
  await this.feedStore.close();
8141
8409
  await this.metadataStore.close();
8142
8410
  log23("closed", void 0, {
8143
- F: __dxlog_file27,
8144
- L: 267,
8411
+ F: __dxlog_file28,
8412
+ L: 288,
8145
8413
  S: this,
8146
8414
  C: (f, a) => f(...a)
8147
8415
  });
@@ -8151,8 +8419,8 @@ var ServiceContext = class extends Resource8 {
8151
8419
  await this._setNetworkIdentity();
8152
8420
  await identity.joinNetwork();
8153
8421
  await this._initialize(new Context10(void 0, {
8154
- F: __dxlog_file27,
8155
- L: 274
8422
+ F: __dxlog_file28,
8423
+ L: 295
8156
8424
  }));
8157
8425
  return identity;
8158
8426
  }
@@ -8161,9 +8429,9 @@ var ServiceContext = class extends Resource8 {
8161
8429
  throw new Error("Identity must be created before joining a space.");
8162
8430
  }
8163
8431
  const factory = this._handlerFactories.get(invitation.kind);
8164
- invariant22(factory, `Unknown invitation kind: ${invitation.kind}`, {
8165
- F: __dxlog_file27,
8166
- L: 283,
8432
+ invariant23(factory, `Unknown invitation kind: ${invitation.kind}`, {
8433
+ F: __dxlog_file28,
8434
+ L: 304,
8167
8435
  S: this,
8168
8436
  A: [
8169
8437
  "factory",
@@ -8188,8 +8456,8 @@ var ServiceContext = class extends Resource8 {
8188
8456
  await identity.joinNetwork();
8189
8457
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
8190
8458
  await this._initialize(new Context10(void 0, {
8191
- F: __dxlog_file27,
8192
- L: 302
8459
+ F: __dxlog_file28,
8460
+ L: 323
8193
8461
  }));
8194
8462
  return identity;
8195
8463
  }
@@ -8202,8 +8470,8 @@ var ServiceContext = class extends Resource8 {
8202
8470
  // Called when identity is created.
8203
8471
  async _initialize(ctx) {
8204
8472
  log23("initializing spaces...", void 0, {
8205
- F: __dxlog_file27,
8206
- L: 317,
8473
+ F: __dxlog_file28,
8474
+ L: 338,
8207
8475
  S: this,
8208
8476
  C: (f, a) => f(...a)
8209
8477
  });
@@ -8240,9 +8508,9 @@ var ServiceContext = class extends Resource8 {
8240
8508
  this.edgeAgentManager = new EdgeAgentManager(this._edgeFeatures, this._edgeHttpClient, this.dataSpaceManager, identity);
8241
8509
  await this.edgeAgentManager.open();
8242
8510
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
8243
- invariant22(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
8244
- F: __dxlog_file27,
8245
- L: 355,
8511
+ invariant23(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
8512
+ F: __dxlog_file28,
8513
+ L: 376,
8246
8514
  S: this,
8247
8515
  A: [
8248
8516
  "this.dataSpaceManager",
@@ -8265,8 +8533,8 @@ var ServiceContext = class extends Resource8 {
8265
8533
  log23("dataSpaceManager not initialized yet, ignoring space admission", {
8266
8534
  details: assertion
8267
8535
  }, {
8268
- F: __dxlog_file27,
8269
- L: 371,
8536
+ F: __dxlog_file28,
8537
+ L: 392,
8270
8538
  S: this,
8271
8539
  C: (f, a) => f(...a)
8272
8540
  });
@@ -8276,8 +8544,8 @@ var ServiceContext = class extends Resource8 {
8276
8544
  log23("space already exists, ignoring space admission", {
8277
8545
  details: assertion
8278
8546
  }, {
8279
- F: __dxlog_file27,
8280
- L: 375,
8547
+ F: __dxlog_file28,
8548
+ L: 396,
8281
8549
  S: this,
8282
8550
  C: (f, a) => f(...a)
8283
8551
  });
@@ -8287,8 +8555,8 @@ var ServiceContext = class extends Resource8 {
8287
8555
  log23("accepting space recorded in halo", {
8288
8556
  details: assertion
8289
8557
  }, {
8290
- F: __dxlog_file27,
8291
- L: 380,
8558
+ F: __dxlog_file28,
8559
+ L: 401,
8292
8560
  S: this,
8293
8561
  C: (f, a) => f(...a)
8294
8562
  });
@@ -8298,8 +8566,8 @@ var ServiceContext = class extends Resource8 {
8298
8566
  });
8299
8567
  } catch (err) {
8300
8568
  log23.catch(err, void 0, {
8301
- F: __dxlog_file27,
8302
- L: 386,
8569
+ F: __dxlog_file28,
8570
+ L: 407,
8303
8571
  S: this,
8304
8572
  C: (f, a) => f(...a)
8305
8573
  });
@@ -8323,8 +8591,8 @@ var ServiceContext = class extends Resource8 {
8323
8591
  identity: identity.identityKey.toHex(),
8324
8592
  swarms: this.networkManager.topics
8325
8593
  }, {
8326
- F: __dxlog_file27,
8327
- L: 400,
8594
+ F: __dxlog_file28,
8595
+ L: 421,
8328
8596
  S: this,
8329
8597
  C: (f, a) => f(...a)
8330
8598
  });
@@ -8336,9 +8604,9 @@ var ServiceContext = class extends Resource8 {
8336
8604
  await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
8337
8605
  await identity.ready();
8338
8606
  });
8339
- invariant22(identity.deviceCredentialChain, void 0, {
8340
- F: __dxlog_file27,
8341
- L: 419,
8607
+ invariant23(identity.deviceCredentialChain, void 0, {
8608
+ F: __dxlog_file28,
8609
+ L: 440,
8342
8610
  S: this,
8343
8611
  A: [
8344
8612
  "identity.deviceCredentialChain",
@@ -8485,13 +8753,13 @@ var ServiceRegistry = class {
8485
8753
 
8486
8754
  // src/packlets/services/service-host.ts
8487
8755
  import * as SqlClient from "@effect/sql/SqlClient";
8488
- import * as Effect from "effect/Effect";
8756
+ import * as Effect2 from "effect/Effect";
8489
8757
  import { Event as Event11, synchronized as synchronized4 } from "@dxos/async";
8490
8758
  import { clientServiceBundle } from "@dxos/client-protocol";
8491
8759
  import { Context as Context11 } from "@dxos/context";
8492
8760
  import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity } from "@dxos/edge-client";
8493
- import { RuntimeProvider } from "@dxos/effect";
8494
- import { invariant as invariant24 } from "@dxos/invariant";
8761
+ import { RuntimeProvider as RuntimeProvider2 } from "@dxos/effect";
8762
+ import { invariant as invariant25 } from "@dxos/invariant";
8495
8763
  import { PublicKey as PublicKey19 } from "@dxos/keys";
8496
8764
  import { log as log25 } from "@dxos/log";
8497
8765
  import { EdgeSignalManager, WebsocketSignalManager } from "@dxos/messaging";
@@ -8505,9 +8773,9 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
8505
8773
  // src/packlets/devices/devices-service.ts
8506
8774
  import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
8507
8775
  import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
8508
- import { invariant as invariant23 } from "@dxos/invariant";
8776
+ import { invariant as invariant24 } from "@dxos/invariant";
8509
8777
  import { Device as Device2, DeviceKind as DeviceKind2, EdgeStatus as EdgeStatus3 } from "@dxos/protocols/proto/dxos/client/services";
8510
- var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8778
+ var __dxlog_file29 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8511
8779
  var DevicesServiceImpl = class {
8512
8780
  _identityManager;
8513
8781
  _edgeConnection;
@@ -8527,8 +8795,8 @@ var DevicesServiceImpl = class {
8527
8795
  devices: []
8528
8796
  });
8529
8797
  } else {
8530
- invariant23(this._identityManager.identity?.presence, "presence not present", {
8531
- F: __dxlog_file28,
8798
+ invariant24(this._identityManager.identity?.presence, "presence not present", {
8799
+ F: __dxlog_file29,
8532
8800
  L: 37,
8533
8801
  S: this,
8534
8802
  A: [
@@ -8595,7 +8863,7 @@ var DevicesServiceImpl = class {
8595
8863
  };
8596
8864
 
8597
8865
  // src/packlets/identity/contacts-service.ts
8598
- import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateScheduler2, scheduleTask as scheduleTask9 } from "@dxos/async";
8866
+ import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateScheduler2, scheduleTask as scheduleTask10 } from "@dxos/async";
8599
8867
  import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8600
8868
  import { PublicKey as PublicKey17 } from "@dxos/keys";
8601
8869
  import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
@@ -8657,7 +8925,7 @@ var ContactsServiceImpl = class {
8657
8925
  }, {
8658
8926
  maxFrequency: 2
8659
8927
  });
8660
- scheduleTask9(ctx, async () => {
8928
+ scheduleTask10(ctx, async () => {
8661
8929
  const subscriptions = new SubscriptionList4();
8662
8930
  ctx.onDispose(() => subscriptions.clear());
8663
8931
  const subscribeToSpaceAndUpdate = () => {
@@ -8936,7 +9204,7 @@ function _ts_decorate9(decorators, target, key, desc) {
8936
9204
  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;
8937
9205
  return c > 3 && r && Object.defineProperty(target, key, r), r;
8938
9206
  }
8939
- var __dxlog_file29 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
9207
+ var __dxlog_file30 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
8940
9208
  var ClientServicesHost = class {
8941
9209
  _resourceLock;
8942
9210
  _serviceRegistry;
@@ -8990,7 +9258,7 @@ var ClientServicesHost = class {
8990
9258
  onAcquire: () => {
8991
9259
  if (!this._opening) {
8992
9260
  void this.open(new Context11(void 0, {
8993
- F: __dxlog_file29,
9261
+ F: __dxlog_file30,
8994
9262
  L: 147
8995
9263
  }));
8996
9264
  }
@@ -9045,7 +9313,7 @@ var ClientServicesHost = class {
9045
9313
  * Debugging util.
9046
9314
  */
9047
9315
  async exportSqliteDatabase() {
9048
- return await RuntimeProvider.runPromise(this._runtime)(Effect.gen(function* () {
9316
+ return await RuntimeProvider2.runPromise(this._runtime)(Effect2.gen(function* () {
9049
9317
  const sql = yield* SqlExport.SqlExport;
9050
9318
  return yield* sql.export;
9051
9319
  }));
@@ -9054,7 +9322,7 @@ var ClientServicesHost = class {
9054
9322
  * Debugging util.
9055
9323
  */
9056
9324
  async runSqliteQuery(query, params) {
9057
- return await RuntimeProvider.runPromise(this._runtime)(Effect.gen(function* () {
9325
+ return await RuntimeProvider2.runPromise(this._runtime)(Effect2.gen(function* () {
9058
9326
  const sql = yield* SqlClient.SqlClient;
9059
9327
  return yield* sql`${sql.unsafe(query, params)}`;
9060
9328
  }));
@@ -9065,8 +9333,8 @@ var ClientServicesHost = class {
9065
9333
  * Can only be called once.
9066
9334
  */
9067
9335
  initialize({ config, ...options }) {
9068
- invariant24(!this._open, "service host is open", {
9069
- F: __dxlog_file29,
9336
+ invariant25(!this._open, "service host is open", {
9337
+ F: __dxlog_file30,
9070
9338
  L: 237,
9071
9339
  S: this,
9072
9340
  A: [
@@ -9075,7 +9343,7 @@ var ClientServicesHost = class {
9075
9343
  ]
9076
9344
  });
9077
9345
  log25("initializing...", void 0, {
9078
- F: __dxlog_file29,
9346
+ F: __dxlog_file30,
9079
9347
  L: 238,
9080
9348
  S: this,
9081
9349
  C: (f, a) => f(...a)
@@ -9087,12 +9355,9 @@ var ClientServicesHost = class {
9087
9355
  if (this._runtimeProps.enableVectorIndexing === void 0) {
9088
9356
  this._runtimeProps.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9089
9357
  }
9090
- if (this._runtimeProps.enableLocalQueues === void 0) {
9091
- this._runtimeProps.enableLocalQueues = config?.get("runtime.client.enableLocalQueues", false);
9092
- }
9093
- invariant24(!this._config, "config already set", {
9094
- F: __dxlog_file29,
9095
- L: 251,
9358
+ invariant25(!this._config, "config already set", {
9359
+ F: __dxlog_file30,
9360
+ L: 248,
9096
9361
  S: this,
9097
9362
  A: [
9098
9363
  "!this._config",
@@ -9119,9 +9384,9 @@ var ClientServicesHost = class {
9119
9384
  edgeConnection: this._edgeConnection
9120
9385
  }) : new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
9121
9386
  this._signalManager = signalManager;
9122
- invariant24(!this._networkManager, "network manager already set", {
9123
- F: __dxlog_file29,
9124
- L: 282,
9387
+ invariant25(!this._networkManager, "network manager already set", {
9388
+ F: __dxlog_file30,
9389
+ L: 279,
9125
9390
  S: this,
9126
9391
  A: [
9127
9392
  "!this._networkManager",
@@ -9138,8 +9403,8 @@ var ClientServicesHost = class {
9138
9403
  } : void 0
9139
9404
  });
9140
9405
  log25("initialized", void 0, {
9141
- F: __dxlog_file29,
9142
- L: 295,
9406
+ F: __dxlog_file30,
9407
+ L: 292,
9143
9408
  S: this,
9144
9409
  C: (f, a) => f(...a)
9145
9410
  });
@@ -9152,41 +9417,41 @@ var ClientServicesHost = class {
9152
9417
  log25.trace("dxos.client-services.host.open", trace10.begin({
9153
9418
  id: traceId
9154
9419
  }), {
9155
- F: __dxlog_file29,
9156
- L: 306,
9420
+ F: __dxlog_file30,
9421
+ L: 303,
9157
9422
  S: this,
9158
9423
  C: (f, a) => f(...a)
9159
9424
  });
9160
- invariant24(this._config, "config not set", {
9161
- F: __dxlog_file29,
9162
- L: 308,
9425
+ invariant25(this._config, "config not set", {
9426
+ F: __dxlog_file30,
9427
+ L: 305,
9163
9428
  S: this,
9164
9429
  A: [
9165
9430
  "this._config",
9166
9431
  "'config not set'"
9167
9432
  ]
9168
9433
  });
9169
- invariant24(this._storage, "storage not set", {
9170
- F: __dxlog_file29,
9171
- L: 309,
9434
+ invariant25(this._storage, "storage not set", {
9435
+ F: __dxlog_file30,
9436
+ L: 306,
9172
9437
  S: this,
9173
9438
  A: [
9174
9439
  "this._storage",
9175
9440
  "'storage not set'"
9176
9441
  ]
9177
9442
  });
9178
- invariant24(this._signalManager, "signal manager not set", {
9179
- F: __dxlog_file29,
9180
- L: 310,
9443
+ invariant25(this._signalManager, "signal manager not set", {
9444
+ F: __dxlog_file30,
9445
+ L: 307,
9181
9446
  S: this,
9182
9447
  A: [
9183
9448
  "this._signalManager",
9184
9449
  "'signal manager not set'"
9185
9450
  ]
9186
9451
  });
9187
- invariant24(this._networkManager, "network manager not set", {
9188
- F: __dxlog_file29,
9189
- L: 311,
9452
+ invariant25(this._networkManager, "network manager not set", {
9453
+ F: __dxlog_file30,
9454
+ L: 308,
9190
9455
  S: this,
9191
9456
  A: [
9192
9457
  "this._networkManager",
@@ -9197,8 +9462,8 @@ var ClientServicesHost = class {
9197
9462
  log25("opening...", {
9198
9463
  lockKey: this._resourceLock?.lockKey
9199
9464
  }, {
9200
- F: __dxlog_file29,
9201
- L: 314,
9465
+ F: __dxlog_file30,
9466
+ L: 311,
9202
9467
  S: this,
9203
9468
  C: (f, a) => f(...a)
9204
9469
  });
@@ -9259,16 +9524,16 @@ var ClientServicesHost = class {
9259
9524
  log25("opened", {
9260
9525
  deviceKey
9261
9526
  }, {
9262
- F: __dxlog_file29,
9263
- L: 417,
9527
+ F: __dxlog_file30,
9528
+ L: 414,
9264
9529
  S: this,
9265
9530
  C: (f, a) => f(...a)
9266
9531
  });
9267
9532
  log25.trace("dxos.client-services.host.open", trace10.end({
9268
9533
  id: traceId
9269
9534
  }), {
9270
- F: __dxlog_file29,
9271
- L: 418,
9535
+ F: __dxlog_file30,
9536
+ L: 415,
9272
9537
  S: this,
9273
9538
  C: (f, a) => f(...a)
9274
9539
  });
@@ -9281,8 +9546,8 @@ var ClientServicesHost = class {
9281
9546
  log25("closing...", {
9282
9547
  deviceKey
9283
9548
  }, {
9284
- F: __dxlog_file29,
9285
- L: 429,
9549
+ F: __dxlog_file30,
9550
+ L: 426,
9286
9551
  S: this,
9287
9552
  C: (f, a) => f(...a)
9288
9553
  });
@@ -9299,8 +9564,8 @@ var ClientServicesHost = class {
9299
9564
  log25("closed", {
9300
9565
  deviceKey
9301
9566
  }, {
9302
- F: __dxlog_file29,
9303
- L: 438,
9567
+ F: __dxlog_file30,
9568
+ L: 435,
9304
9569
  S: this,
9305
9570
  C: (f, a) => f(...a)
9306
9571
  });
@@ -9310,14 +9575,14 @@ var ClientServicesHost = class {
9310
9575
  log25.trace("dxos.sdk.client-services-host.reset", trace10.begin({
9311
9576
  id: traceId
9312
9577
  }), {
9313
- F: __dxlog_file29,
9314
- L: 443,
9578
+ F: __dxlog_file30,
9579
+ L: 440,
9315
9580
  S: this,
9316
9581
  C: (f, a) => f(...a)
9317
9582
  });
9318
9583
  log25.info("resetting...", void 0, {
9319
- F: __dxlog_file29,
9320
- L: 445,
9584
+ F: __dxlog_file30,
9585
+ L: 442,
9321
9586
  S: this,
9322
9587
  C: (f, a) => f(...a)
9323
9588
  });
@@ -9330,24 +9595,24 @@ var ClientServicesHost = class {
9330
9595
  log25.warn("failed to clear leveldb during reset", {
9331
9596
  err
9332
9597
  }, {
9333
- F: __dxlog_file29,
9334
- L: 455,
9598
+ F: __dxlog_file30,
9599
+ L: 452,
9335
9600
  S: this,
9336
9601
  C: (f, a) => f(...a)
9337
9602
  });
9338
9603
  }
9339
9604
  await this._storage.reset();
9340
9605
  log25.info("reset", void 0, {
9341
- F: __dxlog_file29,
9342
- L: 458,
9606
+ F: __dxlog_file30,
9607
+ L: 455,
9343
9608
  S: this,
9344
9609
  C: (f, a) => f(...a)
9345
9610
  });
9346
9611
  log25.trace("dxos.sdk.client-services-host.reset", trace10.end({
9347
9612
  id: traceId
9348
9613
  }), {
9349
- F: __dxlog_file29,
9350
- L: 459,
9614
+ F: __dxlog_file30,
9615
+ L: 456,
9351
9616
  S: this,
9352
9617
  C: (f, a) => f(...a)
9353
9618
  });
@@ -9418,4 +9683,4 @@ export {
9418
9683
  ServiceRegistry,
9419
9684
  ClientServicesHost
9420
9685
  };
9421
- //# sourceMappingURL=chunk-KBXLEVD5.mjs.map
9686
+ //# sourceMappingURL=chunk-CZN7GX3A.mjs.map