@dxos/hypercore 0.8.4-main.dedc0f3 → 0.8.4-main.e00bdcdb52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +13 -50
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +13 -50
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/crypto.d.ts.map +1 -1
- package/dist/types/src/hypercore-factory.d.ts.map +1 -1
- package/dist/types/src/iterator.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts.map +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -25
- package/src/hypercore-factory.test.ts +3 -3
- package/src/hypercore-protocol.test.ts +2 -2
- package/src/hypercore.test.ts +8 -9
- package/src/iterator.test.ts +3 -4
- package/src/replicate.test.ts +4 -4
- package/src/streams.test.ts +3 -4
- package/src/testing.ts +2 -2
- package/src/util.ts +2 -2
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/hypercore",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.e00bdcdb52",
|
|
4
4
|
"description": "Hypercore wrapper and utils.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
|
-
"sideEffects":
|
|
13
|
+
"sideEffects": false,
|
|
10
14
|
"type": "module",
|
|
11
15
|
"exports": {
|
|
12
16
|
".": {
|
|
@@ -17,40 +21,32 @@
|
|
|
17
21
|
}
|
|
18
22
|
},
|
|
19
23
|
"types": "dist/types/src/index.d.ts",
|
|
20
|
-
"typesVersions": {
|
|
21
|
-
"*": {}
|
|
22
|
-
},
|
|
23
24
|
"files": [
|
|
24
25
|
"dist",
|
|
25
26
|
"src"
|
|
26
27
|
],
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"readable-stream": "^3.6.0",
|
|
29
|
-
"sodium-native": "^3.2.0",
|
|
30
|
-
"sodium-universal": "^3.0.2",
|
|
31
30
|
"streamx": "^2.12.5",
|
|
32
|
-
"@dxos/async": "0.8.4-main.
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/invariant": "0.8.4-main.
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/random-access-storage": "0.8.4-main.
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
31
|
+
"@dxos/async": "0.8.4-main.e00bdcdb52",
|
|
32
|
+
"@dxos/crypto": "0.8.4-main.e00bdcdb52",
|
|
33
|
+
"@dxos/debug": "0.8.4-main.e00bdcdb52",
|
|
34
|
+
"@dxos/invariant": "0.8.4-main.e00bdcdb52",
|
|
35
|
+
"@dxos/node-std": "0.8.4-main.e00bdcdb52",
|
|
36
|
+
"@dxos/random-access-storage": "0.8.4-main.e00bdcdb52",
|
|
37
|
+
"@dxos/typings": "0.8.4-main.e00bdcdb52",
|
|
38
|
+
"@dxos/keys": "0.8.4-main.e00bdcdb52",
|
|
39
|
+
"@dxos/util": "0.8.4-main.e00bdcdb52",
|
|
40
|
+
"@dxos/vendor-hypercore": "0.8.4-main.e00bdcdb52",
|
|
41
|
+
"@dxos/codec-protobuf": "0.8.4-main.e00bdcdb52"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
|
-
"@types/randombytes": "^2.0.0",
|
|
46
44
|
"@types/readable-stream": "^2.3.9",
|
|
47
45
|
"hypercore-protocol": "^8.0.7",
|
|
48
|
-
"
|
|
49
|
-
"random
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/tracing": "0.8.4-main.dedc0f3",
|
|
53
|
-
"@dxos/util": "0.8.4-main.dedc0f3"
|
|
46
|
+
"@dxos/log": "0.8.4-main.e00bdcdb52",
|
|
47
|
+
"@dxos/random": "0.8.4-main.e00bdcdb52",
|
|
48
|
+
"@dxos/tracing": "0.8.4-main.e00bdcdb52",
|
|
49
|
+
"@dxos/util": "0.8.4-main.e00bdcdb52"
|
|
54
50
|
},
|
|
55
51
|
"publishConfig": {
|
|
56
52
|
"access": "public"
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { createKeyPair } from '@dxos/crypto';
|
|
8
|
-
import {
|
|
8
|
+
import { random } from '@dxos/random';
|
|
9
9
|
|
|
10
10
|
import { HypercoreFactory } from './hypercore-factory';
|
|
11
11
|
import { createDataItem } from './testing';
|
|
@@ -30,7 +30,7 @@ describe('HypercoreFactory', () => {
|
|
|
30
30
|
{
|
|
31
31
|
const data = Array.from({ length: numBlocks }).map((_, i) => createDataItem(i));
|
|
32
32
|
for await (const datum of data) {
|
|
33
|
-
const feed =
|
|
33
|
+
const feed = random.helpers.arrayElement(feeds);
|
|
34
34
|
await py(feed, feed.append)(Buffer.from(JSON.stringify(datum)));
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -40,7 +40,7 @@ describe('HypercoreFactory', () => {
|
|
|
40
40
|
const total = feeds.reduce((result, feed) => result + feed.length, 0);
|
|
41
41
|
expect(total).to.eq(numBlocks);
|
|
42
42
|
|
|
43
|
-
const feed =
|
|
43
|
+
const feed = random.helpers.arrayElement(feeds);
|
|
44
44
|
const block1 = await py(feed, feed.head)();
|
|
45
45
|
const block2 = await py(feed, feed.get)(feed.length - 1);
|
|
46
46
|
expect(block1.toString()).to.eq(block2.toString());
|
|
@@ -9,7 +9,7 @@ import { latch } from '@dxos/async';
|
|
|
9
9
|
import { createKeyPair } from '@dxos/crypto';
|
|
10
10
|
import { PublicKey } from '@dxos/keys';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
|
-
import {
|
|
12
|
+
import { random } from '@dxos/random';
|
|
13
13
|
|
|
14
14
|
import { HypercoreFactory } from './hypercore-factory';
|
|
15
15
|
|
|
@@ -212,7 +212,7 @@ describe('ProtocolStream', () => {
|
|
|
212
212
|
});
|
|
213
213
|
|
|
214
214
|
Array.from(Array(numBlocks)).forEach((_, i) => {
|
|
215
|
-
const [core1] =
|
|
215
|
+
const [core1] = random.helpers.arrayElement(feeds);
|
|
216
216
|
core1.append(`block-${i}`, () => {});
|
|
217
217
|
});
|
|
218
218
|
|
package/src/hypercore.test.ts
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
// Copyright 2019 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import util from 'node:util';
|
|
6
|
-
|
|
7
5
|
import { type AbstractValueEncoding } from 'hypercore';
|
|
6
|
+
import { promisify } from 'node:util';
|
|
8
7
|
import { describe, expect, test } from 'vitest';
|
|
9
8
|
|
|
10
9
|
import { type Codec } from '@dxos/codec-protobuf';
|
|
@@ -33,7 +32,7 @@ describe('Hypercore', () => {
|
|
|
33
32
|
|
|
34
33
|
{
|
|
35
34
|
// Check open is idempotent.
|
|
36
|
-
const open =
|
|
35
|
+
const open = promisify(core.open.bind(core));
|
|
37
36
|
await open();
|
|
38
37
|
await open();
|
|
39
38
|
}
|
|
@@ -41,7 +40,7 @@ describe('Hypercore', () => {
|
|
|
41
40
|
{
|
|
42
41
|
// Append block.
|
|
43
42
|
expect(core.length).to.eq(0);
|
|
44
|
-
const append =
|
|
43
|
+
const append = promisify(core.append.bind(core));
|
|
45
44
|
const seq = await append('test');
|
|
46
45
|
expect(core.length).to.eq(1);
|
|
47
46
|
expect(seq).to.eq(0);
|
|
@@ -49,14 +48,14 @@ describe('Hypercore', () => {
|
|
|
49
48
|
|
|
50
49
|
{
|
|
51
50
|
// Get block.
|
|
52
|
-
const get =
|
|
51
|
+
const get = promisify(core.get.bind(core));
|
|
53
52
|
const block: any = await get(0);
|
|
54
53
|
expect(block.toString()).to.eq('test');
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
{
|
|
58
57
|
// Check open is idempotent.
|
|
59
|
-
const close =
|
|
58
|
+
const close = promisify(core.close.bind(core));
|
|
60
59
|
await close();
|
|
61
60
|
await close();
|
|
62
61
|
}
|
|
@@ -68,7 +67,7 @@ describe('Hypercore', () => {
|
|
|
68
67
|
const core = factory.createFeed(publicKey, { secretKey, valueEncoding });
|
|
69
68
|
|
|
70
69
|
{
|
|
71
|
-
const append =
|
|
70
|
+
const append = promisify(core.append.bind(core));
|
|
72
71
|
|
|
73
72
|
expect(core.length).to.eq(0);
|
|
74
73
|
const seq = await append({
|
|
@@ -81,7 +80,7 @@ describe('Hypercore', () => {
|
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
{
|
|
84
|
-
const head =
|
|
83
|
+
const head = promisify(core.head.bind(core));
|
|
85
84
|
|
|
86
85
|
const { key, value } = await head();
|
|
87
86
|
expect(key).to.eq('test-1');
|
|
@@ -89,7 +88,7 @@ describe('Hypercore', () => {
|
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
{
|
|
92
|
-
const get =
|
|
91
|
+
const get = promisify(core.get.bind(core));
|
|
93
92
|
|
|
94
93
|
const { key, value } = await get(0);
|
|
95
94
|
expect(key).to.eq('test-1');
|
package/src/iterator.test.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// Copyright 2019 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import { promisify } from 'node:util';
|
|
7
6
|
import { describe, test } from 'vitest';
|
|
8
7
|
|
|
9
8
|
import { latch } from '@dxos/async';
|
|
@@ -23,7 +22,7 @@ describe('AsyncIterator', () => {
|
|
|
23
22
|
|
|
24
23
|
// Write.
|
|
25
24
|
{
|
|
26
|
-
const append =
|
|
25
|
+
const append = promisify(core.append.bind(core));
|
|
27
26
|
for (let i = 0; i < numBlocks; i++) {
|
|
28
27
|
await append(`test-${i}`);
|
|
29
28
|
}
|
|
@@ -52,7 +51,7 @@ describe('AsyncIterator', () => {
|
|
|
52
51
|
|
|
53
52
|
log('received', { data: String(value) });
|
|
54
53
|
inc();
|
|
55
|
-
} catch
|
|
54
|
+
} catch {
|
|
56
55
|
end();
|
|
57
56
|
break;
|
|
58
57
|
}
|
package/src/replicate.test.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { describe, expect, test } from 'vitest';
|
|
|
7
7
|
import { Trigger, latch, sleep } from '@dxos/async';
|
|
8
8
|
import { createKeyPair } from '@dxos/crypto';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
|
-
import {
|
|
10
|
+
import { random } from '@dxos/random';
|
|
11
11
|
import { StorageType, createStorage } from '@dxos/random-access-storage';
|
|
12
12
|
import { TRACE_PROCESSOR } from '@dxos/tracing';
|
|
13
13
|
import { range, sum } from '@dxos/util';
|
|
@@ -166,7 +166,7 @@ describe('Replication', () => {
|
|
|
166
166
|
|
|
167
167
|
// Write batch of messages with delay.
|
|
168
168
|
batch((next, i, remaining) => {
|
|
169
|
-
const size =
|
|
169
|
+
const size = random.number.int({
|
|
170
170
|
min: 1,
|
|
171
171
|
max: Math.min(10, remaining),
|
|
172
172
|
});
|
|
@@ -179,7 +179,7 @@ describe('Replication', () => {
|
|
|
179
179
|
() => {
|
|
180
180
|
next(size);
|
|
181
181
|
},
|
|
182
|
-
|
|
182
|
+
random.number.int({ min: 0, max: 100 }),
|
|
183
183
|
);
|
|
184
184
|
}, numBlocks);
|
|
185
185
|
|
|
@@ -250,7 +250,7 @@ describe('Replication', () => {
|
|
|
250
250
|
setTimeout(async () => {
|
|
251
251
|
for (const _ of Array.from(Array(numBlocks))) {
|
|
252
252
|
const block = {
|
|
253
|
-
text:
|
|
253
|
+
text: random.lorem.sentence(),
|
|
254
254
|
};
|
|
255
255
|
|
|
256
256
|
core1.append(JSON.stringify(block), noop);
|
package/src/streams.test.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// Copyright 2019 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import { promisify } from 'node:util';
|
|
7
6
|
import { Writable } from 'streamx';
|
|
8
7
|
import { describe, test } from 'vitest';
|
|
9
8
|
|
|
@@ -35,7 +34,7 @@ describe('Streams', () => {
|
|
|
35
34
|
);
|
|
36
35
|
|
|
37
36
|
{
|
|
38
|
-
const append =
|
|
37
|
+
const append = promisify(core.append.bind(core));
|
|
39
38
|
for (const i of Array.from(Array(numBlocks)).keys()) {
|
|
40
39
|
await append(`message-${i}`);
|
|
41
40
|
}
|
|
@@ -71,7 +70,7 @@ describe('Streams', () => {
|
|
|
71
70
|
}
|
|
72
71
|
await closed();
|
|
73
72
|
|
|
74
|
-
const close =
|
|
73
|
+
const close = promisify(core.close.bind(core));
|
|
75
74
|
await close();
|
|
76
75
|
});
|
|
77
76
|
});
|
package/src/testing.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2019 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { random } from '@dxos/random';
|
|
6
6
|
|
|
7
7
|
export const noop = () => {};
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ export type TestDataItem = { id: number; text: string };
|
|
|
11
11
|
|
|
12
12
|
export const createDataItem = (n: number): TestDataItem => ({
|
|
13
13
|
id: n,
|
|
14
|
-
text:
|
|
14
|
+
text: random.lorem.sentence(),
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
type BatchCallback = (next: (num: number) => void, index: number, remaining: number) => void;
|
package/src/util.ts
CHANGED