@lng2004/node-datachannel 0.31.0-20251228

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.
Files changed (171) hide show
  1. package/.clang-format +17 -0
  2. package/.editorconfig +12 -0
  3. package/.eslintignore +8 -0
  4. package/.eslintrc.json +27 -0
  5. package/.gitmodules +3 -0
  6. package/.prettierignore +7 -0
  7. package/.prettierrc +13 -0
  8. package/API.md +247 -0
  9. package/BULDING.md +33 -0
  10. package/CMakeLists.txt +134 -0
  11. package/LICENSE +373 -0
  12. package/README.md +130 -0
  13. package/dist/cjs/index.cjs +11 -0
  14. package/dist/cjs/index.cjs.map +1 -0
  15. package/dist/cjs/lib/datachannel-stream.cjs +101 -0
  16. package/dist/cjs/lib/datachannel-stream.cjs.map +1 -0
  17. package/dist/cjs/lib/index.cjs +88 -0
  18. package/dist/cjs/lib/index.cjs.map +1 -0
  19. package/dist/cjs/lib/node-datachannel.cjs +8 -0
  20. package/dist/cjs/lib/node-datachannel.cjs.map +1 -0
  21. package/dist/cjs/lib/websocket-server.cjs +45 -0
  22. package/dist/cjs/lib/websocket-server.cjs.map +1 -0
  23. package/dist/cjs/lib/websocket.cjs +8 -0
  24. package/dist/cjs/lib/websocket.cjs.map +1 -0
  25. package/dist/cjs/polyfill/Events.cjs +86 -0
  26. package/dist/cjs/polyfill/Events.cjs.map +1 -0
  27. package/dist/cjs/polyfill/Exception.cjs +34 -0
  28. package/dist/cjs/polyfill/Exception.cjs.map +1 -0
  29. package/dist/cjs/polyfill/RTCCertificate.cjs +34 -0
  30. package/dist/cjs/polyfill/RTCCertificate.cjs.map +1 -0
  31. package/dist/cjs/polyfill/RTCDataChannel.cjs +214 -0
  32. package/dist/cjs/polyfill/RTCDataChannel.cjs.map +1 -0
  33. package/dist/cjs/polyfill/RTCDtlsTransport.cjs +53 -0
  34. package/dist/cjs/polyfill/RTCDtlsTransport.cjs.map +1 -0
  35. package/dist/cjs/polyfill/RTCError.cjs +83 -0
  36. package/dist/cjs/polyfill/RTCError.cjs.map +1 -0
  37. package/dist/cjs/polyfill/RTCIceCandidate.cjs +132 -0
  38. package/dist/cjs/polyfill/RTCIceCandidate.cjs.map +1 -0
  39. package/dist/cjs/polyfill/RTCIceTransport.cjs +94 -0
  40. package/dist/cjs/polyfill/RTCIceTransport.cjs.map +1 -0
  41. package/dist/cjs/polyfill/RTCPeerConnection.cjs +434 -0
  42. package/dist/cjs/polyfill/RTCPeerConnection.cjs.map +1 -0
  43. package/dist/cjs/polyfill/RTCSctpTransport.cjs +59 -0
  44. package/dist/cjs/polyfill/RTCSctpTransport.cjs.map +1 -0
  45. package/dist/cjs/polyfill/RTCSessionDescription.cjs +45 -0
  46. package/dist/cjs/polyfill/RTCSessionDescription.cjs.map +1 -0
  47. package/dist/cjs/polyfill/index.cjs +42 -0
  48. package/dist/cjs/polyfill/index.cjs.map +1 -0
  49. package/dist/esm/index.mjs +8 -0
  50. package/dist/esm/index.mjs.map +1 -0
  51. package/dist/esm/lib/datachannel-stream.mjs +78 -0
  52. package/dist/esm/lib/datachannel-stream.mjs.map +1 -0
  53. package/dist/esm/lib/index.mjs +62 -0
  54. package/dist/esm/lib/index.mjs.map +1 -0
  55. package/dist/esm/lib/node-datachannel.mjs +12 -0
  56. package/dist/esm/lib/node-datachannel.mjs.map +1 -0
  57. package/dist/esm/lib/websocket-server.mjs +43 -0
  58. package/dist/esm/lib/websocket-server.mjs.map +1 -0
  59. package/dist/esm/lib/websocket.mjs +6 -0
  60. package/dist/esm/lib/websocket.mjs.map +1 -0
  61. package/dist/esm/polyfill/Events.mjs +82 -0
  62. package/dist/esm/polyfill/Events.mjs.map +1 -0
  63. package/dist/esm/polyfill/Exception.mjs +28 -0
  64. package/dist/esm/polyfill/Exception.mjs.map +1 -0
  65. package/dist/esm/polyfill/RTCCertificate.mjs +30 -0
  66. package/dist/esm/polyfill/RTCCertificate.mjs.map +1 -0
  67. package/dist/esm/polyfill/RTCDataChannel.mjs +210 -0
  68. package/dist/esm/polyfill/RTCDataChannel.mjs.map +1 -0
  69. package/dist/esm/polyfill/RTCDtlsTransport.mjs +49 -0
  70. package/dist/esm/polyfill/RTCDtlsTransport.mjs.map +1 -0
  71. package/dist/esm/polyfill/RTCError.mjs +79 -0
  72. package/dist/esm/polyfill/RTCError.mjs.map +1 -0
  73. package/dist/esm/polyfill/RTCIceCandidate.mjs +128 -0
  74. package/dist/esm/polyfill/RTCIceCandidate.mjs.map +1 -0
  75. package/dist/esm/polyfill/RTCIceTransport.mjs +89 -0
  76. package/dist/esm/polyfill/RTCIceTransport.mjs.map +1 -0
  77. package/dist/esm/polyfill/RTCPeerConnection.mjs +430 -0
  78. package/dist/esm/polyfill/RTCPeerConnection.mjs.map +1 -0
  79. package/dist/esm/polyfill/RTCSctpTransport.mjs +55 -0
  80. package/dist/esm/polyfill/RTCSctpTransport.mjs.map +1 -0
  81. package/dist/esm/polyfill/RTCSessionDescription.mjs +41 -0
  82. package/dist/esm/polyfill/RTCSessionDescription.mjs.map +1 -0
  83. package/dist/esm/polyfill/index.mjs +27 -0
  84. package/dist/esm/polyfill/index.mjs.map +1 -0
  85. package/dist/types/lib/datachannel-stream.d.ts +24 -0
  86. package/dist/types/lib/index.d.ts +235 -0
  87. package/dist/types/lib/types.d.ts +118 -0
  88. package/dist/types/lib/websocket-server.d.ts +13 -0
  89. package/dist/types/lib/websocket.d.ts +25 -0
  90. package/dist/types/polyfill/Events.d.ts +15 -0
  91. package/dist/types/polyfill/RTCCertificate.d.ts +9 -0
  92. package/dist/types/polyfill/RTCDataChannel.d.ts +29 -0
  93. package/dist/types/polyfill/RTCDtlsTransport.d.ts +15 -0
  94. package/dist/types/polyfill/RTCError.d.ts +17 -0
  95. package/dist/types/polyfill/RTCIceCandidate.d.ts +21 -0
  96. package/dist/types/polyfill/RTCIceTransport.d.ts +30 -0
  97. package/dist/types/polyfill/RTCPeerConnection.d.ts +64 -0
  98. package/dist/types/polyfill/RTCSctpTransport.d.ts +15 -0
  99. package/dist/types/polyfill/RTCSessionDescription.d.ts +10 -0
  100. package/dist/types/polyfill/index.d.ts +26 -0
  101. package/jest.config.ts +14 -0
  102. package/package.json +121 -0
  103. package/rollup.config.mjs +72 -0
  104. package/src/cpp/data-channel-wrapper.cpp +530 -0
  105. package/src/cpp/data-channel-wrapper.h +63 -0
  106. package/src/cpp/ice-udp-mux-listener-wrapper.cpp +157 -0
  107. package/src/cpp/ice-udp-mux-listener-wrapper.h +43 -0
  108. package/src/cpp/main.cpp +58 -0
  109. package/src/cpp/media-audio-wrapper.cpp +457 -0
  110. package/src/cpp/media-audio-wrapper.h +52 -0
  111. package/src/cpp/media-av1packetization.cpp +24 -0
  112. package/src/cpp/media-av1packetization.h +11 -0
  113. package/src/cpp/media-av1rtppacketizer-wrapper.cpp +126 -0
  114. package/src/cpp/media-av1rtppacketizer-wrapper.h +29 -0
  115. package/src/cpp/media-direction.cpp +43 -0
  116. package/src/cpp/media-direction.h +10 -0
  117. package/src/cpp/media-h264rtppacketizer-wrapper.cpp +126 -0
  118. package/src/cpp/media-h264rtppacketizer-wrapper.h +30 -0
  119. package/src/cpp/media-h265rtppacketizer-wrapper.cpp +126 -0
  120. package/src/cpp/media-h265rtppacketizer-wrapper.h +30 -0
  121. package/src/cpp/media-h26xseparator.cpp +32 -0
  122. package/src/cpp/media-h26xseparator.h +11 -0
  123. package/src/cpp/media-mediahandler-helper.cpp +31 -0
  124. package/src/cpp/media-mediahandler-helper.h +11 -0
  125. package/src/cpp/media-pacinghandler-wrapper.cpp +79 -0
  126. package/src/cpp/media-pacinghandler-wrapper.h +28 -0
  127. package/src/cpp/media-rtcpnackresponder-wrapper.cpp +68 -0
  128. package/src/cpp/media-rtcpnackresponder-wrapper.h +28 -0
  129. package/src/cpp/media-rtcpreceivingsession-wrapper.cpp +57 -0
  130. package/src/cpp/media-rtcpreceivingsession-wrapper.h +28 -0
  131. package/src/cpp/media-rtcpsrreporter-wrapper.cpp +93 -0
  132. package/src/cpp/media-rtcpsrreporter-wrapper.h +30 -0
  133. package/src/cpp/media-rtppacketizationconfig-wrapper.cpp +167 -0
  134. package/src/cpp/media-rtppacketizationconfig-wrapper.h +35 -0
  135. package/src/cpp/media-rtppacketizer-wrapper.cpp +95 -0
  136. package/src/cpp/media-rtppacketizer-wrapper.h +30 -0
  137. package/src/cpp/media-track-wrapper.cpp +458 -0
  138. package/src/cpp/media-track-wrapper.h +61 -0
  139. package/src/cpp/media-video-wrapper.cpp +526 -0
  140. package/src/cpp/media-video-wrapper.h +56 -0
  141. package/src/cpp/peer-connection-wrapper.cpp +1298 -0
  142. package/src/cpp/peer-connection-wrapper.h +89 -0
  143. package/src/cpp/rtc-wrapper.cpp +205 -0
  144. package/src/cpp/rtc-wrapper.h +24 -0
  145. package/src/cpp/thread-safe-callback.cpp +57 -0
  146. package/src/cpp/thread-safe-callback.h +47 -0
  147. package/src/cpp/web-socket-server-wrapper.cpp +275 -0
  148. package/src/cpp/web-socket-server-wrapper.h +41 -0
  149. package/src/cpp/web-socket-wrapper.cpp +796 -0
  150. package/src/cpp/web-socket-wrapper.h +63 -0
  151. package/src/index.ts +9 -0
  152. package/src/lib/datachannel-stream.ts +100 -0
  153. package/src/lib/index.ts +283 -0
  154. package/src/lib/node-datachannel.ts +3 -0
  155. package/src/lib/types.ts +168 -0
  156. package/src/lib/websocket-server.ts +37 -0
  157. package/src/lib/websocket.ts +26 -0
  158. package/src/polyfill/Events.ts +82 -0
  159. package/src/polyfill/Exception.ts +37 -0
  160. package/src/polyfill/README.md +41 -0
  161. package/src/polyfill/RTCCertificate.ts +21 -0
  162. package/src/polyfill/RTCDataChannel.ts +225 -0
  163. package/src/polyfill/RTCDtlsTransport.ts +46 -0
  164. package/src/polyfill/RTCError.ts +78 -0
  165. package/src/polyfill/RTCIceCandidate.ts +128 -0
  166. package/src/polyfill/RTCIceTransport.ts +90 -0
  167. package/src/polyfill/RTCPeerConnection.ts +527 -0
  168. package/src/polyfill/RTCSctpTransport.ts +51 -0
  169. package/src/polyfill/RTCSessionDescription.ts +41 -0
  170. package/src/polyfill/index.ts +38 -0
  171. package/tsconfig.json +21 -0
@@ -0,0 +1,26 @@
1
+ import RTCCertificate from './RTCCertificate.js';
2
+ import RTCDataChannel from './RTCDataChannel.js';
3
+ import RTCDtlsTransport from './RTCDtlsTransport.js';
4
+ import RTCIceCandidate from './RTCIceCandidate.js';
5
+ import RTCIceTransport from './RTCIceTransport.js';
6
+ import RTCPeerConnection from './RTCPeerConnection.js';
7
+ import RTCSctpTransport from './RTCSctpTransport.js';
8
+ import RTCSessionDescription from './RTCSessionDescription.js';
9
+ import { RTCDataChannelEvent, RTCPeerConnectionIceEvent } from './Events.js';
10
+ import RTCError from './RTCError.js';
11
+
12
+ declare const _default: {
13
+ RTCCertificate: typeof RTCCertificate;
14
+ RTCDataChannel: typeof RTCDataChannel;
15
+ RTCDtlsTransport: typeof RTCDtlsTransport;
16
+ RTCIceCandidate: typeof RTCIceCandidate;
17
+ RTCIceTransport: typeof RTCIceTransport;
18
+ RTCPeerConnection: typeof RTCPeerConnection;
19
+ RTCSctpTransport: typeof RTCSctpTransport;
20
+ RTCSessionDescription: typeof RTCSessionDescription;
21
+ RTCDataChannelEvent: typeof RTCDataChannelEvent;
22
+ RTCPeerConnectionIceEvent: typeof RTCPeerConnectionIceEvent;
23
+ RTCError: typeof RTCError;
24
+ };
25
+
26
+ export { RTCCertificate, RTCDataChannel, RTCDataChannelEvent, RTCDtlsTransport, RTCError, RTCIceCandidate, RTCIceTransport, RTCPeerConnection, RTCPeerConnectionIceEvent, RTCSctpTransport, RTCSessionDescription, _default as default };
package/jest.config.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { Config } from 'jest';
2
+
3
+ const config: Config = {
4
+ clearMocks: true,
5
+ collectCoverage: false,
6
+ coverageDirectory: 'coverage',
7
+ coverageProvider: 'v8',
8
+ preset: 'ts-jest',
9
+ testEnvironment: 'jest-environment-node',
10
+ testRegex: '(/test/jest-tests/.*|(\\.|/)(test|spec))\\.(m)?ts$',
11
+ testPathIgnorePatterns: ['node_modules', 'multiple-run.test'],
12
+ };
13
+
14
+ export default config;
package/package.json ADDED
@@ -0,0 +1,121 @@
1
+ {
2
+ "name": "@lng2004/node-datachannel",
3
+ "version": "0.31.0-20251228",
4
+ "description": "WebRTC For Node.js and Electron. libdatachannel node bindings.",
5
+ "main": "./dist/cjs/lib/index.cjs",
6
+ "module": "./dist/esm/lib/index.mjs",
7
+ "types": "./dist/types/lib/index.d.ts",
8
+ "typesVersions": {
9
+ "*": {
10
+ "*": [
11
+ "dist/types/lib/index.d.ts"
12
+ ],
13
+ "polyfill": [
14
+ "dist/types/polyfill/index.d.ts"
15
+ ]
16
+ }
17
+ },
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/types/lib/index.d.ts",
21
+ "require": "./dist/cjs/lib/index.cjs",
22
+ "import": "./dist/esm/lib/index.mjs",
23
+ "default": "./dist/lib/esm/index.mjs"
24
+ },
25
+ "./polyfill": {
26
+ "types": "./dist/types/polyfill/index.d.ts",
27
+ "require": "./dist/cjs/polyfill/index.cjs",
28
+ "import": "./dist/esm/polyfill/index.mjs",
29
+ "default": "./dist/polyfill/esm/index.mjs"
30
+ }
31
+ },
32
+ "engines": {
33
+ "node": ">=18.20.0"
34
+ },
35
+ "scripts": {
36
+ "install": "prebuild-install -r napi || (npm install --ignore-scripts --production=false && npm run _prebuild)",
37
+ "install:nice": "npm run clean && npm install --ignore-scripts --production=false && cmake-js configure --CDUSE_NICE=1 && cmake-js build",
38
+ "install:gnu": "npm run clean && npm install --ignore-scripts --production=false && cmake-js configure --CDUSE_GNUTLS=1 && cmake-js build",
39
+ "build": "npm run compile && npm run build:tsc",
40
+ "compile": "cmake-js build",
41
+ "build:debug": "npm run compile:debug && npm run build:tsc",
42
+ "compile:debug": "cmake-js configure -D && cmake-js build -D",
43
+ "build:tsc": "rimraf dist && rollup -c",
44
+ "build:tsc:watch": "rollup -c -w",
45
+ "clean": "rimraf dist build",
46
+ "lint": "eslint . --ext .ts --ext .mts",
47
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
48
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
49
+ "test:wpt": "npm run run:wpt:server & (sleep 8 && (npm run run:wpt:test | tee test/wpt-tests/last-test-results.md) )",
50
+ "wpt:server": "cd test/wpt-tests/wpt && ./wpt serve",
51
+ "wpt:test": "ts-node test/wpt-tests/index.ts",
52
+ "_prebuild": "prebuild -r napi --backend cmake-js",
53
+ "prepack": "npm run build:tsc",
54
+ "prettier": "prettier --write .",
55
+ "format-cpp": "find src/cpp \\( -name \"*.h\" -o -name \"*.cpp\" \\) -exec clang-format -i \"{}\" \\; "
56
+ },
57
+ "binary": {
58
+ "napi_versions": [
59
+ 8
60
+ ]
61
+ },
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "git+https://github.com/Discord-RE/node-datachannel.git"
65
+ },
66
+ "keywords": [
67
+ "libdatachannel",
68
+ "webrtc",
69
+ "p2p",
70
+ "peer-to-peer",
71
+ "datachannel",
72
+ "data channel",
73
+ "websocket"
74
+ ],
75
+ "contributors": [
76
+ {
77
+ "name": "Murat Doğan",
78
+ "url": "https://github.com/murat-dogan"
79
+ },
80
+ {
81
+ "name": "Paul-Louis Ageneau",
82
+ "url": "https://github.com/paullouisageneau"
83
+ }
84
+ ],
85
+ "license": "MPL 2.0",
86
+ "bugs": {
87
+ "url": "https://github.com/murat-dogan/node-datachannel/issues"
88
+ },
89
+ "homepage": "https://github.com/murat-dogan/node-datachannel#readme",
90
+ "devDependencies": {
91
+ "@rollup/plugin-esm-shim": "^0.1.7",
92
+ "@rollup/plugin-replace": "^6.0.1",
93
+ "@types/jest": "^29.5.12",
94
+ "@types/node": "^20.6.1",
95
+ "@types/webrtc": "^0.0.46",
96
+ "@typescript-eslint/eslint-plugin": "^7.17.0",
97
+ "@typescript-eslint/parser": "^7.17.0",
98
+ "cmake-js": "^7.3.0",
99
+ "eslint": "^8.57.0",
100
+ "eslint-config-prettier": "^9.1.0",
101
+ "eslint-plugin-jest": "^28.6.0",
102
+ "eslint-plugin-prettier": "^5.2.1",
103
+ "jest": "^29.7.0",
104
+ "jsdom": "^24.1.1",
105
+ "node-addon-api": "^7.0.0",
106
+ "prebuild": "^13.0.1",
107
+ "prettier": "^3.3.3",
108
+ "puppeteer": "^22.14.0",
109
+ "rimraf": "^5.0.9",
110
+ "rollup": "^4.22.5",
111
+ "rollup-plugin-dts": "^6.1.1",
112
+ "rollup-plugin-esbuild": "^6.1.1",
113
+ "ts-api-utils": "^1.3.0",
114
+ "ts-jest": "^29.2.3",
115
+ "ts-node": "^10.9.2",
116
+ "typescript": "5.4"
117
+ },
118
+ "dependencies": {
119
+ "prebuild-install": "^7.1.3"
120
+ }
121
+ }
@@ -0,0 +1,72 @@
1
+ import dts from 'rollup-plugin-dts';
2
+ import esbuild from 'rollup-plugin-esbuild';
3
+ import esmShim from '@rollup/plugin-esm-shim';
4
+ import replace from '@rollup/plugin-replace';
5
+
6
+ const external = (id) => {
7
+ return !/^[./]/.test(id);
8
+ };
9
+
10
+ const bundle = (config) => ({
11
+ ...config,
12
+ input: 'src/index.ts',
13
+ external: ['events','stream'] // <-- suppresses the warning for these built-in modules
14
+ });
15
+
16
+ export default [
17
+ bundle({
18
+ plugins: [
19
+ replace({
20
+ include: 'src/lib/node-datachannel.ts',
21
+ preventAssignment: true,
22
+ "require('../../build": "require('../../../build",
23
+ }),
24
+ esmShim(),
25
+ esbuild(),
26
+ ],
27
+ output: [
28
+ {
29
+ dir: 'dist/esm',
30
+ format: 'es',
31
+ exports: 'named',
32
+ sourcemap: true,
33
+ entryFileNames: '[name].mjs',
34
+ preserveModules: true, // Keep directory structure and files
35
+ },
36
+ {
37
+ dir: 'dist/cjs',
38
+ format: 'cjs',
39
+ exports: 'named',
40
+ sourcemap: true,
41
+ entryFileNames: '[name].cjs',
42
+ preserveModules: true, // Keep directory structure and files
43
+ },
44
+ ],
45
+ }),
46
+ // types
47
+ {
48
+ plugins: [dts()],
49
+ input: 'src/lib/index.ts',
50
+ external,
51
+ output: {
52
+ dir: 'dist/types/lib',
53
+ format: 'cjs',
54
+ exports: 'named',
55
+ preserveModules: true, // Keep directory structure and files
56
+ },
57
+ },
58
+ {
59
+ plugins: [dts()],
60
+ input: 'src/polyfill/index.ts',
61
+ external: (id) => {
62
+ if (id.startsWith('../lib')) return true;
63
+ return !/^[./]/.test(id);
64
+ },
65
+ output: {
66
+ dir: 'dist/types/polyfill',
67
+ format: 'cjs',
68
+ exports: 'named',
69
+ preserveModules: true, // Keep directory structure and files
70
+ },
71
+ },
72
+ ];