node-datachannel 0.9.1 → 0.10.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.
@@ -14,98 +14,91 @@ jobs:
14
14
  runs-on: ubuntu-20.04
15
15
  strategy:
16
16
  matrix:
17
- node-version: [ 16.x]
17
+ node-version: [16]
18
+ arch: [amd64, arm64, arm]
19
+ platform: [debian, alpine]
20
+ include:
21
+ # Set baselines per platform
22
+ - triple: "alpine-linux-musl"
23
+ platform: alpine
24
+ version: 3.16
25
+ libc: musl
26
+ gcc_install: clang lld
27
+ gcc: clang
28
+ # libc is intentionally not set here, as prebuild-install requires libc to not be set for glibc builds
29
+ - triple: "linux-gnu"
30
+ platform: debian
31
+ version: bullseye
32
+ # Set baselines per architecture
33
+ - triple_arch: x86_64
34
+ node_arch: x64
35
+ arch: amd64
36
+ - triple_arch: armv7
37
+ node_arch: arm
38
+ triple_postfix: eabihf
39
+ arch: arm
40
+ flags: -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -fPIC
41
+ - triple_arch: aarch64
42
+ node_arch: arm64
43
+ arch: arm64
44
+ flags: -march=armv8-a -fPIC
45
+ # Set edge case overrides for specific platform + architecture
46
+ # also define gcc commands for each architecture
47
+ - arch: amd64
48
+ platform: debian
49
+ gcc_install: gcc g++
50
+ gcc: gcc
51
+ - arch: arm64
52
+ platform: debian
53
+ gcc_install: gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
54
+ gcc: aarch64-linux-gnu-gcc
55
+ # debian uses the triple `arm-linux-gnueabihf` instead of alpine's `armv7-alpine-linux-musleabihf`
56
+ # because of this, we explicitly override triple_arch for debian arm
57
+ - triple_arch: arm
58
+ arch: arm
59
+ platform: debian
60
+ gcc_install: gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
61
+ gcc: arm-linux-gnueabihf-gcc
18
62
 
19
63
  steps:
20
- - uses: actions/checkout@v2
64
+ - uses: actions/checkout@v4
21
65
  - name: Use Node.js ${{ matrix.node-version }}
22
- uses: actions/setup-node@v1
66
+ uses: actions/setup-node@v4
23
67
  with:
24
68
  node-version: ${{ matrix.node-version }}
25
- - name: Build
26
- run: npm install --build-from-source
69
+ - name: Install node dependencies
70
+ run: npm install --ignore-scripts
27
71
  env:
28
72
  CI: true
29
- - name: Test
30
- run: npm run test
31
- env:
32
- CI: true
33
- - name: Upload
34
- run: node_modules/.bin/prebuild -r napi --upload -u ${{ secrets.GITHUB_TOKEN }}
35
- env:
36
- CI: true
37
-
38
- build-linux-armv7:
39
- runs-on: ubuntu-20.04
40
-
41
- strategy:
42
- matrix:
43
- node-version: [16.x]
44
- steps:
45
- - uses: actions/checkout@v2
46
- - name: Prepare Cross Compile
47
- run: |
48
- sudo apt update
49
- sudo apt install -y g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf
50
- mkdir sysroot && cd sysroot
51
- wget https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/ef5c4f84bcafb7a3796d36bb1db7826317dde51c/debian_sid_arm_sysroot.tar.xz
52
- tar xf debian_sid_arm_sysroot.tar.xz
53
- echo "ARM_SYSROOT=$(pwd)" >> $GITHUB_ENV
54
- ls -l
55
- - name: Use Node.js ${{ matrix.node-version }}
56
- uses: actions/setup-node@v1
73
+ - if: matrix.arch != 'amd64'
74
+ name: Set up QEMU
75
+ uses: docker/setup-qemu-action@v3
57
76
  with:
58
- node-version: ${{ matrix.node-version }}
59
- - name: Build & Upload
77
+ platforms: ${{ matrix.arch }}
78
+ - name: Install system dependencies
60
79
  run: |
61
- npm install --ignore-scripts
62
- node_modules/.bin/prebuild -r napi --backend cmake-js --arch arm --upload -u ${{ secrets.GITHUB_TOKEN }} -- --CDCMAKE_TOOLCHAIN_FILE:FILEPATH=./cmake/toolchain/armv7.cmake
80
+ sudo apt update
81
+ sudo apt install -y podman ninja-build ${{ matrix.gcc_install }}
82
+ - name: List installed libc
83
+ run: apt list --installed | grep libc6-dev
84
+ - name: Build sysroot
85
+ run: sudo podman build --isolation=chroot -t ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }} ./build-containers --file Dockerfile.${{ matrix.platform }} --platform linux/${{ matrix.arch }} --build-arg="version=${{ matrix.version }}" --build-arg="node_version=${{ matrix.node-version }}"
86
+ - name: Mount sysroot
87
+ id: sysroot
88
+ run: echo "sysroot=$(sudo podman image mount ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }})" >> $GITHUB_OUTPUT
89
+ - name: Build
90
+ run: sudo --preserve-env=SYSROOT,TRIPLE,COMPILER_FLAGS,LIBC,GCC,CI,PATH node_modules/.bin/prebuild --arch ${{ matrix.node_arch }} -r napi --backend cmake-js -- --CDCMAKE_TOOLCHAIN_FILE:FILEPATH=./cmake/toolchain/ci.cmake
63
91
  env:
92
+ SYSROOT: ${{ steps.sysroot.outputs.sysroot }}
93
+ TRIPLE: ${{ matrix.triple_arch }}-${{ matrix.triple }}${{ matrix.triple_postfix }}
94
+ COMPILER_FLAGS: ${{ matrix.flags }}
95
+ LIBC: ${{ matrix.libc }}
96
+ GCC: ${{ matrix.gcc }}
64
97
  CI: true
65
-
66
- build-linux-arm64:
67
- runs-on: ubuntu-20.04
68
-
69
- strategy:
70
- matrix:
71
- node-version: [16.x]
72
- steps:
73
- - uses: actions/checkout@v2
74
- - name: Prepare Cross Compile
75
- run: |
76
- sudo apt update
77
- sudo apt install -y g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
78
- mkdir sysroot && cd sysroot
79
- wget https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/41a6c8dec4c4304d6509e30cbaf9218dffb4438e/debian_bullseye_arm64_sysroot.tar.xz
80
- tar xf debian_bullseye_arm64_sysroot.tar.xz
81
- echo "ARM64_SYSROOT=$(pwd)" >> $GITHUB_ENV
82
- ls -l
83
- - name: Use Node.js ${{ matrix.node-version }}
84
- uses: actions/setup-node@v1
85
- with:
86
- node-version: ${{ matrix.node-version }}
87
- - name: Build & Upload
88
- run: |
89
- npm install --ignore-scripts
90
- node_modules/.bin/prebuild -r napi --backend cmake-js --arch arm64 --upload -u ${{ secrets.GITHUB_TOKEN }} -- --CDCMAKE_TOOLCHAIN_FILE:FILEPATH=./cmake/toolchain/arm64.cmake
98
+ - name: Test
99
+ run: sudo podman run --rm -v $(pwd):/usr/app/ -e CI=true --platform linux/${{ matrix.arch }} -t ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }} npm run test
100
+ - name: Upload
101
+ run: sudo --preserve-env=CI,LIBC node_modules/.bin/prebuild --arch ${{ matrix.node_arch }} -r napi --upload -u ${{ secrets.GITHUB_TOKEN }}
91
102
  env:
103
+ LIBC: ${{ matrix.libc }}
92
104
  CI: true
93
-
94
- # npm-publish:
95
- # needs: [build-linux, build-linux-armv7, build-linux-arm64]
96
- # name: npm-publish
97
- # runs-on: ubuntu-latest
98
- # steps:
99
- # - name: Checkout repository
100
- # uses: actions/checkout@v2
101
- # - name: Set up Node.js
102
- # uses: actions/setup-node@v1
103
- # with:
104
- # node-version: 16.x
105
- # registry-url: "https://registry.npmjs.org"
106
- # - name: Publish
107
- # run: |
108
- # npm install
109
- # npm publish
110
- # env:
111
- # NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
package/API.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # API
2
2
 
3
- ## PeerConnection Class
3
+ ## PeerConnection Class
4
4
 
5
5
  **Constructor**
6
6
 
7
7
  let pc = new PeerConnection(peerName[,options])
8
- - peerName `<string>` Peer name to use for logs etc..
9
- - options `<Object>` WebRTC Config Options
8
+
9
+ - peerName `<string>` Peer name to use for logs etc..
10
+ - options `<Object>` WebRTC Config Options
11
+
10
12
  ```
11
13
  export interface RtcConfig {
12
14
  iceServers: (string | IceServer)[];
@@ -57,6 +59,7 @@ Close Peer Connection & Clear all callbacks
57
59
  **setRemoteDescription: (sdp: string, type: DescriptionType) => void**
58
60
 
59
61
  Set Remote Description
62
+
60
63
  ```
61
64
  export const enum DescriptionType {
62
65
  Unspec = 'Unspec',
@@ -72,29 +75,21 @@ Add remote candidate info
72
75
  **createDataChannel: (label: string, config?: DataChannelInitConfig) => DataChannel**
73
76
 
74
77
  Create new data-channel
75
- * label `<string>` Data channel name
76
- * config `<Object>` Data channel options
78
+
79
+ - label `<string>` Data channel name
80
+ - config `<Object>` Data channel options
81
+
77
82
  ```
78
83
  export interface DataChannelInitConfig {
79
84
  protocol?: string;
80
85
  negotiated?: boolean;
81
86
  id?: number;
82
- ordered?: boolean;
83
- maxPacketLifeTime?: number;
84
- maxRetransmits?: number;
85
-
86
- // Deprecated, use ordered, maxPacketLifeTime, and maxRetransmits
87
- reliability?: {
88
- type?: ReliabilityType;
89
- unordered?: boolean;
90
- rexmit?: number;
91
- }
92
- }
93
-
94
- export const enum ReliabilityType {
95
- Reliable = 0, Rexmit = 1, Timed = 2
87
+ unordered?: boolean; // Reliability
88
+ maxPacketLifeTime?: number; // Reliability
89
+ maxRetransmits?: number; // Reliability
96
90
  }
97
91
  ```
92
+
98
93
  **state: () => string**
99
94
 
100
95
  Get current state
@@ -110,6 +105,7 @@ Get current gathering state
110
105
  **onLocalDescription: (cb: (sdp: string, type: DescriptionType) => void) => void**
111
106
 
112
107
  Local Description Callback
108
+
113
109
  ```
114
110
  export const enum DescriptionType {
115
111
  Unspec = 'Unspec',
@@ -153,6 +149,7 @@ Get rtt stat
153
149
  **getSelectedCandidatePair: () => { local: SelectedCandidateInfo, remote: SelectedCandidateInfo }**
154
150
 
155
151
  Get info about selected candidate pair
152
+
156
153
  ```
157
154
  export interface SelectedCandidateInfo {
158
155
  address: string;
@@ -162,7 +159,7 @@ export interface SelectedCandidateInfo {
162
159
  }
163
160
  ```
164
161
 
165
- ## DataChannel Class
162
+ ## DataChannel Class
166
163
 
167
164
  > You can create a new Datachannel instance by calling `PeerConnection.createDataChannel` function.
168
165
 
package/CMakeLists.txt CHANGED
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15)
2
2
  cmake_policy(SET CMP0091 NEW)
3
3
  cmake_policy(SET CMP0042 NEW)
4
4
 
5
- project(node_datachannel VERSION 0.9.1)
5
+ project(node_datachannel VERSION 0.10.0)
6
6
 
7
7
  # -Dnapi_build_version=8
8
8
  add_definitions(-DNAPI_VERSION=8)
@@ -29,7 +29,7 @@ include(FetchContent)
29
29
  FetchContent_Declare(
30
30
  libdatachannel
31
31
  GIT_REPOSITORY https://github.com/paullouisageneau/libdatachannel.git
32
- GIT_TAG "v0.21.0"
32
+ GIT_TAG "v0.21.1"
33
33
  )
34
34
 
35
35
  option(NO_MEDIA "Disable media transport support in libdatachannel" OFF)
package/README.md CHANGED
@@ -22,15 +22,11 @@ npm install node-datachannel
22
22
 
23
23
  `node-datachannel` targets N-API version 8 and supports NodeJS v16 and above. It is tested on Linux, Windows and MacOS. For N-API compatibility please check [here](https://nodejs.org/api/n-api.html#n_api_n_api_version_matrix).
24
24
 
25
- | | Linux-x64 | Linux-armv7 | Linux-arm64(1) | Windows-x86 | Windows-x64 | Mac (M1 + x64) |
26
- | -------- | :-------: | :---------: | :------------: | :---------: | :---------: | :------------: |
27
- | Node V16 | + | + | + | + | + | + |
28
- | Node V17 | + | + | + | + | + | + |
29
- | Node V18 | + | + | + | + | + | + |
30
- | Node V19 | + | + | + | + | + | + |
31
- | Node V20 | + | + | + | + | + | + |
32
-
33
- 1. Please note that; For Linux-arm64 platform we need OpenSSL to be installed locally.
25
+ | | Linux [x64,armv7,arm64] (1) | Windows [x86,x64] | Mac [M1,x64] |
26
+ | ----------------------- | :-------------------------: | :---------------: | :----------: |
27
+ | NAPI V8 (>= NodeJS V16) | + | + | + |
28
+
29
+ **(1)** For Linux musl + libc
34
30
 
35
31
  ## Electron
36
32
 
@@ -0,0 +1,6 @@
1
+ ARG version=3.16
2
+ ARG node_version=16
3
+ FROM node:${node_version}-alpine${version}
4
+ RUN apk add build-base openssl-libs-static openssl-dev
5
+
6
+ WORKDIR /usr/app/
@@ -0,0 +1,7 @@
1
+ ARG version=bullseye
2
+ ARG node_version=16
3
+ FROM node:${node_version}-${version}
4
+ RUN apt update
5
+ RUN apt install -y build-essential libssl-dev
6
+
7
+ WORKDIR /usr/app/
@@ -0,0 +1,23 @@
1
+ set(CMAKE_SYSTEM_NAME Linux)
2
+ set(triple $ENV{TRIPLE})
3
+
4
+ # use clang and lld
5
+ set(CMAKE_C_COMPILER $ENV{GCC})
6
+ set(CMAKE_CXX_COMPILER $ENV{GCC})
7
+ if (CMAKE_C_COMPILER MATCHES clang)
8
+ add_link_options("-fuse-ld=lld")
9
+ endif()
10
+
11
+ set(CMAKE_SYSROOT "$ENV{SYSROOT}")
12
+ message(STATUS "Using sysroot: ${CMAKE_SYSROOT}")
13
+
14
+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
15
+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
16
+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
17
+
18
+ set(CMAKE_C_COMPILER_TARGET ${triple})
19
+ set(CMAKE_CXX_COMPILER_TARGET ${triple})
20
+ message(STATUS "Compiling for: ${triple}")
21
+
22
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} $ENV{COMPILER_FLAGS}")
23
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{COMPILER_FLAGS}")
@@ -139,9 +139,9 @@
139
139
  }
140
140
  },
141
141
  "node_modules/ws": {
142
- "version": "7.5.9",
143
- "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
144
- "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
142
+ "version": "7.5.10",
143
+ "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
144
+ "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
145
145
  "engines": {
146
146
  "node": ">=8.3.0"
147
147
  },
@@ -283,9 +283,9 @@
283
283
  }
284
284
  },
285
285
  "ws": {
286
- "version": "7.5.9",
287
- "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
288
- "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
286
+ "version": "7.5.10",
287
+ "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
288
+ "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
289
289
  "requires": {}
290
290
  },
291
291
  "y18n": {