node-datachannel 0.2.4 → 0.3.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.
- package/.editorconfig +12 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +8 -0
- package/.github/FUNDING.yml +2 -0
- package/.github/workflows/build-linux.yml +3 -3
- package/.github/workflows/build-mac.yml +1 -1
- package/.github/workflows/build-win.yml +4 -4
- package/.github/workflows/lint.yml +22 -0
- package/.prettierrc.js +7 -0
- package/CMakeLists.txt +8 -2
- package/README.md +4 -4
- package/examples/client-server/client-benchmark.js +43 -32
- package/examples/client-server/client-periodic.js +30 -14
- package/examples/client-server/client.js +6 -5
- package/examples/client-server/package-lock.json +183 -44
- package/examples/client-server/signaling-server.js +3 -5
- package/examples/media/media.js +9 -9
- package/lib/datachannel-stream.js +23 -12
- package/lib/index.d.ts +113 -116
- package/lib/index.js +3 -2
- package/node_modules/detect-libc/package.json +1 -0
- package/node_modules/lru-cache/package.json +1 -2
- package/node_modules/minimist/index.js +6 -2
- package/node_modules/minimist/package.json +10 -11
- package/node_modules/minimist/readme.markdown +4 -1
- package/node_modules/minimist/test/proto.js +16 -0
- package/node_modules/node-abi/node_modules/semver/README.md +3 -1
- package/node_modules/node-abi/node_modules/semver/bin/semver.js +19 -9
- package/node_modules/node-abi/node_modules/semver/classes/comparator.js +3 -2
- package/node_modules/node-abi/node_modules/semver/classes/index.js +1 -1
- package/node_modules/node-abi/node_modules/semver/classes/range.js +31 -22
- package/node_modules/node-abi/node_modules/semver/classes/semver.js +1 -1
- package/node_modules/node-abi/node_modules/semver/functions/cmp.js +8 -4
- package/node_modules/node-abi/node_modules/semver/functions/coerce.js +3 -2
- package/node_modules/node-abi/node_modules/semver/functions/inc.js +4 -1
- package/node_modules/node-abi/node_modules/semver/functions/parse.js +1 -1
- package/node_modules/node-abi/node_modules/semver/internal/constants.js +2 -2
- package/node_modules/node-abi/node_modules/semver/internal/identifiers.js +1 -1
- package/node_modules/node-abi/node_modules/semver/internal/parse-options.js +3 -3
- package/node_modules/node-abi/node_modules/semver/internal/re.js +3 -3
- package/node_modules/node-abi/node_modules/semver/package.json +51 -18
- package/node_modules/node-abi/node_modules/semver/ranges/min-version.js +2 -1
- package/node_modules/node-abi/node_modules/semver/ranges/outside.js +1 -1
- package/node_modules/node-abi/node_modules/semver/ranges/simplify.js +15 -12
- package/node_modules/node-abi/node_modules/semver/ranges/subset.js +53 -31
- package/node_modules/node-abi/package.json +1 -0
- package/node_modules/npmlog/node_modules/are-we-there-yet/package.json +10 -10
- package/node_modules/npmlog/package.json +1 -1
- package/node_modules/tar-stream/node_modules/bl/.travis.yml +4 -3
- package/node_modules/tar-stream/node_modules/bl/BufferList.js +1 -1
- package/node_modules/tar-stream/node_modules/bl/package.json +10 -10
- package/node_modules/tar-stream/node_modules/bl/test/test.js +20 -2
- package/node_modules/wide-align/LICENSE +0 -0
- package/node_modules/wide-align/README.md +0 -0
- package/node_modules/wide-align/align.js +0 -0
- package/node_modules/wide-align/package.json +14 -14
- package/package.json +12 -4
- package/src/data-channel-wrapper.cpp +90 -40
- package/src/data-channel-wrapper.h +2 -0
- package/src/media-audio-wrapper.cpp +5 -5
- package/src/media-track-wrapper.cpp +96 -38
- package/src/media-track-wrapper.h +1 -0
- package/src/media-video-wrapper.cpp +5 -5
- package/src/peer-connection-wrapper.cpp +111 -54
- package/test/connectivity.js +22 -21
- package/test/test.js +25 -33
- package/node_modules/node-abi/node_modules/semver/CHANGELOG.md +0 -111
package/test/test.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
1
2
|
const nodeDataChannel = require('../lib/index');
|
|
2
3
|
|
|
3
4
|
describe('Module Definition', () => {
|
|
@@ -12,9 +13,8 @@ describe('Module Definition', () => {
|
|
|
12
13
|
});
|
|
13
14
|
|
|
14
15
|
describe('PeerConnection Classes', () => {
|
|
15
|
-
|
|
16
16
|
test('Create PeerConnection', () => {
|
|
17
|
-
let peer = new nodeDataChannel.PeerConnection(
|
|
17
|
+
let peer = new nodeDataChannel.PeerConnection('Peer', { iceServers: ['stun:stun.l.google.com:19302'] });
|
|
18
18
|
expect(peer).toBeDefined();
|
|
19
19
|
expect(peer.onStateChange).toBeDefined();
|
|
20
20
|
expect(peer.createDataChannel).toBeDefined();
|
|
@@ -23,9 +23,12 @@ describe('PeerConnection Classes', () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
test('Create Data Channel', () => {
|
|
26
|
-
let peer = new nodeDataChannel.PeerConnection(
|
|
27
|
-
let dc = peer.createDataChannel('test');
|
|
26
|
+
let peer = new nodeDataChannel.PeerConnection('Peer', { iceServers: ['stun:stun.l.google.com:19302'] });
|
|
27
|
+
let dc = peer.createDataChannel('test', { protocol: 'test-protocol' });
|
|
28
28
|
expect(dc).toBeDefined();
|
|
29
|
+
expect(dc.getId()).toBeDefined();
|
|
30
|
+
expect(dc.getProtocol()).toBe('test-protocol');
|
|
31
|
+
expect(dc.getLabel()).toBe('test');
|
|
29
32
|
expect(dc.onOpen).toBeDefined();
|
|
30
33
|
expect(dc.onMessage).toBeDefined();
|
|
31
34
|
|
|
@@ -34,13 +37,12 @@ describe('PeerConnection Classes', () => {
|
|
|
34
37
|
});
|
|
35
38
|
});
|
|
36
39
|
|
|
37
|
-
|
|
38
40
|
describe('P2P', () => {
|
|
39
41
|
// Default is 5000 ms but we need more
|
|
40
42
|
jest.setTimeout(30000);
|
|
41
43
|
|
|
42
|
-
let peer1 = new nodeDataChannel.PeerConnection(
|
|
43
|
-
let peer2 = new nodeDataChannel.PeerConnection(
|
|
44
|
+
let peer1 = new nodeDataChannel.PeerConnection('Peer1', { iceServers: ['stun:stun.l.google.com:19302'] });
|
|
45
|
+
let peer2 = new nodeDataChannel.PeerConnection('Peer2', { iceServers: ['stun:stun.l.google.com:19302'] });
|
|
44
46
|
let dc1 = null;
|
|
45
47
|
let dc2 = null;
|
|
46
48
|
|
|
@@ -88,13 +90,13 @@ describe('P2P', () => {
|
|
|
88
90
|
dc2.onMessage((msg) => {
|
|
89
91
|
p2DCMessageMock(msg);
|
|
90
92
|
});
|
|
91
|
-
dc2.sendMessage(
|
|
93
|
+
dc2.sendMessage('Hello From Peer2');
|
|
92
94
|
});
|
|
93
95
|
|
|
94
|
-
dc1 = peer1.createDataChannel(
|
|
96
|
+
dc1 = peer1.createDataChannel('test-p2p');
|
|
95
97
|
dc1.onOpen(() => {
|
|
96
98
|
p1DCMock();
|
|
97
|
-
dc1.sendMessage(
|
|
99
|
+
dc1.sendMessage('Hello From Peer1');
|
|
98
100
|
});
|
|
99
101
|
dc1.onMessage((msg) => {
|
|
100
102
|
p1DCMessageMock(msg);
|
|
@@ -106,15 +108,6 @@ describe('P2P', () => {
|
|
|
106
108
|
dc2.close();
|
|
107
109
|
peer1.close();
|
|
108
110
|
peer2.close();
|
|
109
|
-
|
|
110
|
-
// Fee memory
|
|
111
|
-
dc1 = null;
|
|
112
|
-
dc2 = null;
|
|
113
|
-
peer1 = null;
|
|
114
|
-
peer2 = null;
|
|
115
|
-
|
|
116
|
-
// Cleanup Threads
|
|
117
|
-
nodeDataChannel.cleanup();
|
|
118
111
|
}, 10 * 1000);
|
|
119
112
|
|
|
120
113
|
setTimeout(() => {
|
|
@@ -135,15 +128,14 @@ describe('P2P', () => {
|
|
|
135
128
|
// DataChannel
|
|
136
129
|
expect(p1DCMock.mock.calls.length).toBe(1);
|
|
137
130
|
expect(p1DCMessageMock.mock.calls.length).toBe(1);
|
|
138
|
-
expect(p1DCMessageMock.mock.calls[0][0]).toEqual(
|
|
131
|
+
expect(p1DCMessageMock.mock.calls[0][0]).toEqual('Hello From Peer2');
|
|
139
132
|
expect(p2DCMock.mock.calls.length).toBe(1);
|
|
140
133
|
|
|
141
134
|
expect(p2DCMessageMock.mock.calls.length).toBe(1);
|
|
142
|
-
expect(p2DCMessageMock.mock.calls[0][0]).toEqual(
|
|
135
|
+
expect(p2DCMessageMock.mock.calls[0][0]).toEqual('Hello From Peer1');
|
|
143
136
|
|
|
144
137
|
done();
|
|
145
138
|
}, 12 * 1000);
|
|
146
|
-
|
|
147
139
|
});
|
|
148
140
|
});
|
|
149
141
|
|
|
@@ -158,14 +150,11 @@ function waitForGathering(peer) {
|
|
|
158
150
|
}
|
|
159
151
|
|
|
160
152
|
describe('DataChannel streams', () => {
|
|
161
|
-
|
|
162
153
|
test('can build an echo pipeline', async () => {
|
|
163
|
-
let clientPeer = new nodeDataChannel.PeerConnection(
|
|
164
|
-
let echoPeer = new nodeDataChannel.PeerConnection(
|
|
154
|
+
let clientPeer = new nodeDataChannel.PeerConnection('Client', { iceServers: [] });
|
|
155
|
+
let echoPeer = new nodeDataChannel.PeerConnection('Client', { iceServers: [] });
|
|
165
156
|
|
|
166
|
-
const echoStream = new nodeDataChannel.DataChannelStream(
|
|
167
|
-
echoPeer.createDataChannel("echo-channel")
|
|
168
|
-
);
|
|
157
|
+
const echoStream = new nodeDataChannel.DataChannelStream(echoPeer.createDataChannel('echo-channel'));
|
|
169
158
|
echoStream.pipe(echoStream); // Echo all received data back to the client
|
|
170
159
|
|
|
171
160
|
await waitForGathering(echoPeer);
|
|
@@ -180,14 +169,17 @@ describe('DataChannel streams', () => {
|
|
|
180
169
|
const clientChannel = await new Promise((resolve) => clientPeer.onDataChannel(resolve));
|
|
181
170
|
|
|
182
171
|
const clientResponsePromise = new Promise((resolve) => clientChannel.onMessage(resolve));
|
|
183
|
-
clientChannel.sendMessage(
|
|
172
|
+
clientChannel.sendMessage('test message');
|
|
184
173
|
|
|
185
|
-
expect(await clientResponsePromise).toBe(
|
|
174
|
+
expect(await clientResponsePromise).toBe('test message');
|
|
186
175
|
|
|
187
176
|
clientChannel.close();
|
|
188
|
-
await new Promise((resolve) => echoStream.on('end', resolve));
|
|
189
|
-
|
|
190
177
|
clientPeer.close();
|
|
191
178
|
echoPeer.close();
|
|
192
179
|
});
|
|
193
|
-
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
afterAll(() => {
|
|
183
|
+
// Properly cleanup so Jest does not complain about asynchronous operations that weren't stopped.
|
|
184
|
+
nodeDataChannel.cleanup();
|
|
185
|
+
});
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
# changes log
|
|
2
|
-
|
|
3
|
-
## 7.3.0
|
|
4
|
-
|
|
5
|
-
* Add `subset(r1, r2)` method to determine if `r1` range is entirely
|
|
6
|
-
contained by `r2` range.
|
|
7
|
-
|
|
8
|
-
## 7.2.3
|
|
9
|
-
|
|
10
|
-
* Fix handling of `includePrelease` mode where version ranges like `1.0.0 -
|
|
11
|
-
2.0.0` would include `3.0.0-pre` and not `1.0.0-pre`.
|
|
12
|
-
|
|
13
|
-
## 7.2.2
|
|
14
|
-
|
|
15
|
-
* Fix bug where `2.0.0-pre` would be included in `^1.0.0` if
|
|
16
|
-
`includePrerelease` was set to true.
|
|
17
|
-
|
|
18
|
-
## 7.2.0
|
|
19
|
-
|
|
20
|
-
* Add `simplifyRange` method to attempt to generate a more human-readable
|
|
21
|
-
range expression that is equivalent to a supplied range, for a given set
|
|
22
|
-
of versions.
|
|
23
|
-
|
|
24
|
-
## 7.1.2
|
|
25
|
-
|
|
26
|
-
* Remove fancy lazy-loading logic, as it was causing problems for webpack
|
|
27
|
-
users.
|
|
28
|
-
|
|
29
|
-
## 7.1.0
|
|
30
|
-
|
|
31
|
-
* Add `require('semver/preload')` to load the entire module without using
|
|
32
|
-
lazy getter methods.
|
|
33
|
-
|
|
34
|
-
## 7.0.0
|
|
35
|
-
|
|
36
|
-
* Refactor module into separate files for better tree-shaking
|
|
37
|
-
* Drop support for very old node versions, use const/let, `=>` functions,
|
|
38
|
-
and classes.
|
|
39
|
-
|
|
40
|
-
## 6.3.0
|
|
41
|
-
|
|
42
|
-
* Expose the token enum on the exports
|
|
43
|
-
|
|
44
|
-
## 6.2.0
|
|
45
|
-
|
|
46
|
-
* Coerce numbers to strings when passed to semver.coerce()
|
|
47
|
-
* Add `rtl` option to coerce from right to left
|
|
48
|
-
|
|
49
|
-
## 6.1.3
|
|
50
|
-
|
|
51
|
-
* Handle X-ranges properly in includePrerelease mode
|
|
52
|
-
|
|
53
|
-
## 6.1.2
|
|
54
|
-
|
|
55
|
-
* Do not throw when testing invalid version strings
|
|
56
|
-
|
|
57
|
-
## 6.1.1
|
|
58
|
-
|
|
59
|
-
* Add options support for semver.coerce()
|
|
60
|
-
* Handle undefined version passed to Range.test
|
|
61
|
-
|
|
62
|
-
## 6.1.0
|
|
63
|
-
|
|
64
|
-
* Add semver.compareBuild function
|
|
65
|
-
* Support `*` in semver.intersects
|
|
66
|
-
|
|
67
|
-
## 6.0
|
|
68
|
-
|
|
69
|
-
* Fix `intersects` logic.
|
|
70
|
-
|
|
71
|
-
This is technically a bug fix, but since it is also a change to behavior
|
|
72
|
-
that may require users updating their code, it is marked as a major
|
|
73
|
-
version increment.
|
|
74
|
-
|
|
75
|
-
## 5.7
|
|
76
|
-
|
|
77
|
-
* Add `minVersion` method
|
|
78
|
-
|
|
79
|
-
## 5.6
|
|
80
|
-
|
|
81
|
-
* Move boolean `loose` param to an options object, with
|
|
82
|
-
backwards-compatibility protection.
|
|
83
|
-
* Add ability to opt out of special prerelease version handling with
|
|
84
|
-
the `includePrerelease` option flag.
|
|
85
|
-
|
|
86
|
-
## 5.5
|
|
87
|
-
|
|
88
|
-
* Add version coercion capabilities
|
|
89
|
-
|
|
90
|
-
## 5.4
|
|
91
|
-
|
|
92
|
-
* Add intersection checking
|
|
93
|
-
|
|
94
|
-
## 5.3
|
|
95
|
-
|
|
96
|
-
* Add `minSatisfying` method
|
|
97
|
-
|
|
98
|
-
## 5.2
|
|
99
|
-
|
|
100
|
-
* Add `prerelease(v)` that returns prerelease components
|
|
101
|
-
|
|
102
|
-
## 5.1
|
|
103
|
-
|
|
104
|
-
* Add Backus-Naur for ranges
|
|
105
|
-
* Remove excessively cute inspection methods
|
|
106
|
-
|
|
107
|
-
## 5.0
|
|
108
|
-
|
|
109
|
-
* Remove AMD/Browserified build artifacts
|
|
110
|
-
* Fix ltr and gtr when using the `*` range
|
|
111
|
-
* Fix for range `*` with a prerelease identifier
|