@colyseus/core 0.16.0-preview.9 → 0.16.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.
Files changed (146) hide show
  1. package/README.md +5 -5
  2. package/build/Debug.js +6 -2
  3. package/build/Debug.js.map +2 -2
  4. package/build/Debug.mjs +11 -10
  5. package/build/Debug.mjs.map +2 -2
  6. package/build/IPC.d.ts +1 -1
  7. package/build/IPC.js +3 -3
  8. package/build/IPC.js.map +2 -2
  9. package/build/IPC.mjs +4 -3
  10. package/build/IPC.mjs.map +2 -2
  11. package/build/Logger.mjs +4 -3
  12. package/build/Logger.mjs.map +1 -1
  13. package/build/MatchMaker.d.ts +35 -30
  14. package/build/MatchMaker.js +150 -100
  15. package/build/MatchMaker.js.map +2 -2
  16. package/build/MatchMaker.mjs +154 -107
  17. package/build/MatchMaker.mjs.map +2 -2
  18. package/build/Protocol.d.ts +3 -4
  19. package/build/Protocol.js +33 -19
  20. package/build/Protocol.js.map +2 -2
  21. package/build/Protocol.mjs +36 -21
  22. package/build/Protocol.mjs.map +2 -2
  23. package/build/Room.d.ts +64 -40
  24. package/build/Room.js +408 -151
  25. package/build/Room.js.map +2 -2
  26. package/build/Room.mjs +412 -158
  27. package/build/Room.mjs.map +2 -2
  28. package/build/Server.d.ts +8 -7
  29. package/build/Server.js +51 -18
  30. package/build/Server.js.map +2 -2
  31. package/build/Server.mjs +51 -21
  32. package/build/Server.mjs.map +3 -3
  33. package/build/Stats.d.ts +2 -0
  34. package/build/Stats.js +38 -3
  35. package/build/Stats.js.map +2 -2
  36. package/build/Stats.mjs +30 -6
  37. package/build/Stats.mjs.map +2 -2
  38. package/build/Transport.d.ts +8 -7
  39. package/build/Transport.js +1 -1
  40. package/build/Transport.js.map +2 -2
  41. package/build/Transport.mjs +6 -5
  42. package/build/Transport.mjs.map +2 -2
  43. package/build/discovery/index.d.ts +1 -1
  44. package/build/discovery/index.js.map +2 -2
  45. package/build/discovery/index.mjs +3 -2
  46. package/build/discovery/index.mjs.map +2 -2
  47. package/build/errors/RoomExceptions.d.ts +39 -0
  48. package/build/errors/RoomExceptions.js +100 -0
  49. package/build/errors/RoomExceptions.js.map +7 -0
  50. package/build/errors/RoomExceptions.mjs +71 -0
  51. package/build/errors/RoomExceptions.mjs.map +7 -0
  52. package/build/errors/SeatReservationError.mjs +3 -2
  53. package/build/errors/SeatReservationError.mjs.map +1 -1
  54. package/build/errors/ServerError.js +1 -1
  55. package/build/errors/ServerError.js.map +1 -1
  56. package/build/errors/ServerError.mjs +5 -4
  57. package/build/errors/ServerError.mjs.map +2 -2
  58. package/build/index.d.ts +21 -19
  59. package/build/index.js +45 -20
  60. package/build/index.js.map +2 -2
  61. package/build/index.mjs +39 -19
  62. package/build/index.mjs.map +2 -2
  63. package/build/matchmaker/Lobby.d.ts +3 -3
  64. package/build/matchmaker/Lobby.js +6 -3
  65. package/build/matchmaker/Lobby.js.map +2 -2
  66. package/build/matchmaker/Lobby.mjs +4 -4
  67. package/build/matchmaker/Lobby.mjs.map +2 -2
  68. package/build/matchmaker/RegisteredHandler.d.ts +6 -7
  69. package/build/matchmaker/RegisteredHandler.js +7 -10
  70. package/build/matchmaker/RegisteredHandler.js.map +2 -2
  71. package/build/matchmaker/RegisteredHandler.mjs +11 -13
  72. package/build/matchmaker/RegisteredHandler.mjs.map +2 -2
  73. package/build/matchmaker/controller.d.ts +4 -5
  74. package/build/matchmaker/controller.js +22 -15
  75. package/build/matchmaker/controller.js.map +2 -2
  76. package/build/matchmaker/controller.mjs +19 -13
  77. package/build/matchmaker/controller.mjs.map +2 -2
  78. package/build/matchmaker/driver/api.d.ts +104 -0
  79. package/build/matchmaker/driver/api.js +29 -0
  80. package/build/matchmaker/driver/api.js.map +7 -0
  81. package/build/matchmaker/driver/api.mjs +7 -0
  82. package/build/matchmaker/driver/api.mjs.map +7 -0
  83. package/build/matchmaker/driver/index.d.ts +2 -2
  84. package/build/matchmaker/driver/index.js +2 -2
  85. package/build/matchmaker/driver/index.js.map +2 -2
  86. package/build/matchmaker/driver/index.mjs +5 -4
  87. package/build/matchmaker/driver/index.mjs.map +2 -2
  88. package/build/matchmaker/driver/local/LocalDriver.d.ts +13 -0
  89. package/build/matchmaker/driver/local/LocalDriver.js +65 -0
  90. package/build/matchmaker/driver/local/LocalDriver.js.map +7 -0
  91. package/build/matchmaker/driver/local/LocalDriver.mjs +43 -0
  92. package/build/matchmaker/driver/local/LocalDriver.mjs.map +7 -0
  93. package/build/matchmaker/driver/local/Query.d.ts +9 -0
  94. package/build/matchmaker/driver/local/Query.js +78 -0
  95. package/build/matchmaker/driver/local/Query.js.map +7 -0
  96. package/build/matchmaker/driver/local/Query.mjs +56 -0
  97. package/build/matchmaker/driver/local/Query.mjs.map +7 -0
  98. package/build/matchmaker/driver/local/RoomData.d.ts +19 -0
  99. package/build/matchmaker/driver/local/RoomData.js +79 -0
  100. package/build/matchmaker/driver/local/RoomData.js.map +7 -0
  101. package/build/matchmaker/driver/local/RoomData.mjs +57 -0
  102. package/build/matchmaker/driver/local/RoomData.mjs.map +7 -0
  103. package/build/presence/LocalPresence.d.ts +10 -6
  104. package/build/presence/LocalPresence.js +85 -24
  105. package/build/presence/LocalPresence.js.map +3 -3
  106. package/build/presence/LocalPresence.mjs +85 -27
  107. package/build/presence/LocalPresence.mjs.map +3 -3
  108. package/build/presence/Presence.d.ts +38 -2
  109. package/build/presence/Presence.js.map +1 -1
  110. package/build/rooms/LobbyRoom.d.ts +6 -6
  111. package/build/rooms/LobbyRoom.js +8 -3
  112. package/build/rooms/LobbyRoom.js.map +2 -2
  113. package/build/rooms/LobbyRoom.mjs +7 -5
  114. package/build/rooms/LobbyRoom.mjs.map +2 -2
  115. package/build/rooms/RelayRoom.d.ts +3 -3
  116. package/build/rooms/RelayRoom.js +3 -1
  117. package/build/rooms/RelayRoom.js.map +2 -2
  118. package/build/rooms/RelayRoom.mjs +10 -7
  119. package/build/rooms/RelayRoom.mjs.map +2 -2
  120. package/build/serializer/NoneSerializer.d.ts +2 -2
  121. package/build/serializer/NoneSerializer.js.map +1 -1
  122. package/build/serializer/NoneSerializer.mjs +3 -2
  123. package/build/serializer/NoneSerializer.mjs.map +2 -2
  124. package/build/serializer/SchemaSerializer.d.ts +16 -15
  125. package/build/serializer/SchemaSerializer.js +12 -10
  126. package/build/serializer/SchemaSerializer.js.map +2 -2
  127. package/build/serializer/SchemaSerializer.mjs +16 -13
  128. package/build/serializer/SchemaSerializer.mjs.map +2 -2
  129. package/build/serializer/SchemaSerializerDebug.d.ts +7 -0
  130. package/build/serializer/SchemaSerializerDebug.js +0 -0
  131. package/build/serializer/SchemaSerializerDebug.js.map +7 -0
  132. package/build/serializer/SchemaSerializerDebug.mjs +0 -0
  133. package/build/serializer/SchemaSerializerDebug.mjs.map +7 -0
  134. package/build/serializer/Serializer.d.ts +1 -2
  135. package/build/serializer/Serializer.js.map +1 -1
  136. package/build/utils/DevMode.d.ts +2 -2
  137. package/build/utils/DevMode.js +8 -4
  138. package/build/utils/DevMode.js.map +2 -2
  139. package/build/utils/DevMode.mjs +7 -6
  140. package/build/utils/DevMode.mjs.map +2 -2
  141. package/build/utils/Utils.d.ts +8 -3
  142. package/build/utils/Utils.js +41 -17
  143. package/build/utils/Utils.js.map +2 -2
  144. package/build/utils/Utils.mjs +40 -21
  145. package/build/utils/Utils.mjs.map +2 -2
  146. package/package.json +17 -6
package/README.md CHANGED
@@ -7,19 +7,19 @@
7
7
  <a href="https://npmjs.com/package/colyseus">
8
8
  <img src="https://img.shields.io/npm/dm/colyseus.svg?style=for-the-badge&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAKqNIzIAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAHdElNRQfjAgETESWYxR33AAAAtElEQVQoz4WQMQrCQBRE38Z0QoTcwF4Qg1h4BO0sxGOk80iCtViksrIQRRBTewWxMI1mbELYjYu+4rPMDPtn12ChMT3gavb4US5Jym0tcBIta3oDHv4Gwmr7nC4QAxBrCdzM2q6XqUnm9m9r59h7Rc0n2pFv24k4ttGMUXW+sGELTJjSr7QDKuqLS6UKFChVWWuFkZw9Z2AAvAirKT+JTlppIRnd6XgaP4goefI2Shj++OnjB3tBmHYK8z9zAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE5LTAyLTAxVDE4OjE3OjM3KzAxOjAwGQQixQAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOS0wMi0wMVQxODoxNzozNyswMTowMGhZmnkAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAAAElFTkSuQmCC">
9
9
  </a>
10
- <a href="http://chat.colyseus.io">
11
- <img src="https://img.shields.io/discord/525739117951320081.svg?style=for-the-badge&colorB=7581dc&logo=discord&logoColor=white">
12
- </a>
13
10
  <a href="https://github.com/colyseus/colyseus/discussions" title="Discuss on Forum">
14
11
  <img src="https://img.shields.io/badge/discuss-on%20forum-brightgreen.svg?style=for-the-badge&colorB=0069b8&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAKqNIzIAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAHdElNRQfjAgETDROxCNUzAAABB0lEQVQoz4WRvyvEARjGP193CnWRH+dHQmGwKZtFGcSmxHAL400GN95ktIpV2dzlLzDJgsGgGNRdDAzoQueS/PgY3HXHyT3T+/Y87/s89UANBKXBdoZo5J6L4K1K5ZxHfnjnlQUf3bKvkgy57a0r9hS3cXfMO1kWJMza++tj3Ac7/LY343x1NA9cNmYMwnSS/SP8JVFuSJmr44iFqvtmpjhmhBCrOOazCesq6H4P3bPBjFoIBydOk2bUA17I080Es+wSZ51B4DIA2zgjSpYcEe44Js01G0XjRcCU+y4ZMrDeLmfc9EnVd5M/o0VMeu6nJZxWJivLmhyw1WHTvrr2b4+2OFqra+ALwouTMDcqmjMAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTktMDItMDFUMTg6MTM6MTkrMDE6MDAC9f6fAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE5LTAyLTAxVDE4OjEzOjE5KzAxOjAwc6hGIwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAAASUVORK5CYII=" alt="Discussion forum" />
15
12
  </a>
13
+ <a href="http://chat.colyseus.io">
14
+ <img src="https://img.shields.io/discord/525739117951320081.svg?style=for-the-badge&colorB=7581dc&logo=discord&logoColor=white">
15
+ </a>
16
16
  <h3>
17
17
  Multiplayer Framework for Node.js. <br /><a href="https://docs.colyseus.io/">View documentation</a>
18
18
  </h3>
19
19
  </div>
20
20
 
21
- Colyseus is an Authoritative Multiplayer Framework for Node.js, with SDKs
22
- available for the Web, Unity, Defold, Haxe, Cocos and Construct3. ([See official SDKs](https://docs.colyseus.io/client/))
21
+ Colyseus is an Authoritative Multiplayer Framework for Node.js, with clients
22
+ available for the Web, Unity3d, Defold, Haxe, and Cocos. ([See official clients](#%EF%B8%8F-official-client-integration))
23
23
 
24
24
  The project focuses on providing synchronizable data structures for realtime and
25
25
  turn-based games, matchmaking, and ease of usage both on the server-side and
package/build/Debug.js CHANGED
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -34,8 +38,8 @@ __export(Debug_exports, {
34
38
  });
35
39
  module.exports = __toCommonJS(Debug_exports);
36
40
  var import_debug = __toESM(require("debug"));
37
- var import_Logger = require("./Logger");
38
- var import_ServerError = require("./errors/ServerError");
41
+ var import_Logger = require("./Logger.js");
42
+ var import_ServerError = require("./errors/ServerError.js");
39
43
  const debugConnection = (0, import_debug.default)("colyseus:connection");
40
44
  const debugDriver = (0, import_debug.default)("colyseus:driver");
41
45
  const debugError = (0, import_debug.default)("colyseus:errors");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/Debug.ts"],
4
- "sourcesContent": ["import debug from 'debug';\nimport { logger } from './Logger';\nimport { ServerError } from './errors/ServerError';\n\nexport const debugConnection = debug('colyseus:connection');\nexport const debugDriver = debug('colyseus:driver');\nexport const debugError = debug('colyseus:errors');\nexport const debugMatchMaking = debug('colyseus:matchmaking');\nexport const debugMessage = debug('colyseus:message');\nexport const debugPatch = debug('colyseus:patch');\nexport const debugPresence = debug('colyseus:presence');\n\nexport const debugAndPrintError = (e: Error | string) => {\n const message = (e instanceof Error) ? e.stack : e;\n\n if (!(e instanceof ServerError)) {\n logger.error(message);\n }\n\n debugError.call(debugError, message);\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,oBAAuB;AACvB,yBAA4B;AAErB,MAAM,sBAAkB,aAAAA,SAAM,qBAAqB;AACnD,MAAM,kBAAc,aAAAA,SAAM,iBAAiB;AAC3C,MAAM,iBAAa,aAAAA,SAAM,iBAAiB;AAC1C,MAAM,uBAAmB,aAAAA,SAAM,sBAAsB;AACrD,MAAM,mBAAe,aAAAA,SAAM,kBAAkB;AAC7C,MAAM,iBAAa,aAAAA,SAAM,gBAAgB;AACzC,MAAM,oBAAgB,aAAAA,SAAM,mBAAmB;AAE/C,MAAM,qBAAqB,CAAC,MAAsB;AACvD,QAAM,UAAW,aAAa,QAAS,EAAE,QAAQ;AAEjD,MAAI,EAAE,aAAa,iCAAc;AAC/B,yBAAO,MAAM,OAAO;AAAA,EACtB;AAEA,aAAW,KAAK,YAAY,OAAO;AACrC;",
4
+ "sourcesContent": ["import debug from 'debug';\nimport { logger } from './Logger.js';\nimport { ServerError } from './errors/ServerError.js';\n\nexport const debugConnection = debug('colyseus:connection');\nexport const debugDriver = debug('colyseus:driver');\nexport const debugError = debug('colyseus:errors');\nexport const debugMatchMaking = debug('colyseus:matchmaking');\nexport const debugMessage = debug('colyseus:message');\nexport const debugPatch = debug('colyseus:patch');\nexport const debugPresence = debug('colyseus:presence');\n\nexport const debugAndPrintError = (e: Error | string) => {\n const message = (e instanceof Error) ? e.stack : e;\n\n if (!(e instanceof ServerError)) {\n logger.error(message);\n }\n\n debugError.call(debugError, message);\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,oBAAuB;AACvB,yBAA4B;AAErB,MAAM,sBAAkB,aAAAA,SAAM,qBAAqB;AACnD,MAAM,kBAAc,aAAAA,SAAM,iBAAiB;AAC3C,MAAM,iBAAa,aAAAA,SAAM,iBAAiB;AAC1C,MAAM,uBAAmB,aAAAA,SAAM,sBAAsB;AACrD,MAAM,mBAAe,aAAAA,SAAM,kBAAkB;AAC7C,MAAM,iBAAa,aAAAA,SAAM,gBAAgB;AACzC,MAAM,oBAAgB,aAAAA,SAAM,mBAAmB;AAE/C,MAAM,qBAAqB,CAAC,MAAsB;AACvD,QAAM,UAAW,aAAa,QAAS,EAAE,QAAQ;AAEjD,MAAI,EAAE,aAAa,iCAAc;AAC/B,yBAAO,MAAM,OAAO;AAAA,EACtB;AAEA,aAAW,KAAK,YAAY,OAAO;AACrC;",
6
6
  "names": ["debug"]
7
7
  }
package/build/Debug.mjs CHANGED
@@ -1,14 +1,15 @@
1
+ // packages/core/src/Debug.ts
1
2
  import debug from "debug";
2
- import { logger } from "./Logger";
3
- import { ServerError } from "./errors/ServerError";
4
- const debugConnection = debug("colyseus:connection");
5
- const debugDriver = debug("colyseus:driver");
6
- const debugError = debug("colyseus:errors");
7
- const debugMatchMaking = debug("colyseus:matchmaking");
8
- const debugMessage = debug("colyseus:message");
9
- const debugPatch = debug("colyseus:patch");
10
- const debugPresence = debug("colyseus:presence");
11
- const debugAndPrintError = (e) => {
3
+ import { logger } from "./Logger.mjs";
4
+ import { ServerError } from "./errors/ServerError.mjs";
5
+ var debugConnection = debug("colyseus:connection");
6
+ var debugDriver = debug("colyseus:driver");
7
+ var debugError = debug("colyseus:errors");
8
+ var debugMatchMaking = debug("colyseus:matchmaking");
9
+ var debugMessage = debug("colyseus:message");
10
+ var debugPatch = debug("colyseus:patch");
11
+ var debugPresence = debug("colyseus:presence");
12
+ var debugAndPrintError = (e) => {
12
13
  const message = e instanceof Error ? e.stack : e;
13
14
  if (!(e instanceof ServerError)) {
14
15
  logger.error(message);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/Debug.ts"],
4
- "sourcesContent": ["import debug from 'debug';\nimport { logger } from './Logger';\nimport { ServerError } from './errors/ServerError';\n\nexport const debugConnection = debug('colyseus:connection');\nexport const debugDriver = debug('colyseus:driver');\nexport const debugError = debug('colyseus:errors');\nexport const debugMatchMaking = debug('colyseus:matchmaking');\nexport const debugMessage = debug('colyseus:message');\nexport const debugPatch = debug('colyseus:patch');\nexport const debugPresence = debug('colyseus:presence');\n\nexport const debugAndPrintError = (e: Error | string) => {\n const message = (e instanceof Error) ? e.stack : e;\n\n if (!(e instanceof ServerError)) {\n logger.error(message);\n }\n\n debugError.call(debugError, message);\n};\n"],
5
- "mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAErB,MAAM,kBAAkB,MAAM,qBAAqB;AACnD,MAAM,cAAc,MAAM,iBAAiB;AAC3C,MAAM,aAAa,MAAM,iBAAiB;AAC1C,MAAM,mBAAmB,MAAM,sBAAsB;AACrD,MAAM,eAAe,MAAM,kBAAkB;AAC7C,MAAM,aAAa,MAAM,gBAAgB;AACzC,MAAM,gBAAgB,MAAM,mBAAmB;AAE/C,MAAM,qBAAqB,CAAC,MAAsB;AACvD,QAAM,UAAW,aAAa,QAAS,EAAE,QAAQ;AAEjD,MAAI,EAAE,aAAa,cAAc;AAC/B,WAAO,MAAM,OAAO;AAAA,EACtB;AAEA,aAAW,KAAK,YAAY,OAAO;AACrC;",
4
+ "sourcesContent": ["import debug from 'debug';\nimport { logger } from './Logger.js';\nimport { ServerError } from './errors/ServerError.js';\n\nexport const debugConnection = debug('colyseus:connection');\nexport const debugDriver = debug('colyseus:driver');\nexport const debugError = debug('colyseus:errors');\nexport const debugMatchMaking = debug('colyseus:matchmaking');\nexport const debugMessage = debug('colyseus:message');\nexport const debugPatch = debug('colyseus:patch');\nexport const debugPresence = debug('colyseus:presence');\n\nexport const debugAndPrintError = (e: Error | string) => {\n const message = (e instanceof Error) ? e.stack : e;\n\n if (!(e instanceof ServerError)) {\n logger.error(message);\n }\n\n debugError.call(debugError, message);\n};\n"],
5
+ "mappings": ";AAAA,OAAO,WAAW;AAClB,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAErB,IAAM,kBAAkB,MAAM,qBAAqB;AACnD,IAAM,cAAc,MAAM,iBAAiB;AAC3C,IAAM,aAAa,MAAM,iBAAiB;AAC1C,IAAM,mBAAmB,MAAM,sBAAsB;AACrD,IAAM,eAAe,MAAM,kBAAkB;AAC7C,IAAM,aAAa,MAAM,gBAAgB;AACzC,IAAM,gBAAgB,MAAM,mBAAmB;AAE/C,IAAM,qBAAqB,CAAC,MAAsB;AACvD,QAAM,UAAW,aAAa,QAAS,EAAE,QAAQ;AAEjD,MAAI,EAAE,aAAa,cAAc;AAC/B,WAAO,MAAM,OAAO;AAAA,EACtB;AAEA,aAAW,KAAK,YAAY,OAAO;AACrC;",
6
6
  "names": []
7
7
  }
package/build/IPC.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { Presence } from './presence/Presence';
1
+ import { Presence } from './presence/Presence.js';
2
2
  export declare function requestFromIPC<T>(presence: Presence, publishToChannel: string, method: string, args: any[], rejectionTimeout?: number): Promise<T>;
3
3
  export declare function subscribeIPC(presence: Presence, processId: string, channel: string, replyCallback: (method: string, args: any[]) => any): Promise<void>;
package/build/IPC.js CHANGED
@@ -21,9 +21,9 @@ __export(IPC_exports, {
21
21
  subscribeIPC: () => subscribeIPC
22
22
  });
23
23
  module.exports = __toCommonJS(IPC_exports);
24
- var import_Debug = require("./Debug");
25
- var import_Protocol = require("./Protocol");
26
- var import_Utils = require("./utils/Utils");
24
+ var import_Debug = require("./Debug.js");
25
+ var import_Protocol = require("./Protocol.js");
26
+ var import_Utils = require("./utils/Utils.js");
27
27
  async function requestFromIPC(presence, publishToChannel, method, args, rejectionTimeout = import_Utils.REMOTE_ROOM_SHORT_TIMEOUT) {
28
28
  return new Promise((resolve, reject) => {
29
29
  let unsubscribeTimeout;
package/build/IPC.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/IPC.ts"],
4
- "sourcesContent": ["import { debugAndPrintError } from './Debug';\nimport { Presence } from './presence/Presence';\nimport { IpcProtocol } from './Protocol';\nimport { generateId, REMOTE_ROOM_SHORT_TIMEOUT } from './utils/Utils';\n\nexport async function requestFromIPC<T>(\n presence: Presence,\n publishToChannel: string,\n method: string,\n args: any[],\n rejectionTimeout: number = REMOTE_ROOM_SHORT_TIMEOUT,\n): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n let unsubscribeTimeout: NodeJS.Timeout;\n\n const requestId = generateId();\n const channel = `ipc:${requestId}`;\n\n const unsubscribe = () => {\n presence.unsubscribe(channel);\n clearTimeout(unsubscribeTimeout);\n };\n\n presence.subscribe(channel, (message) => {\n const [code, data] = message;\n if (code === IpcProtocol.SUCCESS) {\n resolve(data);\n\n } else if (code === IpcProtocol.ERROR) {\n let error: any = data;\n\n // parse error message + code\n try { error = JSON.parse(data) } catch (e) {}\n\n // turn string message into Error instance\n if (typeof(error) === \"string\") {\n error = new Error(error);\n }\n\n reject(error);\n }\n unsubscribe();\n });\n\n presence.publish(publishToChannel, [method, requestId, args]);\n\n unsubscribeTimeout = setTimeout(() => {\n unsubscribe();\n reject(new Error(\"ipc_timeout\"));\n }, rejectionTimeout);\n });\n}\n\nexport async function subscribeIPC(\n presence: Presence,\n processId: string,\n channel: string,\n replyCallback: (method: string, args: any[]) => any,\n) {\n await presence.subscribe(channel, (message) => {\n const [method, requestId, args] = message;\n\n const reply = (code, data) => {\n presence.publish(`ipc:${requestId}`, [code, data]);\n };\n\n // reply with method result\n let response: any;\n try {\n response = replyCallback(method, args);\n\n } catch (e) {\n debugAndPrintError(e);\n const error = (typeof(e.code) !== \"undefined\")\n ? { code: e.code, message: e.message }\n : e.message;\n return reply(IpcProtocol.ERROR, JSON.stringify(error));\n }\n\n if (!(response instanceof Promise)) {\n return reply(IpcProtocol.SUCCESS, response);\n }\n\n response.\n then((result) => reply(IpcProtocol.SUCCESS, result)).\n catch((e) => {\n // user might have called `reject()` without arguments.\n const err = e && e.message || e;\n reply(IpcProtocol.ERROR, err);\n });\n });\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmC;AAEnC,sBAA4B;AAC5B,mBAAsD;AAEtD,eAAsB,eACpB,UACA,kBACA,QACA,MACA,mBAA2B,wCACf;AACZ,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,QAAI;AAEJ,UAAM,gBAAY,yBAAW;AAC7B,UAAM,UAAU,OAAO;AAEvB,UAAM,cAAc,MAAM;AACxB,eAAS,YAAY,OAAO;AAC5B,mBAAa,kBAAkB;AAAA,IACjC;AAEA,aAAS,UAAU,SAAS,CAAC,YAAY;AACvC,YAAM,CAAC,MAAM,IAAI,IAAI;AACrB,UAAI,SAAS,4BAAY,SAAS;AAChC,gBAAQ,IAAI;AAAA,MAEd,WAAW,SAAS,4BAAY,OAAO;AACrC,YAAI,QAAa;AAGjB,YAAI;AAAE,kBAAQ,KAAK,MAAM,IAAI;AAAA,QAAE,SAAS,GAAP;AAAA,QAAW;AAG5C,YAAI,OAAO,UAAW,UAAU;AAC9B,kBAAQ,IAAI,MAAM,KAAK;AAAA,QACzB;AAEA,eAAO,KAAK;AAAA,MACd;AACA,kBAAY;AAAA,IACd,CAAC;AAED,aAAS,QAAQ,kBAAkB,CAAC,QAAQ,WAAW,IAAI,CAAC;AAE5D,yBAAqB,WAAW,MAAM;AACpC,kBAAY;AACZ,aAAO,IAAI,MAAM,aAAa,CAAC;AAAA,IACjC,GAAG,gBAAgB;AAAA,EACrB,CAAC;AACH;AAEA,eAAsB,aACpB,UACA,WACA,SACA,eACA;AACA,QAAM,SAAS,UAAU,SAAS,CAAC,YAAY;AAC7C,UAAM,CAAC,QAAQ,WAAW,IAAI,IAAI;AAElC,UAAM,QAAQ,CAAC,MAAM,SAAS;AAC5B,eAAS,QAAQ,OAAO,aAAa,CAAC,MAAM,IAAI,CAAC;AAAA,IACnD;AAGA,QAAI;AACJ,QAAI;AACF,iBAAW,cAAc,QAAQ,IAAI;AAAA,IAEvC,SAAS,GAAP;AACA,2CAAmB,CAAC;AACpB,YAAM,QAAS,OAAO,EAAE,SAAU,cAC9B,EAAE,MAAM,EAAE,MAAM,SAAS,EAAE,QAAQ,IACnC,EAAE;AACN,aAAO,MAAM,4BAAY,OAAO,KAAK,UAAU,KAAK,CAAC;AAAA,IACvD;AAEA,QAAI,EAAE,oBAAoB,UAAU;AAClC,aAAO,MAAM,4BAAY,SAAS,QAAQ;AAAA,IAC5C;AAEA,aACE,KAAK,CAAC,WAAW,MAAM,4BAAY,SAAS,MAAM,CAAC,EACnD,MAAM,CAAC,MAAM;AAEX,YAAM,MAAM,KAAK,EAAE,WAAW;AAC9B,YAAM,4BAAY,OAAO,GAAG;AAAA,IAC9B,CAAC;AAAA,EACL,CAAC;AACH;",
4
+ "sourcesContent": ["import { debugAndPrintError } from './Debug.js';\nimport { Presence } from './presence/Presence.js';\nimport { IpcProtocol } from './Protocol.js';\nimport { generateId, REMOTE_ROOM_SHORT_TIMEOUT } from './utils/Utils.js';\n\nexport async function requestFromIPC<T>(\n presence: Presence,\n publishToChannel: string,\n method: string,\n args: any[],\n rejectionTimeout: number = REMOTE_ROOM_SHORT_TIMEOUT,\n): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n let unsubscribeTimeout: NodeJS.Timeout;\n\n const requestId = generateId();\n const channel = `ipc:${requestId}`;\n\n const unsubscribe = () => {\n presence.unsubscribe(channel);\n clearTimeout(unsubscribeTimeout);\n };\n\n presence.subscribe(channel, (message) => {\n const [code, data] = message;\n if (code === IpcProtocol.SUCCESS) {\n resolve(data);\n\n } else if (code === IpcProtocol.ERROR) {\n let error: any = data;\n\n // parse error message + code\n try { error = JSON.parse(data) } catch (e) {}\n\n // turn string message into Error instance\n if (typeof(error) === \"string\") {\n error = new Error(error);\n }\n\n reject(error);\n }\n unsubscribe();\n });\n\n presence.publish(publishToChannel, [method, requestId, args]);\n\n unsubscribeTimeout = setTimeout(() => {\n unsubscribe();\n reject(new Error(\"ipc_timeout\"));\n }, rejectionTimeout);\n });\n}\n\nexport async function subscribeIPC(\n presence: Presence,\n processId: string,\n channel: string,\n replyCallback: (method: string, args: any[]) => any,\n) {\n await presence.subscribe(channel, (message) => {\n const [method, requestId, args] = message;\n\n const reply = (code, data) => {\n presence.publish(`ipc:${requestId}`, [code, data]);\n };\n\n // reply with method result\n let response: any;\n try {\n response = replyCallback(method, args);\n\n } catch (e) {\n debugAndPrintError(e);\n const error = (typeof(e.code) !== \"undefined\")\n ? { code: e.code, message: e.message }\n : e.message;\n return reply(IpcProtocol.ERROR, JSON.stringify(error));\n }\n\n if (!(response instanceof Promise)) {\n return reply(IpcProtocol.SUCCESS, response);\n }\n\n response.\n then((result) => reply(IpcProtocol.SUCCESS, result)).\n catch((e) => {\n // user might have called `reject()` without arguments.\n const err = e && e.message || e;\n reply(IpcProtocol.ERROR, err);\n });\n });\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmC;AAEnC,sBAA4B;AAC5B,mBAAsD;AAEtD,eAAsB,eACpB,UACA,kBACA,QACA,MACA,mBAA2B,wCACf;AACZ,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,QAAI;AAEJ,UAAM,gBAAY,yBAAW;AAC7B,UAAM,UAAU,OAAO,SAAS;AAEhC,UAAM,cAAc,MAAM;AACxB,eAAS,YAAY,OAAO;AAC5B,mBAAa,kBAAkB;AAAA,IACjC;AAEA,aAAS,UAAU,SAAS,CAAC,YAAY;AACvC,YAAM,CAAC,MAAM,IAAI,IAAI;AACrB,UAAI,SAAS,4BAAY,SAAS;AAChC,gBAAQ,IAAI;AAAA,MAEd,WAAW,SAAS,4BAAY,OAAO;AACrC,YAAI,QAAa;AAGjB,YAAI;AAAE,kBAAQ,KAAK,MAAM,IAAI;AAAA,QAAE,SAAS,GAAG;AAAA,QAAC;AAG5C,YAAI,OAAO,UAAW,UAAU;AAC9B,kBAAQ,IAAI,MAAM,KAAK;AAAA,QACzB;AAEA,eAAO,KAAK;AAAA,MACd;AACA,kBAAY;AAAA,IACd,CAAC;AAED,aAAS,QAAQ,kBAAkB,CAAC,QAAQ,WAAW,IAAI,CAAC;AAE5D,yBAAqB,WAAW,MAAM;AACpC,kBAAY;AACZ,aAAO,IAAI,MAAM,aAAa,CAAC;AAAA,IACjC,GAAG,gBAAgB;AAAA,EACrB,CAAC;AACH;AAEA,eAAsB,aACpB,UACA,WACA,SACA,eACA;AACA,QAAM,SAAS,UAAU,SAAS,CAAC,YAAY;AAC7C,UAAM,CAAC,QAAQ,WAAW,IAAI,IAAI;AAElC,UAAM,QAAQ,CAAC,MAAM,SAAS;AAC5B,eAAS,QAAQ,OAAO,SAAS,IAAI,CAAC,MAAM,IAAI,CAAC;AAAA,IACnD;AAGA,QAAI;AACJ,QAAI;AACF,iBAAW,cAAc,QAAQ,IAAI;AAAA,IAEvC,SAAS,GAAG;AACV,2CAAmB,CAAC;AACpB,YAAM,QAAS,OAAO,EAAE,SAAU,cAC9B,EAAE,MAAM,EAAE,MAAM,SAAS,EAAE,QAAQ,IACnC,EAAE;AACN,aAAO,MAAM,4BAAY,OAAO,KAAK,UAAU,KAAK,CAAC;AAAA,IACvD;AAEA,QAAI,EAAE,oBAAoB,UAAU;AAClC,aAAO,MAAM,4BAAY,SAAS,QAAQ;AAAA,IAC5C;AAEA,aACE,KAAK,CAAC,WAAW,MAAM,4BAAY,SAAS,MAAM,CAAC,EACnD,MAAM,CAAC,MAAM;AAEX,YAAM,MAAM,KAAK,EAAE,WAAW;AAC9B,YAAM,4BAAY,OAAO,GAAG;AAAA,IAC9B,CAAC;AAAA,EACL,CAAC;AACH;",
6
6
  "names": []
7
7
  }
package/build/IPC.mjs CHANGED
@@ -1,6 +1,7 @@
1
- import { debugAndPrintError } from "./Debug";
2
- import { IpcProtocol } from "./Protocol";
3
- import { generateId, REMOTE_ROOM_SHORT_TIMEOUT } from "./utils/Utils";
1
+ // packages/core/src/IPC.ts
2
+ import { debugAndPrintError } from "./Debug.mjs";
3
+ import { IpcProtocol } from "./Protocol.mjs";
4
+ import { generateId, REMOTE_ROOM_SHORT_TIMEOUT } from "./utils/Utils.mjs";
4
5
  async function requestFromIPC(presence, publishToChannel, method, args, rejectionTimeout = REMOTE_ROOM_SHORT_TIMEOUT) {
5
6
  return new Promise((resolve, reject) => {
6
7
  let unsubscribeTimeout;
package/build/IPC.mjs.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/IPC.ts"],
4
- "sourcesContent": ["import { debugAndPrintError } from './Debug';\nimport { Presence } from './presence/Presence';\nimport { IpcProtocol } from './Protocol';\nimport { generateId, REMOTE_ROOM_SHORT_TIMEOUT } from './utils/Utils';\n\nexport async function requestFromIPC<T>(\n presence: Presence,\n publishToChannel: string,\n method: string,\n args: any[],\n rejectionTimeout: number = REMOTE_ROOM_SHORT_TIMEOUT,\n): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n let unsubscribeTimeout: NodeJS.Timeout;\n\n const requestId = generateId();\n const channel = `ipc:${requestId}`;\n\n const unsubscribe = () => {\n presence.unsubscribe(channel);\n clearTimeout(unsubscribeTimeout);\n };\n\n presence.subscribe(channel, (message) => {\n const [code, data] = message;\n if (code === IpcProtocol.SUCCESS) {\n resolve(data);\n\n } else if (code === IpcProtocol.ERROR) {\n let error: any = data;\n\n // parse error message + code\n try { error = JSON.parse(data) } catch (e) {}\n\n // turn string message into Error instance\n if (typeof(error) === \"string\") {\n error = new Error(error);\n }\n\n reject(error);\n }\n unsubscribe();\n });\n\n presence.publish(publishToChannel, [method, requestId, args]);\n\n unsubscribeTimeout = setTimeout(() => {\n unsubscribe();\n reject(new Error(\"ipc_timeout\"));\n }, rejectionTimeout);\n });\n}\n\nexport async function subscribeIPC(\n presence: Presence,\n processId: string,\n channel: string,\n replyCallback: (method: string, args: any[]) => any,\n) {\n await presence.subscribe(channel, (message) => {\n const [method, requestId, args] = message;\n\n const reply = (code, data) => {\n presence.publish(`ipc:${requestId}`, [code, data]);\n };\n\n // reply with method result\n let response: any;\n try {\n response = replyCallback(method, args);\n\n } catch (e) {\n debugAndPrintError(e);\n const error = (typeof(e.code) !== \"undefined\")\n ? { code: e.code, message: e.message }\n : e.message;\n return reply(IpcProtocol.ERROR, JSON.stringify(error));\n }\n\n if (!(response instanceof Promise)) {\n return reply(IpcProtocol.SUCCESS, response);\n }\n\n response.\n then((result) => reply(IpcProtocol.SUCCESS, result)).\n catch((e) => {\n // user might have called `reject()` without arguments.\n const err = e && e.message || e;\n reply(IpcProtocol.ERROR, err);\n });\n });\n}\n"],
5
- "mappings": "AAAA,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB;AAC5B,SAAS,YAAY,iCAAiC;AAEtD,eAAsB,eACpB,UACA,kBACA,QACA,MACA,mBAA2B,2BACf;AACZ,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,QAAI;AAEJ,UAAM,YAAY,WAAW;AAC7B,UAAM,UAAU,OAAO;AAEvB,UAAM,cAAc,MAAM;AACxB,eAAS,YAAY,OAAO;AAC5B,mBAAa,kBAAkB;AAAA,IACjC;AAEA,aAAS,UAAU,SAAS,CAAC,YAAY;AACvC,YAAM,CAAC,MAAM,IAAI,IAAI;AACrB,UAAI,SAAS,YAAY,SAAS;AAChC,gBAAQ,IAAI;AAAA,MAEd,WAAW,SAAS,YAAY,OAAO;AACrC,YAAI,QAAa;AAGjB,YAAI;AAAE,kBAAQ,KAAK,MAAM,IAAI;AAAA,QAAE,SAAS,GAAP;AAAA,QAAW;AAG5C,YAAI,OAAO,UAAW,UAAU;AAC9B,kBAAQ,IAAI,MAAM,KAAK;AAAA,QACzB;AAEA,eAAO,KAAK;AAAA,MACd;AACA,kBAAY;AAAA,IACd,CAAC;AAED,aAAS,QAAQ,kBAAkB,CAAC,QAAQ,WAAW,IAAI,CAAC;AAE5D,yBAAqB,WAAW,MAAM;AACpC,kBAAY;AACZ,aAAO,IAAI,MAAM,aAAa,CAAC;AAAA,IACjC,GAAG,gBAAgB;AAAA,EACrB,CAAC;AACH;AAEA,eAAsB,aACpB,UACA,WACA,SACA,eACA;AACA,QAAM,SAAS,UAAU,SAAS,CAAC,YAAY;AAC7C,UAAM,CAAC,QAAQ,WAAW,IAAI,IAAI;AAElC,UAAM,QAAQ,CAAC,MAAM,SAAS;AAC5B,eAAS,QAAQ,OAAO,aAAa,CAAC,MAAM,IAAI,CAAC;AAAA,IACnD;AAGA,QAAI;AACJ,QAAI;AACF,iBAAW,cAAc,QAAQ,IAAI;AAAA,IAEvC,SAAS,GAAP;AACA,yBAAmB,CAAC;AACpB,YAAM,QAAS,OAAO,EAAE,SAAU,cAC9B,EAAE,MAAM,EAAE,MAAM,SAAS,EAAE,QAAQ,IACnC,EAAE;AACN,aAAO,MAAM,YAAY,OAAO,KAAK,UAAU,KAAK,CAAC;AAAA,IACvD;AAEA,QAAI,EAAE,oBAAoB,UAAU;AAClC,aAAO,MAAM,YAAY,SAAS,QAAQ;AAAA,IAC5C;AAEA,aACE,KAAK,CAAC,WAAW,MAAM,YAAY,SAAS,MAAM,CAAC,EACnD,MAAM,CAAC,MAAM;AAEX,YAAM,MAAM,KAAK,EAAE,WAAW;AAC9B,YAAM,YAAY,OAAO,GAAG;AAAA,IAC9B,CAAC;AAAA,EACL,CAAC;AACH;",
4
+ "sourcesContent": ["import { debugAndPrintError } from './Debug.js';\nimport { Presence } from './presence/Presence.js';\nimport { IpcProtocol } from './Protocol.js';\nimport { generateId, REMOTE_ROOM_SHORT_TIMEOUT } from './utils/Utils.js';\n\nexport async function requestFromIPC<T>(\n presence: Presence,\n publishToChannel: string,\n method: string,\n args: any[],\n rejectionTimeout: number = REMOTE_ROOM_SHORT_TIMEOUT,\n): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n let unsubscribeTimeout: NodeJS.Timeout;\n\n const requestId = generateId();\n const channel = `ipc:${requestId}`;\n\n const unsubscribe = () => {\n presence.unsubscribe(channel);\n clearTimeout(unsubscribeTimeout);\n };\n\n presence.subscribe(channel, (message) => {\n const [code, data] = message;\n if (code === IpcProtocol.SUCCESS) {\n resolve(data);\n\n } else if (code === IpcProtocol.ERROR) {\n let error: any = data;\n\n // parse error message + code\n try { error = JSON.parse(data) } catch (e) {}\n\n // turn string message into Error instance\n if (typeof(error) === \"string\") {\n error = new Error(error);\n }\n\n reject(error);\n }\n unsubscribe();\n });\n\n presence.publish(publishToChannel, [method, requestId, args]);\n\n unsubscribeTimeout = setTimeout(() => {\n unsubscribe();\n reject(new Error(\"ipc_timeout\"));\n }, rejectionTimeout);\n });\n}\n\nexport async function subscribeIPC(\n presence: Presence,\n processId: string,\n channel: string,\n replyCallback: (method: string, args: any[]) => any,\n) {\n await presence.subscribe(channel, (message) => {\n const [method, requestId, args] = message;\n\n const reply = (code, data) => {\n presence.publish(`ipc:${requestId}`, [code, data]);\n };\n\n // reply with method result\n let response: any;\n try {\n response = replyCallback(method, args);\n\n } catch (e) {\n debugAndPrintError(e);\n const error = (typeof(e.code) !== \"undefined\")\n ? { code: e.code, message: e.message }\n : e.message;\n return reply(IpcProtocol.ERROR, JSON.stringify(error));\n }\n\n if (!(response instanceof Promise)) {\n return reply(IpcProtocol.SUCCESS, response);\n }\n\n response.\n then((result) => reply(IpcProtocol.SUCCESS, result)).\n catch((e) => {\n // user might have called `reject()` without arguments.\n const err = e && e.message || e;\n reply(IpcProtocol.ERROR, err);\n });\n });\n}\n"],
5
+ "mappings": ";AAAA,SAAS,0BAA0B;AAEnC,SAAS,mBAAmB;AAC5B,SAAS,YAAY,iCAAiC;AAEtD,eAAsB,eACpB,UACA,kBACA,QACA,MACA,mBAA2B,2BACf;AACZ,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,QAAI;AAEJ,UAAM,YAAY,WAAW;AAC7B,UAAM,UAAU,OAAO,SAAS;AAEhC,UAAM,cAAc,MAAM;AACxB,eAAS,YAAY,OAAO;AAC5B,mBAAa,kBAAkB;AAAA,IACjC;AAEA,aAAS,UAAU,SAAS,CAAC,YAAY;AACvC,YAAM,CAAC,MAAM,IAAI,IAAI;AACrB,UAAI,SAAS,YAAY,SAAS;AAChC,gBAAQ,IAAI;AAAA,MAEd,WAAW,SAAS,YAAY,OAAO;AACrC,YAAI,QAAa;AAGjB,YAAI;AAAE,kBAAQ,KAAK,MAAM,IAAI;AAAA,QAAE,SAAS,GAAG;AAAA,QAAC;AAG5C,YAAI,OAAO,UAAW,UAAU;AAC9B,kBAAQ,IAAI,MAAM,KAAK;AAAA,QACzB;AAEA,eAAO,KAAK;AAAA,MACd;AACA,kBAAY;AAAA,IACd,CAAC;AAED,aAAS,QAAQ,kBAAkB,CAAC,QAAQ,WAAW,IAAI,CAAC;AAE5D,yBAAqB,WAAW,MAAM;AACpC,kBAAY;AACZ,aAAO,IAAI,MAAM,aAAa,CAAC;AAAA,IACjC,GAAG,gBAAgB;AAAA,EACrB,CAAC;AACH;AAEA,eAAsB,aACpB,UACA,WACA,SACA,eACA;AACA,QAAM,SAAS,UAAU,SAAS,CAAC,YAAY;AAC7C,UAAM,CAAC,QAAQ,WAAW,IAAI,IAAI;AAElC,UAAM,QAAQ,CAAC,MAAM,SAAS;AAC5B,eAAS,QAAQ,OAAO,SAAS,IAAI,CAAC,MAAM,IAAI,CAAC;AAAA,IACnD;AAGA,QAAI;AACJ,QAAI;AACF,iBAAW,cAAc,QAAQ,IAAI;AAAA,IAEvC,SAAS,GAAG;AACV,yBAAmB,CAAC;AACpB,YAAM,QAAS,OAAO,EAAE,SAAU,cAC9B,EAAE,MAAM,EAAE,MAAM,SAAS,EAAE,QAAQ,IACnC,EAAE;AACN,aAAO,MAAM,YAAY,OAAO,KAAK,UAAU,KAAK,CAAC;AAAA,IACvD;AAEA,QAAI,EAAE,oBAAoB,UAAU;AAClC,aAAO,MAAM,YAAY,SAAS,QAAQ;AAAA,IAC5C;AAEA,aACE,KAAK,CAAC,WAAW,MAAM,YAAY,SAAS,MAAM,CAAC,EACnD,MAAM,CAAC,MAAM;AAEX,YAAM,MAAM,KAAK,EAAE,WAAW;AAC9B,YAAM,YAAY,OAAO,GAAG;AAAA,IAC9B,CAAC;AAAA,EACL,CAAC;AACH;",
6
6
  "names": []
7
7
  }
package/build/Logger.mjs CHANGED
@@ -1,4 +1,5 @@
1
- class Logger {
1
+ // packages/core/src/Logger.ts
2
+ var Logger = class {
2
3
  debug(...args) {
3
4
  logger.debug(...args);
4
5
  }
@@ -14,8 +15,8 @@ class Logger {
14
15
  warn(...args) {
15
16
  logger.warn(...args);
16
17
  }
17
- }
18
- let logger = console;
18
+ };
19
+ var logger = console;
19
20
  function setLogger(instance) {
20
21
  logger = instance;
21
22
  }
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/Logger.ts"],
4
4
  "sourcesContent": ["//\n// Abstract logging adaptor\n//\nexport class Logger {\n debug(...args) {\n logger.debug(...args);\n }\n\n error(...args) {\n logger.error(...args);\n }\n\n info(...args) {\n logger.info(...args);\n }\n\n trace(...args) {\n logger.trace(...args);\n }\n\n warn(...args) {\n logger.warn(...args);\n }\n}\n\nexport let logger: Logger = console;\n\nexport function setLogger(instance: Logger) {\n logger = instance;\n}\n"],
5
- "mappings": "AAGO,MAAM,OAAO;AAAA,EAClB,SAAS,MAAM;AACb,WAAO,MAAM,GAAG,IAAI;AAAA,EACtB;AAAA,EAEA,SAAS,MAAM;AACb,WAAO,MAAM,GAAG,IAAI;AAAA,EACtB;AAAA,EAEA,QAAQ,MAAM;AACZ,WAAO,KAAK,GAAG,IAAI;AAAA,EACrB;AAAA,EAEA,SAAS,MAAM;AACb,WAAO,MAAM,GAAG,IAAI;AAAA,EACtB;AAAA,EAEA,QAAQ,MAAM;AACZ,WAAO,KAAK,GAAG,IAAI;AAAA,EACrB;AACF;AAEO,IAAI,SAAiB;AAErB,SAAS,UAAU,UAAkB;AAC1C,WAAS;AACX;",
5
+ "mappings": ";AAGO,IAAM,SAAN,MAAa;AAAA,EAClB,SAAS,MAAM;AACb,WAAO,MAAM,GAAG,IAAI;AAAA,EACtB;AAAA,EAEA,SAAS,MAAM;AACb,WAAO,MAAM,GAAG,IAAI;AAAA,EACtB;AAAA,EAEA,QAAQ,MAAM;AACZ,WAAO,KAAK,GAAG,IAAI;AAAA,EACrB;AAAA,EAEA,SAAS,MAAM;AACb,WAAO,MAAM,GAAG,IAAI;AAAA,EACtB;AAAA,EAEA,QAAQ,MAAM;AACZ,WAAO,KAAK,GAAG,IAAI;AAAA,EACrB;AACF;AAEO,IAAI,SAAiB;AAErB,SAAS,UAAU,UAAkB;AAC1C,WAAS;AACX;",
6
6
  "names": []
7
7
  }
@@ -1,21 +1,18 @@
1
- import { Deferred } from './utils/Utils';
2
- import { RegisteredHandler } from './matchmaker/RegisteredHandler';
3
- import { Room } from './Room';
4
- import { Presence } from './presence/Presence';
5
- import { IRoomListingData, RoomListingData, MatchMakerDriver } from './matchmaker/driver';
6
- import controller from './matchmaker/controller';
7
- import * as stats from "./Stats";
8
- import { Type } from './utils/types';
1
+ import { Deferred } from './utils/Utils.js';
2
+ import { RegisteredHandler } from './matchmaker/RegisteredHandler.js';
3
+ import { Room } from './Room.js';
4
+ import { Presence } from './presence/Presence.js';
5
+ import { IRoomCache, MatchMakerDriver, SortOptions } from './matchmaker/driver/local/LocalDriver.js';
6
+ import controller from './matchmaker/controller.js';
7
+ import * as stats from './Stats.js';
8
+ import { AuthContext } from './Transport.js';
9
+ import { Type } from './utils/types.js';
9
10
  export { controller, stats, type MatchMakerDriver };
10
11
  export type ClientOptions = any;
11
- export type AuthOptions = {
12
- token?: string;
13
- request?: any;
14
- };
15
12
  export type SelectProcessIdCallback = (roomName: string, clientOptions: ClientOptions) => Promise<string>;
16
13
  export interface SeatReservation {
17
14
  sessionId: string;
18
- room: RoomListingData;
15
+ room: IRoomCache;
19
16
  devMode?: boolean;
20
17
  }
21
18
  export declare let publicAddress: string;
@@ -23,7 +20,7 @@ export declare let processId: string;
23
20
  export declare let presence: Presence;
24
21
  export declare let driver: MatchMakerDriver;
25
22
  export declare let selectProcessIdToCreateRoom: SelectProcessIdCallback;
26
- export declare let isGracefullyShuttingDown: boolean;
23
+ export declare function setHealthChecksEnabled(value: boolean): void;
27
24
  export declare let onReady: Deferred;
28
25
  export declare enum MatchMakerState {
29
26
  INITIALIZING = 0,
@@ -47,20 +44,20 @@ export declare function accept(): Promise<void>;
47
44
  /**
48
45
  * Join or create into a room and return seat reservation
49
46
  */
50
- export declare function joinOrCreate(roomName: string, clientOptions?: ClientOptions, authOptions?: AuthOptions): Promise<SeatReservation>;
47
+ export declare function joinOrCreate(roomName: string, clientOptions?: ClientOptions, authContext?: AuthContext): Promise<SeatReservation>;
51
48
  /**
52
49
  * Create a room and return seat reservation
53
50
  */
54
- export declare function create(roomName: string, clientOptions?: ClientOptions, authOptions?: AuthOptions): Promise<SeatReservation>;
51
+ export declare function create(roomName: string, clientOptions?: ClientOptions, authContext?: AuthContext): Promise<SeatReservation>;
55
52
  /**
56
53
  * Join a room and return seat reservation
57
54
  */
58
- export declare function join(roomName: string, clientOptions?: ClientOptions, authOptions?: AuthOptions): Promise<SeatReservation>;
55
+ export declare function join(roomName: string, clientOptions?: ClientOptions, authOptions?: AuthContext): Promise<SeatReservation>;
59
56
  /**
60
57
  * Join a room by id and return seat reservation
61
58
  */
62
59
  export declare function reconnect(roomId: string, clientOptions?: ClientOptions): Promise<{
63
- room: RoomListingData<any>;
60
+ room: import("./matchmaker/driver/api.js").RoomCache<any>;
64
61
  sessionId: any;
65
62
  }>;
66
63
  /**
@@ -70,22 +67,23 @@ export declare function reconnect(roomId: string, clientOptions?: ClientOptions)
70
67
  * @param clientOptions - Options for the client seat reservation (for `onJoin`/`onAuth`)
71
68
  * @param authOptions - Optional authentication token
72
69
  *
73
- * @returns Promise<SeatReservation> - A promise which contains `sessionId` and `RoomListingData`.
70
+ * @returns Promise<SeatReservation> - A promise which contains `sessionId` and `IRoomCache`.
74
71
  */
75
- export declare function joinById(roomId: string, clientOptions?: ClientOptions, authOptions?: AuthOptions): Promise<SeatReservation>;
72
+ export declare function joinById(roomId: string, clientOptions?: ClientOptions, authOptions?: AuthContext): Promise<SeatReservation>;
76
73
  /**
77
74
  * Perform a query for all cached rooms
78
75
  */
79
- export declare function query(conditions?: Partial<IRoomListingData>): Promise<RoomListingData<any>[]>;
76
+ export declare function query(conditions?: Partial<IRoomCache>, sortOptions?: SortOptions): Promise<IRoomCache[]>;
80
77
  /**
81
78
  * Find for a public and unlocked room available.
82
79
  *
83
80
  * @param roomName - The Id of the specific room.
84
- * @param clientOptions - Options for the client seat reservation (for `onJoin`/`onAuth`).
81
+ * @param filterOptions - Filter options.
82
+ * @param sortOptions - Sorting options.
85
83
  *
86
- * @returns Promise<RoomListingData> - A promise contaning an object which includes room metadata and configurations.
84
+ * @returns Promise<IRoomCache> - A promise contaning an object which includes room metadata and configurations.
87
85
  */
88
- export declare function findOneRoomAvailable(roomName: string, clientOptions: ClientOptions): Promise<RoomListingData>;
86
+ export declare function findOneRoomAvailable(roomName: string, filterOptions: ClientOptions, additionalSortOptions?: SortOptions): Promise<import("./matchmaker/driver/api.js").RoomCache<any>>;
89
87
  /**
90
88
  * Call a method or return a property on a remote room.
91
89
  *
@@ -107,11 +105,19 @@ export declare function getRoomClass(roomName: string): Type<Room>;
107
105
  * @param roomName - The identifier you defined on `gameServer.define()`
108
106
  * @param clientOptions - Options for `onCreate`
109
107
  *
110
- * @returns Promise<RoomListingData> - A promise contaning an object which includes room metadata and configurations.
108
+ * @returns Promise<IRoomCache> - A promise contaning an object which includes room metadata and configurations.
111
109
  */
112
- export declare function createRoom(roomName: string, clientOptions: ClientOptions): Promise<RoomListingData>;
113
- export declare function handleCreateRoom(roomName: string, clientOptions: ClientOptions, restoringRoomId?: string): Promise<RoomListingData>;
114
- export declare function getRoomById(roomId: string): Room<any, any, any, any>;
110
+ export declare function createRoom(roomName: string, clientOptions: ClientOptions): Promise<IRoomCache>;
111
+ export declare function handleCreateRoom(roomName: string, clientOptions: ClientOptions, restoringRoomId?: string): Promise<IRoomCache>;
112
+ /**
113
+ * Get room data by roomId.
114
+ * This method does not return the actual room instance, use `getLocalRoomById` for that.
115
+ */
116
+ export declare function getRoomById(roomId: string): Promise<import("./matchmaker/driver/api.js").RoomCache<any>>;
117
+ /**
118
+ * Get local room instance by roomId. (Can return "undefined" if the room is not available on this process)
119
+ */
120
+ export declare function getLocalRoomById(roomId: string): Room<any, any, any, any>;
115
121
  /**
116
122
  * Disconnects every client on every room in the current process.
117
123
  */
@@ -120,8 +126,7 @@ export declare function gracefullyShutdown(): Promise<any>;
120
126
  /**
121
127
  * Reserve a seat for a client in a room
122
128
  */
123
- export declare function reserveSeatFor(room: RoomListingData, options: ClientOptions, authData?: any): Promise<SeatReservation>;
124
- export declare function cleanupStaleRooms(roomName: string): Promise<void>;
129
+ export declare function reserveSeatFor(room: IRoomCache, options: ClientOptions, authData?: any): Promise<SeatReservation>;
125
130
  /**
126
131
  * Perform health check on all processes
127
132
  */