@genex-ai/multiplayer 0.17.1 → 0.17.8

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 (45) hide show
  1. package/PROTOCOL.md +761 -9
  2. package/README.md +285 -1
  3. package/WORLD-GLTF.md +109 -0
  4. package/WORLD-SCENE.md +135 -0
  5. package/dist/authority/fast-udp.d.ts +15 -0
  6. package/dist/authority/fast-udp.js +14 -0
  7. package/dist/authority/fast-webtransport.d.ts +67 -0
  8. package/dist/authority/fast-webtransport.js +21 -0
  9. package/dist/authority/index.d.ts +2671 -0
  10. package/dist/authority/index.js +958 -0
  11. package/dist/authority/module.d.ts +2 -0
  12. package/dist/authority/module.js +12 -0
  13. package/dist/bridge-authority.d.ts +101 -0
  14. package/dist/bridge-authority.global.js +15 -0
  15. package/dist/bridge-authority.js +291 -0
  16. package/dist/bridge-core-Dhc73GC8.d.ts +27 -0
  17. package/dist/bridge.d.ts +26 -20
  18. package/dist/bridge.global.js +7 -7
  19. package/dist/bridge.js +17 -48
  20. package/dist/chunk-2NGXXQDS.js +1916 -0
  21. package/dist/chunk-4R7C2TLH.js +68 -0
  22. package/dist/{chunk-C52XFIB6.js → chunk-CSQEEANB.js} +217 -4
  23. package/dist/chunk-FPWP22Y7.js +143 -0
  24. package/dist/chunk-NFMGIKFZ.js +2627 -0
  25. package/dist/chunk-OD6NRSX2.js +29 -0
  26. package/dist/{chunk-3ZUPU3GT.js → chunk-QY3QQNDJ.js} +13 -122
  27. package/dist/chunk-QZOCUQJT.js +6900 -0
  28. package/dist/chunk-TSYEWPVO.js +44 -0
  29. package/dist/chunk-TVTVIMIH.js +675 -0
  30. package/dist/chunk-YWQ3ALYY.js +69 -0
  31. package/dist/fast-client--A88q0kk.d.ts +546 -0
  32. package/dist/index.d.ts +3 -5
  33. package/dist/index.js +3 -2
  34. package/dist/join-CGoInvUM.d.ts +6 -0
  35. package/dist/level-build-CbRqrYJq.d.ts +140 -0
  36. package/dist/module-CSpXrzFc.d.ts +1187 -0
  37. package/dist/physics-predict-C7ZB1gDG.d.ts +1223 -0
  38. package/dist/protocol.d.ts +222 -2
  39. package/dist/protocol.js +47 -1
  40. package/dist/shot-world-D22tqOUT.d.ts +485 -0
  41. package/dist/world-fit/index.d.ts +549 -0
  42. package/dist/world-fit/index.js +4763 -0
  43. package/dist/world-fit/three.d.ts +77 -0
  44. package/dist/world-fit/three.js +140 -0
  45. package/package.json +46 -4
package/dist/bridge.js CHANGED
@@ -1,40 +1,35 @@
1
+ import {
2
+ drainQueueJson,
3
+ embedIdentity,
4
+ errorCode,
5
+ errorMessage,
6
+ isObject,
7
+ parseJson,
8
+ parseObject,
9
+ push,
10
+ warningEvent
11
+ } from "./chunk-4R7C2TLH.js";
1
12
  import {
2
13
  connect,
3
14
  createPrivate,
4
15
  joinPrivate,
5
16
  matchmake,
6
17
  roomOf
7
- } from "./chunk-3ZUPU3GT.js";
18
+ } from "./chunk-QY3QQNDJ.js";
19
+ import "./chunk-FPWP22Y7.js";
8
20
  import {
9
21
  Limits,
10
22
  RESERVED_SHARED_PREFIX,
11
23
  ServerMessage,
12
24
  isReservedEventType
13
- } from "./chunk-C52XFIB6.js";
25
+ } from "./chunk-CSQEEANB.js";
14
26
 
15
27
  // src/bridge.ts
16
- import { getColyseusAuth, getColyseusUrls, initEmbed, waitForPlayer } from "@genex-ai/embed-sdk";
17
- var version = 1;
18
- var embedIdentity = {
19
- ready(gameId) {
20
- const cfg = globalThis.__GENEX__;
21
- if (gameId && cfg && typeof cfg.apiUrl === "string" && Array.isArray(cfg.dashboardOrigins)) {
22
- initEmbed({
23
- slug: gameId,
24
- apiUrl: cfg.apiUrl,
25
- dashboardOrigins: cfg.dashboardOrigins.filter((o) => typeof o === "string")
26
- });
27
- }
28
- return waitForPlayer();
29
- },
30
- auth: () => getColyseusAuth(),
31
- urls: () => getColyseusUrls()
32
- };
28
+ var version = 2;
33
29
  var identity = embedIdentity;
34
30
  function setIdentity(next) {
35
31
  identity = next ?? embedIdentity;
36
32
  }
37
- var isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
38
33
  function parseOptions(optsJson) {
39
34
  const o = JSON.parse(optsJson);
40
35
  if (!isObject(o)) throw new TypeError("genex bridge: options must be a JSON object");
@@ -60,25 +55,9 @@ function parseOptions(optsJson) {
60
55
  options: isObject(o.options) ? o.options : void 0
61
56
  };
62
57
  }
63
- var MAX_QUEUED_EVENTS = 4096;
64
58
  var sessions = /* @__PURE__ */ new Map();
65
59
  var nextHandle = 1;
66
- function push(e, event) {
67
- if (e.q.length >= MAX_QUEUED_EVENTS) {
68
- if (e.overflowed) e.q.splice(1, 1);
69
- else {
70
- e.overflowed = true;
71
- e.q.splice(0, 2, { type: "warning", message: "genex bridge: event queue full; drain it every frame (oldest events dropped)" });
72
- }
73
- }
74
- e.q.push(event);
75
- }
76
60
  var current = (e) => e.closed ? null : e.mm ? e.mm.session : e.session;
77
- var errorCode = (err) => {
78
- const c = isObject(err) || err instanceof Error ? err.code : void 0;
79
- return typeof c === "number" && Number.isFinite(c) ? c : 0;
80
- };
81
- var errorMessage = (err) => err instanceof Error ? err.message : typeof err === "string" ? err : "join failed";
82
61
  function end(e) {
83
62
  e.closed = true;
84
63
  e.connected = false;
@@ -270,15 +249,6 @@ var live = (handle) => {
270
249
  follow(e);
271
250
  return current(e);
272
251
  };
273
- function parseJson(json, what) {
274
- if (typeof json !== "string") throw new TypeError(`genex bridge: ${what} must be a JSON string`);
275
- return JSON.parse(json);
276
- }
277
- function parseObject(json, what) {
278
- const v = parseJson(json, what);
279
- if (!isObject(v)) throw new TypeError(`genex bridge: ${what} must be a JSON object`);
280
- return v;
281
- }
282
252
  function leave(handle) {
283
253
  const e = entry(handle);
284
254
  if (!e || e.closed) return;
@@ -518,11 +488,10 @@ function drainEventsJson(handle) {
518
488
  }
519
489
  }
520
490
  e.changed.clear();
521
- e.overflowed = false;
522
- return JSON.stringify(e.q.splice(0));
523
491
  } catch (err) {
524
- return JSON.stringify([{ type: "warning", message: `genex bridge: ${errorMessage(err)}` }]);
492
+ push(e, warningEvent(errorMessage(err)));
525
493
  }
494
+ return drainQueueJson(e);
526
495
  }
527
496
  export {
528
497
  chatSend,