@dxos/echo-pipeline 0.1.51-main.b442c99 → 0.1.51-main.b7fee56

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.
@@ -121,10 +121,6 @@ var MetadataStore = class {
121
121
  }
122
122
  }
123
123
  _getSpace(spaceKey) {
124
- var _a;
125
- if ((_a = this._metadata.identity) == null ? void 0 : _a.haloSpace.key.equals(spaceKey)) {
126
- return this._metadata.identity.haloSpace;
127
- }
128
124
  const space = this.spaces.find((space2) => space2.key === spaceKey);
129
125
  assert(space, "Space not found");
130
126
  return space;
@@ -135,7 +131,7 @@ var MetadataStore = class {
135
131
  async clear() {
136
132
  log("clearing all metadata", {}, {
137
133
  file: "metadata-store.ts",
138
- line: 136,
134
+ line: 131,
139
135
  scope: this,
140
136
  callSite: (f, a) => f(...a)
141
137
  });
@@ -156,14 +152,10 @@ var MetadataStore = class {
156
152
  ((_c = (_b = this._metadata).spaces) != null ? _c : _b.spaces = []).push(record);
157
153
  await this._save();
158
154
  }
159
- async setSpaceDataLatestTimeframe(spaceKey, timeframe) {
155
+ async setSpaceLatestTimeframe(spaceKey, timeframe) {
160
156
  this._getSpace(spaceKey).dataTimeframe = timeframe;
161
157
  await this._save();
162
158
  }
163
- async setSpaceControlLatestTimeframe(spaceKey, timeframe) {
164
- this._getSpace(spaceKey).controlTimeframe = timeframe;
165
- await this._save();
166
- }
167
159
  async setCache(spaceKey, cache) {
168
160
  this._getSpace(spaceKey).cache = cache;
169
161
  await this._save();
@@ -1048,7 +1040,6 @@ var DataPipeline = class DataPipeline2 {
1048
1040
  this._isOpen = false;
1049
1041
  this._lastTimeframeSaveTime = 0;
1050
1042
  this._lastSnapshotSaveTime = 0;
1051
- this._lastProcessedEpoch = -1;
1052
1043
  this.onNewEpoch = new Event4();
1053
1044
  }
1054
1045
  get isOpen() {
@@ -1072,29 +1063,17 @@ var DataPipeline = class DataPipeline2 {
1072
1063
  if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
1073
1064
  return;
1074
1065
  }
1075
- if (this._isOpen) {
1076
- log9("new epoch", {
1077
- credential
1078
- }, {
1079
- file: "data-pipeline.ts",
1080
- line: 112,
1081
- scope: this,
1082
- callSite: (f, a) => f(...a)
1083
- });
1084
- this.currentEpoch = credential;
1085
- await this._processEpoch(credential.subject.assertion);
1086
- this.onNewEpoch.emit(credential);
1087
- } else {
1088
- log9("searching last epoch", {
1089
- credential
1090
- }, {
1091
- file: "data-pipeline.ts",
1092
- line: 118,
1093
- scope: this,
1094
- callSite: (f, a) => f(...a)
1095
- });
1096
- this.currentEpoch = credential;
1097
- }
1066
+ log9("new epoch", {
1067
+ credential
1068
+ }, {
1069
+ file: "data-pipeline.ts",
1070
+ line: 109,
1071
+ scope: this,
1072
+ callSite: (f, a) => f(...a)
1073
+ });
1074
+ await this._processEpoch(credential.subject.assertion);
1075
+ this.currentEpoch = credential;
1076
+ this.onNewEpoch.emit(credential);
1098
1077
  }
1099
1078
  };
1100
1079
  }
@@ -1133,7 +1112,7 @@ var DataPipeline = class DataPipeline2 {
1133
1112
  }
1134
1113
  log9("close", {}, {
1135
1114
  file: "data-pipeline.ts",
1136
- line: 168,
1115
+ line: 161,
1137
1116
  scope: this,
1138
1117
  callSite: (f, a) => f(...a)
1139
1118
  });
@@ -1148,7 +1127,7 @@ var DataPipeline = class DataPipeline2 {
1148
1127
  } catch (err) {
1149
1128
  log9.catch(err, {}, {
1150
1129
  file: "data-pipeline.ts",
1151
- line: 181,
1130
+ line: 174,
1152
1131
  scope: this,
1153
1132
  callSite: (f, a) => f(...a)
1154
1133
  });
@@ -1158,10 +1137,6 @@ var DataPipeline = class DataPipeline2 {
1158
1137
  await this._params.snapshotManager.close();
1159
1138
  }
1160
1139
  async _consumePipeline() {
1161
- if (this.currentEpoch) {
1162
- await this._processEpoch(this.currentEpoch.subject.assertion);
1163
- this.onNewEpoch.emit(this.currentEpoch);
1164
- }
1165
1140
  assert8(this._pipeline, "Pipeline is not initialized.");
1166
1141
  for await (const msg of this._pipeline.consume()) {
1167
1142
  const { feedKey, seq, data } = msg;
@@ -1170,7 +1145,7 @@ var DataPipeline = class DataPipeline2 {
1170
1145
  seq
1171
1146
  }, {
1172
1147
  file: "data-pipeline.ts",
1173
- line: 198,
1148
+ line: 186,
1174
1149
  scope: this,
1175
1150
  callSite: (f, a) => f(...a)
1176
1151
  });
@@ -1182,7 +1157,7 @@ var DataPipeline = class DataPipeline2 {
1182
1157
  feedKey
1183
1158
  }, {
1184
1159
  file: "data-pipeline.ts",
1185
- line: 204,
1160
+ line: 192,
1186
1161
  scope: this,
1187
1162
  callSite: (f, a) => f(...a)
1188
1163
  });
@@ -1202,7 +1177,7 @@ var DataPipeline = class DataPipeline2 {
1202
1177
  } catch (err) {
1203
1178
  log9.catch(err, {}, {
1204
1179
  file: "data-pipeline.ts",
1205
- line: 222,
1180
+ line: 210,
1206
1181
  scope: this,
1207
1182
  callSite: (f, a) => f(...a)
1208
1183
  });
@@ -1220,7 +1195,7 @@ var DataPipeline = class DataPipeline2 {
1220
1195
  async _saveTargetTimeframe(timeframe) {
1221
1196
  var _a;
1222
1197
  const newTimeframe = Timeframe3.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe3(), timeframe);
1223
- await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
1198
+ await this._params.metadataStore.setSpaceLatestTimeframe(this._params.spaceKey, newTimeframe);
1224
1199
  this._targetTimeframe = newTimeframe;
1225
1200
  }
1226
1201
  async _saveCache() {
@@ -1237,7 +1212,7 @@ var DataPipeline = class DataPipeline2 {
1237
1212
  } catch (err) {
1238
1213
  log9.warn("Failed to cache properties", err, {
1239
1214
  file: "data-pipeline.ts",
1240
- line: 256,
1215
+ line: 244,
1241
1216
  scope: this,
1242
1217
  callSite: (f, a) => f(...a)
1243
1218
  });
@@ -1254,17 +1229,13 @@ var DataPipeline = class DataPipeline2 {
1254
1229
  }
1255
1230
  }
1256
1231
  async _processEpoch(epoch) {
1257
- if (epoch.number <= this._lastProcessedEpoch) {
1258
- return;
1259
- }
1260
- this._lastProcessedEpoch = epoch.number;
1261
1232
  assert8(this._isOpen);
1262
1233
  assert8(this._pipeline);
1263
1234
  log9("Processing epoch", {
1264
1235
  epoch
1265
1236
  }, {
1266
1237
  file: "data-pipeline.ts",
1267
- line: 289,
1238
+ line: 273,
1268
1239
  scope: this,
1269
1240
  callSite: (f, a) => f(...a)
1270
1241
  });
@@ -1274,7 +1245,7 @@ var DataPipeline = class DataPipeline2 {
1274
1245
  }
1275
1246
  log9("restarting pipeline for epoch", {}, {
1276
1247
  file: "data-pipeline.ts",
1277
- line: 297,
1248
+ line: 281,
1278
1249
  scope: this,
1279
1250
  callSite: (f, a) => f(...a)
1280
1251
  });
@@ -1333,15 +1304,10 @@ import { SpaceStateMachine } from "@dxos/credentials";
1333
1304
  import { PublicKey as PublicKey3 } from "@dxos/keys";
1334
1305
  import { log as log10 } from "@dxos/log";
1335
1306
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
1336
- import { Timeframe as Timeframe4 } from "@dxos/timeframe";
1337
1307
  import { Callback } from "@dxos/util";
1338
- var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
1339
1308
  var ControlPipeline = class {
1340
- constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
1341
- this._lastTimeframeSaveTime = Date.now();
1309
+ constructor({ spaceKey, genesisFeed, feedProvider }) {
1342
1310
  this.onFeedAdmitted = new Callback();
1343
- this._spaceKey = spaceKey;
1344
- this._metadata = metadataStore;
1345
1311
  this._pipeline = new Pipeline();
1346
1312
  void this._pipeline.addFeed(genesisFeed);
1347
1313
  this._spaceStateMachine = new SpaceStateMachine(spaceKey);
@@ -1350,7 +1316,7 @@ var ControlPipeline = class {
1350
1316
  key: info.key
1351
1317
  }, {
1352
1318
  file: "control-pipeline.ts",
1353
- line: 51,
1319
+ line: 39,
1354
1320
  scope: this,
1355
1321
  callSite: (f, a) => f(...a)
1356
1322
  });
@@ -1361,7 +1327,7 @@ var ControlPipeline = class {
1361
1327
  } catch (err) {
1362
1328
  log10.catch(err, {}, {
1363
1329
  file: "control-pipeline.ts",
1364
- line: 59,
1330
+ line: 47,
1365
1331
  scope: this,
1366
1332
  callSite: (f, a) => f(...a)
1367
1333
  });
@@ -1384,7 +1350,7 @@ var ControlPipeline = class {
1384
1350
  async start() {
1385
1351
  log10("starting...", {}, {
1386
1352
  file: "control-pipeline.ts",
1387
- line: 83,
1353
+ line: 71,
1388
1354
  scope: this,
1389
1355
  callSite: (f, a) => f(...a)
1390
1356
  });
@@ -1396,7 +1362,7 @@ var ControlPipeline = class {
1396
1362
  seq: msg.seq
1397
1363
  }, {
1398
1364
  file: "control-pipeline.ts",
1399
- line: 88,
1365
+ line: 76,
1400
1366
  scope: this,
1401
1367
  callSite: (f, a) => f(...a)
1402
1368
  });
@@ -1407,18 +1373,16 @@ var ControlPipeline = class {
1407
1373
  msg
1408
1374
  }, {
1409
1375
  file: "control-pipeline.ts",
1410
- line: 95,
1376
+ line: 83,
1411
1377
  scope: this,
1412
1378
  callSite: (f, a) => f(...a)
1413
1379
  });
1414
- } else {
1415
- await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1416
1380
  }
1417
1381
  }
1418
1382
  } catch (err) {
1419
1383
  log10.catch(err, {}, {
1420
1384
  file: "control-pipeline.ts",
1421
- line: 101,
1385
+ line: 87,
1422
1386
  scope: this,
1423
1387
  callSite: (f, a) => f(...a)
1424
1388
  });
@@ -1428,48 +1392,26 @@ var ControlPipeline = class {
1428
1392
  await this._pipeline.start();
1429
1393
  log10("started", {}, {
1430
1394
  file: "control-pipeline.ts",
1431
- line: 107,
1395
+ line: 93,
1432
1396
  scope: this,
1433
1397
  callSite: (f, a) => f(...a)
1434
1398
  });
1435
1399
  }
1436
- async _noteTargetStateIfNeeded(timeframe) {
1437
- if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2) {
1438
- this._lastTimeframeSaveTime = Date.now();
1439
- await this._saveTargetTimeframe(timeframe);
1440
- }
1441
- }
1442
1400
  async stop() {
1443
1401
  log10("stopping...", {}, {
1444
1402
  file: "control-pipeline.ts",
1445
- line: 121,
1403
+ line: 97,
1446
1404
  scope: this,
1447
1405
  callSite: (f, a) => f(...a)
1448
1406
  });
1449
1407
  await this._pipeline.stop();
1450
- await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1451
1408
  log10("stopped", {}, {
1452
1409
  file: "control-pipeline.ts",
1453
- line: 124,
1410
+ line: 99,
1454
1411
  scope: this,
1455
1412
  callSite: (f, a) => f(...a)
1456
1413
  });
1457
1414
  }
1458
- async _saveTargetTimeframe(timeframe) {
1459
- var _a;
1460
- try {
1461
- const newTimeframe = Timeframe4.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe4(), timeframe);
1462
- await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
1463
- this._targetTimeframe = newTimeframe;
1464
- } catch (err) {
1465
- log10(err, {}, {
1466
- file: "control-pipeline.ts",
1467
- line: 133,
1468
- scope: this,
1469
- callSite: (f, a) => f(...a)
1470
- });
1471
- }
1472
- }
1473
1415
  };
1474
1416
 
1475
1417
  // packages/core/echo/echo-pipeline/src/space/space.ts
@@ -1499,8 +1441,7 @@ var Space = class Space2 {
1499
1441
  this._controlPipeline = new ControlPipeline({
1500
1442
  spaceKey: params.spaceKey,
1501
1443
  genesisFeed: params.genesisFeed,
1502
- feedProvider: params.feedProvider,
1503
- metadataStore: params.metadataStore
1444
+ feedProvider: params.feedProvider
1504
1445
  });
1505
1446
  this._controlPipeline.onFeedAdmitted.set(async (info) => {
1506
1447
  if (info.assertion.designation === AdmittedFeed2.Designation.DATA) {
@@ -1522,7 +1463,7 @@ var Space = class Space2 {
1522
1463
  credential
1523
1464
  }, {
1524
1465
  file: "space.ts",
1525
- line: 107,
1466
+ line: 106,
1526
1467
  scope: this,
1527
1468
  callSite: (f, a) => f(...a)
1528
1469
  });
@@ -1612,7 +1553,7 @@ var Space = class Space2 {
1612
1553
  async open() {
1613
1554
  log11("opening...", {}, {
1614
1555
  file: "space.ts",
1615
- line: 209,
1556
+ line: 208,
1616
1557
  scope: this,
1617
1558
  callSite: (f, a) => f(...a)
1618
1559
  });
@@ -1622,11 +1563,10 @@ var Space = class Space2 {
1622
1563
  await this._controlPipeline.start();
1623
1564
  await this.protocol.start();
1624
1565
  this._dataPipelineCredentialConsumer = this._controlPipeline.spaceState.registerProcessor(this._dataPipeline.createCredentialProcessor());
1625
- await this._dataPipelineCredentialConsumer.open();
1626
1566
  this._isOpen = true;
1627
1567
  log11("opened", {}, {
1628
1568
  file: "space.ts",
1629
- line: 225,
1569
+ line: 222,
1630
1570
  scope: this,
1631
1571
  callSite: (f, a) => f(...a)
1632
1572
  });
@@ -1637,7 +1577,7 @@ var Space = class Space2 {
1637
1577
  key: this._key
1638
1578
  }, {
1639
1579
  file: "space.ts",
1640
- line: 230,
1580
+ line: 227,
1641
1581
  scope: this,
1642
1582
  callSite: (f, a) => f(...a)
1643
1583
  });
@@ -1652,7 +1592,7 @@ var Space = class Space2 {
1652
1592
  this._isOpen = false;
1653
1593
  log11("closed", {}, {
1654
1594
  file: "space.ts",
1655
- line: 244,
1595
+ line: 241,
1656
1596
  scope: this,
1657
1597
  callSite: (f, a) => f(...a)
1658
1598
  });
@@ -1660,12 +1600,14 @@ var Space = class Space2 {
1660
1600
  async initializeDataPipeline() {
1661
1601
  log11("initializeDataPipeline", {}, {
1662
1602
  file: "space.ts",
1663
- line: 249,
1603
+ line: 246,
1664
1604
  scope: this,
1665
1605
  callSite: (f, a) => f(...a)
1666
1606
  });
1667
1607
  assert9(this._isOpen, "Space must be open to initialize data pipeline.");
1668
1608
  await this._dataPipeline.open();
1609
+ assert9(this._dataPipelineCredentialConsumer);
1610
+ await this._dataPipelineCredentialConsumer.open();
1669
1611
  }
1670
1612
  };
1671
1613
  __decorate6([
@@ -1992,4 +1934,4 @@ export {
1992
1934
  SpaceProtocolSession,
1993
1935
  SpaceManager
1994
1936
  };
1995
- //# sourceMappingURL=chunk-NNHUIDTY.mjs.map
1937
+ //# sourceMappingURL=chunk-CSFWTLPD.mjs.map