@constl/utils-tests 2.2.0 → 2.2.1
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/@types.d.ts +1 -0
- package/dist/@types.d.ts.map +1 -0
- package/dist/attente.d.ts +1 -0
- package/dist/attente.d.ts.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js.map +1 -1
- package/dist/constellation.d.ts +1 -0
- package/dist/constellation.d.ts.map +1 -0
- package/dist/dossiers.d.ts +1 -0
- package/dist/dossiers.d.ts.map +1 -0
- package/dist/h/303/251lia.d.ts +2 -1
- package/dist/h/303/251lia.d.ts.map +1 -0
- package/dist/h/303/251lia.js +8 -4
- package/dist/h/303/251lia.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/libp2p/config.d.ts +1 -0
- package/dist/libp2p/config.d.ts.map +1 -0
- package/dist/libp2p/index.d.ts +1 -0
- package/dist/libp2p/index.d.ts.map +1 -0
- package/dist/libp2p/libp2p.d.ts +2 -1
- package/dist/libp2p/libp2p.d.ts.map +1 -0
- package/dist/libp2p/libp2p.js +2 -2
- package/dist/libp2p/libp2p.js.map +1 -1
- package/dist/libp2p/utils.d.ts +2 -1
- package/dist/libp2p/utils.d.ts.map +1 -0
- package/dist/libp2p/utils.js +6 -4
- package/dist/libp2p/utils.js.map +1 -1
- package/dist/orbite.d.ts +3 -1
- package/dist/orbite.d.ts.map +1 -0
- package/dist/orbite.js +6 -1
- package/dist/orbite.js.map +1 -1
- package/dist/relai/bin.d.ts +1 -0
- package/dist/relai/bin.d.ts.map +1 -0
- package/dist/relai/consts.d.ts +1 -0
- package/dist/relai/consts.d.ts.map +1 -0
- package/dist/relai/index.d.ts +1 -0
- package/dist/relai/index.d.ts.map +1 -0
- package/dist/relai/relai.d.ts +1 -0
- package/dist/relai/relai.d.ts.map +1 -0
- package/dist/relai/utils.d.ts +1 -0
- package/dist/relai/utils.d.ts.map +1 -0
- package/dist/scripts/node-globals.d.ts +1 -0
- package/dist/scripts/node-globals.d.ts.map +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/version.d.ts +2 -1
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +1 -1
- package/eslint.config.js +33 -0
- package/package.json +13 -17
- package/pnpm-workspace.yaml +0 -11
- package/src/config.ts +1 -2
- package/src/h/303/251lia.ts +14 -6
- package/src/index.ts +1 -1
- package/src/libp2p/libp2p.ts +3 -3
- package/src/libp2p/utils.ts +8 -5
- package/src/orbite.ts +8 -2
- package/src/version.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +4 -35
package/src/h/303/251lia.ts
CHANGED
|
@@ -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 {
|
|
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,
|
|
@@ -42,6 +44,12 @@ export const créerHéliasTest = async ({
|
|
|
42
44
|
};
|
|
43
45
|
const hélia = await createHelia(optionsHélia).start();
|
|
44
46
|
hélias.push(hélia);
|
|
47
|
+
await toutesConnectées(
|
|
48
|
+
hélias.map((h) => h.libp2p),
|
|
49
|
+
{
|
|
50
|
+
adresseRelai: obtenirAdresseRelai(),
|
|
51
|
+
},
|
|
52
|
+
);
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
const fermer = async () => {
|
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";
|
package/src/libp2p/libp2p.ts
CHANGED
|
@@ -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 {
|
|
10
|
+
import type { Libp2p } from "@libp2p/interface";
|
|
11
11
|
|
|
12
12
|
export const créerLibp2psTest = async ({
|
|
13
13
|
n,
|
package/src/libp2p/utils.ts
CHANGED
|
@@ -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;
|
|
@@ -22,7 +23,7 @@ export const connecterPairs = async <
|
|
|
22
23
|
if (isBrowser || isElectronRenderer) {
|
|
23
24
|
await libp2p1.dial(multiaddr(options.adresseRelai));
|
|
24
25
|
|
|
25
|
-
const adresse1 = await new Promise<Multiaddr>((
|
|
26
|
+
const adresse1 = await new Promise<Multiaddr>((résoudre) => {
|
|
26
27
|
const testConnecté = () => {
|
|
27
28
|
const adresse = libp2p1
|
|
28
29
|
.getMultiaddrs()
|
|
@@ -30,14 +31,15 @@ export const connecterPairs = async <
|
|
|
30
31
|
.pop();
|
|
31
32
|
if (adresse != null) {
|
|
32
33
|
clearInterval(interval);
|
|
33
|
-
|
|
34
|
+
résoudre(adresse);
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
37
|
const interval = setInterval(testConnecté, 100);
|
|
37
38
|
testConnecté();
|
|
38
39
|
});
|
|
39
40
|
libp2p2.dial(adresse1);
|
|
40
|
-
|
|
41
|
+
|
|
42
|
+
await new Promise((résoudre) => {
|
|
41
43
|
const testConnecté = () => {
|
|
42
44
|
const adresse = libp2p1
|
|
43
45
|
.getConnections()
|
|
@@ -45,7 +47,7 @@ export const connecterPairs = async <
|
|
|
45
47
|
.pop();
|
|
46
48
|
if (adresse != null) {
|
|
47
49
|
clearInterval(interval);
|
|
48
|
-
|
|
50
|
+
résoudre(adresse);
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
53
|
const interval = setInterval(testConnecté, 100);
|
|
@@ -56,6 +58,7 @@ export const connecterPairs = async <
|
|
|
56
58
|
multiaddrs: libp2p1.getMultiaddrs().filter(filtre),
|
|
57
59
|
});
|
|
58
60
|
await libp2p2.dial(libp2p1.peerId);
|
|
61
|
+
await que(() => !!libp2p1.getPeers().find((p) => p.equals(libp2p2.peerId)));
|
|
59
62
|
}
|
|
60
63
|
};
|
|
61
64
|
|
package/src/orbite.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
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.
|
|
2
|
+
export const version = '2.2.1';
|