onelobby 0.4.1 → 0.6.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 +2 -2
- package/blueprint.schema.json +244 -0
- package/dist/blueprint.d.ts +170 -0
- package/dist/blueprint.js +286 -0
- package/dist/blueprint.js.map +1 -0
- package/dist/codec.d.ts +23 -0
- package/dist/codec.js +28 -0
- package/dist/codec.js.map +1 -1
- package/dist/direct/browser-host.d.ts +46 -0
- package/dist/direct/browser-host.js +93 -0
- package/dist/direct/browser-host.js.map +1 -0
- package/dist/direct/hub-host.d.ts +34 -23
- package/dist/direct/hub-host.js +75 -59
- package/dist/direct/hub-host.js.map +1 -1
- package/dist/direct/hub-local.d.ts +22 -0
- package/dist/direct/hub-local.js +46 -0
- package/dist/direct/hub-local.js.map +1 -0
- package/dist/direct/hub.d.ts +37 -10
- package/dist/direct/hub.js +114 -23
- package/dist/direct/hub.js.map +1 -1
- package/dist/direct/index.d.ts +37 -4
- package/dist/direct/index.js +162 -21
- package/dist/direct/index.js.map +1 -1
- package/dist/direct/metrics.d.ts +12 -0
- package/dist/direct/metrics.js +45 -0
- package/dist/direct/metrics.js.map +1 -0
- package/dist/direct/portmap.d.ts +9 -2
- package/dist/direct/portmap.js +7 -2
- package/dist/direct/portmap.js.map +1 -1
- package/dist/direct/sha1.d.ts +16 -0
- package/dist/direct/sha1.js +111 -0
- package/dist/direct/sha1.js.map +1 -0
- package/dist/direct-address.d.ts +2 -2
- package/dist/direct-address.js.map +1 -1
- package/dist/friendly.d.ts +28 -0
- package/dist/friendly.js +40 -0
- package/dist/friendly.js.map +1 -1
- package/dist/index.d.ts +11 -3
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/internals.d.ts +9 -0
- package/dist/internals.js +9 -0
- package/dist/internals.js.map +1 -1
- package/dist/join-code-kind.d.ts +10 -0
- package/dist/join-code-kind.js +10 -0
- package/dist/join-code-kind.js.map +1 -0
- package/dist/joincode.d.ts +10 -1
- package/dist/joincode.js +23 -3
- package/dist/joincode.js.map +1 -1
- package/dist/lobby.d.ts +65 -4
- package/dist/lobby.js +151 -12
- package/dist/lobby.js.map +1 -1
- package/dist/lockstep.d.ts +8 -0
- package/dist/lockstep.js +23 -2
- package/dist/lockstep.js.map +1 -1
- package/dist/nostr/crypto.d.ts +20 -0
- package/dist/nostr/crypto.js +78 -0
- package/dist/nostr/crypto.js.map +1 -0
- package/dist/nostr/host.d.ts +66 -0
- package/dist/nostr/host.js +196 -0
- package/dist/nostr/host.js.map +1 -0
- package/dist/nostr/limits.d.ts +31 -0
- package/dist/nostr/limits.js +36 -0
- package/dist/nostr/limits.js.map +1 -0
- package/dist/nostr/link.d.ts +70 -0
- package/dist/nostr/link.js +180 -0
- package/dist/nostr/link.js.map +1 -0
- package/dist/nostr/relays.d.ts +79 -0
- package/dist/nostr/relays.js +315 -0
- package/dist/nostr/relays.js.map +1 -0
- package/dist/nostr/room.d.ts +43 -0
- package/dist/nostr/room.js +104 -0
- package/dist/nostr/room.js.map +1 -0
- package/dist/nostr/secp256k1.d.ts +10 -0
- package/dist/nostr/secp256k1.js +171 -0
- package/dist/nostr/secp256k1.js.map +1 -0
- package/dist/nostr/socket.d.ts +48 -0
- package/dist/nostr/socket.js +141 -0
- package/dist/nostr/socket.js.map +1 -0
- package/dist/onelobby.bundle.js +146 -0
- package/dist/onelobby.bundle.js.map +7 -0
- package/dist/onelobby.bundle.mjs +11 -5
- package/dist/onelobby.bundle.mjs.map +4 -4
- package/dist/onelobby.d.ts +54 -4
- package/dist/onelobby.global.js +2932 -49
- package/dist/onelobby.global.js.map +4 -4
- package/dist/onelobby.global.min.js +11 -5
- package/dist/onelobby.global.min.js.map +4 -4
- package/dist/onelobby.js +158 -15
- package/dist/onelobby.js.map +1 -1
- package/dist/pause.d.ts +85 -0
- package/dist/pause.js +160 -0
- package/dist/pause.js.map +1 -0
- package/dist/transport.d.ts +3 -1
- package/dist/transport.js.map +1 -1
- package/dist/webrtc.d.ts +1 -0
- package/dist/webrtc.js +6 -1
- package/dist/webrtc.js.map +1 -1
- package/package.json +4 -2
package/dist/onelobby.d.ts
CHANGED
|
@@ -4,8 +4,11 @@ import { Lobby, type RateLimit } from "./lobby.js";
|
|
|
4
4
|
import { type LobbySummary } from "./signaling.js";
|
|
5
5
|
import { type LinkFactory, type SocketFactory } from "./transport.js";
|
|
6
6
|
import type { VoiceCodec, FrameSource, AudioSink } from "./voice-types.js";
|
|
7
|
+
import { type RelayConnect } from "./nostr/relays.js";
|
|
8
|
+
import { type Blueprint } from "./blueprint.js";
|
|
9
|
+
import { type BrowserHostOptions } from "./direct/browser-host.js";
|
|
7
10
|
export declare const LIB_NAME = "onelobby";
|
|
8
|
-
export declare const LIB_VERSION = "0.
|
|
11
|
+
export declare const LIB_VERSION = "0.6.0";
|
|
9
12
|
/** Where `rememberSeat` keeps the resume token: the subset of the Web Storage API it uses. */
|
|
10
13
|
export interface SeatStorage {
|
|
11
14
|
getItem(key: string): string | null;
|
|
@@ -25,6 +28,8 @@ export interface AdvancedOptions {
|
|
|
25
28
|
createSink?: (() => AudioSink) | null;
|
|
26
29
|
/** Storage for `rememberSeat`; defaults to `sessionStorage` when the page has one. null disables it. */
|
|
27
30
|
storage?: SeatStorage | null;
|
|
31
|
+
/** WebSocket to a Nostr relay (default: the runtime's `WebSocket`); for Node older than 22 or tests. */
|
|
32
|
+
nostrConnect?: RelayConnect;
|
|
28
33
|
}
|
|
29
34
|
export interface OneLobbyOptions {
|
|
30
35
|
gameId: string;
|
|
@@ -73,6 +78,16 @@ export interface OneLobbyOptions {
|
|
|
73
78
|
/** @deprecated use `advanced.createSink` */
|
|
74
79
|
createSink?: (() => AudioSink) | null;
|
|
75
80
|
}
|
|
81
|
+
/** Per-launch settings for `OneLobby.fromConfig`; everything else comes from the blueprint. */
|
|
82
|
+
export interface FromConfigOverrides {
|
|
83
|
+
/** The player's name. Checked against `players.identity` and `players.maxNameLength`. */
|
|
84
|
+
displayName?: string;
|
|
85
|
+
/** Wins over `hosting.lobbyServer` (the file is the bottom layer: put `?lobby=` / storage / `<meta>` lookups here). */
|
|
86
|
+
lobbyServer?: string;
|
|
87
|
+
/** Default: `lobby.rejoin` from the file. */
|
|
88
|
+
rememberSeat?: boolean;
|
|
89
|
+
advanced?: AdvancedOptions;
|
|
90
|
+
}
|
|
76
91
|
export interface HostOptions {
|
|
77
92
|
name: string;
|
|
78
93
|
maxPlayers: number;
|
|
@@ -94,10 +109,14 @@ export interface ListOptions {
|
|
|
94
109
|
export interface JoinDirectOptions {
|
|
95
110
|
/** The host's password, if it set one; a wrong one fails with `bad_password`. */
|
|
96
111
|
password?: string;
|
|
97
|
-
/** Port for an address typed without one (default 47810, docs/direct-ip.md s.2). */
|
|
112
|
+
/** Port for an address typed without one (default 47810, docs/design/direct-ip.md s.2). */
|
|
98
113
|
defaultPort?: number;
|
|
99
114
|
/** No answer on the host's TCP port within this long fails with `direct_unreachable` (default 5000). */
|
|
100
115
|
connectTimeoutMs?: number;
|
|
116
|
+
/** Nostr relays for a Nostr code (version 1); default the blueprint's `hosting.nostrRelays`, else the library list. */
|
|
117
|
+
nostrRelays?: string[];
|
|
118
|
+
/** STUN servers for a Nostr code when the host offers none; default Google's and Cloudflare's public ones. */
|
|
119
|
+
stun?: string[];
|
|
101
120
|
}
|
|
102
121
|
/** @internal How onelobby/direct makes a host lobby: its own socket and link factory, and direct mode. */
|
|
103
122
|
export interface DirectLobbyHooks {
|
|
@@ -120,6 +139,17 @@ export declare class OneLobby extends Emitter<OneLobbyEvents> {
|
|
|
120
139
|
private createMic;
|
|
121
140
|
private createSink;
|
|
122
141
|
private storage;
|
|
142
|
+
private nostrConnectFn;
|
|
143
|
+
/** The validated, frozen onelobby.json this kit was built from (`OneLobby.fromConfig`); undefined for `new OneLobby`. */
|
|
144
|
+
readonly blueprint?: Blueprint;
|
|
145
|
+
/**
|
|
146
|
+
* Build a kit from an onelobby.json (already parsed; docs/design/blueprint.md s.7). Throws `bad_config` for an
|
|
147
|
+
* invalid file or name, `identity_anonymous` for a name when `players.identity` is "anonymous". Then `host()` and
|
|
148
|
+
* `hostDirect()` default their options from the file and the file's chat/listing switches are enforced.
|
|
149
|
+
*/
|
|
150
|
+
static fromConfig(json: unknown, overrides?: FromConfigOverrides): OneLobby;
|
|
151
|
+
/** @internal Host options the blueprint implies (empty without one). */
|
|
152
|
+
blueprintHostDefaults(): Partial<HostOptions>;
|
|
123
153
|
constructor(o: OneLobbyOptions);
|
|
124
154
|
private get seatKey();
|
|
125
155
|
private loadSeat;
|
|
@@ -137,10 +167,11 @@ export declare class OneLobby extends Emitter<OneLobbyEvents> {
|
|
|
137
167
|
/** The signaling socket only (no hello yet); with a timeout (direct IP), no answer is `direct_unreachable`. */
|
|
138
168
|
private open;
|
|
139
169
|
private makeLobby;
|
|
140
|
-
|
|
170
|
+
/** With a blueprint (`fromConfig`) every option defaults from `lobby.*`; explicit options win. */
|
|
171
|
+
host(opts?: Partial<HostOptions>): Promise<Lobby>;
|
|
141
172
|
join(code: string): Promise<Lobby>;
|
|
142
173
|
/**
|
|
143
|
-
* Join a direct-IP host (docs/direct-ip.md): a join code from the host's screen (`6B01-RGFE-P2B`, any case, spaces
|
|
174
|
+
* Join a direct-IP host (docs/design/direct-ip.md): a join code from the host's screen (`6B01-RGFE-P2B`, any case, spaces
|
|
144
175
|
* or hyphens) or, advanced, an address (`ip`, `ip:port`, `[v6]:port`). No lobby server is involved: the code is
|
|
145
176
|
* the host's address. A mistyped code fails at once with `bad_code`; nobody listening is `direct_unreachable`.
|
|
146
177
|
* The address is also given to ICE as the host's UDP candidate. When the host leaves, `sessionEnded("host_left")`.
|
|
@@ -152,9 +183,28 @@ export declare class OneLobby extends Emitter<OneLobbyEvents> {
|
|
|
152
183
|
* same peer id comes back. Rejects with `invalid_token` when the seat is gone: offer `joinDirect` then.
|
|
153
184
|
*/
|
|
154
185
|
rejoinDirect(codeOrAddress: string, resumeToken: string, opts?: JoinDirectOptions): Promise<Lobby>;
|
|
186
|
+
private nostrFactory;
|
|
187
|
+
/** Opens the signaling socket of a direct target: TCP to the host's address, or Nostr relays for a version 1 code. */
|
|
188
|
+
private connectDirect;
|
|
189
|
+
/** A Nostr joiner needs STUN; take the host's list (it comes in `welcome`), else the public defaults. */
|
|
190
|
+
private withStun;
|
|
155
191
|
private directTarget;
|
|
192
|
+
/** @internal onelobby/direct's Nostr host: the relay seam and the kit's clocks. */
|
|
193
|
+
nostrHostEnv(): {
|
|
194
|
+
connect: RelayConnect | undefined;
|
|
195
|
+
clock: Clock;
|
|
196
|
+
wall: () => number;
|
|
197
|
+
};
|
|
156
198
|
/** @internal onelobby/direct's host: create the one lobby on the embedded hub, in direct mode. */
|
|
157
199
|
hostDirectWith(h: HostOptions, hooks: DirectLobbyHooks): Promise<Lobby>;
|
|
200
|
+
/**
|
|
201
|
+
* Host a direct lobby from this browser tab (or any runtime with WebSocket and WebRTC): no Node process, no port.
|
|
202
|
+
* The hub runs in the page and joiners find it through Nostr relays with `lobby.joinCode` (a dc1 version 1 code,
|
|
203
|
+
* `joinCodeKind` "nostr"); they use `kit.joinDirect(code)`. Rejects with `direct_unreachable` when no relay answers
|
|
204
|
+
* within 10 s (a browser has no IP fallback) and `nostr_disabled` when the blueprint has `hosting.nostr` false.
|
|
205
|
+
* Keep the tab visible: hidden tabs are throttled (`lobby.hostHidden`, event `hostHiddenChanged`).
|
|
206
|
+
*/
|
|
207
|
+
hostNostr(opts?: BrowserHostOptions): Promise<Lobby>;
|
|
158
208
|
rejoin(resumeToken: string): Promise<Lobby>;
|
|
159
209
|
private resumeAt;
|
|
160
210
|
list(opts?: ListOptions): Promise<LobbySummary[]>;
|