@dxos/echo-pipeline 0.1.53-main.3ecc504 → 0.1.53-main.499755c
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-SCMKAWNW.mjs} +386 -366
- package/dist/lib/browser/chunk-SCMKAWNW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +2 -2
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +2 -2
- package/dist/lib/browser/testing/index.mjs.map +1 -1
- package/dist/lib/node/index.cjs +452 -432
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +436 -416
- 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,13 +1,14 @@
|
|
|
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
|
-
|
|
10
|
+
import { arrayToBuffer } from "@dxos/util";
|
|
11
|
+
function _ts_decorate(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")
|
|
13
14
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -16,7 +17,8 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
16
17
|
if (d = decorators[i])
|
|
17
18
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
18
19
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
19
|
-
}
|
|
20
|
+
}
|
|
21
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
20
22
|
var emptyEchoMetadata = () => ({
|
|
21
23
|
version: STORAGE_VERSION,
|
|
22
24
|
spaces: [],
|
|
@@ -61,10 +63,10 @@ var MetadataStore = class {
|
|
|
61
63
|
size: dataSize,
|
|
62
64
|
checksum
|
|
63
65
|
}, {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
F: __dxlog_file,
|
|
67
|
+
L: 69,
|
|
68
|
+
S: this,
|
|
69
|
+
C: (f, a) => f(...a)
|
|
68
70
|
});
|
|
69
71
|
if (fileLength < dataSize + 8) {
|
|
70
72
|
throw new DataCorruptionError("Metadata size is smaller than expected.");
|
|
@@ -79,10 +81,10 @@ var MetadataStore = class {
|
|
|
79
81
|
log.error("failed to load metadata", {
|
|
80
82
|
err
|
|
81
83
|
}, {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
F: __dxlog_file,
|
|
85
|
+
L: 84,
|
|
86
|
+
S: this,
|
|
87
|
+
C: (f, a) => f(...a)
|
|
86
88
|
});
|
|
87
89
|
this._metadata = emptyEchoMetadata();
|
|
88
90
|
} finally {
|
|
@@ -100,7 +102,7 @@ var MetadataStore = class {
|
|
|
100
102
|
this.update.emit(data);
|
|
101
103
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
102
104
|
try {
|
|
103
|
-
const encoded =
|
|
105
|
+
const encoded = arrayToBuffer(schema.getCodecForType("dxos.echo.metadata.EchoMetadata").encode(data));
|
|
104
106
|
const checksum = CRC32.buf(encoded);
|
|
105
107
|
const result = Buffer.alloc(8 + encoded.length);
|
|
106
108
|
result.writeInt32LE(encoded.length, 0);
|
|
@@ -111,10 +113,10 @@ var MetadataStore = class {
|
|
|
111
113
|
size: encoded.length,
|
|
112
114
|
checksum
|
|
113
115
|
}, {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
F: __dxlog_file,
|
|
117
|
+
L: 116,
|
|
118
|
+
S: this,
|
|
119
|
+
C: (f, a) => f(...a)
|
|
118
120
|
});
|
|
119
121
|
} finally {
|
|
120
122
|
await file.close();
|
|
@@ -126,18 +128,18 @@ var MetadataStore = class {
|
|
|
126
128
|
return this._metadata.identity.haloSpace;
|
|
127
129
|
}
|
|
128
130
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
129
|
-
|
|
131
|
+
invariant(space, "Space not found");
|
|
130
132
|
return space;
|
|
131
133
|
}
|
|
132
134
|
/**
|
|
133
135
|
* Clears storage - doesn't work for now.
|
|
134
136
|
*/
|
|
135
137
|
async clear() {
|
|
136
|
-
log("clearing all metadata",
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
log("clearing all metadata", void 0, {
|
|
139
|
+
F: __dxlog_file,
|
|
140
|
+
L: 137,
|
|
141
|
+
S: this,
|
|
142
|
+
C: (f, a) => f(...a)
|
|
141
143
|
});
|
|
142
144
|
await this._directory.delete();
|
|
143
145
|
this._metadata = emptyEchoMetadata();
|
|
@@ -146,13 +148,13 @@ var MetadataStore = class {
|
|
|
146
148
|
return this._metadata.identity;
|
|
147
149
|
}
|
|
148
150
|
async setIdentityRecord(record) {
|
|
149
|
-
|
|
151
|
+
invariant(!this._metadata.identity, "Cannot overwrite existing identity in metadata");
|
|
150
152
|
this._metadata.identity = record;
|
|
151
153
|
await this._save();
|
|
152
154
|
}
|
|
153
155
|
async addSpace(record) {
|
|
154
156
|
var _a, _b, _c;
|
|
155
|
-
|
|
157
|
+
invariant(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata");
|
|
156
158
|
((_c = (_b = this._metadata).spaces) != null ? _c : _b.spaces = []).push(record);
|
|
157
159
|
await this._save();
|
|
158
160
|
}
|
|
@@ -175,10 +177,10 @@ var MetadataStore = class {
|
|
|
175
177
|
await this._save();
|
|
176
178
|
}
|
|
177
179
|
};
|
|
178
|
-
|
|
180
|
+
_ts_decorate([
|
|
179
181
|
synchronized
|
|
180
182
|
], MetadataStore.prototype, "load", null);
|
|
181
|
-
|
|
183
|
+
_ts_decorate([
|
|
182
184
|
synchronized
|
|
183
185
|
], MetadataStore.prototype, "_save", null);
|
|
184
186
|
var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
@@ -190,10 +192,10 @@ var codec = schema2.getCodecForType("dxos.echo.feed.FeedMessage");
|
|
|
190
192
|
var valueEncoding = createCodecEncoding(codec);
|
|
191
193
|
|
|
192
194
|
// packages/core/echo/echo-pipeline/src/common/feeds.ts
|
|
193
|
-
import
|
|
195
|
+
import invariant2 from "tiny-invariant";
|
|
194
196
|
var createMappedFeedWriter = (mapper, writer) => {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
invariant2(mapper);
|
|
198
|
+
invariant2(writer);
|
|
197
199
|
return {
|
|
198
200
|
write: async (data, options) => await writer.write(await mapper(data), options)
|
|
199
201
|
};
|
|
@@ -204,7 +206,7 @@ import { Event as Event2 } from "@dxos/async";
|
|
|
204
206
|
import { timed } from "@dxos/debug";
|
|
205
207
|
import { log as log2 } from "@dxos/log";
|
|
206
208
|
import { Timeframe } from "@dxos/timeframe";
|
|
207
|
-
|
|
209
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
208
210
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
209
211
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
210
212
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -213,7 +215,8 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
213
215
|
if (d = decorators[i])
|
|
214
216
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
215
217
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
216
|
-
}
|
|
218
|
+
}
|
|
219
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
|
|
217
220
|
var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
218
221
|
feedKey,
|
|
219
222
|
index
|
|
@@ -272,10 +275,10 @@ var TimeframeClock = class {
|
|
|
272
275
|
target,
|
|
273
276
|
current: this._timeframe
|
|
274
277
|
}, {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
278
|
+
F: __dxlog_file2,
|
|
279
|
+
L: 73,
|
|
280
|
+
S: this,
|
|
281
|
+
C: (f, a) => f(...a)
|
|
279
282
|
});
|
|
280
283
|
await this.update.waitForCondition(() => {
|
|
281
284
|
log2("check if reached", {
|
|
@@ -283,21 +286,21 @@ var TimeframeClock = class {
|
|
|
283
286
|
current: this._timeframe,
|
|
284
287
|
deps: Timeframe.dependencies(target, this._timeframe)
|
|
285
288
|
}, {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
289
|
+
F: __dxlog_file2,
|
|
290
|
+
L: 75,
|
|
291
|
+
S: this,
|
|
292
|
+
C: (f, a) => f(...a)
|
|
290
293
|
});
|
|
291
294
|
return Timeframe.dependencies(target, this._timeframe).isEmpty();
|
|
292
295
|
});
|
|
293
296
|
}
|
|
294
297
|
};
|
|
295
|
-
|
|
298
|
+
_ts_decorate2([
|
|
296
299
|
timed(5e3)
|
|
297
300
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
298
301
|
|
|
299
302
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
300
|
-
import
|
|
303
|
+
import invariant4 from "tiny-invariant";
|
|
301
304
|
import { Event as Event3, sleep, synchronized as synchronized2, Trigger } from "@dxos/async";
|
|
302
305
|
import { Context, rejectOnDispose } from "@dxos/context";
|
|
303
306
|
import { failUndefined } from "@dxos/debug";
|
|
@@ -308,24 +311,29 @@ import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
|
308
311
|
import { ComplexMap } from "@dxos/util";
|
|
309
312
|
|
|
310
313
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
311
|
-
import
|
|
312
|
-
import
|
|
313
|
-
var
|
|
314
|
+
import invariant3 from "tiny-invariant";
|
|
315
|
+
import { log as log3 } from "@dxos/log";
|
|
316
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
|
|
314
317
|
var createMessageSelector = (timeframeClock) => {
|
|
315
318
|
return (messages) => {
|
|
316
319
|
for (let i = 0; i < messages.length; i++) {
|
|
317
320
|
const { data: { timeframe } } = messages[i];
|
|
318
|
-
|
|
321
|
+
invariant3(timeframe);
|
|
319
322
|
if (!timeframeClock.hasGaps(timeframe)) {
|
|
320
323
|
return i;
|
|
321
324
|
}
|
|
322
325
|
}
|
|
323
|
-
log3("Skipping..."
|
|
326
|
+
log3("Skipping...", void 0, {
|
|
327
|
+
F: __dxlog_file3,
|
|
328
|
+
L: 34,
|
|
329
|
+
S: void 0,
|
|
330
|
+
C: (f, a) => f(...a)
|
|
331
|
+
});
|
|
324
332
|
};
|
|
325
333
|
};
|
|
326
334
|
|
|
327
335
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
328
|
-
|
|
336
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
329
337
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
330
338
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
331
339
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -334,7 +342,8 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
334
342
|
if (d = decorators[i])
|
|
335
343
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
336
344
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
337
|
-
}
|
|
345
|
+
}
|
|
346
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
338
347
|
var PipelineState = class {
|
|
339
348
|
// prettier-ignore
|
|
340
349
|
constructor(_feeds, _timeframeClock) {
|
|
@@ -390,10 +399,10 @@ var PipelineState = class {
|
|
|
390
399
|
current: this.timeframe,
|
|
391
400
|
target: this.targetTimeframe
|
|
392
401
|
}, {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
402
|
+
F: __dxlog_file4,
|
|
403
|
+
L: 118,
|
|
404
|
+
S: this,
|
|
405
|
+
C: (f, a) => f(...a)
|
|
397
406
|
});
|
|
398
407
|
(_a = this._reachedTargetPromise) != null ? _a : this._reachedTargetPromise = Promise.race([
|
|
399
408
|
this._timeframeClock.update.waitForCondition(() => {
|
|
@@ -420,10 +429,10 @@ var PipelineState = class {
|
|
|
420
429
|
target: this.targetTimeframe,
|
|
421
430
|
dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
|
|
422
431
|
}, {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
432
|
+
F: __dxlog_file4,
|
|
433
|
+
L: 144,
|
|
434
|
+
S: this,
|
|
435
|
+
C: (f, a) => f(...a)
|
|
427
436
|
});
|
|
428
437
|
})
|
|
429
438
|
]);
|
|
@@ -450,7 +459,7 @@ var Pipeline = class {
|
|
|
450
459
|
return this._state;
|
|
451
460
|
}
|
|
452
461
|
get writer() {
|
|
453
|
-
|
|
462
|
+
invariant4(this._writer, "Writer not set.");
|
|
454
463
|
return this._writer;
|
|
455
464
|
}
|
|
456
465
|
getFeeds() {
|
|
@@ -469,8 +478,8 @@ var Pipeline = class {
|
|
|
469
478
|
return this._feeds.has(feedKey);
|
|
470
479
|
}
|
|
471
480
|
setWriteFeed(feed) {
|
|
472
|
-
|
|
473
|
-
|
|
481
|
+
invariant4(!this._writer, "Writer already set.");
|
|
482
|
+
invariant4(feed.properties.writable, "Feed must be writable.");
|
|
474
483
|
this._writer = createMappedFeedWriter((payload) => ({
|
|
475
484
|
timeframe: this._timeframeClock.timeframe,
|
|
476
485
|
payload
|
|
@@ -478,37 +487,37 @@ var Pipeline = class {
|
|
|
478
487
|
}
|
|
479
488
|
async start() {
|
|
480
489
|
log4("starting...", {}, {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
490
|
+
F: __dxlog_file4,
|
|
491
|
+
L: 264,
|
|
492
|
+
S: this,
|
|
493
|
+
C: (f, a) => f(...a)
|
|
485
494
|
});
|
|
486
495
|
await this._initIterator();
|
|
487
496
|
await this._feedSetIterator.open();
|
|
488
|
-
log4("started",
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
497
|
+
log4("started", void 0, {
|
|
498
|
+
F: __dxlog_file4,
|
|
499
|
+
L: 267,
|
|
500
|
+
S: this,
|
|
501
|
+
C: (f, a) => f(...a)
|
|
493
502
|
});
|
|
494
503
|
this._isStarted = true;
|
|
495
504
|
}
|
|
496
505
|
async stop() {
|
|
497
506
|
var _a;
|
|
498
507
|
log4("stopping...", {}, {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
508
|
+
F: __dxlog_file4,
|
|
509
|
+
L: 273,
|
|
510
|
+
S: this,
|
|
511
|
+
C: (f, a) => f(...a)
|
|
503
512
|
});
|
|
504
513
|
this._isStopping = true;
|
|
505
514
|
await ((_a = this._feedSetIterator) == null ? void 0 : _a.close());
|
|
506
515
|
await this._processingTrigger.wait();
|
|
507
|
-
log4("stopped",
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
516
|
+
log4("stopped", void 0, {
|
|
517
|
+
F: __dxlog_file4,
|
|
518
|
+
L: 277,
|
|
519
|
+
S: this,
|
|
520
|
+
C: (f, a) => f(...a)
|
|
512
521
|
});
|
|
513
522
|
this._isStarted = false;
|
|
514
523
|
}
|
|
@@ -516,7 +525,7 @@ var Pipeline = class {
|
|
|
516
525
|
* @param timeframe Timeframe of already processed messages. The pipeline will start processing messages AFTER this timeframe.
|
|
517
526
|
*/
|
|
518
527
|
async setCursor(timeframe) {
|
|
519
|
-
|
|
528
|
+
invariant4(!this._isStarted || this._isPaused, "Invalid state.");
|
|
520
529
|
this._state._startTimeframe = timeframe;
|
|
521
530
|
this._timeframeClock.setTimeframe(timeframe);
|
|
522
531
|
for (const feed of this._feeds.values()) {
|
|
@@ -532,7 +541,7 @@ var Pipeline = class {
|
|
|
532
541
|
* Calling pause while processing will cause a deadlock.
|
|
533
542
|
*/
|
|
534
543
|
async pause() {
|
|
535
|
-
|
|
544
|
+
invariant4(this._isStarted, "Pipeline is not open.");
|
|
536
545
|
if (this._isPaused) {
|
|
537
546
|
return;
|
|
538
547
|
}
|
|
@@ -541,8 +550,8 @@ var Pipeline = class {
|
|
|
541
550
|
this._isPaused = true;
|
|
542
551
|
}
|
|
543
552
|
async unpause() {
|
|
544
|
-
|
|
545
|
-
|
|
553
|
+
invariant4(this._isStarted, "Pipeline is not open.");
|
|
554
|
+
invariant4(this._isPaused, "Pipeline is not paused.");
|
|
546
555
|
this._pauseTrigger.wake();
|
|
547
556
|
this._isPaused = false;
|
|
548
557
|
}
|
|
@@ -551,15 +560,15 @@ var Pipeline = class {
|
|
|
551
560
|
* Updates the timeframe clock after the message has bee processed.
|
|
552
561
|
*/
|
|
553
562
|
async *consume() {
|
|
554
|
-
|
|
563
|
+
invariant4(!this._isOpen, "Pipeline is already being consumed.");
|
|
555
564
|
this._isOpen = true;
|
|
556
|
-
|
|
565
|
+
invariant4(this._feedSetIterator, "Iterator not initialized.");
|
|
557
566
|
let lastFeedSetIterator = this._feedSetIterator;
|
|
558
567
|
let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
559
568
|
while (!this._isStopping) {
|
|
560
569
|
await this._pauseTrigger.wait();
|
|
561
570
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
562
|
-
|
|
571
|
+
invariant4(this._feedSetIterator, "Iterator not initialized.");
|
|
563
572
|
lastFeedSetIterator = this._feedSetIterator;
|
|
564
573
|
iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
565
574
|
}
|
|
@@ -581,11 +590,11 @@ var Pipeline = class {
|
|
|
581
590
|
const timeframe = this._state._startTimeframe;
|
|
582
591
|
const seq = (_a = timeframe.get(feed.key)) != null ? _a : 0;
|
|
583
592
|
feed.undownload({
|
|
584
|
-
callback: () => log4("Undownloaded",
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
593
|
+
callback: () => log4("Undownloaded", void 0, {
|
|
594
|
+
F: __dxlog_file4,
|
|
595
|
+
L: 371,
|
|
596
|
+
S: this,
|
|
597
|
+
C: (f, a) => f(...a)
|
|
589
598
|
})
|
|
590
599
|
});
|
|
591
600
|
feed.download({
|
|
@@ -595,10 +604,10 @@ var Pipeline = class {
|
|
|
595
604
|
log4("failed to download feed", {
|
|
596
605
|
err
|
|
597
606
|
}, {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
607
|
+
F: __dxlog_file4,
|
|
608
|
+
L: 374,
|
|
609
|
+
S: this,
|
|
610
|
+
C: (f, a) => f(...a)
|
|
602
611
|
});
|
|
603
612
|
});
|
|
604
613
|
}
|
|
@@ -608,11 +617,11 @@ var Pipeline = class {
|
|
|
608
617
|
stallTimeout: 1e3
|
|
609
618
|
});
|
|
610
619
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
611
|
-
log4.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`,
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
620
|
+
log4.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
621
|
+
F: __dxlog_file4,
|
|
622
|
+
L: 384,
|
|
623
|
+
S: this,
|
|
624
|
+
C: (f, a) => f(...a)
|
|
616
625
|
});
|
|
617
626
|
this._state.stalled.emit();
|
|
618
627
|
});
|
|
@@ -621,30 +630,31 @@ var Pipeline = class {
|
|
|
621
630
|
}
|
|
622
631
|
}
|
|
623
632
|
};
|
|
624
|
-
|
|
633
|
+
_ts_decorate3([
|
|
625
634
|
synchronized2
|
|
626
635
|
], Pipeline.prototype, "start", null);
|
|
627
|
-
|
|
636
|
+
_ts_decorate3([
|
|
628
637
|
synchronized2
|
|
629
638
|
], Pipeline.prototype, "stop", null);
|
|
630
|
-
|
|
639
|
+
_ts_decorate3([
|
|
631
640
|
synchronized2
|
|
632
641
|
], Pipeline.prototype, "setCursor", null);
|
|
633
|
-
|
|
642
|
+
_ts_decorate3([
|
|
634
643
|
synchronized2
|
|
635
644
|
], Pipeline.prototype, "pause", null);
|
|
636
|
-
|
|
645
|
+
_ts_decorate3([
|
|
637
646
|
synchronized2
|
|
638
647
|
], Pipeline.prototype, "unpause", null);
|
|
639
648
|
|
|
640
649
|
// packages/core/echo/echo-pipeline/src/space/auth.ts
|
|
641
|
-
import
|
|
650
|
+
import invariant5 from "tiny-invariant";
|
|
642
651
|
import { runInContext, scheduleTask } from "@dxos/async";
|
|
643
652
|
import { Context as Context2 } from "@dxos/context";
|
|
644
653
|
import { randomBytes } from "@dxos/crypto";
|
|
645
654
|
import { log as log5 } from "@dxos/log";
|
|
646
655
|
import { schema as schema3 } from "@dxos/protocols";
|
|
647
656
|
import { RpcExtension } from "@dxos/teleport";
|
|
657
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
|
|
648
658
|
var AuthExtension = class extends RpcExtension {
|
|
649
659
|
constructor(_authParams) {
|
|
650
660
|
super({
|
|
@@ -659,11 +669,11 @@ var AuthExtension = class extends RpcExtension {
|
|
|
659
669
|
this._authParams = _authParams;
|
|
660
670
|
this._ctx = new Context2({
|
|
661
671
|
onError: (err) => {
|
|
662
|
-
log5.catch(err,
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
672
|
+
log5.catch(err, void 0, {
|
|
673
|
+
F: __dxlog_file5,
|
|
674
|
+
L: 29,
|
|
675
|
+
S: this,
|
|
676
|
+
C: (f, a) => f(...a)
|
|
667
677
|
});
|
|
668
678
|
}
|
|
669
679
|
});
|
|
@@ -682,10 +692,10 @@ var AuthExtension = class extends RpcExtension {
|
|
|
682
692
|
};
|
|
683
693
|
} catch (err) {
|
|
684
694
|
log5.error("failed to generate auth credentials", err, {
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
695
|
+
F: __dxlog_file5,
|
|
696
|
+
L: 56,
|
|
697
|
+
S: this,
|
|
698
|
+
C: (f, a) => f(...a)
|
|
689
699
|
});
|
|
690
700
|
throw new Error("auth rejected");
|
|
691
701
|
}
|
|
@@ -701,16 +711,16 @@ var AuthExtension = class extends RpcExtension {
|
|
|
701
711
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
702
712
|
challenge
|
|
703
713
|
});
|
|
704
|
-
|
|
714
|
+
invariant5((credential == null ? void 0 : credential.length) > 0, "invalid credential");
|
|
705
715
|
const success = await this._authParams.verifier(challenge, credential);
|
|
706
|
-
|
|
716
|
+
invariant5(success, "credential not verified");
|
|
707
717
|
runInContext(this._ctx, () => this._authParams.onAuthSuccess());
|
|
708
718
|
} catch (err) {
|
|
709
719
|
log5("auth failed", err, {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
720
|
+
F: __dxlog_file5,
|
|
721
|
+
L: 75,
|
|
722
|
+
S: this,
|
|
723
|
+
C: (f, a) => f(...a)
|
|
714
724
|
});
|
|
715
725
|
this.close();
|
|
716
726
|
this._authParams.onAuthFailure();
|
|
@@ -724,11 +734,12 @@ var AuthExtension = class extends RpcExtension {
|
|
|
724
734
|
};
|
|
725
735
|
|
|
726
736
|
// packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts
|
|
727
|
-
import
|
|
737
|
+
import invariant6 from "tiny-invariant";
|
|
728
738
|
import { Stream } from "@dxos/codec-protobuf";
|
|
729
739
|
import { tagMutationsInBatch, setMetadataOnObject } from "@dxos/echo-db";
|
|
730
740
|
import { log as log6 } from "@dxos/log";
|
|
731
741
|
import { ComplexMap as ComplexMap2 } from "@dxos/util";
|
|
742
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts";
|
|
732
743
|
var DataServiceHost = class {
|
|
733
744
|
constructor(_itemManager, _itemDemuxer, _writeStream) {
|
|
734
745
|
this._itemManager = _itemManager;
|
|
@@ -750,15 +761,15 @@ var DataServiceHost = class {
|
|
|
750
761
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
751
762
|
var _a;
|
|
752
763
|
const { batch, meta } = message;
|
|
753
|
-
|
|
764
|
+
invariant6(!meta.clientTag, "Unexpected client tag in mutation message");
|
|
754
765
|
log6("message", {
|
|
755
766
|
batch,
|
|
756
767
|
meta
|
|
757
768
|
}, {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
769
|
+
F: __dxlog_file6,
|
|
770
|
+
L: 51,
|
|
771
|
+
S: this,
|
|
772
|
+
C: (f, a) => f(...a)
|
|
762
773
|
});
|
|
763
774
|
const clientTag = this._clientTagMap.get([
|
|
764
775
|
message.meta.feedKey,
|
|
@@ -783,15 +794,15 @@ var DataServiceHost = class {
|
|
|
783
794
|
}
|
|
784
795
|
async write(request) {
|
|
785
796
|
var _a, _b;
|
|
786
|
-
|
|
797
|
+
invariant6(this._writeStream, "Cannot write mutations in readonly mode");
|
|
787
798
|
log6("write", {
|
|
788
799
|
clientTag: request.clientTag,
|
|
789
800
|
objectCount: (_b = (_a = request.batch.objects) == null ? void 0 : _a.length) != null ? _b : 0
|
|
790
801
|
}, {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
802
|
+
F: __dxlog_file6,
|
|
803
|
+
L: 79,
|
|
804
|
+
S: this,
|
|
805
|
+
C: (f, a) => f(...a)
|
|
795
806
|
});
|
|
796
807
|
const message = createDataMessage(request.batch);
|
|
797
808
|
const receipt = await this._writeStream.write(message, {
|
|
@@ -802,10 +813,10 @@ var DataServiceHost = class {
|
|
|
802
813
|
feedKey: receipt2.feedKey,
|
|
803
814
|
seq: receipt2.seq
|
|
804
815
|
}, {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
816
|
+
F: __dxlog_file6,
|
|
817
|
+
L: 88,
|
|
818
|
+
S: this,
|
|
819
|
+
C: (f, a) => f(...a)
|
|
809
820
|
});
|
|
810
821
|
this._clientTagMap.set([
|
|
811
822
|
receipt2.feedKey,
|
|
@@ -875,7 +886,7 @@ import { timed as timed2 } from "@dxos/debug";
|
|
|
875
886
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
876
887
|
import { schema as schema4 } from "@dxos/protocols";
|
|
877
888
|
import { BlobMeta } from "@dxos/protocols/proto/dxos/echo/blob";
|
|
878
|
-
|
|
889
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
879
890
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
880
891
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
881
892
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -884,7 +895,7 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
884
895
|
if (d = decorators[i])
|
|
885
896
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
886
897
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
887
|
-
}
|
|
898
|
+
}
|
|
888
899
|
var SnapshotManager = class SnapshotManager2 {
|
|
889
900
|
// prettier-ignore
|
|
890
901
|
constructor(_snapshotStore, _blobStore, _blobSync) {
|
|
@@ -915,10 +926,10 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
915
926
|
return PublicKey2.from(id).toHex();
|
|
916
927
|
}
|
|
917
928
|
};
|
|
918
|
-
|
|
929
|
+
_ts_decorate4([
|
|
919
930
|
timed2(1e4)
|
|
920
931
|
], SnapshotManager.prototype, "load", null);
|
|
921
|
-
SnapshotManager =
|
|
932
|
+
SnapshotManager = _ts_decorate4([
|
|
922
933
|
trackLeaks("open", "close")
|
|
923
934
|
], SnapshotManager);
|
|
924
935
|
|
|
@@ -968,11 +979,12 @@ var SnapshotStore = class {
|
|
|
968
979
|
};
|
|
969
980
|
|
|
970
981
|
// packages/core/echo/echo-pipeline/src/dbhost/data-service.ts
|
|
971
|
-
import
|
|
982
|
+
import invariant7 from "tiny-invariant";
|
|
972
983
|
import { raise } from "@dxos/debug";
|
|
973
984
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
974
985
|
import { log as log7 } from "@dxos/log";
|
|
975
986
|
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
987
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service.ts";
|
|
976
988
|
var DataServiceSubscriptions = class {
|
|
977
989
|
constructor() {
|
|
978
990
|
this._spaces = new ComplexMap3(PublicKey3.hash);
|
|
@@ -984,10 +996,10 @@ var DataServiceSubscriptions = class {
|
|
|
984
996
|
log7("Registering space", {
|
|
985
997
|
spaceKey
|
|
986
998
|
}, {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
999
|
+
F: __dxlog_file7,
|
|
1000
|
+
L: 31,
|
|
1001
|
+
S: this,
|
|
1002
|
+
C: (f, a) => f(...a)
|
|
991
1003
|
});
|
|
992
1004
|
this._spaces.set(spaceKey, host);
|
|
993
1005
|
}
|
|
@@ -995,10 +1007,10 @@ var DataServiceSubscriptions = class {
|
|
|
995
1007
|
log7("Unregistering space", {
|
|
996
1008
|
spaceKey
|
|
997
1009
|
}, {
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1010
|
+
F: __dxlog_file7,
|
|
1011
|
+
L: 36,
|
|
1012
|
+
S: this,
|
|
1013
|
+
C: (f, a) => f(...a)
|
|
1002
1014
|
});
|
|
1003
1015
|
this._spaces.delete(spaceKey);
|
|
1004
1016
|
}
|
|
@@ -1012,21 +1024,21 @@ var DataServiceImpl = class {
|
|
|
1012
1024
|
}
|
|
1013
1025
|
subscribe(request) {
|
|
1014
1026
|
var _a;
|
|
1015
|
-
|
|
1027
|
+
invariant7(request.spaceKey);
|
|
1016
1028
|
const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : raise(new Error(`space not found: ${request.spaceKey}`));
|
|
1017
1029
|
return host.subscribe();
|
|
1018
1030
|
}
|
|
1019
1031
|
write(request) {
|
|
1020
1032
|
var _a;
|
|
1021
|
-
|
|
1022
|
-
|
|
1033
|
+
invariant7(request.spaceKey);
|
|
1034
|
+
invariant7(request.batch);
|
|
1023
1035
|
const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : raise(new Error(`space not found: ${request.spaceKey}`));
|
|
1024
1036
|
return host.write(request);
|
|
1025
1037
|
}
|
|
1026
1038
|
};
|
|
1027
1039
|
|
|
1028
1040
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
1029
|
-
import
|
|
1041
|
+
import invariant8 from "tiny-invariant";
|
|
1030
1042
|
import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1031
1043
|
import { Context as Context3 } from "@dxos/context";
|
|
1032
1044
|
import { checkCredentialType } from "@dxos/credentials";
|
|
@@ -1034,7 +1046,7 @@ import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
|
|
|
1034
1046
|
import { CancelledError } from "@dxos/errors";
|
|
1035
1047
|
import { log as log8 } from "@dxos/log";
|
|
1036
1048
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
1037
|
-
|
|
1049
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
1038
1050
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1039
1051
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1040
1052
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1043,7 +1055,8 @@ var __decorate5 = function(decorators, target, key, desc) {
|
|
|
1043
1055
|
if (d = decorators[i])
|
|
1044
1056
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1045
1057
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1046
|
-
}
|
|
1058
|
+
}
|
|
1059
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
|
|
1047
1060
|
var MESSAGES_PER_SNAPSHOT = 10;
|
|
1048
1061
|
var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
|
|
1049
1062
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
|
|
@@ -1099,8 +1112,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1099
1112
|
}
|
|
1100
1113
|
const feedWriter = {
|
|
1101
1114
|
write: (data, options) => {
|
|
1102
|
-
|
|
1103
|
-
|
|
1115
|
+
invariant8(this._pipeline, "Pipeline is not initialized.");
|
|
1116
|
+
invariant8(this.currentEpoch, "Epoch is not initialized.");
|
|
1104
1117
|
return this._pipeline.writer.write({
|
|
1105
1118
|
data
|
|
1106
1119
|
}, options);
|
|
@@ -1119,11 +1132,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1119
1132
|
if (!this._isOpen) {
|
|
1120
1133
|
return;
|
|
1121
1134
|
}
|
|
1122
|
-
log8("close",
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1135
|
+
log8("close", void 0, {
|
|
1136
|
+
F: __dxlog_file8,
|
|
1137
|
+
L: 174,
|
|
1138
|
+
S: this,
|
|
1139
|
+
C: (f, a) => f(...a)
|
|
1127
1140
|
});
|
|
1128
1141
|
this._isOpen = false;
|
|
1129
1142
|
await this._ctx.dispose();
|
|
@@ -1134,11 +1147,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1134
1147
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1135
1148
|
}
|
|
1136
1149
|
} catch (err) {
|
|
1137
|
-
log8.catch(err,
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1150
|
+
log8.catch(err, void 0, {
|
|
1151
|
+
F: __dxlog_file8,
|
|
1152
|
+
L: 187,
|
|
1153
|
+
S: this,
|
|
1154
|
+
C: (f, a) => f(...a)
|
|
1142
1155
|
});
|
|
1143
1156
|
}
|
|
1144
1157
|
await ((_b = this.databaseHost) == null ? void 0 : _b.close());
|
|
@@ -1150,17 +1163,17 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1150
1163
|
await this._processEpochInSeparateTask(this.currentEpoch);
|
|
1151
1164
|
await waitForOneEpoch;
|
|
1152
1165
|
}
|
|
1153
|
-
|
|
1166
|
+
invariant8(this._pipeline, "Pipeline is not initialized.");
|
|
1154
1167
|
for await (const msg of this._pipeline.consume()) {
|
|
1155
1168
|
const { feedKey, seq, data } = msg;
|
|
1156
1169
|
log8("processing message", {
|
|
1157
1170
|
feedKey,
|
|
1158
1171
|
seq
|
|
1159
1172
|
}, {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1173
|
+
F: __dxlog_file8,
|
|
1174
|
+
L: 204,
|
|
1175
|
+
S: this,
|
|
1176
|
+
C: (f, a) => f(...a)
|
|
1164
1177
|
});
|
|
1165
1178
|
try {
|
|
1166
1179
|
if (data.payload.data) {
|
|
@@ -1169,10 +1182,10 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1169
1182
|
log8.error("Could not find feed.", {
|
|
1170
1183
|
feedKey
|
|
1171
1184
|
}, {
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1185
|
+
F: __dxlog_file8,
|
|
1186
|
+
L: 210,
|
|
1187
|
+
S: this,
|
|
1188
|
+
C: (f, a) => f(...a)
|
|
1176
1189
|
});
|
|
1177
1190
|
continue;
|
|
1178
1191
|
}
|
|
@@ -1190,25 +1203,25 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1190
1203
|
seq,
|
|
1191
1204
|
spaceKey: this._params.spaceKey.toHex()
|
|
1192
1205
|
}, {
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1206
|
+
F: __dxlog_file8,
|
|
1207
|
+
L: 224,
|
|
1208
|
+
S: this,
|
|
1209
|
+
C: (f, a) => f(...a)
|
|
1197
1210
|
});
|
|
1198
1211
|
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1199
1212
|
}
|
|
1200
1213
|
} catch (err) {
|
|
1201
|
-
log8.catch(err,
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1214
|
+
log8.catch(err, void 0, {
|
|
1215
|
+
F: __dxlog_file8,
|
|
1216
|
+
L: 234,
|
|
1217
|
+
S: this,
|
|
1218
|
+
C: (f, a) => f(...a)
|
|
1206
1219
|
});
|
|
1207
1220
|
}
|
|
1208
1221
|
}
|
|
1209
1222
|
}
|
|
1210
1223
|
_createSnapshot() {
|
|
1211
|
-
|
|
1224
|
+
invariant8(this.databaseHost, "Database backend is not initialized.");
|
|
1212
1225
|
return {
|
|
1213
1226
|
spaceKey: this._params.spaceKey.asUint8Array(),
|
|
1214
1227
|
timeframe: this._pipeline.state.timeframe,
|
|
@@ -1227,17 +1240,17 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1227
1240
|
try {
|
|
1228
1241
|
const propertiesItem = this.itemManager.items.find((item) => {
|
|
1229
1242
|
var _a2, _b;
|
|
1230
|
-
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = getStateMachineFromItem(item)) == null ? void 0 : _b.snapshot().type
|
|
1243
|
+
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";
|
|
1231
1244
|
});
|
|
1232
1245
|
if (propertiesItem) {
|
|
1233
1246
|
cache.properties = (_a = getStateMachineFromItem(propertiesItem)) == null ? void 0 : _a.snapshot();
|
|
1234
1247
|
}
|
|
1235
1248
|
} catch (err) {
|
|
1236
1249
|
log8.warn("Failed to cache properties", err, {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1250
|
+
F: __dxlog_file8,
|
|
1251
|
+
L: 269,
|
|
1252
|
+
S: this,
|
|
1253
|
+
C: (f, a) => f(...a)
|
|
1241
1254
|
});
|
|
1242
1255
|
}
|
|
1243
1256
|
await this._params.metadataStore.setCache(this._params.spaceKey, cache);
|
|
@@ -1260,18 +1273,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1260
1273
|
const ctx = new Context3({
|
|
1261
1274
|
onError: (err) => {
|
|
1262
1275
|
if (err instanceof CancelledError) {
|
|
1263
|
-
log8("Epoch processing cancelled.",
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1276
|
+
log8("Epoch processing cancelled.", void 0, {
|
|
1277
|
+
F: __dxlog_file8,
|
|
1278
|
+
L: 301,
|
|
1279
|
+
S: this,
|
|
1280
|
+
C: (f, a) => f(...a)
|
|
1268
1281
|
});
|
|
1269
1282
|
} else {
|
|
1270
|
-
log8.catch(err,
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1283
|
+
log8.catch(err, void 0, {
|
|
1284
|
+
F: __dxlog_file8,
|
|
1285
|
+
L: 303,
|
|
1286
|
+
S: this,
|
|
1287
|
+
C: (f, a) => f(...a)
|
|
1275
1288
|
});
|
|
1276
1289
|
}
|
|
1277
1290
|
}
|
|
@@ -1284,10 +1297,10 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1284
1297
|
log8("process epoch", {
|
|
1285
1298
|
epoch
|
|
1286
1299
|
}, {
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1300
|
+
F: __dxlog_file8,
|
|
1301
|
+
L: 313,
|
|
1302
|
+
S: this,
|
|
1303
|
+
C: (f, a) => f(...a)
|
|
1291
1304
|
});
|
|
1292
1305
|
await this._processEpoch(ctx, epoch.subject.assertion);
|
|
1293
1306
|
this.appliedEpoch = epoch;
|
|
@@ -1295,38 +1308,38 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1295
1308
|
});
|
|
1296
1309
|
}
|
|
1297
1310
|
async _processEpoch(ctx, epoch) {
|
|
1298
|
-
|
|
1299
|
-
|
|
1311
|
+
invariant8(this._isOpen, "Space is closed.");
|
|
1312
|
+
invariant8(this._pipeline);
|
|
1300
1313
|
this._lastProcessedEpoch = epoch.number;
|
|
1301
1314
|
log8("Processing epoch", {
|
|
1302
1315
|
epoch
|
|
1303
1316
|
}, {
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1317
|
+
F: __dxlog_file8,
|
|
1318
|
+
L: 327,
|
|
1319
|
+
S: this,
|
|
1320
|
+
C: (f, a) => f(...a)
|
|
1308
1321
|
});
|
|
1309
1322
|
if (epoch.snapshotCid) {
|
|
1310
1323
|
const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
|
|
1311
1324
|
this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
1312
1325
|
}
|
|
1313
|
-
log8("restarting pipeline for epoch",
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1326
|
+
log8("restarting pipeline for epoch", void 0, {
|
|
1327
|
+
F: __dxlog_file8,
|
|
1328
|
+
L: 335,
|
|
1329
|
+
S: this,
|
|
1330
|
+
C: (f, a) => f(...a)
|
|
1318
1331
|
});
|
|
1319
1332
|
await this._pipeline.pause();
|
|
1320
1333
|
await this._pipeline.setCursor(epoch.timeframe);
|
|
1321
1334
|
await this._pipeline.unpause();
|
|
1322
1335
|
}
|
|
1323
1336
|
async waitUntilTimeframe(timeframe) {
|
|
1324
|
-
|
|
1337
|
+
invariant8(this._pipeline, "Pipeline is not initialized.");
|
|
1325
1338
|
await this._pipeline.state.waitUntilTimeframe(timeframe);
|
|
1326
1339
|
}
|
|
1327
1340
|
async createEpoch() {
|
|
1328
|
-
|
|
1329
|
-
|
|
1341
|
+
invariant8(this._pipeline);
|
|
1342
|
+
invariant8(this.currentEpoch);
|
|
1330
1343
|
await this._pipeline.pause();
|
|
1331
1344
|
const snapshot = await this._createSnapshot();
|
|
1332
1345
|
const snapshotCid = await this._params.snapshotManager.store(snapshot);
|
|
@@ -1343,24 +1356,24 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1343
1356
|
await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
|
|
1344
1357
|
}
|
|
1345
1358
|
};
|
|
1346
|
-
|
|
1359
|
+
_ts_decorate5([
|
|
1347
1360
|
synchronized3
|
|
1348
1361
|
], DataPipeline.prototype, "open", null);
|
|
1349
|
-
|
|
1362
|
+
_ts_decorate5([
|
|
1350
1363
|
synchronized3
|
|
1351
1364
|
], DataPipeline.prototype, "close", null);
|
|
1352
|
-
|
|
1365
|
+
_ts_decorate5([
|
|
1353
1366
|
synchronized3
|
|
1354
1367
|
], DataPipeline.prototype, "_processEpoch", null);
|
|
1355
|
-
|
|
1368
|
+
_ts_decorate5([
|
|
1356
1369
|
synchronized3
|
|
1357
1370
|
], DataPipeline.prototype, "createEpoch", null);
|
|
1358
|
-
DataPipeline =
|
|
1371
|
+
DataPipeline = _ts_decorate5([
|
|
1359
1372
|
trackLeaks2("open", "close")
|
|
1360
1373
|
], DataPipeline);
|
|
1361
1374
|
|
|
1362
1375
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1363
|
-
import
|
|
1376
|
+
import invariant9 from "tiny-invariant";
|
|
1364
1377
|
import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeaks3, Lock } from "@dxos/async";
|
|
1365
1378
|
import { log as log10, logInfo } from "@dxos/log";
|
|
1366
1379
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
@@ -1373,6 +1386,7 @@ import { log as log9 } from "@dxos/log";
|
|
|
1373
1386
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1374
1387
|
import { Timeframe as Timeframe4 } from "@dxos/timeframe";
|
|
1375
1388
|
import { Callback } from "@dxos/util";
|
|
1389
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1376
1390
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1377
1391
|
var ControlPipeline = class {
|
|
1378
1392
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
@@ -1387,21 +1401,21 @@ var ControlPipeline = class {
|
|
|
1387
1401
|
log9("feed admitted", {
|
|
1388
1402
|
key: info.key
|
|
1389
1403
|
}, {
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1404
|
+
F: __dxlog_file9,
|
|
1405
|
+
L: 51,
|
|
1406
|
+
S: this,
|
|
1407
|
+
C: (f, a) => f(...a)
|
|
1394
1408
|
});
|
|
1395
1409
|
if (info.assertion.designation === AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
|
|
1396
1410
|
try {
|
|
1397
1411
|
const feed = await feedProvider(info.key);
|
|
1398
1412
|
await this._pipeline.addFeed(feed);
|
|
1399
1413
|
} catch (err) {
|
|
1400
|
-
log9.catch(err,
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1414
|
+
log9.catch(err, void 0, {
|
|
1415
|
+
F: __dxlog_file9,
|
|
1416
|
+
L: 59,
|
|
1417
|
+
S: this,
|
|
1418
|
+
C: (f, a) => f(...a)
|
|
1405
1419
|
});
|
|
1406
1420
|
}
|
|
1407
1421
|
}
|
|
@@ -1420,11 +1434,11 @@ var ControlPipeline = class {
|
|
|
1420
1434
|
this._pipeline.setWriteFeed(feed);
|
|
1421
1435
|
}
|
|
1422
1436
|
async start() {
|
|
1423
|
-
log9("starting...",
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1437
|
+
log9("starting...", void 0, {
|
|
1438
|
+
F: __dxlog_file9,
|
|
1439
|
+
L: 83,
|
|
1440
|
+
S: this,
|
|
1441
|
+
C: (f, a) => f(...a)
|
|
1428
1442
|
});
|
|
1429
1443
|
setTimeout(async () => {
|
|
1430
1444
|
for await (const msg of this._pipeline.consume()) {
|
|
@@ -1433,10 +1447,10 @@ var ControlPipeline = class {
|
|
|
1433
1447
|
key: msg.feedKey,
|
|
1434
1448
|
seq: msg.seq
|
|
1435
1449
|
}, {
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1450
|
+
F: __dxlog_file9,
|
|
1451
|
+
L: 88,
|
|
1452
|
+
S: this,
|
|
1453
|
+
C: (f, a) => f(...a)
|
|
1440
1454
|
});
|
|
1441
1455
|
if (msg.data.payload.credential) {
|
|
1442
1456
|
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
|
|
@@ -1444,31 +1458,31 @@ var ControlPipeline = class {
|
|
|
1444
1458
|
log9.warn("processing failed", {
|
|
1445
1459
|
msg
|
|
1446
1460
|
}, {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1461
|
+
F: __dxlog_file9,
|
|
1462
|
+
L: 95,
|
|
1463
|
+
S: this,
|
|
1464
|
+
C: (f, a) => f(...a)
|
|
1451
1465
|
});
|
|
1452
1466
|
} else {
|
|
1453
1467
|
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1454
1468
|
}
|
|
1455
1469
|
}
|
|
1456
1470
|
} catch (err) {
|
|
1457
|
-
log9.catch(err,
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1471
|
+
log9.catch(err, void 0, {
|
|
1472
|
+
F: __dxlog_file9,
|
|
1473
|
+
L: 101,
|
|
1474
|
+
S: this,
|
|
1475
|
+
C: (f, a) => f(...a)
|
|
1462
1476
|
});
|
|
1463
1477
|
}
|
|
1464
1478
|
}
|
|
1465
1479
|
});
|
|
1466
1480
|
await this._pipeline.start();
|
|
1467
|
-
log9("started",
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1481
|
+
log9("started", void 0, {
|
|
1482
|
+
F: __dxlog_file9,
|
|
1483
|
+
L: 107,
|
|
1484
|
+
S: this,
|
|
1485
|
+
C: (f, a) => f(...a)
|
|
1472
1486
|
});
|
|
1473
1487
|
}
|
|
1474
1488
|
async _noteTargetStateIfNeeded(timeframe) {
|
|
@@ -1478,19 +1492,19 @@ var ControlPipeline = class {
|
|
|
1478
1492
|
}
|
|
1479
1493
|
}
|
|
1480
1494
|
async stop() {
|
|
1481
|
-
log9("stopping...",
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1495
|
+
log9("stopping...", void 0, {
|
|
1496
|
+
F: __dxlog_file9,
|
|
1497
|
+
L: 121,
|
|
1498
|
+
S: this,
|
|
1499
|
+
C: (f, a) => f(...a)
|
|
1486
1500
|
});
|
|
1487
1501
|
await this._pipeline.stop();
|
|
1488
1502
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1489
|
-
log9("stopped",
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1503
|
+
log9("stopped", void 0, {
|
|
1504
|
+
F: __dxlog_file9,
|
|
1505
|
+
L: 124,
|
|
1506
|
+
S: this,
|
|
1507
|
+
C: (f, a) => f(...a)
|
|
1494
1508
|
});
|
|
1495
1509
|
}
|
|
1496
1510
|
async _saveTargetTimeframe(timeframe) {
|
|
@@ -1500,18 +1514,18 @@ var ControlPipeline = class {
|
|
|
1500
1514
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1501
1515
|
this._targetTimeframe = newTimeframe;
|
|
1502
1516
|
} catch (err) {
|
|
1503
|
-
log9(err,
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1517
|
+
log9(err, void 0, {
|
|
1518
|
+
F: __dxlog_file9,
|
|
1519
|
+
L: 133,
|
|
1520
|
+
S: this,
|
|
1521
|
+
C: (f, a) => f(...a)
|
|
1508
1522
|
});
|
|
1509
1523
|
}
|
|
1510
1524
|
}
|
|
1511
1525
|
};
|
|
1512
1526
|
|
|
1513
1527
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1514
|
-
|
|
1528
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1515
1529
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1516
1530
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1517
1531
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1520,7 +1534,8 @@ var __decorate6 = function(decorators, target, key, desc) {
|
|
|
1520
1534
|
if (d = decorators[i])
|
|
1521
1535
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1522
1536
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1523
|
-
}
|
|
1537
|
+
}
|
|
1538
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1524
1539
|
var Space = class Space2 {
|
|
1525
1540
|
constructor(params) {
|
|
1526
1541
|
this._addFeedLock = new Lock();
|
|
@@ -1529,7 +1544,7 @@ var Space = class Space2 {
|
|
|
1529
1544
|
// Processes epoch credentials.
|
|
1530
1545
|
this._dataPipelineCredentialConsumer = void 0;
|
|
1531
1546
|
this._isOpen = false;
|
|
1532
|
-
|
|
1547
|
+
invariant9(params.spaceKey && params.feedProvider);
|
|
1533
1548
|
this._key = params.spaceKey;
|
|
1534
1549
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
1535
1550
|
this._feedProvider = params.feedProvider;
|
|
@@ -1564,10 +1579,10 @@ var Space = class Space2 {
|
|
|
1564
1579
|
log10("onCredentialProcessed", {
|
|
1565
1580
|
credential
|
|
1566
1581
|
}, {
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1582
|
+
F: __dxlog_file10,
|
|
1583
|
+
L: 110,
|
|
1584
|
+
S: this,
|
|
1585
|
+
C: (f, a) => f(...a)
|
|
1571
1586
|
});
|
|
1572
1587
|
this.stateUpdate.emit();
|
|
1573
1588
|
});
|
|
@@ -1630,14 +1645,14 @@ var Space = class Space2 {
|
|
|
1630
1645
|
return this._snapshotManager;
|
|
1631
1646
|
}
|
|
1632
1647
|
setControlFeed(feed) {
|
|
1633
|
-
|
|
1648
|
+
invariant9(!this._controlFeed, "Control feed already set.");
|
|
1634
1649
|
this._controlFeed = feed;
|
|
1635
1650
|
this._controlPipeline.setWriteFeed(feed);
|
|
1636
1651
|
return this;
|
|
1637
1652
|
}
|
|
1638
1653
|
setDataFeed(feed) {
|
|
1639
1654
|
var _a;
|
|
1640
|
-
|
|
1655
|
+
invariant9(!this._dataFeed, "Data feed already set.");
|
|
1641
1656
|
this._dataFeed = feed;
|
|
1642
1657
|
(_a = this._dataPipeline.pipeline) == null ? void 0 : _a.setWriteFeed(feed);
|
|
1643
1658
|
return this;
|
|
@@ -1655,11 +1670,11 @@ var Space = class Space2 {
|
|
|
1655
1670
|
// return this._dataPipeline?.getFeeds();
|
|
1656
1671
|
// }
|
|
1657
1672
|
async open() {
|
|
1658
|
-
log10("opening...",
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1673
|
+
log10("opening...", void 0, {
|
|
1674
|
+
F: __dxlog_file10,
|
|
1675
|
+
L: 212,
|
|
1676
|
+
S: this,
|
|
1677
|
+
C: (f, a) => f(...a)
|
|
1663
1678
|
});
|
|
1664
1679
|
if (this._isOpen) {
|
|
1665
1680
|
return;
|
|
@@ -1669,11 +1684,11 @@ var Space = class Space2 {
|
|
|
1669
1684
|
this._dataPipelineCredentialConsumer = this._controlPipeline.spaceState.registerProcessor(this._dataPipeline.createCredentialProcessor());
|
|
1670
1685
|
await this._dataPipelineCredentialConsumer.open();
|
|
1671
1686
|
this._isOpen = true;
|
|
1672
|
-
log10("opened",
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1687
|
+
log10("opened", void 0, {
|
|
1688
|
+
F: __dxlog_file10,
|
|
1689
|
+
L: 228,
|
|
1690
|
+
S: this,
|
|
1691
|
+
C: (f, a) => f(...a)
|
|
1677
1692
|
});
|
|
1678
1693
|
}
|
|
1679
1694
|
async close() {
|
|
@@ -1681,10 +1696,10 @@ var Space = class Space2 {
|
|
|
1681
1696
|
log10("closing...", {
|
|
1682
1697
|
key: this._key
|
|
1683
1698
|
}, {
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1699
|
+
F: __dxlog_file10,
|
|
1700
|
+
L: 233,
|
|
1701
|
+
S: this,
|
|
1702
|
+
C: (f, a) => f(...a)
|
|
1688
1703
|
});
|
|
1689
1704
|
if (!this._isOpen) {
|
|
1690
1705
|
return;
|
|
@@ -1695,42 +1710,42 @@ var Space = class Space2 {
|
|
|
1695
1710
|
await this.protocol.stop();
|
|
1696
1711
|
await this._controlPipeline.stop();
|
|
1697
1712
|
this._isOpen = false;
|
|
1698
|
-
log10("closed",
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1713
|
+
log10("closed", void 0, {
|
|
1714
|
+
F: __dxlog_file10,
|
|
1715
|
+
L: 247,
|
|
1716
|
+
S: this,
|
|
1717
|
+
C: (f, a) => f(...a)
|
|
1703
1718
|
});
|
|
1704
1719
|
}
|
|
1705
1720
|
async initializeDataPipeline() {
|
|
1706
|
-
log10("initializeDataPipeline",
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1721
|
+
log10("initializeDataPipeline", void 0, {
|
|
1722
|
+
F: __dxlog_file10,
|
|
1723
|
+
L: 252,
|
|
1724
|
+
S: this,
|
|
1725
|
+
C: (f, a) => f(...a)
|
|
1711
1726
|
});
|
|
1712
|
-
|
|
1727
|
+
invariant9(this._isOpen, "Space must be open to initialize data pipeline.");
|
|
1713
1728
|
await this._dataPipeline.open();
|
|
1714
1729
|
}
|
|
1715
1730
|
};
|
|
1716
|
-
|
|
1731
|
+
_ts_decorate6([
|
|
1717
1732
|
logInfo
|
|
1718
1733
|
], Space.prototype, "key", null);
|
|
1719
|
-
|
|
1734
|
+
_ts_decorate6([
|
|
1720
1735
|
synchronized4
|
|
1721
1736
|
], Space.prototype, "open", null);
|
|
1722
|
-
|
|
1737
|
+
_ts_decorate6([
|
|
1723
1738
|
synchronized4
|
|
1724
1739
|
], Space.prototype, "close", null);
|
|
1725
|
-
|
|
1740
|
+
_ts_decorate6([
|
|
1726
1741
|
synchronized4
|
|
1727
1742
|
], Space.prototype, "initializeDataPipeline", null);
|
|
1728
|
-
Space =
|
|
1743
|
+
Space = _ts_decorate6([
|
|
1729
1744
|
trackLeaks3("open", "close")
|
|
1730
1745
|
], Space);
|
|
1731
1746
|
|
|
1732
1747
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
1733
|
-
import { discoveryKey,
|
|
1748
|
+
import { discoveryKey, subtleCrypto as subtleCrypto2 } from "@dxos/crypto";
|
|
1734
1749
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1735
1750
|
import { log as log11, logInfo as logInfo2 } from "@dxos/log";
|
|
1736
1751
|
import { MMSTTopology } from "@dxos/network-manager";
|
|
@@ -1738,7 +1753,7 @@ import { Teleport } from "@dxos/teleport";
|
|
|
1738
1753
|
import { BlobSync } from "@dxos/teleport-extension-object-sync";
|
|
1739
1754
|
import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
|
|
1740
1755
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1741
|
-
|
|
1756
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1742
1757
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1743
1758
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1744
1759
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1747,7 +1762,8 @@ var __decorate7 = function(decorators, target, key, desc) {
|
|
|
1747
1762
|
if (d = decorators[i])
|
|
1748
1763
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1749
1764
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1750
|
-
}
|
|
1765
|
+
}
|
|
1766
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1751
1767
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1752
1768
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1753
1769
|
var SpaceProtocol = class {
|
|
@@ -1761,7 +1777,7 @@ var SpaceProtocol = class {
|
|
|
1761
1777
|
this.blobSync = new BlobSync({
|
|
1762
1778
|
blobStore
|
|
1763
1779
|
});
|
|
1764
|
-
this._topic =
|
|
1780
|
+
this._topic = subtleCrypto2.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey5.from);
|
|
1765
1781
|
}
|
|
1766
1782
|
get sessions() {
|
|
1767
1783
|
return this._sessions;
|
|
@@ -1777,10 +1793,10 @@ var SpaceProtocol = class {
|
|
|
1777
1793
|
log11("addFeed", {
|
|
1778
1794
|
key: feed.key
|
|
1779
1795
|
}, {
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1796
|
+
F: __dxlog_file11,
|
|
1797
|
+
L: 96,
|
|
1798
|
+
S: this,
|
|
1799
|
+
C: (f, a) => f(...a)
|
|
1784
1800
|
});
|
|
1785
1801
|
this._feeds.add(feed);
|
|
1786
1802
|
for (const session of this._sessions.values()) {
|
|
@@ -1798,41 +1814,41 @@ var SpaceProtocol = class {
|
|
|
1798
1814
|
sampleSize: 20
|
|
1799
1815
|
};
|
|
1800
1816
|
await this.blobSync.open();
|
|
1801
|
-
log11("starting...",
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1817
|
+
log11("starting...", void 0, {
|
|
1818
|
+
F: __dxlog_file11,
|
|
1819
|
+
L: 121,
|
|
1820
|
+
S: this,
|
|
1821
|
+
C: (f, a) => f(...a)
|
|
1806
1822
|
});
|
|
1807
1823
|
this._connection = await this._networkManager.joinSwarm({
|
|
1808
1824
|
protocolProvider: this._createProtocolProvider(credentials),
|
|
1809
1825
|
peerId: this._swarmIdentity.peerKey,
|
|
1810
|
-
topic: this._topic,
|
|
1826
|
+
topic: await this._topic,
|
|
1811
1827
|
topology: new MMSTTopology(topologyConfig),
|
|
1812
1828
|
label: `Protocol swarm: ${this._topic}`
|
|
1813
1829
|
});
|
|
1814
|
-
log11("started",
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1830
|
+
log11("started", void 0, {
|
|
1831
|
+
F: __dxlog_file11,
|
|
1832
|
+
L: 130,
|
|
1833
|
+
S: this,
|
|
1834
|
+
C: (f, a) => f(...a)
|
|
1819
1835
|
});
|
|
1820
1836
|
}
|
|
1821
1837
|
async stop() {
|
|
1822
1838
|
await this.blobSync.close();
|
|
1823
1839
|
if (this._connection) {
|
|
1824
|
-
log11("stopping...",
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1840
|
+
log11("stopping...", void 0, {
|
|
1841
|
+
F: __dxlog_file11,
|
|
1842
|
+
L: 137,
|
|
1843
|
+
S: this,
|
|
1844
|
+
C: (f, a) => f(...a)
|
|
1829
1845
|
});
|
|
1830
1846
|
await this._connection.close();
|
|
1831
|
-
log11("stopped",
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1847
|
+
log11("stopped", void 0, {
|
|
1848
|
+
F: __dxlog_file11,
|
|
1849
|
+
L: 139,
|
|
1850
|
+
S: this,
|
|
1851
|
+
C: (f, a) => f(...a)
|
|
1836
1852
|
});
|
|
1837
1853
|
}
|
|
1838
1854
|
}
|
|
@@ -1853,10 +1869,10 @@ var SpaceProtocol = class {
|
|
|
1853
1869
|
};
|
|
1854
1870
|
}
|
|
1855
1871
|
};
|
|
1856
|
-
|
|
1872
|
+
_ts_decorate7([
|
|
1857
1873
|
logInfo2
|
|
1858
1874
|
], SpaceProtocol.prototype, "_topic", void 0);
|
|
1859
|
-
|
|
1875
|
+
_ts_decorate7([
|
|
1860
1876
|
logInfo2
|
|
1861
1877
|
], SpaceProtocol.prototype, "_ownPeerKey", null);
|
|
1862
1878
|
var AuthStatus;
|
|
@@ -1883,6 +1899,9 @@ var SpaceProtocolSession = class {
|
|
|
1883
1899
|
get authStatus() {
|
|
1884
1900
|
return this._authStatus;
|
|
1885
1901
|
}
|
|
1902
|
+
get stats() {
|
|
1903
|
+
return this._teleport.stats;
|
|
1904
|
+
}
|
|
1886
1905
|
get stream() {
|
|
1887
1906
|
return this._teleport.stream;
|
|
1888
1907
|
}
|
|
@@ -1893,11 +1912,11 @@ var SpaceProtocolSession = class {
|
|
|
1893
1912
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
1894
1913
|
onAuthSuccess: () => {
|
|
1895
1914
|
var _a;
|
|
1896
|
-
log11("Peer authenticated",
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1915
|
+
log11("Peer authenticated", void 0, {
|
|
1916
|
+
F: __dxlog_file11,
|
|
1917
|
+
L: 236,
|
|
1918
|
+
S: this,
|
|
1919
|
+
C: (f, a) => f(...a)
|
|
1901
1920
|
});
|
|
1902
1921
|
this._authStatus = AuthStatus.SUCCESS;
|
|
1903
1922
|
(_a = this._onSessionAuth) == null ? void 0 : _a.call(this, this._teleport);
|
|
@@ -1915,10 +1934,10 @@ var SpaceProtocolSession = class {
|
|
|
1915
1934
|
await this._teleport.close();
|
|
1916
1935
|
}
|
|
1917
1936
|
};
|
|
1918
|
-
|
|
1937
|
+
_ts_decorate7([
|
|
1919
1938
|
logInfo2
|
|
1920
1939
|
], SpaceProtocolSession.prototype, "_wireParams", void 0);
|
|
1921
|
-
|
|
1940
|
+
_ts_decorate7([
|
|
1922
1941
|
logInfo2
|
|
1923
1942
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
1924
1943
|
|
|
@@ -1929,7 +1948,7 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
|
1929
1948
|
import { log as log12 } from "@dxos/log";
|
|
1930
1949
|
import { trace } from "@dxos/protocols";
|
|
1931
1950
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
1932
|
-
|
|
1951
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1933
1952
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1934
1953
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1935
1954
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1938,7 +1957,8 @@ var __decorate8 = function(decorators, target, key, desc) {
|
|
|
1938
1957
|
if (d = decorators[i])
|
|
1939
1958
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1940
1959
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1941
|
-
}
|
|
1960
|
+
}
|
|
1961
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
1942
1962
|
var SpaceManager = class SpaceManager2 {
|
|
1943
1963
|
constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
|
|
1944
1964
|
this._spaces = new ComplexMap5(PublicKey6.hash);
|
|
@@ -1966,18 +1986,18 @@ var SpaceManager = class SpaceManager2 {
|
|
|
1966
1986
|
log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
|
|
1967
1987
|
id: this._instanceId
|
|
1968
1988
|
}), {
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1989
|
+
F: __dxlog_file12,
|
|
1990
|
+
L: 97,
|
|
1991
|
+
S: this,
|
|
1992
|
+
C: (f, a) => f(...a)
|
|
1973
1993
|
});
|
|
1974
1994
|
log12("constructing space...", {
|
|
1975
1995
|
spaceKey: metadata.genesisFeedKey
|
|
1976
1996
|
}, {
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1997
|
+
F: __dxlog_file12,
|
|
1998
|
+
L: 98,
|
|
1999
|
+
S: this,
|
|
2000
|
+
C: (f, a) => f(...a)
|
|
1981
2001
|
});
|
|
1982
2002
|
const genesisFeed = await this._feedStore.openFeed((_a = metadata.genesisFeedKey) != null ? _a : failUndefined2());
|
|
1983
2003
|
const spaceKey = metadata.key;
|
|
@@ -2004,21 +2024,21 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2004
2024
|
log12.trace("dxos.echo.space-manager.construct-space", trace.end({
|
|
2005
2025
|
id: this._instanceId
|
|
2006
2026
|
}), {
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2027
|
+
F: __dxlog_file12,
|
|
2028
|
+
L: 125,
|
|
2029
|
+
S: this,
|
|
2030
|
+
C: (f, a) => f(...a)
|
|
2011
2031
|
});
|
|
2012
2032
|
return space;
|
|
2013
2033
|
}
|
|
2014
2034
|
};
|
|
2015
|
-
|
|
2035
|
+
_ts_decorate8([
|
|
2016
2036
|
synchronized5
|
|
2017
2037
|
], SpaceManager.prototype, "open", null);
|
|
2018
|
-
|
|
2038
|
+
_ts_decorate8([
|
|
2019
2039
|
synchronized5
|
|
2020
2040
|
], SpaceManager.prototype, "close", null);
|
|
2021
|
-
SpaceManager =
|
|
2041
|
+
SpaceManager = _ts_decorate8([
|
|
2022
2042
|
trackLeaks4("open", "close")
|
|
2023
2043
|
], SpaceManager);
|
|
2024
2044
|
|
|
@@ -2048,4 +2068,4 @@ export {
|
|
|
2048
2068
|
SpaceProtocolSession,
|
|
2049
2069
|
SpaceManager
|
|
2050
2070
|
};
|
|
2051
|
-
//# sourceMappingURL=chunk-
|
|
2071
|
+
//# sourceMappingURL=chunk-SCMKAWNW.mjs.map
|