@peerbit/log 3.0.32 → 3.0.34-0691c73

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 (120) hide show
  1. package/dist/benchmark/index.d.ts +2 -0
  2. package/dist/benchmark/index.d.ts.map +1 -0
  3. package/{lib/esm/__benchmark__ → dist/benchmark}/index.js +7 -9
  4. package/dist/benchmark/index.js.map +1 -0
  5. package/{lib/esm → dist/src}/change.d.ts +2 -1
  6. package/dist/src/change.d.ts.map +1 -0
  7. package/dist/src/change.js +2 -0
  8. package/dist/src/change.js.map +1 -0
  9. package/{lib/esm → dist/src}/clock.d.ts +3 -2
  10. package/dist/src/clock.d.ts.map +1 -0
  11. package/{lib/esm → dist/src}/clock.js +3 -5
  12. package/dist/src/clock.js.map +1 -0
  13. package/{lib/esm → dist/src}/difference.d.ts +1 -0
  14. package/dist/src/difference.d.ts.map +1 -0
  15. package/{lib/esm → dist/src}/encoding.d.ts +2 -1
  16. package/dist/src/encoding.d.ts.map +1 -0
  17. package/{lib/esm → dist/src}/encoding.js.map +1 -1
  18. package/{lib/esm → dist/src}/entry-index.d.ts +3 -2
  19. package/dist/src/entry-index.d.ts.map +1 -0
  20. package/{lib/esm → dist/src}/entry-index.js +2 -0
  21. package/dist/src/entry-index.js.map +1 -0
  22. package/{lib/esm → dist/src}/entry-with-refs.d.ts +1 -0
  23. package/dist/src/entry-with-refs.d.ts.map +1 -0
  24. package/dist/src/entry-with-refs.js +2 -0
  25. package/dist/src/entry-with-refs.js.map +1 -0
  26. package/{lib/esm → dist/src}/entry.d.ts +7 -6
  27. package/dist/src/entry.d.ts.map +1 -0
  28. package/{lib/esm → dist/src}/entry.js +11 -10
  29. package/dist/src/entry.js.map +1 -0
  30. package/{lib/esm → dist/src}/find-uniques.d.ts +1 -0
  31. package/dist/src/find-uniques.d.ts.map +1 -0
  32. package/{lib/esm → dist/src}/heads-cache.d.ts +4 -3
  33. package/dist/src/heads-cache.d.ts.map +1 -0
  34. package/{lib/esm → dist/src}/heads-cache.js +4 -4
  35. package/dist/src/heads-cache.js.map +1 -0
  36. package/{lib/esm → dist/src}/heads.d.ts +5 -4
  37. package/dist/src/heads.d.ts.map +1 -0
  38. package/{lib/esm → dist/src}/heads.js +7 -0
  39. package/dist/src/heads.js.map +1 -0
  40. package/{lib/esm → dist/src}/index.d.ts +1 -0
  41. package/dist/src/index.d.ts.map +1 -0
  42. package/{lib/esm → dist/src}/log-errors.d.ts +1 -0
  43. package/dist/src/log-errors.d.ts.map +1 -0
  44. package/{lib/esm → dist/src}/log-sorting.d.ts +2 -1
  45. package/dist/src/log-sorting.d.ts.map +1 -0
  46. package/{lib/esm → dist/src}/log-sorting.js +2 -1
  47. package/dist/src/log-sorting.js.map +1 -0
  48. package/{lib/esm → dist/src}/log.d.ts +18 -13
  49. package/dist/src/log.d.ts.map +1 -0
  50. package/{lib/esm → dist/src}/log.js +18 -9
  51. package/dist/src/log.js.map +1 -0
  52. package/{lib/esm → dist/src}/logger.d.ts +1 -0
  53. package/dist/src/logger.d.ts.map +1 -0
  54. package/{lib/esm → dist/src}/snapshot.d.ts +5 -4
  55. package/dist/src/snapshot.d.ts.map +1 -0
  56. package/{lib/esm → dist/src}/snapshot.js +6 -6
  57. package/dist/src/snapshot.js.map +1 -0
  58. package/{lib/esm → dist/src}/trim.d.ts +5 -4
  59. package/dist/src/trim.d.ts.map +1 -0
  60. package/{lib/esm → dist/src}/trim.js +9 -1
  61. package/dist/src/trim.js.map +1 -0
  62. package/{lib/esm → dist/src}/types.d.ts +2 -1
  63. package/dist/src/types.d.ts.map +1 -0
  64. package/{lib/esm → dist/src}/types.js +1 -3
  65. package/dist/src/types.js.map +1 -0
  66. package/dist/src/utils.d.ts +4 -0
  67. package/dist/src/utils.d.ts.map +1 -0
  68. package/dist/src/utils.js +12 -0
  69. package/dist/src/utils.js.map +1 -0
  70. package/{lib/esm → dist/src}/values.d.ts +4 -3
  71. package/dist/src/values.d.ts.map +1 -0
  72. package/{lib/esm → dist/src}/values.js +3 -0
  73. package/dist/src/values.js.map +1 -0
  74. package/package.json +102 -78
  75. package/src/change.ts +1 -1
  76. package/src/clock.ts +10 -16
  77. package/src/encoding.ts +2 -2
  78. package/src/entry-index.ts +2 -2
  79. package/src/entry.ts +24 -27
  80. package/src/heads-cache.ts +9 -11
  81. package/src/heads.ts +5 -5
  82. package/src/log-sorting.ts +2 -2
  83. package/src/log.ts +55 -45
  84. package/src/snapshot.ts +7 -9
  85. package/src/trim.ts +11 -5
  86. package/src/types.ts +2 -4
  87. package/src/utils.ts +13 -1
  88. package/src/values.ts +12 -12
  89. package/lib/esm/__benchmark__/index.d.ts +0 -1
  90. package/lib/esm/__benchmark__/index.js.map +0 -1
  91. package/lib/esm/change.js +0 -2
  92. package/lib/esm/change.js.map +0 -1
  93. package/lib/esm/clock.js.map +0 -1
  94. package/lib/esm/entry-index.js.map +0 -1
  95. package/lib/esm/entry-with-refs.js +0 -2
  96. package/lib/esm/entry-with-refs.js.map +0 -1
  97. package/lib/esm/entry.js.map +0 -1
  98. package/lib/esm/heads-cache.js.map +0 -1
  99. package/lib/esm/heads.js.map +0 -1
  100. package/lib/esm/log-sorting.js.map +0 -1
  101. package/lib/esm/log.js.map +0 -1
  102. package/lib/esm/snapshot.js.map +0 -1
  103. package/lib/esm/trim.js.map +0 -1
  104. package/lib/esm/types.js.map +0 -1
  105. package/lib/esm/utils.d.ts +0 -2
  106. package/lib/esm/utils.js +0 -3
  107. package/lib/esm/utils.js.map +0 -1
  108. package/lib/esm/values.js.map +0 -1
  109. package/src/__benchmark__/index.ts +0 -130
  110. /package/{lib/esm → dist/src}/difference.js +0 -0
  111. /package/{lib/esm → dist/src}/difference.js.map +0 -0
  112. /package/{lib/esm → dist/src}/encoding.js +0 -0
  113. /package/{lib/esm → dist/src}/find-uniques.js +0 -0
  114. /package/{lib/esm → dist/src}/find-uniques.js.map +0 -0
  115. /package/{lib/esm → dist/src}/index.js +0 -0
  116. /package/{lib/esm → dist/src}/index.js.map +0 -0
  117. /package/{lib/esm → dist/src}/log-errors.js +0 -0
  118. /package/{lib/esm → dist/src}/log-errors.js.map +0 -0
  119. /package/{lib/esm → dist/src}/logger.js +0 -0
  120. /package/{lib/esm → dist/src}/logger.js.map +0 -0
package/package.json CHANGED
@@ -1,80 +1,104 @@
1
1
  {
2
- "name": "@peerbit/log",
3
- "version": "3.0.32",
4
- "description": "Append-only log CRDT",
5
- "author": "dao.xyz",
6
- "license": "MIT",
7
- "type": "module",
8
- "module": "lib/esm/index.js",
9
- "types": "lib/esm/index.d.ts",
10
- "exports": {
11
- "import": "./lib/esm/index.js",
12
- "require": "./lib/cjs/index.js"
13
- },
14
- "files": [
15
- "lib",
16
- "src",
17
- "!src/**/__tests__",
18
- "!lib/**/__tests__",
19
- "LICENSE"
20
- ],
21
- "publishConfig": {
22
- "access": "public"
23
- },
24
- "engines": {
25
- "node": ">=16.15.1"
26
- },
27
- "keywords": [
28
- "ipfs",
29
- "log",
30
- "crdts",
31
- "crdt"
32
- ],
33
- "dependencies": {
34
- "@dao-xyz/borsh": "^5.2.1",
35
- "@peerbit/blocks-interface": "^1.2.17",
36
- "@peerbit/cache": "2.0.6",
37
- "@peerbit/crypto": "2.1.7",
38
- "@peerbit/logger": "1.0.2",
39
- "@peerbit/time": "2.0.6",
40
- "libp2p": "^1.2.1",
41
- "p-queue": "^8.0.1",
42
- "path-browserify": "^1.0.1",
43
- "uuid": "^9.0.0",
44
- "yallist": "^4.0.0"
45
- },
46
- "devDependencies": {
47
- "@peerbit/test-utils": "2.0.31",
48
- "@types/yallist": "^4.0.1",
49
- "assert": "^2.0.0",
50
- "json-stringify-deterministic": "^1.0.7"
51
- },
52
- "contributors": [
53
- "haadcode",
54
- "aphelionz",
55
- "shamb0t",
56
- "thiagodelgado111",
57
- "mistakia",
58
- "satazor",
59
- "RichardLitt",
60
- "greenkeeperio-bot",
61
- "chrisdostert",
62
- "zachferland",
63
- "kaibakker",
64
- "dignifiedquire",
65
- "adam-palazzo"
66
- ],
67
- "scripts": {
68
- "clean": "shx rm -rf lib/*",
69
- "build": "yarn clean && tsc -p tsconfig.json",
70
- "test": "node --experimental-vm-modules ./../../node_modules/.bin/jest test -c ../../jest.config.ts --runInBand --forceExit",
71
- "test:unit": "node --experimental-vm-modules ../../node_modules/.bin/jest test -c ../../jest.config.unit.ts --runInBand --forceExit",
72
- "test:integration": "node --experimental-vm-modules ../node_modules/.bin/jest test -c ../../jest.config.integration.ts --runInBand --forceExit",
73
- "benchmark": "nyc --require ts-node/register benchmark-runner -r -b --baselineLimit 1000",
74
- "benchmark:stress": "benchmark-runner -r --grep stress"
75
- },
76
- "localMaintainers": [
77
- "dao.xyz"
78
- ],
79
- "gitHead": "b97732c727e239a3aa637830df4fc386468eaf86"
2
+ "name": "@peerbit/log",
3
+ "version": "3.0.34-0691c73",
4
+ "description": "Append-only log CRDT",
5
+ "author": "dao.xyz",
6
+ "license": "MIT",
7
+ "sideEffects": false,
8
+ "type": "module",
9
+ "types": "./dist/src/index.d.ts",
10
+ "typesVersions": {
11
+ "*": {
12
+ "*": [
13
+ "*",
14
+ "dist/*",
15
+ "dist/src/*",
16
+ "dist/src/*/index"
17
+ ],
18
+ "src/*": [
19
+ "*",
20
+ "dist/*",
21
+ "dist/src/*",
22
+ "dist/src/*/index"
23
+ ]
24
+ }
25
+ },
26
+ "files": [
27
+ "src",
28
+ "dist",
29
+ "!dist/test",
30
+ "!**/*.tsbuildinfo"
31
+ ],
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/src/index.d.ts",
35
+ "import": "./dist/src/index.js"
36
+ }
37
+ },
38
+ "eslintConfig": {
39
+ "extends": "ipfs",
40
+ "parserOptions": {
41
+ "project": true,
42
+ "sourceType": "module"
43
+ },
44
+ "ignorePatterns": [
45
+ "!.aegir.js",
46
+ "test/ts-use",
47
+ "*.d.ts"
48
+ ]
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "engines": {
54
+ "node": ">=16.15.1"
55
+ },
56
+ "keywords": [
57
+ "ipfs",
58
+ "log",
59
+ "crdts",
60
+ "crdt"
61
+ ],
62
+ "dependencies": {
63
+ "@dao-xyz/borsh": "^5.2.2",
64
+ "@peerbit/cache": "2.0.6-0691c73",
65
+ "@peerbit/blocks-interface": "1.2.19-0691c73",
66
+ "@peerbit/crypto": "2.2.0-0691c73",
67
+ "@peerbit/logger": "1.0.2-0691c73",
68
+ "@peerbit/time": "2.0.6-0691c73",
69
+ "libp2p": "^1.2.3",
70
+ "p-queue": "^8.0.1",
71
+ "path-browserify": "^1.0.1",
72
+ "yallist": "^4.0.0",
73
+ "uuid": "^9.0.0"
74
+ },
75
+ "devDependencies": {
76
+ "@peerbit/test-utils": "2.0.33-0691c73",
77
+ "@types/yallist": "^4.0.4",
78
+ "assert": "^2.0.0",
79
+ "json-stringify-deterministic": "^1.0.7"
80
+ },
81
+ "contributors": [
82
+ "haadcode",
83
+ "aphelionz",
84
+ "shamb0t",
85
+ "thiagodelgado111",
86
+ "mistakia",
87
+ "satazor",
88
+ "RichardLitt",
89
+ "greenkeeperio-bot",
90
+ "chrisdostert",
91
+ "zachferland",
92
+ "kaibakker",
93
+ "dignifiedquire",
94
+ "adam-palazzo"
95
+ ],
96
+ "scripts": {
97
+ "clean": "aegir clean",
98
+ "build": "aegir build --no-bundle",
99
+ "test": "aegir test --target node"
100
+ },
101
+ "localMaintainers": [
102
+ "dao.xyz"
103
+ ]
80
104
  }
package/src/change.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Entry } from "./entry";
1
+ import { Entry } from "./entry.js";
2
2
  export type Change<T> = { added: Entry<T>[]; removed: Entry<T>[] };
package/src/clock.ts CHANGED
@@ -24,14 +24,14 @@ SOFTWARE.
24
24
  */
25
25
 
26
26
  import { field, variant } from "@dao-xyz/borsh";
27
- import { compare, equals } from "@peerbit/uint8arrays";
27
+ import { compare, equals } from "uint8arrays";
28
28
  import { hrtime } from "@peerbit/time";
29
29
 
30
30
  const hrTimeNow = hrtime.bigint();
31
31
  const startTime = BigInt(Date.now()) * BigInt(1e6) - hrTimeNow;
32
32
  const bigintTime = () => startTime + hrtime.bigint();
33
33
 
34
- export function fromBits(low, high, unsigned, target?) {
34
+ export function fromBits(low: any, high: any, unsigned: any, target?: any) {
35
35
  if (target === undefined || target === null) {
36
36
  return {
37
37
  low: low | 0,
@@ -49,7 +49,7 @@ const n1e6 = BigInt(1e6);
49
49
  const UINT64_MAX = 18446744073709551615n;
50
50
  const UINT32_MAX = 0xffffffff;
51
51
 
52
- function bigIntCoerce(input, fallback) {
52
+ function bigIntCoerce(input: any, fallback: any) {
53
53
  if (typeof input === "bigint") return input;
54
54
  if (typeof input === "number" || typeof input === "string")
55
55
  return BigInt(input);
@@ -64,11 +64,9 @@ export class Timestamp {
64
64
  @field({ type: "u32" })
65
65
  logical: number;
66
66
 
67
- constructor(properties?: { wallTime: bigint; logical?: number }) {
68
- if (properties) {
69
- this.wallTime = properties.wallTime;
70
- this.logical = properties.logical || 0;
71
- }
67
+ constructor(properties: { wallTime: bigint; logical?: number }) {
68
+ this.wallTime = properties.wallTime;
69
+ this.logical = properties.logical || 0;
72
70
  }
73
71
 
74
72
  static compare(a: Timestamp, b: Timestamp) {
@@ -176,10 +174,8 @@ export class ClockOffsetError extends Error {
176
174
  maxOffset: bigint;
177
175
  constructor(offset: bigint, maxOffset: bigint) {
178
176
  super(
179
- `The received time is ${
180
- offset / n1e6
181
- }ms ahead of the wall time, exceeding the 'maxOffset' limit of ${
182
- maxOffset / n1e6
177
+ `The received time is ${offset / n1e6
178
+ }ms ahead of the wall time, exceeding the 'maxOffset' limit of ${maxOffset / n1e6
183
179
  }ms.`
184
180
  );
185
181
  this.offset = offset;
@@ -192,8 +188,7 @@ export class WallTimeOverflowError extends Error {
192
188
  maxTime: bigint;
193
189
  constructor(time: bigint, maxTime: bigint) {
194
190
  super(
195
- `The wall time ${time / n1e6}ms exceeds the max time of ${
196
- maxTime / n1e6
191
+ `The wall time ${time / n1e6}ms exceeds the max time of ${maxTime / n1e6
197
192
  }ms.`
198
193
  );
199
194
  this.time = time;
@@ -206,8 +201,7 @@ export class ForwardJumpError extends Error {
206
201
  tolerance: bigint;
207
202
  constructor(timejump: bigint, tolerance: bigint) {
208
203
  super(
209
- `Detected a forward time jump of ${
210
- timejump / n1e6
204
+ `Detected a forward time jump of ${timejump / n1e6
211
205
  }ms, which exceed the allowed tolerance of ${tolerance / n1e6}ms.`
212
206
  );
213
207
  this.timejump = timejump;
package/src/encoding.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AbstractType, deserialize, serialize } from "@dao-xyz/borsh";
1
+ import { type AbstractType, deserialize, serialize } from "@dao-xyz/borsh";
2
2
 
3
3
  export interface Encoding<T> {
4
4
  encoder: (data: T) => Uint8Array;
@@ -9,7 +9,7 @@ export const NO_ENCODING: Encoding<any> = {
9
9
  if (obj instanceof Uint8Array === false) {
10
10
  throw new Error(
11
11
  "With NO_ENCODING only Uint8arrays are allowed, received: " +
12
- (obj?.["constructor"]?.["name"] || typeof obj)
12
+ (obj?.["constructor"]?.["name"] || typeof obj)
13
13
  );
14
14
  }
15
15
  return obj;
@@ -1,8 +1,8 @@
1
1
  import { Cache } from "@peerbit/cache";
2
- import { Entry, ShallowEntry } from "./entry.js";
2
+ import { Entry, type ShallowEntry } from "./entry.js";
3
3
  import { deserialize } from "@dao-xyz/borsh";
4
4
  import { logger } from "./logger.js";
5
- import { Blocks } from "@peerbit/blocks-interface";
5
+ import { type Blocks } from "@peerbit/blocks-interface";
6
6
 
7
7
  export class EntryIndex<T> {
8
8
  _cache: Cache<Entry<T> | null>;
package/src/entry.ts CHANGED
@@ -7,8 +7,6 @@ import {
7
7
  option,
8
8
  vec,
9
9
  fixedArray,
10
- BinaryWriter,
11
- serializer
12
10
  } from "@dao-xyz/borsh";
13
11
 
14
12
  import {
@@ -21,15 +19,16 @@ import {
21
19
  Ed25519PublicKey,
22
20
  sha256Base64,
23
21
  randomBytes,
24
- Identity,
22
+ type Identity,
25
23
  X25519Keypair
26
24
  } from "@peerbit/crypto";
27
25
  import { verify } from "@peerbit/crypto";
28
- import { compare, equals } from "@peerbit/uint8arrays";
29
- import { Encoding, NO_ENCODING } from "./encoding.js";
26
+ import { compare } from "uint8arrays";
27
+ import { type Encoding, NO_ENCODING } from "./encoding.js";
30
28
  import { logger } from "./logger.js";
31
- import { Blocks } from "@peerbit/blocks-interface";
32
- import { Keychain } from "@peerbit/keychain";
29
+ import { type Blocks } from "@peerbit/blocks-interface";
30
+ import { type Keychain } from "@peerbit/keychain";
31
+ import { equals } from "./utils.js";
33
32
 
34
33
  export type MaybeEncryptionPublicKey =
35
34
  | X25519PublicKey
@@ -155,27 +154,25 @@ export class Meta {
155
154
  @field({ type: option(Uint8Array) })
156
155
  data?: Uint8Array; // Optional metadata
157
156
 
158
- constructor(properties?: {
157
+ constructor(properties: {
159
158
  gid: string;
160
159
  clock: Clock;
161
160
  type: EntryType;
162
161
  data?: Uint8Array;
163
162
  next: string[];
164
163
  }) {
165
- if (properties) {
166
- this.gid = properties.gid;
167
- this.clock = properties.clock;
168
- this.type = properties.type;
169
- this.data = properties.data;
170
- this.next = properties.next;
171
- }
164
+ this.gid = properties.gid;
165
+ this.clock = properties.clock;
166
+ this.type = properties.type;
167
+ this.data = properties.data;
168
+ this.next = properties.next;
172
169
  }
173
170
  }
174
171
 
175
172
  @variant(0)
176
173
  export class Signatures {
177
174
  @field({ type: vec(MaybeEncrypted) })
178
- signatures: MaybeEncrypted<SignatureWithKey>[];
175
+ signatures!: MaybeEncrypted<SignatureWithKey>[];
179
176
 
180
177
  constructor(properties?: { signatures: MaybeEncrypted<SignatureWithKey>[] }) {
181
178
  if (properties) {
@@ -250,7 +247,7 @@ export class Entry<T>
250
247
  _signatures?: Signatures;
251
248
 
252
249
  @field({ type: option("string") }) // we do option because we serialize and store this in a block without the hash, to receive the hash, which we later set
253
- hash: string; // "zd...Foo", we'll set the hash after persisting the entry
250
+ hash!: string; // "zd...Foo", we'll set the hash after persisting the entry
254
251
 
255
252
  createdLocally?: boolean;
256
253
 
@@ -275,9 +272,9 @@ export class Entry<T>
275
272
  init(
276
273
  props:
277
274
  | {
278
- keychain?: Keychain;
279
- encoding: Encoding<T>;
280
- }
275
+ keychain?: Keychain;
276
+ encoding: Encoding<T>;
277
+ }
281
278
  | Entry<T>
282
279
  ): Entry<T> {
283
280
  if (props instanceof Entry) {
@@ -355,7 +352,7 @@ export class Entry<T>
355
352
  return (await this.getMeta()).next;
356
353
  }
357
354
 
358
- private _size: number;
355
+ private _size!: number;
359
356
 
360
357
  set size(number: number) {
361
358
  this._size = number;
@@ -544,9 +541,9 @@ export class Entry<T>
544
541
  if (Timestamp.compare(n.meta.clock.timestamp, cv.timestamp) >= 0) {
545
542
  throw new Error(
546
543
  "Expecting next(s) to happen before entry, got: " +
547
- n.meta.clock.timestamp +
548
- " > " +
549
- cv.timestamp
544
+ n.meta.clock.timestamp +
545
+ " > " +
546
+ cv.timestamp
550
547
  );
551
548
  }
552
549
  }
@@ -626,9 +623,9 @@ export class Entry<T>
626
623
  for (const signature of signatures) {
627
624
  const encryptionRecievers = encryptAllSignaturesWithSameKey
628
625
  ? properties.encryption?.receiver?.signatures
629
- : properties.encryption?.receiver?.signatures?.[
630
- signature.publicKey.hashcode()
631
- ];
626
+ : (properties.encryption?.receiver?.signatures as any)?.[ // TODO types
627
+ signature.publicKey.hashcode()
628
+ ];
632
629
  const signatureEncrypted = await maybeEncrypt(
633
630
  signature,
634
631
  properties.encryption?.keypair,
@@ -1,14 +1,14 @@
1
1
  import PQueue from "p-queue";
2
2
  import { v4 as uuid } from "uuid";
3
- import { Entry } from "./entry";
4
- import { AnyStore } from "@peerbit/any-store";
3
+ import { Entry } from "./entry.js";
4
+ import { type AnyStore } from "@peerbit/any-store";
5
5
  import { variant, option, field, vec } from "@dao-xyz/borsh";
6
6
  import { serialize, deserialize } from "@dao-xyz/borsh";
7
7
  import { logger as loggerFn } from "@peerbit/logger";
8
8
 
9
9
  import path from "path-browserify";
10
10
  export const logger = loggerFn({ module: "heads-cache" });
11
- export class CachedValue {}
11
+ export class CachedValue { }
12
12
  /* export type AppendOptions<T> = {
13
13
  signers?: ((data: Uint8Array) => Promise<SignatureWithKey>)[];
14
14
  nexts?: Entry<T>[];
@@ -32,10 +32,8 @@ export class UnsfinishedReplication {
32
32
  @field({ type: vec("string") })
33
33
  hashes: string[];
34
34
 
35
- constructor(opts?: { hashes: string[] }) {
36
- if (opts) {
37
- this.hashes = opts.hashes;
38
- }
35
+ constructor(opts: { hashes: string[] }) {
36
+ this.hashes = opts.hashes;
39
37
  }
40
38
  }
41
39
 
@@ -90,9 +88,9 @@ interface HeadsIndex {
90
88
  }
91
89
  export class HeadsCache<T> /* implements Initiable<T> */ {
92
90
  // An access controller that is note part of the store manifest, usefull for circular store -> access controller -> store structures
93
- headsPath: string;
94
- removedHeadsPath: string;
95
- initialized: boolean;
91
+ headsPath!: string;
92
+ removedHeadsPath!: string;
93
+ initialized: boolean = false;
96
94
 
97
95
  private _headsPathCounter = 0;
98
96
 
@@ -106,7 +104,7 @@ export class HeadsCache<T> /* implements Initiable<T> */ {
106
104
  private _cacheWriteQueue?: PQueue<any, any>;
107
105
 
108
106
  private _loaded = false;
109
- private _index: HeadsIndex;
107
+ private _index!: HeadsIndex;
110
108
 
111
109
  constructor(index: HeadsIndex) {
112
110
  this._index = index;
package/src/heads.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Entry } from "./entry.js";
2
- import { AnyStore } from "@peerbit/any-store";
2
+ import { type AnyStore } from "@peerbit/any-store";
3
3
  import { HeadsCache } from "./heads-cache.js";
4
- import { Blocks } from "@peerbit/blocks-interface";
5
- import { Keychain } from "@peerbit/keychain";
6
- import { Encoding } from "./encoding.js";
4
+ import { type Blocks } from "@peerbit/blocks-interface";
5
+ import { type Keychain } from "@peerbit/keychain";
6
+ import { type Encoding } from "./encoding.js";
7
7
  import { Values } from "./values.js";
8
8
  import { logger } from "./logger.js";
9
9
  import { EntryIndex } from "./entry-index.js";
@@ -25,7 +25,7 @@ export class HeadsIndex<T> {
25
25
  private _index: Set<string> = new Set();
26
26
  private _gids: Map<string, Map<string, Entry<T>>>; // gid -> hash -> entry
27
27
  private _headsCache: HeadsCache<T> | undefined;
28
- private _config: Log<T>;
28
+ private _config!: Log<T>;
29
29
  private _onGidRemoved?: (gid: string[]) => Promise<void> | void;
30
30
  constructor(id: Uint8Array) {
31
31
  this._gids = new Map();
@@ -1,6 +1,6 @@
1
- import { Entry, ShallowEntry } from "./entry.js";
1
+ import { type ShallowEntry } from "./entry.js";
2
2
  import { LamportClock as Clock } from "./clock.js";
3
- import { compare } from "@peerbit/uint8arrays";
3
+ import { compare } from "uint8arrays";
4
4
 
5
5
  const First = (a: any, b: any) => a;
6
6