@dxos/feed-store 0.6.5 → 0.6.6-staging.582ce24

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.
@@ -37,7 +37,7 @@ var FeedWrapper = class {
37
37
  pendingWrites: Array.from(this._pendingWrites.values()).map((stack) => stack.getStack())
38
38
  }, {
39
39
  F: __dxlog_file,
40
- L: 172,
40
+ L: 173,
41
41
  S: this,
42
42
  C: (f, a) => f(...a)
43
43
  });
@@ -54,9 +54,12 @@ var FeedWrapper = class {
54
54
  this.setDownloading = this._binder.fn(this._hypercore.setDownloading);
55
55
  this.replicate = this._binder.fn(this._hypercore.replicate);
56
56
  this.clear = this._binder.async(this._hypercore.clear);
57
+ this.proof = this._binder.async(this._hypercore.proof);
58
+ this.put = this._binder.async(this._hypercore.put);
59
+ this.putBuffer = this._binder.async(this._hypercore._putBuffer);
57
60
  invariant(this._hypercore, void 0, {
58
61
  F: __dxlog_file,
59
- L: 36,
62
+ L: 37,
60
63
  S: this,
61
64
  A: [
62
65
  "this._hypercore",
@@ -65,7 +68,7 @@ var FeedWrapper = class {
65
68
  });
66
69
  invariant(this._key, void 0, {
67
70
  F: __dxlog_file,
68
- L: 37,
71
+ L: 38,
69
72
  S: this,
70
73
  A: [
71
74
  "this._key",
@@ -119,13 +122,13 @@ var FeedWrapper = class {
119
122
  data
120
123
  }, {
121
124
  F: __dxlog_file,
122
- L: 96,
125
+ L: 97,
123
126
  S: this,
124
127
  C: (f, a) => f(...a)
125
128
  });
126
129
  invariant(!this._closed, "Feed closed", {
127
130
  F: __dxlog_file,
128
- L: 97,
131
+ L: 98,
129
132
  S: this,
130
133
  A: [
131
134
  "!this._closed",
@@ -155,7 +158,7 @@ var FeedWrapper = class {
155
158
  const seq = await this.append(data);
156
159
  invariant(seq < this.length, "Invalid seq after write", {
157
160
  F: __dxlog_file,
158
- L: 128,
161
+ L: 129,
159
162
  S: this,
160
163
  A: [
161
164
  "seq < this.length",
@@ -167,7 +170,7 @@ var FeedWrapper = class {
167
170
  seq
168
171
  }, {
169
172
  F: __dxlog_file,
170
- L: 129,
173
+ L: 130,
171
174
  S: this,
172
175
  C: (f, a) => f(...a)
173
176
  });
@@ -205,7 +208,7 @@ var FeedWrapper = class {
205
208
  async safeClear(from, to) {
206
209
  invariant(from >= 0 && from < to && to <= this.length, "Invalid range", {
207
210
  F: __dxlog_file,
208
- L: 200,
211
+ L: 210,
209
212
  S: this,
210
213
  A: [
211
214
  "from >= 0 && from < to && to <= this.length",
@@ -243,7 +246,7 @@ var BatchedReadStream = class extends Readable {
243
246
  this._reading = false;
244
247
  invariant(opts.live === true, "Only live mode supported", {
245
248
  F: __dxlog_file,
246
- L: 242,
249
+ L: 252,
247
250
  S: this,
248
251
  A: [
249
252
  "opts.live === true",
@@ -252,7 +255,7 @@ var BatchedReadStream = class extends Readable {
252
255
  });
253
256
  invariant(opts.batch !== void 0 && opts.batch > 1, void 0, {
254
257
  F: __dxlog_file,
255
- L: 243,
258
+ L: 253,
256
259
  S: this,
257
260
  A: [
258
261
  "opts.batch !== undefined && opts.batch > 1",
@@ -498,4 +501,4 @@ export {
498
501
  FeedFactory,
499
502
  FeedStore
500
503
  };
501
- //# sourceMappingURL=chunk-SWZCHSJO.mjs.map
504
+ //# sourceMappingURL=chunk-QEVMM5RF.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 type { Proof } from 'hypercore';\nimport { inspect } from 'node:util';\nimport { Readable, Transform } from 'streamx';\n\nimport { Trigger } from '@dxos/async';\nimport { inspectObject, StackTrace } from '@dxos/debug';\nimport type { Hypercore, HypercoreProperties, ReadStreamOptions } from '@dxos/hypercore';\nimport { 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, createBinder, rangeFromTo } from '@dxos/util';\n\nimport { type FeedWriter, type WriteReceipt } from './feed-writer';\n\n/**\n * Async feed wrapper.\n */\nexport class FeedWrapper<T extends {}> {\n private readonly _pendingWrites = new Set<StackTrace>();\n private readonly _binder = createBinder(this._hypercore);\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 private _hypercore: Hypercore<T>,\n private _key: PublicKey, // TODO(burdon): Required since currently patching the key inside factory.\n private _storageDirectory: Directory,\n ) {\n invariant(this._hypercore);\n invariant(this._key);\n this._writeLock.wake();\n }\n\n [inspect.custom]() {\n return inspectObject(this);\n }\n\n toJSON() {\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, data });\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() {\n await this._storageDirectory.flush();\n }\n\n get opened() {\n return this._hypercore.opened;\n }\n\n get closed() {\n return this._hypercore.closed;\n }\n\n get readable() {\n return this._hypercore.readable;\n }\n\n get length() {\n return this._hypercore.length;\n }\n\n get byteLength() {\n return this._hypercore.byteLength;\n }\n\n on = this._binder.fn(this._hypercore.on);\n off = this._binder.fn(this._hypercore.off);\n\n open = this._binder.async(this._hypercore.open);\n private _close = this._binder.async(this._hypercore.close);\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 = this._binder.fn(this._hypercore.has) as (start: number, end?: number) => boolean;\n get = this._binder.async(this._hypercore.get);\n append = this._binder.async(this._hypercore.append);\n\n /**\n * Will not resolve if `end` parameter is not specified and the feed is not closed.\n */\n download = this._binder.fn(this._hypercore.download);\n undownload = this._binder.fn(this._hypercore.undownload);\n setDownloading = this._binder.fn(this._hypercore.setDownloading);\n replicate: Hypercore<T>['replicate'] = this._binder.fn(this._hypercore.replicate);\n clear = this._binder.async(this._hypercore.clear) as (start: number, end?: number) => Promise<void>;\n\n proof = this._binder.async(this._hypercore.proof) as (index: number) => Promise<Proof>;\n put = this._binder.async(this._hypercore.put) as (index: number, data: T, proof: Proof) => Promise<void>;\n putBuffer = this._binder.async((this._hypercore as any)._putBuffer) as (\n index: number,\n data: Buffer,\n proof: Proof,\n from: null,\n ) => Promise<void>;\n\n /**\n * Clear and check for integrity.\n */\n async safeClear(from: number, to: number) {\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 },\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 },\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) {\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) {\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() {\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": ";;;;;;;;;;AAKA,SAASA,eAAe;AACxB,SAASC,UAAUC,iBAAiB;AAEpC,SAASC,eAAe;AACxB,SAASC,eAAeC,kBAAkB;AAE1C,SAASC,iBAAiB;AAE1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ACT;MACF;AAEAA,aAAO,MAAM,KAAKf,SAASoB,WAAWV,SAAS;QAAEC;QAAUC;MAAO,CAAA;AAClE,WAAKjB,OAAO0B,IAAIN,KAAKO,KAAKP,IAAAA;AAE1B,YAAMA,KAAKI,KAAI;AACf,WAAKpB,WAAWwB,KAAKR,IAAAA;AACrB1B,MAAAA,KAAI,UAAU;QAAEqB;MAAQ,GAAA;;;;;;AACxB,aAAOK;IACT,CAAA;EACF;;;;EAKA,MAAMS,QAAQ;AACZnC,IAAAA,KAAI,cAAA,QAAA;;;;;;AACJ,SAAKS,UAAU;AACf,UAAM2B,QAAQC,IACZvB,MAAMC,KAAK,KAAKT,OAAOU,OAAM,CAAA,EAAIsB,IAAI,OAAOZ,SAAAA;AAC1C,YAAMA,KAAKS,MAAK;AAChBrC,MAAAA,WAAU4B,KAAKa,QAAM,QAAA;;;;;;;;;IAKvB,CAAA,CAAA;AAGF,SAAKjC,OAAOkC,MAAK;AACjBxC,IAAAA,KAAI,UAAA,QAAA;;;;;;EACN;AACF;",
6
+ "names": ["inspect", "Readable", "Transform", "Trigger", "inspectObject", "StackTrace", "invariant", "log", "arrayToBuffer", "createBinder", "rangeFromTo", "FeedWrapper", "constructor", "_hypercore", "_key", "_storageDirectory", "_pendingWrites", "Set", "_binder", "_writeLock", "_closed", "on", "fn", "off", "open", "async", "_close", "close", "size", "warn", "feed", "count", "pendingWrites", "Array", "from", "values", "map", "stack", "getStack", "flushToDisk", "has", "get", "append", "download", "undownload", "setDownloading", "replicate", "clear", "proof", "put", "putBuffer", "_putBuffer", "wake", "custom", "toJSON", "feedKey", "length", "properties", "opened", "closed", "key", "core", "createReadableStream", "opts", "self", "transform", "data", "cb", "wait", "then", "push", "readStream", "batch", "undefined", "BatchedReadStream", "createReadStream", "pipe", "err", "createFeedWriter", "write", "afterWrite", "seq", "stackTrace", "add", "reset", "receipt", "appendWithReceipt", "delete", "flush", "readable", "byteLength", "safeClear", "to", "CHECK_MESSAGES", "checkBegin", "checkEnd", "Math", "min", "messagesBefore", "Promise", "all", "idx", "valueEncoding", "decode", "x", "messagesAfter", "i", "before", "after", "equals", "Error", "objectMode", "_reading", "live", "_feed", "_batch", "_cursor", "start", "_open", "ready", "_read", "bitfield", "total", "_batchedRead", "_nonBatchedRead", "getBatch", "item", "defaultsDeep", "subtleCrypto", "failUndefined", "createCrypto", "hypercore", "log", "FeedFactory", "constructor", "root", "signer", "hypercore", "log", "options", "_root", "failUndefined", "_signer", "_hypercoreOptions", "storageRoot", "createFeed", "publicKey", "writable", "Error", "secretKey", "warn", "key", "subtleCrypto", "digest", "Buffer", "from", "toHex", "opts", "defaultsDeep", "undefined", "crypto", "createCrypto", "onwrite", "noiseKeyPair", "storageDir", "createDirectory", "makeStorage", "filename", "type", "native", "getOrCreateFile", "path", "truncate", "core", "FeedWrapper", "Event", "Mutex", "failUndefined", "invariant", "PublicKey", "log", "ComplexMap", "defaultMap", "FeedStore", "constructor", "factory", "_feeds", "hash", "_mutexes", "_closed", "feedOpened", "_factory", "size", "feeds", "Array", "from", "values", "getFeed", "publicKey", "get", "openFeed", "feedKey", "writable", "sparse", "mutex", "executeSynchronized", "feed", "properties", "Error", "truncate", "open", "createFeed", "set", "key", "emit", "close", "Promise", "all", "map", "closed", "clear"]
7
+ }
@@ -3,7 +3,7 @@ import {
3
3
  FeedFactory,
4
4
  FeedStore,
5
5
  FeedWrapper
6
- } from "./chunk-SWZCHSJO.mjs";
6
+ } from "./chunk-QEVMM5RF.mjs";
7
7
 
8
8
  // packages/common/feed-store/src/feed-iterator.ts
9
9
  import safeRace from "race-as-promised";
@@ -1 +1 @@
1
- {"inputs":{"inject-globals:@inject-globals":{"bytes":384,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-wrapper.ts":{"bytes":33165,"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-factory.ts":{"bytes":9251,"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/feed-wrapper.ts","kind":"import-statement","original":"./feed-wrapper"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-queue.ts":{"bytes":19868,"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-iterator.ts":{"bytes":10231,"imports":[{"path":"race-as-promised","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/feed-queue.ts","kind":"import-statement","original":"./feed-queue"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-set-iterator.ts":{"bytes":19960,"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/feed-iterator.ts","kind":"import-statement","original":"./feed-iterator"},{"path":"packages/common/feed-store/src/feed-queue.ts","kind":"import-statement","original":"./feed-queue"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-store.ts":{"bytes":12315,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-writer.ts":{"bytes":2686,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/types.ts":{"bytes":614,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/index.ts":{"bytes":1196,"imports":[{"path":"packages/common/feed-store/src/feed-factory.ts","kind":"import-statement","original":"./feed-factory"},{"path":"packages/common/feed-store/src/feed-iterator.ts","kind":"import-statement","original":"./feed-iterator"},{"path":"packages/common/feed-store/src/feed-set-iterator.ts","kind":"import-statement","original":"./feed-set-iterator"},{"path":"packages/common/feed-store/src/feed-queue.ts","kind":"import-statement","original":"./feed-queue"},{"path":"packages/common/feed-store/src/feed-store.ts","kind":"import-statement","original":"./feed-store"},{"path":"packages/common/feed-store/src/feed-wrapper.ts","kind":"import-statement","original":"./feed-wrapper"},{"path":"packages/common/feed-store/src/feed-writer.ts","kind":"import-statement","original":"./feed-writer"},{"path":"packages/common/feed-store/src/types.ts","kind":"import-statement","original":"./types"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/testing/mocks.ts":{"bytes":3541,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/testing/test-generator.ts":{"bytes":5631,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/testing/test-builder.ts":{"bytes":9730,"imports":[{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/random-access-storage","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/testing/test-generator.ts","kind":"import-statement","original":"./test-generator"},{"path":"packages/common/feed-store/src/feed-factory.ts","kind":"import-statement","original":"../feed-factory"},{"path":"packages/common/feed-store/src/feed-store.ts","kind":"import-statement","original":"../feed-store"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/testing/index.ts":{"bytes":705,"imports":[{"path":"packages/common/feed-store/src/testing/mocks.ts","kind":"import-statement","original":"./mocks"},{"path":"packages/common/feed-store/src/testing/test-builder.ts","kind":"import-statement","original":"./test-builder"},{"path":"packages/common/feed-store/src/testing/test-generator.ts","kind":"import-statement","original":"./test-generator"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/common/feed-store/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":24009},"packages/common/feed-store/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/common/feed-store/dist/lib/browser/chunk-SWZCHSJO.mjs","kind":"import-statement"},{"path":"race-as-promised","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["AbstractFeedIterator","FeedFactory","FeedIterator","FeedQueue","FeedSetIterator","FeedStore","FeedWrapper","createFeedWriter","defaultFeedSetIteratorOptions","defaultReadStreamOptions","writeMessages"],"entryPoint":"packages/common/feed-store/src/index.ts","inputs":{"packages/common/feed-store/src/index.ts":{"bytesInOutput":0},"packages/common/feed-store/src/feed-iterator.ts":{"bytesInOutput":2802},"packages/common/feed-store/src/feed-queue.ts":{"bytesInOutput":4935},"packages/common/feed-store/src/feed-set-iterator.ts":{"bytesInOutput":4893},"packages/common/feed-store/src/feed-writer.ts":{"bytesInOutput":273}},"bytes":13536},"packages/common/feed-store/dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":9599},"packages/common/feed-store/dist/lib/browser/testing/index.mjs":{"imports":[{"path":"packages/common/feed-store/dist/lib/browser/chunk-SWZCHSJO.mjs","kind":"import-statement"},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/random-access-storage","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true}],"exports":["MockFeedWriter","TestBuilder","TestGenerator","TestItemBuilder","defaultCodec","defaultTestBlockGenerator","defaultTestGenerator","defaultValueEncoding"],"entryPoint":"packages/common/feed-store/src/testing/index.ts","inputs":{"packages/common/feed-store/src/testing/mocks.ts":{"bytesInOutput":784},"packages/common/feed-store/src/testing/index.ts":{"bytesInOutput":0},"packages/common/feed-store/src/testing/test-builder.ts":{"bytesInOutput":1800},"packages/common/feed-store/src/testing/test-generator.ts":{"bytesInOutput":961}},"bytes":4095},"packages/common/feed-store/dist/lib/browser/chunk-SWZCHSJO.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":25432},"packages/common/feed-store/dist/lib/browser/chunk-SWZCHSJO.mjs":{"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true},{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Buffer","FeedFactory","FeedStore","FeedWrapper"],"inputs":{"inject-globals:@inject-globals":{"bytesInOutput":79},"packages/common/feed-store/src/feed-wrapper.ts":{"bytesInOutput":8046},"packages/common/feed-store/src/feed-factory.ts":{"bytesInOutput":2015},"packages/common/feed-store/src/feed-store.ts":{"bytesInOutput":3129}},"bytes":13597}}}
1
+ {"inputs":{"inject-globals:@inject-globals":{"bytes":384,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-wrapper.ts":{"bytes":34421,"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-factory.ts":{"bytes":9251,"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/feed-wrapper.ts","kind":"import-statement","original":"./feed-wrapper"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-queue.ts":{"bytes":19868,"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-iterator.ts":{"bytes":10231,"imports":[{"path":"race-as-promised","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/feed-queue.ts","kind":"import-statement","original":"./feed-queue"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-set-iterator.ts":{"bytes":19960,"imports":[{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/feed-iterator.ts","kind":"import-statement","original":"./feed-iterator"},{"path":"packages/common/feed-store/src/feed-queue.ts","kind":"import-statement","original":"./feed-queue"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-store.ts":{"bytes":12315,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-writer.ts":{"bytes":2686,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/types.ts":{"bytes":614,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/index.ts":{"bytes":1196,"imports":[{"path":"packages/common/feed-store/src/feed-factory.ts","kind":"import-statement","original":"./feed-factory"},{"path":"packages/common/feed-store/src/feed-iterator.ts","kind":"import-statement","original":"./feed-iterator"},{"path":"packages/common/feed-store/src/feed-set-iterator.ts","kind":"import-statement","original":"./feed-set-iterator"},{"path":"packages/common/feed-store/src/feed-queue.ts","kind":"import-statement","original":"./feed-queue"},{"path":"packages/common/feed-store/src/feed-store.ts","kind":"import-statement","original":"./feed-store"},{"path":"packages/common/feed-store/src/feed-wrapper.ts","kind":"import-statement","original":"./feed-wrapper"},{"path":"packages/common/feed-store/src/feed-writer.ts","kind":"import-statement","original":"./feed-writer"},{"path":"packages/common/feed-store/src/types.ts","kind":"import-statement","original":"./types"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/testing/mocks.ts":{"bytes":3541,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/testing/test-generator.ts":{"bytes":5631,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/testing/test-builder.ts":{"bytes":9730,"imports":[{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/random-access-storage","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/testing/test-generator.ts","kind":"import-statement","original":"./test-generator"},{"path":"packages/common/feed-store/src/feed-factory.ts","kind":"import-statement","original":"../feed-factory"},{"path":"packages/common/feed-store/src/feed-store.ts","kind":"import-statement","original":"../feed-store"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/testing/index.ts":{"bytes":705,"imports":[{"path":"packages/common/feed-store/src/testing/mocks.ts","kind":"import-statement","original":"./mocks"},{"path":"packages/common/feed-store/src/testing/test-builder.ts","kind":"import-statement","original":"./test-builder"},{"path":"packages/common/feed-store/src/testing/test-generator.ts","kind":"import-statement","original":"./test-generator"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/common/feed-store/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":24009},"packages/common/feed-store/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/common/feed-store/dist/lib/browser/chunk-QEVMM5RF.mjs","kind":"import-statement"},{"path":"race-as-promised","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["AbstractFeedIterator","FeedFactory","FeedIterator","FeedQueue","FeedSetIterator","FeedStore","FeedWrapper","createFeedWriter","defaultFeedSetIteratorOptions","defaultReadStreamOptions","writeMessages"],"entryPoint":"packages/common/feed-store/src/index.ts","inputs":{"packages/common/feed-store/src/index.ts":{"bytesInOutput":0},"packages/common/feed-store/src/feed-iterator.ts":{"bytesInOutput":2802},"packages/common/feed-store/src/feed-queue.ts":{"bytesInOutput":4935},"packages/common/feed-store/src/feed-set-iterator.ts":{"bytesInOutput":4893},"packages/common/feed-store/src/feed-writer.ts":{"bytesInOutput":273}},"bytes":13536},"packages/common/feed-store/dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":9599},"packages/common/feed-store/dist/lib/browser/testing/index.mjs":{"imports":[{"path":"packages/common/feed-store/dist/lib/browser/chunk-QEVMM5RF.mjs","kind":"import-statement"},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/random-access-storage","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true}],"exports":["MockFeedWriter","TestBuilder","TestGenerator","TestItemBuilder","defaultCodec","defaultTestBlockGenerator","defaultTestGenerator","defaultValueEncoding"],"entryPoint":"packages/common/feed-store/src/testing/index.ts","inputs":{"packages/common/feed-store/src/testing/mocks.ts":{"bytesInOutput":784},"packages/common/feed-store/src/testing/index.ts":{"bytesInOutput":0},"packages/common/feed-store/src/testing/test-builder.ts":{"bytesInOutput":1800},"packages/common/feed-store/src/testing/test-generator.ts":{"bytesInOutput":961}},"bytes":4095},"packages/common/feed-store/dist/lib/browser/chunk-QEVMM5RF.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":26081},"packages/common/feed-store/dist/lib/browser/chunk-QEVMM5RF.mjs":{"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true},{"path":"@dxos/node-std/util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["Buffer","FeedFactory","FeedStore","FeedWrapper"],"inputs":{"inject-globals:@inject-globals":{"bytesInOutput":79},"packages/common/feed-store/src/feed-wrapper.ts":{"bytesInOutput":8231},"packages/common/feed-store/src/feed-factory.ts":{"bytesInOutput":2015},"packages/common/feed-store/src/feed-store.ts":{"bytesInOutput":3129}},"bytes":13782}}}
@@ -3,7 +3,7 @@ import {
3
3
  Buffer,
4
4
  FeedFactory,
5
5
  FeedStore
6
- } from "../chunk-SWZCHSJO.mjs";
6
+ } from "../chunk-QEVMM5RF.mjs";
7
7
 
8
8
  // packages/common/feed-store/src/testing/mocks.ts
9
9
  import { Event, scheduleTask } from "@dxos/async";
@@ -26,13 +26,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_HUR3QFCR_exports = {};
30
- __export(chunk_HUR3QFCR_exports, {
29
+ var chunk_CEOKPJ6P_exports = {};
30
+ __export(chunk_CEOKPJ6P_exports, {
31
31
  FeedFactory: () => FeedFactory,
32
32
  FeedStore: () => FeedStore,
33
33
  FeedWrapper: () => FeedWrapper
34
34
  });
35
- module.exports = __toCommonJS(chunk_HUR3QFCR_exports);
35
+ module.exports = __toCommonJS(chunk_CEOKPJ6P_exports);
36
36
  var import_node_util = require("node:util");
37
37
  var import_streamx = require("streamx");
38
38
  var import_async = require("@dxos/async");
@@ -73,7 +73,7 @@ var FeedWrapper = class {
73
73
  pendingWrites: Array.from(this._pendingWrites.values()).map((stack) => stack.getStack())
74
74
  }, {
75
75
  F: __dxlog_file,
76
- L: 172,
76
+ L: 173,
77
77
  S: this,
78
78
  C: (f, a) => f(...a)
79
79
  });
@@ -90,9 +90,12 @@ var FeedWrapper = class {
90
90
  this.setDownloading = this._binder.fn(this._hypercore.setDownloading);
91
91
  this.replicate = this._binder.fn(this._hypercore.replicate);
92
92
  this.clear = this._binder.async(this._hypercore.clear);
93
+ this.proof = this._binder.async(this._hypercore.proof);
94
+ this.put = this._binder.async(this._hypercore.put);
95
+ this.putBuffer = this._binder.async(this._hypercore._putBuffer);
93
96
  (0, import_invariant.invariant)(this._hypercore, void 0, {
94
97
  F: __dxlog_file,
95
- L: 36,
98
+ L: 37,
96
99
  S: this,
97
100
  A: [
98
101
  "this._hypercore",
@@ -101,7 +104,7 @@ var FeedWrapper = class {
101
104
  });
102
105
  (0, import_invariant.invariant)(this._key, void 0, {
103
106
  F: __dxlog_file,
104
- L: 37,
107
+ L: 38,
105
108
  S: this,
106
109
  A: [
107
110
  "this._key",
@@ -155,13 +158,13 @@ var FeedWrapper = class {
155
158
  data
156
159
  }, {
157
160
  F: __dxlog_file,
158
- L: 96,
161
+ L: 97,
159
162
  S: this,
160
163
  C: (f, a) => f(...a)
161
164
  });
162
165
  (0, import_invariant.invariant)(!this._closed, "Feed closed", {
163
166
  F: __dxlog_file,
164
- L: 97,
167
+ L: 98,
165
168
  S: this,
166
169
  A: [
167
170
  "!this._closed",
@@ -191,7 +194,7 @@ var FeedWrapper = class {
191
194
  const seq = await this.append(data);
192
195
  (0, import_invariant.invariant)(seq < this.length, "Invalid seq after write", {
193
196
  F: __dxlog_file,
194
- L: 128,
197
+ L: 129,
195
198
  S: this,
196
199
  A: [
197
200
  "seq < this.length",
@@ -203,7 +206,7 @@ var FeedWrapper = class {
203
206
  seq
204
207
  }, {
205
208
  F: __dxlog_file,
206
- L: 129,
209
+ L: 130,
207
210
  S: this,
208
211
  C: (f, a) => f(...a)
209
212
  });
@@ -241,7 +244,7 @@ var FeedWrapper = class {
241
244
  async safeClear(from, to) {
242
245
  (0, import_invariant.invariant)(from >= 0 && from < to && to <= this.length, "Invalid range", {
243
246
  F: __dxlog_file,
244
- L: 200,
247
+ L: 210,
245
248
  S: this,
246
249
  A: [
247
250
  "from >= 0 && from < to && to <= this.length",
@@ -279,7 +282,7 @@ var BatchedReadStream = class extends import_streamx.Readable {
279
282
  this._reading = false;
280
283
  (0, import_invariant.invariant)(opts.live === true, "Only live mode supported", {
281
284
  F: __dxlog_file,
282
- L: 242,
285
+ L: 252,
283
286
  S: this,
284
287
  A: [
285
288
  "opts.live === true",
@@ -288,7 +291,7 @@ var BatchedReadStream = class extends import_streamx.Readable {
288
291
  });
289
292
  (0, import_invariant.invariant)(opts.batch !== void 0 && opts.batch > 1, void 0, {
290
293
  F: __dxlog_file,
291
- L: 243,
294
+ L: 253,
292
295
  S: this,
293
296
  A: [
294
297
  "opts.batch !== undefined && opts.batch > 1",
@@ -518,4 +521,4 @@ var FeedStore = class {
518
521
  FeedStore,
519
522
  FeedWrapper
520
523
  });
521
- //# sourceMappingURL=chunk-HUR3QFCR.cjs.map
524
+ //# sourceMappingURL=chunk-CEOKPJ6P.cjs.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 type { Proof } from 'hypercore';\nimport { inspect } from 'node:util';\nimport { Readable, Transform } from 'streamx';\n\nimport { Trigger } from '@dxos/async';\nimport { inspectObject, StackTrace } from '@dxos/debug';\nimport type { Hypercore, HypercoreProperties, ReadStreamOptions } from '@dxos/hypercore';\nimport { 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, createBinder, rangeFromTo } from '@dxos/util';\n\nimport { type FeedWriter, type WriteReceipt } from './feed-writer';\n\n/**\n * Async feed wrapper.\n */\nexport class FeedWrapper<T extends {}> {\n private readonly _pendingWrites = new Set<StackTrace>();\n private readonly _binder = createBinder(this._hypercore);\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 private _hypercore: Hypercore<T>,\n private _key: PublicKey, // TODO(burdon): Required since currently patching the key inside factory.\n private _storageDirectory: Directory,\n ) {\n invariant(this._hypercore);\n invariant(this._key);\n this._writeLock.wake();\n }\n\n [inspect.custom]() {\n return inspectObject(this);\n }\n\n toJSON() {\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, data });\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() {\n await this._storageDirectory.flush();\n }\n\n get opened() {\n return this._hypercore.opened;\n }\n\n get closed() {\n return this._hypercore.closed;\n }\n\n get readable() {\n return this._hypercore.readable;\n }\n\n get length() {\n return this._hypercore.length;\n }\n\n get byteLength() {\n return this._hypercore.byteLength;\n }\n\n on = this._binder.fn(this._hypercore.on);\n off = this._binder.fn(this._hypercore.off);\n\n open = this._binder.async(this._hypercore.open);\n private _close = this._binder.async(this._hypercore.close);\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 = this._binder.fn(this._hypercore.has) as (start: number, end?: number) => boolean;\n get = this._binder.async(this._hypercore.get);\n append = this._binder.async(this._hypercore.append);\n\n /**\n * Will not resolve if `end` parameter is not specified and the feed is not closed.\n */\n download = this._binder.fn(this._hypercore.download);\n undownload = this._binder.fn(this._hypercore.undownload);\n setDownloading = this._binder.fn(this._hypercore.setDownloading);\n replicate: Hypercore<T>['replicate'] = this._binder.fn(this._hypercore.replicate);\n clear = this._binder.async(this._hypercore.clear) as (start: number, end?: number) => Promise<void>;\n\n proof = this._binder.async(this._hypercore.proof) as (index: number) => Promise<Proof>;\n put = this._binder.async(this._hypercore.put) as (index: number, data: T, proof: Proof) => Promise<void>;\n putBuffer = this._binder.async((this._hypercore as any)._putBuffer) as (\n index: number,\n data: Buffer,\n proof: Proof,\n from: null,\n ) => Promise<void>;\n\n /**\n * Clear and check for integrity.\n */\n async safeClear(from: number, to: number) {\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 },\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 },\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) {\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) {\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() {\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,uBAAwB;AACxB,qBAAoC;AAEpC,mBAAwB;AACxB,mBAA0C;AAE1C,uBAA0B;AAE1B,iBAAoB;AAEpB,kBAAyD;ACXzD,oBAAyB;AAEzB,oBAA0C;AAC1C,IAAAA,gBAA8B;AAE9B,uBAAwC;AAExC,IAAAC,cAAoB;ACPpB,IAAAC,gBAA6B;AAC7B,IAAAF,gBAA8B;AAC9B,IAAAG,oBAA0B;AAC1B,kBAA0B;AAC1B,IAAAF,cAAoB;AACpB,IAAAG,eAAuC;;AFahC,IAAMC,cAAN,MAAMA;EASXC,YACUC,YACAC,MACAC,mBACR;SAHQF,aAAAA;SACAC,OAAAA;SACAC,oBAAAA;SAXOC,iBAAiB,oBAAIC,IAAAA;SACrBC,cAAUC,0BAAa,KAAKN,UAAU;SAGtCO,aAAa,IAAIC,qBAAAA;SAE1BC,UAAU;SAwIlBC,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AAM,CAAA,EAAIC,IAAI,OAAON,SAAAA;AAC1C,YAAMA,KAAKJ,MAAK;AAChB0B,4BAAAA,WAAUtB,KAAKgC,QAAM,QAAA;;;;;;;;;IAKvB,CAAA,CAAA;AAGF,SAAK2G,OAAO1H,MAAK;AACjBnB,oBAAAA,KAAI,UAAA,QAAA;;;;;;EACN;AACF;",
6
+ "names": ["import_debug", "import_log", "import_async", "import_invariant", "import_util", "FeedWrapper", "constructor", "_hypercore", "_key", "_storageDirectory", "_pendingWrites", "Set", "_binder", "createBinder", "_writeLock", "Trigger", "_closed", "on", "fn", "off", "open", "async", "_close", "close", "size", "log", "warn", "feed", "count", "pendingWrites", "Array", "from", "values", "map", "stack", "getStack", "flushToDisk", "has", "get", "append", "download", "undownload", "setDownloading", "replicate", "clear", "proof", "put", "putBuffer", "_putBuffer", "invariant", "wake", "inspect", "custom", "inspectObject", "toJSON", "feedKey", "length", "properties", "opened", "closed", "key", "core", "createReadableStream", "opts", "self", "transform", "Transform", "data", "cb", "wait", "then", "push", "readStream", "batch", "undefined", "BatchedReadStream", "createReadStream", "pipe", "err", "createFeedWriter", "write", "afterWrite", "seq", "stackTrace", "StackTrace", "add", "reset", "receipt", "appendWithReceipt", "delete", "flush", "readable", "byteLength", "safeClear", "to", "CHECK_MESSAGES", "checkBegin", "checkEnd", "Math", "min", "messagesBefore", "Promise", "all", "rangeFromTo", "idx", "valueEncoding", "decode", "x", "messagesAfter", "i", "before", "arrayToBuffer", "after", "equals", "Error", "Readable", "objectMode", "_reading", "live", "_feed", "_batch", "_cursor", "start", "_open", "ready", "_read", "bitfield", "total", "_batchedRead", "_nonBatchedRead", "getBatch", "item", "FeedFactory", "root", "signer", "hypercore", "options", "_root", "failUndefined", "_signer", "_hypercoreOptions", "storageRoot", "createFeed", "publicKey", "writable", "secretKey", "subtleCrypto", "digest", "Buffer", "toHex", "defaultsDeep", "crypto", "createCrypto", "onwrite", "noiseKeyPair", "storageDir", "createDirectory", "makeStorage", "filename", "type", "native", "getOrCreateFile", "path", "truncate", "FeedStore", "factory", "_feeds", "ComplexMap", "PublicKey", "hash", "_mutexes", "feedOpened", "Event", "_factory", "feeds", "getFeed", "openFeed", "sparse", "mutex", "defaultMap", "Mutex", "executeSynchronized", "set", "emit"]
7
+ }
@@ -29,19 +29,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  var node_exports = {};
30
30
  __export(node_exports, {
31
31
  AbstractFeedIterator: () => AbstractFeedIterator,
32
- FeedFactory: () => import_chunk_HUR3QFCR.FeedFactory,
32
+ FeedFactory: () => import_chunk_CEOKPJ6P.FeedFactory,
33
33
  FeedIterator: () => FeedIterator,
34
34
  FeedQueue: () => FeedQueue,
35
35
  FeedSetIterator: () => FeedSetIterator,
36
- FeedStore: () => import_chunk_HUR3QFCR.FeedStore,
37
- FeedWrapper: () => import_chunk_HUR3QFCR.FeedWrapper,
36
+ FeedStore: () => import_chunk_CEOKPJ6P.FeedStore,
37
+ FeedWrapper: () => import_chunk_CEOKPJ6P.FeedWrapper,
38
38
  createFeedWriter: () => createFeedWriter,
39
39
  defaultFeedSetIteratorOptions: () => defaultFeedSetIteratorOptions,
40
40
  defaultReadStreamOptions: () => defaultReadStreamOptions,
41
41
  writeMessages: () => writeMessages
42
42
  });
43
43
  module.exports = __toCommonJS(node_exports);
44
- var import_chunk_HUR3QFCR = require("./chunk-HUR3QFCR.cjs");
44
+ var import_chunk_CEOKPJ6P = require("./chunk-CEOKPJ6P.cjs");
45
45
  var import_race_as_promised = __toESM(require("race-as-promised"));
46
46
  var import_async = require("@dxos/async");
47
47
  var import_invariant = require("@dxos/invariant");
@@ -1 +1 @@
1
- {"inputs":{"packages/common/feed-store/src/feed-wrapper.ts":{"bytes":33165,"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-factory.ts":{"bytes":9251,"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/feed-wrapper.ts","kind":"import-statement","original":"./feed-wrapper"}],"format":"esm"},"packages/common/feed-store/src/feed-queue.ts":{"bytes":19868,"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-iterator.ts":{"bytes":10231,"imports":[{"path":"race-as-promised","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/feed-queue.ts","kind":"import-statement","original":"./feed-queue"}],"format":"esm"},"packages/common/feed-store/src/feed-set-iterator.ts":{"bytes":19960,"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/feed-iterator.ts","kind":"import-statement","original":"./feed-iterator"},{"path":"packages/common/feed-store/src/feed-queue.ts","kind":"import-statement","original":"./feed-queue"}],"format":"esm"},"packages/common/feed-store/src/feed-store.ts":{"bytes":12315,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-writer.ts":{"bytes":2686,"imports":[],"format":"esm"},"packages/common/feed-store/src/types.ts":{"bytes":614,"imports":[],"format":"esm"},"packages/common/feed-store/src/index.ts":{"bytes":1196,"imports":[{"path":"packages/common/feed-store/src/feed-factory.ts","kind":"import-statement","original":"./feed-factory"},{"path":"packages/common/feed-store/src/feed-iterator.ts","kind":"import-statement","original":"./feed-iterator"},{"path":"packages/common/feed-store/src/feed-set-iterator.ts","kind":"import-statement","original":"./feed-set-iterator"},{"path":"packages/common/feed-store/src/feed-queue.ts","kind":"import-statement","original":"./feed-queue"},{"path":"packages/common/feed-store/src/feed-store.ts","kind":"import-statement","original":"./feed-store"},{"path":"packages/common/feed-store/src/feed-wrapper.ts","kind":"import-statement","original":"./feed-wrapper"},{"path":"packages/common/feed-store/src/feed-writer.ts","kind":"import-statement","original":"./feed-writer"},{"path":"packages/common/feed-store/src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/common/feed-store/src/testing/mocks.ts":{"bytes":3541,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/testing/test-generator.ts":{"bytes":5631,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/testing/test-builder.ts":{"bytes":9730,"imports":[{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/random-access-storage","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/testing/test-generator.ts","kind":"import-statement","original":"./test-generator"},{"path":"packages/common/feed-store/src/feed-factory.ts","kind":"import-statement","original":"../feed-factory"},{"path":"packages/common/feed-store/src/feed-store.ts","kind":"import-statement","original":"../feed-store"}],"format":"esm"},"packages/common/feed-store/src/testing/index.ts":{"bytes":705,"imports":[{"path":"packages/common/feed-store/src/testing/mocks.ts","kind":"import-statement","original":"./mocks"},{"path":"packages/common/feed-store/src/testing/test-builder.ts","kind":"import-statement","original":"./test-builder"},{"path":"packages/common/feed-store/src/testing/test-generator.ts","kind":"import-statement","original":"./test-generator"}],"format":"esm"}},"outputs":{"packages/common/feed-store/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":24008},"packages/common/feed-store/dist/lib/node/index.cjs":{"imports":[{"path":"packages/common/feed-store/dist/lib/node/chunk-HUR3QFCR.cjs","kind":"import-statement"},{"path":"race-as-promised","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["AbstractFeedIterator","FeedFactory","FeedIterator","FeedQueue","FeedSetIterator","FeedStore","FeedWrapper","createFeedWriter","defaultFeedSetIteratorOptions","defaultReadStreamOptions","writeMessages"],"entryPoint":"packages/common/feed-store/src/index.ts","inputs":{"packages/common/feed-store/src/index.ts":{"bytesInOutput":0},"packages/common/feed-store/src/feed-iterator.ts":{"bytesInOutput":2802},"packages/common/feed-store/src/feed-queue.ts":{"bytesInOutput":4925},"packages/common/feed-store/src/feed-set-iterator.ts":{"bytesInOutput":4883},"packages/common/feed-store/src/feed-writer.ts":{"bytesInOutput":273}},"bytes":13483},"packages/common/feed-store/dist/lib/node/testing/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":9597},"packages/common/feed-store/dist/lib/node/testing/index.cjs":{"imports":[{"path":"packages/common/feed-store/dist/lib/node/chunk-HUR3QFCR.cjs","kind":"import-statement"},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/random-access-storage","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true}],"exports":["MockFeedWriter","TestBuilder","TestGenerator","TestItemBuilder","defaultCodec","defaultTestBlockGenerator","defaultTestGenerator","defaultValueEncoding"],"entryPoint":"packages/common/feed-store/src/testing/index.ts","inputs":{"packages/common/feed-store/src/testing/mocks.ts":{"bytesInOutput":784},"packages/common/feed-store/src/testing/index.ts":{"bytesInOutput":0},"packages/common/feed-store/src/testing/test-builder.ts":{"bytesInOutput":1800},"packages/common/feed-store/src/testing/test-generator.ts":{"bytesInOutput":961}},"bytes":4052},"packages/common/feed-store/dist/lib/node/chunk-HUR3QFCR.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":25423},"packages/common/feed-store/dist/lib/node/chunk-HUR3QFCR.cjs":{"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["FeedFactory","FeedStore","FeedWrapper"],"inputs":{"packages/common/feed-store/src/feed-wrapper.ts":{"bytesInOutput":8036},"packages/common/feed-store/src/feed-factory.ts":{"bytesInOutput":2015},"packages/common/feed-store/src/feed-store.ts":{"bytesInOutput":3129}},"bytes":13429}}}
1
+ {"inputs":{"packages/common/feed-store/src/feed-wrapper.ts":{"bytes":34421,"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-factory.ts":{"bytes":9251,"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/feed-wrapper.ts","kind":"import-statement","original":"./feed-wrapper"}],"format":"esm"},"packages/common/feed-store/src/feed-queue.ts":{"bytes":19868,"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-iterator.ts":{"bytes":10231,"imports":[{"path":"race-as-promised","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/feed-queue.ts","kind":"import-statement","original":"./feed-queue"}],"format":"esm"},"packages/common/feed-store/src/feed-set-iterator.ts":{"bytes":19960,"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/feed-iterator.ts","kind":"import-statement","original":"./feed-iterator"},{"path":"packages/common/feed-store/src/feed-queue.ts","kind":"import-statement","original":"./feed-queue"}],"format":"esm"},"packages/common/feed-store/src/feed-store.ts":{"bytes":12315,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/feed-writer.ts":{"bytes":2686,"imports":[],"format":"esm"},"packages/common/feed-store/src/types.ts":{"bytes":614,"imports":[],"format":"esm"},"packages/common/feed-store/src/index.ts":{"bytes":1196,"imports":[{"path":"packages/common/feed-store/src/feed-factory.ts","kind":"import-statement","original":"./feed-factory"},{"path":"packages/common/feed-store/src/feed-iterator.ts","kind":"import-statement","original":"./feed-iterator"},{"path":"packages/common/feed-store/src/feed-set-iterator.ts","kind":"import-statement","original":"./feed-set-iterator"},{"path":"packages/common/feed-store/src/feed-queue.ts","kind":"import-statement","original":"./feed-queue"},{"path":"packages/common/feed-store/src/feed-store.ts","kind":"import-statement","original":"./feed-store"},{"path":"packages/common/feed-store/src/feed-wrapper.ts","kind":"import-statement","original":"./feed-wrapper"},{"path":"packages/common/feed-store/src/feed-writer.ts","kind":"import-statement","original":"./feed-writer"},{"path":"packages/common/feed-store/src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/common/feed-store/src/testing/mocks.ts":{"bytes":3541,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/testing/test-generator.ts":{"bytes":5631,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true}],"format":"esm"},"packages/common/feed-store/src/testing/test-builder.ts":{"bytes":9730,"imports":[{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/random-access-storage","kind":"import-statement","external":true},{"path":"packages/common/feed-store/src/testing/test-generator.ts","kind":"import-statement","original":"./test-generator"},{"path":"packages/common/feed-store/src/feed-factory.ts","kind":"import-statement","original":"../feed-factory"},{"path":"packages/common/feed-store/src/feed-store.ts","kind":"import-statement","original":"../feed-store"}],"format":"esm"},"packages/common/feed-store/src/testing/index.ts":{"bytes":705,"imports":[{"path":"packages/common/feed-store/src/testing/mocks.ts","kind":"import-statement","original":"./mocks"},{"path":"packages/common/feed-store/src/testing/test-builder.ts","kind":"import-statement","original":"./test-builder"},{"path":"packages/common/feed-store/src/testing/test-generator.ts","kind":"import-statement","original":"./test-generator"}],"format":"esm"}},"outputs":{"packages/common/feed-store/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":24008},"packages/common/feed-store/dist/lib/node/index.cjs":{"imports":[{"path":"packages/common/feed-store/dist/lib/node/chunk-CEOKPJ6P.cjs","kind":"import-statement"},{"path":"race-as-promised","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["AbstractFeedIterator","FeedFactory","FeedIterator","FeedQueue","FeedSetIterator","FeedStore","FeedWrapper","createFeedWriter","defaultFeedSetIteratorOptions","defaultReadStreamOptions","writeMessages"],"entryPoint":"packages/common/feed-store/src/index.ts","inputs":{"packages/common/feed-store/src/index.ts":{"bytesInOutput":0},"packages/common/feed-store/src/feed-iterator.ts":{"bytesInOutput":2802},"packages/common/feed-store/src/feed-queue.ts":{"bytesInOutput":4925},"packages/common/feed-store/src/feed-set-iterator.ts":{"bytesInOutput":4883},"packages/common/feed-store/src/feed-writer.ts":{"bytesInOutput":273}},"bytes":13483},"packages/common/feed-store/dist/lib/node/testing/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":9597},"packages/common/feed-store/dist/lib/node/testing/index.cjs":{"imports":[{"path":"packages/common/feed-store/dist/lib/node/chunk-CEOKPJ6P.cjs","kind":"import-statement"},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/random-access-storage","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/random","kind":"import-statement","external":true}],"exports":["MockFeedWriter","TestBuilder","TestGenerator","TestItemBuilder","defaultCodec","defaultTestBlockGenerator","defaultTestGenerator","defaultValueEncoding"],"entryPoint":"packages/common/feed-store/src/testing/index.ts","inputs":{"packages/common/feed-store/src/testing/mocks.ts":{"bytesInOutput":784},"packages/common/feed-store/src/testing/index.ts":{"bytesInOutput":0},"packages/common/feed-store/src/testing/test-builder.ts":{"bytesInOutput":1800},"packages/common/feed-store/src/testing/test-generator.ts":{"bytesInOutput":961}},"bytes":4052},"packages/common/feed-store/dist/lib/node/chunk-CEOKPJ6P.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":26072},"packages/common/feed-store/dist/lib/node/chunk-CEOKPJ6P.cjs":{"imports":[{"path":"node:util","kind":"import-statement","external":true},{"path":"streamx","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/hypercore","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["FeedFactory","FeedStore","FeedWrapper"],"inputs":{"packages/common/feed-store/src/feed-wrapper.ts":{"bytesInOutput":8221},"packages/common/feed-store/src/feed-factory.ts":{"bytesInOutput":2015},"packages/common/feed-store/src/feed-store.ts":{"bytesInOutput":3129}},"bytes":13614}}}
@@ -28,7 +28,7 @@ __export(testing_exports, {
28
28
  defaultValueEncoding: () => defaultValueEncoding
29
29
  });
30
30
  module.exports = __toCommonJS(testing_exports);
31
- var import_chunk_HUR3QFCR = require("../chunk-HUR3QFCR.cjs");
31
+ var import_chunk_CEOKPJ6P = require("../chunk-CEOKPJ6P.cjs");
32
32
  var import_async = require("@dxos/async");
33
33
  var import_context = require("@dxos/context");
34
34
  var import_keys = require("@dxos/keys");
@@ -131,7 +131,7 @@ var TestBuilder = class _TestBuilder {
131
131
  return this;
132
132
  }
133
133
  createFeedFactory() {
134
- return new import_chunk_HUR3QFCR.FeedFactory({
134
+ return new import_chunk_CEOKPJ6P.FeedFactory({
135
135
  root: this.root,
136
136
  signer: this.keyring,
137
137
  hypercore: {
@@ -140,7 +140,7 @@ var TestBuilder = class _TestBuilder {
140
140
  });
141
141
  }
142
142
  createFeedStore() {
143
- return new import_chunk_HUR3QFCR.FeedStore({
143
+ return new import_chunk_CEOKPJ6P.FeedStore({
144
144
  factory: this.createFeedFactory()
145
145
  });
146
146
  }
@@ -1,6 +1,8 @@
1
+ /// <reference types="@dxos/typings/src/hypercore" />
1
2
  /// <reference types="node" />
2
3
  /// <reference types="@dxos/typings/src/streamx" />
3
- /// <reference types="@dxos/typings/src/hypercore" />
4
+ /// <reference types="node" />
5
+ import type { Proof } from 'hypercore';
4
6
  import { inspect } from 'node:util';
5
7
  import { Readable } from 'streamx';
6
8
  import type { Hypercore, HypercoreProperties, ReadStreamOptions } from '@dxos/hypercore';
@@ -48,7 +50,7 @@ export declare class FeedWrapper<T extends {}> {
48
50
  open: Function;
49
51
  private _close;
50
52
  close: () => Promise<void>;
51
- has: any;
53
+ has: (start: number, end?: number) => boolean;
52
54
  get: Function;
53
55
  append: Function;
54
56
  /**
@@ -59,6 +61,9 @@ export declare class FeedWrapper<T extends {}> {
59
61
  setDownloading: any;
60
62
  replicate: Hypercore<T>['replicate'];
61
63
  clear: (start: number, end?: number) => Promise<void>;
64
+ proof: (index: number) => Promise<Proof>;
65
+ put: (index: number, data: T, proof: Proof) => Promise<void>;
66
+ putBuffer: (index: number, data: Buffer, proof: Proof, from: null) => Promise<void>;
62
67
  /**
63
68
  * Clear and check for integrity.
64
69
  */
@@ -1 +1 @@
1
- {"version":3,"file":"feed-wrapper.d.ts","sourceRoot":"","sources":["../../../src/feed-wrapper.ts"],"names":[],"mappings":";;;AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAa,MAAM,SAAS,CAAC;AAI9C,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAG7D,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAEnE;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC,SAAS,EAAE;IAUjC,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,iBAAiB;IAX3B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyB;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IAGzD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;IAE5C,OAAO,CAAC,OAAO,CAAS;gBAGd,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,EACxB,IAAI,EAAE,SAAS,EAAE,0EAA0E;IAC3F,iBAAiB,EAAE,SAAS;IAOtC,CAAC,OAAO,CAAC,MAAM,CAAC;IAIhB,MAAM;;;;;;IASN,IAAI,G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MAAM,KAAK,OAAO,CAAC;IACvF,GAAG,WAA2C;IAC9C,MAAM,WAA8C;IAEpD;;OAEG;IACH,QAAQ,MAA6C;IACrD,UAAU,MAA+C;IACzD,cAAc,MAAmD;IACjE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAA8C;IAClF,KAAK,UAAwD,MAAM,QAAQ,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC;IAEpG,KAAK,UAAwD,MAAM,KAAK,QAAQ,KAAK,CAAC,CAAC;IACvF,GAAG,UAAsD,MAAM,QAAQ,CAAC,SAAS,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC;IACzG,SAAS,UACA,MAAM,QACP,MAAM,SACL,KAAK,QACN,IAAI,KACP,QAAQ,IAAI,CAAC,CAAC;IAEnB;;OAEG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;CAiCzC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/feed-store",
3
- "version": "0.6.5",
3
+ "version": "0.6.6-staging.582ce24",
4
4
  "description": "A consistent store for hypercore feeds.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -40,27 +40,27 @@
40
40
  "lodash.defaultsdeep": "^4.6.1",
41
41
  "race-as-promised": "^0.0.2",
42
42
  "streamx": "^2.12.5",
43
- "@dxos/context": "0.6.5",
44
- "@dxos/async": "0.6.5",
45
- "@dxos/codec-protobuf": "0.6.5",
46
- "@dxos/debug": "0.6.5",
47
- "@dxos/hypercore": "0.6.5",
48
- "@dxos/crypto": "0.6.5",
49
- "@dxos/invariant": "0.6.5",
50
- "@dxos/keyring": "0.6.5",
51
- "@dxos/keys": "0.6.5",
52
- "@dxos/log": "0.6.5",
53
- "@dxos/random-access-storage": "0.6.5",
54
- "@dxos/node-std": "0.6.5",
55
- "@dxos/util": "0.6.5"
43
+ "@dxos/crypto": "0.6.6-staging.582ce24",
44
+ "@dxos/async": "0.6.6-staging.582ce24",
45
+ "@dxos/invariant": "0.6.6-staging.582ce24",
46
+ "@dxos/context": "0.6.6-staging.582ce24",
47
+ "@dxos/codec-protobuf": "0.6.6-staging.582ce24",
48
+ "@dxos/hypercore": "0.6.6-staging.582ce24",
49
+ "@dxos/debug": "0.6.6-staging.582ce24",
50
+ "@dxos/keyring": "0.6.6-staging.582ce24",
51
+ "@dxos/node-std": "0.6.6-staging.582ce24",
52
+ "@dxos/keys": "0.6.6-staging.582ce24",
53
+ "@dxos/log": "0.6.6-staging.582ce24",
54
+ "@dxos/random-access-storage": "0.6.6-staging.582ce24",
55
+ "@dxos/util": "0.6.6-staging.582ce24"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/lodash.defaultsdeep": "^4.6.6",
59
- "@dxos/keys": "0.6.5",
60
- "@dxos/random": "0.6.5"
59
+ "@dxos/keys": "0.6.6-staging.582ce24",
60
+ "@dxos/random": "0.6.6-staging.582ce24"
61
61
  },
62
62
  "optionalDependencies": {
63
- "@dxos/random": "0.6.5"
63
+ "@dxos/random": "0.6.6-staging.582ce24"
64
64
  },
65
65
  "publishConfig": {
66
66
  "access": "public"
@@ -3,6 +3,7 @@
3
3
  //
4
4
 
5
5
  import { expect } from 'chai';
6
+ import { inspect } from 'util';
6
7
  import waitForExpect from 'wait-for-expect';
7
8
 
8
9
  import { asyncTimeout, latch, sleep } from '@dxos/async';
@@ -247,4 +248,43 @@ describe('FeedWrapper', () => {
247
248
  }
248
249
  }
249
250
  });
251
+
252
+ test('proofs', async () => {
253
+ const numBlocks = 10;
254
+ const builder1 = new TestItemBuilder();
255
+ const builder2 = new TestItemBuilder();
256
+ const feedFactory1 = builder1.createFeedFactory();
257
+ const feedFactory2 = builder2.createFeedFactory();
258
+
259
+ const key1 = await builder1.keyring!.createKey();
260
+ const feed1 = await feedFactory1.createFeed(key1, { writable: true });
261
+ const feed2 = await feedFactory2.createFeed(key1);
262
+
263
+ await feed1.open();
264
+ await feed2.open();
265
+
266
+ for (const i of range(numBlocks)) {
267
+ await feed1.append(`block-${i}`);
268
+ }
269
+
270
+ for (const i of range(numBlocks)) {
271
+ const data = await feed1.get(i);
272
+
273
+ console.log({ data });
274
+
275
+ const proof = await feed1.proof(i);
276
+
277
+ // proof.signature[2] = 0xff;
278
+
279
+ console.log('proof', inspect({ proof }, { depth: null, colors: true }));
280
+
281
+ await feed2.core.put(i, data, proof);
282
+
283
+ console.log({ data2: await feed2.get(i) });
284
+ }
285
+
286
+ feed2.core.audit((err, valid) => {
287
+ console.log('audit', { err, valid });
288
+ });
289
+ });
250
290
  });
@@ -2,6 +2,7 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
+ import type { Proof } from 'hypercore';
5
6
  import { inspect } from 'node:util';
6
7
  import { Readable, Transform } from 'streamx';
7
8
 
@@ -180,7 +181,7 @@ export class FeedWrapper<T extends {}> {
180
181
  await this._close();
181
182
  };
182
183
 
183
- has = this._binder.fn(this._hypercore.has);
184
+ has = this._binder.fn(this._hypercore.has) as (start: number, end?: number) => boolean;
184
185
  get = this._binder.async(this._hypercore.get);
185
186
  append = this._binder.async(this._hypercore.append);
186
187
 
@@ -193,6 +194,15 @@ export class FeedWrapper<T extends {}> {
193
194
  replicate: Hypercore<T>['replicate'] = this._binder.fn(this._hypercore.replicate);
194
195
  clear = this._binder.async(this._hypercore.clear) as (start: number, end?: number) => Promise<void>;
195
196
 
197
+ proof = this._binder.async(this._hypercore.proof) as (index: number) => Promise<Proof>;
198
+ put = this._binder.async(this._hypercore.put) as (index: number, data: T, proof: Proof) => Promise<void>;
199
+ putBuffer = this._binder.async((this._hypercore as any)._putBuffer) as (
200
+ index: number,
201
+ data: Buffer,
202
+ proof: Proof,
203
+ from: null,
204
+ ) => Promise<void>;
205
+
196
206
  /**
197
207
  * Clear and check for integrity.
198
208
  */
@@ -1,7 +0,0 @@
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 { Readable, Transform } from 'streamx';\n\nimport { Trigger } from '@dxos/async';\nimport { inspectObject, StackTrace } from '@dxos/debug';\nimport type { Hypercore, HypercoreProperties, ReadStreamOptions } from '@dxos/hypercore';\nimport { 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, createBinder, rangeFromTo } from '@dxos/util';\n\nimport { type FeedWriter, type WriteReceipt } from './feed-writer';\n\n/**\n * Async feed wrapper.\n */\nexport class FeedWrapper<T extends {}> {\n private readonly _pendingWrites = new Set<StackTrace>();\n private readonly _binder = createBinder(this._hypercore);\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 private _hypercore: Hypercore<T>,\n private _key: PublicKey, // TODO(burdon): Required since currently patching the key inside factory.\n private _storageDirectory: Directory,\n ) {\n invariant(this._hypercore);\n invariant(this._key);\n this._writeLock.wake();\n }\n\n [inspect.custom]() {\n return inspectObject(this);\n }\n\n toJSON() {\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, data });\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() {\n await this._storageDirectory.flush();\n }\n\n get opened() {\n return this._hypercore.opened;\n }\n\n get closed() {\n return this._hypercore.closed;\n }\n\n get readable() {\n return this._hypercore.readable;\n }\n\n get length() {\n return this._hypercore.length;\n }\n\n get byteLength() {\n return this._hypercore.byteLength;\n }\n\n on = this._binder.fn(this._hypercore.on);\n off = this._binder.fn(this._hypercore.off);\n\n open = this._binder.async(this._hypercore.open);\n private _close = this._binder.async(this._hypercore.close);\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 = this._binder.fn(this._hypercore.has);\n get = this._binder.async(this._hypercore.get);\n append = this._binder.async(this._hypercore.append);\n\n /**\n * Will not resolve if `end` parameter is not specified and the feed is not closed.\n */\n download = this._binder.fn(this._hypercore.download);\n undownload = this._binder.fn(this._hypercore.undownload);\n setDownloading = this._binder.fn(this._hypercore.setDownloading);\n replicate: Hypercore<T>['replicate'] = this._binder.fn(this._hypercore.replicate);\n clear = this._binder.async(this._hypercore.clear) as (start: number, end?: number) => Promise<void>;\n\n /**\n * Clear and check for integrity.\n */\n async safeClear(from: number, to: number) {\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 },\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 },\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) {\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) {\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() {\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;AAC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CAAA;AAClE,WAAKjB,OAAO0B,IAAIN,KAAKO,KAAKP,IAAAA;AAE1B,YAAMA,KAAKI,KAAI;AACf,WAAKpB,WAAWwB,KAAKR,IAAAA;AACrB1B,MAAAA,KAAI,UAAU;QAAEqB;MAAQ,GAAA;;;;;;AACxB,aAAOK;IACT,CAAA;EACF;;;;EAKA,MAAMS,QAAQ;AACZnC,IAAAA,KAAI,cAAA,QAAA;;;;;;AACJ,SAAKS,UAAU;AACf,UAAM2B,QAAQC,IACZvB,MAAMC,KAAK,KAAKT,OAAOU,OAAM,CAAA,EAAIsB,IAAI,OAAOZ,SAAAA;AAC1C,YAAMA,KAAKS,MAAK;AAChBrC,MAAAA,WAAU4B,KAAKa,QAAM,QAAA;;;;;;;;;IAKvB,CAAA,CAAA;AAGF,SAAKjC,OAAOkC,MAAK;AACjBxC,IAAAA,KAAI,UAAA,QAAA;;;;;;EACN;AACF;",
6
- "names": ["inspect", "Readable", "Transform", "Trigger", "inspectObject", "StackTrace", "invariant", "log", "arrayToBuffer", "createBinder", "rangeFromTo", "FeedWrapper", "constructor", "_hypercore", "_key", "_storageDirectory", "_pendingWrites", "Set", "_binder", "_writeLock", "_closed", "on", "fn", "off", "open", "async", "_close", "close", "size", "warn", "feed", "count", "pendingWrites", "Array", "from", "values", "map", "stack", "getStack", "flushToDisk", "has", "get", "append", "download", "undownload", "setDownloading", "replicate", "clear", "wake", "custom", "toJSON", "feedKey", "length", "properties", "opened", "closed", "key", "core", "createReadableStream", "opts", "self", "transform", "data", "cb", "wait", "then", "push", "readStream", "batch", "undefined", "BatchedReadStream", "createReadStream", "pipe", "err", "createFeedWriter", "write", "afterWrite", "seq", "stackTrace", "add", "reset", "receipt", "appendWithReceipt", "delete", "flush", "readable", "byteLength", "safeClear", "to", "CHECK_MESSAGES", "checkBegin", "checkEnd", "Math", "min", "messagesBefore", "Promise", "all", "idx", "valueEncoding", "decode", "x", "messagesAfter", "i", "before", "after", "equals", "Error", "objectMode", "_reading", "live", "_feed", "_batch", "_cursor", "start", "_open", "ready", "_read", "bitfield", "total", "_batchedRead", "_nonBatchedRead", "getBatch", "item", "defaultsDeep", "subtleCrypto", "failUndefined", "createCrypto", "hypercore", "log", "FeedFactory", "constructor", "root", "signer", "hypercore", "log", "options", "_root", "failUndefined", "_signer", "_hypercoreOptions", "storageRoot", "createFeed", "publicKey", "writable", "Error", "secretKey", "warn", "key", "subtleCrypto", "digest", "Buffer", "from", "toHex", "opts", "defaultsDeep", "undefined", "crypto", "createCrypto", "onwrite", "noiseKeyPair", "storageDir", "createDirectory", "makeStorage", "filename", "type", "native", "getOrCreateFile", "path", "truncate", "core", "FeedWrapper", "Event", "Mutex", "failUndefined", "invariant", "PublicKey", "log", "ComplexMap", "defaultMap", "FeedStore", "constructor", "factory", "_feeds", "hash", "_mutexes", "_closed", "feedOpened", "_factory", "size", "feeds", "Array", "from", "values", "getFeed", "publicKey", "get", "openFeed", "feedKey", "writable", "sparse", "mutex", "executeSynchronized", "feed", "properties", "Error", "truncate", "open", "createFeed", "set", "key", "emit", "close", "Promise", "all", "map", "closed", "clear"]
7
- }
@@ -1,7 +0,0 @@
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 { Readable, Transform } from 'streamx';\n\nimport { Trigger } from '@dxos/async';\nimport { inspectObject, StackTrace } from '@dxos/debug';\nimport type { Hypercore, HypercoreProperties, ReadStreamOptions } from '@dxos/hypercore';\nimport { 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, createBinder, rangeFromTo } from '@dxos/util';\n\nimport { type FeedWriter, type WriteReceipt } from './feed-writer';\n\n/**\n * Async feed wrapper.\n */\nexport class FeedWrapper<T extends {}> {\n private readonly _pendingWrites = new Set<StackTrace>();\n private readonly _binder = createBinder(this._hypercore);\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 private _hypercore: Hypercore<T>,\n private _key: PublicKey, // TODO(burdon): Required since currently patching the key inside factory.\n private _storageDirectory: Directory,\n ) {\n invariant(this._hypercore);\n invariant(this._key);\n this._writeLock.wake();\n }\n\n [inspect.custom]() {\n return inspectObject(this);\n }\n\n toJSON() {\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, data });\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() {\n await this._storageDirectory.flush();\n }\n\n get opened() {\n return this._hypercore.opened;\n }\n\n get closed() {\n return this._hypercore.closed;\n }\n\n get readable() {\n return this._hypercore.readable;\n }\n\n get length() {\n return this._hypercore.length;\n }\n\n get byteLength() {\n return this._hypercore.byteLength;\n }\n\n on = this._binder.fn(this._hypercore.on);\n off = this._binder.fn(this._hypercore.off);\n\n open = this._binder.async(this._hypercore.open);\n private _close = this._binder.async(this._hypercore.close);\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 = this._binder.fn(this._hypercore.has);\n get = this._binder.async(this._hypercore.get);\n append = this._binder.async(this._hypercore.append);\n\n /**\n * Will not resolve if `end` parameter is not specified and the feed is not closed.\n */\n download = this._binder.fn(this._hypercore.download);\n undownload = this._binder.fn(this._hypercore.undownload);\n setDownloading = this._binder.fn(this._hypercore.setDownloading);\n replicate: Hypercore<T>['replicate'] = this._binder.fn(this._hypercore.replicate);\n clear = this._binder.async(this._hypercore.clear) as (start: number, end?: number) => Promise<void>;\n\n /**\n * Clear and check for integrity.\n */\n async safeClear(from: number, to: number) {\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 },\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 },\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) {\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) {\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() {\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,uBAAwB;AACxB,qBAAoC;AAEpC,mBAAwB;AACxB,mBAA0C;AAE1C,uBAA0B;AAE1B,iBAAoB;AAEpB,kBAAyD;ACVzD,oBAAyB;AAEzB,oBAA0C;AAC1C,IAAAA,gBAA8B;AAE9B,uBAAwC;AAExC,IAAAC,cAAoB;ACPpB,IAAAC,gBAA6B;AAC7B,IAAAF,gBAA8B;AAC9B,IAAAG,oBAA0B;AAC1B,kBAA0B;AAC1B,IAAAF,cAAoB;AACpB,IAAAG,eAAuC;;AFYhC,IAAMC,cAAN,MAAMA;EASXC,YACUC,YACAC,MACAC,mBACR;SAHQF,aAAAA;SACAC,OAAAA;SACAC,oBAAAA;SAXOC,iBAAiB,oBAAIC,IAAAA;SACrBC,cAAUC,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M,QAAA;;;;;;;;;IAKvB,CAAA,CAAA;AAGF,SAAK2G,OAAOtH,MAAK;AACjBnB,oBAAAA,KAAI,UAAA,QAAA;;;;;;EACN;AACF;",
6
- "names": ["import_debug", "import_log", "import_async", "import_invariant", "import_util", "FeedWrapper", "constructor", "_hypercore", "_key", "_storageDirectory", "_pendingWrites", "Set", "_binder", "createBinder", "_writeLock", "Trigger", "_closed", "on", "fn", "off", "open", "async", "_close", "close", "size", "log", "warn", "feed", "count", "pendingWrites", "Array", "from", "values", "map", "stack", "getStack", "flushToDisk", "has", "get", "append", "download", "undownload", "setDownloading", "replicate", "clear", "invariant", "wake", "inspect", "custom", "inspectObject", "toJSON", "feedKey", "length", "properties", "opened", "closed", "key", "core", "createReadableStream", "opts", "self", "transform", "Transform", "data", "cb", "wait", "then", "push", "readStream", "batch", "undefined", "BatchedReadStream", "createReadStream", "pipe", "err", "createFeedWriter", "write", "afterWrite", "seq", "stackTrace", "StackTrace", "add", "reset", "receipt", "appendWithReceipt", "delete", "flush", "readable", "byteLength", "safeClear", "to", "CHECK_MESSAGES", "checkBegin", "checkEnd", "Math", "min", "messagesBefore", "Promise", "all", "rangeFromTo", "idx", "valueEncoding", "decode", "x", "messagesAfter", "i", "before", "arrayToBuffer", "after", "equals", "Error", "Readable", "objectMode", "_reading", "live", "_feed", "_batch", "_cursor", "start", "_open", "ready", "_read", "bitfield", "total", "_batchedRead", "_nonBatchedRead", "getBatch", "item", "FeedFactory", "root", "signer", "hypercore", "options", "_root", "failUndefined", "_signer", "_hypercoreOptions", "storageRoot", "createFeed", "publicKey", "writable", "secretKey", "subtleCrypto", "digest", "Buffer", "toHex", "defaultsDeep", "crypto", "createCrypto", "onwrite", "noiseKeyPair", "storageDir", "createDirectory", "makeStorage", "filename", "type", "native", "getOrCreateFile", "path", "truncate", "FeedStore", "factory", "_feeds", "ComplexMap", "PublicKey", "hash", "_mutexes", "feedOpened", "Event", "_factory", "feeds", "getFeed", "openFeed", "sparse", "mutex", "defaultMap", "Mutex", "executeSynchronized", "set", "emit"]
7
- }