@dxos/client-services 0.1.50 → 0.1.51-main.04cd027

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 (30) hide show
  1. package/dist/lib/browser/{chunk-BAHSFG33.mjs → chunk-ARBZHWMK.mjs} +126 -74
  2. package/dist/lib/browser/chunk-ARBZHWMK.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/packlets/testing/index.mjs +1 -1
  6. package/dist/lib/node/index.cjs +139 -87
  7. package/dist/lib/node/index.cjs.map +3 -3
  8. package/dist/lib/node/meta.json +1 -1
  9. package/dist/lib/node/packlets/testing/index.cjs +156 -104
  10. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  11. package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
  12. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  13. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  14. package/dist/types/src/packlets/logging/logging-service.d.ts +1 -1
  15. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  16. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  17. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  18. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  19. package/package.json +30 -30
  20. package/src/packlets/devtools/feeds.ts +1 -0
  21. package/src/packlets/identity/identity-manager.ts +4 -1
  22. package/src/packlets/identity/identity.test.ts +9 -3
  23. package/src/packlets/invitations/invitations-handler.ts +14 -6
  24. package/src/packlets/invitations/space-invitation-protocol.test.ts +8 -1
  25. package/src/packlets/logging/logging-service.ts +58 -15
  26. package/src/packlets/spaces/data-space-manager.test.ts +64 -1
  27. package/src/packlets/spaces/data-space-manager.ts +2 -1
  28. package/src/packlets/spaces/data-space.ts +8 -3
  29. package/src/packlets/spaces/spaces-service.ts +7 -0
  30. package/dist/lib/browser/chunk-BAHSFG33.mjs.map +0 -7
@@ -20,11 +20,15 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
20
20
  }
21
21
  });
22
22
  next({
23
- feeds: Array.from(feedMap.values()).map((feed) => ({
24
- feedKey: feed.key,
25
- length: feed.properties.length,
26
- bytes: feed.core.byteLength
27
- }))
23
+ feeds: Array.from(feedMap.values()).map((feed) => {
24
+ var _a, _b;
25
+ return {
26
+ feedKey: feed.key,
27
+ length: feed.properties.length,
28
+ bytes: feed.core.byteLength,
29
+ downloaded: (_b = (_a = feed.core.bitfield) == null ? void 0 : _a.data.toBuffer()) != null ? _b : new Uint8Array()
30
+ };
31
+ })
28
32
  });
29
33
  };
30
34
  subscriptions.add(feedStore.feedOpened.on(update));
@@ -800,7 +804,8 @@ var IdentityManager = class {
800
804
  });
801
805
  assert2(identityRecord.haloSpace.dataFeedKey);
802
806
  const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
803
- writable: true
807
+ writable: true,
808
+ sparse: true
804
809
  });
805
810
  const space = await this._constructSpace({
806
811
  spaceRecord: identityRecord.haloSpace,
@@ -823,7 +828,7 @@ var IdentityManager = class {
823
828
  identityKey: identityRecord.identityKey
824
829
  }, {
825
830
  file: "identity-manager.ts",
826
- line: 223,
831
+ line: 226,
827
832
  scope: this,
828
833
  callSite: (f, a) => f(...a)
829
834
  });
@@ -844,7 +849,7 @@ var IdentityManager = class {
844
849
  onAuthFailure: () => {
845
850
  log3.warn("auth failure", {}, {
846
851
  file: "identity-manager.ts",
847
- line: 242,
852
+ line: 245,
848
853
  scope: this,
849
854
  callSite: (f, a) => f(...a)
850
855
  });
@@ -969,8 +974,8 @@ var DeviceInvitationProtocol = class {
969
974
 
970
975
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
971
976
  import assert6 from "@dxos/node-std/assert";
972
- import { PushStream, scheduleTask as scheduleTask2, sleep, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
973
- import { AuthenticatingInvitationObservable, AUTHENTICATION_CODE_LENGTH, CancellableInvitationObservable, INVITATION_TIMEOUT, ON_CLOSE_DELAY } from "@dxos/client-protocol";
977
+ import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
978
+ import { AuthenticatingInvitationObservable, AUTHENTICATION_CODE_LENGTH, CancellableInvitationObservable, INVITATION_TIMEOUT } from "@dxos/client-protocol";
974
979
  import { Context as Context4 } from "@dxos/context";
975
980
  import { generatePasscode } from "@dxos/credentials";
976
981
  import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2 } from "@dxos/errors";
@@ -1326,7 +1331,7 @@ var InvitationsHandler = class {
1326
1331
  ...protocol.toJSON()
1327
1332
  }, {
1328
1333
  file: "invitations-handler.ts",
1329
- line: 100,
1334
+ line: 99,
1330
1335
  scope: this,
1331
1336
  callSite: (f, a) => f(...a)
1332
1337
  });
@@ -1367,7 +1372,7 @@ var InvitationsHandler = class {
1367
1372
  id: traceId
1368
1373
  }), {
1369
1374
  file: "invitations-handler.ts",
1370
- line: 139,
1375
+ line: 138,
1371
1376
  scope: this,
1372
1377
  callSite: (f, a) => f(...a)
1373
1378
  });
@@ -1375,7 +1380,7 @@ var InvitationsHandler = class {
1375
1380
  ...protocol.toJSON()
1376
1381
  }, {
1377
1382
  file: "invitations-handler.ts",
1378
- line: 140,
1383
+ line: 139,
1379
1384
  scope: this,
1380
1385
  callSite: (f, a) => f(...a)
1381
1386
  });
@@ -1391,7 +1396,7 @@ var InvitationsHandler = class {
1391
1396
  ...protocol.toJSON()
1392
1397
  }, {
1393
1398
  file: "invitations-handler.ts",
1394
- line: 143,
1399
+ line: 142,
1395
1400
  scope: this,
1396
1401
  callSite: (f, a) => f(...a)
1397
1402
  });
@@ -1403,7 +1408,7 @@ var InvitationsHandler = class {
1403
1408
  id: traceId
1404
1409
  }), {
1405
1410
  file: "invitations-handler.ts",
1406
- line: 145,
1411
+ line: 144,
1407
1412
  scope: this,
1408
1413
  callSite: (f, a) => f(...a)
1409
1414
  });
@@ -1413,7 +1418,7 @@ var InvitationsHandler = class {
1413
1418
  ...protocol.toJSON()
1414
1419
  }, {
1415
1420
  file: "invitations-handler.ts",
1416
- line: 148,
1421
+ line: 147,
1417
1422
  scope: this,
1418
1423
  callSite: (f, a) => f(...a)
1419
1424
  });
@@ -1424,7 +1429,7 @@ var InvitationsHandler = class {
1424
1429
  } else {
1425
1430
  log5.error("failed", err, {
1426
1431
  file: "invitations-handler.ts",
1427
- line: 151,
1432
+ line: 150,
1428
1433
  scope: this,
1429
1434
  callSite: (f, a) => f(...a)
1430
1435
  });
@@ -1435,13 +1440,13 @@ var InvitationsHandler = class {
1435
1440
  error: err
1436
1441
  }), {
1437
1442
  file: "invitations-handler.ts",
1438
- line: 154,
1443
+ line: 153,
1439
1444
  scope: this,
1440
1445
  callSite: (f, a) => f(...a)
1441
1446
  });
1442
1447
  } finally {
1443
1448
  if (type !== Invitation3.Type.MULTIUSE) {
1444
- await sleep(ON_CLOSE_DELAY);
1449
+ await swarmConnection.close();
1445
1450
  await ctx.dispose();
1446
1451
  }
1447
1452
  }
@@ -1477,9 +1482,10 @@ var InvitationsHandler = class {
1477
1482
  });
1478
1483
  return extension;
1479
1484
  };
1485
+ let swarmConnection;
1480
1486
  scheduleTask2(ctx, async () => {
1481
1487
  const topic = invitation.swarmKey;
1482
- const swarmConnection = await this._networkManager.joinSwarm({
1488
+ swarmConnection = await this._networkManager.joinSwarm({
1483
1489
  topic,
1484
1490
  peerId: topic,
1485
1491
  protocolProvider: createTeleportProtocolFactory(async (teleport) => {
@@ -1510,6 +1516,7 @@ var InvitationsHandler = class {
1510
1516
  const { timeout = INVITATION_TIMEOUT } = invitation;
1511
1517
  assert6(protocol);
1512
1518
  const authenticated = new Trigger3();
1519
+ let admitted = false;
1513
1520
  let currentState;
1514
1521
  const stream = new PushStream();
1515
1522
  const setState = (newData) => {
@@ -1527,7 +1534,7 @@ var InvitationsHandler = class {
1527
1534
  ...protocol.toJSON()
1528
1535
  }, {
1529
1536
  file: "invitations-handler.ts",
1530
- line: 225,
1537
+ line: 230,
1531
1538
  scope: this,
1532
1539
  callSite: (f, a) => f(...a)
1533
1540
  });
@@ -1537,7 +1544,7 @@ var InvitationsHandler = class {
1537
1544
  } else {
1538
1545
  log5.warn("auth failed", err, {
1539
1546
  file: "invitations-handler.ts",
1540
- line: 228,
1547
+ line: 233,
1541
1548
  scope: this,
1542
1549
  callSite: (f, a) => f(...a)
1543
1550
  });
@@ -1551,7 +1558,7 @@ var InvitationsHandler = class {
1551
1558
  ...protocol.toJSON()
1552
1559
  }, {
1553
1560
  file: "invitations-handler.ts",
1554
- line: 236,
1561
+ line: 241,
1555
1562
  scope: this,
1556
1563
  callSite: (f, a) => f(...a)
1557
1564
  });
@@ -1566,11 +1573,11 @@ var InvitationsHandler = class {
1566
1573
  currentState
1567
1574
  }, {
1568
1575
  file: "invitations-handler.ts",
1569
- line: 246,
1576
+ line: 251,
1570
1577
  scope: this,
1571
1578
  callSite: (f, a) => f(...a)
1572
1579
  });
1573
- if (currentState !== Invitation3.State.SUCCESS) {
1580
+ if (!admitted) {
1574
1581
  stream.error(new Error("Remote peer disconnected."));
1575
1582
  }
1576
1583
  });
@@ -1581,7 +1588,7 @@ var InvitationsHandler = class {
1581
1588
  id: traceId
1582
1589
  }), {
1583
1590
  file: "invitations-handler.ts",
1584
- line: 255,
1591
+ line: 260,
1585
1592
  scope: this,
1586
1593
  callSite: (f, a) => f(...a)
1587
1594
  });
@@ -1593,7 +1600,7 @@ var InvitationsHandler = class {
1593
1600
  ...protocol.toJSON()
1594
1601
  }, {
1595
1602
  file: "invitations-handler.ts",
1596
- line: 263,
1603
+ line: 268,
1597
1604
  scope: this,
1598
1605
  callSite: (f, a) => f(...a)
1599
1606
  });
@@ -1604,7 +1611,7 @@ var InvitationsHandler = class {
1604
1611
  ...protocol.toJSON()
1605
1612
  }, {
1606
1613
  file: "invitations-handler.ts",
1607
- line: 267,
1614
+ line: 272,
1608
1615
  scope: this,
1609
1616
  callSite: (f, a) => f(...a)
1610
1617
  });
@@ -1614,7 +1621,7 @@ var InvitationsHandler = class {
1614
1621
  response: introductionResponse
1615
1622
  }, {
1616
1623
  file: "invitations-handler.ts",
1617
- line: 271,
1624
+ line: 276,
1618
1625
  scope: this,
1619
1626
  callSite: (f, a) => f(...a)
1620
1627
  });
@@ -1626,7 +1633,7 @@ var InvitationsHandler = class {
1626
1633
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1627
1634
  log5("guest waiting for authentication code...", {}, {
1628
1635
  file: "invitations-handler.ts",
1629
- line: 280,
1636
+ line: 285,
1630
1637
  scope: this,
1631
1638
  callSite: (f, a) => f(...a)
1632
1639
  });
@@ -1638,7 +1645,7 @@ var InvitationsHandler = class {
1638
1645
  });
1639
1646
  log5("sending authentication request", {}, {
1640
1647
  file: "invitations-handler.ts",
1641
- line: 284,
1648
+ line: 289,
1642
1649
  scope: this,
1643
1650
  callSite: (f, a) => f(...a)
1644
1651
  });
@@ -1659,7 +1666,7 @@ var InvitationsHandler = class {
1659
1666
  attempt
1660
1667
  }, {
1661
1668
  file: "invitations-handler.ts",
1662
- line: 295,
1669
+ line: 300,
1663
1670
  scope: this,
1664
1671
  callSite: (f, a) => f(...a)
1665
1672
  });
@@ -1676,18 +1683,19 @@ var InvitationsHandler = class {
1676
1683
  ...protocol.toJSON()
1677
1684
  }, {
1678
1685
  file: "invitations-handler.ts",
1679
- line: 306,
1686
+ line: 311,
1680
1687
  scope: this,
1681
1688
  callSite: (f, a) => f(...a)
1682
1689
  });
1683
1690
  const admissionRequest = await protocol.createAdmissionRequest();
1684
1691
  const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
1692
+ admitted = true;
1685
1693
  const result = await protocol.accept(admissionResponse, admissionRequest);
1686
1694
  log5("admitted by host", {
1687
1695
  ...protocol.toJSON()
1688
1696
  }, {
1689
1697
  file: "invitations-handler.ts",
1690
- line: 314,
1698
+ line: 322,
1691
1699
  scope: this,
1692
1700
  callSite: (f, a) => f(...a)
1693
1701
  });
@@ -1699,7 +1707,7 @@ var InvitationsHandler = class {
1699
1707
  id: traceId
1700
1708
  }), {
1701
1709
  file: "invitations-handler.ts",
1702
- line: 316,
1710
+ line: 324,
1703
1711
  scope: this,
1704
1712
  callSite: (f, a) => f(...a)
1705
1713
  });
@@ -1709,7 +1717,7 @@ var InvitationsHandler = class {
1709
1717
  ...protocol.toJSON()
1710
1718
  }, {
1711
1719
  file: "invitations-handler.ts",
1712
- line: 319,
1720
+ line: 327,
1713
1721
  scope: this,
1714
1722
  callSite: (f, a) => f(...a)
1715
1723
  });
@@ -1719,7 +1727,7 @@ var InvitationsHandler = class {
1719
1727
  } else {
1720
1728
  log5("auth failed", err, {
1721
1729
  file: "invitations-handler.ts",
1722
- line: 322,
1730
+ line: 330,
1723
1731
  scope: this,
1724
1732
  callSite: (f, a) => f(...a)
1725
1733
  });
@@ -1730,7 +1738,7 @@ var InvitationsHandler = class {
1730
1738
  error: err
1731
1739
  }), {
1732
1740
  file: "invitations-handler.ts",
1733
- line: 325,
1741
+ line: 333,
1734
1742
  scope: this,
1735
1743
  callSite: (f, a) => f(...a)
1736
1744
  });
@@ -1748,7 +1756,7 @@ var InvitationsHandler = class {
1748
1756
  ...protocol.toJSON()
1749
1757
  }, {
1750
1758
  file: "invitations-handler.ts",
1751
- line: 336,
1759
+ line: 344,
1752
1760
  scope: this,
1753
1761
  callSite: (f, a) => f(...a)
1754
1762
  });
@@ -1758,7 +1766,7 @@ var InvitationsHandler = class {
1758
1766
  } else {
1759
1767
  log5("auth failed", err, {
1760
1768
  file: "invitations-handler.ts",
1761
- line: 339,
1769
+ line: 347,
1762
1770
  scope: this,
1763
1771
  callSite: (f, a) => f(...a)
1764
1772
  });
@@ -2195,11 +2203,12 @@ import { PublicKey as PublicKey7 } from "@dxos/keys";
2195
2203
  import { log as log10 } from "@dxos/log";
2196
2204
  import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
2197
2205
  import { AdmittedFeed as AdmittedFeed3 } from "@dxos/protocols/proto/dxos/halo/credentials";
2206
+ import { Timeframe } from "@dxos/timeframe";
2198
2207
  import { ComplexSet as ComplexSet2 } from "@dxos/util";
2199
2208
 
2200
2209
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2201
2210
  import assert9 from "@dxos/node-std/assert";
2202
- import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep as sleep2, TimeoutError as TimeoutError2, Trigger as Trigger5 } from "@dxos/async";
2211
+ import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger5 } from "@dxos/async";
2203
2212
  import { Context as Context5, rejectOnDispose } from "@dxos/context";
2204
2213
  import { PublicKey as PublicKey6 } from "@dxos/keys";
2205
2214
  import { log as log9 } from "@dxos/log";
@@ -2309,7 +2318,7 @@ var NotarizationPlugin = class {
2309
2318
  scope: this,
2310
2319
  callSite: (f, a) => f(...a)
2311
2320
  });
2312
- await sleep2(successDelay);
2321
+ await sleep(successDelay);
2313
2322
  } catch (err) {
2314
2323
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
2315
2324
  log9.warn("error notarizing (recoverable)", err, {
@@ -2537,7 +2546,7 @@ var DataSpace = class DataSpace2 {
2537
2546
  if (err instanceof CancelledError) {
2538
2547
  log10("Data pipeline initialization cancelled", err, {
2539
2548
  file: "data-space.ts",
2540
- line: 172,
2549
+ line: 173,
2541
2550
  scope: this,
2542
2551
  callSite: (f, a) => f(...a)
2543
2552
  });
@@ -2545,7 +2554,7 @@ var DataSpace = class DataSpace2 {
2545
2554
  }
2546
2555
  log10.error("Error initializing data pipeline", err, {
2547
2556
  file: "data-space.ts",
2548
- line: 176,
2557
+ line: 177,
2549
2558
  scope: this,
2550
2559
  callSite: (f, a) => f(...a)
2551
2560
  });
@@ -2626,7 +2635,8 @@ var DataSpace = class DataSpace2 {
2626
2635
  }
2627
2636
  if (!this.inner.dataFeedKey) {
2628
2637
  const dataFeed = await this._feedStore.openFeed(await this._keyring.createKey(), {
2629
- writable: true
2638
+ writable: true,
2639
+ sparse: true
2630
2640
  });
2631
2641
  this.inner.setDataFeed(dataFeed);
2632
2642
  credentials.push(await this._signingContext.credentialSigner.createCredential({
@@ -2652,7 +2662,7 @@ var DataSpace = class DataSpace2 {
2652
2662
  async createEpoch() {
2653
2663
  var _a, _b;
2654
2664
  const epoch = await this.dataPipeline.createEpoch();
2655
- await this.inner.controlPipeline.writer.write({
2665
+ const receipt = await this.inner.controlPipeline.writer.write({
2656
2666
  credential: {
2657
2667
  credential: await this._signingContext.credentialSigner.createCredential({
2658
2668
  subject: this.key,
@@ -2663,6 +2673,12 @@ var DataSpace = class DataSpace2 {
2663
2673
  })
2664
2674
  }
2665
2675
  });
2676
+ await this.inner.controlPipeline.state.waitUntilTimeframe(new Timeframe([
2677
+ [
2678
+ receipt.feedKey,
2679
+ receipt.seq
2680
+ ]
2681
+ ]));
2666
2682
  for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
2667
2683
  const indexBeforeEpoch = epoch.timeframe.get(feed.key);
2668
2684
  if (indexBeforeEpoch) {
@@ -2694,7 +2710,7 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2 } from "@dxo
2694
2710
  import { createCredential } from "@dxos/credentials";
2695
2711
  import { failUndefined as failUndefined2 } from "@dxos/debug";
2696
2712
  import { AdmittedFeed as AdmittedFeed4, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
2697
- import { Timeframe } from "@dxos/timeframe";
2713
+ import { Timeframe as Timeframe2 } from "@dxos/timeframe";
2698
2714
  var spaceGenesis = async (keyring, signingContext, space) => {
2699
2715
  var _a, _b, _c, _d;
2700
2716
  const credentials = [
@@ -2745,7 +2761,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2745
2761
  "@type": "dxos.halo.credentials.Epoch",
2746
2762
  number: 0,
2747
2763
  previousId: void 0,
2748
- timeframe: new Timeframe(),
2764
+ timeframe: new Timeframe2(),
2749
2765
  snapshotCid: void 0
2750
2766
  }
2751
2767
  })
@@ -2950,7 +2966,8 @@ var DataSpaceManager = class DataSpaceManager2 {
2950
2966
  writable: true
2951
2967
  });
2952
2968
  const dataFeed = metadata.dataFeedKey && await this._feedStore.openFeed(metadata.dataFeedKey, {
2953
- writable: true
2969
+ writable: true,
2970
+ sparse: true
2954
2971
  });
2955
2972
  const space = await this._spaceManager.constructSpace({
2956
2973
  metadata,
@@ -2969,7 +2986,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2969
2986
  onAuthFailure: () => {
2970
2987
  log11.warn("auth failure", {}, {
2971
2988
  file: "data-space-manager.ts",
2972
- line: 212,
2989
+ line: 213,
2973
2990
  scope: this,
2974
2991
  callSite: (f, a) => f(...a)
2975
2992
  });
@@ -2992,7 +3009,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2992
3009
  space: space.key
2993
3010
  }, {
2994
3011
  file: "data-space-manager.ts",
2995
- line: 229,
3012
+ line: 230,
2996
3013
  scope: this,
2997
3014
  callSite: (f, a) => f(...a)
2998
3015
  });
@@ -3004,7 +3021,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3004
3021
  open: this._isOpen
3005
3022
  }, {
3006
3023
  file: "data-space-manager.ts",
3007
- line: 236,
3024
+ line: 237,
3008
3025
  scope: this,
3009
3026
  callSite: (f, a) => f(...a)
3010
3027
  });
@@ -3079,7 +3096,7 @@ var SpacesServiceImpl = class {
3079
3096
  spaces
3080
3097
  }, {
3081
3098
  file: "spaces-service.ts",
3082
- line: 59,
3099
+ line: 60,
3083
3100
  scope: this,
3084
3101
  callSite: (f, a) => f(...a)
3085
3102
  });
@@ -3096,6 +3113,7 @@ var SpacesServiceImpl = class {
3096
3113
  for (const space of dataSpaceManager.spaces.values()) {
3097
3114
  subscriptions.add(space.stateUpdate.on(ctx, onUpdate));
3098
3115
  subscriptions.add(space.presence.updated.on(ctx, onUpdate));
3116
+ subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx, onUpdate));
3099
3117
  space.inner.controlPipeline.state.timeframeUpdate.debounce(TIMEFRAME_UPDATE_DEBOUNCE_TIME).on(ctx, onUpdate);
3100
3118
  if (space.dataPipeline.pipelineState) {
3101
3119
  subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.debounce(TIMEFRAME_UPDATE_DEBOUNCE_TIME).on(ctx, onUpdate));
@@ -3166,20 +3184,23 @@ var SpacesServiceImpl = class {
3166
3184
  await space.createEpoch();
3167
3185
  }
3168
3186
  _transformSpace(space) {
3169
- var _a, _b, _c, _d, _e;
3187
+ var _a, _b, _c, _d, _e, _f, _g;
3170
3188
  return {
3171
3189
  spaceKey: space.key,
3172
3190
  state: space.state,
3173
3191
  error: space.error ? encodeError(space.error) : void 0,
3174
3192
  pipeline: {
3193
+ currentEpoch: space.dataPipeline.currentEpoch,
3194
+ appliedEpoch: space.dataPipeline.appliedEpoch,
3175
3195
  controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
3176
3196
  currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
3177
3197
  targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
3178
3198
  totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
3179
3199
  dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
3180
- currentDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.timeframe,
3181
- targetDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.targetTimeframe,
3182
- totalDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.endTimeframe
3200
+ startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
3201
+ currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
3202
+ targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
3203
+ totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
3183
3204
  },
3184
3205
  members: Array.from(space.inner.spaceState.members.values()).map((member) => {
3185
3206
  var _a2, _b2, _c2;
@@ -3193,6 +3214,7 @@ var SpacesServiceImpl = class {
3193
3214
  presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember2.PresenceState.ONLINE : SpaceMember2.PresenceState.OFFLINE
3194
3215
  };
3195
3216
  }),
3217
+ creator: (_g = space.inner.spaceState.creator) == null ? void 0 : _g.key,
3196
3218
  cache: space.cache,
3197
3219
  metrics: space.metrics
3198
3220
  };
@@ -3554,7 +3576,8 @@ var DevicesServiceImpl = class {
3554
3576
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
3555
3577
  import { Event as Event7 } from "@dxos/async";
3556
3578
  import { Stream as Stream11 } from "@dxos/codec-protobuf";
3557
- import { log as log14, shouldLog, getContextFromEntry } from "@dxos/log";
3579
+ import { getContextFromEntry, log as log14 } from "@dxos/log";
3580
+ import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
3558
3581
  import { jsonify } from "@dxos/util";
3559
3582
  var LoggingServiceImpl = class {
3560
3583
  constructor() {
@@ -3571,31 +3594,60 @@ var LoggingServiceImpl = class {
3571
3594
  log14.runtimeConfig.processors.splice(index, 1);
3572
3595
  }
3573
3596
  queryLogs(request) {
3574
- var _a;
3575
- const filters = ((_a = request.filters) == null ? void 0 : _a.length) ? request.filters : void 0;
3576
3597
  return new Stream11(({ ctx, next }) => {
3577
3598
  const handler = (entry2) => {
3578
- var _a2, _b, _c;
3579
- if (((_a2 = entry2.meta) == null ? void 0 : _a2.file.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
3599
+ var _a, _b, _c, _d, _e;
3600
+ if (LOG_PROCESSING > 0) {
3580
3601
  return;
3581
3602
  }
3582
- if (shouldLog(entry2, filters)) {
3583
- const record = {
3584
- ...entry2,
3585
- context: jsonify(getContextFromEntry(entry2))
3586
- };
3587
- (_b = record.meta) == null ? true : delete _b.bugcheck;
3588
- (_c = record.meta) == null ? true : delete _c.scope;
3603
+ if (((_a = entry2.meta) == null ? void 0 : _a.file.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
3604
+ return;
3605
+ }
3606
+ if (!shouldLog(entry2, request)) {
3607
+ return;
3608
+ }
3609
+ const record = {
3610
+ ...entry2,
3611
+ context: jsonify(getContextFromEntry(entry2)),
3612
+ timestamp: new Date(),
3613
+ meta: {
3614
+ // TODO(dmaretskyi): Fix proto.
3615
+ file: (_c = (_b = entry2.meta) == null ? void 0 : _b.file) != null ? _c : "",
3616
+ line: (_e = (_d = entry2.meta) == null ? void 0 : _d.line) != null ? _e : 0
3617
+ }
3618
+ };
3619
+ try {
3620
+ LOG_PROCESSING++;
3589
3621
  next(record);
3622
+ } finally {
3623
+ LOG_PROCESSING--;
3590
3624
  }
3591
3625
  };
3592
- ctx.onDispose(() => {
3593
- this._logs.off(handler);
3594
- });
3595
- this._logs.on(handler);
3626
+ this._logs.on(ctx, handler);
3627
+ });
3628
+ }
3629
+ };
3630
+ var matchFilter = (filter, level, path, options) => {
3631
+ switch (options) {
3632
+ case QueryLogsRequest.MatchingOptions.INCLUSIVE:
3633
+ return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
3634
+ case QueryLogsRequest.MatchingOptions.EXPLICIT:
3635
+ return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
3636
+ }
3637
+ };
3638
+ var shouldLog = (entry2, request) => {
3639
+ var _a;
3640
+ const options = (_a = request.options) != null ? _a : QueryLogsRequest.MatchingOptions.INCLUSIVE;
3641
+ if (request.filters === void 0) {
3642
+ return options === QueryLogsRequest.MatchingOptions.INCLUSIVE;
3643
+ } else {
3644
+ return request.filters.some((filter) => {
3645
+ var _a2, _b;
3646
+ return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.file) != null ? _b : "", options);
3596
3647
  });
3597
3648
  }
3598
3649
  };
3650
+ var LOG_PROCESSING = 0;
3599
3651
 
3600
3652
  // packages/sdk/client-services/src/packlets/network/network-service.ts
3601
3653
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
@@ -3952,4 +4004,4 @@ export {
3952
4004
  ClientServicesHost,
3953
4005
  LocalClientServices
3954
4006
  };
3955
- //# sourceMappingURL=chunk-BAHSFG33.mjs.map
4007
+ //# sourceMappingURL=chunk-ARBZHWMK.mjs.map