@dxos/feed-store 0.8.4-main.a4bbb77 → 0.8.4-main.abd8ff62ef
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-4RW534M7.mjs → chunk-MB63GMGR.mjs} +76 -237
- package/dist/lib/browser/chunk-MB63GMGR.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +63 -255
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +32 -80
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{chunk-D4DVCY7Y.mjs → chunk-VZUET36D.mjs} +76 -237
- package/dist/lib/node-esm/chunk-VZUET36D.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +63 -255
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +32 -80
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/feed-factory.d.ts.map +1 -1
- package/dist/types/src/feed-iterator.d.ts.map +1 -1
- package/dist/types/src/feed-queue.d.ts.map +1 -1
- package/dist/types/src/feed-set-iterator.d.ts.map +1 -1
- package/dist/types/src/feed-store.d.ts.map +1 -1
- package/dist/types/src/feed-wrapper.d.ts +1 -1
- package/dist/types/src/feed-wrapper.d.ts.map +1 -1
- package/dist/types/src/feed-writer.d.ts.map +1 -1
- package/dist/types/src/testing/mocks.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts +1 -1
- package/dist/types/src/testing/test-generator.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -26
- package/src/feed-queue.ts +0 -1
- package/src/feed-set-iterator.test.ts +6 -6
- package/src/feed-store.node.test.ts +2 -2
- package/src/feed-wrapper.test.ts +9 -10
- package/src/feed-wrapper.ts +0 -1
- package/src/testing/test-builder.ts +0 -1
- package/src/testing/test-generator.ts +4 -4
- package/dist/lib/browser/chunk-4RW534M7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-D4DVCY7Y.mjs.map +0 -7
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
FeedFactory,
|
|
4
4
|
FeedStore,
|
|
5
5
|
FeedWrapper
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-MB63GMGR.mjs";
|
|
7
7
|
|
|
8
8
|
// src/feed-iterator.ts
|
|
9
9
|
import safeRace from "race-as-promised";
|
|
@@ -18,27 +18,28 @@ import { Event, Trigger, latch } from "@dxos/async";
|
|
|
18
18
|
import { inspectObject } from "@dxos/debug";
|
|
19
19
|
import { invariant } from "@dxos/invariant";
|
|
20
20
|
import { log } from "@dxos/log";
|
|
21
|
-
function _define_property(obj, key, value) {
|
|
22
|
-
if (key in obj) {
|
|
23
|
-
Object.defineProperty(obj, key, {
|
|
24
|
-
value,
|
|
25
|
-
enumerable: true,
|
|
26
|
-
configurable: true,
|
|
27
|
-
writable: true
|
|
28
|
-
});
|
|
29
|
-
} else {
|
|
30
|
-
obj[key] = value;
|
|
31
|
-
}
|
|
32
|
-
return obj;
|
|
33
|
-
}
|
|
34
21
|
var __dxlog_file = "/__w/dxos/dxos/packages/common/feed-store/src/feed-queue.ts";
|
|
35
22
|
var defaultReadStreamOptions = {
|
|
36
23
|
live: true,
|
|
37
24
|
batch: 1024
|
|
38
25
|
};
|
|
39
|
-
var _inspect_custom = inspect.custom;
|
|
40
26
|
var FeedQueue = class {
|
|
41
|
-
|
|
27
|
+
_feed;
|
|
28
|
+
_options;
|
|
29
|
+
updated = new Event();
|
|
30
|
+
_messageTrigger = new Trigger({
|
|
31
|
+
autoReset: true
|
|
32
|
+
});
|
|
33
|
+
_feedConsumer = void 0;
|
|
34
|
+
_next;
|
|
35
|
+
_currentBlock = void 0;
|
|
36
|
+
_index = -1;
|
|
37
|
+
// prettier-ignore
|
|
38
|
+
constructor(_feed, _options = {}) {
|
|
39
|
+
this._feed = _feed;
|
|
40
|
+
this._options = _options;
|
|
41
|
+
}
|
|
42
|
+
[inspect.custom]() {
|
|
42
43
|
return inspectObject(this);
|
|
43
44
|
}
|
|
44
45
|
toJSON() {
|
|
@@ -75,12 +76,7 @@ var FeedQueue = class {
|
|
|
75
76
|
this._index = options.start ?? 0;
|
|
76
77
|
log("opening", {
|
|
77
78
|
feedKey: this._feed.key
|
|
78
|
-
}, {
|
|
79
|
-
F: __dxlog_file,
|
|
80
|
-
L: 93,
|
|
81
|
-
S: this,
|
|
82
|
-
C: (f, a) => f(...a)
|
|
83
|
-
});
|
|
79
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 69, S: this });
|
|
84
80
|
const opts = Object.assign({}, defaultReadStreamOptions, options);
|
|
85
81
|
const feedStream = this._feed.createReadableStream(opts);
|
|
86
82
|
this._feedConsumer = new Writable({
|
|
@@ -118,12 +114,7 @@ var FeedQueue = class {
|
|
|
118
114
|
}
|
|
119
115
|
log.catch(err, {
|
|
120
116
|
feedKey: this._feed.key
|
|
121
|
-
}, {
|
|
122
|
-
F: __dxlog_file,
|
|
123
|
-
L: 138,
|
|
124
|
-
S: this,
|
|
125
|
-
C: (f, a) => f(...a)
|
|
126
|
-
});
|
|
117
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 108, S: this });
|
|
127
118
|
};
|
|
128
119
|
this._feed.core.once("close", onClose);
|
|
129
120
|
this._feedConsumer.on("error", onError);
|
|
@@ -134,55 +125,24 @@ var FeedQueue = class {
|
|
|
134
125
|
}
|
|
135
126
|
this._destroyConsumer();
|
|
136
127
|
});
|
|
137
|
-
log("opened", void 0, {
|
|
138
|
-
F: __dxlog_file,
|
|
139
|
-
L: 156,
|
|
140
|
-
S: this,
|
|
141
|
-
C: (f, a) => f(...a)
|
|
142
|
-
});
|
|
128
|
+
log("opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 124, S: this });
|
|
143
129
|
}
|
|
144
130
|
/**
|
|
145
131
|
* Closes the queue.
|
|
146
132
|
*/
|
|
147
133
|
async close() {
|
|
148
134
|
if (this.isOpen) {
|
|
149
|
-
invariant(this._feedConsumer, void 0, {
|
|
150
|
-
|
|
151
|
-
L: 164,
|
|
152
|
-
S: this,
|
|
153
|
-
A: [
|
|
154
|
-
"this._feedConsumer",
|
|
155
|
-
""
|
|
156
|
-
]
|
|
157
|
-
});
|
|
158
|
-
invariant(!this._feed.properties.closed, void 0, {
|
|
159
|
-
F: __dxlog_file,
|
|
160
|
-
L: 165,
|
|
161
|
-
S: this,
|
|
162
|
-
A: [
|
|
163
|
-
"!this._feed.properties.closed",
|
|
164
|
-
""
|
|
165
|
-
]
|
|
166
|
-
});
|
|
135
|
+
invariant(this._feedConsumer, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 130, S: this, A: ["this._feedConsumer", ""] });
|
|
136
|
+
invariant(!this._feed.properties.closed, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 131, S: this, A: ["!this._feed.properties.closed", ""] });
|
|
167
137
|
log("closing", {
|
|
168
138
|
feedKey: this._feed.key
|
|
169
|
-
}, {
|
|
170
|
-
F: __dxlog_file,
|
|
171
|
-
L: 167,
|
|
172
|
-
S: this,
|
|
173
|
-
C: (f, a) => f(...a)
|
|
174
|
-
});
|
|
139
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 132, S: this });
|
|
175
140
|
const [closed, setClosed] = latch();
|
|
176
141
|
this._feedConsumer.once("close", setClosed);
|
|
177
142
|
this._feedConsumer.destroy();
|
|
178
143
|
this._next?.();
|
|
179
144
|
await closed();
|
|
180
|
-
log("closed", void 0, {
|
|
181
|
-
F: __dxlog_file,
|
|
182
|
-
L: 173,
|
|
183
|
-
S: this,
|
|
184
|
-
C: (f, a) => f(...a)
|
|
185
|
-
});
|
|
145
|
+
log("closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 140, S: this });
|
|
186
146
|
}
|
|
187
147
|
}
|
|
188
148
|
/**
|
|
@@ -211,56 +171,21 @@ var FeedQueue = class {
|
|
|
211
171
|
if (this._feedConsumer) {
|
|
212
172
|
log("queue closed", {
|
|
213
173
|
feedKey: this._feed.key
|
|
214
|
-
}, {
|
|
215
|
-
F: __dxlog_file,
|
|
216
|
-
L: 206,
|
|
217
|
-
S: this,
|
|
218
|
-
C: (f, a) => f(...a)
|
|
219
|
-
});
|
|
174
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 165, S: this });
|
|
220
175
|
this._feedConsumer = void 0;
|
|
221
176
|
this._next = void 0;
|
|
222
177
|
this._currentBlock = void 0;
|
|
223
178
|
this._index = -1;
|
|
224
179
|
}
|
|
225
180
|
}
|
|
226
|
-
// prettier-ignore
|
|
227
|
-
constructor(_feed, _options = {}) {
|
|
228
|
-
_define_property(this, "_feed", void 0);
|
|
229
|
-
_define_property(this, "_options", void 0);
|
|
230
|
-
_define_property(this, "updated", void 0);
|
|
231
|
-
_define_property(this, "_messageTrigger", void 0);
|
|
232
|
-
_define_property(this, "_feedConsumer", void 0);
|
|
233
|
-
_define_property(this, "_next", void 0);
|
|
234
|
-
_define_property(this, "_currentBlock", void 0);
|
|
235
|
-
_define_property(this, "_index", void 0);
|
|
236
|
-
this._feed = _feed;
|
|
237
|
-
this._options = _options;
|
|
238
|
-
this.updated = new Event();
|
|
239
|
-
this._messageTrigger = new Trigger({
|
|
240
|
-
autoReset: true
|
|
241
|
-
});
|
|
242
|
-
this._feedConsumer = void 0;
|
|
243
|
-
this._currentBlock = void 0;
|
|
244
|
-
this._index = -1;
|
|
245
|
-
}
|
|
246
181
|
};
|
|
247
182
|
|
|
248
183
|
// src/feed-iterator.ts
|
|
249
|
-
function _define_property2(obj, key, value) {
|
|
250
|
-
if (key in obj) {
|
|
251
|
-
Object.defineProperty(obj, key, {
|
|
252
|
-
value,
|
|
253
|
-
enumerable: true,
|
|
254
|
-
configurable: true,
|
|
255
|
-
writable: true
|
|
256
|
-
});
|
|
257
|
-
} else {
|
|
258
|
-
obj[key] = value;
|
|
259
|
-
}
|
|
260
|
-
return obj;
|
|
261
|
-
}
|
|
262
184
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/feed-store/src/feed-iterator.ts";
|
|
263
185
|
var AbstractFeedIterator = class {
|
|
186
|
+
_stopTrigger = new Trigger2();
|
|
187
|
+
_open = false;
|
|
188
|
+
_running = false;
|
|
264
189
|
toJSON() {
|
|
265
190
|
return {
|
|
266
191
|
open: this.isOpen,
|
|
@@ -275,66 +200,30 @@ var AbstractFeedIterator = class {
|
|
|
275
200
|
}
|
|
276
201
|
async open() {
|
|
277
202
|
if (!this._open) {
|
|
278
|
-
log2("opening...", void 0, {
|
|
279
|
-
F: __dxlog_file2,
|
|
280
|
-
L: 41,
|
|
281
|
-
S: this,
|
|
282
|
-
C: (f, a) => f(...a)
|
|
283
|
-
});
|
|
203
|
+
log2("opening...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 29, S: this });
|
|
284
204
|
await this._onOpen();
|
|
285
205
|
this._open = true;
|
|
286
206
|
await this.start();
|
|
287
|
-
log2("opened", void 0, {
|
|
288
|
-
F: __dxlog_file2,
|
|
289
|
-
L: 46,
|
|
290
|
-
S: this,
|
|
291
|
-
C: (f, a) => f(...a)
|
|
292
|
-
});
|
|
207
|
+
log2("opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 33, S: this });
|
|
293
208
|
}
|
|
294
209
|
}
|
|
295
210
|
async close() {
|
|
296
211
|
if (this._open) {
|
|
297
|
-
log2("closing...", void 0, {
|
|
298
|
-
F: __dxlog_file2,
|
|
299
|
-
L: 52,
|
|
300
|
-
S: this,
|
|
301
|
-
C: (f, a) => f(...a)
|
|
302
|
-
});
|
|
212
|
+
log2("closing...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 38, S: this });
|
|
303
213
|
await this.stop();
|
|
304
214
|
await this._onClose();
|
|
305
215
|
this._open = false;
|
|
306
|
-
log2("closed", void 0, {
|
|
307
|
-
F: __dxlog_file2,
|
|
308
|
-
L: 57,
|
|
309
|
-
S: this,
|
|
310
|
-
C: (f, a) => f(...a)
|
|
311
|
-
});
|
|
216
|
+
log2("closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 42, S: this });
|
|
312
217
|
}
|
|
313
218
|
}
|
|
314
219
|
async start() {
|
|
315
|
-
invariant2(this._open, void 0, {
|
|
316
|
-
F: __dxlog_file2,
|
|
317
|
-
L: 62,
|
|
318
|
-
S: this,
|
|
319
|
-
A: [
|
|
320
|
-
"this._open",
|
|
321
|
-
""
|
|
322
|
-
]
|
|
323
|
-
});
|
|
220
|
+
invariant2(this._open, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 46, S: this, A: ["this._open", ""] });
|
|
324
221
|
if (!this._running) {
|
|
325
222
|
this._running = true;
|
|
326
223
|
}
|
|
327
224
|
}
|
|
328
225
|
async stop() {
|
|
329
|
-
invariant2(this._open, void 0, {
|
|
330
|
-
F: __dxlog_file2,
|
|
331
|
-
L: 69,
|
|
332
|
-
S: this,
|
|
333
|
-
A: [
|
|
334
|
-
"this._open",
|
|
335
|
-
""
|
|
336
|
-
]
|
|
337
|
-
});
|
|
226
|
+
invariant2(this._open, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 52, S: this, A: ["this._open", ""] });
|
|
338
227
|
if (this._running) {
|
|
339
228
|
this._running = false;
|
|
340
229
|
this._stopTrigger.wake();
|
|
@@ -347,12 +236,7 @@ var AbstractFeedIterator = class {
|
|
|
347
236
|
return this._generator();
|
|
348
237
|
}
|
|
349
238
|
async *_generator() {
|
|
350
|
-
log2("started", void 0, {
|
|
351
|
-
F: __dxlog_file2,
|
|
352
|
-
L: 85,
|
|
353
|
-
S: this,
|
|
354
|
-
C: (f, a) => f(...a)
|
|
355
|
-
});
|
|
239
|
+
log2("started", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 65, S: this });
|
|
356
240
|
while (this._running) {
|
|
357
241
|
const block = await safeRace([
|
|
358
242
|
this._stopTrigger.wait(),
|
|
@@ -363,20 +247,16 @@ var AbstractFeedIterator = class {
|
|
|
363
247
|
}
|
|
364
248
|
yield block;
|
|
365
249
|
}
|
|
366
|
-
log2("stopped", void 0, {
|
|
367
|
-
F: __dxlog_file2,
|
|
368
|
-
L: 97,
|
|
369
|
-
S: this,
|
|
370
|
-
C: (f, a) => f(...a)
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
constructor() {
|
|
374
|
-
_define_property2(this, "_stopTrigger", new Trigger2());
|
|
375
|
-
_define_property2(this, "_open", false);
|
|
376
|
-
_define_property2(this, "_running", false);
|
|
250
|
+
log2("stopped", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 77, S: this });
|
|
377
251
|
}
|
|
378
252
|
};
|
|
379
253
|
var FeedIterator = class extends AbstractFeedIterator {
|
|
254
|
+
_feed;
|
|
255
|
+
_queue;
|
|
256
|
+
constructor(_feed) {
|
|
257
|
+
super(), this._feed = _feed;
|
|
258
|
+
this._queue = new FeedQueue(this._feed);
|
|
259
|
+
}
|
|
380
260
|
async _onOpen() {
|
|
381
261
|
await this._queue.open();
|
|
382
262
|
}
|
|
@@ -386,10 +266,6 @@ var FeedIterator = class extends AbstractFeedIterator {
|
|
|
386
266
|
async _nextBlock() {
|
|
387
267
|
return this._queue.pop();
|
|
388
268
|
}
|
|
389
|
-
constructor(_feed) {
|
|
390
|
-
super(), _define_property2(this, "_feed", void 0), _define_property2(this, "_queue", void 0), this._feed = _feed;
|
|
391
|
-
this._queue = new FeedQueue(this._feed);
|
|
392
|
-
}
|
|
393
269
|
};
|
|
394
270
|
|
|
395
271
|
// src/feed-set-iterator.ts
|
|
@@ -400,26 +276,25 @@ import { invariant as invariant3 } from "@dxos/invariant";
|
|
|
400
276
|
import { PublicKey } from "@dxos/keys";
|
|
401
277
|
import { log as log3 } from "@dxos/log";
|
|
402
278
|
import { ComplexMap, isNonNullable } from "@dxos/util";
|
|
403
|
-
function _define_property3(obj, key, value) {
|
|
404
|
-
if (key in obj) {
|
|
405
|
-
Object.defineProperty(obj, key, {
|
|
406
|
-
value,
|
|
407
|
-
enumerable: true,
|
|
408
|
-
configurable: true,
|
|
409
|
-
writable: true
|
|
410
|
-
});
|
|
411
|
-
} else {
|
|
412
|
-
obj[key] = value;
|
|
413
|
-
}
|
|
414
|
-
return obj;
|
|
415
|
-
}
|
|
416
279
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/feed-store/src/feed-set-iterator.ts";
|
|
417
280
|
var defaultFeedSetIteratorOptions = {
|
|
418
281
|
stallTimeout: 1e3
|
|
419
282
|
};
|
|
420
|
-
var _inspect_custom2 = inspect2.custom;
|
|
421
283
|
var FeedSetIterator = class extends AbstractFeedIterator {
|
|
422
|
-
|
|
284
|
+
_selector;
|
|
285
|
+
options;
|
|
286
|
+
_feedQueues = new ComplexMap(PublicKey.hash);
|
|
287
|
+
_trigger = new Trigger3({
|
|
288
|
+
autoReset: true
|
|
289
|
+
});
|
|
290
|
+
_subscriptions = new SubscriptionList();
|
|
291
|
+
stalled = new Event2();
|
|
292
|
+
constructor(_selector, options = defaultFeedSetIteratorOptions) {
|
|
293
|
+
super(), this._selector = _selector, this.options = options;
|
|
294
|
+
invariant3(_selector, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 29, S: this, A: ["_selector", ""] });
|
|
295
|
+
invariant3(options, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 30, S: this, A: ["options", ""] });
|
|
296
|
+
}
|
|
297
|
+
[inspect2.custom]() {
|
|
423
298
|
return inspectObject2(this);
|
|
424
299
|
}
|
|
425
300
|
toJSON() {
|
|
@@ -445,32 +320,11 @@ var FeedSetIterator = class extends AbstractFeedIterator {
|
|
|
445
320
|
this._trigger.wake();
|
|
446
321
|
}
|
|
447
322
|
async addFeed(feed) {
|
|
448
|
-
invariant3(!this._feedQueues.has(feed.key), `Feed already added: ${feed.key}`, {
|
|
449
|
-
|
|
450
|
-
L: 91,
|
|
451
|
-
S: this,
|
|
452
|
-
A: [
|
|
453
|
-
"!this._feedQueues.has(feed.key)",
|
|
454
|
-
"`Feed already added: ${feed.key}`"
|
|
455
|
-
]
|
|
456
|
-
});
|
|
457
|
-
invariant3(feed.properties.opened, void 0, {
|
|
458
|
-
F: __dxlog_file3,
|
|
459
|
-
L: 92,
|
|
460
|
-
S: this,
|
|
461
|
-
A: [
|
|
462
|
-
"feed.properties.opened",
|
|
463
|
-
""
|
|
464
|
-
]
|
|
465
|
-
});
|
|
323
|
+
invariant3(!this._feedQueues.has(feed.key), `Feed already added: ${feed.key}`, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 58, S: this, A: ["!this._feedQueues.has(feed.key)", "`Feed already added: ${feed.key}`"] });
|
|
324
|
+
invariant3(feed.properties.opened, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 59, S: this, A: ["feed.properties.opened", ""] });
|
|
466
325
|
log3("feed added", {
|
|
467
326
|
feedKey: feed.key
|
|
468
|
-
}, {
|
|
469
|
-
F: __dxlog_file3,
|
|
470
|
-
L: 93,
|
|
471
|
-
S: this,
|
|
472
|
-
C: (f, a) => f(...a)
|
|
473
|
-
});
|
|
327
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 60, S: this });
|
|
474
328
|
const queue = new FeedQueue(feed);
|
|
475
329
|
this._feedQueues.set(feed.key, queue);
|
|
476
330
|
this._subscriptions.add(queue.updated.on(() => {
|
|
@@ -507,12 +361,7 @@ var FeedSetIterator = class extends AbstractFeedIterator {
|
|
|
507
361
|
log3("selected", {
|
|
508
362
|
idx,
|
|
509
363
|
blocks
|
|
510
|
-
}, {
|
|
511
|
-
F: __dxlog_file3,
|
|
512
|
-
L: 143,
|
|
513
|
-
S: this,
|
|
514
|
-
C: (f, a) => f(...a)
|
|
515
|
-
});
|
|
364
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 100, S: this });
|
|
516
365
|
if (idx === void 0) {
|
|
517
366
|
if (t === void 0) {
|
|
518
367
|
t = setTimeout(() => {
|
|
@@ -529,62 +378,21 @@ var FeedSetIterator = class extends AbstractFeedIterator {
|
|
|
529
378
|
throw new Error(`Index out of bounds: ${idx} of ${blocks.length}`);
|
|
530
379
|
}
|
|
531
380
|
const queue = this._feedQueues.get(blocks[idx].feedKey);
|
|
532
|
-
log3("popping", queue.toJSON(), {
|
|
533
|
-
F: __dxlog_file3,
|
|
534
|
-
L: 163,
|
|
535
|
-
S: this,
|
|
536
|
-
C: (f, a) => f(...a)
|
|
537
|
-
});
|
|
381
|
+
log3("popping", queue.toJSON(), { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 122, S: this });
|
|
538
382
|
try {
|
|
539
383
|
const message = await queue.pop();
|
|
540
|
-
invariant3(message === blocks[idx], void 0, {
|
|
541
|
-
F: __dxlog_file3,
|
|
542
|
-
L: 166,
|
|
543
|
-
S: this,
|
|
544
|
-
A: [
|
|
545
|
-
"message === blocks[idx]",
|
|
546
|
-
""
|
|
547
|
-
]
|
|
548
|
-
});
|
|
384
|
+
invariant3(message === blocks[idx], void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 125, S: this, A: ["message === blocks[idx]", ""] });
|
|
549
385
|
return message;
|
|
550
386
|
} catch (err) {
|
|
551
387
|
log3.warn("queue closed", {
|
|
552
388
|
feedKey: queue.feed.key
|
|
553
|
-
}, {
|
|
554
|
-
F: __dxlog_file3,
|
|
555
|
-
L: 170,
|
|
556
|
-
S: this,
|
|
557
|
-
C: (f, a) => f(...a)
|
|
558
|
-
});
|
|
389
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 129, S: this });
|
|
559
390
|
}
|
|
560
391
|
}
|
|
561
392
|
}
|
|
562
393
|
await this._trigger.wait();
|
|
563
394
|
}
|
|
564
395
|
}
|
|
565
|
-
constructor(_selector, options = defaultFeedSetIteratorOptions) {
|
|
566
|
-
super(), _define_property3(this, "_selector", void 0), _define_property3(this, "options", void 0), _define_property3(this, "_feedQueues", void 0), _define_property3(this, "_trigger", void 0), _define_property3(this, "_subscriptions", void 0), _define_property3(this, "stalled", void 0), this._selector = _selector, this.options = options, this._feedQueues = new ComplexMap(PublicKey.hash), this._trigger = new Trigger3({
|
|
567
|
-
autoReset: true
|
|
568
|
-
}), this._subscriptions = new SubscriptionList(), this.stalled = new Event2();
|
|
569
|
-
invariant3(_selector, void 0, {
|
|
570
|
-
F: __dxlog_file3,
|
|
571
|
-
L: 55,
|
|
572
|
-
S: this,
|
|
573
|
-
A: [
|
|
574
|
-
"_selector",
|
|
575
|
-
""
|
|
576
|
-
]
|
|
577
|
-
});
|
|
578
|
-
invariant3(options, void 0, {
|
|
579
|
-
F: __dxlog_file3,
|
|
580
|
-
L: 56,
|
|
581
|
-
S: this,
|
|
582
|
-
A: [
|
|
583
|
-
"options",
|
|
584
|
-
""
|
|
585
|
-
]
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
396
|
};
|
|
589
397
|
|
|
590
398
|
// src/feed-writer.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/feed-iterator.ts", "../../../src/feed-queue.ts", "../../../src/feed-set-iterator.ts", "../../../src/feed-writer.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport safeRace from 'race-as-promised';\n\nimport { Trigger } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport { FeedQueue } from './feed-queue';\nimport { type FeedWrapper } from './feed-wrapper';\nimport { type FeedBlock } from './types';\n\n/**\n * Base class for an async iterable feed.\n */\nexport abstract class AbstractFeedIterator<T> implements AsyncIterable<FeedBlock<T>> {\n private readonly _stopTrigger = new Trigger();\n\n protected _open = false;\n protected _running = false;\n\n toJSON(): { open: boolean; running: boolean } {\n return {\n open: this.isOpen,\n running: this.isRunning,\n };\n }\n\n get isOpen() {\n return this._open;\n }\n\n get isRunning() {\n return this._running;\n }\n\n async open(): Promise<void> {\n if (!this._open) {\n log('opening...');\n await this._onOpen();\n this._open = true;\n\n await this.start();\n log('opened');\n }\n }\n\n async close(): Promise<void> {\n if (this._open) {\n log('closing...');\n await this.stop();\n\n await this._onClose();\n this._open = false;\n log('closed');\n }\n }\n\n async start(): Promise<void> {\n invariant(this._open);\n if (!this._running) {\n this._running = true;\n }\n }\n\n async stop(): Promise<void> {\n invariant(this._open);\n if (this._running) {\n this._running = false;\n this._stopTrigger.wake();\n }\n }\n\n //\n // AsyncIterable\n //\n\n [Symbol.asyncIterator]() {\n return this._generator();\n }\n\n async *_generator() {\n log('started');\n while (this._running) {\n // https://github.com/nodejs/node/issues/17469\n const block = await safeRace([this._stopTrigger.wait(), this._nextBlock()]);\n\n if (block === undefined) {\n break;\n }\n\n yield block;\n }\n\n log('stopped');\n }\n\n abstract _onOpen(): Promise<void>;\n abstract _onClose(): Promise<void>;\n abstract _nextBlock(): Promise<FeedBlock<T> | undefined>;\n}\n\n/**\n * Iterator that reads blocks from a single feed.\n */\nexport class FeedIterator<T extends {}> extends AbstractFeedIterator<T> {\n private readonly _queue: FeedQueue<T>;\n\n constructor(private readonly _feed: FeedWrapper<T>) {\n super();\n this._queue = new FeedQueue<T>(this._feed);\n }\n\n override async _onOpen(): Promise<void> {\n await this._queue.open();\n }\n\n override async _onClose(): Promise<void> {\n await this._queue.close();\n }\n\n override async _nextBlock(): Promise<FeedBlock<T> | undefined> {\n return this._queue.pop();\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport { Writable } from 'streamx';\n\nimport { Event, Trigger, latch } from '@dxos/async';\nimport { inspectObject } from '@dxos/debug';\nimport type { ReadStreamOptions } from '@dxos/hypercore';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport { type FeedWrapper } from './feed-wrapper';\nimport { type FeedBlock } from './types';\n\nexport const defaultReadStreamOptions: ReadStreamOptions = {\n live: true, // Keep reading until closed.\n batch: 1024, // Read in batches.\n};\n\nexport type FeedQueueOptions = {};\n\n/**\n * Async queue using an AsyncIterator created from a hypercore.\n */\nexport class FeedQueue<T extends {}> {\n public updated = new Event<FeedQueue<T>>();\n\n private readonly _messageTrigger = new Trigger<FeedBlock<T>>({\n autoReset: true,\n });\n\n private _feedConsumer?: Writable = undefined;\n private _next?: () => void;\n private _currentBlock?: FeedBlock<T> = undefined;\n private _index = -1;\n\n // prettier-ignore\n constructor(\n private readonly _feed: FeedWrapper<T>,\n private readonly _options: FeedQueueOptions = {},\n ) {}\n\n [inspect.custom](): string {\n return inspectObject(this);\n }\n\n toJSON() {\n return {\n feedKey: this._feed.key,\n index: this.index,\n length: this.length,\n open: this.isOpen,\n };\n }\n\n get feed() {\n return this._feed;\n }\n\n get isOpen(): boolean {\n return Boolean(this._feedConsumer);\n }\n\n get length(): number {\n return this._feed.properties.length;\n }\n\n /**\n * Index (seq) of the NEXT block to be read, or -1 if not open.\n */\n get index() {\n return this._index;\n }\n\n /**\n * Opens (or reopens) the queue.\n * @param options.start Starting index. First mutation to be read would have `seq == options.start`.\n */\n async open(options: ReadStreamOptions = {}): Promise<void> {\n if (this.isOpen) {\n // TODO(burdon): Warn if re-opening (e.g., with different starting point).\n return;\n }\n\n this._index = options.start ?? 0;\n // if (this._index !== 0) {\n // console.warn('Start index not yet supported.');\n // }\n\n log('opening', { feedKey: this._feed.key });\n\n // TODO(burdon): Open with starting range.\n const opts = Object.assign({}, defaultReadStreamOptions, options);\n const feedStream = this._feed.createReadableStream(opts);\n\n this._feedConsumer = new Writable({\n write: (data: any, next: () => void) => {\n this._next = () => {\n this._next = undefined;\n this._currentBlock = undefined;\n this._index++;\n next();\n };\n\n this._currentBlock = {\n feedKey: this._feed.key,\n seq: this._index,\n data,\n };\n\n this._messageTrigger.wake(this._currentBlock);\n this.updated.emit(this);\n },\n });\n\n const onClose = () => {\n this.feed.core.off('close', onClose);\n this._feedConsumer?.off('close', onClose);\n this._feedConsumer?.off('error', onError);\n\n this._destroyConsumer();\n };\n\n const onError = (err?: Error) => {\n if (!this.isOpen) {\n return;\n }\n if (!err) {\n return;\n }\n if (err.message === 'Writable stream closed prematurely' || err.message === 'Feed is closed') {\n return;\n }\n\n log.catch(err, { feedKey: this._feed.key });\n };\n\n // Called if feed is closed externally.\n this._feed.core.once('close', onClose);\n this._feedConsumer.on('error', onError);\n\n // Called when queue is closed. Throws exception if waiting for `pop`.\n this._feedConsumer.once('close', onClose);\n\n // Pipe readable stream into writable consumer.\n feedStream.pipe(this._feedConsumer, (err) => {\n if (err) {\n onError(err);\n }\n this._destroyConsumer();\n });\n\n log('opened');\n }\n\n /**\n * Closes the queue.\n */\n async close(): Promise<void> {\n if (this.isOpen) {\n invariant(this._feedConsumer);\n invariant(!this._feed.properties.closed);\n\n log('closing', { feedKey: this._feed.key });\n const [closed, setClosed] = latch();\n this._feedConsumer.once('close', setClosed);\n this._feedConsumer.destroy();\n this._next?.(); // Release any message currently in the queue (otherwise destroy will block).\n await closed();\n log('closed');\n }\n }\n\n /**\n * Get the block at the head of the queue without removing it.\n */\n peek(): FeedBlock<T> | undefined {\n return this._currentBlock;\n }\n\n /**\n * Pop block at the head of the queue.\n */\n async pop(): Promise<FeedBlock<T>> {\n if (!this.isOpen) {\n throw new Error(`Queue closed: ${this.feed.key.truncate()}`);\n }\n\n let block = this.peek();\n if (!block) {\n block = await this._messageTrigger.wait();\n }\n\n if (block) {\n this._next?.();\n }\n\n return block;\n }\n\n private _destroyConsumer(): void {\n if (this._feedConsumer) {\n log('queue closed', { feedKey: this._feed.key });\n this._feedConsumer = undefined;\n this._next = undefined;\n this._currentBlock = undefined;\n this._index = -1;\n }\n }\n}\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport { Event, SubscriptionList, Trigger } from '@dxos/async';\nimport { inspectObject } from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { ComplexMap, isNonNullable } from '@dxos/util';\n\nimport { AbstractFeedIterator } from './feed-iterator';\nimport { FeedQueue } from './feed-queue';\nimport { type FeedWrapper } from './feed-wrapper';\nimport { type FeedBlock } from './types';\n\n/**\n * Select next block.\n */\nexport type FeedBlockSelector<T> = (blocks: FeedBlock<T>[]) => number | undefined;\n\nexport type FeedIndex = {\n feedKey: PublicKey;\n index: number;\n};\n\nexport type FeedSetIteratorOptions = {\n // TODO(burdon): Should we remove this and assume the feeds are positioned before adding?\n start?: FeedIndex[];\n stallTimeout?: number;\n};\n\nexport const defaultFeedSetIteratorOptions = {\n stallTimeout: 1000,\n};\n\n/**\n * Iterator that reads blocks from multiple feeds, ordering them based on a traversal callback.\n */\nexport class FeedSetIterator<T extends {}> extends AbstractFeedIterator<T> {\n private readonly _feedQueues = new ComplexMap<PublicKey, FeedQueue<T>>(PublicKey.hash);\n\n private readonly _trigger = new Trigger({ autoReset: true });\n private readonly _subscriptions = new SubscriptionList();\n\n public readonly stalled = new Event<FeedSetIterator<T>>();\n\n constructor(\n private readonly _selector: FeedBlockSelector<T>,\n public readonly options: FeedSetIteratorOptions = defaultFeedSetIteratorOptions,\n ) {\n super();\n invariant(_selector);\n invariant(options);\n }\n\n [inspect.custom](): string {\n return inspectObject(this);\n }\n\n override toJSON(): { open: boolean; running: boolean; indexes: FeedIndex[] } {\n return {\n open: this.isOpen,\n running: this.isRunning,\n indexes: this.indexes,\n };\n }\n\n get size() {\n return this._feedQueues.size;\n }\n\n get feeds(): FeedWrapper<T>[] {\n return Array.from(this._feedQueues.values()).map((feedQueue) => feedQueue.feed);\n }\n\n get indexes(): FeedIndex[] {\n return Array.from(this._feedQueues.values()).map((feedQueue) => ({\n feedKey: feedQueue.feed.key,\n index: feedQueue.index,\n }));\n }\n\n reiterateBlock(block: FeedBlock<T>): void {\n this._trigger.wake();\n }\n\n async addFeed(feed: FeedWrapper<T>): Promise<void> {\n invariant(!this._feedQueues.has(feed.key), `Feed already added: ${feed.key}`);\n invariant(feed.properties.opened);\n log('feed added', { feedKey: feed.key });\n\n // Create queue and listen for updates.\n const queue = new FeedQueue<T>(feed);\n this._feedQueues.set(feed.key, queue);\n this._subscriptions.add(\n queue.updated.on(() => {\n this._trigger.wake();\n }),\n );\n\n await queue.open({\n start: this.options.start?.find((index) => index.feedKey.equals(feed.key))?.index,\n });\n\n // Wake when feed added or queue updated.\n this._trigger.wake();\n }\n\n hasFeed(feedKey: PublicKey): boolean {\n return this._feedQueues.has(feedKey);\n }\n\n override async _onOpen(): Promise<void> {\n for (const queue of this._feedQueues.values()) {\n await queue.open();\n }\n }\n\n override async _onClose(): Promise<void> {\n this._subscriptions.clear();\n await Promise.all(Array.from(this._feedQueues.values()).map((queue) => queue.close()));\n\n // Wake when feed added or queue updated.\n this._trigger.wake();\n }\n\n /**\n * Gets the next block from the selected queue.\n */\n override async _nextBlock(): Promise<FeedBlock<T> | undefined> {\n let t: NodeJS.Timeout | undefined;\n\n while (this._running) {\n // Get blocks from the head of each queue.\n const queues = Array.from(this._feedQueues.values());\n const blocks = queues.map((queue) => queue.peek()).filter(isNonNullable);\n if (blocks.length) {\n // Get the selected block from candidates.\n const idx = this._selector(blocks);\n log('selected', { idx, blocks });\n if (idx === undefined) {\n // Timeout if all candidates are rejected.\n if (t === undefined) {\n t = setTimeout(() => {\n this.stalled.emit(this);\n this._trigger.wake();\n }, this.options.stallTimeout);\n }\n } else {\n if (t !== undefined) {\n clearTimeout(t);\n t = undefined;\n }\n if (idx >= blocks.length) {\n throw new Error(`Index out of bounds: ${idx} of ${blocks.length}`);\n }\n\n // Pop from queue.\n const queue = this._feedQueues.get(blocks[idx].feedKey)!;\n log('popping', queue.toJSON());\n try {\n const message = await queue.pop();\n invariant(message === blocks[idx]);\n return message;\n } catch (err) {\n // TODO(burdon): Same queue closed twice.\n log.warn('queue closed', { feedKey: queue.feed.key });\n // console.log(Array.from(this._feedQueues.values()));\n }\n }\n }\n\n // Wait until feed added, new block, or closing.\n await this._trigger.wait();\n }\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type PublicKey } from '@dxos/keys';\n\nexport type WriteReceipt = {\n feedKey: PublicKey;\n seq: number;\n};\n\nexport type WriteOptions = {\n /**\n * Called after the write is complete.\n * Runs and completes before the mutation is read from the pipeline.\n */\n afterWrite?: (receipt: WriteReceipt) => Promise<void>;\n};\n\nexport interface FeedWriter<T extends {}> {\n /**\n * Write data to the feed.\n * Awaits `afterWrite` before returning.\n */\n write(data: T, options?: WriteOptions): Promise<WriteReceipt>;\n}\n\nexport const createFeedWriter = <T extends {}>(cb: (data: T) => Promise<WriteReceipt>): FeedWriter<T> => ({\n write: async (data: T) => {\n return cb(data);\n },\n});\n\nexport const writeMessages = async <T extends {}>(writer: FeedWriter<T>, messages: T[]): Promise<WriteReceipt[]> => {\n const receipts: WriteReceipt[] = [];\n // NOTE: Write messages sequentially.\n for (const message of messages) {\n receipts.push(await writer.write(message));\n }\n return receipts;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAIA,OAAOA,cAAc;AAErB,SAASC,WAAAA,gBAAe;AACxB,SAASC,aAAAA,kBAAiB;AAC1B,SAASC,OAAAA,YAAW;;;ACJpB,SAASC,eAAe;
|
|
6
|
-
"names": ["safeRace", "Trigger", "invariant", "log", "inspect", "Writable", "Event", "Trigger", "latch", "inspectObject", "invariant", "log", "defaultReadStreamOptions", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport safeRace from 'race-as-promised';\n\nimport { Trigger } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport { FeedQueue } from './feed-queue';\nimport { type FeedWrapper } from './feed-wrapper';\nimport { type FeedBlock } from './types';\n\n/**\n * Base class for an async iterable feed.\n */\nexport abstract class AbstractFeedIterator<T> implements AsyncIterable<FeedBlock<T>> {\n private readonly _stopTrigger = new Trigger();\n\n protected _open = false;\n protected _running = false;\n\n toJSON(): { open: boolean; running: boolean } {\n return {\n open: this.isOpen,\n running: this.isRunning,\n };\n }\n\n get isOpen() {\n return this._open;\n }\n\n get isRunning() {\n return this._running;\n }\n\n async open(): Promise<void> {\n if (!this._open) {\n log('opening...');\n await this._onOpen();\n this._open = true;\n\n await this.start();\n log('opened');\n }\n }\n\n async close(): Promise<void> {\n if (this._open) {\n log('closing...');\n await this.stop();\n\n await this._onClose();\n this._open = false;\n log('closed');\n }\n }\n\n async start(): Promise<void> {\n invariant(this._open);\n if (!this._running) {\n this._running = true;\n }\n }\n\n async stop(): Promise<void> {\n invariant(this._open);\n if (this._running) {\n this._running = false;\n this._stopTrigger.wake();\n }\n }\n\n //\n // AsyncIterable\n //\n\n [Symbol.asyncIterator]() {\n return this._generator();\n }\n\n async *_generator() {\n log('started');\n while (this._running) {\n // https://github.com/nodejs/node/issues/17469\n const block = await safeRace([this._stopTrigger.wait(), this._nextBlock()]);\n\n if (block === undefined) {\n break;\n }\n\n yield block;\n }\n\n log('stopped');\n }\n\n abstract _onOpen(): Promise<void>;\n abstract _onClose(): Promise<void>;\n abstract _nextBlock(): Promise<FeedBlock<T> | undefined>;\n}\n\n/**\n * Iterator that reads blocks from a single feed.\n */\nexport class FeedIterator<T extends {}> extends AbstractFeedIterator<T> {\n private readonly _queue: FeedQueue<T>;\n\n constructor(private readonly _feed: FeedWrapper<T>) {\n super();\n this._queue = new FeedQueue<T>(this._feed);\n }\n\n override async _onOpen(): Promise<void> {\n await this._queue.open();\n }\n\n override async _onClose(): Promise<void> {\n await this._queue.close();\n }\n\n override async _nextBlock(): Promise<FeedBlock<T> | undefined> {\n return this._queue.pop();\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { inspect } from 'node:util';\nimport { Writable } from 'streamx';\n\nimport { Event, Trigger, latch } from '@dxos/async';\nimport { inspectObject } from '@dxos/debug';\nimport type { ReadStreamOptions } from '@dxos/hypercore';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport { type FeedWrapper } from './feed-wrapper';\nimport { type FeedBlock } from './types';\n\nexport const defaultReadStreamOptions: ReadStreamOptions = {\n live: true, // Keep reading until closed.\n batch: 1024, // Read in batches.\n};\n\nexport type FeedQueueOptions = {};\n\n/**\n * Async queue using an AsyncIterator created from a hypercore.\n */\nexport class FeedQueue<T extends {}> {\n public updated = new Event<FeedQueue<T>>();\n\n private readonly _messageTrigger = new Trigger<FeedBlock<T>>({\n autoReset: true,\n });\n\n private _feedConsumer?: Writable = undefined;\n private _next?: () => void;\n private _currentBlock?: FeedBlock<T> = undefined;\n private _index = -1;\n\n // prettier-ignore\n constructor(\n private readonly _feed: FeedWrapper<T>,\n private readonly _options: FeedQueueOptions = {},\n ) {}\n\n [inspect.custom](): string {\n return inspectObject(this);\n }\n\n toJSON() {\n return {\n feedKey: this._feed.key,\n index: this.index,\n length: this.length,\n open: this.isOpen,\n };\n }\n\n get feed() {\n return this._feed;\n }\n\n get isOpen(): boolean {\n return Boolean(this._feedConsumer);\n }\n\n get length(): number {\n return this._feed.properties.length;\n }\n\n /**\n * Index (seq) of the NEXT block to be read, or -1 if not open.\n */\n get index() {\n return this._index;\n }\n\n /**\n * Opens (or reopens) the queue.\n * @param options.start Starting index. First mutation to be read would have `seq == options.start`.\n */\n async open(options: ReadStreamOptions = {}): Promise<void> {\n if (this.isOpen) {\n // TODO(burdon): Warn if re-opening (e.g., with different starting point).\n return;\n }\n\n this._index = options.start ?? 0;\n // if (this._index !== 0) {\n // console.warn('Start index not yet supported.');\n // }\n\n log('opening', { feedKey: this._feed.key });\n\n // TODO(burdon): Open with starting range.\n const opts = Object.assign({}, defaultReadStreamOptions, options);\n const feedStream = this._feed.createReadableStream(opts);\n\n this._feedConsumer = new Writable({\n write: (data: any, next: () => void) => {\n this._next = () => {\n this._next = undefined;\n this._currentBlock = undefined;\n this._index++;\n next();\n };\n\n this._currentBlock = {\n feedKey: this._feed.key,\n seq: this._index,\n data,\n };\n\n this._messageTrigger.wake(this._currentBlock);\n this.updated.emit(this);\n },\n });\n\n const onClose = () => {\n this.feed.core.off('close', onClose);\n this._feedConsumer?.off('close', onClose);\n this._feedConsumer?.off('error', onError);\n\n this._destroyConsumer();\n };\n\n const onError = (err?: Error) => {\n if (!this.isOpen) {\n return;\n }\n if (!err) {\n return;\n }\n if (err.message === 'Writable stream closed prematurely' || err.message === 'Feed is closed') {\n return;\n }\n\n log.catch(err, { feedKey: this._feed.key });\n };\n\n // Called if feed is closed externally.\n this._feed.core.once('close', onClose);\n this._feedConsumer.on('error', onError);\n\n // Called when queue is closed. Throws exception if waiting for `pop`.\n this._feedConsumer.once('close', onClose);\n\n // Pipe readable stream into writable consumer.\n feedStream.pipe(this._feedConsumer, (err) => {\n if (err) {\n onError(err);\n }\n this._destroyConsumer();\n });\n\n log('opened');\n }\n\n /**\n * Closes the queue.\n */\n async close(): Promise<void> {\n if (this.isOpen) {\n invariant(this._feedConsumer);\n invariant(!this._feed.properties.closed);\n\n log('closing', { feedKey: this._feed.key });\n const [closed, setClosed] = latch();\n this._feedConsumer.once('close', setClosed);\n this._feedConsumer.destroy();\n this._next?.(); // Release any message currently in the queue (otherwise destroy will block).\n await closed();\n log('closed');\n }\n }\n\n /**\n * Get the block at the head of the queue without removing it.\n */\n peek(): FeedBlock<T> | undefined {\n return this._currentBlock;\n }\n\n /**\n * Pop block at the head of the queue.\n */\n async pop(): Promise<FeedBlock<T>> {\n if (!this.isOpen) {\n throw new Error(`Queue closed: ${this.feed.key.truncate()}`);\n }\n\n let block = this.peek();\n if (!block) {\n block = await this._messageTrigger.wait();\n }\n\n if (block) {\n this._next?.();\n }\n\n return block;\n }\n\n private _destroyConsumer(): void {\n if (this._feedConsumer) {\n log('queue closed', { feedKey: this._feed.key });\n this._feedConsumer = undefined;\n this._next = undefined;\n this._currentBlock = undefined;\n this._index = -1;\n }\n }\n}\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport { Event, SubscriptionList, Trigger } from '@dxos/async';\nimport { inspectObject } from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { ComplexMap, isNonNullable } from '@dxos/util';\n\nimport { AbstractFeedIterator } from './feed-iterator';\nimport { FeedQueue } from './feed-queue';\nimport { type FeedWrapper } from './feed-wrapper';\nimport { type FeedBlock } from './types';\n\n/**\n * Select next block.\n */\nexport type FeedBlockSelector<T> = (blocks: FeedBlock<T>[]) => number | undefined;\n\nexport type FeedIndex = {\n feedKey: PublicKey;\n index: number;\n};\n\nexport type FeedSetIteratorOptions = {\n // TODO(burdon): Should we remove this and assume the feeds are positioned before adding?\n start?: FeedIndex[];\n stallTimeout?: number;\n};\n\nexport const defaultFeedSetIteratorOptions = {\n stallTimeout: 1000,\n};\n\n/**\n * Iterator that reads blocks from multiple feeds, ordering them based on a traversal callback.\n */\nexport class FeedSetIterator<T extends {}> extends AbstractFeedIterator<T> {\n private readonly _feedQueues = new ComplexMap<PublicKey, FeedQueue<T>>(PublicKey.hash);\n\n private readonly _trigger = new Trigger({ autoReset: true });\n private readonly _subscriptions = new SubscriptionList();\n\n public readonly stalled = new Event<FeedSetIterator<T>>();\n\n constructor(\n private readonly _selector: FeedBlockSelector<T>,\n public readonly options: FeedSetIteratorOptions = defaultFeedSetIteratorOptions,\n ) {\n super();\n invariant(_selector);\n invariant(options);\n }\n\n [inspect.custom](): string {\n return inspectObject(this);\n }\n\n override toJSON(): { open: boolean; running: boolean; indexes: FeedIndex[] } {\n return {\n open: this.isOpen,\n running: this.isRunning,\n indexes: this.indexes,\n };\n }\n\n get size() {\n return this._feedQueues.size;\n }\n\n get feeds(): FeedWrapper<T>[] {\n return Array.from(this._feedQueues.values()).map((feedQueue) => feedQueue.feed);\n }\n\n get indexes(): FeedIndex[] {\n return Array.from(this._feedQueues.values()).map((feedQueue) => ({\n feedKey: feedQueue.feed.key,\n index: feedQueue.index,\n }));\n }\n\n reiterateBlock(block: FeedBlock<T>): void {\n this._trigger.wake();\n }\n\n async addFeed(feed: FeedWrapper<T>): Promise<void> {\n invariant(!this._feedQueues.has(feed.key), `Feed already added: ${feed.key}`);\n invariant(feed.properties.opened);\n log('feed added', { feedKey: feed.key });\n\n // Create queue and listen for updates.\n const queue = new FeedQueue<T>(feed);\n this._feedQueues.set(feed.key, queue);\n this._subscriptions.add(\n queue.updated.on(() => {\n this._trigger.wake();\n }),\n );\n\n await queue.open({\n start: this.options.start?.find((index) => index.feedKey.equals(feed.key))?.index,\n });\n\n // Wake when feed added or queue updated.\n this._trigger.wake();\n }\n\n hasFeed(feedKey: PublicKey): boolean {\n return this._feedQueues.has(feedKey);\n }\n\n override async _onOpen(): Promise<void> {\n for (const queue of this._feedQueues.values()) {\n await queue.open();\n }\n }\n\n override async _onClose(): Promise<void> {\n this._subscriptions.clear();\n await Promise.all(Array.from(this._feedQueues.values()).map((queue) => queue.close()));\n\n // Wake when feed added or queue updated.\n this._trigger.wake();\n }\n\n /**\n * Gets the next block from the selected queue.\n */\n override async _nextBlock(): Promise<FeedBlock<T> | undefined> {\n let t: NodeJS.Timeout | undefined;\n\n while (this._running) {\n // Get blocks from the head of each queue.\n const queues = Array.from(this._feedQueues.values());\n const blocks = queues.map((queue) => queue.peek()).filter(isNonNullable);\n if (blocks.length) {\n // Get the selected block from candidates.\n const idx = this._selector(blocks);\n log('selected', { idx, blocks });\n if (idx === undefined) {\n // Timeout if all candidates are rejected.\n if (t === undefined) {\n t = setTimeout(() => {\n this.stalled.emit(this);\n this._trigger.wake();\n }, this.options.stallTimeout);\n }\n } else {\n if (t !== undefined) {\n clearTimeout(t);\n t = undefined;\n }\n if (idx >= blocks.length) {\n throw new Error(`Index out of bounds: ${idx} of ${blocks.length}`);\n }\n\n // Pop from queue.\n const queue = this._feedQueues.get(blocks[idx].feedKey)!;\n log('popping', queue.toJSON());\n try {\n const message = await queue.pop();\n invariant(message === blocks[idx]);\n return message;\n } catch (err) {\n // TODO(burdon): Same queue closed twice.\n log.warn('queue closed', { feedKey: queue.feed.key });\n // console.log(Array.from(this._feedQueues.values()));\n }\n }\n }\n\n // Wait until feed added, new block, or closing.\n await this._trigger.wait();\n }\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type PublicKey } from '@dxos/keys';\n\nexport type WriteReceipt = {\n feedKey: PublicKey;\n seq: number;\n};\n\nexport type WriteOptions = {\n /**\n * Called after the write is complete.\n * Runs and completes before the mutation is read from the pipeline.\n */\n afterWrite?: (receipt: WriteReceipt) => Promise<void>;\n};\n\nexport interface FeedWriter<T extends {}> {\n /**\n * Write data to the feed.\n * Awaits `afterWrite` before returning.\n */\n write(data: T, options?: WriteOptions): Promise<WriteReceipt>;\n}\n\nexport const createFeedWriter = <T extends {}>(cb: (data: T) => Promise<WriteReceipt>): FeedWriter<T> => ({\n write: async (data: T) => {\n return cb(data);\n },\n});\n\nexport const writeMessages = async <T extends {}>(writer: FeedWriter<T>, messages: T[]): Promise<WriteReceipt[]> => {\n const receipts: WriteReceipt[] = [];\n // NOTE: Write messages sequentially.\n for (const message of messages) {\n receipts.push(await writer.write(message));\n }\n return receipts;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAIA,OAAOA,cAAc;AAErB,SAASC,WAAAA,gBAAe;AACxB,SAASC,aAAAA,kBAAiB;AAC1B,SAASC,OAAAA,YAAW;;;ACJpB,SAASC,eAAe;AACxB,SAASC,gBAAgB;AAEzB,SAASC,OAAOC,SAASC,aAAa;AACtC,SAASC,qBAAqB;AAE9B,SAASC,iBAAiB;AAC1B,SAASC,WAAW;AAKpB,IAAA,eAAaC;AAEXC,IAAO,2BAAA;EACP,MAAA;EAIF,OAAA;;;EAISC;EAEUC;YACfC,IAAAA,MAAW;EACb,kBAAG,IAAA,QAAA;IAEKC,WAAAA;EACAC,CAAAA;EACAC,gBAA+BC;EAC/BC;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EjC,aAAWC,WAAWF,UAAU;AAC9BC,aAASE,KAAK,MAAMJ,OAAOH,MAAMM,OAAAA,CAAAA;EACnC;AACA,SAAOD;AACT;",
|
|
6
|
+
"names": ["safeRace", "Trigger", "invariant", "log", "inspect", "Writable", "Event", "Trigger", "latch", "inspectObject", "invariant", "log", "defaultReadStreamOptions", "batch", "updated", "_messageTrigger", "autoReset", "_feedConsumer", "_next", "_currentBlock", "undefined", "_index", "_options", "custom", "toJSON", "feedKey", "index", "length", "open", "isOpen", "feed", "Object", "assign", "write", "next", "seq", "data", "onError", "_destroyConsumer", "err", "catch", "once", "onClose", "feedStream", "_feed", "closed", "setClosed", "destroy", "block", "peek", "__dxlog_file", "_open", "_running", "Trigger", "toJSON", "open", "running", "isOpen", "isRunning", "_onOpen", "log", "start", "stop", "_onClose", "_stopTrigger", "_generator", "block", "_nextBlock", "undefined", "_queue", "inspect", "Event", "SubscriptionList", "Trigger", "inspectObject", "invariant", "PublicKey", "log", "ComplexMap", "isNonNullable", "__dxlog_file", "defaultFeedSetIteratorOptions", "_feedQueues", "_trigger", "autoReset", "Trigger", "_subscriptions", "stalled", "_selector", "Event", "invariant", "options", "inspect", "custom", "toJSON", "inspectObject", "open", "running", "indexes", "size", "feeds", "feedKey", "index", "feedQueue", "reiterateBlock", "addFeed", "feed", "properties", "log", "FeedQueue", "queue", "updated", "wake", "hasFeed", "_onOpen", "Promise", "_running", "queues", "Array", "blocks", "length", "idx", "t", "undefined", "emit", "stallTimeout", "message", "warn", "createFeedWriter", "cb", "write", "data", "writeMessages", "writer", "messages", "receipts", "message", "push"]
|
|
7
7
|
}
|