@dxos/echo-pipeline 0.1.53-main.b9267b1 → 0.1.53-main.ceb8ff5
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-AXGWKSM3.mjs → chunk-ZYDZBSIT.mjs} +80 -71
- package/dist/lib/browser/chunk-ZYDZBSIT.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +2 -2
- package/dist/lib/node/index.cjs +173 -164
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +156 -147
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/dbhost/snapshot-store.d.ts +3 -0
- package/dist/types/src/dbhost/snapshot-store.d.ts.map +1 -1
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/dist/types/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space-protocol.d.ts +3 -0
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/package.json +31 -32
- package/src/common/feeds.ts +3 -3
- package/src/dbhost/data-service-host.ts +3 -3
- package/src/dbhost/data-service.ts +4 -4
- package/src/dbhost/snapshot-store.ts +3 -0
- package/src/metadata/metadata-store.ts +6 -5
- package/src/pipeline/message-selector.ts +3 -5
- package/src/pipeline/pipeline.ts +11 -11
- package/src/space/auth.ts +3 -3
- package/src/space/data-pipeline.ts +11 -10
- package/src/space/space-protocol.browser.test.ts +2 -2
- package/src/space/space-protocol.test.ts +2 -2
- package/src/space/space-protocol.ts +10 -4
- package/src/space/space.ts +5 -5
- package/dist/lib/browser/chunk-AXGWKSM3.mjs.map +0 -7
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import "@dxos/node-std/globals"
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
3
|
// packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
|
|
4
4
|
import CRC32 from "crc-32";
|
|
5
|
-
import
|
|
5
|
+
import invariant from "tiny-invariant";
|
|
6
6
|
import { synchronized, Event } from "@dxos/async";
|
|
7
7
|
import { DataCorruptionError } from "@dxos/errors";
|
|
8
8
|
import { log } from "@dxos/log";
|
|
9
9
|
import { STORAGE_VERSION, schema } from "@dxos/protocols";
|
|
10
|
+
import { arrayToBuffer } from "@dxos/util";
|
|
10
11
|
var __decorate = function(decorators, target, key, desc) {
|
|
11
12
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
13
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -62,7 +63,7 @@ var MetadataStore = class {
|
|
|
62
63
|
checksum
|
|
63
64
|
}, {
|
|
64
65
|
file: "metadata-store.ts",
|
|
65
|
-
line:
|
|
66
|
+
line: 69,
|
|
66
67
|
scope: this,
|
|
67
68
|
callSite: (f, a) => f(...a)
|
|
68
69
|
});
|
|
@@ -80,7 +81,7 @@ var MetadataStore = class {
|
|
|
80
81
|
err
|
|
81
82
|
}, {
|
|
82
83
|
file: "metadata-store.ts",
|
|
83
|
-
line:
|
|
84
|
+
line: 84,
|
|
84
85
|
scope: this,
|
|
85
86
|
callSite: (f, a) => f(...a)
|
|
86
87
|
});
|
|
@@ -100,7 +101,7 @@ var MetadataStore = class {
|
|
|
100
101
|
this.update.emit(data);
|
|
101
102
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
102
103
|
try {
|
|
103
|
-
const encoded =
|
|
104
|
+
const encoded = arrayToBuffer(schema.getCodecForType("dxos.echo.metadata.EchoMetadata").encode(data));
|
|
104
105
|
const checksum = CRC32.buf(encoded);
|
|
105
106
|
const result = Buffer.alloc(8 + encoded.length);
|
|
106
107
|
result.writeInt32LE(encoded.length, 0);
|
|
@@ -112,7 +113,7 @@ var MetadataStore = class {
|
|
|
112
113
|
checksum
|
|
113
114
|
}, {
|
|
114
115
|
file: "metadata-store.ts",
|
|
115
|
-
line:
|
|
116
|
+
line: 116,
|
|
116
117
|
scope: this,
|
|
117
118
|
callSite: (f, a) => f(...a)
|
|
118
119
|
});
|
|
@@ -126,7 +127,7 @@ var MetadataStore = class {
|
|
|
126
127
|
return this._metadata.identity.haloSpace;
|
|
127
128
|
}
|
|
128
129
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
129
|
-
|
|
130
|
+
invariant(space, "Space not found");
|
|
130
131
|
return space;
|
|
131
132
|
}
|
|
132
133
|
/**
|
|
@@ -135,7 +136,7 @@ var MetadataStore = class {
|
|
|
135
136
|
async clear() {
|
|
136
137
|
log("clearing all metadata", {}, {
|
|
137
138
|
file: "metadata-store.ts",
|
|
138
|
-
line:
|
|
139
|
+
line: 137,
|
|
139
140
|
scope: this,
|
|
140
141
|
callSite: (f, a) => f(...a)
|
|
141
142
|
});
|
|
@@ -146,13 +147,13 @@ var MetadataStore = class {
|
|
|
146
147
|
return this._metadata.identity;
|
|
147
148
|
}
|
|
148
149
|
async setIdentityRecord(record) {
|
|
149
|
-
|
|
150
|
+
invariant(!this._metadata.identity, "Cannot overwrite existing identity in metadata");
|
|
150
151
|
this._metadata.identity = record;
|
|
151
152
|
await this._save();
|
|
152
153
|
}
|
|
153
154
|
async addSpace(record) {
|
|
154
155
|
var _a, _b, _c;
|
|
155
|
-
|
|
156
|
+
invariant(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata");
|
|
156
157
|
((_c = (_b = this._metadata).spaces) != null ? _c : _b.spaces = []).push(record);
|
|
157
158
|
await this._save();
|
|
158
159
|
}
|
|
@@ -190,10 +191,10 @@ var codec = schema2.getCodecForType("dxos.echo.feed.FeedMessage");
|
|
|
190
191
|
var valueEncoding = createCodecEncoding(codec);
|
|
191
192
|
|
|
192
193
|
// packages/core/echo/echo-pipeline/src/common/feeds.ts
|
|
193
|
-
import
|
|
194
|
+
import invariant2 from "tiny-invariant";
|
|
194
195
|
var createMappedFeedWriter = (mapper, writer) => {
|
|
195
|
-
|
|
196
|
-
|
|
196
|
+
invariant2(mapper);
|
|
197
|
+
invariant2(writer);
|
|
197
198
|
return {
|
|
198
199
|
write: async (data, options) => await writer.write(await mapper(data), options)
|
|
199
200
|
};
|
|
@@ -297,7 +298,7 @@ __decorate2([
|
|
|
297
298
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
298
299
|
|
|
299
300
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
300
|
-
import
|
|
301
|
+
import invariant4 from "tiny-invariant";
|
|
301
302
|
import { Event as Event3, sleep, synchronized as synchronized2, Trigger } from "@dxos/async";
|
|
302
303
|
import { Context, rejectOnDispose } from "@dxos/context";
|
|
303
304
|
import { failUndefined } from "@dxos/debug";
|
|
@@ -308,19 +309,23 @@ import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
|
308
309
|
import { ComplexMap } from "@dxos/util";
|
|
309
310
|
|
|
310
311
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
311
|
-
import
|
|
312
|
-
import
|
|
313
|
-
var log3 = debug("dxos:echo-db:message-selector");
|
|
312
|
+
import invariant3 from "tiny-invariant";
|
|
313
|
+
import { log as log3 } from "@dxos/log";
|
|
314
314
|
var createMessageSelector = (timeframeClock) => {
|
|
315
315
|
return (messages) => {
|
|
316
316
|
for (let i = 0; i < messages.length; i++) {
|
|
317
317
|
const { data: { timeframe } } = messages[i];
|
|
318
|
-
|
|
318
|
+
invariant3(timeframe);
|
|
319
319
|
if (!timeframeClock.hasGaps(timeframe)) {
|
|
320
320
|
return i;
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
log3("Skipping..."
|
|
323
|
+
log3("Skipping...", {}, {
|
|
324
|
+
file: "message-selector.ts",
|
|
325
|
+
line: 34,
|
|
326
|
+
scope: void 0,
|
|
327
|
+
callSite: (f, a) => f(...a)
|
|
328
|
+
});
|
|
324
329
|
};
|
|
325
330
|
};
|
|
326
331
|
|
|
@@ -450,7 +455,7 @@ var Pipeline = class {
|
|
|
450
455
|
return this._state;
|
|
451
456
|
}
|
|
452
457
|
get writer() {
|
|
453
|
-
|
|
458
|
+
invariant4(this._writer, "Writer not set.");
|
|
454
459
|
return this._writer;
|
|
455
460
|
}
|
|
456
461
|
getFeeds() {
|
|
@@ -469,8 +474,8 @@ var Pipeline = class {
|
|
|
469
474
|
return this._feeds.has(feedKey);
|
|
470
475
|
}
|
|
471
476
|
setWriteFeed(feed) {
|
|
472
|
-
|
|
473
|
-
|
|
477
|
+
invariant4(!this._writer, "Writer already set.");
|
|
478
|
+
invariant4(feed.properties.writable, "Feed must be writable.");
|
|
474
479
|
this._writer = createMappedFeedWriter((payload) => ({
|
|
475
480
|
timeframe: this._timeframeClock.timeframe,
|
|
476
481
|
payload
|
|
@@ -516,7 +521,7 @@ var Pipeline = class {
|
|
|
516
521
|
* @param timeframe Timeframe of already processed messages. The pipeline will start processing messages AFTER this timeframe.
|
|
517
522
|
*/
|
|
518
523
|
async setCursor(timeframe) {
|
|
519
|
-
|
|
524
|
+
invariant4(!this._isStarted || this._isPaused, "Invalid state.");
|
|
520
525
|
this._state._startTimeframe = timeframe;
|
|
521
526
|
this._timeframeClock.setTimeframe(timeframe);
|
|
522
527
|
for (const feed of this._feeds.values()) {
|
|
@@ -532,7 +537,7 @@ var Pipeline = class {
|
|
|
532
537
|
* Calling pause while processing will cause a deadlock.
|
|
533
538
|
*/
|
|
534
539
|
async pause() {
|
|
535
|
-
|
|
540
|
+
invariant4(this._isStarted, "Pipeline is not open.");
|
|
536
541
|
if (this._isPaused) {
|
|
537
542
|
return;
|
|
538
543
|
}
|
|
@@ -541,8 +546,8 @@ var Pipeline = class {
|
|
|
541
546
|
this._isPaused = true;
|
|
542
547
|
}
|
|
543
548
|
async unpause() {
|
|
544
|
-
|
|
545
|
-
|
|
549
|
+
invariant4(this._isStarted, "Pipeline is not open.");
|
|
550
|
+
invariant4(this._isPaused, "Pipeline is not paused.");
|
|
546
551
|
this._pauseTrigger.wake();
|
|
547
552
|
this._isPaused = false;
|
|
548
553
|
}
|
|
@@ -551,15 +556,15 @@ var Pipeline = class {
|
|
|
551
556
|
* Updates the timeframe clock after the message has bee processed.
|
|
552
557
|
*/
|
|
553
558
|
async *consume() {
|
|
554
|
-
|
|
559
|
+
invariant4(!this._isOpen, "Pipeline is already being consumed.");
|
|
555
560
|
this._isOpen = true;
|
|
556
|
-
|
|
561
|
+
invariant4(this._feedSetIterator, "Iterator not initialized.");
|
|
557
562
|
let lastFeedSetIterator = this._feedSetIterator;
|
|
558
563
|
let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
559
564
|
while (!this._isStopping) {
|
|
560
565
|
await this._pauseTrigger.wait();
|
|
561
566
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
562
|
-
|
|
567
|
+
invariant4(this._feedSetIterator, "Iterator not initialized.");
|
|
563
568
|
lastFeedSetIterator = this._feedSetIterator;
|
|
564
569
|
iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
565
570
|
}
|
|
@@ -638,7 +643,7 @@ __decorate3([
|
|
|
638
643
|
], Pipeline.prototype, "unpause", null);
|
|
639
644
|
|
|
640
645
|
// packages/core/echo/echo-pipeline/src/space/auth.ts
|
|
641
|
-
import
|
|
646
|
+
import invariant5 from "tiny-invariant";
|
|
642
647
|
import { runInContext, scheduleTask } from "@dxos/async";
|
|
643
648
|
import { Context as Context2 } from "@dxos/context";
|
|
644
649
|
import { randomBytes } from "@dxos/crypto";
|
|
@@ -701,9 +706,9 @@ var AuthExtension = class extends RpcExtension {
|
|
|
701
706
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
702
707
|
challenge
|
|
703
708
|
});
|
|
704
|
-
|
|
709
|
+
invariant5((credential == null ? void 0 : credential.length) > 0, "invalid credential");
|
|
705
710
|
const success = await this._authParams.verifier(challenge, credential);
|
|
706
|
-
|
|
711
|
+
invariant5(success, "credential not verified");
|
|
707
712
|
runInContext(this._ctx, () => this._authParams.onAuthSuccess());
|
|
708
713
|
} catch (err) {
|
|
709
714
|
log5("auth failed", err, {
|
|
@@ -724,7 +729,7 @@ var AuthExtension = class extends RpcExtension {
|
|
|
724
729
|
};
|
|
725
730
|
|
|
726
731
|
// packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts
|
|
727
|
-
import
|
|
732
|
+
import invariant6 from "tiny-invariant";
|
|
728
733
|
import { Stream } from "@dxos/codec-protobuf";
|
|
729
734
|
import { tagMutationsInBatch, setMetadataOnObject } from "@dxos/echo-db";
|
|
730
735
|
import { log as log6 } from "@dxos/log";
|
|
@@ -750,7 +755,7 @@ var DataServiceHost = class {
|
|
|
750
755
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
751
756
|
var _a;
|
|
752
757
|
const { batch, meta } = message;
|
|
753
|
-
|
|
758
|
+
invariant6(!meta.clientTag, "Unexpected client tag in mutation message");
|
|
754
759
|
log6("message", {
|
|
755
760
|
batch,
|
|
756
761
|
meta
|
|
@@ -783,7 +788,7 @@ var DataServiceHost = class {
|
|
|
783
788
|
}
|
|
784
789
|
async write(request) {
|
|
785
790
|
var _a, _b;
|
|
786
|
-
|
|
791
|
+
invariant6(this._writeStream, "Cannot write mutations in readonly mode");
|
|
787
792
|
log6("write", {
|
|
788
793
|
clientTag: request.clientTag,
|
|
789
794
|
objectCount: (_b = (_a = request.batch.objects) == null ? void 0 : _a.length) != null ? _b : 0
|
|
@@ -968,7 +973,7 @@ var SnapshotStore = class {
|
|
|
968
973
|
};
|
|
969
974
|
|
|
970
975
|
// packages/core/echo/echo-pipeline/src/dbhost/data-service.ts
|
|
971
|
-
import
|
|
976
|
+
import invariant7 from "tiny-invariant";
|
|
972
977
|
import { raise } from "@dxos/debug";
|
|
973
978
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
974
979
|
import { log as log7 } from "@dxos/log";
|
|
@@ -1012,21 +1017,21 @@ var DataServiceImpl = class {
|
|
|
1012
1017
|
}
|
|
1013
1018
|
subscribe(request) {
|
|
1014
1019
|
var _a;
|
|
1015
|
-
|
|
1020
|
+
invariant7(request.spaceKey);
|
|
1016
1021
|
const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : raise(new Error(`space not found: ${request.spaceKey}`));
|
|
1017
1022
|
return host.subscribe();
|
|
1018
1023
|
}
|
|
1019
1024
|
write(request) {
|
|
1020
1025
|
var _a;
|
|
1021
|
-
|
|
1022
|
-
|
|
1026
|
+
invariant7(request.spaceKey);
|
|
1027
|
+
invariant7(request.batch);
|
|
1023
1028
|
const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : raise(new Error(`space not found: ${request.spaceKey}`));
|
|
1024
1029
|
return host.write(request);
|
|
1025
1030
|
}
|
|
1026
1031
|
};
|
|
1027
1032
|
|
|
1028
1033
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
1029
|
-
import
|
|
1034
|
+
import invariant8 from "tiny-invariant";
|
|
1030
1035
|
import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1031
1036
|
import { Context as Context3 } from "@dxos/context";
|
|
1032
1037
|
import { checkCredentialType } from "@dxos/credentials";
|
|
@@ -1099,8 +1104,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1099
1104
|
}
|
|
1100
1105
|
const feedWriter = {
|
|
1101
1106
|
write: (data, options) => {
|
|
1102
|
-
|
|
1103
|
-
|
|
1107
|
+
invariant8(this._pipeline, "Pipeline is not initialized.");
|
|
1108
|
+
invariant8(this.currentEpoch, "Epoch is not initialized.");
|
|
1104
1109
|
return this._pipeline.writer.write({
|
|
1105
1110
|
data
|
|
1106
1111
|
}, options);
|
|
@@ -1150,7 +1155,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1150
1155
|
await this._processEpochInSeparateTask(this.currentEpoch);
|
|
1151
1156
|
await waitForOneEpoch;
|
|
1152
1157
|
}
|
|
1153
|
-
|
|
1158
|
+
invariant8(this._pipeline, "Pipeline is not initialized.");
|
|
1154
1159
|
for await (const msg of this._pipeline.consume()) {
|
|
1155
1160
|
const { feedKey, seq, data } = msg;
|
|
1156
1161
|
log8("processing message", {
|
|
@@ -1208,7 +1213,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1208
1213
|
}
|
|
1209
1214
|
}
|
|
1210
1215
|
_createSnapshot() {
|
|
1211
|
-
|
|
1216
|
+
invariant8(this.databaseHost, "Database backend is not initialized.");
|
|
1212
1217
|
return {
|
|
1213
1218
|
spaceKey: this._params.spaceKey.asUint8Array(),
|
|
1214
1219
|
timeframe: this._pipeline.state.timeframe,
|
|
@@ -1227,7 +1232,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1227
1232
|
try {
|
|
1228
1233
|
const propertiesItem = this.itemManager.items.find((item) => {
|
|
1229
1234
|
var _a2, _b;
|
|
1230
|
-
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" &&
|
|
1235
|
+
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && // TODO(burdon): Document?
|
|
1236
|
+
((_b = getStateMachineFromItem(item)) == null ? void 0 : _b.snapshot().type) === "dxos.sdk.client.Properties";
|
|
1231
1237
|
});
|
|
1232
1238
|
if (propertiesItem) {
|
|
1233
1239
|
cache.properties = (_a = getStateMachineFromItem(propertiesItem)) == null ? void 0 : _a.snapshot();
|
|
@@ -1235,7 +1241,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1235
1241
|
} catch (err) {
|
|
1236
1242
|
log8.warn("Failed to cache properties", err, {
|
|
1237
1243
|
file: "data-pipeline.ts",
|
|
1238
|
-
line:
|
|
1244
|
+
line: 269,
|
|
1239
1245
|
scope: this,
|
|
1240
1246
|
callSite: (f, a) => f(...a)
|
|
1241
1247
|
});
|
|
@@ -1262,14 +1268,14 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1262
1268
|
if (err instanceof CancelledError) {
|
|
1263
1269
|
log8("Epoch processing cancelled.", {}, {
|
|
1264
1270
|
file: "data-pipeline.ts",
|
|
1265
|
-
line:
|
|
1271
|
+
line: 301,
|
|
1266
1272
|
scope: this,
|
|
1267
1273
|
callSite: (f, a) => f(...a)
|
|
1268
1274
|
});
|
|
1269
1275
|
} else {
|
|
1270
1276
|
log8.catch(err, {}, {
|
|
1271
1277
|
file: "data-pipeline.ts",
|
|
1272
|
-
line:
|
|
1278
|
+
line: 303,
|
|
1273
1279
|
scope: this,
|
|
1274
1280
|
callSite: (f, a) => f(...a)
|
|
1275
1281
|
});
|
|
@@ -1285,7 +1291,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1285
1291
|
epoch
|
|
1286
1292
|
}, {
|
|
1287
1293
|
file: "data-pipeline.ts",
|
|
1288
|
-
line:
|
|
1294
|
+
line: 313,
|
|
1289
1295
|
scope: this,
|
|
1290
1296
|
callSite: (f, a) => f(...a)
|
|
1291
1297
|
});
|
|
@@ -1295,14 +1301,14 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1295
1301
|
});
|
|
1296
1302
|
}
|
|
1297
1303
|
async _processEpoch(ctx, epoch) {
|
|
1298
|
-
|
|
1299
|
-
|
|
1304
|
+
invariant8(this._isOpen, "Space is closed.");
|
|
1305
|
+
invariant8(this._pipeline);
|
|
1300
1306
|
this._lastProcessedEpoch = epoch.number;
|
|
1301
1307
|
log8("Processing epoch", {
|
|
1302
1308
|
epoch
|
|
1303
1309
|
}, {
|
|
1304
1310
|
file: "data-pipeline.ts",
|
|
1305
|
-
line:
|
|
1311
|
+
line: 327,
|
|
1306
1312
|
scope: this,
|
|
1307
1313
|
callSite: (f, a) => f(...a)
|
|
1308
1314
|
});
|
|
@@ -1312,7 +1318,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1312
1318
|
}
|
|
1313
1319
|
log8("restarting pipeline for epoch", {}, {
|
|
1314
1320
|
file: "data-pipeline.ts",
|
|
1315
|
-
line:
|
|
1321
|
+
line: 335,
|
|
1316
1322
|
scope: this,
|
|
1317
1323
|
callSite: (f, a) => f(...a)
|
|
1318
1324
|
});
|
|
@@ -1321,12 +1327,12 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1321
1327
|
await this._pipeline.unpause();
|
|
1322
1328
|
}
|
|
1323
1329
|
async waitUntilTimeframe(timeframe) {
|
|
1324
|
-
|
|
1330
|
+
invariant8(this._pipeline, "Pipeline is not initialized.");
|
|
1325
1331
|
await this._pipeline.state.waitUntilTimeframe(timeframe);
|
|
1326
1332
|
}
|
|
1327
1333
|
async createEpoch() {
|
|
1328
|
-
|
|
1329
|
-
|
|
1334
|
+
invariant8(this._pipeline);
|
|
1335
|
+
invariant8(this.currentEpoch);
|
|
1330
1336
|
await this._pipeline.pause();
|
|
1331
1337
|
const snapshot = await this._createSnapshot();
|
|
1332
1338
|
const snapshotCid = await this._params.snapshotManager.store(snapshot);
|
|
@@ -1360,7 +1366,7 @@ DataPipeline = __decorate5([
|
|
|
1360
1366
|
], DataPipeline);
|
|
1361
1367
|
|
|
1362
1368
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1363
|
-
import
|
|
1369
|
+
import invariant9 from "tiny-invariant";
|
|
1364
1370
|
import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeaks3, Lock } from "@dxos/async";
|
|
1365
1371
|
import { log as log10, logInfo } from "@dxos/log";
|
|
1366
1372
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
@@ -1529,7 +1535,7 @@ var Space = class Space2 {
|
|
|
1529
1535
|
// Processes epoch credentials.
|
|
1530
1536
|
this._dataPipelineCredentialConsumer = void 0;
|
|
1531
1537
|
this._isOpen = false;
|
|
1532
|
-
|
|
1538
|
+
invariant9(params.spaceKey && params.feedProvider);
|
|
1533
1539
|
this._key = params.spaceKey;
|
|
1534
1540
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
1535
1541
|
this._feedProvider = params.feedProvider;
|
|
@@ -1630,14 +1636,14 @@ var Space = class Space2 {
|
|
|
1630
1636
|
return this._snapshotManager;
|
|
1631
1637
|
}
|
|
1632
1638
|
setControlFeed(feed) {
|
|
1633
|
-
|
|
1639
|
+
invariant9(!this._controlFeed, "Control feed already set.");
|
|
1634
1640
|
this._controlFeed = feed;
|
|
1635
1641
|
this._controlPipeline.setWriteFeed(feed);
|
|
1636
1642
|
return this;
|
|
1637
1643
|
}
|
|
1638
1644
|
setDataFeed(feed) {
|
|
1639
1645
|
var _a;
|
|
1640
|
-
|
|
1646
|
+
invariant9(!this._dataFeed, "Data feed already set.");
|
|
1641
1647
|
this._dataFeed = feed;
|
|
1642
1648
|
(_a = this._dataPipeline.pipeline) == null ? void 0 : _a.setWriteFeed(feed);
|
|
1643
1649
|
return this;
|
|
@@ -1709,7 +1715,7 @@ var Space = class Space2 {
|
|
|
1709
1715
|
scope: this,
|
|
1710
1716
|
callSite: (f, a) => f(...a)
|
|
1711
1717
|
});
|
|
1712
|
-
|
|
1718
|
+
invariant9(this._isOpen, "Space must be open to initialize data pipeline.");
|
|
1713
1719
|
await this._dataPipeline.open();
|
|
1714
1720
|
}
|
|
1715
1721
|
};
|
|
@@ -1730,7 +1736,7 @@ Space = __decorate6([
|
|
|
1730
1736
|
], Space);
|
|
1731
1737
|
|
|
1732
1738
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
1733
|
-
import { discoveryKey,
|
|
1739
|
+
import { discoveryKey, subtleCrypto as subtleCrypto2 } from "@dxos/crypto";
|
|
1734
1740
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1735
1741
|
import { log as log11, logInfo as logInfo2 } from "@dxos/log";
|
|
1736
1742
|
import { MMSTTopology } from "@dxos/network-manager";
|
|
@@ -1761,7 +1767,7 @@ var SpaceProtocol = class {
|
|
|
1761
1767
|
this.blobSync = new BlobSync({
|
|
1762
1768
|
blobStore
|
|
1763
1769
|
});
|
|
1764
|
-
this._topic =
|
|
1770
|
+
this._topic = subtleCrypto2.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey5.from);
|
|
1765
1771
|
}
|
|
1766
1772
|
get sessions() {
|
|
1767
1773
|
return this._sessions;
|
|
@@ -1778,7 +1784,7 @@ var SpaceProtocol = class {
|
|
|
1778
1784
|
key: feed.key
|
|
1779
1785
|
}, {
|
|
1780
1786
|
file: "space-protocol.ts",
|
|
1781
|
-
line:
|
|
1787
|
+
line: 96,
|
|
1782
1788
|
scope: this,
|
|
1783
1789
|
callSite: (f, a) => f(...a)
|
|
1784
1790
|
});
|
|
@@ -1800,20 +1806,20 @@ var SpaceProtocol = class {
|
|
|
1800
1806
|
await this.blobSync.open();
|
|
1801
1807
|
log11("starting...", {}, {
|
|
1802
1808
|
file: "space-protocol.ts",
|
|
1803
|
-
line:
|
|
1809
|
+
line: 121,
|
|
1804
1810
|
scope: this,
|
|
1805
1811
|
callSite: (f, a) => f(...a)
|
|
1806
1812
|
});
|
|
1807
1813
|
this._connection = await this._networkManager.joinSwarm({
|
|
1808
1814
|
protocolProvider: this._createProtocolProvider(credentials),
|
|
1809
1815
|
peerId: this._swarmIdentity.peerKey,
|
|
1810
|
-
topic: this._topic,
|
|
1816
|
+
topic: await this._topic,
|
|
1811
1817
|
topology: new MMSTTopology(topologyConfig),
|
|
1812
1818
|
label: `Protocol swarm: ${this._topic}`
|
|
1813
1819
|
});
|
|
1814
1820
|
log11("started", {}, {
|
|
1815
1821
|
file: "space-protocol.ts",
|
|
1816
|
-
line:
|
|
1822
|
+
line: 130,
|
|
1817
1823
|
scope: this,
|
|
1818
1824
|
callSite: (f, a) => f(...a)
|
|
1819
1825
|
});
|
|
@@ -1823,14 +1829,14 @@ var SpaceProtocol = class {
|
|
|
1823
1829
|
if (this._connection) {
|
|
1824
1830
|
log11("stopping...", {}, {
|
|
1825
1831
|
file: "space-protocol.ts",
|
|
1826
|
-
line:
|
|
1832
|
+
line: 137,
|
|
1827
1833
|
scope: this,
|
|
1828
1834
|
callSite: (f, a) => f(...a)
|
|
1829
1835
|
});
|
|
1830
1836
|
await this._connection.close();
|
|
1831
1837
|
log11("stopped", {}, {
|
|
1832
1838
|
file: "space-protocol.ts",
|
|
1833
|
-
line:
|
|
1839
|
+
line: 139,
|
|
1834
1840
|
scope: this,
|
|
1835
1841
|
callSite: (f, a) => f(...a)
|
|
1836
1842
|
});
|
|
@@ -1883,6 +1889,9 @@ var SpaceProtocolSession = class {
|
|
|
1883
1889
|
get authStatus() {
|
|
1884
1890
|
return this._authStatus;
|
|
1885
1891
|
}
|
|
1892
|
+
get stats() {
|
|
1893
|
+
return this._teleport.stats;
|
|
1894
|
+
}
|
|
1886
1895
|
get stream() {
|
|
1887
1896
|
return this._teleport.stream;
|
|
1888
1897
|
}
|
|
@@ -1895,7 +1904,7 @@ var SpaceProtocolSession = class {
|
|
|
1895
1904
|
var _a;
|
|
1896
1905
|
log11("Peer authenticated", {}, {
|
|
1897
1906
|
file: "space-protocol.ts",
|
|
1898
|
-
line:
|
|
1907
|
+
line: 236,
|
|
1899
1908
|
scope: this,
|
|
1900
1909
|
callSite: (f, a) => f(...a)
|
|
1901
1910
|
});
|
|
@@ -2048,4 +2057,4 @@ export {
|
|
|
2048
2057
|
SpaceProtocolSession,
|
|
2049
2058
|
SpaceManager
|
|
2050
2059
|
};
|
|
2051
|
-
//# sourceMappingURL=chunk-
|
|
2060
|
+
//# sourceMappingURL=chunk-ZYDZBSIT.mjs.map
|