@dxos/feed-store 0.8.4-main.5ea62a8 → 0.8.4-main.60689f5b1c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +1 -1
  3. package/dist/lib/browser/{chunk-HBSCNY5U.mjs → chunk-MB63GMGR.mjs} +128 -279
  4. package/dist/lib/browser/chunk-MB63GMGR.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +63 -255
  6. package/dist/lib/browser/index.mjs.map +3 -3
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +32 -80
  9. package/dist/lib/browser/testing/index.mjs.map +3 -3
  10. package/dist/lib/node-esm/{chunk-NKF34XAW.mjs → chunk-VZUET36D.mjs} +128 -279
  11. package/dist/lib/node-esm/chunk-VZUET36D.mjs.map +7 -0
  12. package/dist/lib/node-esm/index.mjs +63 -255
  13. package/dist/lib/node-esm/index.mjs.map +3 -3
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/testing/index.mjs +32 -80
  16. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  17. package/dist/types/src/feed-factory.d.ts.map +1 -1
  18. package/dist/types/src/feed-iterator.d.ts.map +1 -1
  19. package/dist/types/src/feed-queue.d.ts +1 -1
  20. package/dist/types/src/feed-queue.d.ts.map +1 -1
  21. package/dist/types/src/feed-set-iterator.d.ts.map +1 -1
  22. package/dist/types/src/feed-store.d.ts.map +1 -1
  23. package/dist/types/src/feed-wrapper.d.ts +18 -19
  24. package/dist/types/src/feed-wrapper.d.ts.map +1 -1
  25. package/dist/types/src/feed-writer.d.ts.map +1 -1
  26. package/dist/types/src/testing/mocks.d.ts.map +1 -1
  27. package/dist/types/src/testing/test-builder.d.ts +1 -1
  28. package/dist/types/src/testing/test-builder.d.ts.map +1 -1
  29. package/dist/types/src/testing/test-generator.d.ts +2 -2
  30. package/dist/types/src/testing/test-generator.d.ts.map +1 -1
  31. package/dist/types/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +25 -27
  33. package/src/feed-queue.ts +1 -2
  34. package/src/feed-set-iterator.test.ts +6 -6
  35. package/src/feed-store.node.test.ts +4 -4
  36. package/src/feed-wrapper.test.ts +44 -12
  37. package/src/feed-wrapper.ts +73 -35
  38. package/src/testing/test-builder.ts +1 -3
  39. package/src/testing/test-generator.ts +5 -6
  40. package/dist/lib/browser/chunk-HBSCNY5U.mjs.map +0 -7
  41. package/dist/lib/node-esm/chunk-NKF34XAW.mjs.map +0 -7
package/LICENSE CHANGED
@@ -1,8 +1,105 @@
1
- MIT License
2
- Copyright (c) 2022 DXOS
1
+ # Functional Source License, Version 1.1, ALv2 Future License
3
2
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ ## Abbreviation
5
4
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ FSL-1.1-Apache-2.0
7
6
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ ## Notice
8
+
9
+ Copyright 2026 DXOS
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
package/README.md CHANGED
@@ -18,4 +18,4 @@ pnpm i @dxos/feed-store
18
18
 
19
19
  Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
20
20
 
21
- License: [MIT](./LICENSE) Copyright 2022 © DXOS
21
+ License: [FSL-1.1-Apache-2.0](./LICENSE) Copyright 2022 © DXOS
@@ -2,29 +2,31 @@ import "@dxos/node-std/globals";
2
2
 
3
3
  // src/feed-wrapper.ts
4
4
  import { inspect } from "@dxos/node-std/util";
5
+ import { promisify } from "@dxos/node-std/util";
5
6
  import { Readable, Transform } from "streamx";
6
7
  import { Trigger } from "@dxos/async";
7
8
  import { StackTrace, inspectObject } from "@dxos/debug";
8
- import { invariant } from "@dxos/invariant";
9
+ import { assertArgument, invariant } from "@dxos/invariant";
9
10
  import { log } from "@dxos/log";
10
- import { arrayToBuffer, createBinder, rangeFromTo } from "@dxos/util";
11
- function _define_property(obj, key, value) {
12
- if (key in obj) {
13
- Object.defineProperty(obj, key, {
14
- value,
15
- enumerable: true,
16
- configurable: true,
17
- writable: true
18
- });
19
- } else {
20
- obj[key] = value;
21
- }
22
- return obj;
23
- }
11
+ import { arrayToBuffer, rangeFromTo } from "@dxos/util";
24
12
  var __dxlog_file = "/__w/dxos/dxos/packages/common/feed-store/src/feed-wrapper.ts";
25
- var _inspect_custom = inspect.custom;
26
13
  var FeedWrapper = class {
27
- [_inspect_custom]() {
14
+ _key;
15
+ _storageDirectory;
16
+ _hypercore;
17
+ _pendingWrites = /* @__PURE__ */ new Set();
18
+ // Pending while writes are happening. Resolves when there are no pending writes.
19
+ _writeLock = new Trigger();
20
+ _closed = false;
21
+ constructor(hypercore2, _key, _storageDirectory) {
22
+ this._key = _key;
23
+ this._storageDirectory = _storageDirectory;
24
+ assertArgument(hypercore2, "hypercore");
25
+ this._hypercore = hypercore2;
26
+ invariant(this._key, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 27, S: this, A: ["this._key", ""] });
27
+ this._writeLock.wake();
28
+ }
29
+ [inspect.custom]() {
28
30
  return inspectObject(this);
29
31
  }
30
32
  toJSON() {
@@ -66,21 +68,8 @@ var FeedWrapper = class {
66
68
  log("write", {
67
69
  feed: this._key,
68
70
  seq: this._hypercore.length
69
- }, {
70
- F: __dxlog_file,
71
- L: 98,
72
- S: this,
73
- C: (f, a) => f(...a)
74
- });
75
- invariant(!this._closed, "Feed closed", {
76
- F: __dxlog_file,
77
- L: 99,
78
- S: this,
79
- A: [
80
- "!this._closed",
81
- "'Feed closed'"
82
- ]
83
- });
71
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 74, S: this });
72
+ invariant(!this._closed, "Feed closed", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 78, S: this, A: ["!this._closed", "'Feed closed'"] });
84
73
  const stackTrace = new StackTrace();
85
74
  try {
86
75
  this._pendingWrites.add(stackTrace);
@@ -102,24 +91,11 @@ var FeedWrapper = class {
102
91
  }
103
92
  async appendWithReceipt(data) {
104
93
  const seq = await this.append(data);
105
- invariant(seq < this.length, "Invalid seq after write", {
106
- F: __dxlog_file,
107
- L: 130,
108
- S: this,
109
- A: [
110
- "seq < this.length",
111
- "'Invalid seq after write'"
112
- ]
113
- });
94
+ invariant(seq < this.length, "Invalid seq after write", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 103, S: this, A: ["seq < this.length", "'Invalid seq after write'"] });
114
95
  log("write complete", {
115
96
  feed: this._key,
116
97
  seq
117
- }, {
118
- F: __dxlog_file,
119
- L: 131,
120
- S: this,
121
- C: (f, a) => f(...a)
122
- });
98
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 104, S: this });
123
99
  const receipt = {
124
100
  feedKey: this.key,
125
101
  seq
@@ -148,19 +124,72 @@ var FeedWrapper = class {
148
124
  get byteLength() {
149
125
  return this._hypercore.byteLength;
150
126
  }
127
+ on(...args) {
128
+ return this._hypercore.on(...args);
129
+ }
130
+ off(...args) {
131
+ return this._hypercore.off(...args);
132
+ }
133
+ open(...args) {
134
+ return promisify(this._hypercore.open.bind(this._hypercore))(...args);
135
+ }
136
+ _close(...args) {
137
+ return promisify(this._hypercore.close.bind(this._hypercore))(...args);
138
+ }
139
+ close = async () => {
140
+ if (this._pendingWrites.size) {
141
+ log.warn("Closing feed with pending writes", {
142
+ feed: this._key,
143
+ count: this._pendingWrites.size,
144
+ pendingWrites: Array.from(this._pendingWrites.values()).map((stack) => stack.getStack())
145
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 149, S: this });
146
+ }
147
+ this._closed = true;
148
+ await this.flushToDisk();
149
+ await this._close();
150
+ };
151
+ has(start, end) {
152
+ return this._hypercore.has(start, end);
153
+ }
154
+ get(index, options) {
155
+ return promisify(this._hypercore.get.bind(this._hypercore))(index, options);
156
+ }
157
+ // TODO(dmaretskyi): Type better
158
+ append(data) {
159
+ return promisify(this._hypercore.append.bind(this._hypercore))(data);
160
+ }
161
+ /**
162
+ * Will not resolve if `end` parameter is not specified and the feed is not closed.
163
+ */
164
+ download(...args) {
165
+ return this._hypercore.download(...args);
166
+ }
167
+ undownload(...args) {
168
+ return this._hypercore.undownload(...args);
169
+ }
170
+ setDownloading(...args) {
171
+ return this._hypercore.setDownloading(...args);
172
+ }
173
+ replicate(...args) {
174
+ return this._hypercore.replicate(...args);
175
+ }
176
+ clear(start, end) {
177
+ return promisify(this._hypercore.clear.bind(this._hypercore))(start, end);
178
+ }
179
+ proof(index, options) {
180
+ return promisify(this._hypercore.proof.bind(this._hypercore))(index);
181
+ }
182
+ put(index, data, proof) {
183
+ return promisify(this._hypercore.put.bind(this._hypercore))(index, data, proof);
184
+ }
185
+ putBuffer(index, data, proof, peer) {
186
+ return promisify(this._hypercore._putBuffer.bind(this._hypercore))(index, data, proof, peer);
187
+ }
151
188
  /**
152
189
  * Clear and check for integrity.
153
190
  */
154
191
  async safeClear(from, to) {
155
- invariant(from >= 0 && from < to && to <= this.length, "Invalid range", {
156
- F: __dxlog_file,
157
- L: 211,
158
- S: this,
159
- A: [
160
- "from >= 0 && from < to && to <= this.length",
161
- "'Invalid range'"
162
- ]
163
- });
192
+ invariant(from >= 0 && from < to && to <= this.length, "Invalid range", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 198, S: this, A: ["from >= 0 && from < to && to <= this.length", "'Invalid range'"] });
164
193
  const CHECK_MESSAGES = 20;
165
194
  const checkBegin = to;
166
195
  const checkEnd = Math.min(checkBegin + CHECK_MESSAGES, this.length);
@@ -183,91 +212,22 @@ var FeedWrapper = class {
183
212
  }
184
213
  }
185
214
  }
186
- constructor(_hypercore, _key, _storageDirectory) {
187
- _define_property(this, "_hypercore", void 0);
188
- _define_property(this, "_key", void 0);
189
- _define_property(this, "_storageDirectory", void 0);
190
- _define_property(this, "_pendingWrites", void 0);
191
- _define_property(this, "_binder", void 0);
192
- _define_property(this, "_writeLock", void 0);
193
- _define_property(this, "_closed", void 0);
194
- _define_property(this, "on", void 0);
195
- _define_property(this, "off", void 0);
196
- _define_property(this, "open", void 0);
197
- _define_property(this, "_close", void 0);
198
- _define_property(this, "close", void 0);
199
- _define_property(this, "has", void 0);
200
- _define_property(this, "get", void 0);
201
- _define_property(this, "append", void 0);
202
- _define_property(this, "download", void 0);
203
- _define_property(this, "undownload", void 0);
204
- _define_property(this, "setDownloading", void 0);
205
- _define_property(this, "replicate", void 0);
206
- _define_property(this, "clear", void 0);
207
- _define_property(this, "proof", void 0);
208
- _define_property(this, "put", void 0);
209
- _define_property(this, "putBuffer", void 0);
210
- this._hypercore = _hypercore;
211
- this._key = _key;
212
- this._storageDirectory = _storageDirectory;
213
- this._pendingWrites = /* @__PURE__ */ new Set();
214
- this._binder = createBinder(this._hypercore);
215
- this._writeLock = new Trigger();
216
- this._closed = false;
217
- this.on = this._binder.fn(this._hypercore.on);
218
- this.off = this._binder.fn(this._hypercore.off);
219
- this.open = this._binder.async(this._hypercore.open);
220
- this._close = this._binder.async(this._hypercore.close);
221
- this.close = async () => {
222
- if (this._pendingWrites.size) {
223
- log.warn("Closing feed with pending writes", {
224
- feed: this._key,
225
- count: this._pendingWrites.size,
226
- pendingWrites: Array.from(this._pendingWrites.values()).map((stack) => stack.getStack())
227
- }, {
228
- F: __dxlog_file,
229
- L: 174,
230
- S: this,
231
- C: (f, a) => f(...a)
232
- });
233
- }
234
- this._closed = true;
235
- await this.flushToDisk();
236
- await this._close();
237
- };
238
- this.has = this._binder.fn(this._hypercore.has);
239
- this.get = this._binder.async(this._hypercore.get);
240
- this.append = this._binder.async(this._hypercore.append);
241
- this.download = this._binder.fn(this._hypercore.download);
242
- this.undownload = this._binder.fn(this._hypercore.undownload);
243
- this.setDownloading = this._binder.fn(this._hypercore.setDownloading);
244
- this.replicate = this._binder.fn(this._hypercore.replicate);
245
- this.clear = this._binder.async(this._hypercore.clear);
246
- this.proof = this._binder.async(this._hypercore.proof);
247
- this.put = this._binder.async(this._hypercore.put);
248
- this.putBuffer = this._binder.async(this._hypercore._putBuffer);
249
- invariant(this._hypercore, void 0, {
250
- F: __dxlog_file,
251
- L: 38,
252
- S: this,
253
- A: [
254
- "this._hypercore",
255
- ""
256
- ]
257
- });
258
- invariant(this._key, void 0, {
259
- F: __dxlog_file,
260
- L: 39,
261
- S: this,
262
- A: [
263
- "this._key",
264
- ""
265
- ]
266
- });
267
- this._writeLock.wake();
268
- }
269
215
  };
270
216
  var BatchedReadStream = class extends Readable {
217
+ _feed;
218
+ _batch;
219
+ _cursor;
220
+ _reading = false;
221
+ constructor(feed, opts = {}) {
222
+ super({
223
+ objectMode: true
224
+ });
225
+ invariant(opts.live === true, "Only live mode supported", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 231, S: this, A: ["opts.live === true", "'Only live mode supported'"] });
226
+ invariant(opts.batch !== void 0 && opts.batch > 1, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 232, S: this, A: ["opts.batch !== undefined && opts.batch > 1", ""] });
227
+ this._feed = feed;
228
+ this._batch = opts.batch;
229
+ this._cursor = opts.start ?? 0;
230
+ }
271
231
  _open(cb) {
272
232
  this._feed.ready(cb);
273
233
  }
@@ -311,32 +271,6 @@ var BatchedReadStream = class extends Readable {
311
271
  }
312
272
  });
313
273
  }
314
- constructor(feed, opts = {}) {
315
- super({
316
- objectMode: true
317
- }), _define_property(this, "_feed", void 0), _define_property(this, "_batch", void 0), _define_property(this, "_cursor", void 0), _define_property(this, "_reading", false);
318
- invariant(opts.live === true, "Only live mode supported", {
319
- F: __dxlog_file,
320
- L: 253,
321
- S: this,
322
- A: [
323
- "opts.live === true",
324
- "'Only live mode supported'"
325
- ]
326
- });
327
- invariant(opts.batch !== void 0 && opts.batch > 1, void 0, {
328
- F: __dxlog_file,
329
- L: 254,
330
- S: this,
331
- A: [
332
- "opts.batch !== undefined && opts.batch > 1",
333
- ""
334
- ]
335
- });
336
- this._feed = feed;
337
- this._batch = opts.batch;
338
- this._cursor = opts.start ?? 0;
339
- }
340
274
  };
341
275
 
342
276
  // src/feed-factory.ts
@@ -345,21 +279,19 @@ import { subtleCrypto } from "@dxos/crypto";
345
279
  import { failUndefined } from "@dxos/debug";
346
280
  import { createCrypto, hypercore } from "@dxos/hypercore";
347
281
  import { log as log2 } from "@dxos/log";
348
- function _define_property2(obj, key, value) {
349
- if (key in obj) {
350
- Object.defineProperty(obj, key, {
351
- value,
352
- enumerable: true,
353
- configurable: true,
354
- writable: true
355
- });
356
- } else {
357
- obj[key] = value;
358
- }
359
- return obj;
360
- }
361
282
  var __dxlog_file2 = "/__w/dxos/dxos/packages/common/feed-store/src/feed-factory.ts";
362
283
  var FeedFactory = class {
284
+ _root;
285
+ _signer;
286
+ _hypercoreOptions;
287
+ constructor({ root, signer, hypercore: hypercore2 }) {
288
+ log2("FeedFactory", {
289
+ options: hypercore2
290
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 17, S: this });
291
+ this._root = root ?? failUndefined();
292
+ this._signer = signer;
293
+ this._hypercoreOptions = hypercore2;
294
+ }
363
295
  get storageRoot() {
364
296
  return this._root;
365
297
  }
@@ -368,12 +300,7 @@ var FeedFactory = class {
368
300
  throw new Error("Signer required to create writable feeds.");
369
301
  }
370
302
  if (options?.secretKey) {
371
- log2.warn("Secret key ignored due to signer.", void 0, {
372
- F: __dxlog_file2,
373
- L: 58,
374
- S: this,
375
- C: (f, a) => f(...a)
376
- });
303
+ log2.warn("Secret key ignored due to signer.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 32, S: this });
377
304
  }
378
305
  const key = await subtleCrypto.digest("SHA-256", Buffer.from(publicKey.toHex()));
379
306
  const opts = defaultsDeep({}, this._hypercoreOptions, {
@@ -387,33 +314,12 @@ var FeedFactory = class {
387
314
  const { type, native } = storageDir.getOrCreateFile(filename);
388
315
  log2("created", {
389
316
  path: `${type}:${this._root.path}/${publicKey.truncate()}/${filename}`
390
- }, {
391
- F: __dxlog_file2,
392
- L: 82,
393
- S: this,
394
- C: (f, a) => f(...a)
395
- });
317
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 46, S: this });
396
318
  return native;
397
319
  };
398
320
  const core = hypercore(makeStorage, Buffer.from(key), opts);
399
321
  return new FeedWrapper(core, publicKey, storageDir);
400
322
  }
401
- constructor({ root, signer, hypercore: hypercore2 }) {
402
- _define_property2(this, "_root", void 0);
403
- _define_property2(this, "_signer", void 0);
404
- _define_property2(this, "_hypercoreOptions", void 0);
405
- log2("FeedFactory", {
406
- options: hypercore2
407
- }, {
408
- F: __dxlog_file2,
409
- L: 43,
410
- S: this,
411
- C: (f, a) => f(...a)
412
- });
413
- this._root = root ?? failUndefined();
414
- this._signer = signer;
415
- this._hypercoreOptions = hypercore2;
416
- }
417
323
  };
418
324
 
419
325
  // src/feed-store.ts
@@ -423,21 +329,16 @@ import { invariant as invariant2 } from "@dxos/invariant";
423
329
  import { PublicKey } from "@dxos/keys";
424
330
  import { log as log3 } from "@dxos/log";
425
331
  import { ComplexMap, defaultMap } from "@dxos/util";
426
- function _define_property3(obj, key, value) {
427
- if (key in obj) {
428
- Object.defineProperty(obj, key, {
429
- value,
430
- enumerable: true,
431
- configurable: true,
432
- writable: true
433
- });
434
- } else {
435
- obj[key] = value;
436
- }
437
- return obj;
438
- }
439
332
  var __dxlog_file3 = "/__w/dxos/dxos/packages/common/feed-store/src/feed-store.ts";
440
333
  var FeedStore = class {
334
+ _feeds = new ComplexMap(PublicKey.hash);
335
+ _mutexes = new ComplexMap(PublicKey.hash);
336
+ _factory;
337
+ _closed = false;
338
+ feedOpened = new Event();
339
+ constructor({ factory }) {
340
+ this._factory = factory ?? failUndefined2();
341
+ }
441
342
  get size() {
442
343
  return this._feeds.size;
443
344
  }
@@ -457,30 +358,9 @@ var FeedStore = class {
457
358
  async openFeed(feedKey, { writable, sparse } = {}) {
458
359
  log3("opening feed", {
459
360
  feedKey
460
- }, {
461
- F: __dxlog_file3,
462
- L: 55,
463
- S: this,
464
- C: (f, a) => f(...a)
465
- });
466
- invariant2(feedKey, void 0, {
467
- F: __dxlog_file3,
468
- L: 56,
469
- S: this,
470
- A: [
471
- "feedKey",
472
- ""
473
- ]
474
- });
475
- invariant2(!this._closed, "Feed store is closed", {
476
- F: __dxlog_file3,
477
- L: 57,
478
- S: this,
479
- A: [
480
- "!this._closed",
481
- "'Feed store is closed'"
482
- ]
483
- });
361
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 36, S: this });
362
+ invariant2(feedKey, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 39, S: this, A: ["feedKey", ""] });
363
+ invariant2(!this._closed, "Feed store is closed", { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 40, S: this, A: ["!this._closed", "'Feed store is closed'"] });
484
364
  const mutex = defaultMap(this._mutexes, feedKey, () => new Mutex());
485
365
  return mutex.executeSynchronized(async () => {
486
366
  let feed = this.getFeed(feedKey);
@@ -503,12 +383,7 @@ var FeedStore = class {
503
383
  this.feedOpened.emit(feed);
504
384
  log3("opened", {
505
385
  feedKey
506
- }, {
507
- F: __dxlog_file3,
508
- L: 85,
509
- S: this,
510
- C: (f, a) => f(...a)
511
- });
386
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 63, S: this });
512
387
  return feed;
513
388
  });
514
389
  }
@@ -516,40 +391,14 @@ var FeedStore = class {
516
391
  * Close all feeds.
517
392
  */
518
393
  async close() {
519
- log3("closing...", void 0, {
520
- F: __dxlog_file3,
521
- L: 94,
522
- S: this,
523
- C: (f, a) => f(...a)
524
- });
394
+ log3("closing...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 72, S: this });
525
395
  this._closed = true;
526
396
  await Promise.all(Array.from(this._feeds.values()).map(async (feed) => {
527
397
  await feed.close();
528
- invariant2(feed.closed, void 0, {
529
- F: __dxlog_file3,
530
- L: 99,
531
- S: this,
532
- A: [
533
- "feed.closed",
534
- ""
535
- ]
536
- });
398
+ invariant2(feed.closed, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 76, S: this, A: ["feed.closed", ""] });
537
399
  }));
538
400
  this._feeds.clear();
539
- log3("closed", void 0, {
540
- F: __dxlog_file3,
541
- L: 108,
542
- S: this,
543
- C: (f, a) => f(...a)
544
- });
545
- }
546
- constructor({ factory }) {
547
- _define_property3(this, "_feeds", new ComplexMap(PublicKey.hash));
548
- _define_property3(this, "_mutexes", new ComplexMap(PublicKey.hash));
549
- _define_property3(this, "_factory", void 0);
550
- _define_property3(this, "_closed", false);
551
- _define_property3(this, "feedOpened", new Event());
552
- this._factory = factory ?? failUndefined2();
401
+ log3("closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 83, S: this });
553
402
  }
554
403
  };
555
404
 
@@ -558,4 +407,4 @@ export {
558
407
  FeedFactory,
559
408
  FeedStore
560
409
  };
561
- //# sourceMappingURL=chunk-HBSCNY5U.mjs.map
410
+ //# sourceMappingURL=chunk-MB63GMGR.mjs.map