@dxos/echo-pipeline 0.4.6-main.aeca3cc → 0.4.6-main.b69a2b5

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.
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_37RERU2L_exports = {};
30
- __export(chunk_37RERU2L_exports, {
29
+ var chunk_CZ5KWO66_exports = {};
30
+ __export(chunk_CZ5KWO66_exports, {
31
31
  AuthExtension: () => AuthExtension,
32
32
  AuthStatus: () => AuthStatus,
33
33
  AutomergeHost: () => AutomergeHost,
@@ -57,7 +57,7 @@ __export(chunk_37RERU2L_exports, {
57
57
  startAfter: () => startAfter,
58
58
  valueEncoding: () => valueEncoding
59
59
  });
60
- module.exports = __toCommonJS(chunk_37RERU2L_exports);
60
+ module.exports = __toCommonJS(chunk_CZ5KWO66_exports);
61
61
  var import_hypercore = require("@dxos/hypercore");
62
62
  var import_protocols = require("@dxos/protocols");
63
63
  var import_invariant = require("@dxos/invariant");
@@ -2059,7 +2059,8 @@ var ControlPipeline = class {
2059
2059
  get pipeline() {
2060
2060
  return this._pipeline;
2061
2061
  }
2062
- setWriteFeed(feed) {
2062
+ async setWriteFeed(feed) {
2063
+ await this._pipeline.addFeed(feed);
2063
2064
  this._pipeline.setWriteFeed(feed);
2064
2065
  }
2065
2066
  async start() {
@@ -2070,7 +2071,7 @@ var ControlPipeline = class {
2070
2071
  tf: snapshot?.timeframe
2071
2072
  }, {
2072
2073
  F: __dxlog_file10,
2073
- L: 110,
2074
+ L: 111,
2074
2075
  S: this,
2075
2076
  C: (f, a) => f(...a)
2076
2077
  });
@@ -2079,7 +2080,7 @@ var ControlPipeline = class {
2079
2080
  }
2080
2081
  (0, import_log10.log)("starting...", void 0, {
2081
2082
  F: __dxlog_file10,
2082
- L: 115,
2083
+ L: 116,
2083
2084
  S: this,
2084
2085
  C: (f, a) => f(...a)
2085
2086
  });
@@ -2089,7 +2090,7 @@ var ControlPipeline = class {
2089
2090
  await this._pipeline.start();
2090
2091
  (0, import_log10.log)("started", void 0, {
2091
2092
  F: __dxlog_file10,
2092
- L: 121,
2093
+ L: 122,
2093
2094
  S: this,
2094
2095
  C: (f, a) => f(...a)
2095
2096
  });
@@ -2106,7 +2107,7 @@ var ControlPipeline = class {
2106
2107
  message
2107
2108
  }, {
2108
2109
  F: __dxlog_file10,
2109
- L: 134,
2110
+ L: 135,
2110
2111
  S: this,
2111
2112
  C: (f, a) => f(...a)
2112
2113
  });
@@ -2128,7 +2129,7 @@ var ControlPipeline = class {
2128
2129
  snapshot
2129
2130
  }, {
2130
2131
  F: __dxlog_file10,
2131
- L: 150,
2132
+ L: 151,
2132
2133
  S: this,
2133
2134
  C: (f, a) => f(...a)
2134
2135
  });
@@ -2143,7 +2144,7 @@ var ControlPipeline = class {
2143
2144
  } catch (err) {
2144
2145
  import_log10.log.catch(err, void 0, {
2145
2146
  F: __dxlog_file10,
2146
- L: 163,
2147
+ L: 164,
2147
2148
  S: this,
2148
2149
  C: (f, a) => f(...a)
2149
2150
  });
@@ -2157,7 +2158,7 @@ var ControlPipeline = class {
2157
2158
  seq: msg.seq
2158
2159
  }, {
2159
2160
  F: __dxlog_file10,
2160
- L: 173,
2161
+ L: 174,
2161
2162
  S: this,
2162
2163
  C: (f, a) => f(...a)
2163
2164
  });
@@ -2172,7 +2173,7 @@ var ControlPipeline = class {
2172
2173
  msg
2173
2174
  }, {
2174
2175
  F: __dxlog_file10,
2175
- L: 182,
2176
+ L: 183,
2176
2177
  S: this,
2177
2178
  C: (f, a) => f(...a)
2178
2179
  });
@@ -2191,7 +2192,7 @@ var ControlPipeline = class {
2191
2192
  async stop() {
2192
2193
  (0, import_log10.log)("stopping...", void 0, {
2193
2194
  F: __dxlog_file10,
2194
- L: 202,
2195
+ L: 203,
2195
2196
  S: this,
2196
2197
  C: (f, a) => f(...a)
2197
2198
  });
@@ -2200,7 +2201,7 @@ var ControlPipeline = class {
2200
2201
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
2201
2202
  (0, import_log10.log)("stopped", void 0, {
2202
2203
  F: __dxlog_file10,
2203
- L: 206,
2204
+ L: 207,
2204
2205
  S: this,
2205
2206
  C: (f, a) => f(...a)
2206
2207
  });
@@ -2213,7 +2214,7 @@ var ControlPipeline = class {
2213
2214
  } catch (err) {
2214
2215
  (0, import_log10.log)(err, void 0, {
2215
2216
  F: __dxlog_file10,
2216
- L: 215,
2217
+ L: 216,
2217
2218
  S: this,
2218
2219
  C: (f, a) => f(...a)
2219
2220
  });
@@ -2366,7 +2367,7 @@ var Space = class {
2366
2367
  get snapshotManager() {
2367
2368
  return this._snapshotManager;
2368
2369
  }
2369
- setControlFeed(feed) {
2370
+ async setControlFeed(feed) {
2370
2371
  (0, import_invariant9.invariant)(!this._controlFeed, "Control feed already set.", {
2371
2372
  F: __dxlog_file11,
2372
2373
  L: 191,
@@ -2377,10 +2378,10 @@ var Space = class {
2377
2378
  ]
2378
2379
  });
2379
2380
  this._controlFeed = feed;
2380
- this._controlPipeline.setWriteFeed(feed);
2381
+ await this._controlPipeline.setWriteFeed(feed);
2381
2382
  return this;
2382
2383
  }
2383
- setDataFeed(feed) {
2384
+ async setDataFeed(feed) {
2384
2385
  (0, import_invariant9.invariant)(!this._dataFeed, "Data feed already set.", {
2385
2386
  F: __dxlog_file11,
2386
2387
  L: 198,
@@ -2391,6 +2392,7 @@ var Space = class {
2391
2392
  ]
2392
2393
  });
2393
2394
  this._dataFeed = feed;
2395
+ await this._dataPipeline.pipeline?.addFeed(feed);
2394
2396
  this._dataPipeline.pipeline?.setWriteFeed(feed);
2395
2397
  return this;
2396
2398
  }
@@ -2409,7 +2411,7 @@ var Space = class {
2409
2411
  async open(ctx) {
2410
2412
  (0, import_log9.log)("opening...", void 0, {
2411
2413
  F: __dxlog_file11,
2412
- L: 220,
2414
+ L: 221,
2413
2415
  S: this,
2414
2416
  C: (f, a) => f(...a)
2415
2417
  });
@@ -2422,7 +2424,7 @@ var Space = class {
2422
2424
  this._isOpen = true;
2423
2425
  (0, import_log9.log)("opened", void 0, {
2424
2426
  F: __dxlog_file11,
2425
- L: 231,
2427
+ L: 232,
2426
2428
  S: this,
2427
2429
  C: (f, a) => f(...a)
2428
2430
  });
@@ -2432,7 +2434,7 @@ var Space = class {
2432
2434
  key: this._key
2433
2435
  }, {
2434
2436
  F: __dxlog_file11,
2435
- L: 236,
2437
+ L: 237,
2436
2438
  S: this,
2437
2439
  C: (f, a) => f(...a)
2438
2440
  });
@@ -2446,7 +2448,7 @@ var Space = class {
2446
2448
  this._isOpen = false;
2447
2449
  (0, import_log9.log)("closed", void 0, {
2448
2450
  F: __dxlog_file11,
2449
- L: 249,
2451
+ L: 250,
2450
2452
  S: this,
2451
2453
  C: (f, a) => f(...a)
2452
2454
  });
@@ -2454,13 +2456,13 @@ var Space = class {
2454
2456
  async initializeDataPipeline() {
2455
2457
  (0, import_log9.log)("initializeDataPipeline", void 0, {
2456
2458
  F: __dxlog_file11,
2457
- L: 254,
2459
+ L: 255,
2458
2460
  S: this,
2459
2461
  C: (f, a) => f(...a)
2460
2462
  });
2461
2463
  (0, import_invariant9.invariant)(this._isOpen, "Space must be open to initialize data pipeline.", {
2462
2464
  F: __dxlog_file11,
2463
- L: 255,
2465
+ L: 256,
2464
2466
  S: this,
2465
2467
  A: [
2466
2468
  "this._isOpen",
@@ -3102,9 +3104,9 @@ var AutomergeHost = class {
3102
3104
  this._meshNetwork = new MeshNetworkAdapter();
3103
3105
  this._clientNetwork = new LocalHostNetworkAdapter();
3104
3106
  this._storage = storageDirectory.type === import_random_access_storage.StorageType.IDB ? new import_automerge_repo_storage_indexeddb.IndexedDBStorageAdapter(storageDirectory.path, "data") : new AutomergeStorageAdapter(storageDirectory);
3105
- const localPeerId = `host-${import_keys8.PublicKey.random().toHex()}`;
3107
+ this._peerId = `host-${import_keys8.PublicKey.random().toHex()}`;
3106
3108
  this._repo = new import_automerge_repo4.Repo({
3107
- peerId: localPeerId,
3109
+ peerId: this._peerId,
3108
3110
  network: [
3109
3111
  this._clientNetwork,
3110
3112
  this._meshNetwork
@@ -3128,26 +3130,27 @@ var AutomergeHost = class {
3128
3130
  isRequested
3129
3131
  }, {
3130
3132
  F: __dxlog_file16,
3131
- L: 66,
3133
+ L: 69,
3132
3134
  S: this,
3133
3135
  C: (f, a) => f(...a)
3134
3136
  });
3135
3137
  return isRequested;
3136
3138
  }
3137
3139
  try {
3138
- if (!doc.experimental_spaceKey) {
3140
+ const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;
3141
+ if (!rawSpaceKey) {
3139
3142
  (0, import_log15.log)("space key not found for share policy check", {
3140
3143
  peerId,
3141
3144
  documentId
3142
3145
  }, {
3143
3146
  F: __dxlog_file16,
3144
- L: 72,
3147
+ L: 77,
3145
3148
  S: this,
3146
3149
  C: (f, a) => f(...a)
3147
3150
  });
3148
3151
  return false;
3149
3152
  }
3150
- const spaceKey = import_keys8.PublicKey.from(doc.experimental_spaceKey);
3153
+ const spaceKey = import_keys8.PublicKey.from(rawSpaceKey);
3151
3154
  const authorizedDevices = this._authorizedDevices.get(spaceKey);
3152
3155
  const deviceKeyHex = this.repo.peerMetadataByPeerId[peerId]?.dxos_deviceKey;
3153
3156
  if (!deviceKeyHex) {
@@ -3156,7 +3159,7 @@ var AutomergeHost = class {
3156
3159
  documentId
3157
3160
  }, {
3158
3161
  F: __dxlog_file16,
3159
- L: 82,
3162
+ L: 87,
3160
3163
  S: this,
3161
3164
  C: (f, a) => f(...a)
3162
3165
  });
@@ -3165,7 +3168,7 @@ var AutomergeHost = class {
3165
3168
  const deviceKey = import_keys8.PublicKey.from(deviceKeyHex);
3166
3169
  const isAuthorized = authorizedDevices?.has(deviceKey) ?? false;
3167
3170
  (0, import_log15.log)("share policy check", {
3168
- localPeer: localPeerId,
3171
+ localPeer: this._peerId,
3169
3172
  remotePeer: peerId,
3170
3173
  documentId,
3171
3174
  deviceKey,
@@ -3173,7 +3176,7 @@ var AutomergeHost = class {
3173
3176
  isAuthorized
3174
3177
  }, {
3175
3178
  F: __dxlog_file16,
3176
- L: 88,
3179
+ L: 93,
3177
3180
  S: this,
3178
3181
  C: (f, a) => f(...a)
3179
3182
  });
@@ -3181,7 +3184,7 @@ var AutomergeHost = class {
3181
3184
  } catch (err) {
3182
3185
  import_log15.log.catch(err, void 0, {
3183
3186
  F: __dxlog_file16,
3184
- L: 98,
3187
+ L: 103,
3185
3188
  S: this,
3186
3189
  C: (f, a) => f(...a)
3187
3190
  });
@@ -3199,7 +3202,22 @@ var AutomergeHost = class {
3199
3202
  return (0, import_util11.mapValues)(this._repo.handles, (handle) => ({
3200
3203
  state: handle.state,
3201
3204
  hasDoc: !!handle.docSync(),
3202
- heads: handle.docSync() ? import_automerge.next.getHeads(handle.docSync()) : null
3205
+ heads: handle.docSync() ? import_automerge.next.getHeads(handle.docSync()) : null,
3206
+ data: handle.docSync()?.doc && (0, import_util11.mapValues)(handle.docSync()?.doc, (value, key) => {
3207
+ try {
3208
+ switch (key) {
3209
+ case "access":
3210
+ case "links":
3211
+ return value;
3212
+ case "objects":
3213
+ return Object.keys(value);
3214
+ default:
3215
+ return `${value}`;
3216
+ }
3217
+ } catch (err) {
3218
+ return `${err}`;
3219
+ }
3220
+ })
3203
3221
  }));
3204
3222
  }
3205
3223
  _automergePeers() {
@@ -3233,13 +3251,16 @@ var AutomergeHost = class {
3233
3251
  deviceKey
3234
3252
  }, {
3235
3253
  F: __dxlog_file16,
3236
- L: 155,
3254
+ L: 177,
3237
3255
  S: this,
3238
3256
  C: (f, a) => f(...a)
3239
3257
  });
3240
3258
  (0, import_util11.defaultMap)(this._authorizedDevices, spaceKey, () => new import_util11.ComplexSet(import_keys8.PublicKey.hash)).add(deviceKey);
3241
3259
  }
3242
3260
  };
3261
+ _ts_decorate9([
3262
+ import_tracing5.trace.info()
3263
+ ], AutomergeHost.prototype, "_peerId", void 0);
3243
3264
  _ts_decorate9([
3244
3265
  import_tracing5.trace.info({
3245
3266
  depth: null
@@ -3284,4 +3305,4 @@ AutomergeHost = _ts_decorate9([
3284
3305
  startAfter,
3285
3306
  valueEncoding
3286
3307
  });
3287
- //# sourceMappingURL=chunk-37RERU2L.cjs.map
3308
+ //# sourceMappingURL=chunk-CZ5KWO66.cjs.map