@dxos/feed-store 0.8.3 → 0.8.4-main.2e9d522

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.
@@ -1,593 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var node_exports = {};
30
- __export(node_exports, {
31
- AbstractFeedIterator: () => AbstractFeedIterator,
32
- FeedFactory: () => import_chunk_YOYJCS5J.FeedFactory,
33
- FeedIterator: () => FeedIterator,
34
- FeedQueue: () => FeedQueue,
35
- FeedSetIterator: () => FeedSetIterator,
36
- FeedStore: () => import_chunk_YOYJCS5J.FeedStore,
37
- FeedWrapper: () => import_chunk_YOYJCS5J.FeedWrapper,
38
- createFeedWriter: () => createFeedWriter,
39
- defaultFeedSetIteratorOptions: () => defaultFeedSetIteratorOptions,
40
- defaultReadStreamOptions: () => defaultReadStreamOptions,
41
- writeMessages: () => writeMessages
42
- });
43
- module.exports = __toCommonJS(node_exports);
44
- var import_chunk_YOYJCS5J = require("./chunk-YOYJCS5J.cjs");
45
- var import_race_as_promised = __toESM(require("race-as-promised"));
46
- var import_async = require("@dxos/async");
47
- var import_invariant = require("@dxos/invariant");
48
- var import_log = require("@dxos/log");
49
- var import_node_util = require("node:util");
50
- var import_streamx = require("streamx");
51
- var import_async2 = require("@dxos/async");
52
- var import_debug = require("@dxos/debug");
53
- var import_invariant2 = require("@dxos/invariant");
54
- var import_log2 = require("@dxos/log");
55
- var import_node_util2 = require("node:util");
56
- var import_async3 = require("@dxos/async");
57
- var import_debug2 = require("@dxos/debug");
58
- var import_invariant3 = require("@dxos/invariant");
59
- var import_keys = require("@dxos/keys");
60
- var import_log3 = require("@dxos/log");
61
- var import_util = require("@dxos/util");
62
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/common/feed-store/src/feed-queue.ts";
63
- var defaultReadStreamOptions = {
64
- live: true,
65
- batch: 1024
66
- };
67
- var FeedQueue = class {
68
- // prettier-ignore
69
- constructor(_feed, _options = {}) {
70
- this._feed = _feed;
71
- this._options = _options;
72
- this.updated = new import_async2.Event();
73
- this._messageTrigger = new import_async2.Trigger({
74
- autoReset: true
75
- });
76
- this._feedConsumer = void 0;
77
- this._currentBlock = void 0;
78
- this._index = -1;
79
- }
80
- [import_node_util.inspect.custom]() {
81
- return (0, import_debug.inspectObject)(this);
82
- }
83
- toJSON() {
84
- return {
85
- feedKey: this._feed.key,
86
- index: this.index,
87
- length: this.length,
88
- open: this.isOpen
89
- };
90
- }
91
- get feed() {
92
- return this._feed;
93
- }
94
- get isOpen() {
95
- return Boolean(this._feedConsumer);
96
- }
97
- get length() {
98
- return this._feed.properties.length;
99
- }
100
- /**
101
- * Index (seq) of the NEXT block to be read, or -1 if not open.
102
- */
103
- get index() {
104
- return this._index;
105
- }
106
- /**
107
- * Opens (or reopens) the queue.
108
- * @param options.start Starting index. First mutation to be read would have `seq == options.start`.
109
- */
110
- async open(options = {}) {
111
- if (this.isOpen) {
112
- return;
113
- }
114
- this._index = options.start ?? 0;
115
- (0, import_log2.log)("opening", {
116
- feedKey: this._feed.key
117
- }, {
118
- F: __dxlog_file,
119
- L: 92,
120
- S: this,
121
- C: (f, a) => f(...a)
122
- });
123
- const opts = Object.assign({}, defaultReadStreamOptions, options);
124
- const feedStream = this._feed.createReadableStream(opts);
125
- this._feedConsumer = new import_streamx.Writable({
126
- write: (data, next) => {
127
- this._next = () => {
128
- this._next = void 0;
129
- this._currentBlock = void 0;
130
- this._index++;
131
- next();
132
- };
133
- this._currentBlock = {
134
- feedKey: this._feed.key,
135
- seq: this._index,
136
- data
137
- };
138
- this._messageTrigger.wake(this._currentBlock);
139
- this.updated.emit(this);
140
- }
141
- });
142
- const onClose = () => {
143
- this.feed.core.off("close", onClose);
144
- this._feedConsumer?.off("close", onClose);
145
- this._feedConsumer?.off("error", onError);
146
- this._destroyConsumer();
147
- };
148
- const onError = (err) => {
149
- if (!err) {
150
- return;
151
- }
152
- if (err.message === "Writable stream closed prematurely" || err.message === "Feed is closed") {
153
- return;
154
- }
155
- import_log2.log.catch(err, {
156
- feedKey: this._feed.key
157
- }, {
158
- F: __dxlog_file,
159
- L: 135,
160
- S: this,
161
- C: (f, a) => f(...a)
162
- });
163
- };
164
- this._feed.core.once("close", onClose);
165
- this._feedConsumer.on("error", onError);
166
- this._feedConsumer.once("close", onClose);
167
- feedStream.pipe(this._feedConsumer, (err) => {
168
- if (err) {
169
- onError(err);
170
- }
171
- this._destroyConsumer();
172
- });
173
- (0, import_log2.log)("opened", void 0, {
174
- F: __dxlog_file,
175
- L: 153,
176
- S: this,
177
- C: (f, a) => f(...a)
178
- });
179
- }
180
- /**
181
- * Closes the queue.
182
- */
183
- async close() {
184
- if (this.isOpen) {
185
- (0, import_invariant2.invariant)(this._feedConsumer, void 0, {
186
- F: __dxlog_file,
187
- L: 161,
188
- S: this,
189
- A: [
190
- "this._feedConsumer",
191
- ""
192
- ]
193
- });
194
- (0, import_invariant2.invariant)(!this._feed.properties.closed, void 0, {
195
- F: __dxlog_file,
196
- L: 162,
197
- S: this,
198
- A: [
199
- "!this._feed.properties.closed",
200
- ""
201
- ]
202
- });
203
- (0, import_log2.log)("closing", {
204
- feedKey: this._feed.key
205
- }, {
206
- F: __dxlog_file,
207
- L: 164,
208
- S: this,
209
- C: (f, a) => f(...a)
210
- });
211
- const [closed, setClosed] = (0, import_async2.latch)();
212
- this._feedConsumer.once("close", setClosed);
213
- this._feedConsumer.destroy();
214
- this._next?.();
215
- await closed();
216
- (0, import_log2.log)("closed", void 0, {
217
- F: __dxlog_file,
218
- L: 170,
219
- S: this,
220
- C: (f, a) => f(...a)
221
- });
222
- }
223
- }
224
- /**
225
- * Get the block at the head of the queue without removing it.
226
- */
227
- peek() {
228
- return this._currentBlock;
229
- }
230
- /**
231
- * Pop block at the head of the queue.
232
- */
233
- async pop() {
234
- if (!this.isOpen) {
235
- throw new Error(`Queue closed: ${this.feed.key.truncate()}`);
236
- }
237
- let block = this.peek();
238
- if (!block) {
239
- block = await this._messageTrigger.wait();
240
- }
241
- if (block) {
242
- this._next?.();
243
- }
244
- return block;
245
- }
246
- _destroyConsumer() {
247
- if (this._feedConsumer) {
248
- (0, import_log2.log)("queue closed", {
249
- feedKey: this._feed.key
250
- }, {
251
- F: __dxlog_file,
252
- L: 203,
253
- S: this,
254
- C: (f, a) => f(...a)
255
- });
256
- this._feedConsumer = void 0;
257
- this._next = void 0;
258
- this._currentBlock = void 0;
259
- this._index = -1;
260
- }
261
- }
262
- };
263
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/common/feed-store/src/feed-iterator.ts";
264
- var AbstractFeedIterator = class {
265
- constructor() {
266
- this._stopTrigger = new import_async.Trigger();
267
- this._open = false;
268
- this._running = false;
269
- }
270
- toJSON() {
271
- return {
272
- open: this.isOpen,
273
- running: this.isRunning
274
- };
275
- }
276
- get isOpen() {
277
- return this._open;
278
- }
279
- get isRunning() {
280
- return this._running;
281
- }
282
- async open() {
283
- if (!this._open) {
284
- (0, import_log.log)("opening...", void 0, {
285
- F: __dxlog_file2,
286
- L: 41,
287
- S: this,
288
- C: (f, a) => f(...a)
289
- });
290
- await this._onOpen();
291
- this._open = true;
292
- await this.start();
293
- (0, import_log.log)("opened", void 0, {
294
- F: __dxlog_file2,
295
- L: 46,
296
- S: this,
297
- C: (f, a) => f(...a)
298
- });
299
- }
300
- }
301
- async close() {
302
- if (this._open) {
303
- (0, import_log.log)("closing...", void 0, {
304
- F: __dxlog_file2,
305
- L: 52,
306
- S: this,
307
- C: (f, a) => f(...a)
308
- });
309
- await this.stop();
310
- await this._onClose();
311
- this._open = false;
312
- (0, import_log.log)("closed", void 0, {
313
- F: __dxlog_file2,
314
- L: 57,
315
- S: this,
316
- C: (f, a) => f(...a)
317
- });
318
- }
319
- }
320
- async start() {
321
- (0, import_invariant.invariant)(this._open, void 0, {
322
- F: __dxlog_file2,
323
- L: 62,
324
- S: this,
325
- A: [
326
- "this._open",
327
- ""
328
- ]
329
- });
330
- if (!this._running) {
331
- this._running = true;
332
- }
333
- }
334
- async stop() {
335
- (0, import_invariant.invariant)(this._open, void 0, {
336
- F: __dxlog_file2,
337
- L: 69,
338
- S: this,
339
- A: [
340
- "this._open",
341
- ""
342
- ]
343
- });
344
- if (this._running) {
345
- this._running = false;
346
- this._stopTrigger.wake();
347
- }
348
- }
349
- //
350
- // AsyncIterable
351
- //
352
- [Symbol.asyncIterator]() {
353
- return this._generator();
354
- }
355
- async *_generator() {
356
- (0, import_log.log)("started", void 0, {
357
- F: __dxlog_file2,
358
- L: 85,
359
- S: this,
360
- C: (f, a) => f(...a)
361
- });
362
- while (this._running) {
363
- const block = await (0, import_race_as_promised.default)([
364
- this._stopTrigger.wait(),
365
- this._nextBlock()
366
- ]);
367
- if (block === void 0) {
368
- break;
369
- }
370
- yield block;
371
- }
372
- (0, import_log.log)("stopped", void 0, {
373
- F: __dxlog_file2,
374
- L: 97,
375
- S: this,
376
- C: (f, a) => f(...a)
377
- });
378
- }
379
- };
380
- var FeedIterator = class extends AbstractFeedIterator {
381
- constructor(_feed) {
382
- super(), this._feed = _feed;
383
- this._queue = new FeedQueue(this._feed);
384
- }
385
- async _onOpen() {
386
- await this._queue.open();
387
- }
388
- async _onClose() {
389
- await this._queue.close();
390
- }
391
- async _nextBlock() {
392
- return this._queue.pop();
393
- }
394
- };
395
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/common/feed-store/src/feed-set-iterator.ts";
396
- var defaultFeedSetIteratorOptions = {
397
- stallTimeout: 1e3
398
- };
399
- var FeedSetIterator = class extends AbstractFeedIterator {
400
- constructor(_selector, options = defaultFeedSetIteratorOptions) {
401
- super(), this._selector = _selector, this.options = options, this._feedQueues = new import_util.ComplexMap(import_keys.PublicKey.hash), this._trigger = new import_async3.Trigger({
402
- autoReset: true
403
- }), this._subscriptions = new import_async3.SubscriptionList(), this.stalled = new import_async3.Event();
404
- (0, import_invariant3.invariant)(_selector, void 0, {
405
- F: __dxlog_file3,
406
- L: 55,
407
- S: this,
408
- A: [
409
- "_selector",
410
- ""
411
- ]
412
- });
413
- (0, import_invariant3.invariant)(options, void 0, {
414
- F: __dxlog_file3,
415
- L: 56,
416
- S: this,
417
- A: [
418
- "options",
419
- ""
420
- ]
421
- });
422
- }
423
- [import_node_util2.inspect.custom]() {
424
- return (0, import_debug2.inspectObject)(this);
425
- }
426
- toJSON() {
427
- return {
428
- open: this.isOpen,
429
- running: this.isRunning,
430
- indexes: this.indexes
431
- };
432
- }
433
- get size() {
434
- return this._feedQueues.size;
435
- }
436
- get feeds() {
437
- return Array.from(this._feedQueues.values()).map((feedQueue) => feedQueue.feed);
438
- }
439
- get indexes() {
440
- return Array.from(this._feedQueues.values()).map((feedQueue) => ({
441
- feedKey: feedQueue.feed.key,
442
- index: feedQueue.index
443
- }));
444
- }
445
- reiterateBlock(block) {
446
- this._trigger.wake();
447
- }
448
- async addFeed(feed) {
449
- (0, import_invariant3.invariant)(!this._feedQueues.has(feed.key), `Feed already added: ${feed.key}`, {
450
- F: __dxlog_file3,
451
- L: 91,
452
- S: this,
453
- A: [
454
- "!this._feedQueues.has(feed.key)",
455
- "`Feed already added: ${feed.key}`"
456
- ]
457
- });
458
- (0, import_invariant3.invariant)(feed.properties.opened, void 0, {
459
- F: __dxlog_file3,
460
- L: 92,
461
- S: this,
462
- A: [
463
- "feed.properties.opened",
464
- ""
465
- ]
466
- });
467
- (0, import_log3.log)("feed added", {
468
- feedKey: feed.key
469
- }, {
470
- F: __dxlog_file3,
471
- L: 93,
472
- S: this,
473
- C: (f, a) => f(...a)
474
- });
475
- const queue = new FeedQueue(feed);
476
- this._feedQueues.set(feed.key, queue);
477
- this._subscriptions.add(queue.updated.on(() => {
478
- this._trigger.wake();
479
- }));
480
- await queue.open({
481
- start: this.options.start?.find((index) => index.feedKey.equals(feed.key))?.index
482
- });
483
- this._trigger.wake();
484
- }
485
- hasFeed(feedKey) {
486
- return this._feedQueues.has(feedKey);
487
- }
488
- async _onOpen() {
489
- for (const queue of this._feedQueues.values()) {
490
- await queue.open();
491
- }
492
- }
493
- async _onClose() {
494
- this._subscriptions.clear();
495
- await Promise.all(Array.from(this._feedQueues.values()).map((queue) => queue.close()));
496
- this._trigger.wake();
497
- }
498
- /**
499
- * Gets the next block from the selected queue.
500
- */
501
- async _nextBlock() {
502
- let t;
503
- while (this._running) {
504
- const queues = Array.from(this._feedQueues.values());
505
- const blocks = queues.map((queue) => queue.peek()).filter(import_util.isNonNullable);
506
- if (blocks.length) {
507
- const idx = this._selector(blocks);
508
- (0, import_log3.log)("selected", {
509
- idx,
510
- blocks
511
- }, {
512
- F: __dxlog_file3,
513
- L: 143,
514
- S: this,
515
- C: (f, a) => f(...a)
516
- });
517
- if (idx === void 0) {
518
- if (t === void 0) {
519
- t = setTimeout(() => {
520
- this.stalled.emit(this);
521
- this._trigger.wake();
522
- }, this.options.stallTimeout);
523
- }
524
- } else {
525
- if (t !== void 0) {
526
- clearTimeout(t);
527
- t = void 0;
528
- }
529
- if (idx >= blocks.length) {
530
- throw new Error(`Index out of bounds: ${idx} of ${blocks.length}`);
531
- }
532
- const queue = this._feedQueues.get(blocks[idx].feedKey);
533
- (0, import_log3.log)("popping", queue.toJSON(), {
534
- F: __dxlog_file3,
535
- L: 163,
536
- S: this,
537
- C: (f, a) => f(...a)
538
- });
539
- try {
540
- const message = await queue.pop();
541
- (0, import_invariant3.invariant)(message === blocks[idx], void 0, {
542
- F: __dxlog_file3,
543
- L: 166,
544
- S: this,
545
- A: [
546
- "message === blocks[idx]",
547
- ""
548
- ]
549
- });
550
- return message;
551
- } catch (err) {
552
- import_log3.log.warn("queue closed", {
553
- feedKey: queue.feed.key
554
- }, {
555
- F: __dxlog_file3,
556
- L: 170,
557
- S: this,
558
- C: (f, a) => f(...a)
559
- });
560
- }
561
- }
562
- }
563
- await this._trigger.wait();
564
- }
565
- }
566
- };
567
- var createFeedWriter = (cb) => ({
568
- write: async (data) => {
569
- return cb(data);
570
- }
571
- });
572
- var writeMessages = async (writer, messages) => {
573
- const receipts = [];
574
- for (const message of messages) {
575
- receipts.push(await writer.write(message));
576
- }
577
- return receipts;
578
- };
579
- // Annotate the CommonJS export names for ESM import in node:
580
- 0 && (module.exports = {
581
- AbstractFeedIterator,
582
- FeedFactory,
583
- FeedIterator,
584
- FeedQueue,
585
- FeedSetIterator,
586
- FeedStore,
587
- FeedWrapper,
588
- createFeedWriter,
589
- defaultFeedSetIteratorOptions,
590
- defaultReadStreamOptions,
591
- writeMessages
592
- });
593
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 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';\nimport { Writable } from 'streamx';\n\nimport { Event, latch, Trigger } 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 (!err) {\n return;\n }\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,8BAAqB;AAErB,mBAAwB;AACxB,uBAA0B;AAC1B,iBAAoB;ACJpB,uBAAwB;AACxB,qBAAyB;AAEzB,IAAAA,gBAAsC;AACtC,mBAA8B;AAE9B,IAAAC,oBAA0B;AAC1B,IAAAC,cAAoB;ACPpB,IAAA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E2F;UAAKH;QAAO,GAAA;;;;;;AAC9B,YAAIG,QAAQ7G,QAAW;AAErB,cAAIwG,MAAMxG,QAAW;AACnBwG,gBAAIM,WAAW,MAAA;AACb,mBAAK5B,QAAQnD,KAAK,IAAI;AACtB,mBAAKgD,SAASjD,KAAI;YACpB,GAAG,KAAKd,QAAQwD,YAAY;UAC9B;QACF,OAAO;AACL,cAAIgC,MAAMxG,QAAW;AACnB+G,yBAAaP,CAAAA;AACbA,gBAAIxG;UACN;AACA,cAAI6G,OAAOH,OAAOhG,QAAQ;AACxB,kBAAM,IAAIyC,MAAM,wBAAwB0D,GAAAA,OAAUH,OAAOhG,MAAM,EAAE;UACnE;AAGA,gBAAMqF,QAAQ,KAAKpB,YAAYqC,IAAIN,OAAOG,GAAAA,EAAKtG,OAAO;AACtDW,0BAAAA,KAAI,WAAW6E,MAAMzF,OAAM,GAAA;;;;;;AAC3B,cAAI;AACF,kBAAMgC,UAAU,MAAMyD,MAAM7C,IAAG;AAC/BN,kCAAAA,WAAUN,YAAYoE,OAAOG,GAAAA,GAAI,QAAA;;;;;;;;;AACjC,mBAAOvE;UACT,SAASD,KAAK;AAEZnB,wBAAAA,IAAI+F,KAAK,gBAAgB;cAAE1G,SAASwF,MAAMlF,KAAKL;YAAI,GAAA;;;;;;UAErD;QACF;MACF;AAGA,YAAM,KAAKuE,SAASzB,KAAI;IAC1B;EACF;AACF;ACxJO,IAAM4D,mBAAmB,CAAeC,QAA2D;EACxG1F,OAAO,OAAOC,SAAAA;AACZ,WAAOyF,GAAGzF,IAAAA;EACZ;AACF;AAEO,IAAM0F,gBAAgB,OAAqBC,QAAuBC,aAAAA;AACvE,QAAMC,WAA2B,CAAA;AAEjC,aAAWjF,WAAWgF,UAAU;AAC9BC,aAASC,KAAK,MAAMH,OAAO5F,MAAMa,OAAAA,CAAAA;EACnC;AACA,SAAOiF;AACT;",
6
- "names": ["import_async", "import_invariant", "import_log", "import_node_util", "import_debug", "defaultReadStreamOptions", "live", "batch", "FeedQueue", "_feed", "_options", "updated", "Event", "_messageTrigger", "Trigger", "autoReset", "_feedConsumer", "undefined", "_currentBlock", "_index", "inspect", "custom", "inspectObject", "toJSON", "feedKey", "key", "index", "length", "open", "isOpen", "feed", "Boolean", "properties", "options", "start", "log", "opts", "Object", "assign", "feedStream", "createReadableStream", "Writable", "write", "data", "next", "_next", "seq", "wake", "emit", "onClose", "core", "off", "onError", "_destroyConsumer", "err", "message", "catch", "once", "on", "pipe", "close", "invariant", "closed", "setClosed", "latch", "destroy", "peek", "pop", "Error", "truncate", "block", "wait", "AbstractFeedIterator", "_stopTrigger", "_open", "_running", "running", "isRunning", "_onOpen", "stop", "_onClose", "Symbol", "asyncIterator", "_generator", "safeRace", "_nextBlock", "FeedIterator", "_queue", "defaultFeedSetIteratorOptions", "stallTimeout", "FeedSetIterator", "_selector", "_feedQueues", "ComplexMap", "PublicKey", "hash", "_trigger", "_subscriptions", "SubscriptionList", "stalled", "indexes", "size", "feeds", "Array", "from", "values", "map", "feedQueue", "reiterateBlock", "addFeed", "has", "opened", "queue", "set", "add", "find", "equals", "hasFeed", "clear", "Promise", "all", "t", "queues", "blocks", "filter", "isNonNullable", "idx", "setTimeout", "clearTimeout", "get", "warn", "createFeedWriter", "cb", "writeMessages", "writer", "messages", "receipts", "push"]
7
- }