@libp2p/devtools-metrics 1.0.1 → 1.1.0-b3272cfce

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.
@@ -0,0 +1,9 @@
1
+ import { gatherCapabilities } from './gather-capabilities.js'
2
+
3
+ export function findCapability (capability: string, components: any): any | undefined {
4
+ for (const [name, capabilities] of Object.entries(gatherCapabilities(components))) {
5
+ if (capabilities.includes(capability)) {
6
+ return components[name]
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,14 @@
1
+ import { serviceCapabilities } from '@libp2p/interface'
2
+
3
+ export function gatherCapabilities (components: any): Record<string, string[]> {
4
+ const capabilities: Record<string, string[]> = {}
5
+ const services: Record<string, any> = components.components ?? components
6
+
7
+ Object.entries(services).forEach(([name, component]) => {
8
+ if (component?.[serviceCapabilities] != null && Array.isArray(component[serviceCapabilities])) {
9
+ capabilities[name] = component[serviceCapabilities]
10
+ }
11
+ })
12
+
13
+ return capabilities
14
+ }
@@ -0,0 +1,12 @@
1
+ import { InvalidParametersError, isPubSub } from '@libp2p/interface'
2
+ import type { PubSub } from '@libp2p/interface'
3
+
4
+ export function getPubSub (component: string, components: any): PubSub {
5
+ const pubsub = components[component]
6
+
7
+ if (!isPubSub(pubsub)) {
8
+ throw new InvalidParametersError(`Component ${component} did not implement the PubSub interface`)
9
+ }
10
+
11
+ return pubsub
12
+ }
@@ -1,50 +0,0 @@
1
- {
2
- "Address": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.Address.html",
3
- ".:Address": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.Address.html",
4
- "CopyToClipboardMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.CopyToClipboardMessage.html",
5
- ".:CopyToClipboardMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.CopyToClipboardMessage.html",
6
- "DevToolsEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.DevToolsEvents.html",
7
- "./rpc:DevToolsEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.DevToolsEvents.html",
8
- "DevToolsMetricsComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.DevToolsMetricsComponents.html",
9
- ".:DevToolsMetricsComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.DevToolsMetricsComponents.html",
10
- "DevToolsMetricsInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.DevToolsMetricsInit.html",
11
- ".:DevToolsMetricsInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.DevToolsMetricsInit.html",
12
- "DevToolsRPC": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.DevToolsRPC.html",
13
- "./rpc:DevToolsRPC": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.DevToolsRPC.html",
14
- "MetricsRPC": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.MetricsRPC.html",
15
- "./rpc:MetricsRPC": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.MetricsRPC.html",
16
- "NodeAddress": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.NodeAddress.html",
17
- "./rpc:NodeAddress": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.NodeAddress.html",
18
- "NodeStatus": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.NodeStatus.html",
19
- "./rpc:NodeStatus": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.NodeStatus.html",
20
- "PageLoadedMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.PageLoadedMessage.html",
21
- ".:PageLoadedMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.PageLoadedMessage.html",
22
- "Peer": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.Peer.html",
23
- "./rpc:Peer": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.Peer.html",
24
- "PeerAddress": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.PeerAddress.html",
25
- "./rpc:PeerAddress": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.PeerAddress.html",
26
- "PermissionsErrorMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.PermissionsErrorMessage.html",
27
- ".:PermissionsErrorMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.PermissionsErrorMessage.html",
28
- "RPCMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.RPCMessage.html",
29
- ".:RPCMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_devtools_metrics.RPCMessage.html",
30
- "ApplicationMessage": "https://libp2p.github.io/js-libp2p/types/_libp2p_devtools_metrics.ApplicationMessage.html",
31
- ".:ApplicationMessage": "https://libp2p.github.io/js-libp2p/types/_libp2p_devtools_metrics.ApplicationMessage.html",
32
- "DevToolsMessage": "https://libp2p.github.io/js-libp2p/types/_libp2p_devtools_metrics.DevToolsMessage.html",
33
- ".:DevToolsMessage": "https://libp2p.github.io/js-libp2p/types/_libp2p_devtools_metrics.DevToolsMessage.html",
34
- "WorkerMessage": "https://libp2p.github.io/js-libp2p/types/_libp2p_devtools_metrics.WorkerMessage.html",
35
- ".:WorkerMessage": "https://libp2p.github.io/js-libp2p/types/_libp2p_devtools_metrics.WorkerMessage.html",
36
- "LIBP2P_DEVTOOLS_METRICS_KEY": "https://libp2p.github.io/js-libp2p/variables/_libp2p_devtools_metrics.LIBP2P_DEVTOOLS_METRICS_KEY.html",
37
- ".:LIBP2P_DEVTOOLS_METRICS_KEY": "https://libp2p.github.io/js-libp2p/variables/_libp2p_devtools_metrics.LIBP2P_DEVTOOLS_METRICS_KEY.html",
38
- "SOURCE_CONTENT_SCRIPT": "https://libp2p.github.io/js-libp2p/variables/_libp2p_devtools_metrics.SOURCE_CONTENT_SCRIPT.html",
39
- ".:SOURCE_CONTENT_SCRIPT": "https://libp2p.github.io/js-libp2p/variables/_libp2p_devtools_metrics.SOURCE_CONTENT_SCRIPT.html",
40
- "SOURCE_DEVTOOLS": "https://libp2p.github.io/js-libp2p/variables/_libp2p_devtools_metrics.SOURCE_DEVTOOLS.html",
41
- ".:SOURCE_DEVTOOLS": "https://libp2p.github.io/js-libp2p/variables/_libp2p_devtools_metrics.SOURCE_DEVTOOLS.html",
42
- "SOURCE_METRICS": "https://libp2p.github.io/js-libp2p/variables/_libp2p_devtools_metrics.SOURCE_METRICS.html",
43
- ".:SOURCE_METRICS": "https://libp2p.github.io/js-libp2p/variables/_libp2p_devtools_metrics.SOURCE_METRICS.html",
44
- "SOURCE_SERVICE_WORKER": "https://libp2p.github.io/js-libp2p/variables/_libp2p_devtools_metrics.SOURCE_SERVICE_WORKER.html",
45
- ".:SOURCE_SERVICE_WORKER": "https://libp2p.github.io/js-libp2p/variables/_libp2p_devtools_metrics.SOURCE_SERVICE_WORKER.html",
46
- "valueCodecs": "https://libp2p.github.io/js-libp2p/variables/_libp2p_devtools_metrics.valueCodecs.html",
47
- "./rpc:valueCodecs": "https://libp2p.github.io/js-libp2p/variables/_libp2p_devtools_metrics.valueCodecs.html",
48
- "devToolsMetrics": "https://libp2p.github.io/js-libp2p/functions/_libp2p_devtools_metrics.devToolsMetrics.html",
49
- ".:devToolsMetrics": "https://libp2p.github.io/js-libp2p/functions/_libp2p_devtools_metrics.devToolsMetrics.html"
50
- }