@mertushka/webrtc-node 0.1.0-alpha.0 → 0.1.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/README.md CHANGED
@@ -1,103 +1,115 @@
1
- <h1 align="center">@mertushka/webrtc-node</h1>
1
+ <h1 align="center">webrtc-node</h1>
2
2
 
3
3
  <p align="center">
4
- W3C-style RTCPeerConnection and RTCDataChannel for Node.js, backed by
4
+ WebRTC data channels for Node.js, with the browser API shape developers
5
+ already know.
6
+ </p>
7
+
8
+ <p align="center">
9
+ Backed by
5
10
  <a href="https://github.com/paullouisageneau/libdatachannel">libdatachannel</a>
6
- and checked against selected web-platform-tests.
11
+ and validated with 620 selected Web Platform Tests subtests.
7
12
  </p>
8
13
 
9
14
  <p align="center">
10
15
  <a href="https://github.com/mertushka/webrtc-node/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/mertushka/webrtc-node/actions/workflows/ci.yml/badge.svg"></a>
16
+ <a href="https://www.npmjs.com/package/@mertushka/webrtc-node"><img alt="npm" src="https://img.shields.io/npm/v/@mertushka/webrtc-node"></a>
11
17
  <img alt="Node.js" src="https://img.shields.io/badge/node-%3E%3D20-339933">
18
+ <img alt="WPT" src="https://img.shields.io/badge/WPT-620%20selected%20subtests-4c1">
12
19
  <img alt="Native API" src="https://img.shields.io/badge/native-Node--API-blue">
13
20
  <img alt="License" src="https://img.shields.io/badge/license-MPL--2.0-orange">
14
21
  </p>
15
22
 
16
- > Experimental WebRTC data-channel profile for Node.js. The exposed scope is
17
- > `RTCPeerConnection` plus `RTCDataChannel`; media APIs are intentionally absent.
18
-
19
- ## Overview
20
-
21
- `@mertushka/webrtc-node` provides browser-compatible peer-connection and
22
- data-channel APIs for Node.js while delegating ICE, DTLS, SCTP, and
23
- data-channel transport to `libdatachannel`.
24
-
25
- The supported API surface focuses on:
26
-
27
- - `RTCPeerConnection`
28
- - `RTCDataChannel`
29
- - session descriptions and ICE candidates
30
- - DOM-style events, promises, and WebRTC-shaped errors
31
- - selected WPT conformance for data-channel behavior
32
-
33
- Media tracks, transceivers, RTP sender/receiver APIs, stats, DTMF, and capture
34
- devices are not part of this package.
35
-
36
- ## Installation
37
-
38
- The package is not published to npm yet. Releases are planned to publish
39
- Node-API prebuilt binaries as GitHub Release assets. The npm package stays a
40
- source package; its install script downloads the one matching binary for the
41
- current platform, then falls back to a `cmake-js` source build if none is
42
- available.
43
-
44
- Build from source today:
23
+ `webrtc-node` provides W3C-style `RTCPeerConnection` and
24
+ `RTCDataChannel` APIs for Node.js. It focuses on data channels, uses
25
+ `libdatachannel` for transport, and ships through ABI-stable Node-API native
26
+ bindings.
45
27
 
46
28
  ```sh
47
- git clone https://github.com/mertushka/webrtc-node.git
48
- cd webrtc-node
49
- npm ci
50
- npm run build
29
+ npm install @mertushka/webrtc-node
51
30
  ```
52
31
 
53
- Requirements:
32
+ ## Highlights
54
33
 
55
- - Node.js 20 or newer
56
- - CMake and a C++17 compiler
57
- - OpenSSL development libraries
34
+ - **Browser-compatible surface:** W3C-style `RTCPeerConnection`,
35
+ `RTCDataChannel`, session descriptions, ICE candidates, DOM-style events, and
36
+ WebRTC-shaped errors.
37
+ - **Conformance-led development:** 620 selected WPT subtests cover the supported
38
+ data-channel profile across Linux, macOS, and Windows.
39
+ - **Small native core:** ICE, DTLS, SCTP, and data-channel transport come from
40
+ pinned `libdatachannel`, exposed through an ABI-stable Node-API addon.
41
+ - **Ready for TypeScript:** declarations are included and checked with the
42
+ runtime API surface.
43
+ - **Focused by design:** data channels first; no media tracks, transceivers,
44
+ stats, DTMF, or browser device APIs.
58
45
 
59
- Planned prebuilt targets:
46
+ ## Performance Snapshot
60
47
 
61
- - Linux x64 glibc
62
- - Linux x64 musl
63
- - macOS x64 and arm64
64
- - Windows x64
48
+ Local benchmark snapshots show this package ahead on binary throughput and
49
+ object operation rates. Benchmarks are environment-sensitive; treat them as
50
+ directional rather than a substitute for testing your workload.
65
51
 
66
- ## Example
52
+ | Metric | `webrtc-node` | `node-datachannel` | `@roamhq/wrtc` |
53
+ | --- | ---: | ---: | ---: |
54
+ | Linux binary 8 KiB x1000 | 39.9 MB/s | 30.4 MB/s | 27.4 MB/s |
55
+ | Linux construct+close PC | 53k ops/s | 3.2k ops/s | 200 ops/s |
56
+ | Linux negotiated DC create+close | 2.2k ops/s | 974 ops/s | 173 ops/s |
67
57
 
68
- Run the bundled data-channel example after building:
69
-
70
- ```sh
71
- node examples/datachannel.js
72
- ```
58
+ ## Usage
73
59
 
74
60
  ```js
75
61
  const { RTCPeerConnection } = require("@mertushka/webrtc-node");
76
62
 
77
- const pc = new RTCPeerConnection();
63
+ const pc = new RTCPeerConnection({ iceServers: [] });
78
64
  const channel = pc.createDataChannel("events");
79
65
 
80
66
  channel.addEventListener("open", () => {
81
67
  channel.send("hello from Node");
82
68
  });
69
+
70
+ channel.addEventListener("message", (event) => {
71
+ console.log(event.data);
72
+ });
83
73
  ```
84
74
 
85
75
  See [examples/datachannel.js](examples/datachannel.js) for a complete local
86
76
  offer/answer exchange.
87
77
 
88
- ## Project Status
78
+ ## Installation Details
79
+
80
+ The npm package downloads the matching Node-API prebuilt binary when available,
81
+ then falls back to a `cmake-js` source build. Published prebuild targets are
82
+ Linux x64 glibc, Linux x64 musl, macOS x64, macOS arm64, and Windows x64.
83
+
84
+ Source builds require Node.js 20 or newer, CMake, a C++17 compiler, and OpenSSL
85
+ development libraries.
86
+
87
+ Run the example from a checkout:
88
+
89
+ ```sh
90
+ npm run example:datachannel
91
+ ```
89
92
 
90
- | Area | Status |
93
+ ## Conformance
94
+
95
+ The compatibility target is the selected WPT suite tracked in
96
+ [wpt-manifest.json](wpt-manifest.json). The current selected suite contains
97
+ **620 expected-passing subtests** across the Node 20, 22, and 24 CI matrix on
98
+ Linux, macOS, and Windows.
99
+
100
+ | Area | Coverage |
91
101
  | --- | --- |
92
- | Native binding | Node-API/node-addon-api, no direct V8 or NAN APIs |
93
- | Transport backend | pinned `libdatachannel` via CMake `FetchContent` or local checkout |
94
- | Public API | W3C-style JavaScript facade with TypeScript declarations |
95
- | Conformance target | selected WPT subset tracked in `wpt-manifest.json` |
96
- | Current scope | `RTCPeerConnection` and `RTCDataChannel` data-channel profile |
102
+ | PeerConnection | construction, descriptions, ICE candidates, signaling/ICE/connection state, close |
103
+ | DataChannel | id, label, readyState, ordered, negotiated, protocol, binaryType, send, message, open, close, error |
104
+ | Events and errors | DOM-style events, `RTCDataChannelEvent`, ICE events, DOMException-shaped failures |
105
+ | Excluded by design | media tracks, transceivers, RTP sender/receiver APIs, stats, DTMF, browser devices |
97
106
 
98
107
  Intentional WebRTC divergences are documented in
99
108
  [docs/divergences.md](docs/divergences.md).
100
109
 
110
+ This is not a claim of full browser WebRTC compliance. It is a documented
111
+ data-channel profile with WPT evidence.
112
+
101
113
  ## Development
102
114
 
103
115
  Common local checks:
@@ -115,10 +127,6 @@ npm run wpt:smoke
115
127
  npm run wpt:smoke:check
116
128
  ```
117
129
 
118
- `npm run pack:check` verifies the npm source artifact contains the native
119
- sources, facade, declarations, docs, and examples while excluding local caches,
120
- CI output, and release prebuild artifacts.
121
-
122
130
  Run selected WPT tests:
123
131
 
124
132
  ```sh
@@ -132,6 +140,7 @@ and pull requests. The full selected WPT matrix lives in the separate
132
140
  `Conformance` workflow for manual, scheduled, and version-tagged release checks.
133
141
 
134
142
  Use `npm run format` to apply Biome formatting before opening a pull request.
143
+ `npm run pack:check` verifies the npm source artifact.
135
144
 
136
145
  More details:
137
146
 
@@ -139,22 +148,6 @@ More details:
139
148
  - [docs/conformance.md](docs/conformance.md)
140
149
  - [docs/architecture.md](docs/architecture.md)
141
150
 
142
- ## Repository Layout
143
-
144
- ```text
145
- lib/ JavaScript WebRTC facade
146
- src/native/ Node-API addon
147
- examples/ runnable examples
148
- test/ focused node:test coverage
149
- scripts/ build, API, WPT, and CI utilities
150
- docs/ architecture, conformance, and design notes
151
- wpt-manifest.json selected WPT scope
152
- index.d.ts TypeScript declarations
153
- ```
154
-
155
- Local `build/`, `node_modules/`, `libdatachannel/`, `wpt/`, and
156
- `ci-artifacts/` directories are ignored development caches.
157
-
158
151
  ## Contributing
159
152
 
160
153
  Read [CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request. Public
@@ -4,6 +4,12 @@ The compatibility target is the selected WPT subset in `wpt-manifest.json`.
4
4
  This project targets the WebRTC data-channel profile exposed through
5
5
  `RTCPeerConnection` and `RTCDataChannel`.
6
6
 
7
+ The current selected suite contains **620 expected-passing WPT subtests**. CI
8
+ validates this suite on Linux, macOS, and Windows across Node 20, 22, and 24 in
9
+ the Conformance workflow. Ordinary push and pull-request CI runs a faster WPT
10
+ smoke check; release readiness should be judged from the full Conformance
11
+ workflow.
12
+
7
13
  ## Selected Scope
8
14
 
9
15
  Expected-pass coverage currently includes:
@@ -20,6 +26,10 @@ Out-of-scope WPT areas are grouped in the manifest as `notApplicable`,
20
26
  `needsShim`, or `expectedFail`. Media and RTP APIs are outside this package's
21
27
  public scope.
22
28
 
29
+ This project should not be described as fully browser/WebRTC compliant. The
30
+ supported claim is: W3C-style peer-connection and data-channel behavior for
31
+ Node.js, backed by a selected WPT conformance suite.
32
+
23
33
  ## Running WPT
24
34
 
25
35
  ```sh
@@ -104,13 +104,24 @@ Publishing uses npm trusted publishing with GitHub Actions OIDC, not an
104
104
  `mertushka/webrtc-node`, workflow filename `release.yml`, and environment `npm`
105
105
  if the GitHub release environment is kept.
106
106
 
107
+ The `Published Install` workflow runs after a successful `Release` workflow or
108
+ by manual dispatch. It installs the published npm package on Linux glibc, Linux
109
+ musl, macOS x64, macOS arm64, and Windows x64, then verifies both CommonJS and
110
+ ESM imports. It sets `WEBRTC_NODE_PREBUILD_ONLY=1` so missing or broken release
111
+ assets fail instead of compiling from source.
112
+
107
113
  Manual `workflow_dispatch` releases expect a GitHub Release named
108
114
  `v<package.json version>` to already exist, because prebuilt archives are
109
115
  uploaded as release assets before `npm publish` runs.
110
116
 
117
+ If a release asset needs to be rebuilt for an already-published npm version, run
118
+ the `Release` workflow manually with `publish_npm` disabled. The workflow still
119
+ builds and uploads prebuild assets with `--clobber`, but skips `npm publish`.
120
+
111
121
  Supported release targets are:
112
122
 
113
- - `linux-x64-glibc`
123
+ - `linux-x64-glibc` built in a Debian Bullseye container for an older glibc
124
+ baseline
114
125
  - `linux-x64-musl`
115
126
  - `darwin-x64`
116
127
  - `darwin-arm64`
@@ -118,7 +129,8 @@ Supported release targets are:
118
129
 
119
130
  Use `WEBRTC_NODE_NATIVE_PATH=/absolute/path/to/webrtc_node.node` to test a
120
131
  specific local native binary. Use `npm install --build-from-source` to force the
121
- install script to compile with `cmake-js`.
132
+ install script to compile with `cmake-js`. Use `WEBRTC_NODE_PREBUILD_ONLY=1` in
133
+ release validation to fail rather than falling back to a source build.
122
134
 
123
135
  ## Docker Linux Slice
124
136