openrtc-netcode-node 1.0.0 → 2.0.0-rc.1
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 +13 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -11
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,12 +3,20 @@
|
|
|
3
3
|
Node.js helpers for `openrtc-netcode`.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
|
-
import {
|
|
6
|
+
import { OpenRTC } from 'openrtc';
|
|
7
|
+
import { createNodeNetcode, resolveNodeTransports } from 'openrtc-netcode-node';
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
-
|
|
9
|
+
const rtc = OpenRTC({
|
|
10
|
+
apiKey: process.env.OPENRTC_API_KEY!,
|
|
11
|
+
transports: resolveNodeTransports('auto'),
|
|
10
12
|
});
|
|
13
|
+
const room = await rtc.rooms.join('match-123', {
|
|
14
|
+
access: 'capability',
|
|
15
|
+
membership: 'ephemeral',
|
|
16
|
+
});
|
|
17
|
+
const netcode = createNodeNetcode({ room });
|
|
11
18
|
```
|
|
12
19
|
|
|
13
|
-
The helper
|
|
14
|
-
message, and replicated-state behavior to `openrtc-netcode`.
|
|
20
|
+
The helper exposes Node transport preferences and delegates all lobby, mesh,
|
|
21
|
+
message, and replicated-state behavior to `openrtc-netcode`. It never creates
|
|
22
|
+
an OpenRTC client or activates a second avenue.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type NetcodeClient, type NetcodeOptions } from 'openrtc-netcode';
|
|
2
|
+
import type { OpenRTCTransportPreferences } from 'openrtc';
|
|
2
3
|
export type NodeTransportProfile = 'auto' | 'iroh' | 'webrtc' | 'moq' | 'all';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function resolveNodeTransports(profile: NodeTransportProfile): NonNullable<NetcodeOptions['transports']>;
|
|
4
|
+
export type NodeNetcodeOptions = NetcodeOptions;
|
|
5
|
+
export declare function createNodeNetcode(options: NodeNetcodeOptions): NetcodeClient;
|
|
6
|
+
/** Use this when constructing OpenRTC; netcode itself never owns transport lifecycle. */
|
|
7
|
+
export declare function resolveNodeTransports(profile: NodeTransportProfile): OpenRTCTransportPreferences;
|
|
8
8
|
export type { CreateLobbyOptions, JoinLobbyOptions, NetVar, NetVarOptions, NetcodeClient, NetcodeEventHandler, NetcodeEventName, NetcodeEvents, NetcodeLobby, NetcodeMessage, NetcodeMessageHandler, NetcodeOptions, NetcodePeer, NetcodeState, SendOptions, } from 'openrtc-netcode';
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import { createNetcode } from 'openrtc-netcode';
|
|
2
|
-
export function createNodeNetcode(options
|
|
3
|
-
|
|
4
|
-
return createNetcode({
|
|
5
|
-
authMode: options.apiKey ? options.authMode : options.authMode ?? 'anonymous',
|
|
6
|
-
allowAnonymousHostedDefaults: options.apiKey
|
|
7
|
-
? options.allowAnonymousHostedDefaults
|
|
8
|
-
: options.allowAnonymousHostedDefaults ?? true,
|
|
9
|
-
nodeIdPersistence: options.nodeIdPersistence ?? 'ephemeral',
|
|
10
|
-
...netcodeOptions,
|
|
11
|
-
transports: options.transports ?? resolveNodeTransports(transportProfile),
|
|
12
|
-
});
|
|
2
|
+
export function createNodeNetcode(options) {
|
|
3
|
+
return createNetcode(options);
|
|
13
4
|
}
|
|
5
|
+
/** Use this when constructing OpenRTC; netcode itself never owns transport lifecycle. */
|
|
14
6
|
export function resolveNodeTransports(profile) {
|
|
15
7
|
const hasWebRtc = typeof globalThis.RTCPeerConnection === 'function';
|
|
16
8
|
const hasWebTransport = typeof globalThis.WebTransport === 'function';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openrtc-netcode-node",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-rc.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"test:watch": "vitest"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"openrtc": "
|
|
44
|
-
"openrtc-netcode": "
|
|
43
|
+
"openrtc": "2.0.0-rc.1",
|
|
44
|
+
"openrtc-netcode": "2.0.0-rc.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^24.10.1",
|