@constl/utils-tests 2.2.0 → 2.2.2

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 (67) hide show
  1. package/dist/@types.d.ts +1 -0
  2. package/dist/@types.d.ts.map +1 -0
  3. package/dist/attente.d.ts +1 -0
  4. package/dist/attente.d.ts.map +1 -0
  5. package/dist/config.d.ts +1 -0
  6. package/dist/config.d.ts.map +1 -0
  7. package/dist/config.js.map +1 -1
  8. package/dist/constellation.d.ts +1 -0
  9. package/dist/constellation.d.ts.map +1 -0
  10. package/dist/dossiers.d.ts +1 -0
  11. package/dist/dossiers.d.ts.map +1 -0
  12. package/dist/h/303/251lia.d.ts +2 -1
  13. package/dist/h/303/251lia.d.ts.map +1 -0
  14. package/dist/h/303/251lia.js +8 -4
  15. package/dist/h/303/251lia.js.map +1 -1
  16. package/dist/index.d.ts +2 -1
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +1 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/libp2p/config.d.ts +3 -1
  21. package/dist/libp2p/config.d.ts.map +1 -0
  22. package/dist/libp2p/config.js +3 -1
  23. package/dist/libp2p/config.js.map +1 -1
  24. package/dist/libp2p/index.d.ts +1 -0
  25. package/dist/libp2p/index.d.ts.map +1 -0
  26. package/dist/libp2p/libp2p.d.ts +2 -1
  27. package/dist/libp2p/libp2p.d.ts.map +1 -0
  28. package/dist/libp2p/libp2p.js +2 -2
  29. package/dist/libp2p/libp2p.js.map +1 -1
  30. package/dist/libp2p/utils.d.ts +2 -1
  31. package/dist/libp2p/utils.d.ts.map +1 -0
  32. package/dist/libp2p/utils.js +8 -4
  33. package/dist/libp2p/utils.js.map +1 -1
  34. package/dist/orbite.d.ts +3 -1
  35. package/dist/orbite.d.ts.map +1 -0
  36. package/dist/orbite.js +6 -1
  37. package/dist/orbite.js.map +1 -1
  38. package/dist/relai/bin.d.ts +1 -0
  39. package/dist/relai/bin.d.ts.map +1 -0
  40. package/dist/relai/consts.d.ts +1 -0
  41. package/dist/relai/consts.d.ts.map +1 -0
  42. package/dist/relai/index.d.ts +1 -0
  43. package/dist/relai/index.d.ts.map +1 -0
  44. package/dist/relai/relai.d.ts +1 -0
  45. package/dist/relai/relai.d.ts.map +1 -0
  46. package/dist/relai/utils.d.ts +1 -0
  47. package/dist/relai/utils.d.ts.map +1 -0
  48. package/dist/scripts/node-globals.d.ts +1 -0
  49. package/dist/scripts/node-globals.d.ts.map +1 -0
  50. package/dist/utils.d.ts +1 -0
  51. package/dist/utils.d.ts.map +1 -0
  52. package/dist/version.d.ts +2 -1
  53. package/dist/version.d.ts.map +1 -0
  54. package/dist/version.js +1 -1
  55. package/eslint.config.js +33 -0
  56. package/package.json +13 -17
  57. package/pnpm-workspace.yaml +0 -11
  58. package/src/config.ts +1 -2
  59. package/src/h/303/251lia.ts +15 -6
  60. package/src/index.ts +1 -1
  61. package/src/libp2p/config.ts +4 -1
  62. package/src/libp2p/libp2p.ts +3 -3
  63. package/src/libp2p/utils.ts +9 -5
  64. package/src/orbite.ts +8 -2
  65. package/src/version.ts +1 -1
  66. package/tsconfig.build.tsbuildinfo +1 -1
  67. package/tsconfig.json +4 -35
@@ -1,22 +1,11 @@
1
1
  allowBuilds:
2
- '@ipshipyard/node-datachannel': true
3
- aws-sdk: false
4
2
  bun: true
5
3
  classic-level: true
6
4
  core-js: true
7
5
  deno: true
8
6
  electron: true
9
7
  esbuild: true
10
- iso-constants@https://codeload.github.com/inverted-capital/iso-constants/tar.gz/2af6fdfb2cacaa03ebd58543703918783e62649f: true
11
8
  node-datachannel: true
12
9
  unrs-resolver: true
13
10
 
14
- overrides:
15
- xlsx: "@e965/xlsx"
16
-
17
- blockExoticSubdeps: false
18
-
19
11
  packages: []
20
-
21
- minimumReleaseAgeExclude:
22
- - '@orbitdb/core-types@2.0.0'
package/src/config.ts CHANGED
@@ -1,8 +1,7 @@
1
+ import { lancerRelai } from "./relai/index.js";
1
2
  import type { PartialOptions } from "aegir";
2
3
  import type { BuildOptions } from "esbuild";
3
4
 
4
- import { lancerRelai } from "./relai/index.js";
5
-
6
5
  export const obtConfigEsbuild = async (): Promise<BuildOptions> => {
7
6
  const { createRequire } = (await import("module")).default;
8
7
  const path = await import("path");
@@ -1,15 +1,17 @@
1
+ import { join } from "path";
2
+ import { MemoryBlockstore } from "blockstore-core";
1
3
  import { createHelia } from "helia";
4
+ import { IDBBlockstore } from "blockstore-idb";
5
+ import { isBrowser, isElectronMain, isNode } from "wherearewe";
6
+ import { type HeliaWithLibp2p } from "@helia/libp2p";
7
+ import { sousDossier } from "./utils.js";
2
8
  import {
3
9
  OptionsDéfautLibp2pNavigateur,
4
10
  OptionsDéfautLibp2pNode,
11
+ toutesConnectées,
5
12
  type ServicesLibp2pTest,
6
13
  } from "./libp2p/index.js";
7
- import { MemoryBlockstore } from "blockstore-core";
8
- import { join } from "path";
9
- import { sousDossier } from "./utils.js";
10
- import { IDBBlockstore } from "blockstore-idb";
11
- import { isBrowser, isElectronMain, isNode } from "wherearewe";
12
- import { type HeliaWithLibp2p } from "@helia/libp2p";
14
+ import { obtenirAdresseRelai } from "./relai/index.ts";
13
15
 
14
16
  export const créerHéliasTest = async ({
15
17
  n,
@@ -43,6 +45,13 @@ export const créerHéliasTest = async ({
43
45
  const hélia = await createHelia(optionsHélia).start();
44
46
  hélias.push(hélia);
45
47
  }
48
+
49
+ await toutesConnectées(
50
+ hélias.map((h) => h.libp2p),
51
+ {
52
+ adresseRelai: obtenirAdresseRelai(),
53
+ },
54
+ );
46
55
 
47
56
  const fermer = async () => {
48
57
  await Promise.all(
package/src/index.ts CHANGED
@@ -26,4 +26,4 @@ export { obtConfigEsbuild, générerConfigÆgir } from "./config.js";
26
26
  export { créerConstellationsTest } from "./constellation.js";
27
27
  export { dossierTempo } from "./dossiers.js";
28
28
  export { créerHéliasTest } from "./hélia.js";
29
- export { créerOrbitesTest } from "./orbite.js";
29
+ export { créerOrbitesTest, attendreSync } from "./orbite.js";
@@ -32,7 +32,7 @@ import {
32
32
  import { noise } from "@chainsafe/libp2p-noise";
33
33
  import { yamux } from "@chainsafe/libp2p-yamux";
34
34
  import { circuitRelayTransport } from "@libp2p/circuit-relay-v2";
35
- import { type Identify, identify } from "@libp2p/identify";
35
+ import { type Identify, identify, identifyPush, type IdentifyPush } from "@libp2p/identify";
36
36
  import { webRTC } from "@libp2p/webrtc";
37
37
  import { webSockets } from "@libp2p/websockets";
38
38
 
@@ -44,6 +44,7 @@ import { ping, type Ping } from "@libp2p/ping";
44
44
  export type ServicesLibp2pTest = {
45
45
  ping: Ping;
46
46
  identify: Identify;
47
+ identifyPush: IdentifyPush;
47
48
  pubsub: GossipSub;
48
49
  obtClefPrivée: ServiceClefPrivée;
49
50
  };
@@ -82,6 +83,7 @@ export const OptionsDéfautLibp2pNode: () => Libp2pOptions<ServicesLibp2pTest> =
82
83
  services: {
83
84
  ping: ping(),
84
85
  identify: identify(),
86
+ identifyPush: identifyPush(),
85
87
  pubsub: gossipsub({ allowPublishToZeroTopicPeers: true }) as (
86
88
  components: GossipSubComponents,
87
89
  ) => GossipSub, // Erreur de type dans @chainsafe/pubsub
@@ -109,6 +111,7 @@ export const OptionsDéfautLibp2pNavigateur: () => Libp2pOptions<ServicesLibp2pT
109
111
  services: {
110
112
  ping: ping(),
111
113
  identify: identify(),
114
+ identifyPush: identifyPush(),
112
115
  pubsub: gossipsub({ allowPublishToZeroTopicPeers: true }) as (
113
116
  components: GossipSubComponents,
114
117
  ) => GossipSub, // Erreur de type dans @chainsafe/pubsub,
@@ -1,13 +1,13 @@
1
- import type { Libp2p } from "@libp2p/interface";
2
1
  import { createLibp2p } from "libp2p";
2
+ import { isBrowser } from "wherearewe";
3
+ import { obtenirAdresseRelai } from "../relai/index.js";
3
4
  import {
4
5
  OptionsDéfautLibp2pNavigateur,
5
6
  OptionsDéfautLibp2pNode,
6
7
  type ServicesLibp2pTest,
7
8
  } from "./config.js";
8
- import { isBrowser } from "wherearewe";
9
9
  import { connecterPairs } from "./utils.js";
10
- import { obtenirAdresseRelai } from "../relai/index.js";
10
+ import type { Libp2p } from "@libp2p/interface";
11
11
 
12
12
  export const créerLibp2psTest = async ({
13
13
  n,
@@ -1,7 +1,8 @@
1
- import type { Libp2p } from "@libp2p/interface";
2
1
  import { WebRTC } from "@multiformats/multiaddr-matcher";
3
2
  import { multiaddr, type Multiaddr } from "@multiformats/multiaddr";
4
3
  import { isBrowser, isElectronRenderer } from "wherearewe";
4
+ import { que } from "../attente.ts";
5
+ import type { Libp2p } from "@libp2p/interface";
5
6
  import type { ServicesLibp2pTest } from "./config.js";
6
7
 
7
8
  const filtreParDéfaut = () => true;
@@ -18,11 +19,12 @@ export const connecterPairs = async <
18
19
  options: OptionsConnectionPairs,
19
20
  ): Promise<void> => {
20
21
  const filtre = options.filtre ?? filtreParDéfaut;
22
+ if (libp2p1.getPeers().some(idPair=>idPair.equals(libp2p2.peerId))) return
21
23
 
22
24
  if (isBrowser || isElectronRenderer) {
23
25
  await libp2p1.dial(multiaddr(options.adresseRelai));
24
26
 
25
- const adresse1 = await new Promise<Multiaddr>((resolve) => {
27
+ const adresse1 = await new Promise<Multiaddr>((résoudre) => {
26
28
  const testConnecté = () => {
27
29
  const adresse = libp2p1
28
30
  .getMultiaddrs()
@@ -30,14 +32,15 @@ export const connecterPairs = async <
30
32
  .pop();
31
33
  if (adresse != null) {
32
34
  clearInterval(interval);
33
- resolve(adresse);
35
+ résoudre(adresse);
34
36
  }
35
37
  };
36
38
  const interval = setInterval(testConnecté, 100);
37
39
  testConnecté();
38
40
  });
39
41
  libp2p2.dial(adresse1);
40
- await new Promise((resolve) => {
42
+
43
+ await new Promise((résoudre) => {
41
44
  const testConnecté = () => {
42
45
  const adresse = libp2p1
43
46
  .getConnections()
@@ -45,7 +48,7 @@ export const connecterPairs = async <
45
48
  .pop();
46
49
  if (adresse != null) {
47
50
  clearInterval(interval);
48
- resolve(adresse);
51
+ résoudre(adresse);
49
52
  }
50
53
  };
51
54
  const interval = setInterval(testConnecté, 100);
@@ -56,6 +59,7 @@ export const connecterPairs = async <
56
59
  multiaddrs: libp2p1.getMultiaddrs().filter(filtre),
57
60
  });
58
61
  await libp2p2.dial(libp2p1.peerId);
62
+ await que(() => !!libp2p1.getPeers().find((p) => p.equals(libp2p2.peerId)));
59
63
  }
60
64
  };
61
65
 
package/src/orbite.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { type OrbitDB, createOrbitDB } from "@orbitdb/core";
1
+ import { join } from "path";
2
+ import { type BaseDatabase, type OrbitDB, createOrbitDB } from "@orbitdb/core";
2
3
  import { dossierTempo } from "./dossiers.js";
3
4
  import { type ServicesLibp2pTest } from "./libp2p/index.js";
4
5
  import { créerHéliasTest } from "./hélia.js";
5
- import { join } from "path";
6
6
  import { sousDossier } from "./utils.js";
7
7
 
8
8
  export const créerOrbitesTest = async ({
@@ -48,3 +48,9 @@ export const créerOrbitesTest = async ({
48
48
  fermer,
49
49
  };
50
50
  };
51
+
52
+ export const attendreSync = async (bd: BaseDatabase): Promise<void> => {
53
+ return new Promise<void>((résoudre) => {
54
+ bd.events.once("update", () => résoudre());
55
+ });
56
+ };
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '2.2.0';
2
+ export const version = '2.2.2';