@dxos/echo-pipeline 0.4.7-next.f4b92be → 0.4.8-main.ac78619
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.
- package/dist/lib/browser/{chunk-UIMWNUNO.mjs → chunk-LED7X4WK.mjs} +54 -27
- package/dist/lib/browser/chunk-LED7X4WK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-Z3IT3GUD.cjs → chunk-UKREXVZX.cjs} +59 -32
- package/dist/lib/node/chunk-UKREXVZX.cjs.map +7 -0
- package/dist/lib/node/index.cjs +29 -29
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +16 -16
- package/dist/types/src/metadata/metadata-store.d.ts +6 -2
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-host.ts +1 -1
- package/src/metadata/metadata-store.ts +46 -3
- package/dist/lib/browser/chunk-UIMWNUNO.mjs.map +0 -7
- package/dist/lib/node/chunk-Z3IT3GUD.cjs.map +0 -7
|
@@ -491,7 +491,8 @@ var DataServiceImpl = class {
|
|
|
491
491
|
|
|
492
492
|
// packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
|
|
493
493
|
import CRC32 from "crc-32";
|
|
494
|
-
import {
|
|
494
|
+
import { Event, scheduleTaskInterval, synchronized } from "@dxos/async";
|
|
495
|
+
import { Context as Context2 } from "@dxos/context";
|
|
495
496
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
496
497
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
497
498
|
import { log as log3 } from "@dxos/log";
|
|
@@ -509,6 +510,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
509
510
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
510
511
|
}
|
|
511
512
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
513
|
+
var EXPIRED_INVITATION_CLEANUP_INTERVAL = 60 * 60 * 1e3;
|
|
512
514
|
var emptyEchoMetadata = () => ({
|
|
513
515
|
version: STORAGE_VERSION,
|
|
514
516
|
spaces: [],
|
|
@@ -524,6 +526,7 @@ var MetadataStore = class {
|
|
|
524
526
|
this._spaceLargeMetadata = new ComplexMap3(PublicKey3.hash);
|
|
525
527
|
this._metadataFile = void 0;
|
|
526
528
|
this.update = new Event();
|
|
529
|
+
this._invitationCleanupCtx = new Context2();
|
|
527
530
|
this._directory = directory;
|
|
528
531
|
}
|
|
529
532
|
get metadata() {
|
|
@@ -553,7 +556,7 @@ var MetadataStore = class {
|
|
|
553
556
|
name: file.filename
|
|
554
557
|
}, {
|
|
555
558
|
F: __dxlog_file4,
|
|
556
|
-
L:
|
|
559
|
+
L: 89,
|
|
557
560
|
S: this,
|
|
558
561
|
C: (f, a) => f(...a)
|
|
559
562
|
});
|
|
@@ -589,12 +592,13 @@ var MetadataStore = class {
|
|
|
589
592
|
checksum
|
|
590
593
|
}, {
|
|
591
594
|
F: __dxlog_file4,
|
|
592
|
-
L:
|
|
595
|
+
L: 124,
|
|
593
596
|
S: this,
|
|
594
597
|
C: (f, a) => f(...a)
|
|
595
598
|
});
|
|
596
599
|
}
|
|
597
600
|
async close() {
|
|
601
|
+
await this._invitationCleanupCtx.dispose();
|
|
598
602
|
await this.flush();
|
|
599
603
|
await this._metadataFile?.close();
|
|
600
604
|
this._metadataFile = void 0;
|
|
@@ -621,7 +625,7 @@ var MetadataStore = class {
|
|
|
621
625
|
err
|
|
622
626
|
}, {
|
|
623
627
|
F: __dxlog_file4,
|
|
624
|
-
L:
|
|
628
|
+
L: 156,
|
|
625
629
|
S: this,
|
|
626
630
|
C: (f, a) => f(...a)
|
|
627
631
|
});
|
|
@@ -638,12 +642,19 @@ var MetadataStore = class {
|
|
|
638
642
|
err
|
|
639
643
|
}, {
|
|
640
644
|
F: __dxlog_file4,
|
|
641
|
-
L:
|
|
645
|
+
L: 168,
|
|
642
646
|
S: this,
|
|
643
647
|
C: (f, a) => f(...a)
|
|
644
648
|
});
|
|
645
649
|
}
|
|
646
650
|
});
|
|
651
|
+
scheduleTaskInterval(this._invitationCleanupCtx, async () => {
|
|
652
|
+
for (const invitation of this.getInvitations()) {
|
|
653
|
+
if (invitation.created && invitation.lifetime && invitation.lifetime !== 0 && invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
654
|
+
await this.removeInvitation(invitation.invitationId);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}, EXPIRED_INVITATION_CLEANUP_INTERVAL);
|
|
647
658
|
}
|
|
648
659
|
async _save() {
|
|
649
660
|
const data = {
|
|
@@ -668,7 +679,7 @@ var MetadataStore = class {
|
|
|
668
679
|
err
|
|
669
680
|
}, {
|
|
670
681
|
F: __dxlog_file4,
|
|
671
|
-
L:
|
|
682
|
+
L: 215,
|
|
672
683
|
S: this,
|
|
673
684
|
C: (f, a) => f(...a)
|
|
674
685
|
});
|
|
@@ -689,7 +700,7 @@ var MetadataStore = class {
|
|
|
689
700
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
690
701
|
invariant4(space, "Space not found", {
|
|
691
702
|
F: __dxlog_file4,
|
|
692
|
-
L:
|
|
703
|
+
L: 237,
|
|
693
704
|
S: this,
|
|
694
705
|
A: [
|
|
695
706
|
"space",
|
|
@@ -713,7 +724,7 @@ var MetadataStore = class {
|
|
|
713
724
|
async clear() {
|
|
714
725
|
log3("clearing all metadata", void 0, {
|
|
715
726
|
F: __dxlog_file4,
|
|
716
|
-
L:
|
|
727
|
+
L: 256,
|
|
717
728
|
S: this,
|
|
718
729
|
C: (f, a) => f(...a)
|
|
719
730
|
});
|
|
@@ -726,7 +737,7 @@ var MetadataStore = class {
|
|
|
726
737
|
async setIdentityRecord(record) {
|
|
727
738
|
invariant4(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
|
|
728
739
|
F: __dxlog_file4,
|
|
729
|
-
L:
|
|
740
|
+
L: 266,
|
|
730
741
|
S: this,
|
|
731
742
|
A: [
|
|
732
743
|
"!this._metadata.identity",
|
|
@@ -737,10 +748,26 @@ var MetadataStore = class {
|
|
|
737
748
|
await this._save();
|
|
738
749
|
await this.flush();
|
|
739
750
|
}
|
|
751
|
+
getInvitations() {
|
|
752
|
+
return this._metadata.invitations ?? [];
|
|
753
|
+
}
|
|
754
|
+
async addInvitation(invitation) {
|
|
755
|
+
if (this._metadata.invitations?.find((i) => i.invitationId === invitation.invitationId)) {
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
(this._metadata.invitations ??= []).push(invitation);
|
|
759
|
+
await this._save();
|
|
760
|
+
await this.flush();
|
|
761
|
+
}
|
|
762
|
+
async removeInvitation(invitationId) {
|
|
763
|
+
this._metadata.invitations = (this._metadata.invitations ?? []).filter((i) => i.invitationId !== invitationId);
|
|
764
|
+
await this._save();
|
|
765
|
+
await this.flush();
|
|
766
|
+
}
|
|
740
767
|
async addSpace(record) {
|
|
741
768
|
invariant4(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
742
769
|
F: __dxlog_file4,
|
|
743
|
-
L:
|
|
770
|
+
L: 294,
|
|
744
771
|
S: this,
|
|
745
772
|
A: [
|
|
746
773
|
"!(this._metadata.spaces ?? []).find((space) => space.key === record.key)",
|
|
@@ -895,7 +922,7 @@ _ts_decorate2([
|
|
|
895
922
|
|
|
896
923
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
897
924
|
import { Event as Event3, sleepWithContext, synchronized as synchronized2, Trigger } from "@dxos/async";
|
|
898
|
-
import { Context as
|
|
925
|
+
import { Context as Context3, rejectOnDispose } from "@dxos/context";
|
|
899
926
|
import { failUndefined } from "@dxos/debug";
|
|
900
927
|
import { FeedSetIterator } from "@dxos/feed-store";
|
|
901
928
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
@@ -950,7 +977,7 @@ var PipelineState = class {
|
|
|
950
977
|
constructor(_feeds, _timeframeClock) {
|
|
951
978
|
this._feeds = _feeds;
|
|
952
979
|
this._timeframeClock = _timeframeClock;
|
|
953
|
-
this._ctx = new
|
|
980
|
+
this._ctx = new Context3();
|
|
954
981
|
this.timeframeUpdate = this._timeframeClock.update;
|
|
955
982
|
this.stalled = new Event3();
|
|
956
983
|
this._startTimeframe = new Timeframe2();
|
|
@@ -998,7 +1025,7 @@ var PipelineState = class {
|
|
|
998
1025
|
*
|
|
999
1026
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
1000
1027
|
*/
|
|
1001
|
-
async waitUntilReachedTargetTimeframe({ ctx = new
|
|
1028
|
+
async waitUntilReachedTargetTimeframe({ ctx = new Context3(), timeout, breakOnStall = true } = {}) {
|
|
1002
1029
|
log6("waitUntilReachedTargetTimeframe", {
|
|
1003
1030
|
timeout,
|
|
1004
1031
|
current: this.timeframe,
|
|
@@ -1166,7 +1193,7 @@ var Pipeline = class {
|
|
|
1166
1193
|
await this._feedSetIterator?.close();
|
|
1167
1194
|
await this._processingTrigger.wait();
|
|
1168
1195
|
await this._state._ctx.dispose();
|
|
1169
|
-
this._state._ctx = new
|
|
1196
|
+
this._state._ctx = new Context3();
|
|
1170
1197
|
this._state._reachedTargetPromise = void 0;
|
|
1171
1198
|
this._state._reachedTarget = false;
|
|
1172
1199
|
this._isStarted = false;
|
|
@@ -1351,7 +1378,7 @@ _ts_decorate3([
|
|
|
1351
1378
|
|
|
1352
1379
|
// packages/core/echo/echo-pipeline/src/space/auth.ts
|
|
1353
1380
|
import { runInContext, scheduleTask } from "@dxos/async";
|
|
1354
|
-
import { Context as
|
|
1381
|
+
import { Context as Context4 } from "@dxos/context";
|
|
1355
1382
|
import { randomBytes } from "@dxos/crypto";
|
|
1356
1383
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
1357
1384
|
import { log as log7 } from "@dxos/log";
|
|
@@ -1370,7 +1397,7 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1370
1397
|
timeout: 60 * 1e3
|
|
1371
1398
|
});
|
|
1372
1399
|
this._authParams = _authParams;
|
|
1373
|
-
this._ctx = new
|
|
1400
|
+
this._ctx = new Context4({
|
|
1374
1401
|
onError: (err) => {
|
|
1375
1402
|
log7.catch(err, void 0, {
|
|
1376
1403
|
F: __dxlog_file8,
|
|
@@ -1458,7 +1485,7 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1458
1485
|
|
|
1459
1486
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
1460
1487
|
import { Event as Event4, scheduleTask as scheduleTask2, sleep, synchronized as synchronized3, trackLeaks } from "@dxos/async";
|
|
1461
|
-
import { Context as
|
|
1488
|
+
import { Context as Context5 } from "@dxos/context";
|
|
1462
1489
|
import { checkCredentialType } from "@dxos/credentials";
|
|
1463
1490
|
import { getStateMachineFromItem, ItemManager, TYPE_PROPERTIES } from "@dxos/echo-db";
|
|
1464
1491
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
@@ -1484,7 +1511,7 @@ var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 5e3;
|
|
|
1484
1511
|
var DataPipeline = class {
|
|
1485
1512
|
constructor(_params) {
|
|
1486
1513
|
this._params = _params;
|
|
1487
|
-
this._ctx = new
|
|
1514
|
+
this._ctx = new Context5();
|
|
1488
1515
|
this._pipeline = void 0;
|
|
1489
1516
|
this._targetTimeframe = void 0;
|
|
1490
1517
|
this._lastAutomaticSnapshotTimeframe = new Timeframe3();
|
|
@@ -1592,7 +1619,7 @@ var DataPipeline = class {
|
|
|
1592
1619
|
}
|
|
1593
1620
|
await this.databaseHost?.close();
|
|
1594
1621
|
await this.itemManager?.destroy();
|
|
1595
|
-
this._ctx = new
|
|
1622
|
+
this._ctx = new Context5();
|
|
1596
1623
|
this._pipeline = void 0;
|
|
1597
1624
|
this._targetTimeframe = void 0;
|
|
1598
1625
|
this._lastAutomaticSnapshotTimeframe = new Timeframe3();
|
|
@@ -1739,7 +1766,7 @@ var DataPipeline = class {
|
|
|
1739
1766
|
return;
|
|
1740
1767
|
}
|
|
1741
1768
|
await this._epochCtx?.dispose();
|
|
1742
|
-
const ctx = new
|
|
1769
|
+
const ctx = new Context5({
|
|
1743
1770
|
onError: (err) => {
|
|
1744
1771
|
if (err instanceof CancelledError) {
|
|
1745
1772
|
log8("Epoch processing cancelled.", void 0, {
|
|
@@ -1934,7 +1961,7 @@ import { Callback as Callback2 } from "@dxos/util";
|
|
|
1934
1961
|
|
|
1935
1962
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
1936
1963
|
import { DeferredTask, sleepWithContext as sleepWithContext2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1937
|
-
import { Context as
|
|
1964
|
+
import { Context as Context6 } from "@dxos/context";
|
|
1938
1965
|
import { SpaceStateMachine } from "@dxos/credentials";
|
|
1939
1966
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1940
1967
|
import { log as log9 } from "@dxos/log";
|
|
@@ -1958,7 +1985,7 @@ var CONTROL_PIPELINE_SNAPSHOT_DELAY = 1e4;
|
|
|
1958
1985
|
var USE_SNAPSHOTS = true;
|
|
1959
1986
|
var ControlPipeline = class {
|
|
1960
1987
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1961
|
-
this._ctx = new
|
|
1988
|
+
this._ctx = new Context6();
|
|
1962
1989
|
this._lastTimeframeSaveTime = Date.now();
|
|
1963
1990
|
this.onFeedAdmitted = new Callback();
|
|
1964
1991
|
this._usage = new TimeUsageCounter2();
|
|
@@ -2033,7 +2060,7 @@ var ControlPipeline = class {
|
|
|
2033
2060
|
C: (f, a) => f(...a)
|
|
2034
2061
|
});
|
|
2035
2062
|
setTimeout(async () => {
|
|
2036
|
-
void this._consumePipeline(new
|
|
2063
|
+
void this._consumePipeline(new Context6());
|
|
2037
2064
|
});
|
|
2038
2065
|
await this._pipeline.start();
|
|
2039
2066
|
log9("started", void 0, {
|
|
@@ -3079,7 +3106,7 @@ var MeshNetworkAdapter = class extends NetworkAdapter2 {
|
|
|
3079
3106
|
import { next as automerge, getHeads } from "@dxos/automerge/automerge";
|
|
3080
3107
|
import { Repo } from "@dxos/automerge/automerge-repo";
|
|
3081
3108
|
import { IndexedDBStorageAdapter } from "@dxos/automerge/automerge-repo-storage-indexeddb";
|
|
3082
|
-
import { Context as
|
|
3109
|
+
import { Context as Context7, cancelWithContext as cancelWithContext2 } from "@dxos/context";
|
|
3083
3110
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
3084
3111
|
import { log as log15 } from "@dxos/log";
|
|
3085
3112
|
import { idCodec } from "@dxos/protocols";
|
|
@@ -3131,7 +3158,7 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
3131
3158
|
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
3132
3159
|
var AutomergeHost = class {
|
|
3133
3160
|
constructor({ directory, metadata }) {
|
|
3134
|
-
this._ctx = new
|
|
3161
|
+
this._ctx = new Context7();
|
|
3135
3162
|
/**
|
|
3136
3163
|
* spaceKey -> deviceKey[]
|
|
3137
3164
|
*/
|
|
@@ -3162,7 +3189,7 @@ var AutomergeHost = class {
|
|
|
3162
3189
|
// Hosts, running in the worker, don't share documents unless requested by other peers.
|
|
3163
3190
|
sharePolicy: async (peerId, documentId) => {
|
|
3164
3191
|
if (peerId.startsWith("client-")) {
|
|
3165
|
-
return
|
|
3192
|
+
return false;
|
|
3166
3193
|
}
|
|
3167
3194
|
if (!documentId) {
|
|
3168
3195
|
return false;
|
|
@@ -3421,4 +3448,4 @@ export {
|
|
|
3421
3448
|
MeshNetworkAdapter,
|
|
3422
3449
|
AutomergeHost
|
|
3423
3450
|
};
|
|
3424
|
-
//# sourceMappingURL=chunk-
|
|
3451
|
+
//# sourceMappingURL=chunk-LED7X4WK.mjs.map
|