@dxos/echo-pipeline 0.1.56-main.5c924bd → 0.1.56-main.5db35f4
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-7RPTJNLX.mjs → chunk-WS36YFR3.mjs} +166 -177
- package/dist/lib/browser/chunk-WS36YFR3.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +14 -18
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +164 -175
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +177 -192
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/db-host/data-service-host.d.ts.map +1 -1
- package/dist/types/src/db-host/snapshot-manager.d.ts.map +1 -1
- package/dist/types/src/pipeline/pipeline.d.ts +1 -1
- package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +2 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/database-test-rig.d.ts +4 -1
- package/dist/types/src/testing/database-test-rig.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/package.json +32 -31
- package/src/db-host/data-service-host.ts +8 -1
- package/src/db-host/snapshot-manager.ts +0 -2
- package/src/metadata/metadata-store.ts +1 -1
- package/src/pipeline/pipeline.test.ts +37 -1
- package/src/pipeline/pipeline.ts +35 -12
- package/src/space/data-pipeline.ts +2 -2
- package/src/space/space.test.ts +10 -9
- package/src/space/space.ts +5 -1
- package/src/testing/database-test-rig.ts +27 -2
- package/src/testing/test-agent-builder.ts +2 -1
- package/src/tests/database-unit.test.ts +39 -0
- package/dist/lib/browser/chunk-7RPTJNLX.mjs.map +0 -7
|
@@ -39,6 +39,7 @@ import { Context } from "@dxos/context";
|
|
|
39
39
|
import { tagMutationsInBatch, setMetadataOnObject } from "@dxos/echo-db";
|
|
40
40
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
41
41
|
import { log } from "@dxos/log";
|
|
42
|
+
import { EchoEvent } from "@dxos/protocols/proto/dxos/echo/service";
|
|
42
43
|
import { ComplexMap } from "@dxos/util";
|
|
43
44
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
|
|
44
45
|
var DataServiceHost = class {
|
|
@@ -66,12 +67,19 @@ var DataServiceHost = class {
|
|
|
66
67
|
objects
|
|
67
68
|
}
|
|
68
69
|
});
|
|
70
|
+
this._itemDemuxer.snapshot.on(ctx, (snapshot) => {
|
|
71
|
+
next({
|
|
72
|
+
action: EchoEvent.DatabaseAction.RESET,
|
|
73
|
+
batch: {
|
|
74
|
+
objects: snapshot.items
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
69
78
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
70
|
-
var _a;
|
|
71
79
|
const { batch, meta } = message;
|
|
72
80
|
invariant2(!meta.clientTag, "Unexpected client tag in mutation message", {
|
|
73
81
|
F: __dxlog_file2,
|
|
74
|
-
L:
|
|
82
|
+
L: 68,
|
|
75
83
|
S: this,
|
|
76
84
|
A: [
|
|
77
85
|
"!(meta as any).clientTag",
|
|
@@ -83,7 +91,7 @@ var DataServiceHost = class {
|
|
|
83
91
|
meta
|
|
84
92
|
}, {
|
|
85
93
|
F: __dxlog_file2,
|
|
86
|
-
L:
|
|
94
|
+
L: 69,
|
|
87
95
|
S: this,
|
|
88
96
|
C: (f, a) => f(...a)
|
|
89
97
|
});
|
|
@@ -91,7 +99,7 @@ var DataServiceHost = class {
|
|
|
91
99
|
message.meta.feedKey,
|
|
92
100
|
message.meta.seq
|
|
93
101
|
]);
|
|
94
|
-
|
|
102
|
+
batch.objects?.forEach((object) => {
|
|
95
103
|
setMetadataOnObject(object, {
|
|
96
104
|
...meta
|
|
97
105
|
});
|
|
@@ -109,10 +117,9 @@ var DataServiceHost = class {
|
|
|
109
117
|
});
|
|
110
118
|
}
|
|
111
119
|
async write(request) {
|
|
112
|
-
var _a, _b;
|
|
113
120
|
invariant2(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
|
|
114
121
|
F: __dxlog_file2,
|
|
115
|
-
L:
|
|
122
|
+
L: 95,
|
|
116
123
|
S: this,
|
|
117
124
|
A: [
|
|
118
125
|
"!this._ctx.disposed",
|
|
@@ -121,7 +128,7 @@ var DataServiceHost = class {
|
|
|
121
128
|
});
|
|
122
129
|
invariant2(this._writeStream, "Cannot write mutations in readonly mode", {
|
|
123
130
|
F: __dxlog_file2,
|
|
124
|
-
L:
|
|
131
|
+
L: 96,
|
|
125
132
|
S: this,
|
|
126
133
|
A: [
|
|
127
134
|
"this._writeStream",
|
|
@@ -130,10 +137,10 @@ var DataServiceHost = class {
|
|
|
130
137
|
});
|
|
131
138
|
log("write", {
|
|
132
139
|
clientTag: request.clientTag,
|
|
133
|
-
objectCount:
|
|
140
|
+
objectCount: request.batch.objects?.length ?? 0
|
|
134
141
|
}, {
|
|
135
142
|
F: __dxlog_file2,
|
|
136
|
-
L:
|
|
143
|
+
L: 98,
|
|
137
144
|
S: this,
|
|
138
145
|
C: (f, a) => f(...a)
|
|
139
146
|
});
|
|
@@ -147,7 +154,7 @@ var DataServiceHost = class {
|
|
|
147
154
|
seq: receipt2.seq
|
|
148
155
|
}, {
|
|
149
156
|
F: __dxlog_file2,
|
|
150
|
-
L:
|
|
157
|
+
L: 107,
|
|
151
158
|
S: this,
|
|
152
159
|
C: (f, a) => f(...a)
|
|
153
160
|
});
|
|
@@ -161,24 +168,18 @@ var DataServiceHost = class {
|
|
|
161
168
|
return receipt;
|
|
162
169
|
}
|
|
163
170
|
};
|
|
164
|
-
var createDataMessage = (batch) => {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
meta: void 0
|
|
177
|
-
};
|
|
178
|
-
})
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
};
|
|
171
|
+
var createDataMessage = (batch) => ({
|
|
172
|
+
batch: {
|
|
173
|
+
objects: batch.objects?.map((object) => ({
|
|
174
|
+
...object,
|
|
175
|
+
mutations: object.mutations?.map((mutation) => ({
|
|
176
|
+
...mutation,
|
|
177
|
+
meta: void 0
|
|
178
|
+
})),
|
|
179
|
+
meta: void 0
|
|
180
|
+
}))
|
|
181
|
+
}
|
|
182
|
+
});
|
|
182
183
|
|
|
183
184
|
// packages/core/echo/echo-pipeline/src/db-host/database-host.ts
|
|
184
185
|
import { ItemDemuxer } from "@dxos/echo-db";
|
|
@@ -207,15 +208,13 @@ var DatabaseHost = class {
|
|
|
207
208
|
return this._itemDemuxer.createSnapshot();
|
|
208
209
|
}
|
|
209
210
|
createDataServiceHost() {
|
|
210
|
-
|
|
211
|
-
return new DataServiceHost(this._itemManager, this._itemDemuxer, (_a = this._outboundStream) != null ? _a : void 0);
|
|
211
|
+
return new DataServiceHost(this._itemManager, this._itemDemuxer, this._outboundStream ?? void 0);
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
|
|
215
215
|
// packages/core/echo/echo-pipeline/src/db-host/snapshot-manager.ts
|
|
216
216
|
import { trackLeaks } from "@dxos/async";
|
|
217
217
|
import { cancelWithContext } from "@dxos/context";
|
|
218
|
-
import { timed } from "@dxos/debug";
|
|
219
218
|
import { PublicKey } from "@dxos/keys";
|
|
220
219
|
import { schema as schema2 } from "@dxos/protocols";
|
|
221
220
|
import { BlobMeta } from "@dxos/protocols/proto/dxos/echo/blob";
|
|
@@ -260,9 +259,6 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
260
259
|
return PublicKey.from(id).toHex();
|
|
261
260
|
}
|
|
262
261
|
};
|
|
263
|
-
_ts_decorate([
|
|
264
|
-
timed(1e4)
|
|
265
|
-
], SnapshotManager.prototype, "load", null);
|
|
266
262
|
SnapshotManager = _ts_decorate([
|
|
267
263
|
trackLeaks("open", "close")
|
|
268
264
|
], SnapshotManager);
|
|
@@ -358,7 +354,7 @@ var DataServiceSubscriptions = class {
|
|
|
358
354
|
C: (f, a) => f(...a)
|
|
359
355
|
});
|
|
360
356
|
const host = this._spaces.get(spaceKey);
|
|
361
|
-
await
|
|
357
|
+
await host?.close();
|
|
362
358
|
this._spaces.delete(spaceKey);
|
|
363
359
|
}
|
|
364
360
|
getDataService(spaceKey) {
|
|
@@ -370,7 +366,6 @@ var DataServiceImpl = class {
|
|
|
370
366
|
this._subscriptions = _subscriptions;
|
|
371
367
|
}
|
|
372
368
|
subscribe(request) {
|
|
373
|
-
var _a;
|
|
374
369
|
invariant3(request.spaceKey, void 0, {
|
|
375
370
|
F: __dxlog_file3,
|
|
376
371
|
L: 56,
|
|
@@ -380,11 +375,10 @@ var DataServiceImpl = class {
|
|
|
380
375
|
""
|
|
381
376
|
]
|
|
382
377
|
});
|
|
383
|
-
const host =
|
|
378
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
384
379
|
return host.subscribe();
|
|
385
380
|
}
|
|
386
381
|
write(request) {
|
|
387
|
-
var _a;
|
|
388
382
|
invariant3(request.spaceKey, void 0, {
|
|
389
383
|
F: __dxlog_file3,
|
|
390
384
|
L: 63,
|
|
@@ -403,7 +397,7 @@ var DataServiceImpl = class {
|
|
|
403
397
|
""
|
|
404
398
|
]
|
|
405
399
|
});
|
|
406
|
-
const host =
|
|
400
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
407
401
|
return host.write(request);
|
|
408
402
|
}
|
|
409
403
|
};
|
|
@@ -431,8 +425,8 @@ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipelin
|
|
|
431
425
|
var emptyEchoMetadata = () => ({
|
|
432
426
|
version: STORAGE_VERSION,
|
|
433
427
|
spaces: [],
|
|
434
|
-
created: new Date(),
|
|
435
|
-
updated: new Date()
|
|
428
|
+
created: /* @__PURE__ */ new Date(),
|
|
429
|
+
updated: /* @__PURE__ */ new Date()
|
|
436
430
|
});
|
|
437
431
|
var EchoMetadata = schema4.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
438
432
|
var MetadataStore = class {
|
|
@@ -446,22 +440,19 @@ var MetadataStore = class {
|
|
|
446
440
|
return this._metadata;
|
|
447
441
|
}
|
|
448
442
|
get version() {
|
|
449
|
-
|
|
450
|
-
return (_a = this._metadata.version) != null ? _a : 0;
|
|
443
|
+
return this._metadata.version ?? 0;
|
|
451
444
|
}
|
|
452
445
|
/**
|
|
453
446
|
* Returns a list of currently saved spaces. The list and objects in it can be modified addSpace and
|
|
454
447
|
* addSpaceFeed functions.
|
|
455
448
|
*/
|
|
456
449
|
get spaces() {
|
|
457
|
-
|
|
458
|
-
return (_a = this._metadata.spaces) != null ? _a : [];
|
|
450
|
+
return this._metadata.spaces ?? [];
|
|
459
451
|
}
|
|
460
452
|
/**
|
|
461
453
|
* Loads metadata from persistent storage.
|
|
462
454
|
*/
|
|
463
455
|
async load() {
|
|
464
|
-
var _a;
|
|
465
456
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
466
457
|
try {
|
|
467
458
|
const { size: fileLength } = await file.stat();
|
|
@@ -480,7 +471,10 @@ var MetadataStore = class {
|
|
|
480
471
|
C: (f, a) => f(...a)
|
|
481
472
|
});
|
|
482
473
|
if (fileLength < dataSize + 8) {
|
|
483
|
-
throw new DataCorruptionError("Metadata size is smaller than expected."
|
|
474
|
+
throw new DataCorruptionError("Metadata size is smaller than expected.", {
|
|
475
|
+
fileLength,
|
|
476
|
+
dataSize
|
|
477
|
+
});
|
|
484
478
|
}
|
|
485
479
|
const data = await file.read(8, dataSize);
|
|
486
480
|
const calculatedChecksum = CRC32.buf(data);
|
|
@@ -488,9 +482,8 @@ var MetadataStore = class {
|
|
|
488
482
|
throw new DataCorruptionError("Metadata checksum is invalid.");
|
|
489
483
|
}
|
|
490
484
|
this._metadata = EchoMetadata.decode(data);
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
(_a2 = space.state) != null ? _a2 : space.state = SpaceState.ACTIVE;
|
|
485
|
+
this._metadata.spaces?.forEach((space) => {
|
|
486
|
+
space.state ??= SpaceState.ACTIVE;
|
|
494
487
|
});
|
|
495
488
|
} catch (err) {
|
|
496
489
|
log3.error("failed to load metadata", {
|
|
@@ -507,12 +500,11 @@ var MetadataStore = class {
|
|
|
507
500
|
}
|
|
508
501
|
}
|
|
509
502
|
async _save() {
|
|
510
|
-
var _a;
|
|
511
503
|
const data = {
|
|
512
504
|
...this._metadata,
|
|
513
505
|
version: STORAGE_VERSION,
|
|
514
|
-
created:
|
|
515
|
-
updated: new Date()
|
|
506
|
+
created: this._metadata.created ?? /* @__PURE__ */ new Date(),
|
|
507
|
+
updated: /* @__PURE__ */ new Date()
|
|
516
508
|
};
|
|
517
509
|
this.update.emit(data);
|
|
518
510
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
@@ -538,8 +530,7 @@ var MetadataStore = class {
|
|
|
538
530
|
}
|
|
539
531
|
}
|
|
540
532
|
_getSpace(spaceKey) {
|
|
541
|
-
|
|
542
|
-
if ((_a = this._metadata.identity) == null ? void 0 : _a.haloSpace.key.equals(spaceKey)) {
|
|
533
|
+
if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {
|
|
543
534
|
return this._metadata.identity.haloSpace;
|
|
544
535
|
}
|
|
545
536
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
@@ -584,8 +575,7 @@ var MetadataStore = class {
|
|
|
584
575
|
await this._save();
|
|
585
576
|
}
|
|
586
577
|
async addSpace(record) {
|
|
587
|
-
|
|
588
|
-
invariant4(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
578
|
+
invariant4(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
589
579
|
F: __dxlog_file4,
|
|
590
580
|
L: 162,
|
|
591
581
|
S: this,
|
|
@@ -594,7 +584,7 @@ var MetadataStore = class {
|
|
|
594
584
|
"'Cannot overwrite existing space in metadata'"
|
|
595
585
|
]
|
|
596
586
|
});
|
|
597
|
-
(
|
|
587
|
+
(this._metadata.spaces ??= []).push(record);
|
|
598
588
|
await this._save();
|
|
599
589
|
}
|
|
600
590
|
async setSpaceDataLatestTimeframe(spaceKey, timeframe) {
|
|
@@ -630,7 +620,7 @@ var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
|
630
620
|
|
|
631
621
|
// packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
|
|
632
622
|
import { Event as Event2 } from "@dxos/async";
|
|
633
|
-
import { timed
|
|
623
|
+
import { timed } from "@dxos/debug";
|
|
634
624
|
import { log as log4 } from "@dxos/log";
|
|
635
625
|
import { Timeframe } from "@dxos/timeframe";
|
|
636
626
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
@@ -723,7 +713,7 @@ var TimeframeClock = class {
|
|
|
723
713
|
}
|
|
724
714
|
};
|
|
725
715
|
_ts_decorate3([
|
|
726
|
-
|
|
716
|
+
timed(5e3)
|
|
727
717
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
728
718
|
|
|
729
719
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
@@ -735,7 +725,7 @@ import { invariant as invariant6 } from "@dxos/invariant";
|
|
|
735
725
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
736
726
|
import { log as log6 } from "@dxos/log";
|
|
737
727
|
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
738
|
-
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
728
|
+
import { ComplexMap as ComplexMap3, getPrototypeSpecificInstanceId } from "@dxos/util";
|
|
739
729
|
|
|
740
730
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
741
731
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
@@ -829,7 +819,6 @@ var PipelineState = class {
|
|
|
829
819
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
830
820
|
*/
|
|
831
821
|
async waitUntilReachedTargetTimeframe({ ctx = new Context2(), timeout, breakOnStall = true } = {}) {
|
|
832
|
-
var _a;
|
|
833
822
|
log6("waitUntilReachedTargetTimeframe", {
|
|
834
823
|
timeout,
|
|
835
824
|
current: this.timeframe,
|
|
@@ -840,7 +829,7 @@ var PipelineState = class {
|
|
|
840
829
|
S: this,
|
|
841
830
|
C: (f, a) => f(...a)
|
|
842
831
|
});
|
|
843
|
-
|
|
832
|
+
this._reachedTargetPromise ??= Promise.race([
|
|
844
833
|
this._timeframeClock.update.waitForCondition(() => {
|
|
845
834
|
return Timeframe2.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
|
|
846
835
|
}),
|
|
@@ -889,7 +878,7 @@ var Pipeline = class {
|
|
|
889
878
|
this._pauseTrigger = new Trigger().wake();
|
|
890
879
|
this._isStopping = false;
|
|
891
880
|
this._isStarted = false;
|
|
892
|
-
this.
|
|
881
|
+
this._isBeingConsumed = false;
|
|
893
882
|
this._isPaused = false;
|
|
894
883
|
}
|
|
895
884
|
get state() {
|
|
@@ -920,12 +909,14 @@ var Pipeline = class {
|
|
|
920
909
|
if (this._feedSetIterator) {
|
|
921
910
|
await this._feedSetIterator.addFeed(feed);
|
|
922
911
|
}
|
|
923
|
-
this.
|
|
912
|
+
if (this._isStarted && !this._isPaused) {
|
|
913
|
+
this._setFeedDownloadState(feed);
|
|
914
|
+
}
|
|
924
915
|
}
|
|
925
916
|
setWriteFeed(feed) {
|
|
926
917
|
invariant6(!this._writer, "Writer already set.", {
|
|
927
918
|
F: __dxlog_file7,
|
|
928
|
-
L:
|
|
919
|
+
L: 257,
|
|
929
920
|
S: this,
|
|
930
921
|
A: [
|
|
931
922
|
"!this._writer",
|
|
@@ -934,7 +925,7 @@ var Pipeline = class {
|
|
|
934
925
|
});
|
|
935
926
|
invariant6(feed.properties.writable, "Feed must be writable.", {
|
|
936
927
|
F: __dxlog_file7,
|
|
937
|
-
L:
|
|
928
|
+
L: 258,
|
|
938
929
|
S: this,
|
|
939
930
|
A: [
|
|
940
931
|
"feed.properties.writable",
|
|
@@ -947,9 +938,18 @@ var Pipeline = class {
|
|
|
947
938
|
}), feed.createFeedWriter());
|
|
948
939
|
}
|
|
949
940
|
async start() {
|
|
941
|
+
invariant6(!this._isStarted, "Pipeline is already started.", {
|
|
942
|
+
F: __dxlog_file7,
|
|
943
|
+
L: 271,
|
|
944
|
+
S: this,
|
|
945
|
+
A: [
|
|
946
|
+
"!this._isStarted",
|
|
947
|
+
"'Pipeline is already started.'"
|
|
948
|
+
]
|
|
949
|
+
});
|
|
950
950
|
log6("starting...", void 0, {
|
|
951
951
|
F: __dxlog_file7,
|
|
952
|
-
L:
|
|
952
|
+
L: 272,
|
|
953
953
|
S: this,
|
|
954
954
|
C: (f, a) => f(...a)
|
|
955
955
|
});
|
|
@@ -958,21 +958,25 @@ var Pipeline = class {
|
|
|
958
958
|
this._isStarted = true;
|
|
959
959
|
log6("started", void 0, {
|
|
960
960
|
F: __dxlog_file7,
|
|
961
|
-
L:
|
|
961
|
+
L: 276,
|
|
962
962
|
S: this,
|
|
963
963
|
C: (f, a) => f(...a)
|
|
964
964
|
});
|
|
965
|
+
if (!this._isPaused) {
|
|
966
|
+
for (const feed of this._feeds.values()) {
|
|
967
|
+
this._setFeedDownloadState(feed);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
965
970
|
}
|
|
966
971
|
async stop() {
|
|
967
|
-
var _a;
|
|
968
972
|
log6("stopping...", void 0, {
|
|
969
973
|
F: __dxlog_file7,
|
|
970
|
-
L:
|
|
974
|
+
L: 287,
|
|
971
975
|
S: this,
|
|
972
976
|
C: (f, a) => f(...a)
|
|
973
977
|
});
|
|
974
978
|
this._isStopping = true;
|
|
975
|
-
await
|
|
979
|
+
await this._feedSetIterator?.close();
|
|
976
980
|
await this._processingTrigger.wait();
|
|
977
981
|
await this._state._ctx.dispose();
|
|
978
982
|
this._state._ctx = new Context2();
|
|
@@ -980,7 +984,7 @@ var Pipeline = class {
|
|
|
980
984
|
this._isStarted = false;
|
|
981
985
|
log6("stopped", void 0, {
|
|
982
986
|
F: __dxlog_file7,
|
|
983
|
-
L:
|
|
987
|
+
L: 295,
|
|
984
988
|
S: this,
|
|
985
989
|
C: (f, a) => f(...a)
|
|
986
990
|
});
|
|
@@ -992,7 +996,7 @@ var Pipeline = class {
|
|
|
992
996
|
async setCursor(timeframe) {
|
|
993
997
|
invariant6(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
994
998
|
F: __dxlog_file7,
|
|
995
|
-
L:
|
|
999
|
+
L: 304,
|
|
996
1000
|
S: this,
|
|
997
1001
|
A: [
|
|
998
1002
|
"!this._isStarted || this._isPaused",
|
|
@@ -1001,9 +1005,6 @@ var Pipeline = class {
|
|
|
1001
1005
|
});
|
|
1002
1006
|
this._state._startTimeframe = timeframe;
|
|
1003
1007
|
this._timeframeClock.setTimeframe(timeframe);
|
|
1004
|
-
for (const feed of this._feeds.values()) {
|
|
1005
|
-
this._setFeedDownloadState(feed);
|
|
1006
|
-
}
|
|
1007
1008
|
if (this._feedSetIterator) {
|
|
1008
1009
|
await this._feedSetIterator.close();
|
|
1009
1010
|
await this._initIterator();
|
|
@@ -1014,15 +1015,6 @@ var Pipeline = class {
|
|
|
1014
1015
|
* Calling pause while processing will cause a deadlock.
|
|
1015
1016
|
*/
|
|
1016
1017
|
async pause() {
|
|
1017
|
-
invariant6(this._isStarted, "Pipeline is not open.", {
|
|
1018
|
-
F: __dxlog_file7,
|
|
1019
|
-
L: 315,
|
|
1020
|
-
S: this,
|
|
1021
|
-
A: [
|
|
1022
|
-
"this._isStarted",
|
|
1023
|
-
"'Pipeline is not open.'"
|
|
1024
|
-
]
|
|
1025
|
-
});
|
|
1026
1018
|
if (this._isPaused) {
|
|
1027
1019
|
return;
|
|
1028
1020
|
}
|
|
@@ -1031,18 +1023,9 @@ var Pipeline = class {
|
|
|
1031
1023
|
this._isPaused = true;
|
|
1032
1024
|
}
|
|
1033
1025
|
async unpause() {
|
|
1034
|
-
invariant6(this._isStarted, "Pipeline is not open.", {
|
|
1035
|
-
F: __dxlog_file7,
|
|
1036
|
-
L: 327,
|
|
1037
|
-
S: this,
|
|
1038
|
-
A: [
|
|
1039
|
-
"this._isStarted",
|
|
1040
|
-
"'Pipeline is not open.'"
|
|
1041
|
-
]
|
|
1042
|
-
});
|
|
1043
1026
|
invariant6(this._isPaused, "Pipeline is not paused.", {
|
|
1044
1027
|
F: __dxlog_file7,
|
|
1045
|
-
L:
|
|
1028
|
+
L: 334,
|
|
1046
1029
|
S: this,
|
|
1047
1030
|
A: [
|
|
1048
1031
|
"this._isPaused",
|
|
@@ -1051,25 +1034,28 @@ var Pipeline = class {
|
|
|
1051
1034
|
});
|
|
1052
1035
|
this._pauseTrigger.wake();
|
|
1053
1036
|
this._isPaused = false;
|
|
1037
|
+
for (const feed of this._feeds.values()) {
|
|
1038
|
+
this._setFeedDownloadState(feed);
|
|
1039
|
+
}
|
|
1054
1040
|
}
|
|
1055
1041
|
/**
|
|
1056
1042
|
* Starts to iterate over the ordered messages from the added feeds.
|
|
1057
1043
|
* Updates the timeframe clock after the message has bee processed.
|
|
1058
1044
|
*/
|
|
1059
1045
|
async *consume() {
|
|
1060
|
-
invariant6(!this.
|
|
1046
|
+
invariant6(!this._isBeingConsumed, "Pipeline is already being consumed.", {
|
|
1061
1047
|
F: __dxlog_file7,
|
|
1062
|
-
L:
|
|
1048
|
+
L: 349,
|
|
1063
1049
|
S: this,
|
|
1064
1050
|
A: [
|
|
1065
|
-
"!this.
|
|
1051
|
+
"!this._isBeingConsumed",
|
|
1066
1052
|
"'Pipeline is already being consumed.'"
|
|
1067
1053
|
]
|
|
1068
1054
|
});
|
|
1069
|
-
this.
|
|
1055
|
+
this._isBeingConsumed = true;
|
|
1070
1056
|
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1071
1057
|
F: __dxlog_file7,
|
|
1072
|
-
L:
|
|
1058
|
+
L: 352,
|
|
1073
1059
|
S: this,
|
|
1074
1060
|
A: [
|
|
1075
1061
|
"this._feedSetIterator",
|
|
@@ -1083,7 +1069,7 @@ var Pipeline = class {
|
|
|
1083
1069
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
1084
1070
|
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1085
1071
|
F: __dxlog_file7,
|
|
1086
|
-
L:
|
|
1072
|
+
L: 361,
|
|
1087
1073
|
S: this,
|
|
1088
1074
|
A: [
|
|
1089
1075
|
"this._feedSetIterator",
|
|
@@ -1095,7 +1081,7 @@ var Pipeline = class {
|
|
|
1095
1081
|
}
|
|
1096
1082
|
const { done, value } = await iterable.next();
|
|
1097
1083
|
if (!done) {
|
|
1098
|
-
const block = value
|
|
1084
|
+
const block = value ?? failUndefined();
|
|
1099
1085
|
this._processingTrigger.reset();
|
|
1100
1086
|
this._timeframeClock.updatePendingTimeframe(PublicKey3.from(block.feedKey), block.seq);
|
|
1101
1087
|
yield block;
|
|
@@ -1103,16 +1089,31 @@ var Pipeline = class {
|
|
|
1103
1089
|
this._timeframeClock.updateTimeframe();
|
|
1104
1090
|
}
|
|
1105
1091
|
}
|
|
1106
|
-
this.
|
|
1092
|
+
this._isBeingConsumed = false;
|
|
1107
1093
|
}
|
|
1108
1094
|
_setFeedDownloadState(feed) {
|
|
1109
|
-
var _a;
|
|
1110
1095
|
const timeframe = this._state._startTimeframe;
|
|
1111
|
-
const seq =
|
|
1096
|
+
const seq = timeframe.get(feed.key) ?? -1;
|
|
1097
|
+
log6("setFeedDownloadState", {
|
|
1098
|
+
feed: feed.key,
|
|
1099
|
+
feedInstance: getPrototypeSpecificInstanceId(feed),
|
|
1100
|
+
seq,
|
|
1101
|
+
isBeingConsumed: this._isBeingConsumed,
|
|
1102
|
+
isStarted: this._isStarted,
|
|
1103
|
+
isPaused: this._isPaused
|
|
1104
|
+
}, {
|
|
1105
|
+
F: __dxlog_file7,
|
|
1106
|
+
L: 386,
|
|
1107
|
+
S: this,
|
|
1108
|
+
C: (f, a) => f(...a)
|
|
1109
|
+
});
|
|
1110
|
+
if (!this._isStarted || this._isPaused) {
|
|
1111
|
+
console.log(new Error().stack);
|
|
1112
|
+
}
|
|
1112
1113
|
feed.undownload({
|
|
1113
1114
|
callback: () => log6("undownload", void 0, {
|
|
1114
1115
|
F: __dxlog_file7,
|
|
1115
|
-
L:
|
|
1116
|
+
L: 398,
|
|
1116
1117
|
S: this,
|
|
1117
1118
|
C: (f, a) => f(...a)
|
|
1118
1119
|
})
|
|
@@ -1125,7 +1126,7 @@ var Pipeline = class {
|
|
|
1125
1126
|
err
|
|
1126
1127
|
}, {
|
|
1127
1128
|
F: __dxlog_file7,
|
|
1128
|
-
L:
|
|
1129
|
+
L: 400,
|
|
1129
1130
|
S: this,
|
|
1130
1131
|
C: (f, a) => f(...a)
|
|
1131
1132
|
});
|
|
@@ -1139,7 +1140,7 @@ var Pipeline = class {
|
|
|
1139
1140
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
1140
1141
|
log6.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
1141
1142
|
F: __dxlog_file7,
|
|
1142
|
-
L:
|
|
1143
|
+
L: 411,
|
|
1143
1144
|
S: this,
|
|
1144
1145
|
C: (f, a) => f(...a)
|
|
1145
1146
|
});
|
|
@@ -1231,7 +1232,7 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1231
1232
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
1232
1233
|
challenge
|
|
1233
1234
|
});
|
|
1234
|
-
invariant7(
|
|
1235
|
+
invariant7(credential?.length > 0, "invalid credential", {
|
|
1235
1236
|
F: __dxlog_file8,
|
|
1236
1237
|
L: 69,
|
|
1237
1238
|
S: this,
|
|
@@ -1315,13 +1316,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1315
1316
|
return this._pipeline;
|
|
1316
1317
|
}
|
|
1317
1318
|
get pipelineState() {
|
|
1318
|
-
|
|
1319
|
-
return (_a = this._pipeline) == null ? void 0 : _a.state;
|
|
1319
|
+
return this._pipeline?.state;
|
|
1320
1320
|
}
|
|
1321
1321
|
setTargetTimeframe(timeframe) {
|
|
1322
|
-
var _a;
|
|
1323
1322
|
this._targetTimeframe = timeframe;
|
|
1324
|
-
|
|
1323
|
+
this._pipeline?.state.setTargetTimeframe(timeframe);
|
|
1325
1324
|
}
|
|
1326
1325
|
async processCredential(credential) {
|
|
1327
1326
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
@@ -1338,8 +1337,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1338
1337
|
}
|
|
1339
1338
|
this._pipeline = new Pipeline();
|
|
1340
1339
|
await this._params.onPipelineCreated(this._pipeline);
|
|
1341
|
-
await this._pipeline.start();
|
|
1342
1340
|
await this._pipeline.pause();
|
|
1341
|
+
await this._pipeline.start();
|
|
1343
1342
|
if (this._targetTimeframe) {
|
|
1344
1343
|
this._pipeline.state.setTargetTimeframe(this._targetTimeframe);
|
|
1345
1344
|
}
|
|
@@ -1347,7 +1346,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1347
1346
|
write: (data, options) => {
|
|
1348
1347
|
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1349
1348
|
F: __dxlog_file9,
|
|
1350
|
-
L:
|
|
1349
|
+
L: 146,
|
|
1351
1350
|
S: this,
|
|
1352
1351
|
A: [
|
|
1353
1352
|
"this._pipeline",
|
|
@@ -1356,7 +1355,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1356
1355
|
});
|
|
1357
1356
|
invariant8(this.currentEpoch, "Epoch is not initialized.", {
|
|
1358
1357
|
F: __dxlog_file9,
|
|
1359
|
-
L:
|
|
1358
|
+
L: 147,
|
|
1360
1359
|
S: this,
|
|
1361
1360
|
A: [
|
|
1362
1361
|
"this.currentEpoch",
|
|
@@ -1377,19 +1376,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1377
1376
|
this._isOpen = true;
|
|
1378
1377
|
}
|
|
1379
1378
|
async close() {
|
|
1380
|
-
var _a, _b, _c;
|
|
1381
1379
|
if (!this._isOpen) {
|
|
1382
1380
|
return;
|
|
1383
1381
|
}
|
|
1384
1382
|
log8("close", void 0, {
|
|
1385
1383
|
F: __dxlog_file9,
|
|
1386
|
-
L:
|
|
1384
|
+
L: 171,
|
|
1387
1385
|
S: this,
|
|
1388
1386
|
C: (f, a) => f(...a)
|
|
1389
1387
|
});
|
|
1390
1388
|
this._isOpen = false;
|
|
1391
1389
|
await this._ctx.dispose();
|
|
1392
|
-
await
|
|
1390
|
+
await this._pipeline?.stop();
|
|
1393
1391
|
try {
|
|
1394
1392
|
await this._saveCache();
|
|
1395
1393
|
if (this._pipeline) {
|
|
@@ -1398,13 +1396,13 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1398
1396
|
} catch (err) {
|
|
1399
1397
|
log8.catch(err, void 0, {
|
|
1400
1398
|
F: __dxlog_file9,
|
|
1401
|
-
L:
|
|
1399
|
+
L: 184,
|
|
1402
1400
|
S: this,
|
|
1403
1401
|
C: (f, a) => f(...a)
|
|
1404
1402
|
});
|
|
1405
1403
|
}
|
|
1406
|
-
await
|
|
1407
|
-
await
|
|
1404
|
+
await this.databaseHost?.close();
|
|
1405
|
+
await this.itemManager?.destroy();
|
|
1408
1406
|
this._ctx = new Context4();
|
|
1409
1407
|
this._pipeline = void 0;
|
|
1410
1408
|
this._targetTimeframe = void 0;
|
|
@@ -1422,7 +1420,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1422
1420
|
}
|
|
1423
1421
|
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1424
1422
|
F: __dxlog_file9,
|
|
1425
|
-
L:
|
|
1423
|
+
L: 207,
|
|
1426
1424
|
S: this,
|
|
1427
1425
|
A: [
|
|
1428
1426
|
"this._pipeline",
|
|
@@ -1436,7 +1434,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1436
1434
|
seq
|
|
1437
1435
|
}, {
|
|
1438
1436
|
F: __dxlog_file9,
|
|
1439
|
-
L:
|
|
1437
|
+
L: 210,
|
|
1440
1438
|
S: this,
|
|
1441
1439
|
C: (f, a) => f(...a)
|
|
1442
1440
|
});
|
|
@@ -1448,7 +1446,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1448
1446
|
feedKey
|
|
1449
1447
|
}, {
|
|
1450
1448
|
F: __dxlog_file9,
|
|
1451
|
-
L:
|
|
1449
|
+
L: 216,
|
|
1452
1450
|
S: this,
|
|
1453
1451
|
C: (f, a) => f(...a)
|
|
1454
1452
|
});
|
|
@@ -1471,7 +1469,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1471
1469
|
spaceKey: this._params.spaceKey.toHex()
|
|
1472
1470
|
}, {
|
|
1473
1471
|
F: __dxlog_file9,
|
|
1474
|
-
L:
|
|
1472
|
+
L: 233,
|
|
1475
1473
|
S: this,
|
|
1476
1474
|
C: (f, a) => f(...a)
|
|
1477
1475
|
});
|
|
@@ -1480,7 +1478,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1480
1478
|
} catch (err) {
|
|
1481
1479
|
log8.catch(err, void 0, {
|
|
1482
1480
|
F: __dxlog_file9,
|
|
1483
|
-
L:
|
|
1481
|
+
L: 243,
|
|
1484
1482
|
S: this,
|
|
1485
1483
|
C: (f, a) => f(...a)
|
|
1486
1484
|
});
|
|
@@ -1490,7 +1488,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1490
1488
|
_createSnapshot() {
|
|
1491
1489
|
invariant8(this.databaseHost, "Database backend is not initialized.", {
|
|
1492
1490
|
F: __dxlog_file9,
|
|
1493
|
-
L:
|
|
1491
|
+
L: 249,
|
|
1494
1492
|
S: this,
|
|
1495
1493
|
A: [
|
|
1496
1494
|
"this.databaseHost",
|
|
@@ -1504,26 +1502,22 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1504
1502
|
};
|
|
1505
1503
|
}
|
|
1506
1504
|
async _saveTargetTimeframe(timeframe) {
|
|
1507
|
-
|
|
1508
|
-
const newTimeframe = Timeframe3.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe3(), timeframe);
|
|
1505
|
+
const newTimeframe = Timeframe3.merge(this._targetTimeframe ?? new Timeframe3(), timeframe);
|
|
1509
1506
|
await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
|
|
1510
1507
|
this._targetTimeframe = newTimeframe;
|
|
1511
1508
|
}
|
|
1512
1509
|
async _saveCache() {
|
|
1513
|
-
var _a;
|
|
1514
1510
|
const cache = {};
|
|
1515
1511
|
try {
|
|
1516
|
-
const propertiesItem = this.itemManager.items.find((item) =>
|
|
1517
|
-
|
|
1518
|
-
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = getStateMachineFromItem(item)) == null ? void 0 : _b.snapshot()).type === "dxos.sdk.client.Properties";
|
|
1519
|
-
});
|
|
1512
|
+
const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
|
|
1513
|
+
(getStateMachineFromItem(item)?.snapshot()).type === "dxos.sdk.client.Properties");
|
|
1520
1514
|
if (propertiesItem) {
|
|
1521
|
-
cache.properties =
|
|
1515
|
+
cache.properties = getStateMachineFromItem(propertiesItem)?.snapshot();
|
|
1522
1516
|
}
|
|
1523
1517
|
} catch (err) {
|
|
1524
1518
|
log8.warn("Failed to cache properties", err, {
|
|
1525
1519
|
F: __dxlog_file9,
|
|
1526
|
-
L:
|
|
1520
|
+
L: 278,
|
|
1527
1521
|
S: this,
|
|
1528
1522
|
C: (f, a) => f(...a)
|
|
1529
1523
|
});
|
|
@@ -1540,24 +1534,23 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1540
1534
|
}
|
|
1541
1535
|
}
|
|
1542
1536
|
async _processEpochInSeparateTask(epoch) {
|
|
1543
|
-
var _a;
|
|
1544
1537
|
if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
|
|
1545
1538
|
return;
|
|
1546
1539
|
}
|
|
1547
|
-
await
|
|
1540
|
+
await this._epochCtx?.dispose();
|
|
1548
1541
|
const ctx = new Context4({
|
|
1549
1542
|
onError: (err) => {
|
|
1550
1543
|
if (err instanceof CancelledError) {
|
|
1551
1544
|
log8("Epoch processing cancelled.", void 0, {
|
|
1552
1545
|
F: __dxlog_file9,
|
|
1553
|
-
L:
|
|
1546
|
+
L: 310,
|
|
1554
1547
|
S: this,
|
|
1555
1548
|
C: (f, a) => f(...a)
|
|
1556
1549
|
});
|
|
1557
1550
|
} else {
|
|
1558
1551
|
log8.catch(err, void 0, {
|
|
1559
1552
|
F: __dxlog_file9,
|
|
1560
|
-
L:
|
|
1553
|
+
L: 312,
|
|
1561
1554
|
S: this,
|
|
1562
1555
|
C: (f, a) => f(...a)
|
|
1563
1556
|
});
|
|
@@ -1573,7 +1566,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1573
1566
|
epoch
|
|
1574
1567
|
}, {
|
|
1575
1568
|
F: __dxlog_file9,
|
|
1576
|
-
L:
|
|
1569
|
+
L: 322,
|
|
1577
1570
|
S: this,
|
|
1578
1571
|
C: (f, a) => f(...a)
|
|
1579
1572
|
});
|
|
@@ -1585,7 +1578,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1585
1578
|
async _processEpoch(ctx, epoch) {
|
|
1586
1579
|
invariant8(this._isOpen, "Space is closed.", {
|
|
1587
1580
|
F: __dxlog_file9,
|
|
1588
|
-
L:
|
|
1581
|
+
L: 332,
|
|
1589
1582
|
S: this,
|
|
1590
1583
|
A: [
|
|
1591
1584
|
"this._isOpen",
|
|
@@ -1594,7 +1587,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1594
1587
|
});
|
|
1595
1588
|
invariant8(this._pipeline, void 0, {
|
|
1596
1589
|
F: __dxlog_file9,
|
|
1597
|
-
L:
|
|
1590
|
+
L: 333,
|
|
1598
1591
|
S: this,
|
|
1599
1592
|
A: [
|
|
1600
1593
|
"this._pipeline",
|
|
@@ -1606,7 +1599,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1606
1599
|
epoch
|
|
1607
1600
|
}, {
|
|
1608
1601
|
F: __dxlog_file9,
|
|
1609
|
-
L:
|
|
1602
|
+
L: 336,
|
|
1610
1603
|
S: this,
|
|
1611
1604
|
C: (f, a) => f(...a)
|
|
1612
1605
|
});
|
|
@@ -1692,6 +1685,7 @@ import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeak
|
|
|
1692
1685
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1693
1686
|
import { log as log10, logInfo } from "@dxos/log";
|
|
1694
1687
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1688
|
+
import { trace } from "@dxos/tracing";
|
|
1695
1689
|
import { Callback as Callback2 } from "@dxos/util";
|
|
1696
1690
|
|
|
1697
1691
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
@@ -1825,9 +1819,8 @@ var ControlPipeline = class {
|
|
|
1825
1819
|
});
|
|
1826
1820
|
}
|
|
1827
1821
|
async _saveTargetTimeframe(timeframe) {
|
|
1828
|
-
var _a;
|
|
1829
1822
|
try {
|
|
1830
|
-
const newTimeframe = Timeframe4.merge(
|
|
1823
|
+
const newTimeframe = Timeframe4.merge(this._targetTimeframe ?? new Timeframe4(), timeframe);
|
|
1831
1824
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1832
1825
|
this._targetTimeframe = newTimeframe;
|
|
1833
1826
|
} catch (err) {
|
|
@@ -1861,7 +1854,7 @@ var Space = class Space2 {
|
|
|
1861
1854
|
this._isOpen = false;
|
|
1862
1855
|
invariant9(params.spaceKey && params.feedProvider, void 0, {
|
|
1863
1856
|
F: __dxlog_file11,
|
|
1864
|
-
L:
|
|
1857
|
+
L: 73,
|
|
1865
1858
|
S: this,
|
|
1866
1859
|
A: [
|
|
1867
1860
|
"params.spaceKey && params.feedProvider",
|
|
@@ -1903,7 +1896,7 @@ var Space = class Space2 {
|
|
|
1903
1896
|
credential
|
|
1904
1897
|
}, {
|
|
1905
1898
|
F: __dxlog_file11,
|
|
1906
|
-
L:
|
|
1899
|
+
L: 109,
|
|
1907
1900
|
S: this,
|
|
1908
1901
|
C: (f, a) => f(...a)
|
|
1909
1902
|
});
|
|
@@ -1945,12 +1938,10 @@ var Space = class Space2 {
|
|
|
1945
1938
|
return this._genesisFeedKey;
|
|
1946
1939
|
}
|
|
1947
1940
|
get controlFeedKey() {
|
|
1948
|
-
|
|
1949
|
-
return (_a = this._controlFeed) == null ? void 0 : _a.key;
|
|
1941
|
+
return this._controlFeed?.key;
|
|
1950
1942
|
}
|
|
1951
1943
|
get dataFeedKey() {
|
|
1952
|
-
|
|
1953
|
-
return (_a = this._dataFeed) == null ? void 0 : _a.key;
|
|
1944
|
+
return this._dataFeed?.key;
|
|
1954
1945
|
}
|
|
1955
1946
|
get spaceState() {
|
|
1956
1947
|
return this._controlPipeline.spaceState;
|
|
@@ -1970,7 +1961,7 @@ var Space = class Space2 {
|
|
|
1970
1961
|
setControlFeed(feed) {
|
|
1971
1962
|
invariant9(!this._controlFeed, "Control feed already set.", {
|
|
1972
1963
|
F: __dxlog_file11,
|
|
1973
|
-
L:
|
|
1964
|
+
L: 183,
|
|
1974
1965
|
S: this,
|
|
1975
1966
|
A: [
|
|
1976
1967
|
"!this._controlFeed",
|
|
@@ -1982,10 +1973,9 @@ var Space = class Space2 {
|
|
|
1982
1973
|
return this;
|
|
1983
1974
|
}
|
|
1984
1975
|
setDataFeed(feed) {
|
|
1985
|
-
var _a;
|
|
1986
1976
|
invariant9(!this._dataFeed, "Data feed already set.", {
|
|
1987
1977
|
F: __dxlog_file11,
|
|
1988
|
-
L:
|
|
1978
|
+
L: 190,
|
|
1989
1979
|
S: this,
|
|
1990
1980
|
A: [
|
|
1991
1981
|
"!this._dataFeed",
|
|
@@ -1993,7 +1983,7 @@ var Space = class Space2 {
|
|
|
1993
1983
|
]
|
|
1994
1984
|
});
|
|
1995
1985
|
this._dataFeed = feed;
|
|
1996
|
-
|
|
1986
|
+
this._dataPipeline.pipeline?.setWriteFeed(feed);
|
|
1997
1987
|
return this;
|
|
1998
1988
|
}
|
|
1999
1989
|
/**
|
|
@@ -2008,10 +1998,10 @@ var Space = class Space2 {
|
|
|
2008
1998
|
// getDataFeeds(): FeedInfo[] {
|
|
2009
1999
|
// return this._dataPipeline?.getFeeds();
|
|
2010
2000
|
// }
|
|
2011
|
-
async open() {
|
|
2001
|
+
async open(ctx) {
|
|
2012
2002
|
log10("opening...", void 0, {
|
|
2013
2003
|
F: __dxlog_file11,
|
|
2014
|
-
L:
|
|
2004
|
+
L: 212,
|
|
2015
2005
|
S: this,
|
|
2016
2006
|
C: (f, a) => f(...a)
|
|
2017
2007
|
});
|
|
@@ -2024,7 +2014,7 @@ var Space = class Space2 {
|
|
|
2024
2014
|
this._isOpen = true;
|
|
2025
2015
|
log10("opened", void 0, {
|
|
2026
2016
|
F: __dxlog_file11,
|
|
2027
|
-
L:
|
|
2017
|
+
L: 223,
|
|
2028
2018
|
S: this,
|
|
2029
2019
|
C: (f, a) => f(...a)
|
|
2030
2020
|
});
|
|
@@ -2034,7 +2024,7 @@ var Space = class Space2 {
|
|
|
2034
2024
|
key: this._key
|
|
2035
2025
|
}, {
|
|
2036
2026
|
F: __dxlog_file11,
|
|
2037
|
-
L:
|
|
2027
|
+
L: 228,
|
|
2038
2028
|
S: this,
|
|
2039
2029
|
C: (f, a) => f(...a)
|
|
2040
2030
|
});
|
|
@@ -2048,7 +2038,7 @@ var Space = class Space2 {
|
|
|
2048
2038
|
this._isOpen = false;
|
|
2049
2039
|
log10("closed", void 0, {
|
|
2050
2040
|
F: __dxlog_file11,
|
|
2051
|
-
L:
|
|
2041
|
+
L: 241,
|
|
2052
2042
|
S: this,
|
|
2053
2043
|
C: (f, a) => f(...a)
|
|
2054
2044
|
});
|
|
@@ -2056,13 +2046,13 @@ var Space = class Space2 {
|
|
|
2056
2046
|
async initializeDataPipeline() {
|
|
2057
2047
|
log10("initializeDataPipeline", void 0, {
|
|
2058
2048
|
F: __dxlog_file11,
|
|
2059
|
-
L:
|
|
2049
|
+
L: 246,
|
|
2060
2050
|
S: this,
|
|
2061
2051
|
C: (f, a) => f(...a)
|
|
2062
2052
|
});
|
|
2063
2053
|
invariant9(this._isOpen, "Space must be open to initialize data pipeline.", {
|
|
2064
2054
|
F: __dxlog_file11,
|
|
2065
|
-
L:
|
|
2055
|
+
L: 247,
|
|
2066
2056
|
S: this,
|
|
2067
2057
|
A: [
|
|
2068
2058
|
"this._isOpen",
|
|
@@ -2076,7 +2066,8 @@ _ts_decorate6([
|
|
|
2076
2066
|
logInfo
|
|
2077
2067
|
], Space.prototype, "key", null);
|
|
2078
2068
|
_ts_decorate6([
|
|
2079
|
-
synchronized4
|
|
2069
|
+
synchronized4,
|
|
2070
|
+
trace.span()
|
|
2080
2071
|
], Space.prototype, "open", null);
|
|
2081
2072
|
_ts_decorate6([
|
|
2082
2073
|
synchronized4
|
|
@@ -2085,7 +2076,8 @@ _ts_decorate6([
|
|
|
2085
2076
|
synchronized4
|
|
2086
2077
|
], Space.prototype, "initializeDataPipeline", null);
|
|
2087
2078
|
Space = _ts_decorate6([
|
|
2088
|
-
trackLeaks3("open", "close")
|
|
2079
|
+
trackLeaks3("open", "close"),
|
|
2080
|
+
trace.resource()
|
|
2089
2081
|
], Space);
|
|
2090
2082
|
|
|
2091
2083
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
@@ -2256,7 +2248,6 @@ var SpaceProtocolSession = class {
|
|
|
2256
2248
|
provider: this._swarmIdentity.credentialProvider,
|
|
2257
2249
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
2258
2250
|
onAuthSuccess: () => {
|
|
2259
|
-
var _a;
|
|
2260
2251
|
log11("Peer authenticated", void 0, {
|
|
2261
2252
|
F: __dxlog_file12,
|
|
2262
2253
|
L: 236,
|
|
@@ -2264,12 +2255,11 @@ var SpaceProtocolSession = class {
|
|
|
2264
2255
|
C: (f, a) => f(...a)
|
|
2265
2256
|
});
|
|
2266
2257
|
this._authStatus = AuthStatus.SUCCESS;
|
|
2267
|
-
|
|
2258
|
+
this._onSessionAuth?.(this._teleport);
|
|
2268
2259
|
},
|
|
2269
2260
|
onAuthFailure: () => {
|
|
2270
|
-
var _a;
|
|
2271
2261
|
this._authStatus = AuthStatus.FAILURE;
|
|
2272
|
-
|
|
2262
|
+
this._onAuthFailure?.(this._teleport);
|
|
2273
2263
|
}
|
|
2274
2264
|
}));
|
|
2275
2265
|
this._teleport.addExtension("dxos.mesh.teleport.replicator", this.replicator);
|
|
@@ -2291,7 +2281,7 @@ import { synchronized as synchronized5, trackLeaks as trackLeaks4 } from "@dxos/
|
|
|
2291
2281
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
2292
2282
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2293
2283
|
import { log as log12 } from "@dxos/log";
|
|
2294
|
-
import { trace } from "@dxos/protocols";
|
|
2284
|
+
import { trace as trace2 } from "@dxos/protocols";
|
|
2295
2285
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
2296
2286
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
2297
2287
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -2327,8 +2317,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2327
2317
|
].map((space) => space.close()));
|
|
2328
2318
|
}
|
|
2329
2319
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2330
|
-
|
|
2331
|
-
log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
|
|
2320
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace2.begin({
|
|
2332
2321
|
id: this._instanceId
|
|
2333
2322
|
}), {
|
|
2334
2323
|
F: __dxlog_file13,
|
|
@@ -2344,7 +2333,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2344
2333
|
S: this,
|
|
2345
2334
|
C: (f, a) => f(...a)
|
|
2346
2335
|
});
|
|
2347
|
-
const genesisFeed = await this._feedStore.openFeed(
|
|
2336
|
+
const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? failUndefined2());
|
|
2348
2337
|
const spaceKey = metadata.key;
|
|
2349
2338
|
const protocol = new SpaceProtocol({
|
|
2350
2339
|
topic: spaceKey,
|
|
@@ -2366,7 +2355,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2366
2355
|
memberKey
|
|
2367
2356
|
});
|
|
2368
2357
|
this._spaces.set(space.key, space);
|
|
2369
|
-
log12.trace("dxos.echo.space-manager.construct-space",
|
|
2358
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace2.end({
|
|
2370
2359
|
id: this._instanceId
|
|
2371
2360
|
}), {
|
|
2372
2361
|
F: __dxlog_file13,
|
|
@@ -2413,4 +2402,4 @@ export {
|
|
|
2413
2402
|
SpaceProtocolSession,
|
|
2414
2403
|
SpaceManager
|
|
2415
2404
|
};
|
|
2416
|
-
//# sourceMappingURL=chunk-
|
|
2405
|
+
//# sourceMappingURL=chunk-WS36YFR3.mjs.map
|