@ircam/comote-helpers 1.0.3 → 1.2.0
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ircam/comote-helpers",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Server component & utilities for the CoMote application",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Benjamin.Matuszewski@ircam.fr",
|
|
@@ -19,11 +19,20 @@
|
|
|
19
19
|
"./*.js": "./src/*.js"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"src"
|
|
22
|
+
"./src/**/*.js"
|
|
23
23
|
],
|
|
24
24
|
"workspaces": [
|
|
25
25
|
".",
|
|
26
26
|
"examples/*",
|
|
27
27
|
"max/CoMote/sources/*"
|
|
28
|
-
]
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"assign-deep": "^1.0.1",
|
|
31
|
+
"clone-deep": "^4.0.1",
|
|
32
|
+
"node-osc": "^9.1.4",
|
|
33
|
+
"qrcode": "^1.5.4",
|
|
34
|
+
"systeminformation": "^5.25.11",
|
|
35
|
+
"utf-8-validate": "^6.0.5",
|
|
36
|
+
"ws": "^8.18.1"
|
|
37
|
+
}
|
|
29
38
|
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import si from 'systeminformation';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {Object} NetworkInterfaces
|
|
5
|
-
* @property {Array.<NetworkInterface>} Interfaces
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @typedef {Object} NetworkInterface
|
|
10
|
-
*
|
|
11
|
-
* @property {string} iface: - identifier eg. 'en0'
|
|
12
|
-
* @property {string} ifaceName - name eg. 'en0'
|
|
13
|
-
* @property {boolean} default - true if default interface (for sending data)
|
|
14
|
-
* @property {string} ip4 - address eg. '192.168.0.1'
|
|
15
|
-
* @property {string} ip4subnet - eg. '255.255.252.0'
|
|
16
|
-
* @property {string} ip6 eg. 'fe80::456:7890:abcd:ef01'
|
|
17
|
-
* @property {string} ip6subnet eg. 'ffff:ffff:ffff:ffff::'
|
|
18
|
-
* @property {string} type eg. 'wireless' or 'wired'
|
|
19
|
-
*
|
|
20
|
-
* @see https://www.npmjs.com/package/systeminformation
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Retrieve information of network interfaces
|
|
25
|
-
* Return `null` if no WiFi connection found.
|
|
26
|
-
*
|
|
27
|
-
* @async
|
|
28
|
-
* @return {NetworkInterfaces|null}
|
|
29
|
-
*/
|
|
30
|
-
export async function getNetworkInterfacesInfos({
|
|
31
|
-
interfaceFilter = (i) => {
|
|
32
|
-
// only IPv4
|
|
33
|
-
// avoid localhost
|
|
34
|
-
return i.ip4
|
|
35
|
-
&& i.ip4 !== '127.0.0.1'
|
|
36
|
-
&& i.ip4 !== 'localhost';
|
|
37
|
-
}
|
|
38
|
-
}= {}) {
|
|
39
|
-
const interfaces = await si.networkInterfaces();
|
|
40
|
-
|
|
41
|
-
if(!interfaces) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if(typeof interfaceFilter !== 'function') {
|
|
46
|
-
return interfaces;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return interfaces.filter(interfaceFilter);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import si from 'systeminformation';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {Object} WifiInfos
|
|
5
|
-
* @property {number} ssid - SSID of the WiFi connection
|
|
6
|
-
* @property {number} ip - Related IP (IPV4)
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Retrieve the SSID and related IP of the first WiFi connection found, return
|
|
11
|
-
* `null` if no WiFi connection found.
|
|
12
|
-
*
|
|
13
|
-
* @async
|
|
14
|
-
* @return {WiFiInfos|null}
|
|
15
|
-
*/
|
|
16
|
-
export async function getWifiInfos() {
|
|
17
|
-
// find first wifi connection
|
|
18
|
-
const wifiConnections = await si.wifiConnections();
|
|
19
|
-
const conn = wifiConnections[0];
|
|
20
|
-
|
|
21
|
-
if (!conn) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// find related interface
|
|
26
|
-
const interfaces = await si.networkInterfaces();
|
|
27
|
-
const int = interfaces.find(int => int.iface === conn.iface);
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
ssid: conn.ssid,
|
|
31
|
-
ip: int.ip4,
|
|
32
|
-
};
|
|
33
|
-
}
|