@dxos/feed-store 0.8.3 → 0.8.4-main.05e74ebcff

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.
Files changed (52) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +1 -1
  3. package/dist/lib/browser/{chunk-WS47OKDO.mjs → chunk-MB63GMGR.mjs} +112 -197
  4. package/dist/lib/browser/chunk-MB63GMGR.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +62 -202
  6. package/dist/lib/browser/index.mjs.map +3 -3
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +19 -21
  9. package/dist/lib/browser/testing/index.mjs.map +3 -3
  10. package/dist/lib/node-esm/{chunk-AO5I2BX3.mjs → chunk-VZUET36D.mjs} +112 -197
  11. package/dist/lib/node-esm/chunk-VZUET36D.mjs.map +7 -0
  12. package/dist/lib/node-esm/index.mjs +62 -202
  13. package/dist/lib/node-esm/index.mjs.map +3 -3
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/testing/index.mjs +19 -21
  16. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  17. package/dist/types/src/feed-factory.d.ts.map +1 -1
  18. package/dist/types/src/feed-iterator.d.ts.map +1 -1
  19. package/dist/types/src/feed-queue.d.ts +1 -1
  20. package/dist/types/src/feed-queue.d.ts.map +1 -1
  21. package/dist/types/src/feed-set-iterator.d.ts.map +1 -1
  22. package/dist/types/src/feed-store.d.ts.map +1 -1
  23. package/dist/types/src/feed-wrapper.d.ts +18 -19
  24. package/dist/types/src/feed-wrapper.d.ts.map +1 -1
  25. package/dist/types/src/feed-writer.d.ts.map +1 -1
  26. package/dist/types/src/index.d.ts +1 -1
  27. package/dist/types/src/index.d.ts.map +1 -1
  28. package/dist/types/src/testing/mocks.d.ts.map +1 -1
  29. package/dist/types/src/testing/test-builder.d.ts +2 -2
  30. package/dist/types/src/testing/test-builder.d.ts.map +1 -1
  31. package/dist/types/src/testing/test-generator.d.ts +2 -2
  32. package/dist/types/src/testing/test-generator.d.ts.map +1 -1
  33. package/dist/types/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +27 -27
  35. package/src/feed-queue.test.ts +1 -1
  36. package/src/feed-queue.ts +5 -3
  37. package/src/feed-set-iterator.test.ts +6 -6
  38. package/src/feed-store.node.test.ts +5 -5
  39. package/src/feed-wrapper.test.ts +45 -12
  40. package/src/feed-wrapper.ts +74 -35
  41. package/src/index.ts +1 -1
  42. package/src/testing/test-builder.ts +3 -4
  43. package/src/testing/test-generator.ts +5 -6
  44. package/dist/lib/browser/chunk-WS47OKDO.mjs.map +0 -7
  45. package/dist/lib/node/chunk-YOYJCS5J.cjs +0 -523
  46. package/dist/lib/node/chunk-YOYJCS5J.cjs.map +0 -7
  47. package/dist/lib/node/index.cjs +0 -593
  48. package/dist/lib/node/index.cjs.map +0 -7
  49. package/dist/lib/node/meta.json +0 -1
  50. package/dist/lib/node/testing/index.cjs +0 -173
  51. package/dist/lib/node/testing/index.cjs.map +0 -7
  52. package/dist/lib/node-esm/chunk-AO5I2BX3.mjs.map +0 -7
package/LICENSE CHANGED
@@ -1,8 +1,105 @@
1
- MIT License
2
- Copyright (c) 2022 DXOS
1
+ # Functional Source License, Version 1.1, ALv2 Future License
3
2
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ ## Abbreviation
5
4
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ FSL-1.1-Apache-2.0
7
6
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ ## Notice
8
+
9
+ Copyright 2026 DXOS
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
package/README.md CHANGED
@@ -18,4 +18,4 @@ pnpm i @dxos/feed-store
18
18
 
19
19
  Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
20
20
 
21
- License: [MIT](./LICENSE) Copyright 2022 © DXOS
21
+ License: [FSL-1.1-Apache-2.0](./LICENSE) Copyright 2022 © DXOS
@@ -1,73 +1,29 @@
1
1
  import "@dxos/node-std/globals";
2
2
 
3
- // packages/common/feed-store/src/feed-wrapper.ts
3
+ // src/feed-wrapper.ts
4
4
  import { inspect } from "@dxos/node-std/util";
5
+ import { promisify } from "@dxos/node-std/util";
5
6
  import { Readable, Transform } from "streamx";
6
7
  import { Trigger } from "@dxos/async";
7
- import { inspectObject, StackTrace } from "@dxos/debug";
8
- import { invariant } from "@dxos/invariant";
8
+ import { StackTrace, inspectObject } from "@dxos/debug";
9
+ import { assertArgument, invariant } from "@dxos/invariant";
9
10
  import { log } from "@dxos/log";
10
- import { arrayToBuffer, createBinder, rangeFromTo } from "@dxos/util";
11
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/common/feed-store/src/feed-wrapper.ts";
11
+ import { arrayToBuffer, rangeFromTo } from "@dxos/util";
12
+ var __dxlog_file = "/__w/dxos/dxos/packages/common/feed-store/src/feed-wrapper.ts";
12
13
  var FeedWrapper = class {
13
- constructor(_hypercore, _key, _storageDirectory) {
14
- this._hypercore = _hypercore;
14
+ _key;
15
+ _storageDirectory;
16
+ _hypercore;
17
+ _pendingWrites = /* @__PURE__ */ new Set();
18
+ // Pending while writes are happening. Resolves when there are no pending writes.
19
+ _writeLock = new Trigger();
20
+ _closed = false;
21
+ constructor(hypercore2, _key, _storageDirectory) {
15
22
  this._key = _key;
16
23
  this._storageDirectory = _storageDirectory;
17
- this._pendingWrites = /* @__PURE__ */ new Set();
18
- this._binder = createBinder(this._hypercore);
19
- this._writeLock = new Trigger();
20
- this._closed = false;
21
- this.on = this._binder.fn(this._hypercore.on);
22
- this.off = this._binder.fn(this._hypercore.off);
23
- this.open = this._binder.async(this._hypercore.open);
24
- this._close = this._binder.async(this._hypercore.close);
25
- this.close = async () => {
26
- if (this._pendingWrites.size) {
27
- log.warn("Closing feed with pending writes", {
28
- feed: this._key,
29
- count: this._pendingWrites.size,
30
- pendingWrites: Array.from(this._pendingWrites.values()).map((stack) => stack.getStack())
31
- }, {
32
- F: __dxlog_file,
33
- L: 173,
34
- S: this,
35
- C: (f, a) => f(...a)
36
- });
37
- }
38
- this._closed = true;
39
- await this.flushToDisk();
40
- await this._close();
41
- };
42
- this.has = this._binder.fn(this._hypercore.has);
43
- this.get = this._binder.async(this._hypercore.get);
44
- this.append = this._binder.async(this._hypercore.append);
45
- this.download = this._binder.fn(this._hypercore.download);
46
- this.undownload = this._binder.fn(this._hypercore.undownload);
47
- this.setDownloading = this._binder.fn(this._hypercore.setDownloading);
48
- this.replicate = this._binder.fn(this._hypercore.replicate);
49
- this.clear = this._binder.async(this._hypercore.clear);
50
- this.proof = this._binder.async(this._hypercore.proof);
51
- this.put = this._binder.async(this._hypercore.put);
52
- this.putBuffer = this._binder.async(this._hypercore._putBuffer);
53
- invariant(this._hypercore, void 0, {
54
- F: __dxlog_file,
55
- L: 37,
56
- S: this,
57
- A: [
58
- "this._hypercore",
59
- ""
60
- ]
61
- });
62
- invariant(this._key, void 0, {
63
- F: __dxlog_file,
64
- L: 38,
65
- S: this,
66
- A: [
67
- "this._key",
68
- ""
69
- ]
70
- });
24
+ assertArgument(hypercore2, "hypercore");
25
+ this._hypercore = hypercore2;
26
+ invariant(this._key, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 27, S: this, A: ["this._key", ""] });
71
27
  this._writeLock.wake();
72
28
  }
73
29
  [inspect.custom]() {
@@ -112,21 +68,8 @@ var FeedWrapper = class {
112
68
  log("write", {
113
69
  feed: this._key,
114
70
  seq: this._hypercore.length
115
- }, {
116
- F: __dxlog_file,
117
- L: 97,
118
- S: this,
119
- C: (f, a) => f(...a)
120
- });
121
- invariant(!this._closed, "Feed closed", {
122
- F: __dxlog_file,
123
- L: 98,
124
- S: this,
125
- A: [
126
- "!this._closed",
127
- "'Feed closed'"
128
- ]
129
- });
71
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 74, S: this });
72
+ invariant(!this._closed, "Feed closed", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 78, S: this, A: ["!this._closed", "'Feed closed'"] });
130
73
  const stackTrace = new StackTrace();
131
74
  try {
132
75
  this._pendingWrites.add(stackTrace);
@@ -148,24 +91,11 @@ var FeedWrapper = class {
148
91
  }
149
92
  async appendWithReceipt(data) {
150
93
  const seq = await this.append(data);
151
- invariant(seq < this.length, "Invalid seq after write", {
152
- F: __dxlog_file,
153
- L: 129,
154
- S: this,
155
- A: [
156
- "seq < this.length",
157
- "'Invalid seq after write'"
158
- ]
159
- });
94
+ invariant(seq < this.length, "Invalid seq after write", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 103, S: this, A: ["seq < this.length", "'Invalid seq after write'"] });
160
95
  log("write complete", {
161
96
  feed: this._key,
162
97
  seq
163
- }, {
164
- F: __dxlog_file,
165
- L: 130,
166
- S: this,
167
- C: (f, a) => f(...a)
168
- });
98
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 104, S: this });
169
99
  const receipt = {
170
100
  feedKey: this.key,
171
101
  seq
@@ -194,19 +124,72 @@ var FeedWrapper = class {
194
124
  get byteLength() {
195
125
  return this._hypercore.byteLength;
196
126
  }
127
+ on(...args) {
128
+ return this._hypercore.on(...args);
129
+ }
130
+ off(...args) {
131
+ return this._hypercore.off(...args);
132
+ }
133
+ open(...args) {
134
+ return promisify(this._hypercore.open.bind(this._hypercore))(...args);
135
+ }
136
+ _close(...args) {
137
+ return promisify(this._hypercore.close.bind(this._hypercore))(...args);
138
+ }
139
+ close = async () => {
140
+ if (this._pendingWrites.size) {
141
+ log.warn("Closing feed with pending writes", {
142
+ feed: this._key,
143
+ count: this._pendingWrites.size,
144
+ pendingWrites: Array.from(this._pendingWrites.values()).map((stack) => stack.getStack())
145
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 149, S: this });
146
+ }
147
+ this._closed = true;
148
+ await this.flushToDisk();
149
+ await this._close();
150
+ };
151
+ has(start, end) {
152
+ return this._hypercore.has(start, end);
153
+ }
154
+ get(index, options) {
155
+ return promisify(this._hypercore.get.bind(this._hypercore))(index, options);
156
+ }
157
+ // TODO(dmaretskyi): Type better
158
+ append(data) {
159
+ return promisify(this._hypercore.append.bind(this._hypercore))(data);
160
+ }
161
+ /**
162
+ * Will not resolve if `end` parameter is not specified and the feed is not closed.
163
+ */
164
+ download(...args) {
165
+ return this._hypercore.download(...args);
166
+ }
167
+ undownload(...args) {
168
+ return this._hypercore.undownload(...args);
169
+ }
170
+ setDownloading(...args) {
171
+ return this._hypercore.setDownloading(...args);
172
+ }
173
+ replicate(...args) {
174
+ return this._hypercore.replicate(...args);
175
+ }
176
+ clear(start, end) {
177
+ return promisify(this._hypercore.clear.bind(this._hypercore))(start, end);
178
+ }
179
+ proof(index, options) {
180
+ return promisify(this._hypercore.proof.bind(this._hypercore))(index);
181
+ }
182
+ put(index, data, proof) {
183
+ return promisify(this._hypercore.put.bind(this._hypercore))(index, data, proof);
184
+ }
185
+ putBuffer(index, data, proof, peer) {
186
+ return promisify(this._hypercore._putBuffer.bind(this._hypercore))(index, data, proof, peer);
187
+ }
197
188
  /**
198
189
  * Clear and check for integrity.
199
190
  */
200
191
  async safeClear(from, to) {
201
- invariant(from >= 0 && from < to && to <= this.length, "Invalid range", {
202
- F: __dxlog_file,
203
- L: 210,
204
- S: this,
205
- A: [
206
- "from >= 0 && from < to && to <= this.length",
207
- "'Invalid range'"
208
- ]
209
- });
192
+ invariant(from >= 0 && from < to && to <= this.length, "Invalid range", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 198, S: this, A: ["from >= 0 && from < to && to <= this.length", "'Invalid range'"] });
210
193
  const CHECK_MESSAGES = 20;
211
194
  const checkBegin = to;
212
195
  const checkEnd = Math.min(checkBegin + CHECK_MESSAGES, this.length);
@@ -231,29 +214,16 @@ var FeedWrapper = class {
231
214
  }
232
215
  };
233
216
  var BatchedReadStream = class extends Readable {
217
+ _feed;
218
+ _batch;
219
+ _cursor;
220
+ _reading = false;
234
221
  constructor(feed, opts = {}) {
235
222
  super({
236
223
  objectMode: true
237
224
  });
238
- this._reading = false;
239
- invariant(opts.live === true, "Only live mode supported", {
240
- F: __dxlog_file,
241
- L: 252,
242
- S: this,
243
- A: [
244
- "opts.live === true",
245
- "'Only live mode supported'"
246
- ]
247
- });
248
- invariant(opts.batch !== void 0 && opts.batch > 1, void 0, {
249
- F: __dxlog_file,
250
- L: 253,
251
- S: this,
252
- A: [
253
- "opts.batch !== undefined && opts.batch > 1",
254
- ""
255
- ]
256
- });
225
+ invariant(opts.live === true, "Only live mode supported", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 231, S: this, A: ["opts.live === true", "'Only live mode supported'"] });
226
+ invariant(opts.batch !== void 0 && opts.batch > 1, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 232, S: this, A: ["opts.batch !== undefined && opts.batch > 1", ""] });
257
227
  this._feed = feed;
258
228
  this._batch = opts.batch;
259
229
  this._cursor = opts.start ?? 0;
@@ -303,23 +273,21 @@ var BatchedReadStream = class extends Readable {
303
273
  }
304
274
  };
305
275
 
306
- // packages/common/feed-store/src/feed-factory.ts
276
+ // src/feed-factory.ts
307
277
  import defaultsDeep from "lodash.defaultsdeep";
308
278
  import { subtleCrypto } from "@dxos/crypto";
309
279
  import { failUndefined } from "@dxos/debug";
310
280
  import { createCrypto, hypercore } from "@dxos/hypercore";
311
281
  import { log as log2 } from "@dxos/log";
312
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/common/feed-store/src/feed-factory.ts";
282
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/common/feed-store/src/feed-factory.ts";
313
283
  var FeedFactory = class {
284
+ _root;
285
+ _signer;
286
+ _hypercoreOptions;
314
287
  constructor({ root, signer, hypercore: hypercore2 }) {
315
288
  log2("FeedFactory", {
316
289
  options: hypercore2
317
- }, {
318
- F: __dxlog_file2,
319
- L: 43,
320
- S: this,
321
- C: (f, a) => f(...a)
322
- });
290
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 17, S: this });
323
291
  this._root = root ?? failUndefined();
324
292
  this._signer = signer;
325
293
  this._hypercoreOptions = hypercore2;
@@ -332,12 +300,7 @@ var FeedFactory = class {
332
300
  throw new Error("Signer required to create writable feeds.");
333
301
  }
334
302
  if (options?.secretKey) {
335
- log2.warn("Secret key ignored due to signer.", void 0, {
336
- F: __dxlog_file2,
337
- L: 58,
338
- S: this,
339
- C: (f, a) => f(...a)
340
- });
303
+ log2.warn("Secret key ignored due to signer.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 32, S: this });
341
304
  }
342
305
  const key = await subtleCrypto.digest("SHA-256", Buffer.from(publicKey.toHex()));
343
306
  const opts = defaultsDeep({}, this._hypercoreOptions, {
@@ -351,12 +314,7 @@ var FeedFactory = class {
351
314
  const { type, native } = storageDir.getOrCreateFile(filename);
352
315
  log2("created", {
353
316
  path: `${type}:${this._root.path}/${publicKey.truncate()}/${filename}`
354
- }, {
355
- F: __dxlog_file2,
356
- L: 82,
357
- S: this,
358
- C: (f, a) => f(...a)
359
- });
317
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 46, S: this });
360
318
  return native;
361
319
  };
362
320
  const core = hypercore(makeStorage, Buffer.from(key), opts);
@@ -364,20 +322,21 @@ var FeedFactory = class {
364
322
  }
365
323
  };
366
324
 
367
- // packages/common/feed-store/src/feed-store.ts
325
+ // src/feed-store.ts
368
326
  import { Event, Mutex } from "@dxos/async";
369
327
  import { failUndefined as failUndefined2 } from "@dxos/debug";
370
328
  import { invariant as invariant2 } from "@dxos/invariant";
371
329
  import { PublicKey } from "@dxos/keys";
372
330
  import { log as log3 } from "@dxos/log";
373
331
  import { ComplexMap, defaultMap } from "@dxos/util";
374
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/common/feed-store/src/feed-store.ts";
332
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/common/feed-store/src/feed-store.ts";
375
333
  var FeedStore = class {
334
+ _feeds = new ComplexMap(PublicKey.hash);
335
+ _mutexes = new ComplexMap(PublicKey.hash);
336
+ _factory;
337
+ _closed = false;
338
+ feedOpened = new Event();
376
339
  constructor({ factory }) {
377
- this._feeds = new ComplexMap(PublicKey.hash);
378
- this._mutexes = new ComplexMap(PublicKey.hash);
379
- this._closed = false;
380
- this.feedOpened = new Event();
381
340
  this._factory = factory ?? failUndefined2();
382
341
  }
383
342
  get size() {
@@ -399,30 +358,9 @@ var FeedStore = class {
399
358
  async openFeed(feedKey, { writable, sparse } = {}) {
400
359
  log3("opening feed", {
401
360
  feedKey
402
- }, {
403
- F: __dxlog_file3,
404
- L: 55,
405
- S: this,
406
- C: (f, a) => f(...a)
407
- });
408
- invariant2(feedKey, void 0, {
409
- F: __dxlog_file3,
410
- L: 56,
411
- S: this,
412
- A: [
413
- "feedKey",
414
- ""
415
- ]
416
- });
417
- invariant2(!this._closed, "Feed store is closed", {
418
- F: __dxlog_file3,
419
- L: 57,
420
- S: this,
421
- A: [
422
- "!this._closed",
423
- "'Feed store is closed'"
424
- ]
425
- });
361
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 36, S: this });
362
+ invariant2(feedKey, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 39, S: this, A: ["feedKey", ""] });
363
+ invariant2(!this._closed, "Feed store is closed", { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 40, S: this, A: ["!this._closed", "'Feed store is closed'"] });
426
364
  const mutex = defaultMap(this._mutexes, feedKey, () => new Mutex());
427
365
  return mutex.executeSynchronized(async () => {
428
366
  let feed = this.getFeed(feedKey);
@@ -445,12 +383,7 @@ var FeedStore = class {
445
383
  this.feedOpened.emit(feed);
446
384
  log3("opened", {
447
385
  feedKey
448
- }, {
449
- F: __dxlog_file3,
450
- L: 85,
451
- S: this,
452
- C: (f, a) => f(...a)
453
- });
386
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 63, S: this });
454
387
  return feed;
455
388
  });
456
389
  }
@@ -458,32 +391,14 @@ var FeedStore = class {
458
391
  * Close all feeds.
459
392
  */
460
393
  async close() {
461
- log3("closing...", void 0, {
462
- F: __dxlog_file3,
463
- L: 94,
464
- S: this,
465
- C: (f, a) => f(...a)
466
- });
394
+ log3("closing...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 72, S: this });
467
395
  this._closed = true;
468
396
  await Promise.all(Array.from(this._feeds.values()).map(async (feed) => {
469
397
  await feed.close();
470
- invariant2(feed.closed, void 0, {
471
- F: __dxlog_file3,
472
- L: 99,
473
- S: this,
474
- A: [
475
- "feed.closed",
476
- ""
477
- ]
478
- });
398
+ invariant2(feed.closed, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 76, S: this, A: ["feed.closed", ""] });
479
399
  }));
480
400
  this._feeds.clear();
481
- log3("closed", void 0, {
482
- F: __dxlog_file3,
483
- L: 108,
484
- S: this,
485
- C: (f, a) => f(...a)
486
- });
401
+ log3("closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 83, S: this });
487
402
  }
488
403
  };
489
404
 
@@ -492,4 +407,4 @@ export {
492
407
  FeedFactory,
493
408
  FeedStore
494
409
  };
495
- //# sourceMappingURL=chunk-WS47OKDO.mjs.map
410
+ //# sourceMappingURL=chunk-MB63GMGR.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/feed-wrapper.ts", "../../../src/feed-factory.ts", "../../../src/feed-store.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { inspect } from 'node:util';\nimport { promisify } from 'node:util';\nimport { Readable, Transform } from 'streamx';\n\nimport { Trigger } from '@dxos/async';\nimport { StackTrace, inspectObject } from '@dxos/debug';\nimport type { Hypercore, HypercoreProperties, ReadStreamOptions } from '@dxos/hypercore';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { type PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type Directory } from '@dxos/random-access-storage';\nimport { arrayToBuffer, rangeFromTo } from '@dxos/util';\nimport type { GetOptions, Proof } from '@dxos/vendor-hypercore/hypercore';\n\nimport { type FeedWriter, type WriteReceipt } from './feed-writer';\n\n/**\n * Async feed wrapper.\n */\nexport class FeedWrapper<T extends {}> {\n private _hypercore: Hypercore<T>;\n private readonly _pendingWrites = new Set<StackTrace>();\n\n // Pending while writes are happening. Resolves when there are no pending writes.\n private readonly _writeLock = new Trigger();\n\n private _closed = false;\n\n constructor(\n hypercore: Hypercore<T>,\n private _key: PublicKey, // TODO(burdon): Required since currently patching the key inside factory.\n private _storageDirectory: Directory,\n ) {\n assertArgument(hypercore, 'hypercore');\n this._hypercore = hypercore;\n invariant(this._key);\n this._writeLock.wake();\n }\n\n [inspect.custom](): string {\n return inspectObject(this);\n }\n\n toJSON(): { feedKey: PublicKey; length: number; opened: boolean; closed: boolean } {\n return {\n feedKey: this._key,\n length: this.properties.length,\n opened: this.properties.opened,\n closed: this.properties.closed,\n };\n }\n\n get key(): PublicKey {\n return this._key;\n }\n\n get core(): Hypercore<T> {\n return this._hypercore;\n }\n\n // TODO(burdon): Create proxy.\n get properties(): HypercoreProperties {\n return this._hypercore;\n }\n\n createReadableStream(opts?: ReadStreamOptions): Readable {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n const transform = new Transform({\n transform(data: any, cb: (err?: Error | null, data?: any) => void) {\n // Delay until write is complete.\n void self._writeLock.wait().then(() => {\n this.push(data);\n cb();\n });\n },\n });\n const readStream =\n opts?.batch !== undefined && opts?.batch > 1\n ? new BatchedReadStream(this._hypercore, opts)\n : this._hypercore.createReadStream(opts);\n\n readStream.pipe(transform, (err: any) => {\n // Ignore errors.\n // We might get \"Writable stream closed prematurely\" error.\n // Its okay since the pipeline is closed and does not expect more messages.\n });\n\n return transform;\n }\n\n createFeedWriter(): FeedWriter<T> {\n return {\n write: async (data: T, { afterWrite } = {}) => {\n log('write', { feed: this._key, seq: this._hypercore.length });\n invariant(!this._closed, 'Feed closed');\n const stackTrace = new StackTrace();\n\n try {\n // Pending writes pause the read stream.\n this._pendingWrites.add(stackTrace);\n if (this._pendingWrites.size === 1) {\n this._writeLock.reset();\n }\n\n const receipt = await this.appendWithReceipt(data);\n\n // TODO(dmaretskyi): Removing this will make user-intiated writes faster but might result in a data-loss.\n await this.flushToDisk();\n\n await afterWrite?.(receipt);\n\n return receipt;\n } finally {\n // Unblock the read stream after the write (and callback) is complete.\n this._pendingWrites.delete(stackTrace);\n if (this._pendingWrites.size === 0) {\n this._writeLock.wake();\n }\n }\n },\n };\n }\n\n async appendWithReceipt(data: T): Promise<WriteReceipt> {\n const seq = await this.append(data);\n invariant(seq < this.length, 'Invalid seq after write');\n log('write complete', { feed: this._key, seq });\n const receipt: WriteReceipt = {\n feedKey: this.key,\n seq,\n };\n return receipt;\n }\n\n /**\n * Flush pending changes to disk.\n * Calling this is not required unless you want to explicitly wait for data to be written.\n */\n async flushToDisk(): Promise<void> {\n await this._storageDirectory.flush();\n }\n\n get opened(): boolean {\n return this._hypercore.opened;\n }\n\n get closed(): boolean {\n return this._hypercore.closed;\n }\n\n get readable(): boolean {\n return this._hypercore.readable;\n }\n\n get length(): number {\n return this._hypercore.length;\n }\n\n get byteLength(): number {\n return this._hypercore.byteLength;\n }\n\n on(...args: any[]) {\n return (this._hypercore as any).on(...args);\n }\n\n off(...args: any[]) {\n return (this._hypercore as any).off(...args);\n }\n\n open(...args: Parameters<Hypercore<T>['open']>) {\n return promisify(this._hypercore.open.bind(this._hypercore) as any)(...args);\n }\n\n _close(...args: Parameters<Hypercore<T>['close']>) {\n return promisify(this._hypercore.close.bind(this._hypercore) as any)(...args);\n }\n\n close = async () => {\n if (this._pendingWrites.size) {\n log.warn('Closing feed with pending writes', {\n feed: this._key,\n count: this._pendingWrites.size,\n pendingWrites: Array.from(this._pendingWrites.values()).map((stack) => stack.getStack()),\n });\n }\n this._closed = true;\n await this.flushToDisk();\n await this._close();\n };\n\n has(start: number, end?: number) {\n return this._hypercore.has(start, end);\n }\n\n get(index: number, options?: GetOptions) {\n return promisify(this._hypercore.get.bind(this._hypercore) as any)(index, options);\n }\n\n // TODO(dmaretskyi): Type better\n append(data: any | any[]): Promise<number> {\n return promisify(this._hypercore.append.bind(this._hypercore))(data);\n }\n\n /**\n * Will not resolve if `end` parameter is not specified and the feed is not closed.\n */\n download(...args: Parameters<Hypercore<T>['download']>) {\n return this._hypercore.download(...args);\n }\n\n undownload(...args: Parameters<Hypercore<T>['undownload']>) {\n return this._hypercore.undownload(...args);\n }\n\n setDownloading(...args: Parameters<Hypercore<T>['setDownloading']>) {\n return this._hypercore.setDownloading(...args);\n }\n\n replicate(...args: Parameters<Hypercore<T>['replicate']>) {\n return this._hypercore.replicate(...args);\n }\n\n clear(start: number, end?: number) {\n return promisify(this._hypercore.clear.bind(this._hypercore))(start, end);\n }\n\n proof(index: number, options?: any) {\n return promisify(this._hypercore.proof.bind(this._hypercore))(index);\n }\n\n put(index: number, data: T, proof: Proof) {\n return promisify(this._hypercore.put.bind(this._hypercore))(index, data, proof);\n }\n\n putBuffer(index: number, data: Buffer | Uint8Array, proof: Proof, peer: null): Promise<void> {\n return promisify((this._hypercore as any)._putBuffer.bind(this._hypercore) as any)(index, data, proof, peer);\n }\n\n /**\n * Clear and check for integrity.\n */\n async safeClear(from: number, to: number): Promise<void> {\n invariant(from >= 0 && from < to && to <= this.length, 'Invalid range');\n\n const CHECK_MESSAGES = 20;\n const checkBegin = to;\n const checkEnd = Math.min(checkBegin + CHECK_MESSAGES, this.length);\n\n const messagesBefore = await Promise.all(\n rangeFromTo(checkBegin, checkEnd).map((idx) =>\n this.get(idx, {\n valueEncoding: { decode: (x: Uint8Array) => x } as any,\n }),\n ),\n );\n\n await this.clear(from, to);\n\n const messagesAfter = await Promise.all(\n rangeFromTo(checkBegin, checkEnd).map((idx) =>\n this.get(idx, {\n valueEncoding: { decode: (x: Uint8Array) => x } as any,\n }),\n ),\n );\n\n for (let i = 0; i < messagesBefore.length; i++) {\n const before = arrayToBuffer(messagesBefore[i]);\n const after = arrayToBuffer(messagesAfter[i]);\n if (!before.equals(after)) {\n throw new Error('Feed corruption on clear. There has likely been a data loss.');\n }\n }\n }\n}\n\nclass BatchedReadStream extends Readable {\n private readonly _feed: Hypercore<any>;\n private readonly _batch: number;\n private _cursor: number;\n private _reading = false;\n\n constructor(feed: Hypercore<any>, opts: ReadStreamOptions = {}) {\n super({ objectMode: true });\n invariant(opts.live === true, 'Only live mode supported');\n invariant(opts.batch !== undefined && opts.batch > 1);\n this._feed = feed;\n this._batch = opts.batch;\n this._cursor = opts.start ?? 0;\n }\n\n override _open(cb: (err: Error | null) => void): void {\n this._feed.ready(cb);\n }\n\n override _read(cb: (err: Error | null) => void): void {\n if (this._reading) {\n return;\n }\n\n if (this._feed.bitfield!.total(this._cursor, this._cursor + this._batch) === this._batch) {\n this._batchedRead(cb);\n } else {\n this._nonBatchedRead(cb);\n }\n }\n\n private _nonBatchedRead(cb: (err: Error | null) => void): void {\n this._feed.get(this._cursor, { wait: true }, (err, data) => {\n if (err) {\n cb(err);\n } else {\n this._cursor++;\n this._reading = false;\n this.push(data);\n cb(null);\n }\n });\n }\n\n private _batchedRead(cb: (err: Error | null) => void): void {\n this._feed.getBatch(this._cursor, this._cursor + this._batch, { wait: true }, (err, data) => {\n if (err) {\n cb(err);\n } else {\n this._cursor += data.length;\n this._reading = false;\n for (const item of data) {\n this.push(item);\n }\n cb(null);\n }\n });\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport defaultsDeep from 'lodash.defaultsdeep';\n\nimport { type Signer, subtleCrypto } from '@dxos/crypto';\nimport { failUndefined } from '@dxos/debug';\nimport type { HypercoreOptions } from '@dxos/hypercore';\nimport { createCrypto, hypercore } from '@dxos/hypercore';\nimport { type PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type Directory } from '@dxos/random-access-storage';\n\nimport { FeedWrapper } from './feed-wrapper';\n\nexport type FeedFactoryOptions = {\n root: Directory;\n signer?: Signer;\n hypercore?: HypercoreOptions;\n};\n\nexport type FeedOptions = HypercoreOptions & {\n writable?: boolean;\n /**\n * Optional hook called before data is written after being verified.\n * Called for writes done by this peer as well as for data replicated from other peers.\n * NOTE: The callback must be invoked to complete the write operation.\n * @param peer Always null in hypercore@9.12.0.\n */\n onwrite?: (index: number, data: any, peer: null, cb: (err: Error | null) => void) => void;\n};\n\n/**\n * Hypercore factory.\n */\nexport class FeedFactory<T extends {}> {\n private readonly _root: Directory;\n private readonly _signer?: Signer;\n private readonly _hypercoreOptions?: HypercoreOptions;\n\n constructor({ root, signer, hypercore }: FeedFactoryOptions) {\n log('FeedFactory', { options: hypercore });\n this._root = root ?? failUndefined();\n this._signer = signer;\n this._hypercoreOptions = hypercore;\n }\n\n get storageRoot() {\n return this._root;\n }\n\n async createFeed(publicKey: PublicKey, options?: FeedOptions): Promise<FeedWrapper<T>> {\n if (options?.writable && !this._signer) {\n throw new Error('Signer required to create writable feeds.');\n }\n if (options?.secretKey) {\n log.warn('Secret key ignored due to signer.');\n }\n\n // Required due to hypercore's 32-byte key limit.\n const key = await subtleCrypto.digest('SHA-256', Buffer.from(publicKey.toHex()));\n\n const opts = defaultsDeep(\n {\n // sparse: false,\n // stats: false,\n },\n this._hypercoreOptions,\n {\n secretKey: this._signer && options?.writable ? Buffer.from('secret') : undefined,\n crypto: this._signer ? createCrypto(this._signer, publicKey) : undefined,\n onwrite: options?.onwrite,\n noiseKeyPair: {}, // We're not using noise.\n },\n options,\n );\n\n const storageDir = this._root.createDirectory(publicKey.toHex());\n const makeStorage = (filename: string) => {\n const { type, native } = storageDir.getOrCreateFile(filename);\n log('created', {\n path: `${type}:${this._root.path}/${publicKey.truncate()}/${filename}`,\n });\n\n return native;\n };\n\n const core = hypercore(makeStorage, Buffer.from(key), opts);\n return new FeedWrapper(core, publicKey, storageDir);\n }\n}\n", "//\n// Copyright 2019 DXOS.org\n//\n\nimport { Event, Mutex } from '@dxos/async';\nimport { failUndefined } from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { ComplexMap, defaultMap } from '@dxos/util';\n\nimport { type FeedFactory, type FeedOptions } from './feed-factory';\nimport { type FeedWrapper } from './feed-wrapper';\n\nexport interface FeedStoreOptions<T extends {}> {\n factory: FeedFactory<T>;\n}\n\n/**\n * Persistent hypercore store.\n */\nexport class FeedStore<T extends {}> {\n private readonly _feeds: ComplexMap<PublicKey, FeedWrapper<T>> = new ComplexMap(PublicKey.hash);\n private readonly _mutexes = new ComplexMap<PublicKey, Mutex>(PublicKey.hash);\n private readonly _factory: FeedFactory<T>;\n\n private _closed = false;\n\n readonly feedOpened = new Event<FeedWrapper<T>>();\n\n constructor({ factory }: FeedStoreOptions<T>) {\n this._factory = factory ?? failUndefined();\n }\n\n get size() {\n return this._feeds.size;\n }\n\n get feeds() {\n return Array.from(this._feeds.values());\n }\n\n /**\n * Get the open feed if it exists.\n */\n getFeed(publicKey: PublicKey): FeedWrapper<T> | undefined {\n return this._feeds.get(publicKey);\n }\n\n /**\n * Gets or opens a feed.\n * The feed is readonly unless a secret key is provided.\n */\n async openFeed(feedKey: PublicKey, { writable, sparse }: FeedOptions = {}): Promise<FeedWrapper<T>> {\n log('opening feed', { feedKey });\n invariant(feedKey);\n invariant(!this._closed, 'Feed store is closed');\n\n const mutex = defaultMap(this._mutexes, feedKey, () => new Mutex());\n\n return mutex.executeSynchronized(async () => {\n let feed = this.getFeed(feedKey);\n if (feed) {\n // TODO(burdon): Need to check that there's another instance being used (create test and break this).\n // TODO(burdon): Remove from store if feed is closed externally? (remove wrapped open/close methods?)\n if (writable && !feed.properties.writable) {\n throw new Error(`Read-only feed is already open: ${feedKey.truncate()}`);\n } else if ((sparse ?? false) !== feed.properties.sparse) {\n throw new Error(\n `Feed already open with different sparse setting: ${feedKey.truncate()} [${sparse} !== ${\n feed.properties.sparse\n }]`,\n );\n } else {\n await feed.open();\n return feed;\n }\n }\n\n feed = await this._factory.createFeed(feedKey, { writable, sparse });\n this._feeds.set(feed.key, feed);\n\n await feed.open();\n this.feedOpened.emit(feed);\n log('opened', { feedKey });\n return feed;\n });\n }\n\n /**\n * Close all feeds.\n */\n async close(): Promise<void> {\n log('closing...');\n this._closed = true;\n await Promise.all(\n Array.from(this._feeds.values()).map(async (feed) => {\n await feed.close();\n invariant(feed.closed);\n // TODO(burdon): SpaceProxy still being initialized.\n // SpaceProxy.initialize => Database.createItem => ... => FeedWrapper.append\n // Uncaught Error: Closed [random-access-storage/index.js:181:38]\n // await sleep(100);\n }),\n );\n\n this._feeds.clear();\n log('closed');\n }\n}\n"],
5
+ "mappings": ";;;AAIA,SAASA,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SAASC,UAAUC,iBAAiB;AAEpC,SAASC,eAAe;AACxB,SAASC,YAAYC,qBAAqB;AAE1C,SAASC,gBAAgBC,iBAAiB;AAE1C,SAASC,WAAW;AAEpB,SAASC,eAAeC,mBAAmB;AAK3C,IAAA,eAAA;;EAIUC;EACSC;EAEjB;EACiBC,iBAAiBV,oBAAAA,IAAAA;;EAIlC,aACEW,IAAAA,QACQC;YAAAA;cACAC,YAAAA,MAAAA,mBAAAA;AAERV,SAAAA,OAAAA;AACA,SAAKK,oBAAaG;AAClBP,mBAAeQ,YAAI,WAAA;AACnB,SAAKF,aAAWI;AAClB,cAAA,KAAA,MAAA,QAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,MAAA,GAAA,CAAA,aAAA,EAAA,EAAA,CAAA;AAEClB,SAAQmB,WAAkB,KAAA;;EAE3B,CAAA,QAAA,MAAA,IAAA;AAEAC,WAAmF,cAAA,IAAA;;WAE/EC;WACAC;MACAC,SAAQ,KAAKC;MACbC,QAAQ,K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ACF,iBAAA;QAEAA;;aAA2DE,MAAAA,KAAAA,SAAAA,WAAAA,SAAAA;QAAO;QAC9D;MAEJ,CAAA;AACA,WAAKT,OAAAA,IAAWY,KAAKL,KAAAA,IAAAA;AACrBd,YAAI,KAAA,KAAU;WAAEW,WAAAA,KAAAA,IAAAA;AAAQ,MAAAX,KAAA,UAAA;QACxB;MACF,GAAA,EAAA,YAAA,YAAA,GAAAG,eAAA,GAAA,IAAA,GAAA,KAAA,CAAA;AACF,aAAA;IAEA,CAAA;;;;;QAKM,QAAQ;AACZ,IAAAH,KAAA,cAAiB,QACToB,EAAAA,YAAUC,YAAa,GAAAlB,eAAeW,GAAAA,IAAAA,GAAAA,KAAAA,CAAAA;SAC1C,UAAWQ;UACXxB,QAAUgB,IAAAA,MAAKS,KAAM,KAAA,OAAA,OAAA,CAAA,EAAA,IAAA,OAAA,SAAA;AACrB,YAAA,KAAA,MAAA;AACA,MAAAzB,WAAA,KAAA,QAAA,QAAA,EAAA,YAAA,YAAA,GAAAK,eAAA,GAAA,IAAA,GAA6E,MAAA,GAAA,CAAA,eAAA,EAAA,EAAA,CAAA;IAOjFH,CAAAA,CAAAA;AACF,SAAA,OAAA,MAAA;AACF,IAAAA,KAAA,UAAA,QAAA,EAAA,YAAA,YAAA,GAAAG,eAAA,GAAA,IAAA,GAAA,KAAA,CAAA;;;",
6
+ "names": ["inspect", "promisify", "Readable", "Transform", "Trigger", "StackTrace", "inspectObject", "assertArgument", "invariant", "log", "arrayToBuffer", "rangeFromTo", "_hypercore", "_pendingWrites", "_writeLock", "hypercore", "_key", "_storageDirectory", "wake", "custom", "toJSON", "feedKey", "length", "opened", "properties", "closed", "key", "core", "createReadableStream", "transform", "self", "cb", "readStream", "createFeedWriter", "seq", "stackTrace", "reset", "receipt", "flushToDisk", "readable", "byteLength", "open", "args", "_close", "close", "feed", "count", "pendingWrites", "_closed", "start", "index", "options", "append", "undownload", "setDownloading", "replicate", "clear", "proof", "data", "putBuffer", "CHECK_MESSAGES", "checkBegin", "to", "checkEnd", "min", "messagesBefore", "valueEncoding", "x", "messagesAfter", "i", "after", "before", "equals", "Error", "_batch", "_cursor", "_reading", "objectMode", "live", "opts", "_open", "_read", "_nonBatchedRead", "err", "push", "_batchedRead", "wait", "item", "defaultsDeep", "subtleCrypto", "failUndefined", "createCrypto", "hypercore", "log", "__dxlog_file", "_signer", "_hypercoreOptions", "options", "hypercore", "log", "root", "signer", "storageRoot", "createFeed", "secretKey", "crypto", "createCrypto", "onwrite", "noiseKeyPair", "storageDir", "makeStorage", "native", "getOrCreateFile", "filename", "path", "type", "truncate", "core", "Event", "Mutex", "failUndefined", "invariant", "PublicKey", "log", "ComplexMap", "defaultMap", "__dxlog_file", "_mutexes", "_factory", "_closed", "feedOpened", "factory", "size", "feeds", "feedKey", "mutex", "executeSynchronized", "feed", "getFeed", "sparse", "properties", "Error", "emit", "from", "_feeds", "close", "closed"]
7
+ }