@dxos/echo-pipeline 0.4.8 → 0.4.9-main.1057b49

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 (55) hide show
  1. package/dist/lib/browser/{chunk-WAN2XUWE.mjs → chunk-RTEEJ723.mjs} +273 -1131
  2. package/dist/lib/browser/chunk-RTEEJ723.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +2 -10
  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 +4 -60
  7. package/dist/lib/browser/testing/index.mjs.map +4 -4
  8. package/dist/lib/node/{chunk-U6J2HC4T.cjs → chunk-7VZVCCNF.cjs} +310 -1166
  9. package/dist/lib/node/chunk-7VZVCCNF.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +22 -30
  11. package/dist/lib/node/index.cjs.map +3 -3
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +13 -68
  14. package/dist/lib/node/testing/index.cjs.map +4 -4
  15. package/dist/types/src/db-host/data-service.d.ts +3 -13
  16. package/dist/types/src/db-host/data-service.d.ts.map +1 -1
  17. package/dist/types/src/db-host/index.d.ts +0 -2
  18. package/dist/types/src/db-host/index.d.ts.map +1 -1
  19. package/dist/types/src/space/index.d.ts +0 -1
  20. package/dist/types/src/space/index.d.ts.map +1 -1
  21. package/dist/types/src/space/space-manager.d.ts +1 -4
  22. package/dist/types/src/space/space-manager.d.ts.map +1 -1
  23. package/dist/types/src/space/space.d.ts +1 -7
  24. package/dist/types/src/space/space.d.ts.map +1 -1
  25. package/dist/types/src/testing/index.d.ts +0 -1
  26. package/dist/types/src/testing/index.d.ts.map +1 -1
  27. package/dist/types/src/testing/test-agent-builder.d.ts +1 -3
  28. package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
  29. package/package.json +30 -33
  30. package/src/automerge/automerge-host.ts +1 -1
  31. package/src/db-host/data-service.ts +10 -56
  32. package/src/db-host/index.ts +0 -2
  33. package/src/space/index.ts +0 -1
  34. package/src/space/space-manager.ts +1 -13
  35. package/src/space/space.test.ts +2 -112
  36. package/src/space/space.ts +2 -60
  37. package/src/testing/index.ts +0 -1
  38. package/src/testing/test-agent-builder.ts +3 -8
  39. package/dist/lib/browser/chunk-WAN2XUWE.mjs.map +0 -7
  40. package/dist/lib/node/chunk-U6J2HC4T.cjs.map +0 -7
  41. package/dist/types/src/db-host/data-service-host.d.ts +0 -38
  42. package/dist/types/src/db-host/data-service-host.d.ts.map +0 -1
  43. package/dist/types/src/db-host/database-host.d.ts +0 -27
  44. package/dist/types/src/db-host/database-host.d.ts.map +0 -1
  45. package/dist/types/src/space/data-pipeline.d.ts +0 -79
  46. package/dist/types/src/space/data-pipeline.d.ts.map +0 -1
  47. package/dist/types/src/space/data-pipeline.test.d.ts +0 -1
  48. package/dist/types/src/space/data-pipeline.test.d.ts.map +0 -1
  49. package/dist/types/src/testing/util.d.ts +0 -10
  50. package/dist/types/src/testing/util.d.ts.map +0 -1
  51. package/src/db-host/data-service-host.ts +0 -233
  52. package/src/db-host/database-host.ts +0 -63
  53. package/src/space/data-pipeline.test.ts +0 -3
  54. package/src/space/data-pipeline.ts +0 -425
  55. package/src/testing/util.ts +0 -61
@@ -26,15 +26,11 @@ 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_U6J2HC4T_exports = {};
30
- __export(chunk_U6J2HC4T_exports, {
29
+ var chunk_7VZVCCNF_exports = {};
30
+ __export(chunk_7VZVCCNF_exports, {
31
31
  AuthExtension: () => AuthExtension,
32
32
  AuthStatus: () => AuthStatus,
33
- DataPipeline: () => DataPipeline,
34
- DataServiceHost: () => DataServiceHost,
35
33
  DataServiceImpl: () => DataServiceImpl,
36
- DataServiceSubscriptions: () => DataServiceSubscriptions,
37
- DatabaseHost: () => DatabaseHost,
38
34
  MOCK_AUTH_PROVIDER: () => MOCK_AUTH_PROVIDER,
39
35
  MOCK_AUTH_VERIFIER: () => MOCK_AUTH_VERIFIER,
40
36
  MetadataStore: () => MetadataStore,
@@ -53,101 +49,77 @@ __export(chunk_U6J2HC4T_exports, {
53
49
  startAfter: () => startAfter,
54
50
  valueEncoding: () => valueEncoding
55
51
  });
56
- module.exports = __toCommonJS(chunk_U6J2HC4T_exports);
52
+ module.exports = __toCommonJS(chunk_7VZVCCNF_exports);
57
53
  var import_hypercore = require("@dxos/hypercore");
58
54
  var import_protocols = require("@dxos/protocols");
59
55
  var import_invariant = require("@dxos/invariant");
60
- var import_async = require("@dxos/async");
61
- var import_codec_protobuf = require("@dxos/codec-protobuf");
62
56
  var import_context = require("@dxos/context");
63
- var import_echo_db = require("@dxos/echo-db");
64
- var import_invariant2 = require("@dxos/invariant");
65
- var import_log = require("@dxos/log");
66
- var import_service = require("@dxos/protocols/proto/dxos/echo/service");
67
- var import_util = require("@dxos/util");
68
- var import_echo_db2 = require("@dxos/echo-db");
69
- var import_context2 = require("@dxos/context");
70
57
  var import_keys = require("@dxos/keys");
71
58
  var import_protocols2 = require("@dxos/protocols");
72
59
  var import_blob = require("@dxos/protocols/proto/dxos/echo/blob");
73
60
  var import_crypto = require("@dxos/crypto");
74
61
  var import_protocols3 = require("@dxos/protocols");
75
- var import_debug = require("@dxos/debug");
76
- var import_invariant3 = require("@dxos/invariant");
77
- var import_keys2 = require("@dxos/keys");
78
- var import_log2 = require("@dxos/log");
79
- var import_util2 = require("@dxos/util");
80
62
  var import_crc_32 = __toESM(require("crc-32"));
81
- var import_async2 = require("@dxos/async");
82
- var import_context3 = require("@dxos/context");
83
- var import_invariant4 = require("@dxos/invariant");
84
- var import_keys3 = require("@dxos/keys");
85
- var import_log3 = require("@dxos/log");
63
+ var import_async = require("@dxos/async");
64
+ var import_context2 = require("@dxos/context");
65
+ var import_invariant2 = require("@dxos/invariant");
66
+ var import_keys2 = require("@dxos/keys");
67
+ var import_log = require("@dxos/log");
86
68
  var import_protocols4 = require("@dxos/protocols");
87
69
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
88
- var import_util3 = require("@dxos/util");
70
+ var import_util = require("@dxos/util");
71
+ var import_async2 = require("@dxos/async");
72
+ var import_debug = require("@dxos/debug");
73
+ var import_log2 = require("@dxos/log");
74
+ var import_timeframe = require("@dxos/timeframe");
89
75
  var import_async3 = require("@dxos/async");
76
+ var import_context3 = require("@dxos/context");
90
77
  var import_debug2 = require("@dxos/debug");
78
+ var import_feed_store = require("@dxos/feed-store");
79
+ var import_invariant3 = require("@dxos/invariant");
80
+ var import_keys3 = require("@dxos/keys");
81
+ var import_log3 = require("@dxos/log");
82
+ var import_timeframe2 = require("@dxos/timeframe");
83
+ var import_util2 = require("@dxos/util");
84
+ var import_invariant4 = require("@dxos/invariant");
91
85
  var import_log4 = require("@dxos/log");
92
- var import_timeframe = require("@dxos/timeframe");
93
86
  var import_async4 = require("@dxos/async");
94
87
  var import_context4 = require("@dxos/context");
95
- var import_debug3 = require("@dxos/debug");
96
- var import_feed_store = require("@dxos/feed-store");
88
+ var import_crypto2 = require("@dxos/crypto");
97
89
  var import_invariant5 = require("@dxos/invariant");
98
- var import_keys4 = require("@dxos/keys");
99
90
  var import_log5 = require("@dxos/log");
100
- var import_timeframe2 = require("@dxos/timeframe");
101
- var import_util4 = require("@dxos/util");
91
+ var import_protocols5 = require("@dxos/protocols");
92
+ var import_teleport = require("@dxos/teleport");
93
+ var import_async5 = require("@dxos/async");
102
94
  var import_invariant6 = require("@dxos/invariant");
103
95
  var import_log6 = require("@dxos/log");
104
- var import_async5 = require("@dxos/async");
96
+ var import_credentials = require("@dxos/protocols/proto/dxos/halo/credentials");
97
+ var import_tracing = require("@dxos/tracing");
98
+ var import_util3 = require("@dxos/util");
99
+ var import_async6 = require("@dxos/async");
105
100
  var import_context5 = require("@dxos/context");
106
- var import_crypto2 = require("@dxos/crypto");
107
- var import_invariant7 = require("@dxos/invariant");
101
+ var import_credentials2 = require("@dxos/credentials");
102
+ var import_keys4 = require("@dxos/keys");
108
103
  var import_log7 = require("@dxos/log");
109
- var import_protocols5 = require("@dxos/protocols");
110
- var import_teleport = require("@dxos/teleport");
111
- var import_async6 = require("@dxos/async");
112
- var import_context6 = require("@dxos/context");
113
- var import_credentials = require("@dxos/credentials");
114
- var import_echo_db3 = require("@dxos/echo-db");
115
- var import_invariant8 = require("@dxos/invariant");
116
- var import_log8 = require("@dxos/log");
117
- var import_protocols6 = require("@dxos/protocols");
104
+ var import_credentials3 = require("@dxos/protocols/proto/dxos/halo/credentials");
118
105
  var import_timeframe3 = require("@dxos/timeframe");
119
- var import_tracing = require("@dxos/tracing");
120
- var import_util5 = require("@dxos/util");
121
- var import_async7 = require("@dxos/async");
122
- var import_invariant9 = require("@dxos/invariant");
123
- var import_log9 = require("@dxos/log");
124
- var import_credentials2 = require("@dxos/protocols/proto/dxos/halo/credentials");
125
106
  var import_tracing2 = require("@dxos/tracing");
126
- var import_util6 = require("@dxos/util");
127
- var import_async8 = require("@dxos/async");
128
- var import_context7 = require("@dxos/context");
129
- var import_credentials3 = require("@dxos/credentials");
130
- var import_keys5 = require("@dxos/keys");
131
- var import_log10 = require("@dxos/log");
132
- var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
133
- var import_timeframe4 = require("@dxos/timeframe");
134
- var import_tracing3 = require("@dxos/tracing");
135
- var import_util7 = require("@dxos/util");
107
+ var import_util4 = require("@dxos/util");
136
108
  var import_crypto3 = require("@dxos/crypto");
137
- var import_keys6 = require("@dxos/keys");
138
- var import_log11 = require("@dxos/log");
109
+ var import_keys5 = require("@dxos/keys");
110
+ var import_log8 = require("@dxos/log");
139
111
  var import_network_manager = require("@dxos/network-manager");
140
112
  var import_teleport2 = require("@dxos/teleport");
141
113
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
142
114
  var import_teleport_extension_replicator = require("@dxos/teleport-extension-replicator");
143
- var import_tracing4 = require("@dxos/tracing");
144
- var import_util8 = require("@dxos/util");
145
- var import_async9 = require("@dxos/async");
146
- var import_debug4 = require("@dxos/debug");
147
- var import_keys7 = require("@dxos/keys");
148
- var import_log12 = require("@dxos/log");
149
- var import_protocols7 = require("@dxos/protocols");
150
- var import_util9 = require("@dxos/util");
115
+ var import_tracing3 = require("@dxos/tracing");
116
+ var import_util5 = require("@dxos/util");
117
+ var import_async7 = require("@dxos/async");
118
+ var import_debug3 = require("@dxos/debug");
119
+ var import_keys6 = require("@dxos/keys");
120
+ var import_log9 = require("@dxos/log");
121
+ var import_protocols6 = require("@dxos/protocols");
122
+ var import_util6 = require("@dxos/util");
151
123
  var codec = import_protocols.schema.getCodecForType("dxos.echo.feed.FeedMessage");
152
124
  var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
153
125
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
@@ -174,244 +146,6 @@ var createMappedFeedWriter = (mapper, writer) => {
174
146
  write: async (data, options) => await writer.write(await mapper(data), options)
175
147
  };
176
148
  };
177
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
178
- var MUTATION_LIMIT_PER_OBJECT = 10;
179
- var DataServiceHost = class {
180
- constructor(_itemManager, _itemDemuxer, _flush, _writeStream, _opts = {}) {
181
- this._itemManager = _itemManager;
182
- this._itemDemuxer = _itemDemuxer;
183
- this._flush = _flush;
184
- this._writeStream = _writeStream;
185
- this._opts = _opts;
186
- this._ctx = new import_context.Context();
187
- this._clientTagMap = new import_util.ComplexMap(([feedKey, seq]) => `${feedKey.toHex()}:${seq}`);
188
- }
189
- async open() {
190
- }
191
- async close() {
192
- await this._ctx.dispose();
193
- }
194
- get _deferEvents() {
195
- return this._opts.deferEvents ?? true;
196
- }
197
- /**
198
- * Real-time subscription to data objects in a space.
199
- */
200
- subscribe() {
201
- return new import_codec_protobuf.Stream(({ next, close, ctx }) => {
202
- ctx.onDispose(this._ctx.onDispose(close));
203
- const objects = Array.from(this._itemManager.entities.values()).map((entity) => entity.createSnapshot());
204
- next({
205
- batch: {
206
- objects
207
- }
208
- });
209
- const updateScheduler = new import_async.UpdateScheduler(ctx, async () => {
210
- flushPendingUpdate();
211
- }, {
212
- maxFrequency: 10
213
- });
214
- const pendingUpdates = [];
215
- const mutationsPerObject = /* @__PURE__ */ new Map();
216
- const clearPendingUpdates = () => {
217
- pendingUpdates.length = 0;
218
- mutationsPerObject.clear();
219
- };
220
- const flushPendingUpdate = () => {
221
- const stagedEvents = [];
222
- const objectsWithSnapshots = /* @__PURE__ */ new Set();
223
- for (const [id, count] of mutationsPerObject) {
224
- if (count >= MUTATION_LIMIT_PER_OBJECT) {
225
- objectsWithSnapshots.add(id);
226
- const entity = this._itemManager.entities.get(id);
227
- if (entity) {
228
- stagedEvents.push(entity.createSnapshot());
229
- }
230
- }
231
- }
232
- for (const obj of pendingUpdates) {
233
- if (!objectsWithSnapshots.has(obj.objectId)) {
234
- stagedEvents.push(obj);
235
- }
236
- }
237
- next({
238
- batch: {
239
- objects: stagedEvents
240
- }
241
- });
242
- clearPendingUpdates();
243
- };
244
- this._itemDemuxer.snapshot.on(ctx, (snapshot) => {
245
- clearPendingUpdates();
246
- next({
247
- action: import_service.EchoEvent.DatabaseAction.RESET,
248
- batch: {
249
- objects: snapshot.items
250
- }
251
- });
252
- });
253
- this._itemDemuxer.mutation.on(ctx, (message) => {
254
- const { batch, meta } = message;
255
- (0, import_invariant2.invariant)(!meta.clientTag, "Unexpected client tag in mutation message", {
256
- F: __dxlog_file2,
257
- L: 138,
258
- S: this,
259
- A: [
260
- "!(meta as any).clientTag",
261
- "'Unexpected client tag in mutation message'"
262
- ]
263
- });
264
- (0, import_log.log)("message", {
265
- batch: batch.objects?.length,
266
- meta
267
- }, {
268
- F: __dxlog_file2,
269
- L: 139,
270
- S: this,
271
- C: (f, a) => f(...a)
272
- });
273
- const clientTag = this._clientTagMap.get([
274
- message.meta.feedKey,
275
- message.meta.seq
276
- ]);
277
- batch.objects?.forEach((object) => {
278
- (0, import_echo_db.setMetadataOnObject)(object, {
279
- ...meta
280
- });
281
- });
282
- if (clientTag) {
283
- flushPendingUpdate();
284
- (0, import_echo_db.tagMutationsInBatch)(batch, clientTag, 0);
285
- next({
286
- clientTag,
287
- feedKey: message.meta.feedKey,
288
- seq: message.meta.seq,
289
- batch
290
- });
291
- } else {
292
- for (const obj of batch.objects ?? []) {
293
- const newCount = (mutationsPerObject.get(obj.objectId) ?? 0) + 1;
294
- mutationsPerObject.set(obj.objectId, newCount);
295
- }
296
- for (const obj of batch.objects ?? []) {
297
- if ((mutationsPerObject.get(obj.objectId) ?? 0) < MUTATION_LIMIT_PER_OBJECT) {
298
- pendingUpdates.push(obj);
299
- }
300
- }
301
- if (this._deferEvents) {
302
- updateScheduler.trigger();
303
- } else {
304
- flushPendingUpdate();
305
- }
306
- }
307
- });
308
- });
309
- }
310
- async write(request) {
311
- (0, import_invariant2.invariant)(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
312
- F: __dxlog_file2,
313
- L: 184,
314
- S: this,
315
- A: [
316
- "!this._ctx.disposed",
317
- "'Cannot write to closed DataServiceHost'"
318
- ]
319
- });
320
- (0, import_invariant2.invariant)(this._writeStream, "Cannot write mutations in readonly mode", {
321
- F: __dxlog_file2,
322
- L: 185,
323
- S: this,
324
- A: [
325
- "this._writeStream",
326
- "'Cannot write mutations in readonly mode'"
327
- ]
328
- });
329
- (0, import_log.log)("write", {
330
- clientTag: request.clientTag,
331
- objectCount: request.batch.objects?.length ?? 0
332
- }, {
333
- F: __dxlog_file2,
334
- L: 187,
335
- S: this,
336
- C: (f, a) => f(...a)
337
- });
338
- const message = createDataMessage(request.batch);
339
- const receipt = await this._writeStream.write(message, {
340
- afterWrite: async (receipt2) => {
341
- if (request.clientTag) {
342
- (0, import_log.log)("tag", {
343
- clientTag: request.clientTag,
344
- feedKey: receipt2.feedKey,
345
- seq: receipt2.seq
346
- }, {
347
- F: __dxlog_file2,
348
- L: 196,
349
- S: this,
350
- C: (f, a) => f(...a)
351
- });
352
- this._clientTagMap.set([
353
- receipt2.feedKey,
354
- receipt2.seq
355
- ], request.clientTag);
356
- }
357
- }
358
- });
359
- return receipt;
360
- }
361
- async flush() {
362
- await this._flush();
363
- }
364
- getHostInfo() {
365
- throw new Error("Method not implemented.");
366
- }
367
- syncRepo(request) {
368
- throw new Error("Method not implemented.");
369
- }
370
- sendSyncMessage(request) {
371
- throw new Error("Method not implemented.");
372
- }
373
- };
374
- var createDataMessage = (batch) => ({
375
- batch: {
376
- objects: batch.objects?.map((object) => ({
377
- ...object,
378
- mutations: object.mutations?.map((mutation) => ({
379
- ...mutation,
380
- meta: void 0
381
- })),
382
- meta: void 0
383
- }))
384
- }
385
- });
386
- var DatabaseHost = class {
387
- constructor(_outboundStream, _flush) {
388
- this._outboundStream = _outboundStream;
389
- this._flush = _flush;
390
- }
391
- get isReadOnly() {
392
- return !!this._outboundStream;
393
- }
394
- get echoProcessor() {
395
- return this._echoProcessor;
396
- }
397
- async open(itemManager, modelFactory) {
398
- this._itemManager = itemManager;
399
- this._itemManager._debugLabel = "host";
400
- this._itemDemuxer = new import_echo_db2.ItemDemuxer(itemManager, modelFactory);
401
- this._echoProcessor = this._itemDemuxer.open();
402
- }
403
- async close() {
404
- }
405
- getWriteStream() {
406
- return this._outboundStream;
407
- }
408
- createSnapshot() {
409
- return this._itemDemuxer.createSnapshot();
410
- }
411
- createDataServiceHost(opts = {}) {
412
- return new DataServiceHost(this._itemManager, this._itemDemuxer, this._flush, this._outboundStream ?? void 0, opts);
413
- }
414
- };
415
149
  var SpaceSnapshot = import_protocols2.schema.getCodecForType("dxos.echo.snapshot.SpaceSnapshot");
416
150
  var SnapshotManager = class {
417
151
  constructor(_snapshotStore, _blobStore, _blobSync) {
@@ -429,7 +163,7 @@ var SnapshotManager = class {
429
163
  if (blobMeta && blobMeta.state === import_blob.BlobMeta.State.FULLY_PRESENT) {
430
164
  return this._getBlob(blobId);
431
165
  }
432
- const fallbackStore = await (0, import_context2.cancelWithContext)(ctx, this._snapshotStore.loadSnapshot(id));
166
+ const fallbackStore = await (0, import_context.cancelWithContext)(ctx, this._snapshotStore.loadSnapshot(id));
433
167
  if (fallbackStore) {
434
168
  return fallbackStore;
435
169
  }
@@ -483,104 +217,17 @@ var SnapshotStore = class {
483
217
  }));
484
218
  }
485
219
  };
486
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
487
- var DataServiceSubscriptions = class {
488
- constructor() {
489
- this._spaces = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
490
- }
491
- clear() {
492
- this._spaces.clear();
493
- }
494
- async registerSpace(spaceKey, host) {
495
- (0, import_log2.log)("Registering space", {
496
- spaceKey
497
- }, {
498
- F: __dxlog_file3,
499
- L: 35,
500
- S: this,
501
- C: (f, a) => f(...a)
502
- });
503
- (0, import_invariant3.invariant)(!this._spaces.has(spaceKey), void 0, {
504
- F: __dxlog_file3,
505
- L: 36,
506
- S: this,
507
- A: [
508
- "!this._spaces.has(spaceKey)",
509
- ""
510
- ]
511
- });
512
- await host.open();
513
- this._spaces.set(spaceKey, host);
514
- }
515
- async unregisterSpace(spaceKey) {
516
- (0, import_log2.log)("Unregistering space", {
517
- spaceKey
518
- }, {
519
- F: __dxlog_file3,
520
- L: 42,
521
- S: this,
522
- C: (f, a) => f(...a)
523
- });
524
- const host = this._spaces.get(spaceKey);
525
- await host?.close();
526
- this._spaces.delete(spaceKey);
527
- }
528
- getDataService(spaceKey) {
529
- return this._spaces.get(spaceKey);
530
- }
531
- };
532
220
  var DataServiceImpl = class {
533
- constructor(_subscriptions, _automergeHost) {
534
- this._subscriptions = _subscriptions;
221
+ constructor(_automergeHost) {
535
222
  this._automergeHost = _automergeHost;
536
223
  }
537
224
  subscribe(request) {
538
- (0, import_invariant3.invariant)(request.spaceKey, void 0, {
539
- F: __dxlog_file3,
540
- L: 64,
541
- S: this,
542
- A: [
543
- "request.spaceKey",
544
- ""
545
- ]
546
- });
547
- const host = this._subscriptions.getDataService(request.spaceKey) ?? (0, import_debug.raise)(new Error(`space not found: ${request.spaceKey}`));
548
- return host.subscribe();
225
+ throw new Error("Deprecated.");
549
226
  }
550
227
  write(request) {
551
- (0, import_invariant3.invariant)(request.spaceKey, void 0, {
552
- F: __dxlog_file3,
553
- L: 71,
554
- S: this,
555
- A: [
556
- "request.spaceKey",
557
- ""
558
- ]
559
- });
560
- (0, import_invariant3.invariant)(request.batch, void 0, {
561
- F: __dxlog_file3,
562
- L: 72,
563
- S: this,
564
- A: [
565
- "request.batch",
566
- ""
567
- ]
568
- });
569
- const host = this._subscriptions.getDataService(request.spaceKey) ?? (0, import_debug.raise)(new Error(`space not found: ${request.spaceKey}`));
570
- return host.write(request);
228
+ throw new Error("Deprecated.");
571
229
  }
572
- flush(request) {
573
- (0, import_invariant3.invariant)(request.spaceKey, void 0, {
574
- F: __dxlog_file3,
575
- L: 79,
576
- S: this,
577
- A: [
578
- "request.spaceKey",
579
- ""
580
- ]
581
- });
582
- const host = this._subscriptions.getDataService(request.spaceKey) ?? (0, import_debug.raise)(new Error(`space not found: ${request.spaceKey}`));
583
- return host.flush();
230
+ async flush(request) {
584
231
  }
585
232
  // Automerge specific.
586
233
  async getHostInfo(request) {
@@ -603,7 +250,7 @@ function _ts_decorate(decorators, target, key, desc) {
603
250
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
604
251
  return c > 3 && r && Object.defineProperty(target, key, r), r;
605
252
  }
606
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
253
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
607
254
  var EXPIRED_INVITATION_CLEANUP_INTERVAL = 60 * 60 * 1e3;
608
255
  var emptyEchoMetadata = () => ({
609
256
  version: import_protocols4.STORAGE_VERSION,
@@ -617,10 +264,10 @@ var LargeSpaceMetadata = import_protocols4.schema.getCodecForType("dxos.echo.met
617
264
  var MetadataStore = class {
618
265
  constructor(directory) {
619
266
  this._metadata = emptyEchoMetadata();
620
- this._spaceLargeMetadata = new import_util3.ComplexMap(import_keys3.PublicKey.hash);
267
+ this._spaceLargeMetadata = new import_util.ComplexMap(import_keys2.PublicKey.hash);
621
268
  this._metadataFile = void 0;
622
- this.update = new import_async2.Event();
623
- this._invitationCleanupCtx = new import_context3.Context();
269
+ this.update = new import_async.Event();
270
+ this._invitationCleanupCtx = new import_context2.Context();
624
271
  this._directory = directory;
625
272
  }
626
273
  get metadata() {
@@ -644,12 +291,12 @@ var MetadataStore = class {
644
291
  }
645
292
  const dataSize = fromBytesInt32(await file.read(0, 4));
646
293
  const checksum = fromBytesInt32(await file.read(4, 4));
647
- (0, import_log3.log)("loaded", {
294
+ (0, import_log.log)("loaded", {
648
295
  size: dataSize,
649
296
  checksum,
650
297
  name: file.filename
651
298
  }, {
652
- F: __dxlog_file4,
299
+ F: __dxlog_file2,
653
300
  L: 89,
654
301
  S: this,
655
302
  C: (f, a) => f(...a)
@@ -674,18 +321,18 @@ var MetadataStore = class {
674
321
  * @internal
675
322
  */
676
323
  async _writeFile(file, codec2, data) {
677
- const encoded = (0, import_util3.arrayToBuffer)(codec2.encode(data));
324
+ const encoded = (0, import_util.arrayToBuffer)(codec2.encode(data));
678
325
  const checksum = import_crc_32.default.buf(encoded);
679
326
  const result = Buffer.alloc(8 + encoded.length);
680
327
  result.writeInt32LE(encoded.length, 0);
681
328
  result.writeInt32LE(checksum, 4);
682
329
  encoded.copy(result, 8);
683
330
  await file.write(0, result);
684
- (0, import_log3.log)("saved", {
331
+ (0, import_log.log)("saved", {
685
332
  size: encoded.length,
686
333
  checksum
687
334
  }, {
688
- F: __dxlog_file4,
335
+ F: __dxlog_file2,
689
336
  L: 124,
690
337
  S: this,
691
338
  C: (f, a) => f(...a)
@@ -715,34 +362,34 @@ var MetadataStore = class {
715
362
  space.state ??= import_services.SpaceState.ACTIVE;
716
363
  });
717
364
  } catch (err) {
718
- import_log3.log.error("failed to load metadata", {
365
+ import_log.log.error("failed to load metadata", {
719
366
  err
720
367
  }, {
721
- F: __dxlog_file4,
368
+ F: __dxlog_file2,
722
369
  L: 156,
723
370
  S: this,
724
371
  C: (f, a) => f(...a)
725
372
  });
726
373
  this._metadata = emptyEchoMetadata();
727
374
  }
728
- await (0, import_util3.forEachAsync)([
375
+ await (0, import_util.forEachAsync)([
729
376
  this._metadata.identity?.haloSpace.key,
730
377
  ...this._metadata.spaces?.map((space) => space.key) ?? []
731
- ].filter(import_util3.isNotNullOrUndefined), async (key) => {
378
+ ].filter(import_util.isNotNullOrUndefined), async (key) => {
732
379
  try {
733
380
  await this._loadSpaceLargeMetadata(key);
734
381
  } catch (err) {
735
- import_log3.log.error("failed to load space large metadata", {
382
+ import_log.log.error("failed to load space large metadata", {
736
383
  err
737
384
  }, {
738
- F: __dxlog_file4,
385
+ F: __dxlog_file2,
739
386
  L: 168,
740
387
  S: this,
741
388
  C: (f, a) => f(...a)
742
389
  });
743
390
  }
744
391
  });
745
- (0, import_async2.scheduleTaskInterval)(this._invitationCleanupCtx, async () => {
392
+ (0, import_async.scheduleTaskInterval)(this._invitationCleanupCtx, async () => {
746
393
  for (const invitation of this.getInvitations()) {
747
394
  if (invitation.created && invitation.lifetime && invitation.lifetime !== 0 && invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
748
395
  await this.removeInvitation(invitation.invitationId);
@@ -769,10 +416,10 @@ var MetadataStore = class {
769
416
  this._spaceLargeMetadata.set(key, metadata);
770
417
  }
771
418
  } catch (err) {
772
- import_log3.log.error("failed to load space large metadata", {
419
+ import_log.log.error("failed to load space large metadata", {
773
420
  err
774
421
  }, {
775
- F: __dxlog_file4,
422
+ F: __dxlog_file2,
776
423
  L: 215,
777
424
  S: this,
778
425
  C: (f, a) => f(...a)
@@ -792,8 +439,8 @@ var MetadataStore = class {
792
439
  return this._metadata.identity.haloSpace;
793
440
  }
794
441
  const space = this.spaces.find((space2) => space2.key === spaceKey);
795
- (0, import_invariant4.invariant)(space, "Space not found", {
796
- F: __dxlog_file4,
442
+ (0, import_invariant2.invariant)(space, "Space not found", {
443
+ F: __dxlog_file2,
797
444
  L: 237,
798
445
  S: this,
799
446
  A: [
@@ -816,8 +463,8 @@ var MetadataStore = class {
816
463
  * Clears storage - doesn't work for now.
817
464
  */
818
465
  async clear() {
819
- (0, import_log3.log)("clearing all metadata", void 0, {
820
- F: __dxlog_file4,
466
+ (0, import_log.log)("clearing all metadata", void 0, {
467
+ F: __dxlog_file2,
821
468
  L: 256,
822
469
  S: this,
823
470
  C: (f, a) => f(...a)
@@ -829,8 +476,8 @@ var MetadataStore = class {
829
476
  return this._metadata.identity;
830
477
  }
831
478
  async setIdentityRecord(record) {
832
- (0, import_invariant4.invariant)(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
833
- F: __dxlog_file4,
479
+ (0, import_invariant2.invariant)(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
480
+ F: __dxlog_file2,
834
481
  L: 266,
835
482
  S: this,
836
483
  A: [
@@ -859,8 +506,8 @@ var MetadataStore = class {
859
506
  await this.flush();
860
507
  }
861
508
  async addSpace(record) {
862
- (0, import_invariant4.invariant)(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
863
- F: __dxlog_file4,
509
+ (0, import_invariant2.invariant)(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
510
+ F: __dxlog_file2,
864
511
  L: 294,
865
512
  S: this,
866
513
  A: [
@@ -907,13 +554,13 @@ var MetadataStore = class {
907
554
  }
908
555
  };
909
556
  _ts_decorate([
910
- import_async2.synchronized
557
+ import_async.synchronized
911
558
  ], MetadataStore.prototype, "load", null);
912
559
  _ts_decorate([
913
- import_async2.synchronized
560
+ import_async.synchronized
914
561
  ], MetadataStore.prototype, "_save", null);
915
562
  _ts_decorate([
916
- import_async2.synchronized
563
+ import_async.synchronized
917
564
  ], MetadataStore.prototype, "_saveSpaceLargeMetadata", null);
918
565
  var fromBytesInt32 = (buf) => buf.readInt32LE(0);
919
566
  function _ts_decorate2(decorators, target, key, desc) {
@@ -926,7 +573,7 @@ function _ts_decorate2(decorators, target, key, desc) {
926
573
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
927
574
  return c > 3 && r && Object.defineProperty(target, key, r), r;
928
575
  }
929
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
576
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
930
577
  var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
931
578
  feedKey,
932
579
  index
@@ -942,7 +589,7 @@ var startAfter = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
942
589
  var TimeframeClock = class {
943
590
  constructor(_timeframe = new import_timeframe.Timeframe()) {
944
591
  this._timeframe = _timeframe;
945
- this.update = new import_async3.Event();
592
+ this.update = new import_async2.Event();
946
593
  this._pendingTimeframe = _timeframe;
947
594
  }
948
595
  /**
@@ -980,22 +627,22 @@ var TimeframeClock = class {
980
627
  return !gaps.isEmpty();
981
628
  }
982
629
  async waitUntilReached(target) {
983
- (0, import_log4.log)("waitUntilReached", {
630
+ (0, import_log2.log)("waitUntilReached", {
984
631
  target,
985
632
  current: this._timeframe
986
633
  }, {
987
- F: __dxlog_file5,
634
+ F: __dxlog_file3,
988
635
  L: 70,
989
636
  S: this,
990
637
  C: (f, a) => f(...a)
991
638
  });
992
639
  await this.update.waitForCondition(() => {
993
- (0, import_log4.log)("check if reached", {
640
+ (0, import_log2.log)("check if reached", {
994
641
  target,
995
642
  current: this._timeframe,
996
643
  deps: import_timeframe.Timeframe.dependencies(target, this._timeframe)
997
644
  }, {
998
- F: __dxlog_file5,
645
+ F: __dxlog_file3,
999
646
  L: 72,
1000
647
  S: this,
1001
648
  C: (f, a) => f(...a)
@@ -1005,15 +652,15 @@ var TimeframeClock = class {
1005
652
  }
1006
653
  };
1007
654
  _ts_decorate2([
1008
- (0, import_debug2.timed)(5e3)
655
+ (0, import_debug.timed)(5e3)
1009
656
  ], TimeframeClock.prototype, "waitUntilReached", null);
1010
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
657
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
1011
658
  var createMessageSelector = (timeframeClock) => {
1012
659
  return (messages) => {
1013
660
  for (let i = 0; i < messages.length; i++) {
1014
661
  const { data: { timeframe } } = messages[i];
1015
- (0, import_invariant6.invariant)(timeframe, void 0, {
1016
- F: __dxlog_file6,
662
+ (0, import_invariant4.invariant)(timeframe, void 0, {
663
+ F: __dxlog_file4,
1017
664
  L: 25,
1018
665
  S: void 0,
1019
666
  A: [
@@ -1025,8 +672,8 @@ var createMessageSelector = (timeframeClock) => {
1025
672
  return i;
1026
673
  }
1027
674
  }
1028
- (0, import_log6.log)("Skipping...", void 0, {
1029
- F: __dxlog_file6,
675
+ (0, import_log4.log)("Skipping...", void 0, {
676
+ F: __dxlog_file4,
1030
677
  L: 33,
1031
678
  S: void 0,
1032
679
  C: (f, a) => f(...a)
@@ -1043,14 +690,14 @@ function _ts_decorate3(decorators, target, key, desc) {
1043
690
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1044
691
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1045
692
  }
1046
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
693
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
1047
694
  var PipelineState = class {
1048
695
  constructor(_feeds, _timeframeClock) {
1049
696
  this._feeds = _feeds;
1050
697
  this._timeframeClock = _timeframeClock;
1051
- this._ctx = new import_context4.Context();
698
+ this._ctx = new import_context3.Context();
1052
699
  this.timeframeUpdate = this._timeframeClock.update;
1053
- this.stalled = new import_async4.Event();
700
+ this.stalled = new import_async3.Event();
1054
701
  this._startTimeframe = new import_timeframe2.Timeframe();
1055
702
  this._reachedTarget = false;
1056
703
  }
@@ -1096,13 +743,13 @@ var PipelineState = class {
1096
743
  *
1097
744
  * @param timeout Timeout in milliseconds to specify the maximum wait time.
1098
745
  */
1099
- async waitUntilReachedTargetTimeframe({ ctx = new import_context4.Context(), timeout, breakOnStall = true } = {}) {
1100
- (0, import_log5.log)("waitUntilReachedTargetTimeframe", {
746
+ async waitUntilReachedTargetTimeframe({ ctx = new import_context3.Context(), timeout, breakOnStall = true } = {}) {
747
+ (0, import_log3.log)("waitUntilReachedTargetTimeframe", {
1101
748
  timeout,
1102
749
  current: this.timeframe,
1103
750
  target: this.targetTimeframe
1104
751
  }, {
1105
- F: __dxlog_file7,
752
+ F: __dxlog_file5,
1106
753
  L: 133,
1107
754
  S: this,
1108
755
  C: (f, a) => f(...a)
@@ -1118,23 +765,23 @@ var PipelineState = class {
1118
765
  let done = false;
1119
766
  if (timeout) {
1120
767
  return Promise.race([
1121
- (0, import_context4.rejectOnDispose)(ctx),
1122
- (0, import_context4.rejectOnDispose)(this._ctx),
768
+ (0, import_context3.rejectOnDispose)(ctx),
769
+ (0, import_context3.rejectOnDispose)(this._ctx),
1123
770
  this._reachedTargetPromise.then(() => {
1124
771
  done = true;
1125
772
  this._reachedTarget = true;
1126
773
  }),
1127
- (0, import_async4.sleepWithContext)(this._ctx, timeout).then(() => {
774
+ (0, import_async3.sleepWithContext)(this._ctx, timeout).then(() => {
1128
775
  if (done) {
1129
776
  return;
1130
777
  }
1131
- import_log5.log.warn("waitUntilReachedTargetTimeframe timed out", {
778
+ import_log3.log.warn("waitUntilReachedTargetTimeframe timed out", {
1132
779
  timeout,
1133
780
  current: this.timeframe,
1134
781
  target: this.targetTimeframe,
1135
782
  dependencies: import_timeframe2.Timeframe.dependencies(this.targetTimeframe, this.timeframe)
1136
783
  }, {
1137
- F: __dxlog_file7,
784
+ F: __dxlog_file5,
1138
785
  L: 161,
1139
786
  S: this,
1140
787
  C: (f, a) => f(...a)
@@ -1149,11 +796,11 @@ var PipelineState = class {
1149
796
  var Pipeline = class {
1150
797
  constructor() {
1151
798
  this._timeframeClock = new TimeframeClock(new import_timeframe2.Timeframe());
1152
- this._feeds = new import_util4.ComplexMap(import_keys4.PublicKey.hash);
799
+ this._feeds = new import_util2.ComplexMap(import_keys3.PublicKey.hash);
1153
800
  this._state = new PipelineState(this._feeds, this._timeframeClock);
1154
- this._processingTrigger = new import_async4.Trigger().wake();
1155
- this._pauseTrigger = new import_async4.Trigger().wake();
1156
- this._downloads = new import_util4.ComplexMap((value) => import_keys4.PublicKey.hash(value.key));
801
+ this._processingTrigger = new import_async3.Trigger().wake();
802
+ this._pauseTrigger = new import_async3.Trigger().wake();
803
+ this._downloads = new import_util2.ComplexMap((value) => import_keys3.PublicKey.hash(value.key));
1157
804
  this._isStopping = false;
1158
805
  this._isStarted = false;
1159
806
  this._isBeingConsumed = false;
@@ -1163,8 +810,8 @@ var Pipeline = class {
1163
810
  return this._state;
1164
811
  }
1165
812
  get writer() {
1166
- (0, import_invariant5.invariant)(this._writer, "Writer not set.", {
1167
- F: __dxlog_file7,
813
+ (0, import_invariant3.invariant)(this._writer, "Writer not set.", {
814
+ F: __dxlog_file5,
1168
815
  L: 242,
1169
816
  S: this,
1170
817
  A: [
@@ -1192,8 +839,8 @@ var Pipeline = class {
1192
839
  }
1193
840
  }
1194
841
  setWriteFeed(feed) {
1195
- (0, import_invariant5.invariant)(!this._writer, "Writer already set.", {
1196
- F: __dxlog_file7,
842
+ (0, import_invariant3.invariant)(!this._writer, "Writer already set.", {
843
+ F: __dxlog_file5,
1197
844
  L: 269,
1198
845
  S: this,
1199
846
  A: [
@@ -1201,8 +848,8 @@ var Pipeline = class {
1201
848
  "'Writer already set.'"
1202
849
  ]
1203
850
  });
1204
- (0, import_invariant5.invariant)(feed.properties.writable, "Feed must be writable.", {
1205
- F: __dxlog_file7,
851
+ (0, import_invariant3.invariant)(feed.properties.writable, "Feed must be writable.", {
852
+ F: __dxlog_file5,
1206
853
  L: 270,
1207
854
  S: this,
1208
855
  A: [
@@ -1216,8 +863,8 @@ var Pipeline = class {
1216
863
  }), feed.createFeedWriter());
1217
864
  }
1218
865
  async start() {
1219
- (0, import_invariant5.invariant)(!this._isStarted, "Pipeline is already started.", {
1220
- F: __dxlog_file7,
866
+ (0, import_invariant3.invariant)(!this._isStarted, "Pipeline is already started.", {
867
+ F: __dxlog_file5,
1221
868
  L: 283,
1222
869
  S: this,
1223
870
  A: [
@@ -1225,8 +872,8 @@ var Pipeline = class {
1225
872
  "'Pipeline is already started.'"
1226
873
  ]
1227
874
  });
1228
- (0, import_log5.log)("starting...", void 0, {
1229
- F: __dxlog_file7,
875
+ (0, import_log3.log)("starting...", void 0, {
876
+ F: __dxlog_file5,
1230
877
  L: 284,
1231
878
  S: this,
1232
879
  C: (f, a) => f(...a)
@@ -1234,8 +881,8 @@ var Pipeline = class {
1234
881
  await this._initIterator();
1235
882
  await this._feedSetIterator.open();
1236
883
  this._isStarted = true;
1237
- (0, import_log5.log)("started", void 0, {
1238
- F: __dxlog_file7,
884
+ (0, import_log3.log)("started", void 0, {
885
+ F: __dxlog_file5,
1239
886
  L: 288,
1240
887
  S: this,
1241
888
  C: (f, a) => f(...a)
@@ -1247,8 +894,8 @@ var Pipeline = class {
1247
894
  }
1248
895
  }
1249
896
  async stop() {
1250
- (0, import_log5.log)("stopping...", void 0, {
1251
- F: __dxlog_file7,
897
+ (0, import_log3.log)("stopping...", void 0, {
898
+ F: __dxlog_file5,
1252
899
  L: 299,
1253
900
  S: this,
1254
901
  C: (f, a) => f(...a)
@@ -1261,12 +908,12 @@ var Pipeline = class {
1261
908
  await this._feedSetIterator?.close();
1262
909
  await this._processingTrigger.wait();
1263
910
  await this._state._ctx.dispose();
1264
- this._state._ctx = new import_context4.Context();
911
+ this._state._ctx = new import_context3.Context();
1265
912
  this._state._reachedTargetPromise = void 0;
1266
913
  this._state._reachedTarget = false;
1267
914
  this._isStarted = false;
1268
- (0, import_log5.log)("stopped", void 0, {
1269
- F: __dxlog_file7,
915
+ (0, import_log3.log)("stopped", void 0, {
916
+ F: __dxlog_file5,
1270
917
  L: 312,
1271
918
  S: this,
1272
919
  C: (f, a) => f(...a)
@@ -1277,8 +924,8 @@ var Pipeline = class {
1277
924
  * The pipeline will start processing messages AFTER this timeframe.
1278
925
  */
1279
926
  async setCursor(timeframe) {
1280
- (0, import_invariant5.invariant)(!this._isStarted || this._isPaused, "Invalid state.", {
1281
- F: __dxlog_file7,
927
+ (0, import_invariant3.invariant)(!this._isStarted || this._isPaused, "Invalid state.", {
928
+ F: __dxlog_file5,
1282
929
  L: 321,
1283
930
  S: this,
1284
931
  A: [
@@ -1306,8 +953,8 @@ var Pipeline = class {
1306
953
  this._isPaused = true;
1307
954
  }
1308
955
  async unpause() {
1309
- (0, import_invariant5.invariant)(this._isPaused, "Pipeline is not paused.", {
1310
- F: __dxlog_file7,
956
+ (0, import_invariant3.invariant)(this._isPaused, "Pipeline is not paused.", {
957
+ F: __dxlog_file5,
1311
958
  L: 350,
1312
959
  S: this,
1313
960
  A: [
@@ -1326,8 +973,8 @@ var Pipeline = class {
1326
973
  * Updates the timeframe clock after the message has bee processed.
1327
974
  */
1328
975
  async *consume() {
1329
- (0, import_invariant5.invariant)(!this._isBeingConsumed, "Pipeline is already being consumed.", {
1330
- F: __dxlog_file7,
976
+ (0, import_invariant3.invariant)(!this._isBeingConsumed, "Pipeline is already being consumed.", {
977
+ F: __dxlog_file5,
1331
978
  L: 365,
1332
979
  S: this,
1333
980
  A: [
@@ -1336,8 +983,8 @@ var Pipeline = class {
1336
983
  ]
1337
984
  });
1338
985
  this._isBeingConsumed = true;
1339
- (0, import_invariant5.invariant)(this._feedSetIterator, "Iterator not initialized.", {
1340
- F: __dxlog_file7,
986
+ (0, import_invariant3.invariant)(this._feedSetIterator, "Iterator not initialized.", {
987
+ F: __dxlog_file5,
1341
988
  L: 368,
1342
989
  S: this,
1343
990
  A: [
@@ -1350,8 +997,8 @@ var Pipeline = class {
1350
997
  while (!this._isStopping) {
1351
998
  await this._pauseTrigger.wait();
1352
999
  if (lastFeedSetIterator !== this._feedSetIterator) {
1353
- (0, import_invariant5.invariant)(this._feedSetIterator, "Iterator not initialized.", {
1354
- F: __dxlog_file7,
1000
+ (0, import_invariant3.invariant)(this._feedSetIterator, "Iterator not initialized.", {
1001
+ F: __dxlog_file5,
1355
1002
  L: 377,
1356
1003
  S: this,
1357
1004
  A: [
@@ -1364,9 +1011,9 @@ var Pipeline = class {
1364
1011
  }
1365
1012
  const { done, value } = await iterable.next();
1366
1013
  if (!done) {
1367
- const block = value ?? (0, import_debug3.failUndefined)();
1014
+ const block = value ?? (0, import_debug2.failUndefined)();
1368
1015
  this._processingTrigger.reset();
1369
- this._timeframeClock.updatePendingTimeframe(import_keys4.PublicKey.from(block.feedKey), block.seq);
1016
+ this._timeframeClock.updatePendingTimeframe(import_keys3.PublicKey.from(block.feedKey), block.seq);
1370
1017
  yield block;
1371
1018
  this._processingTrigger.wake();
1372
1019
  this._timeframeClock.updateTimeframe();
@@ -1381,12 +1028,12 @@ var Pipeline = class {
1381
1028
  }
1382
1029
  const timeframe = this._state._startTimeframe;
1383
1030
  const seq = timeframe.get(feed.key) ?? -1;
1384
- (0, import_log5.log)("download", {
1031
+ (0, import_log3.log)("download", {
1385
1032
  feed: feed.key.truncate(),
1386
1033
  seq,
1387
1034
  length: feed.length
1388
1035
  }, {
1389
- F: __dxlog_file7,
1036
+ F: __dxlog_file5,
1390
1037
  L: 406,
1391
1038
  S: this,
1392
1039
  C: (f, a) => f(...a)
@@ -1397,10 +1044,10 @@ var Pipeline = class {
1397
1044
  }, (err, data) => {
1398
1045
  if (err) {
1399
1046
  } else {
1400
- import_log5.log.info("downloaded", {
1047
+ import_log3.log.info("downloaded", {
1401
1048
  data
1402
1049
  }, {
1403
- F: __dxlog_file7,
1050
+ F: __dxlog_file5,
1404
1051
  L: 411,
1405
1052
  S: this,
1406
1053
  C: (f, a) => f(...a)
@@ -1415,8 +1062,8 @@ var Pipeline = class {
1415
1062
  stallTimeout: 1e3
1416
1063
  });
1417
1064
  this._feedSetIterator.stalled.on((iterator) => {
1418
- import_log5.log.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
1419
- F: __dxlog_file7,
1065
+ import_log3.log.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
1066
+ F: __dxlog_file5,
1420
1067
  L: 425,
1421
1068
  S: this,
1422
1069
  C: (f, a) => f(...a)
@@ -1429,21 +1076,21 @@ var Pipeline = class {
1429
1076
  }
1430
1077
  };
1431
1078
  _ts_decorate3([
1432
- import_async4.synchronized
1079
+ import_async3.synchronized
1433
1080
  ], Pipeline.prototype, "start", null);
1434
1081
  _ts_decorate3([
1435
- import_async4.synchronized
1082
+ import_async3.synchronized
1436
1083
  ], Pipeline.prototype, "stop", null);
1437
1084
  _ts_decorate3([
1438
- import_async4.synchronized
1085
+ import_async3.synchronized
1439
1086
  ], Pipeline.prototype, "setCursor", null);
1440
1087
  _ts_decorate3([
1441
- import_async4.synchronized
1088
+ import_async3.synchronized
1442
1089
  ], Pipeline.prototype, "pause", null);
1443
1090
  _ts_decorate3([
1444
- import_async4.synchronized
1091
+ import_async3.synchronized
1445
1092
  ], Pipeline.prototype, "unpause", null);
1446
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
1093
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
1447
1094
  var AuthExtension = class extends import_teleport.RpcExtension {
1448
1095
  constructor(_authParams) {
1449
1096
  super({
@@ -1456,10 +1103,10 @@ var AuthExtension = class extends import_teleport.RpcExtension {
1456
1103
  timeout: 60 * 1e3
1457
1104
  });
1458
1105
  this._authParams = _authParams;
1459
- this._ctx = new import_context5.Context({
1106
+ this._ctx = new import_context4.Context({
1460
1107
  onError: (err) => {
1461
- import_log7.log.catch(err, void 0, {
1462
- F: __dxlog_file8,
1108
+ import_log5.log.catch(err, void 0, {
1109
+ F: __dxlog_file6,
1463
1110
  L: 28,
1464
1111
  S: this,
1465
1112
  C: (f, a) => f(...a)
@@ -1480,8 +1127,8 @@ var AuthExtension = class extends import_teleport.RpcExtension {
1480
1127
  credential
1481
1128
  };
1482
1129
  } catch (err) {
1483
- import_log7.log.error("failed to generate auth credentials", err, {
1484
- F: __dxlog_file8,
1130
+ import_log5.log.error("failed to generate auth credentials", err, {
1131
+ F: __dxlog_file6,
1485
1132
  L: 55,
1486
1133
  S: this,
1487
1134
  C: (f, a) => f(...a)
@@ -1494,14 +1141,14 @@ var AuthExtension = class extends import_teleport.RpcExtension {
1494
1141
  }
1495
1142
  async onOpen(context) {
1496
1143
  await super.onOpen(context);
1497
- (0, import_async5.scheduleTask)(this._ctx, async () => {
1144
+ (0, import_async4.scheduleTask)(this._ctx, async () => {
1498
1145
  try {
1499
1146
  const challenge = (0, import_crypto2.randomBytes)(32);
1500
1147
  const { credential } = await this.rpc.AuthService.authenticate({
1501
1148
  challenge
1502
1149
  });
1503
- (0, import_invariant7.invariant)(credential?.length > 0, "invalid credential", {
1504
- F: __dxlog_file8,
1150
+ (0, import_invariant5.invariant)(credential?.length > 0, "invalid credential", {
1151
+ F: __dxlog_file6,
1505
1152
  L: 69,
1506
1153
  S: this,
1507
1154
  A: [
@@ -1510,8 +1157,8 @@ var AuthExtension = class extends import_teleport.RpcExtension {
1510
1157
  ]
1511
1158
  });
1512
1159
  const success = await this._authParams.verifier(challenge, credential);
1513
- (0, import_invariant7.invariant)(success, "credential not verified", {
1514
- F: __dxlog_file8,
1160
+ (0, import_invariant5.invariant)(success, "credential not verified", {
1161
+ F: __dxlog_file6,
1515
1162
  L: 71,
1516
1163
  S: this,
1517
1164
  A: [
@@ -1519,10 +1166,10 @@ var AuthExtension = class extends import_teleport.RpcExtension {
1519
1166
  "'credential not verified'"
1520
1167
  ]
1521
1168
  });
1522
- (0, import_async5.runInContext)(this._ctx, () => this._authParams.onAuthSuccess());
1169
+ (0, import_async4.runInContext)(this._ctx, () => this._authParams.onAuthSuccess());
1523
1170
  } catch (err) {
1524
- (0, import_log7.log)("auth failed", err, {
1525
- F: __dxlog_file8,
1171
+ (0, import_log5.log)("auth failed", err, {
1172
+ F: __dxlog_file6,
1526
1173
  L: 74,
1527
1174
  S: this,
1528
1175
  C: (f, a) => f(...a)
@@ -1551,467 +1198,36 @@ function _ts_decorate4(decorators, target, key, desc) {
1551
1198
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1552
1199
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1553
1200
  }
1554
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
1555
- var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 5e3;
1556
- var DataPipeline = class {
1557
- constructor(_params) {
1558
- this._params = _params;
1559
- this._ctx = new import_context6.Context();
1560
- this._pipeline = void 0;
1561
- this._targetTimeframe = void 0;
1562
- this._lastAutomaticSnapshotTimeframe = new import_timeframe3.Timeframe();
1563
- this._isOpen = false;
1564
- this._lastTimeframeSaveTime = 0;
1565
- this._lastSnapshotSaveTime = 0;
1566
- this._lastProcessedEpoch = -1;
1567
- this._usage = new import_tracing.TimeUsageCounter();
1568
- this._mutations = new import_tracing.TimeSeriesCounter();
1569
- this.currentEpoch = void 0;
1570
- this.appliedEpoch = void 0;
1571
- this.onNewEpoch = new import_async6.Event();
1572
- }
1573
- get isOpen() {
1574
- return this._isOpen;
1575
- }
1576
- get pipeline() {
1577
- return this._pipeline;
1578
- }
1579
- get pipelineState() {
1580
- return this._pipeline?.state;
1581
- }
1582
- setTargetTimeframe(timeframe) {
1583
- this._targetTimeframe = timeframe;
1584
- this._pipeline?.state.setTargetTimeframe(timeframe);
1585
- }
1586
- async processCredential(credential) {
1587
- if (!(0, import_credentials.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
1588
- return;
1589
- }
1590
- this.currentEpoch = credential;
1591
- if (this._isOpen) {
1592
- await this._processEpochInSeparateTask(credential);
1593
- }
1594
- }
1595
- async open() {
1596
- if (this._isOpen) {
1597
- return;
1598
- }
1599
- this._pipeline = new Pipeline();
1600
- await this._params.onPipelineCreated(this._pipeline);
1601
- await this._pipeline.pause();
1602
- await this._pipeline.start();
1603
- if (this._targetTimeframe) {
1604
- this._pipeline.state.setTargetTimeframe(this._targetTimeframe);
1605
- }
1606
- const feedWriter = {
1607
- write: (data, options) => {
1608
- (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
1609
- F: __dxlog_file9,
1610
- L: 152,
1611
- S: this,
1612
- A: [
1613
- "this._pipeline",
1614
- "'Pipeline is not initialized.'"
1615
- ]
1616
- });
1617
- (0, import_invariant8.invariant)(this.currentEpoch, "Epoch is not initialized.", {
1618
- F: __dxlog_file9,
1619
- L: 153,
1620
- S: this,
1621
- A: [
1622
- "this.currentEpoch",
1623
- "'Epoch is not initialized.'"
1624
- ]
1625
- });
1626
- return this._pipeline.writer.write({
1627
- data
1628
- }, options);
1629
- }
1630
- };
1631
- this.databaseHost = new DatabaseHost(feedWriter, () => this._flush());
1632
- this.itemManager = new import_echo_db3.ItemManager(this._params.modelFactory);
1633
- await this.databaseHost.open(this.itemManager, this._params.modelFactory);
1634
- (0, import_async6.scheduleTask)(this._ctx, async () => {
1635
- await this._consumePipeline();
1636
- });
1637
- this._isOpen = true;
1638
- }
1639
- async close() {
1640
- if (!this._isOpen) {
1641
- return;
1642
- }
1643
- (0, import_log8.log)("close", void 0, {
1644
- F: __dxlog_file9,
1645
- L: 177,
1646
- S: this,
1647
- C: (f, a) => f(...a)
1648
- });
1649
- this._isOpen = false;
1650
- await this._ctx.dispose();
1651
- await this._pipeline?.stop();
1652
- try {
1653
- if (this._pipeline) {
1654
- await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1655
- }
1656
- } catch (err) {
1657
- import_log8.log.catch(err, void 0, {
1658
- F: __dxlog_file9,
1659
- L: 189,
1660
- S: this,
1661
- C: (f, a) => f(...a)
1662
- });
1663
- }
1664
- await this.databaseHost?.close();
1665
- await this.itemManager?.destroy();
1666
- this._ctx = new import_context6.Context();
1667
- this._pipeline = void 0;
1668
- this._targetTimeframe = void 0;
1669
- this._lastAutomaticSnapshotTimeframe = new import_timeframe3.Timeframe();
1670
- this.currentEpoch = void 0;
1671
- this.appliedEpoch = void 0;
1672
- this._lastProcessedEpoch = -1;
1673
- this._epochCtx = void 0;
1674
- }
1675
- async _consumePipeline() {
1676
- const pipeline = this._pipeline;
1677
- if (this.currentEpoch) {
1678
- const waitForOneEpoch = this.onNewEpoch.waitForCount(1);
1679
- await this._processEpochInSeparateTask(this.currentEpoch);
1680
- await waitForOneEpoch;
1681
- }
1682
- let messageCounter = 0;
1683
- (0, import_invariant8.invariant)(pipeline, "Pipeline is not initialized.", {
1684
- F: __dxlog_file9,
1685
- L: 216,
1686
- S: this,
1687
- A: [
1688
- "pipeline",
1689
- "'Pipeline is not initialized.'"
1690
- ]
1691
- });
1692
- for await (const msg of pipeline.consume()) {
1693
- const span = this._usage.beginRecording();
1694
- this._mutations.inc();
1695
- const { feedKey, seq, data } = msg;
1696
- (0, import_log8.log)("processing message", {
1697
- feedKey,
1698
- seq
1699
- }, {
1700
- F: __dxlog_file9,
1701
- L: 222,
1702
- S: this,
1703
- C: (f, a) => f(...a)
1704
- });
1705
- try {
1706
- if (data.payload.data) {
1707
- const feedInfo = this._params.feedInfoProvider(feedKey);
1708
- if (!feedInfo) {
1709
- import_log8.log.warn("Could not find feed", {
1710
- feedKey
1711
- }, {
1712
- F: __dxlog_file9,
1713
- L: 228,
1714
- S: this,
1715
- C: (f, a) => f(...a)
1716
- });
1717
- continue;
1718
- }
1719
- const timer = import_util5.tracer.mark("dxos.echo.pipeline.data");
1720
- this.databaseHost.echoProcessor({
1721
- batch: data.payload.data.batch,
1722
- meta: {
1723
- feedKey,
1724
- seq,
1725
- timeframe: data.timeframe,
1726
- memberKey: feedInfo.assertion.identityKey
1727
- }
1728
- });
1729
- timer.end();
1730
- import_log8.log.trace("dxos.echo.data-pipeline.processed", {
1731
- feedKey: feedKey.toHex(),
1732
- seq,
1733
- spaceKey: this._params.spaceKey.toHex()
1734
- }, {
1735
- F: __dxlog_file9,
1736
- L: 245,
1737
- S: this,
1738
- C: (f, a) => f(...a)
1739
- });
1740
- await this._noteTargetStateIfNeeded(pipeline.state.pendingTimeframe);
1741
- }
1742
- } catch (err) {
1743
- import_log8.log.catch(err, void 0, {
1744
- F: __dxlog_file9,
1745
- L: 255,
1746
- S: this,
1747
- C: (f, a) => f(...a)
1748
- });
1749
- }
1750
- span.end();
1751
- if (++messageCounter > 100) {
1752
- messageCounter = 0;
1753
- await idle(1e3);
1754
- }
1755
- }
1756
- }
1757
- _createSnapshot() {
1758
- (0, import_invariant8.invariant)(this.databaseHost, "Database backend is not initialized.", {
1759
- F: __dxlog_file9,
1760
- L: 269,
1761
- S: this,
1762
- A: [
1763
- "this.databaseHost",
1764
- "'Database backend is not initialized.'"
1765
- ]
1766
- });
1767
- return {
1768
- spaceKey: this._params.spaceKey.asUint8Array(),
1769
- timeframe: this._pipeline.state.timeframe,
1770
- database: this.databaseHost.createSnapshot()
1771
- };
1772
- }
1773
- async _saveTargetTimeframe(timeframe) {
1774
- const newTimeframe = import_timeframe3.Timeframe.merge(this._targetTimeframe ?? new import_timeframe3.Timeframe(), timeframe);
1775
- await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
1776
- this._targetTimeframe = newTimeframe;
1777
- }
1778
- async _noteTargetStateIfNeeded(timeframe) {
1779
- if (!this._pipeline?.state.reachedTarget) {
1780
- return;
1781
- }
1782
- if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL) {
1783
- this._lastTimeframeSaveTime = Date.now();
1784
- await this._saveTargetTimeframe(timeframe);
1785
- }
1786
- }
1787
- async _processEpochInSeparateTask(epoch) {
1788
- if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
1789
- return;
1790
- }
1791
- await this._epochCtx?.dispose();
1792
- const ctx = new import_context6.Context({
1793
- onError: (err) => {
1794
- if (err instanceof import_protocols6.CancelledError) {
1795
- (0, import_log8.log)("Epoch processing cancelled.", void 0, {
1796
- F: __dxlog_file9,
1797
- L: 305,
1798
- S: this,
1799
- C: (f, a) => f(...a)
1800
- });
1801
- } else {
1802
- import_log8.log.catch(err, void 0, {
1803
- F: __dxlog_file9,
1804
- L: 307,
1805
- S: this,
1806
- C: (f, a) => f(...a)
1807
- });
1808
- }
1809
- }
1810
- });
1811
- this._epochCtx = ctx;
1812
- (0, import_async6.scheduleTask)(ctx, async () => {
1813
- if (!this._isOpen) {
1814
- return;
1815
- }
1816
- await this._processEpoch(ctx, epoch.subject.assertion);
1817
- if (epoch.subject.assertion.snapshotCid === void 0) {
1818
- epoch.subject.assertion.snapshotCid = this.appliedEpoch?.subject.assertion.snapshotCid;
1819
- }
1820
- this.appliedEpoch = epoch;
1821
- this.onNewEpoch.emit(epoch);
1822
- });
1823
- }
1824
- async _processEpoch(ctx, epoch) {
1825
- (0, import_invariant8.invariant)(this._isOpen, "Space is closed.", {
1826
- F: __dxlog_file9,
1827
- L: 331,
1828
- S: this,
1829
- A: [
1830
- "this._isOpen",
1831
- "'Space is closed.'"
1832
- ]
1833
- });
1834
- (0, import_invariant8.invariant)(this._pipeline, void 0, {
1835
- F: __dxlog_file9,
1836
- L: 332,
1837
- S: this,
1838
- A: [
1839
- "this._pipeline",
1840
- ""
1841
- ]
1842
- });
1843
- this._lastProcessedEpoch = epoch.number;
1844
- (0, import_log8.log)("processing", {
1845
- epoch: (0, import_log8.omit)(epoch, "proof")
1846
- }, {
1847
- F: __dxlog_file9,
1848
- L: 335,
1849
- S: this,
1850
- C: (f, a) => f(...a)
1851
- });
1852
- if (epoch.snapshotCid) {
1853
- const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
1854
- this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
1855
- }
1856
- (0, import_log8.log)("restarting pipeline from epoch", void 0, {
1857
- F: __dxlog_file9,
1858
- L: 341,
1859
- S: this,
1860
- C: (f, a) => f(...a)
1861
- });
1862
- await this._pipeline.pause();
1863
- await this._pipeline.setCursor(epoch.timeframe);
1864
- await this._pipeline.unpause();
1865
- }
1866
- async waitUntilTimeframe(timeframe) {
1867
- (0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
1868
- F: __dxlog_file9,
1869
- L: 348,
1870
- S: this,
1871
- A: [
1872
- "this._pipeline",
1873
- "'Pipeline is not initialized.'"
1874
- ]
1875
- });
1876
- await this._pipeline.state.waitUntilTimeframe(timeframe);
1877
- }
1878
- async createEpoch() {
1879
- (0, import_invariant8.invariant)(this._pipeline, void 0, {
1880
- F: __dxlog_file9,
1881
- L: 354,
1882
- S: this,
1883
- A: [
1884
- "this._pipeline",
1885
- ""
1886
- ]
1887
- });
1888
- (0, import_invariant8.invariant)(this.currentEpoch, void 0, {
1889
- F: __dxlog_file9,
1890
- L: 355,
1891
- S: this,
1892
- A: [
1893
- "this.currentEpoch",
1894
- ""
1895
- ]
1896
- });
1897
- await this._pipeline.pause();
1898
- const snapshot = await this._createSnapshot();
1899
- const snapshotCid = await this._params.snapshotManager.store(snapshot);
1900
- const epoch = {
1901
- previousId: this.currentEpoch.id,
1902
- timeframe: this._pipeline.state.timeframe,
1903
- number: this.currentEpoch.subject.assertion.number + 1,
1904
- snapshotCid
1905
- };
1906
- await this._pipeline.unpause();
1907
- return epoch;
1908
- }
1909
- async ensureEpochInitialized() {
1910
- await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
1911
- }
1912
- async _flush() {
1913
- try {
1914
- if (this._pipeline) {
1915
- await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1916
- }
1917
- } catch (err) {
1918
- import_log8.log.catch(err, void 0, {
1919
- F: __dxlog_file9,
1920
- L: 384,
1921
- S: this,
1922
- C: (f, a) => f(...a)
1923
- });
1924
- }
1925
- await this._params.metadataStore.flush();
1926
- }
1927
- };
1928
- _ts_decorate4([
1929
- import_tracing.trace.metricsCounter()
1930
- ], DataPipeline.prototype, "_usage", void 0);
1931
- _ts_decorate4([
1932
- import_tracing.trace.metricsCounter()
1933
- ], DataPipeline.prototype, "_mutations", void 0);
1934
- _ts_decorate4([
1935
- import_async6.synchronized
1936
- ], DataPipeline.prototype, "open", null);
1937
- _ts_decorate4([
1938
- import_async6.synchronized
1939
- ], DataPipeline.prototype, "close", null);
1940
- _ts_decorate4([
1941
- import_async6.synchronized
1942
- ], DataPipeline.prototype, "_processEpoch", null);
1943
- _ts_decorate4([
1944
- import_async6.synchronized
1945
- ], DataPipeline.prototype, "createEpoch", null);
1946
- DataPipeline = _ts_decorate4([
1947
- (0, import_async6.trackLeaks)("open", "close"),
1948
- import_tracing.trace.resource()
1949
- ], DataPipeline);
1950
- var idle = async (timeout) => {
1951
- if (!("scheduler" in globalThis && typeof globalThis.scheduler.postTask === "function")) {
1952
- await (0, import_async6.sleep)(1);
1953
- return;
1954
- }
1955
- await new Promise((resolve) => {
1956
- const cleanup = () => {
1957
- clearTimeout(timer);
1958
- controller.abort();
1959
- };
1960
- const controller = new AbortController();
1961
- void globalThis.scheduler.postTask(() => {
1962
- cleanup();
1963
- resolve();
1964
- }, {
1965
- priority: "background",
1966
- signal: controller.signal
1967
- }).catch(() => {
1968
- });
1969
- const timer = setTimeout(() => {
1970
- cleanup();
1971
- resolve();
1972
- }, timeout);
1973
- });
1974
- };
1975
- function _ts_decorate5(decorators, target, key, desc) {
1976
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1977
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1978
- r = Reflect.decorate(decorators, target, key, desc);
1979
- else
1980
- for (var i = decorators.length - 1; i >= 0; i--)
1981
- if (d = decorators[i])
1982
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1983
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1984
- }
1985
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1986
- var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
1201
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1202
+ var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
1987
1203
  var CONTROL_PIPELINE_SNAPSHOT_DELAY = 1e4;
1988
1204
  var USE_SNAPSHOTS = true;
1989
1205
  var ControlPipeline = class {
1990
1206
  constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
1991
- this._ctx = new import_context7.Context();
1207
+ this._ctx = new import_context5.Context();
1992
1208
  this._lastTimeframeSaveTime = Date.now();
1993
- this.onFeedAdmitted = new import_util7.Callback();
1994
- this._usage = new import_tracing3.TimeUsageCounter();
1995
- this._mutations = new import_tracing3.TimeSeriesCounter();
1996
- this._snapshotTask = new import_async8.DeferredTask(this._ctx, async () => {
1997
- await (0, import_async8.sleepWithContext)(this._ctx, CONTROL_PIPELINE_SNAPSHOT_DELAY);
1209
+ this.onFeedAdmitted = new import_util4.Callback();
1210
+ this._usage = new import_tracing2.TimeUsageCounter();
1211
+ this._mutations = new import_tracing2.TimeSeriesCounter();
1212
+ this._snapshotTask = new import_async6.DeferredTask(this._ctx, async () => {
1213
+ await (0, import_async6.sleepWithContext)(this._ctx, CONTROL_PIPELINE_SNAPSHOT_DELAY);
1998
1214
  await this._saveSnapshot();
1999
1215
  });
2000
1216
  this._spaceKey = spaceKey;
2001
1217
  this._metadata = metadataStore;
2002
1218
  this._pipeline = new Pipeline();
2003
1219
  void this._pipeline.addFeed(genesisFeed);
2004
- this._spaceStateMachine = new import_credentials3.SpaceStateMachine(spaceKey);
1220
+ this._spaceStateMachine = new import_credentials2.SpaceStateMachine(spaceKey);
2005
1221
  this._spaceStateMachine.onFeedAdmitted.set(async (info) => {
2006
- (0, import_log10.log)("feed admitted", {
1222
+ (0, import_log7.log)("feed admitted", {
2007
1223
  key: info.key
2008
1224
  }, {
2009
- F: __dxlog_file10,
1225
+ F: __dxlog_file7,
2010
1226
  L: 74,
2011
1227
  S: this,
2012
1228
  C: (f, a) => f(...a)
2013
1229
  });
2014
- if (info.assertion.designation === import_credentials4.AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
1230
+ if (info.assertion.designation === import_credentials3.AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
2015
1231
  queueMicrotask(async () => {
2016
1232
  try {
2017
1233
  const feed = await feedProvider(info.key);
@@ -2019,8 +1235,8 @@ var ControlPipeline = class {
2019
1235
  await this._pipeline.addFeed(feed);
2020
1236
  }
2021
1237
  } catch (err) {
2022
- import_log10.log.catch(err, void 0, {
2023
- F: __dxlog_file10,
1238
+ import_log7.log.catch(err, void 0, {
1239
+ F: __dxlog_file7,
2024
1240
  L: 85,
2025
1241
  S: this,
2026
1242
  C: (f, a) => f(...a)
@@ -2045,12 +1261,12 @@ var ControlPipeline = class {
2045
1261
  }
2046
1262
  async start() {
2047
1263
  const snapshot = this._metadata.getSpaceControlPipelineSnapshot(this._spaceKey);
2048
- (0, import_log10.log)("load snapshot", {
1264
+ (0, import_log7.log)("load snapshot", {
2049
1265
  key: this._spaceKey,
2050
1266
  present: !!snapshot,
2051
1267
  tf: snapshot?.timeframe
2052
1268
  }, {
2053
- F: __dxlog_file10,
1269
+ F: __dxlog_file7,
2054
1270
  L: 113,
2055
1271
  S: this,
2056
1272
  C: (f, a) => f(...a)
@@ -2058,18 +1274,18 @@ var ControlPipeline = class {
2058
1274
  if (USE_SNAPSHOTS && snapshot) {
2059
1275
  await this._processSnapshot(snapshot);
2060
1276
  }
2061
- (0, import_log10.log)("starting...", void 0, {
2062
- F: __dxlog_file10,
1277
+ (0, import_log7.log)("starting...", void 0, {
1278
+ F: __dxlog_file7,
2063
1279
  L: 118,
2064
1280
  S: this,
2065
1281
  C: (f, a) => f(...a)
2066
1282
  });
2067
1283
  setTimeout(async () => {
2068
- void this._consumePipeline(new import_context7.Context());
1284
+ void this._consumePipeline(new import_context5.Context());
2069
1285
  });
2070
1286
  await this._pipeline.start();
2071
- (0, import_log10.log)("started", void 0, {
2072
- F: __dxlog_file10,
1287
+ (0, import_log7.log)("started", void 0, {
1288
+ F: __dxlog_file7,
2073
1289
  L: 124,
2074
1290
  S: this,
2075
1291
  C: (f, a) => f(...a)
@@ -2083,10 +1299,10 @@ var ControlPipeline = class {
2083
1299
  skipVerification: true
2084
1300
  });
2085
1301
  if (!result) {
2086
- import_log10.log.warn("credential processing failed from snapshot", {
1302
+ import_log7.log.warn("credential processing failed from snapshot", {
2087
1303
  message
2088
1304
  }, {
2089
- F: __dxlog_file10,
1305
+ F: __dxlog_file7,
2090
1306
  L: 137,
2091
1307
  S: this,
2092
1308
  C: (f, a) => f(...a)
@@ -2104,11 +1320,11 @@ var ControlPipeline = class {
2104
1320
  }))
2105
1321
  };
2106
1322
  await this._pipeline.unpause();
2107
- (0, import_log10.log)("save snapshot", {
1323
+ (0, import_log7.log)("save snapshot", {
2108
1324
  key: this._spaceKey,
2109
1325
  snapshot
2110
1326
  }, {
2111
- F: __dxlog_file10,
1327
+ F: __dxlog_file7,
2112
1328
  L: 153,
2113
1329
  S: this,
2114
1330
  C: (f, a) => f(...a)
@@ -2122,8 +1338,8 @@ var ControlPipeline = class {
2122
1338
  try {
2123
1339
  await this._processMessage(ctx, msg);
2124
1340
  } catch (err) {
2125
- import_log10.log.catch(err, void 0, {
2126
- F: __dxlog_file10,
1341
+ import_log7.log.catch(err, void 0, {
1342
+ F: __dxlog_file7,
2127
1343
  L: 166,
2128
1344
  S: this,
2129
1345
  C: (f, a) => f(...a)
@@ -2133,26 +1349,26 @@ var ControlPipeline = class {
2133
1349
  }
2134
1350
  }
2135
1351
  async _processMessage(ctx, msg) {
2136
- (0, import_log10.log)("processing", {
1352
+ (0, import_log7.log)("processing", {
2137
1353
  key: msg.feedKey,
2138
1354
  seq: msg.seq
2139
1355
  }, {
2140
- F: __dxlog_file10,
1356
+ F: __dxlog_file7,
2141
1357
  L: 176,
2142
1358
  S: this,
2143
1359
  C: (f, a) => f(...a)
2144
1360
  });
2145
1361
  if (msg.data.payload.credential) {
2146
- const timer = import_util7.tracer.mark("dxos.echo.pipeline.control");
1362
+ const timer = import_util4.tracer.mark("dxos.echo.pipeline.control");
2147
1363
  const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, {
2148
- sourceFeed: import_keys5.PublicKey.from(msg.feedKey)
1364
+ sourceFeed: import_keys4.PublicKey.from(msg.feedKey)
2149
1365
  });
2150
1366
  timer.end();
2151
1367
  if (!result) {
2152
- import_log10.log.warn("processing failed", {
1368
+ import_log7.log.warn("processing failed", {
2153
1369
  msg
2154
1370
  }, {
2155
- F: __dxlog_file10,
1371
+ F: __dxlog_file7,
2156
1372
  L: 185,
2157
1373
  S: this,
2158
1374
  C: (f, a) => f(...a)
@@ -2164,14 +1380,14 @@ var ControlPipeline = class {
2164
1380
  }
2165
1381
  }
2166
1382
  async _noteTargetStateIfNeeded(timeframe) {
2167
- if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2) {
1383
+ if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL) {
2168
1384
  this._lastTimeframeSaveTime = Date.now();
2169
1385
  await this._saveTargetTimeframe(timeframe);
2170
1386
  }
2171
1387
  }
2172
1388
  async stop() {
2173
- (0, import_log10.log)("stopping...", void 0, {
2174
- F: __dxlog_file10,
1389
+ (0, import_log7.log)("stopping...", void 0, {
1390
+ F: __dxlog_file7,
2175
1391
  L: 205,
2176
1392
  S: this,
2177
1393
  C: (f, a) => f(...a)
@@ -2179,8 +1395,8 @@ var ControlPipeline = class {
2179
1395
  await this._ctx.dispose();
2180
1396
  await this._pipeline.stop();
2181
1397
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
2182
- (0, import_log10.log)("stopped", void 0, {
2183
- F: __dxlog_file10,
1398
+ (0, import_log7.log)("stopped", void 0, {
1399
+ F: __dxlog_file7,
2184
1400
  L: 209,
2185
1401
  S: this,
2186
1402
  C: (f, a) => f(...a)
@@ -2188,12 +1404,12 @@ var ControlPipeline = class {
2188
1404
  }
2189
1405
  async _saveTargetTimeframe(timeframe) {
2190
1406
  try {
2191
- const newTimeframe = import_timeframe4.Timeframe.merge(this._targetTimeframe ?? new import_timeframe4.Timeframe(), timeframe);
1407
+ const newTimeframe = import_timeframe3.Timeframe.merge(this._targetTimeframe ?? new import_timeframe3.Timeframe(), timeframe);
2192
1408
  await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
2193
1409
  this._targetTimeframe = newTimeframe;
2194
1410
  } catch (err) {
2195
- (0, import_log10.log)(err, void 0, {
2196
- F: __dxlog_file10,
1411
+ (0, import_log7.log)(err, void 0, {
1412
+ F: __dxlog_file7,
2197
1413
  L: 218,
2198
1414
  S: this,
2199
1415
  C: (f, a) => f(...a)
@@ -2201,28 +1417,28 @@ var ControlPipeline = class {
2201
1417
  }
2202
1418
  }
2203
1419
  };
2204
- _ts_decorate5([
2205
- import_tracing3.trace.metricsCounter()
1420
+ _ts_decorate4([
1421
+ import_tracing2.trace.metricsCounter()
2206
1422
  ], ControlPipeline.prototype, "_usage", void 0);
2207
- _ts_decorate5([
2208
- import_tracing3.trace.metricsCounter()
1423
+ _ts_decorate4([
1424
+ import_tracing2.trace.metricsCounter()
2209
1425
  ], ControlPipeline.prototype, "_mutations", void 0);
2210
- _ts_decorate5([
2211
- import_tracing3.trace.span({
1426
+ _ts_decorate4([
1427
+ import_tracing2.trace.span({
2212
1428
  showInBrowserTimeline: true
2213
1429
  })
2214
1430
  ], ControlPipeline.prototype, "start", null);
2215
- _ts_decorate5([
2216
- import_tracing3.trace.span()
1431
+ _ts_decorate4([
1432
+ import_tracing2.trace.span()
2217
1433
  ], ControlPipeline.prototype, "_consumePipeline", null);
2218
- _ts_decorate5([
2219
- import_tracing3.trace.span()
1434
+ _ts_decorate4([
1435
+ import_tracing2.trace.span()
2220
1436
  ], ControlPipeline.prototype, "_processMessage", null);
2221
- ControlPipeline = _ts_decorate5([
2222
- import_tracing3.trace.resource(),
2223
- (0, import_async8.trackLeaks)("start", "stop")
1437
+ ControlPipeline = _ts_decorate4([
1438
+ import_tracing2.trace.resource(),
1439
+ (0, import_async6.trackLeaks)("start", "stop")
2224
1440
  ], ControlPipeline);
2225
- function _ts_decorate6(decorators, target, key, desc) {
1441
+ function _ts_decorate5(decorators, target, key, desc) {
2226
1442
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2227
1443
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2228
1444
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2232,16 +1448,16 @@ function _ts_decorate6(decorators, target, key, desc) {
2232
1448
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2233
1449
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2234
1450
  }
2235
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
1451
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
2236
1452
  var Space = class {
2237
1453
  constructor(params) {
2238
- this._addFeedMutex = new import_async7.Mutex();
2239
- this.onCredentialProcessed = new import_util6.Callback();
2240
- this.stateUpdate = new import_async7.Event();
1454
+ this._addFeedMutex = new import_async5.Mutex();
1455
+ this.onCredentialProcessed = new import_util3.Callback();
1456
+ this.stateUpdate = new import_async5.Event();
2241
1457
  this._isOpen = false;
2242
- (0, import_invariant9.invariant)(params.spaceKey && params.feedProvider, void 0, {
2243
- F: __dxlog_file11,
2244
- L: 78,
1458
+ (0, import_invariant6.invariant)(params.spaceKey && params.feedProvider, void 0, {
1459
+ F: __dxlog_file8,
1460
+ L: 72,
2245
1461
  S: this,
2246
1462
  A: [
2247
1463
  "params.spaceKey && params.feedProvider",
@@ -2259,18 +1475,7 @@ var Space = class {
2259
1475
  metadataStore: params.metadataStore
2260
1476
  });
2261
1477
  this._controlPipeline.onFeedAdmitted.set(async (info) => {
2262
- const sparse = info.assertion.designation === import_credentials2.AdmittedFeed.Designation.DATA;
2263
- if (info.assertion.designation === import_credentials2.AdmittedFeed.Designation.DATA) {
2264
- queueMicrotask(async () => {
2265
- if (this._dataPipeline.pipeline) {
2266
- if (!this._dataPipeline.pipeline.hasFeed(info.key)) {
2267
- return this._dataPipeline.pipeline.addFeed(await this._feedProvider(info.key, {
2268
- sparse
2269
- }));
2270
- }
2271
- }
2272
- });
2273
- }
1478
+ const sparse = info.assertion.designation === import_credentials.AdmittedFeed.Designation.DATA;
2274
1479
  if (!info.key.equals(params.genesisFeed.key)) {
2275
1480
  queueMicrotask(async () => {
2276
1481
  this.protocol.addFeed(await params.feedProvider(info.key, {
@@ -2281,11 +1486,11 @@ var Space = class {
2281
1486
  });
2282
1487
  this._controlPipeline.onCredentialProcessed.set(async (credential) => {
2283
1488
  await this.onCredentialProcessed.callIfSet(credential);
2284
- (0, import_log9.log)("onCredentialProcessed", {
1489
+ (0, import_log6.log)("onCredentialProcessed", {
2285
1490
  credential
2286
1491
  }, {
2287
- F: __dxlog_file11,
2288
- L: 116,
1492
+ F: __dxlog_file8,
1493
+ L: 99,
2289
1494
  S: this,
2290
1495
  C: (f, a) => f(...a)
2291
1496
  });
@@ -2293,29 +1498,6 @@ var Space = class {
2293
1498
  });
2294
1499
  this.protocol = params.protocol;
2295
1500
  this.protocol.addFeed(params.genesisFeed);
2296
- this._dataPipeline = new DataPipeline({
2297
- modelFactory: params.modelFactory,
2298
- metadataStore: params.metadataStore,
2299
- snapshotManager: params.snapshotManager,
2300
- memberKey: params.memberKey,
2301
- spaceKey: this._key,
2302
- feedInfoProvider: (feedKey) => this._controlPipeline.spaceState.feeds.get(feedKey),
2303
- snapshotId: params.snapshotId,
2304
- onPipelineCreated: async (pipeline) => {
2305
- if (this._dataFeed) {
2306
- pipeline.setWriteFeed(this._dataFeed);
2307
- }
2308
- await this._addFeedMutex.executeSynchronized(async () => {
2309
- for (const feed of this._controlPipeline.spaceState.feeds.values()) {
2310
- if (feed.assertion.designation === import_credentials2.AdmittedFeed.Designation.DATA && !pipeline.hasFeed(feed.key)) {
2311
- await pipeline.addFeed(await this._feedProvider(feed.key, {
2312
- sparse: true
2313
- }));
2314
- }
2315
- }
2316
- });
2317
- }
2318
- });
2319
1501
  }
2320
1502
  get key() {
2321
1503
  return this._key;
@@ -2341,16 +1523,13 @@ var Space = class {
2341
1523
  get controlPipeline() {
2342
1524
  return this._controlPipeline.pipeline;
2343
1525
  }
2344
- get dataPipeline() {
2345
- return this._dataPipeline;
2346
- }
2347
1526
  get snapshotManager() {
2348
1527
  return this._snapshotManager;
2349
1528
  }
2350
1529
  async setControlFeed(feed) {
2351
- (0, import_invariant9.invariant)(!this._controlFeed, "Control feed already set.", {
2352
- F: __dxlog_file11,
2353
- L: 191,
1530
+ (0, import_invariant6.invariant)(!this._controlFeed, "Control feed already set.", {
1531
+ F: __dxlog_file8,
1532
+ L: 146,
2354
1533
  S: this,
2355
1534
  A: [
2356
1535
  "!this._controlFeed",
@@ -2362,9 +1541,9 @@ var Space = class {
2362
1541
  return this;
2363
1542
  }
2364
1543
  async setDataFeed(feed) {
2365
- (0, import_invariant9.invariant)(!this._dataFeed, "Data feed already set.", {
2366
- F: __dxlog_file11,
2367
- L: 198,
1544
+ (0, import_invariant6.invariant)(!this._dataFeed, "Data feed already set.", {
1545
+ F: __dxlog_file8,
1546
+ L: 153,
2368
1547
  S: this,
2369
1548
  A: [
2370
1549
  "!this._dataFeed",
@@ -2372,8 +1551,6 @@ var Space = class {
2372
1551
  ]
2373
1552
  });
2374
1553
  this._dataFeed = feed;
2375
- await this._dataPipeline.pipeline?.addFeed(feed);
2376
- this._dataPipeline.pipeline?.setWriteFeed(feed);
2377
1554
  return this;
2378
1555
  }
2379
1556
  /**
@@ -2389,9 +1566,9 @@ var Space = class {
2389
1566
  // return this._dataPipeline?.getFeeds();
2390
1567
  // }
2391
1568
  async open(ctx) {
2392
- (0, import_log9.log)("opening...", void 0, {
2393
- F: __dxlog_file11,
2394
- L: 221,
1569
+ (0, import_log6.log)("opening...", void 0, {
1570
+ F: __dxlog_file8,
1571
+ L: 174,
2395
1572
  S: this,
2396
1573
  C: (f, a) => f(...a)
2397
1574
  });
@@ -2400,86 +1577,59 @@ var Space = class {
2400
1577
  }
2401
1578
  await this._controlPipeline.start();
2402
1579
  await this.protocol.start();
2403
- await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
2404
1580
  this._isOpen = true;
2405
- (0, import_log9.log)("opened", void 0, {
2406
- F: __dxlog_file11,
2407
- L: 232,
1581
+ (0, import_log6.log)("opened", void 0, {
1582
+ F: __dxlog_file8,
1583
+ L: 184,
2408
1584
  S: this,
2409
1585
  C: (f, a) => f(...a)
2410
1586
  });
2411
1587
  }
2412
1588
  async close() {
2413
- (0, import_log9.log)("closing...", {
1589
+ (0, import_log6.log)("closing...", {
2414
1590
  key: this._key
2415
1591
  }, {
2416
- F: __dxlog_file11,
2417
- L: 237,
1592
+ F: __dxlog_file8,
1593
+ L: 189,
2418
1594
  S: this,
2419
1595
  C: (f, a) => f(...a)
2420
1596
  });
2421
1597
  if (!this._isOpen) {
2422
1598
  return;
2423
1599
  }
2424
- await this._controlPipeline.spaceState.removeCredentialProcessor(this._dataPipeline);
2425
- await this._dataPipeline.close();
2426
1600
  await this.protocol.stop();
2427
1601
  await this._controlPipeline.stop();
2428
1602
  this._isOpen = false;
2429
- (0, import_log9.log)("closed", void 0, {
2430
- F: __dxlog_file11,
2431
- L: 250,
2432
- S: this,
2433
- C: (f, a) => f(...a)
2434
- });
2435
- }
2436
- async initializeDataPipeline() {
2437
- (0, import_log9.log)("initializeDataPipeline", void 0, {
2438
- F: __dxlog_file11,
2439
- L: 255,
1603
+ (0, import_log6.log)("closed", void 0, {
1604
+ F: __dxlog_file8,
1605
+ L: 199,
2440
1606
  S: this,
2441
1607
  C: (f, a) => f(...a)
2442
1608
  });
2443
- (0, import_invariant9.invariant)(this._isOpen, "Space must be open to initialize data pipeline.", {
2444
- F: __dxlog_file11,
2445
- L: 256,
2446
- S: this,
2447
- A: [
2448
- "this._isOpen",
2449
- "'Space must be open to initialize data pipeline.'"
2450
- ]
2451
- });
2452
- await this._dataPipeline.open();
2453
1609
  }
2454
1610
  };
2455
- _ts_decorate6([
2456
- import_tracing2.trace.info()
1611
+ _ts_decorate5([
1612
+ import_tracing.trace.info()
2457
1613
  ], Space.prototype, "protocol", void 0);
2458
- _ts_decorate6([
2459
- import_tracing2.trace.info()
1614
+ _ts_decorate5([
1615
+ import_tracing.trace.info()
2460
1616
  ], Space.prototype, "_controlPipeline", void 0);
2461
- _ts_decorate6([
2462
- import_tracing2.trace.info()
2463
- ], Space.prototype, "_dataPipeline", void 0);
2464
- _ts_decorate6([
2465
- import_log9.logInfo,
2466
- import_tracing2.trace.info()
1617
+ _ts_decorate5([
1618
+ import_log6.logInfo,
1619
+ import_tracing.trace.info()
2467
1620
  ], Space.prototype, "key", null);
2468
- _ts_decorate6([
2469
- import_async7.synchronized,
2470
- import_tracing2.trace.span()
1621
+ _ts_decorate5([
1622
+ import_async5.synchronized,
1623
+ import_tracing.trace.span()
2471
1624
  ], Space.prototype, "open", null);
2472
- _ts_decorate6([
2473
- import_async7.synchronized
1625
+ _ts_decorate5([
1626
+ import_async5.synchronized
2474
1627
  ], Space.prototype, "close", null);
2475
- _ts_decorate6([
2476
- import_async7.synchronized
2477
- ], Space.prototype, "initializeDataPipeline", null);
2478
- Space = _ts_decorate6([
2479
- (0, import_async7.trackLeaks)("open", "close"),
2480
- import_tracing2.trace.resource()
1628
+ Space = _ts_decorate5([
1629
+ (0, import_async5.trackLeaks)("open", "close"),
1630
+ import_tracing.trace.resource()
2481
1631
  ], Space);
2482
- function _ts_decorate7(decorators, target, key, desc) {
1632
+ function _ts_decorate6(decorators, target, key, desc) {
2483
1633
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2484
1634
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2485
1635
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2489,13 +1639,13 @@ function _ts_decorate7(decorators, target, key, desc) {
2489
1639
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2490
1640
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2491
1641
  }
2492
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
1642
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
2493
1643
  var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
2494
1644
  var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
2495
1645
  var SpaceProtocol = class {
2496
1646
  constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore }) {
2497
1647
  this._feeds = /* @__PURE__ */ new Set();
2498
- this._sessions = new import_util8.ComplexMap(import_keys6.PublicKey.hash);
1648
+ this._sessions = new import_util5.ComplexMap(import_keys5.PublicKey.hash);
2499
1649
  this._spaceKey = topic;
2500
1650
  this._networkManager = networkManager;
2501
1651
  this._swarmIdentity = swarmIdentity;
@@ -2504,7 +1654,7 @@ var SpaceProtocol = class {
2504
1654
  this.blobSync = new import_teleport_extension_object_sync.BlobSync({
2505
1655
  blobStore
2506
1656
  });
2507
- this._topic = import_crypto3.subtleCrypto.digest("SHA-256", topic.asBuffer()).then(import_crypto3.discoveryKey).then(import_keys6.PublicKey.from);
1657
+ this._topic = import_crypto3.subtleCrypto.digest("SHA-256", topic.asBuffer()).then(import_crypto3.discoveryKey).then(import_keys5.PublicKey.from);
2508
1658
  }
2509
1659
  get sessions() {
2510
1660
  return this._sessions;
@@ -2517,10 +1667,10 @@ var SpaceProtocol = class {
2517
1667
  }
2518
1668
  // TODO(burdon): Create abstraction for Space (e.g., add keys and have provider).
2519
1669
  addFeed(feed) {
2520
- (0, import_log11.log)("addFeed", {
1670
+ (0, import_log8.log)("addFeed", {
2521
1671
  key: feed.key
2522
1672
  }, {
2523
- F: __dxlog_file12,
1673
+ F: __dxlog_file9,
2524
1674
  L: 103,
2525
1675
  S: this,
2526
1676
  C: (f, a) => f(...a)
@@ -2542,8 +1692,8 @@ var SpaceProtocol = class {
2542
1692
  sampleSize: 20
2543
1693
  };
2544
1694
  await this.blobSync.open();
2545
- (0, import_log11.log)("starting...", void 0, {
2546
- F: __dxlog_file12,
1695
+ (0, import_log8.log)("starting...", void 0, {
1696
+ F: __dxlog_file9,
2547
1697
  L: 129,
2548
1698
  S: this,
2549
1699
  C: (f, a) => f(...a)
@@ -2556,8 +1706,8 @@ var SpaceProtocol = class {
2556
1706
  topology: new import_network_manager.MMSTTopology(topologyConfig),
2557
1707
  label: `swarm ${topic.truncate()} for space ${this._spaceKey.truncate()}`
2558
1708
  });
2559
- (0, import_log11.log)("started", void 0, {
2560
- F: __dxlog_file12,
1709
+ (0, import_log8.log)("started", void 0, {
1710
+ F: __dxlog_file9,
2561
1711
  L: 139,
2562
1712
  S: this,
2563
1713
  C: (f, a) => f(...a)
@@ -2566,15 +1716,15 @@ var SpaceProtocol = class {
2566
1716
  async stop() {
2567
1717
  await this.blobSync.close();
2568
1718
  if (this._connection) {
2569
- (0, import_log11.log)("stopping...", void 0, {
2570
- F: __dxlog_file12,
1719
+ (0, import_log8.log)("stopping...", void 0, {
1720
+ F: __dxlog_file9,
2571
1721
  L: 146,
2572
1722
  S: this,
2573
1723
  C: (f, a) => f(...a)
2574
1724
  });
2575
1725
  await this._connection.close();
2576
- (0, import_log11.log)("stopped", void 0, {
2577
- F: __dxlog_file12,
1726
+ (0, import_log8.log)("stopped", void 0, {
1727
+ F: __dxlog_file9,
2578
1728
  L: 148,
2579
1729
  S: this,
2580
1730
  C: (f, a) => f(...a)
@@ -2598,18 +1748,18 @@ var SpaceProtocol = class {
2598
1748
  };
2599
1749
  }
2600
1750
  };
2601
- _ts_decorate7([
2602
- import_log11.logInfo,
2603
- import_tracing4.trace.info()
1751
+ _ts_decorate6([
1752
+ import_log8.logInfo,
1753
+ import_tracing3.trace.info()
2604
1754
  ], SpaceProtocol.prototype, "_topic", void 0);
2605
- _ts_decorate7([
2606
- import_tracing4.trace.info()
1755
+ _ts_decorate6([
1756
+ import_tracing3.trace.info()
2607
1757
  ], SpaceProtocol.prototype, "_spaceKey", void 0);
2608
- _ts_decorate7([
2609
- import_log11.logInfo
1758
+ _ts_decorate6([
1759
+ import_log8.logInfo
2610
1760
  ], SpaceProtocol.prototype, "_ownPeerKey", null);
2611
- SpaceProtocol = _ts_decorate7([
2612
- import_tracing4.trace.resource()
1761
+ SpaceProtocol = _ts_decorate6([
1762
+ import_tracing3.trace.resource()
2613
1763
  ], SpaceProtocol);
2614
1764
  var AuthStatus;
2615
1765
  (function(AuthStatus2) {
@@ -2646,8 +1796,8 @@ var SpaceProtocolSession = class {
2646
1796
  provider: this._swarmIdentity.credentialProvider,
2647
1797
  verifier: this._swarmIdentity.credentialAuthenticator,
2648
1798
  onAuthSuccess: () => {
2649
- (0, import_log11.log)("Peer authenticated", void 0, {
2650
- F: __dxlog_file12,
1799
+ (0, import_log8.log)("Peer authenticated", void 0, {
1800
+ F: __dxlog_file9,
2651
1801
  L: 245,
2652
1802
  S: this,
2653
1803
  C: (f, a) => f(...a)
@@ -2664,8 +1814,8 @@ var SpaceProtocolSession = class {
2664
1814
  this._teleport.addExtension("dxos.mesh.teleport.blobsync", this._blobSync.createExtension());
2665
1815
  }
2666
1816
  async close() {
2667
- (0, import_log11.log)("close", void 0, {
2668
- F: __dxlog_file12,
1817
+ (0, import_log8.log)("close", void 0, {
1818
+ F: __dxlog_file9,
2669
1819
  L: 261,
2670
1820
  S: this,
2671
1821
  C: (f, a) => f(...a)
@@ -2676,13 +1826,13 @@ var SpaceProtocolSession = class {
2676
1826
  await this._teleport.abort();
2677
1827
  }
2678
1828
  };
2679
- _ts_decorate7([
2680
- import_log11.logInfo
1829
+ _ts_decorate6([
1830
+ import_log8.logInfo
2681
1831
  ], SpaceProtocolSession.prototype, "_wireParams", void 0);
2682
- _ts_decorate7([
2683
- import_log11.logInfo
1832
+ _ts_decorate6([
1833
+ import_log8.logInfo
2684
1834
  ], SpaceProtocolSession.prototype, "authStatus", null);
2685
- function _ts_decorate8(decorators, target, key, desc) {
1835
+ function _ts_decorate7(decorators, target, key, desc) {
2686
1836
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2687
1837
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2688
1838
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2692,14 +1842,13 @@ function _ts_decorate8(decorators, target, key, desc) {
2692
1842
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2693
1843
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2694
1844
  }
2695
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
1845
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
2696
1846
  var SpaceManager = class {
2697
- constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
2698
- this._spaces = new import_util9.ComplexMap(import_keys7.PublicKey.hash);
2699
- this._instanceId = import_keys7.PublicKey.random().toHex();
1847
+ constructor({ feedStore, networkManager, metadataStore, snapshotStore, blobStore }) {
1848
+ this._spaces = new import_util6.ComplexMap(import_keys6.PublicKey.hash);
1849
+ this._instanceId = import_keys6.PublicKey.random().toHex();
2700
1850
  this._feedStore = feedStore;
2701
1851
  this._networkManager = networkManager;
2702
- this._modelFactory = modelFactory;
2703
1852
  this._metadataStore = metadataStore;
2704
1853
  this._snapshotStore = snapshotStore;
2705
1854
  this._blobStore = blobStore;
@@ -2716,23 +1865,23 @@ var SpaceManager = class {
2716
1865
  ].map((space) => space.close()));
2717
1866
  }
2718
1867
  async constructSpace({ metadata, swarmIdentity, onAuthorizedConnection, onAuthFailure, memberKey }) {
2719
- import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols7.trace.begin({
1868
+ import_log9.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.begin({
2720
1869
  id: this._instanceId
2721
1870
  }), {
2722
- F: __dxlog_file13,
2723
- L: 100,
1871
+ F: __dxlog_file10,
1872
+ L: 89,
2724
1873
  S: this,
2725
1874
  C: (f, a) => f(...a)
2726
1875
  });
2727
- (0, import_log12.log)("constructing space...", {
1876
+ (0, import_log9.log)("constructing space...", {
2728
1877
  spaceKey: metadata.genesisFeedKey
2729
1878
  }, {
2730
- F: __dxlog_file13,
2731
- L: 101,
1879
+ F: __dxlog_file10,
1880
+ L: 90,
2732
1881
  S: this,
2733
1882
  C: (f, a) => f(...a)
2734
1883
  });
2735
- const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? (0, import_debug4.failUndefined)());
1884
+ const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? (0, import_debug3.failUndefined)());
2736
1885
  const spaceKey = metadata.key;
2737
1886
  const protocol = new SpaceProtocol({
2738
1887
  topic: spaceKey,
@@ -2748,41 +1897,36 @@ var SpaceManager = class {
2748
1897
  protocol,
2749
1898
  genesisFeed,
2750
1899
  feedProvider: (feedKey, opts) => this._feedStore.openFeed(feedKey, opts),
2751
- modelFactory: this._modelFactory,
2752
1900
  metadataStore: this._metadataStore,
2753
1901
  snapshotManager,
2754
1902
  memberKey
2755
1903
  });
2756
1904
  this._spaces.set(space.key, space);
2757
- import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols7.trace.end({
1905
+ import_log9.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.end({
2758
1906
  id: this._instanceId
2759
1907
  }), {
2760
- F: __dxlog_file13,
2761
- L: 129,
1908
+ F: __dxlog_file10,
1909
+ L: 117,
2762
1910
  S: this,
2763
1911
  C: (f, a) => f(...a)
2764
1912
  });
2765
1913
  return space;
2766
1914
  }
2767
1915
  };
2768
- _ts_decorate8([
2769
- import_async9.synchronized
1916
+ _ts_decorate7([
1917
+ import_async7.synchronized
2770
1918
  ], SpaceManager.prototype, "open", null);
2771
- _ts_decorate8([
2772
- import_async9.synchronized
1919
+ _ts_decorate7([
1920
+ import_async7.synchronized
2773
1921
  ], SpaceManager.prototype, "close", null);
2774
- SpaceManager = _ts_decorate8([
2775
- (0, import_async9.trackLeaks)("open", "close")
1922
+ SpaceManager = _ts_decorate7([
1923
+ (0, import_async7.trackLeaks)("open", "close")
2776
1924
  ], SpaceManager);
2777
1925
  // Annotate the CommonJS export names for ESM import in node:
2778
1926
  0 && (module.exports = {
2779
1927
  AuthExtension,
2780
1928
  AuthStatus,
2781
- DataPipeline,
2782
- DataServiceHost,
2783
1929
  DataServiceImpl,
2784
- DataServiceSubscriptions,
2785
- DatabaseHost,
2786
1930
  MOCK_AUTH_PROVIDER,
2787
1931
  MOCK_AUTH_VERIFIER,
2788
1932
  MetadataStore,
@@ -2801,4 +1945,4 @@ SpaceManager = _ts_decorate8([
2801
1945
  startAfter,
2802
1946
  valueEncoding
2803
1947
  });
2804
- //# sourceMappingURL=chunk-U6J2HC4T.cjs.map
1948
+ //# sourceMappingURL=chunk-7VZVCCNF.cjs.map