@dxos/hypercore 0.8.3 → 0.8.4-main.1068cf700f

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/package.json CHANGED
@@ -1,15 +1,20 @@
1
1
  {
2
2
  "name": "@dxos/hypercore",
3
- "version": "0.8.3",
3
+ "version": "0.8.4-main.1068cf700f",
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": true,
13
+ "sideEffects": false,
10
14
  "type": "module",
11
15
  "exports": {
12
16
  ".": {
17
+ "source": "./src/index.ts",
13
18
  "types": "./dist/types/src/index.d.ts",
14
19
  "browser": "./dist/lib/browser/index.mjs",
15
20
  "node": "./dist/lib/node-esm/index.mjs"
@@ -25,31 +30,26 @@
25
30
  ],
26
31
  "dependencies": {
27
32
  "readable-stream": "^3.6.0",
28
- "sodium-native": "^3.2.0",
29
- "sodium-universal": "^3.0.2",
30
33
  "streamx": "^2.12.5",
31
- "@dxos/async": "0.8.3",
32
- "@dxos/codec-protobuf": "0.8.3",
33
- "@dxos/crypto": "0.8.3",
34
- "@dxos/debug": "0.8.3",
35
- "@dxos/invariant": "0.8.3",
36
- "@dxos/keys": "0.8.3",
37
- "@dxos/node-std": "0.8.3",
38
- "@dxos/random-access-storage": "0.8.3",
39
- "@dxos/typings": "0.8.3",
40
- "@dxos/util": "0.8.3"
34
+ "@dxos/async": "0.8.4-main.1068cf700f",
35
+ "@dxos/codec-protobuf": "0.8.4-main.1068cf700f",
36
+ "@dxos/debug": "0.8.4-main.1068cf700f",
37
+ "@dxos/invariant": "0.8.4-main.1068cf700f",
38
+ "@dxos/random-access-storage": "0.8.4-main.1068cf700f",
39
+ "@dxos/node-std": "0.8.4-main.1068cf700f",
40
+ "@dxos/keys": "0.8.4-main.1068cf700f",
41
+ "@dxos/crypto": "0.8.4-main.1068cf700f",
42
+ "@dxos/typings": "0.8.4-main.1068cf700f",
43
+ "@dxos/util": "0.8.4-main.1068cf700f",
44
+ "@dxos/vendor-hypercore": "0.8.4-main.1068cf700f"
41
45
  },
42
46
  "devDependencies": {
43
- "@types/randombytes": "^2.0.0",
44
47
  "@types/readable-stream": "^2.3.9",
45
- "hypercore": "^9.12.0",
46
48
  "hypercore-protocol": "^8.0.7",
47
- "noise-protocol": "3.0.1",
48
- "random-access-memory": "^4.1.0",
49
- "@dxos/random": "0.8.3",
50
- "@dxos/tracing": "0.8.3",
51
- "@dxos/util": "0.8.3",
52
- "@dxos/log": "0.8.3"
49
+ "@dxos/log": "0.8.4-main.1068cf700f",
50
+ "@dxos/random": "0.8.4-main.1068cf700f",
51
+ "@dxos/util": "0.8.4-main.1068cf700f",
52
+ "@dxos/tracing": "0.8.4-main.1068cf700f"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"
package/src/crypto.ts CHANGED
@@ -2,7 +2,6 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { type AbstractValueEncoding, type Crypto } from 'hypercore';
6
5
  import { callbackify } from 'node:util';
7
6
 
8
7
  import { type Codec, type EncodingOptions } from '@dxos/codec-protobuf';
@@ -10,6 +9,7 @@ import { type Signer, verifySignature } from '@dxos/crypto';
10
9
  import { invariant } from '@dxos/invariant';
11
10
  import { type PublicKey } from '@dxos/keys';
12
11
  import { arrayToBuffer } from '@dxos/util';
12
+ import { type AbstractValueEncoding, type Crypto } from '@dxos/vendor-hypercore/hypercore';
13
13
 
14
14
  /**
15
15
  * Create encoding (e.g., from protobuf codec).
package/src/defaults.ts CHANGED
@@ -2,7 +2,12 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import type { HypercoreOptions, ReadStreamOptions, ReplicationOptions, WriteStreamOptions } from 'hypercore';
5
+ import type {
6
+ HypercoreOptions,
7
+ ReadStreamOptions,
8
+ ReplicationOptions,
9
+ WriteStreamOptions,
10
+ } from '@dxos/vendor-hypercore/hypercore';
6
11
 
7
12
  /**
8
13
  * https://github.com/hypercore-protocol/hypercore/tree/v9.12.0#var-feed--hypercorestorage-key-options
@@ -2,11 +2,10 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import hypercore from 'hypercore';
6
- import type { Hypercore, HypercoreOptions } from 'hypercore';
7
-
8
5
  import { invariant } from '@dxos/invariant';
9
- import { createStorage, type Directory, StorageType } from '@dxos/random-access-storage';
6
+ import { type Directory, StorageType, createStorage } from '@dxos/random-access-storage';
7
+ import hypercore from '@dxos/vendor-hypercore/hypercore';
8
+ import type { Hypercore, HypercoreOptions } from '@dxos/vendor-hypercore/hypercore';
10
9
 
11
10
  import { py } from './util';
12
11
 
@@ -2,8 +2,9 @@
2
2
  // Copyright 2019 DXOS.org
3
3
  //
4
4
 
5
+ import { promisify } from 'node:util';
6
+
5
7
  import { type AbstractValueEncoding } from 'hypercore';
6
- import util from 'node:util';
7
8
  import { describe, expect, test } from 'vitest';
8
9
 
9
10
  import { type Codec } from '@dxos/codec-protobuf';
@@ -32,7 +33,7 @@ describe('Hypercore', () => {
32
33
 
33
34
  {
34
35
  // Check open is idempotent.
35
- const open = util.promisify(core.open.bind(core));
36
+ const open = promisify(core.open.bind(core));
36
37
  await open();
37
38
  await open();
38
39
  }
@@ -40,7 +41,7 @@ describe('Hypercore', () => {
40
41
  {
41
42
  // Append block.
42
43
  expect(core.length).to.eq(0);
43
- const append = util.promisify(core.append.bind(core));
44
+ const append = promisify(core.append.bind(core));
44
45
  const seq = await append('test');
45
46
  expect(core.length).to.eq(1);
46
47
  expect(seq).to.eq(0);
@@ -48,14 +49,14 @@ describe('Hypercore', () => {
48
49
 
49
50
  {
50
51
  // Get block.
51
- const get = util.promisify(core.get.bind(core));
52
+ const get = promisify(core.get.bind(core));
52
53
  const block: any = await get(0);
53
54
  expect(block.toString()).to.eq('test');
54
55
  }
55
56
 
56
57
  {
57
58
  // Check open is idempotent.
58
- const close = util.promisify(core.close.bind(core));
59
+ const close = promisify(core.close.bind(core));
59
60
  await close();
60
61
  await close();
61
62
  }
@@ -67,7 +68,7 @@ describe('Hypercore', () => {
67
68
  const core = factory.createFeed(publicKey, { secretKey, valueEncoding });
68
69
 
69
70
  {
70
- const append = util.promisify(core.append.bind(core));
71
+ const append = promisify(core.append.bind(core));
71
72
 
72
73
  expect(core.length).to.eq(0);
73
74
  const seq = await append({
@@ -80,7 +81,7 @@ describe('Hypercore', () => {
80
81
  }
81
82
 
82
83
  {
83
- const head = util.promisify(core.head.bind(core));
84
+ const head = promisify(core.head.bind(core));
84
85
 
85
86
  const { key, value } = await head();
86
87
  expect(key).to.eq('test-1');
@@ -88,7 +89,7 @@ describe('Hypercore', () => {
88
89
  }
89
90
 
90
91
  {
91
- const get = util.promisify(core.get.bind(core));
92
+ const get = promisify(core.get.bind(core));
92
93
 
93
94
  const { key, value } = await get(0);
94
95
  expect(key).to.eq('test-1');
package/src/index.ts CHANGED
@@ -2,8 +2,13 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- export { default as hypercore } from 'hypercore';
6
- export type { Hypercore, HypercoreOptions, HypercoreProperties, ReadStreamOptions } from 'hypercore';
5
+ export { default as hypercore } from '@dxos/vendor-hypercore/hypercore';
6
+ export type {
7
+ Hypercore,
8
+ HypercoreOptions,
9
+ HypercoreProperties,
10
+ ReadStreamOptions,
11
+ } from '@dxos/vendor-hypercore/hypercore';
7
12
 
8
13
  export * from './crypto';
9
14
  export * from './defaults';
@@ -2,7 +2,8 @@
2
2
  // Copyright 2019 DXOS.org
3
3
  //
4
4
 
5
- import util from 'node:util';
5
+ import { promisify } from 'node:util';
6
+
6
7
  import { describe, test } from 'vitest';
7
8
 
8
9
  import { latch } from '@dxos/async';
@@ -22,7 +23,7 @@ describe('AsyncIterator', () => {
22
23
 
23
24
  // Write.
24
25
  {
25
- const append = util.promisify(core.append.bind(core));
26
+ const append = promisify(core.append.bind(core));
26
27
  for (let i = 0; i < numBlocks; i++) {
27
28
  await append(`test-${i}`);
28
29
  }
@@ -51,7 +52,7 @@ describe('AsyncIterator', () => {
51
52
 
52
53
  log('received', { data: String(value) });
53
54
  inc();
54
- } catch (err) {
55
+ } catch {
55
56
  end();
56
57
  break;
57
58
  }
@@ -4,17 +4,17 @@
4
4
 
5
5
  import { describe, expect, test } from 'vitest';
6
6
 
7
- import { latch, sleep, Trigger } from '@dxos/async';
7
+ import { Trigger, latch, sleep } from '@dxos/async';
8
8
  import { createKeyPair } from '@dxos/crypto';
9
9
  import { log } from '@dxos/log';
10
10
  import { faker } from '@dxos/random';
11
- import { createStorage, StorageType } from '@dxos/random-access-storage';
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';
14
14
 
15
15
  import { HypercoreFactory } from './hypercore-factory';
16
16
  import { createReadable } from './iterator';
17
- import { batch, createDataItem, type TestDataItem } from './testing';
17
+ import { type TestDataItem, batch, createDataItem } from './testing';
18
18
 
19
19
  const noop = () => {};
20
20
 
@@ -2,7 +2,8 @@
2
2
  // Copyright 2019 DXOS.org
3
3
  //
4
4
 
5
- import util from 'node:util';
5
+ import { promisify } from 'node:util';
6
+
6
7
  import { Writable } from 'streamx';
7
8
  import { describe, test } from 'vitest';
8
9
 
@@ -34,7 +35,7 @@ describe('Streams', () => {
34
35
  );
35
36
 
36
37
  {
37
- const append = util.promisify(core.append.bind(core));
38
+ const append = promisify(core.append.bind(core));
38
39
  for (const i of Array.from(Array(numBlocks)).keys()) {
39
40
  await append(`message-${i}`);
40
41
  }
@@ -70,7 +71,7 @@ describe('Streams', () => {
70
71
  }
71
72
  await closed();
72
73
 
73
- const close = util.promisify(core.close.bind(core));
74
+ const close = promisify(core.close.bind(core));
74
75
  await close();
75
76
  });
76
77
  });
package/src/util.ts CHANGED
@@ -2,6 +2,6 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import util from 'node:util';
5
+ import { promisify } from 'node:util';
6
6
 
7
- export const py = (obj: any, fn: Function) => util.promisify(fn.bind(obj));
7
+ export const py = (obj: any, fn: Function) => promisify(fn.bind(obj));