@margoengine/netcode 0.1.0 → 1.0.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/LICENSE +201 -201
- package/NOTICE +4 -4
- package/README.md +1388 -1306
- package/dist/media.d.ts +21 -3
- package/dist/media.js +40 -9
- package/dist/physics.js +11 -11
- package/dist/shared/bytes.d.ts +38 -36
- package/package.json +140 -140
package/dist/media.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ export interface MediaSessionOptions {
|
|
|
6
6
|
/** The `navigator.mediaDevices` to use (default the global one, in a browser). */
|
|
7
7
|
mediaDevices?: Pick<MediaDevices, 'getUserMedia' | 'getDisplayMedia'>;
|
|
8
8
|
/**
|
|
9
|
-
* The Web Audio context that plays remote voices and measures levels (default: one is made on first use
|
|
9
|
+
* The Web Audio context that plays remote voices and measures levels (default: one is made on first use, resumed on
|
|
10
|
+
* the page's first click or key press if the browser starts it suspended, and closed by `dispose()`; resume and close
|
|
11
|
+
* one you pass yourself). Without
|
|
10
12
|
* Web Audio (no `AudioContext` and none passed) voices are not played or measured: remote streams are still given on
|
|
11
13
|
* `peer.stream` for your own `<audio>` element.
|
|
12
14
|
*/
|
|
@@ -121,6 +123,8 @@ export declare class MediaSession extends EventTarget {
|
|
|
121
123
|
readonly remotes: Map<number, RemoteMedia>;
|
|
122
124
|
private readonly devices;
|
|
123
125
|
private context;
|
|
126
|
+
/** True when this session made `context`, so it unlocks and closes it. */
|
|
127
|
+
private ownsContext;
|
|
124
128
|
private readonly options;
|
|
125
129
|
private readonly now;
|
|
126
130
|
private readonly sent;
|
|
@@ -142,6 +146,11 @@ export declare class MediaSession extends EventTarget {
|
|
|
142
146
|
signal?: AbortSignal;
|
|
143
147
|
}): AsyncGenerator<MediaEventMap[K]>;
|
|
144
148
|
private audio;
|
|
149
|
+
/**
|
|
150
|
+
* A context made before the page's first click, tap or key press starts suspended and stays silent until `resume()`
|
|
151
|
+
* runs after one (HTML user activation), so resume it on the first.
|
|
152
|
+
*/
|
|
153
|
+
private unlock;
|
|
145
154
|
private meter;
|
|
146
155
|
/** Reads every level once and emits `speaking` events on changes. Runs by itself every `pollMs`; call it to step by hand. */
|
|
147
156
|
poll(): void;
|
|
@@ -175,7 +184,7 @@ export declare class MediaSession extends EventTarget {
|
|
|
175
184
|
* @throws MargoError `state` when a share is already on; the signal's reason when `signal` aborts; the browser's
|
|
176
185
|
* error (a `NotAllowedError` when the user declines) otherwise.
|
|
177
186
|
*/
|
|
178
|
-
startScreenShare({ signal, constraints }?: ScreenShareOptions): Promise<void>;
|
|
187
|
+
startScreenShare({ signal, constraints, }?: ScreenShareOptions): Promise<void>;
|
|
179
188
|
/** Stops sharing the screen and removes it from every link. */
|
|
180
189
|
stopScreenShare(): void;
|
|
181
190
|
/** Sets a peer's playback volume (0 and up, default 1). */
|
|
@@ -188,9 +197,18 @@ export declare class MediaSession extends EventTarget {
|
|
|
188
197
|
private receive;
|
|
189
198
|
private lose;
|
|
190
199
|
private play;
|
|
200
|
+
/**
|
|
201
|
+
* Chromium decodes a remote WebRTC voice only while a media element plays it: until then
|
|
202
|
+
* `createMediaStreamSource` gives silence (Chromium issue 933677). A muted element, which autoplay policies let
|
|
203
|
+
* play without a gesture, pulls the voice; the sound still comes from the Web Audio graph alone.
|
|
204
|
+
*/
|
|
205
|
+
private sink;
|
|
191
206
|
private unplay;
|
|
192
207
|
private detach;
|
|
193
|
-
/**
|
|
208
|
+
/**
|
|
209
|
+
* Stops every track this end sends, leaves the mesh's hooks, closes the audio context the session made and ends event
|
|
210
|
+
* iterators. The mesh, its links and a context you passed stay.
|
|
211
|
+
*/
|
|
194
212
|
dispose(): void;
|
|
195
213
|
/** Same as {@link MediaSession.dispose}, for `using`. */
|
|
196
214
|
[Symbol.dispose](): void;
|
package/dist/media.js
CHANGED
|
@@ -17,7 +17,7 @@ var t = class extends Event {
|
|
|
17
17
|
return e.length ? Math.sqrt(t / e.length) : 0;
|
|
18
18
|
}, i = class extends EventTarget {
|
|
19
19
|
constructor(t, n = {}) {
|
|
20
|
-
if (super(), this.mesh = t, this.remotes = /* @__PURE__ */ new Map(), this.sent = /* @__PURE__ */ new Map(), this.voices = /* @__PURE__ */ new Map(), this.meters = /* @__PURE__ */ new Map(), this.cleanup = [], this.talking = !1, this.muted = !1, this.disposed = !1, this.options = n, this.devices = n.mediaDevices ?? globalThis.navigator?.mediaDevices, !this.devices) throw e("unsupported", "MediaSession needs navigator.mediaDevices; run it in a browser (HTTPS) or pass mediaDevices");
|
|
20
|
+
if (super(), this.mesh = t, this.remotes = /* @__PURE__ */ new Map(), this.ownsContext = !1, this.sent = /* @__PURE__ */ new Map(), this.voices = /* @__PURE__ */ new Map(), this.meters = /* @__PURE__ */ new Map(), this.cleanup = [], this.talking = !1, this.muted = !1, this.disposed = !1, this.options = n, this.devices = n.mediaDevices ?? globalThis.navigator?.mediaDevices, !this.devices) throw e("unsupported", "MediaSession needs navigator.mediaDevices; run it in a browser (HTTPS) or pass mediaDevices");
|
|
21
21
|
this.context = n.audioContext, this.now = n.now ?? (() => performance.now()), this.ptt = n.pushToTalk ?? !1;
|
|
22
22
|
let r = this.before = t.onlink, i = t.onunlink;
|
|
23
23
|
this.beforeUnlink = i, t.onlink = (e, t) => {
|
|
@@ -46,7 +46,26 @@ var t = class extends Event {
|
|
|
46
46
|
audio() {
|
|
47
47
|
if (this.context) return this.context;
|
|
48
48
|
let e = globalThis.AudioContext;
|
|
49
|
-
|
|
49
|
+
if (e) return this.context = new e(), this.ownsContext = !0, this.unlock(this.context), this.context;
|
|
50
|
+
}
|
|
51
|
+
unlock(e) {
|
|
52
|
+
let t = globalThis.document;
|
|
53
|
+
if (e.state !== "suspended" || !t) return;
|
|
54
|
+
let n = [
|
|
55
|
+
"pointerdown",
|
|
56
|
+
"pointerup",
|
|
57
|
+
"keydown",
|
|
58
|
+
"touchend"
|
|
59
|
+
], r = () => void e.resume().then(i, (e) => {
|
|
60
|
+
this.disposed || this.emit("error", {
|
|
61
|
+
peer: "self",
|
|
62
|
+
error: e
|
|
63
|
+
});
|
|
64
|
+
}), i = () => {
|
|
65
|
+
for (let e of n) t.removeEventListener(e, r, !0);
|
|
66
|
+
};
|
|
67
|
+
for (let e of n) t.addEventListener(e, r, !0);
|
|
68
|
+
this.cleanup.push(i);
|
|
50
69
|
}
|
|
51
70
|
meter(e, t) {
|
|
52
71
|
let r = this.audio();
|
|
@@ -238,16 +257,28 @@ var t = class extends Event {
|
|
|
238
257
|
let n = this.audio();
|
|
239
258
|
if (!n) return;
|
|
240
259
|
this.unplay(e);
|
|
241
|
-
let r = n.createMediaStreamSource(t),
|
|
242
|
-
|
|
243
|
-
source:
|
|
244
|
-
volume:
|
|
245
|
-
|
|
260
|
+
let r = this.sink(e, t), i = n.createMediaStreamSource(t), a = n.createGain();
|
|
261
|
+
i.connect(a), this.meter(e, i), this.voices.set(e, {
|
|
262
|
+
source: i,
|
|
263
|
+
volume: a,
|
|
264
|
+
sink: r
|
|
265
|
+
}), this.applyVolume(e), a.connect(this.options.spatial?.(e, a, n) ?? n.destination);
|
|
266
|
+
}
|
|
267
|
+
sink(e, t) {
|
|
268
|
+
let n = globalThis.Audio;
|
|
269
|
+
if (!n) return;
|
|
270
|
+
let r = new n();
|
|
271
|
+
return r.muted = !0, r.srcObject = t, r.play().catch((t) => {
|
|
272
|
+
this.voices.get(e)?.sink === r && this.emit("error", {
|
|
273
|
+
peer: e,
|
|
274
|
+
error: t
|
|
275
|
+
});
|
|
276
|
+
}), r;
|
|
246
277
|
}
|
|
247
278
|
unplay(e) {
|
|
248
279
|
let t = this.voices.get(e);
|
|
249
280
|
if (!t) return;
|
|
250
|
-
t.source.disconnect(), t.volume.disconnect(), this.voices.delete(e), this.meters.delete(e);
|
|
281
|
+
t.source.disconnect(), t.volume.disconnect(), t.sink && (t.sink.pause(), t.sink.srcObject = null), this.voices.delete(e), this.meters.delete(e);
|
|
251
282
|
let n = this.remotes.get(e);
|
|
252
283
|
n?.speaking && (n.speaking = !1, this.emit("speaking", {
|
|
253
284
|
peer: e,
|
|
@@ -263,7 +294,7 @@ var t = class extends Event {
|
|
|
263
294
|
this.stopVoice(), this.stopScreenShare(), this.disposed = !0, clearInterval(this.timer);
|
|
264
295
|
for (let e of [...this.remotes.keys()]) this.detach(e);
|
|
265
296
|
for (let e of this.cleanup.splice(0)) e();
|
|
266
|
-
this.mesh.onlink = this.before, this.mesh.onunlink = this.beforeUnlink, this.dispatchEvent(new Event("dispose"));
|
|
297
|
+
this.mesh.onlink = this.before, this.mesh.onunlink = this.beforeUnlink, this.ownsContext && this.context.close(), this.dispatchEvent(new Event("dispose"));
|
|
267
298
|
}
|
|
268
299
|
}
|
|
269
300
|
[Symbol.dispose]() {
|
package/dist/physics.js
CHANGED
|
@@ -5,32 +5,32 @@ function r(e) {
|
|
|
5
5
|
let { world: t, schema: r, input: a, apply: c } = e, l = Math.round(1 / t.fixedTimestep);
|
|
6
6
|
if (!(l >= 1 && l <= 240) || Math.abs(l * t.fixedTimestep - 1) > 1e-9) throw RangeError(`A rollback physics world needs a step of 1 / n seconds for a whole n from 1 to 240 (got ${t.fixedTimestep} s); set fixedTimestep to 1 / 60, say.`);
|
|
7
7
|
if (!r.names.includes(a)) throw RangeError(`The schema has no struct "${a}"; pass the name of its input struct.`);
|
|
8
|
-
let u = t.takeSnapshot(),
|
|
9
|
-
if (!(e instanceof Uint8Array) || e.byteLength !==
|
|
8
|
+
let { stepCount: u, accumulator: d, ...f } = t.takeSnapshot(), p = f.bytes.byteLength, m = (e) => {
|
|
9
|
+
if (!(e instanceof Uint8Array) || e.byteLength !== p) throw RangeError(`A physics state is the ${p} bytes of the world's snapshot (got ${e?.byteLength ?? typeof e}); the world grew or another world sent it.`);
|
|
10
10
|
return e;
|
|
11
11
|
};
|
|
12
12
|
return {
|
|
13
13
|
schema: {
|
|
14
14
|
json: r.json,
|
|
15
|
-
hash: (r.hash ^ 1540483477 ^
|
|
15
|
+
hash: (r.hash ^ 1540483477 ^ p) >>> 0,
|
|
16
16
|
names: [...r.names, n],
|
|
17
|
-
encode: (e, t) => e === "PhysicsWorld" ?
|
|
18
|
-
decode: (e, t) => e === "PhysicsWorld" ?
|
|
19
|
-
encodeDelta: (e, t, n) => e === "PhysicsWorld" ? o(
|
|
20
|
-
decodeDelta: (e, t, n) => e === "PhysicsWorld" ? s(
|
|
17
|
+
encode: (e, t) => e === "PhysicsWorld" ? m(t).slice() : r.encode(e, t),
|
|
18
|
+
decode: (e, t) => e === "PhysicsWorld" ? m(t).slice() : r.decode(e, t),
|
|
19
|
+
encodeDelta: (e, t, n) => e === "PhysicsWorld" ? o(m(n), m(t)) : r.encodeDelta(e, t, n),
|
|
20
|
+
decodeDelta: (e, t, n) => e === "PhysicsWorld" ? s(m(n), t) : r.decodeDelta(e, t, n),
|
|
21
21
|
equals: (e, t, n) => e === "PhysicsWorld" ? i(t, n) : r.equals(e, t, n),
|
|
22
|
-
clone: (e, t) => e === "PhysicsWorld" ?
|
|
22
|
+
clone: (e, t) => e === "PhysicsWorld" ? m(t).slice() : r.clone(e, t),
|
|
23
23
|
interpolate: (e, t, n, i) => e === "PhysicsWorld" ? (i >= 1 ? n : t).slice() : r.interpolate(e, t, n, i)
|
|
24
24
|
},
|
|
25
25
|
stateType: n,
|
|
26
26
|
inputType: a,
|
|
27
27
|
tickRate: l,
|
|
28
28
|
tickMs: 1e3 / l,
|
|
29
|
-
initial: () =>
|
|
29
|
+
initial: () => f.bytes.slice(),
|
|
30
30
|
step(e, n, r) {
|
|
31
31
|
t.restoreSnapshot({
|
|
32
|
-
...
|
|
33
|
-
bytes:
|
|
32
|
+
...f,
|
|
33
|
+
bytes: m(e)
|
|
34
34
|
}), c(n, r), t.step(), e.set(t.takeSnapshot().bytes);
|
|
35
35
|
},
|
|
36
36
|
join() {},
|
package/dist/shared/bytes.d.ts
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
/** Signed integer to an unsigned one, small magnitudes small. */
|
|
2
|
-
export function zigzag(n: number): number;
|
|
3
|
-
/** The inverse of {@link zigzag}. */
|
|
4
|
-
export function unzigzag(z: number): number;
|
|
5
|
-
/**
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
/** Signed integer to an unsigned one, small magnitudes small. */
|
|
2
|
+
export function zigzag(n: number): number;
|
|
3
|
+
/** The inverse of {@link zigzag}. */
|
|
4
|
+
export function unzigzag(z: number): number;
|
|
5
|
+
/** The parts laid end to end in one new array. */
|
|
6
|
+
export function concatBytes(parts: readonly Uint8Array[]): Uint8Array<ArrayBuffer>;
|
|
7
|
+
/** A growing little-endian byte buffer. */
|
|
8
|
+
export class ByteWriter {
|
|
9
|
+
bytes: Uint8Array;
|
|
10
|
+
view: DataView;
|
|
11
|
+
at: number;
|
|
12
|
+
constructor(size?: number);
|
|
13
|
+
room(n: number): void;
|
|
14
|
+
u8(v: number): void;
|
|
15
|
+
u16(v: number): void;
|
|
16
|
+
u32(v: number): void;
|
|
17
|
+
f32(v: number): void;
|
|
18
|
+
varint(v: number): void;
|
|
19
|
+
raw(b: Uint8Array): void;
|
|
20
|
+
done(): Uint8Array<ArrayBuffer>;
|
|
21
|
+
}
|
|
22
|
+
/** Checked little-endian reads; failures throw RangeError `"<what> <problem>; <fix>"`. */
|
|
23
|
+
export class ByteReader {
|
|
24
|
+
readonly bytes: Uint8Array;
|
|
25
|
+
readonly view: DataView;
|
|
26
|
+
readonly what: string;
|
|
27
|
+
readonly fix: string;
|
|
28
|
+
at: number;
|
|
29
|
+
constructor(bytes: Uint8Array, what: string, fix: string, start?: number);
|
|
30
|
+
fail(problem: string, fix?: string): RangeError;
|
|
31
|
+
need(n: number): void;
|
|
32
|
+
u8(): number;
|
|
33
|
+
u16(): number;
|
|
34
|
+
u32(): number;
|
|
35
|
+
f32(): number;
|
|
36
|
+
varint(): number;
|
|
37
|
+
end(): void;
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@margoengine/netcode",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Game networking for any game: schema-first binary codec with delta snapshots, an authoritative fixed-timestep server, client prediction and reconciliation, interpolation and a loopback network for tests.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"margoengine",
|
|
7
|
-
"netcode",
|
|
8
|
-
"multiplayer",
|
|
9
|
-
"networking",
|
|
10
|
-
"prediction"
|
|
11
|
-
],
|
|
12
|
-
"homepage": "https://margoengine.com",
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/scottcampbelldata/margoengine/issues"
|
|
15
|
-
},
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/scottcampbelldata/margoengine.git",
|
|
19
|
-
"directory": "packages/netcode"
|
|
20
|
-
},
|
|
21
|
-
"license": "Apache-2.0",
|
|
22
|
-
"author": "Scott Campbell",
|
|
23
|
-
"type": "module",
|
|
24
|
-
"sideEffects": false,
|
|
25
|
-
"exports": {
|
|
26
|
-
".": {
|
|
27
|
-
"types": "./dist/index.d.ts",
|
|
28
|
-
"import": "./dist/index.js"
|
|
29
|
-
},
|
|
30
|
-
"./rollback": {
|
|
31
|
-
"types": "./dist/rollback.d.ts",
|
|
32
|
-
"import": "./dist/rollback.js"
|
|
33
|
-
},
|
|
34
|
-
"./physics": {
|
|
35
|
-
"types": "./dist/physics.d.ts",
|
|
36
|
-
"import": "./dist/physics.js"
|
|
37
|
-
},
|
|
38
|
-
"./websocket": {
|
|
39
|
-
"types": "./dist/websocket.d.ts",
|
|
40
|
-
"import": "./dist/websocket.js"
|
|
41
|
-
},
|
|
42
|
-
"./webrtc": {
|
|
43
|
-
"types": "./dist/webrtc.d.ts",
|
|
44
|
-
"import": "./dist/webrtc.js"
|
|
45
|
-
},
|
|
46
|
-
"./node": {
|
|
47
|
-
"types": "./dist/node.d.ts",
|
|
48
|
-
"import": "./dist/node.js"
|
|
49
|
-
},
|
|
50
|
-
"./rooms": {
|
|
51
|
-
"types": "./dist/rooms.d.ts",
|
|
52
|
-
"import": "./dist/rooms.js"
|
|
53
|
-
},
|
|
54
|
-
"./smoothing": {
|
|
55
|
-
"types": "./dist/smoothing.d.ts",
|
|
56
|
-
"import": "./dist/smoothing.js"
|
|
57
|
-
},
|
|
58
|
-
"./webtransport": {
|
|
59
|
-
"types": "./dist/webtransport.d.ts",
|
|
60
|
-
"import": "./dist/webtransport.js"
|
|
61
|
-
},
|
|
62
|
-
"./signal": {
|
|
63
|
-
"types": "./dist/signal.d.ts",
|
|
64
|
-
"import": "./dist/signal.js"
|
|
65
|
-
},
|
|
66
|
-
"./extrapolate": {
|
|
67
|
-
"types": "./dist/extrapolate.d.ts",
|
|
68
|
-
"import": "./dist/extrapolate.js"
|
|
69
|
-
},
|
|
70
|
-
"./relay": {
|
|
71
|
-
"types": "./dist/relay.d.ts",
|
|
72
|
-
"import": "./dist/relay.js"
|
|
73
|
-
},
|
|
74
|
-
"./hitboxes": {
|
|
75
|
-
"types": "./dist/hitboxes.d.ts",
|
|
76
|
-
"import": "./dist/hitboxes.js"
|
|
77
|
-
},
|
|
78
|
-
"./interest": {
|
|
79
|
-
"types": "./dist/interest.d.ts",
|
|
80
|
-
"import": "./dist/interest.js"
|
|
81
|
-
},
|
|
82
|
-
"./generate": {
|
|
83
|
-
"types": "./dist/generate.d.ts",
|
|
84
|
-
"import": "./dist/generate.js"
|
|
85
|
-
},
|
|
86
|
-
"./lobby": {
|
|
87
|
-
"types": "./dist/lobby.d.ts",
|
|
88
|
-
"import": "./dist/lobby.js"
|
|
89
|
-
},
|
|
90
|
-
"./media": {
|
|
91
|
-
"types": "./dist/media.d.ts",
|
|
92
|
-
"import": "./dist/media.js"
|
|
93
|
-
},
|
|
94
|
-
"./presence": {
|
|
95
|
-
"types": "./dist/presence.d.ts",
|
|
96
|
-
"import": "./dist/presence.js"
|
|
97
|
-
},
|
|
98
|
-
"./generate-rust": {
|
|
99
|
-
"types": "./dist/generate-rust.d.ts",
|
|
100
|
-
"import": "./dist/generate-rust.js"
|
|
101
|
-
},
|
|
102
|
-
"./migrate": {
|
|
103
|
-
"types": "./dist/migrate.d.ts",
|
|
104
|
-
"import": "./dist/migrate.js"
|
|
105
|
-
},
|
|
106
|
-
"./interpolation": {
|
|
107
|
-
"types": "./dist/interpolation.d.ts",
|
|
108
|
-
"import": "./dist/interpolation.js"
|
|
109
|
-
},
|
|
110
|
-
"./interpolation-delay": {
|
|
111
|
-
"types": "./dist/interpolation-delay.d.ts",
|
|
112
|
-
"import": "./dist/interpolation-delay.js"
|
|
113
|
-
},
|
|
114
|
-
"./interpolation-fields": {
|
|
115
|
-
"types": "./dist/interpolation-fields.d.ts",
|
|
116
|
-
"import": "./dist/interpolation-fields.js"
|
|
117
|
-
},
|
|
118
|
-
"./interpolation-timeline": {
|
|
119
|
-
"types": "./dist/interpolation-timeline.d.ts",
|
|
120
|
-
"import": "./dist/interpolation-timeline.js"
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
"files": [
|
|
124
|
-
"dist",
|
|
125
|
-
"LICENSE",
|
|
126
|
-
"NOTICE"
|
|
127
|
-
],
|
|
128
|
-
"publishConfig": {
|
|
129
|
-
"access": "public"
|
|
130
|
-
},
|
|
131
|
-
"dependencies": {
|
|
132
|
-
"@margoengine/math": "^
|
|
133
|
-
},
|
|
134
|
-
"scripts": {
|
|
135
|
-
"build": "node ../../scripts/build-optional.js netcode",
|
|
136
|
-
"test": "npm run build && node --test tests/*.test.js",
|
|
137
|
-
"test:browser": "npm run build && node tests/browser/signal.mjs",
|
|
138
|
-
"prepack": "npm run build"
|
|
139
|
-
}
|
|
140
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@margoengine/netcode",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Game networking for any game: schema-first binary codec with delta snapshots, an authoritative fixed-timestep server, client prediction and reconciliation, interpolation and a loopback network for tests.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"margoengine",
|
|
7
|
+
"netcode",
|
|
8
|
+
"multiplayer",
|
|
9
|
+
"networking",
|
|
10
|
+
"prediction"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://margoengine.com",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/scottcampbelldata/margoengine/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/scottcampbelldata/margoengine.git",
|
|
19
|
+
"directory": "packages/netcode"
|
|
20
|
+
},
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"author": "Scott Campbell",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./rollback": {
|
|
31
|
+
"types": "./dist/rollback.d.ts",
|
|
32
|
+
"import": "./dist/rollback.js"
|
|
33
|
+
},
|
|
34
|
+
"./physics": {
|
|
35
|
+
"types": "./dist/physics.d.ts",
|
|
36
|
+
"import": "./dist/physics.js"
|
|
37
|
+
},
|
|
38
|
+
"./websocket": {
|
|
39
|
+
"types": "./dist/websocket.d.ts",
|
|
40
|
+
"import": "./dist/websocket.js"
|
|
41
|
+
},
|
|
42
|
+
"./webrtc": {
|
|
43
|
+
"types": "./dist/webrtc.d.ts",
|
|
44
|
+
"import": "./dist/webrtc.js"
|
|
45
|
+
},
|
|
46
|
+
"./node": {
|
|
47
|
+
"types": "./dist/node.d.ts",
|
|
48
|
+
"import": "./dist/node.js"
|
|
49
|
+
},
|
|
50
|
+
"./rooms": {
|
|
51
|
+
"types": "./dist/rooms.d.ts",
|
|
52
|
+
"import": "./dist/rooms.js"
|
|
53
|
+
},
|
|
54
|
+
"./smoothing": {
|
|
55
|
+
"types": "./dist/smoothing.d.ts",
|
|
56
|
+
"import": "./dist/smoothing.js"
|
|
57
|
+
},
|
|
58
|
+
"./webtransport": {
|
|
59
|
+
"types": "./dist/webtransport.d.ts",
|
|
60
|
+
"import": "./dist/webtransport.js"
|
|
61
|
+
},
|
|
62
|
+
"./signal": {
|
|
63
|
+
"types": "./dist/signal.d.ts",
|
|
64
|
+
"import": "./dist/signal.js"
|
|
65
|
+
},
|
|
66
|
+
"./extrapolate": {
|
|
67
|
+
"types": "./dist/extrapolate.d.ts",
|
|
68
|
+
"import": "./dist/extrapolate.js"
|
|
69
|
+
},
|
|
70
|
+
"./relay": {
|
|
71
|
+
"types": "./dist/relay.d.ts",
|
|
72
|
+
"import": "./dist/relay.js"
|
|
73
|
+
},
|
|
74
|
+
"./hitboxes": {
|
|
75
|
+
"types": "./dist/hitboxes.d.ts",
|
|
76
|
+
"import": "./dist/hitboxes.js"
|
|
77
|
+
},
|
|
78
|
+
"./interest": {
|
|
79
|
+
"types": "./dist/interest.d.ts",
|
|
80
|
+
"import": "./dist/interest.js"
|
|
81
|
+
},
|
|
82
|
+
"./generate": {
|
|
83
|
+
"types": "./dist/generate.d.ts",
|
|
84
|
+
"import": "./dist/generate.js"
|
|
85
|
+
},
|
|
86
|
+
"./lobby": {
|
|
87
|
+
"types": "./dist/lobby.d.ts",
|
|
88
|
+
"import": "./dist/lobby.js"
|
|
89
|
+
},
|
|
90
|
+
"./media": {
|
|
91
|
+
"types": "./dist/media.d.ts",
|
|
92
|
+
"import": "./dist/media.js"
|
|
93
|
+
},
|
|
94
|
+
"./presence": {
|
|
95
|
+
"types": "./dist/presence.d.ts",
|
|
96
|
+
"import": "./dist/presence.js"
|
|
97
|
+
},
|
|
98
|
+
"./generate-rust": {
|
|
99
|
+
"types": "./dist/generate-rust.d.ts",
|
|
100
|
+
"import": "./dist/generate-rust.js"
|
|
101
|
+
},
|
|
102
|
+
"./migrate": {
|
|
103
|
+
"types": "./dist/migrate.d.ts",
|
|
104
|
+
"import": "./dist/migrate.js"
|
|
105
|
+
},
|
|
106
|
+
"./interpolation": {
|
|
107
|
+
"types": "./dist/interpolation.d.ts",
|
|
108
|
+
"import": "./dist/interpolation.js"
|
|
109
|
+
},
|
|
110
|
+
"./interpolation-delay": {
|
|
111
|
+
"types": "./dist/interpolation-delay.d.ts",
|
|
112
|
+
"import": "./dist/interpolation-delay.js"
|
|
113
|
+
},
|
|
114
|
+
"./interpolation-fields": {
|
|
115
|
+
"types": "./dist/interpolation-fields.d.ts",
|
|
116
|
+
"import": "./dist/interpolation-fields.js"
|
|
117
|
+
},
|
|
118
|
+
"./interpolation-timeline": {
|
|
119
|
+
"types": "./dist/interpolation-timeline.d.ts",
|
|
120
|
+
"import": "./dist/interpolation-timeline.js"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"files": [
|
|
124
|
+
"dist",
|
|
125
|
+
"LICENSE",
|
|
126
|
+
"NOTICE"
|
|
127
|
+
],
|
|
128
|
+
"publishConfig": {
|
|
129
|
+
"access": "public"
|
|
130
|
+
},
|
|
131
|
+
"dependencies": {
|
|
132
|
+
"@margoengine/math": "^1.0.0"
|
|
133
|
+
},
|
|
134
|
+
"scripts": {
|
|
135
|
+
"build": "node ../../scripts/build-optional.js netcode",
|
|
136
|
+
"test": "npm run build && node --test tests/*.test.js",
|
|
137
|
+
"test:browser": "npm run build && node tests/browser/signal.mjs && node tests/browser/media.mjs",
|
|
138
|
+
"prepack": "npm run build"
|
|
139
|
+
}
|
|
140
|
+
}
|