@casual-simulation/aux-common 3.2.6 → 3.2.7-alpha.6227012901

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 (212) hide show
  1. package/Errors.d.ts +29 -0
  2. package/Errors.js +2 -0
  3. package/Errors.js.map +1 -0
  4. package/{aux-format-2 → bots}/AuxStateHelpers.d.ts +2 -33
  5. package/{aux-format-2 → bots}/AuxStateHelpers.js +1 -116
  6. package/bots/AuxStateHelpers.js.map +1 -0
  7. package/bots/Bot.d.ts +1 -1
  8. package/bots/BotCalculations.d.ts +4 -1
  9. package/bots/BotCalculations.js +62 -0
  10. package/bots/BotCalculations.js.map +1 -1
  11. package/bots/BotEvents.d.ts +859 -3401
  12. package/bots/BotEvents.js +133 -1529
  13. package/bots/BotEvents.js.map +1 -1
  14. package/bots/StateUpdatedEvent.d.ts +1 -1
  15. package/bots/StateUpdatedEvent.js +1 -1
  16. package/bots/StateUpdatedEvent.js.map +1 -1
  17. package/bots/index.d.ts +1 -0
  18. package/bots/index.js +1 -0
  19. package/bots/index.js.map +1 -1
  20. package/common/Action.d.ts +17 -0
  21. package/common/Action.js +2 -0
  22. package/common/Action.js.map +1 -0
  23. package/common/ConnectionIndicator.d.ts +29 -0
  24. package/common/ConnectionIndicator.js +23 -0
  25. package/common/ConnectionIndicator.js.map +1 -0
  26. package/common/ConnectionInfo.d.ts +30 -0
  27. package/common/ConnectionInfo.js +14 -0
  28. package/common/ConnectionInfo.js.map +1 -0
  29. package/common/ConnectionToken.d.ts +37 -0
  30. package/common/ConnectionToken.js +93 -0
  31. package/common/ConnectionToken.js.map +1 -0
  32. package/common/CurrentVersion.d.ts +26 -0
  33. package/common/CurrentVersion.js +2 -0
  34. package/common/CurrentVersion.js.map +1 -0
  35. package/common/Iterators.d.ts +19 -0
  36. package/common/Iterators.js +39 -0
  37. package/common/Iterators.js.map +1 -0
  38. package/common/LoadingProgress.d.ts +26 -0
  39. package/common/LoadingProgress.js +2 -0
  40. package/common/LoadingProgress.js.map +1 -0
  41. package/common/RemoteActions.d.ts +558 -0
  42. package/common/RemoteActions.js +128 -0
  43. package/common/RemoteActions.js.map +1 -0
  44. package/common/StatusUpdate.d.ts +108 -0
  45. package/common/StatusUpdate.js +2 -0
  46. package/common/StatusUpdate.js.map +1 -0
  47. package/common/StatusUpdateUtils.d.ts +3 -0
  48. package/common/StatusUpdateUtils.js +11 -0
  49. package/common/StatusUpdateUtils.js.map +1 -0
  50. package/common/index.d.ts +11 -0
  51. package/common/index.js +11 -0
  52. package/common/index.js.map +1 -0
  53. package/index.d.ts +4 -1
  54. package/index.js +4 -1
  55. package/index.js.map +1 -1
  56. package/package.json +3 -4
  57. package/partitions/AuxPartition.d.ts +1 -11
  58. package/partitions/AuxPartition.js.map +1 -1
  59. package/partitions/AuxPartitionConfig.d.ts +39 -123
  60. package/partitions/MemoryPartition.d.ts +2 -2
  61. package/partitions/MemoryPartition.js +2 -2
  62. package/partitions/MemoryPartition.js.map +1 -1
  63. package/partitions/OtherPlayersPartition.d.ts +6 -7
  64. package/partitions/OtherPlayersPartition.js +40 -54
  65. package/partitions/OtherPlayersPartition.js.map +1 -1
  66. package/partitions/PartitionUtils.d.ts +28 -1
  67. package/partitions/PartitionUtils.js +174 -1
  68. package/partitions/PartitionUtils.js.map +1 -1
  69. package/partitions/ProxyBridgePartition.d.ts +1 -3
  70. package/partitions/ProxyBridgePartition.js +0 -14
  71. package/partitions/ProxyBridgePartition.js.map +1 -1
  72. package/partitions/RemoteYjsPartition.d.ts +7 -6
  73. package/partitions/RemoteYjsPartition.js +55 -75
  74. package/partitions/RemoteYjsPartition.js.map +1 -1
  75. package/partitions/YjsPartition.d.ts +1 -2
  76. package/partitions/YjsPartition.js +3 -6
  77. package/partitions/YjsPartition.js.map +1 -1
  78. package/partitions/index.d.ts +1 -7
  79. package/partitions/index.js +1 -7
  80. package/partitions/index.js.map +1 -1
  81. package/test/FuzzingHelpers.d.ts +1 -1
  82. package/test/FuzzingHelpers.js +1 -1
  83. package/test/FuzzingHelpers.js.map +1 -1
  84. package/test/TestHelpers.d.ts +8 -0
  85. package/test/TestHelpers.js +23 -0
  86. package/test/TestHelpers.js.map +1 -1
  87. package/utils.d.ts +10 -5
  88. package/utils.js +19 -7
  89. package/utils.js.map +1 -1
  90. package/websockets/AuthenticatedConnectionClient.d.ts +26 -0
  91. package/websockets/AuthenticatedConnectionClient.js +61 -0
  92. package/websockets/AuthenticatedConnectionClient.js.map +1 -0
  93. package/websockets/ConnectionClient.d.ts +59 -0
  94. package/websockets/ConnectionClient.js +2 -0
  95. package/websockets/ConnectionClient.js.map +1 -0
  96. package/websockets/InstRecordsClient.d.ts +118 -0
  97. package/websockets/InstRecordsClient.js +387 -0
  98. package/websockets/InstRecordsClient.js.map +1 -0
  99. package/websockets/InstRecordsClientTimeSyncConnection.d.ts +13 -0
  100. package/websockets/InstRecordsClientTimeSyncConnection.js +16 -0
  101. package/websockets/InstRecordsClientTimeSyncConnection.js.map +1 -0
  102. package/websockets/MemoryConnectionClient.d.ts +19 -0
  103. package/websockets/MemoryConnectionClient.js +41 -0
  104. package/websockets/MemoryConnectionClient.js.map +1 -0
  105. package/websockets/WebsocketEvents.d.ts +2670 -0
  106. package/websockets/WebsocketEvents.js +189 -0
  107. package/websockets/WebsocketEvents.js.map +1 -0
  108. package/websockets/index.d.ts +7 -0
  109. package/websockets/index.js +7 -0
  110. package/websockets/index.js.map +1 -0
  111. package/yjs/YjsHelpers.d.ts +1 -1
  112. package/LoadingProgress.d.ts +0 -54
  113. package/LoadingProgress.js +0 -105
  114. package/LoadingProgress.js.map +0 -1
  115. package/aux-format-2/AuxCausalTree2.d.ts +0 -98
  116. package/aux-format-2/AuxCausalTree2.js +0 -616
  117. package/aux-format-2/AuxCausalTree2.js.map +0 -1
  118. package/aux-format-2/AuxOpTypes.d.ts +0 -268
  119. package/aux-format-2/AuxOpTypes.js +0 -240
  120. package/aux-format-2/AuxOpTypes.js.map +0 -1
  121. package/aux-format-2/AuxStateHelpers.js.map +0 -1
  122. package/aux-format-2/AuxWeaveHelpers.d.ts +0 -132
  123. package/aux-format-2/AuxWeaveHelpers.js +0 -335
  124. package/aux-format-2/AuxWeaveHelpers.js.map +0 -1
  125. package/aux-format-2/AuxWeaveReducer.d.ts +0 -37
  126. package/aux-format-2/AuxWeaveReducer.js +0 -980
  127. package/aux-format-2/AuxWeaveReducer.js.map +0 -1
  128. package/aux-format-2/index.d.ts +0 -7
  129. package/aux-format-2/index.js +0 -7
  130. package/aux-format-2/index.js.map +0 -1
  131. package/partitions/AuxPartitionRealtimeEditModeProvider.d.ts +0 -9
  132. package/partitions/AuxPartitionRealtimeEditModeProvider.js +0 -21
  133. package/partitions/AuxPartitionRealtimeEditModeProvider.js.map +0 -1
  134. package/partitions/BotClient.d.ts +0 -24
  135. package/partitions/BotClient.js +0 -2
  136. package/partitions/BotClient.js.map +0 -1
  137. package/partitions/BotPartition.d.ts +0 -45
  138. package/partitions/BotPartition.js +0 -186
  139. package/partitions/BotPartition.js.map +0 -1
  140. package/partitions/CausalRepoPartition.d.ts +0 -45
  141. package/partitions/CausalRepoPartition.js +0 -157
  142. package/partitions/CausalRepoPartition.js.map +0 -1
  143. package/partitions/MemoryBotClient.d.ts +0 -11
  144. package/partitions/MemoryBotClient.js +0 -41
  145. package/partitions/MemoryBotClient.js.map +0 -1
  146. package/partitions/RemoteCausalRepoHistoryPartition.d.ts +0 -53
  147. package/partitions/RemoteCausalRepoHistoryPartition.js +0 -206
  148. package/partitions/RemoteCausalRepoHistoryPartition.js.map +0 -1
  149. package/partitions/RemoteCausalRepoPartition.d.ts +0 -72
  150. package/partitions/RemoteCausalRepoPartition.js +0 -468
  151. package/partitions/RemoteCausalRepoPartition.js.map +0 -1
  152. package/runtime/AuxCompiler.d.ts +0 -258
  153. package/runtime/AuxCompiler.js +0 -722
  154. package/runtime/AuxCompiler.js.map +0 -1
  155. package/runtime/AuxDevice.d.ts +0 -28
  156. package/runtime/AuxDevice.js +0 -2
  157. package/runtime/AuxDevice.js.map +0 -1
  158. package/runtime/AuxGlobalContext.d.ts +0 -571
  159. package/runtime/AuxGlobalContext.js +0 -606
  160. package/runtime/AuxGlobalContext.js.map +0 -1
  161. package/runtime/AuxLibrary.d.ts +0 -2702
  162. package/runtime/AuxLibrary.js +0 -11046
  163. package/runtime/AuxLibrary.js.map +0 -1
  164. package/runtime/AuxLibraryDefinitions.def +0 -13139
  165. package/runtime/AuxRealtimeEditModeProvider.d.ts +0 -35
  166. package/runtime/AuxRealtimeEditModeProvider.js +0 -34
  167. package/runtime/AuxRealtimeEditModeProvider.js.map +0 -1
  168. package/runtime/AuxResults.d.ts +0 -77
  169. package/runtime/AuxResults.js +0 -6
  170. package/runtime/AuxResults.js.map +0 -1
  171. package/runtime/AuxRuntime.d.ts +0 -253
  172. package/runtime/AuxRuntime.js +0 -2700
  173. package/runtime/AuxRuntime.js.map +0 -1
  174. package/runtime/AuxRuntimeDynamicImports.d.ts +0 -14
  175. package/runtime/AuxRuntimeDynamicImports.js +0 -24
  176. package/runtime/AuxRuntimeDynamicImports.js.map +0 -1
  177. package/runtime/AuxVersion.d.ts +0 -39
  178. package/runtime/AuxVersion.js +0 -2
  179. package/runtime/AuxVersion.js.map +0 -1
  180. package/runtime/CasualOSError.d.ts +0 -37
  181. package/runtime/CasualOSError.js +0 -25
  182. package/runtime/CasualOSError.js.map +0 -1
  183. package/runtime/CompiledBot.d.ts +0 -106
  184. package/runtime/CompiledBot.js +0 -44
  185. package/runtime/CompiledBot.js.map +0 -1
  186. package/runtime/PerformanceNowPolyfill.d.ts +0 -1
  187. package/runtime/PerformanceNowPolyfill.js +0 -8
  188. package/runtime/PerformanceNowPolyfill.js.map +0 -1
  189. package/runtime/RuntimeBot.d.ts +0 -176
  190. package/runtime/RuntimeBot.js +0 -732
  191. package/runtime/RuntimeBot.js.map +0 -1
  192. package/runtime/RuntimeStateVersion.d.ts +0 -23
  193. package/runtime/RuntimeStateVersion.js +0 -22
  194. package/runtime/RuntimeStateVersion.js.map +0 -1
  195. package/runtime/Transpiler.d.ts +0 -174
  196. package/runtime/Transpiler.js +0 -611
  197. package/runtime/Transpiler.js.map +0 -1
  198. package/runtime/Utils.d.ts +0 -74
  199. package/runtime/Utils.js +0 -488
  200. package/runtime/Utils.js.map +0 -1
  201. package/runtime/index.d.ts +0 -9
  202. package/runtime/index.js +0 -9
  203. package/runtime/index.js.map +0 -1
  204. package/runtime/test/RuntimeTestHelpers.d.ts +0 -11
  205. package/runtime/test/RuntimeTestHelpers.js +0 -26
  206. package/runtime/test/RuntimeTestHelpers.js.map +0 -1
  207. package/runtime/test/TestScriptBotFactory.d.ts +0 -16
  208. package/runtime/test/TestScriptBotFactory.js +0 -107
  209. package/runtime/test/TestScriptBotFactory.js.map +0 -1
  210. /package/{runtime/BlobPolyfill.d.ts → BlobPolyfill.d.ts} +0 -0
  211. /package/{runtime/BlobPolyfill.js → BlobPolyfill.js} +0 -0
  212. /package/{runtime/BlobPolyfill.js.map → BlobPolyfill.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"TestHelpers.js","sourceRoot":"","sources":["TestHelpers.ts"],"names":[],"mappings":";;;;;;;;;AAAA,MAAM,UAAU,IAAI,CAAC,EAAU;IAC3B,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QACjC,UAAU,CAAC,GAAG,EAAE;YACZ,OAAO,EAAE,CAAC;QACd,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAgB,SAAS,CAAC,MAAc,EAAE;;QAC5C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC3B,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CACrD,CAAC;IACN,CAAC;CAAA"}
1
+ {"version":3,"file":"TestHelpers.js","sourceRoot":"","sources":["TestHelpers.ts"],"names":[],"mappings":";;;;;;;;;AA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AAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAU;IACzC,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAU;IAC5C,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAU;IACnD,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAU;CAC3C,CAAC"}
package/utils.d.ts CHANGED
@@ -28,11 +28,6 @@ export declare function unnormalize(normal: number, min: number, max: number): n
28
28
  * Creates and returns a short 8 character UUID (no dashes).
29
29
  */
30
30
  export declare function shortUuid(): string;
31
- /**
32
- * Parses the given RealtimeChannelInfo ID to the ID of the aux.
33
- * @param id The id to parse.
34
- */
35
- export declare function parseRealtimeChannelId(id: string): string;
36
31
  /**
37
32
  * Converts the given string from dot case (dot.case) to camel case (camelCase).
38
33
  * @param dotCase The string to convert.
@@ -49,4 +44,14 @@ export declare function mightBeEmailAddress(value: string): boolean;
49
44
  * @param value The value that should be cleaned.
50
45
  */
51
46
  export declare function cleanPhoneNumber(value: string): string;
47
+ /**
48
+ * Converts the given string into a base64 string.
49
+ * @param str The string to convert.
50
+ */
51
+ export declare function toBase64String(str: string): string;
52
+ /**
53
+ * Converts the given string from a base64 string.
54
+ * @param base64
55
+ */
56
+ export declare function fromBase64String(base64: string): string;
52
57
  //# sourceMappingURL=utils.d.ts.map
package/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { fromByteArray, toByteArray } from 'base64-js';
1
2
  import { union, keys, every, some, isObject, mapValues } from 'lodash';
2
3
  import { v4 as uuid } from 'uuid';
3
4
  export function merge(...objs) {
@@ -64,13 +65,6 @@ export function unnormalize(normal, min, max) {
64
65
  export function shortUuid() {
65
66
  return uuid().substr(0, 8);
66
67
  }
67
- /**
68
- * Parses the given RealtimeChannelInfo ID to the ID of the aux.
69
- * @param id The id to parse.
70
- */
71
- export function parseRealtimeChannelId(id) {
72
- return id.substring(4);
73
- }
74
68
  /**
75
69
  * Converts the given string from dot case (dot.case) to camel case (camelCase).
76
70
  * @param dotCase The string to convert.
@@ -150,4 +144,22 @@ export function cleanPhoneNumber(value) {
150
144
  }
151
145
  return sms;
152
146
  }
147
+ /**
148
+ * Converts the given string into a base64 string.
149
+ * @param str The string to convert.
150
+ */
151
+ export function toBase64String(str) {
152
+ const encoder = new TextEncoder();
153
+ const array = encoder.encode(str);
154
+ return fromByteArray(array);
155
+ }
156
+ /**
157
+ * Converts the given string from a base64 string.
158
+ * @param base64
159
+ */
160
+ export function fromBase64String(base64) {
161
+ const decoder = new TextDecoder();
162
+ const array = toByteArray(base64);
163
+ return decoder.decode(array);
164
+ }
153
165
  //# sourceMappingURL=utils.js.map
package/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACvE,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAclC,MAAM,UAAU,KAAK,CAAC,GAAG,IAAW;IAChC,IAAI,MAAM,GAAQ,EAAE,CAAC;IACrB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC;IAElC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAClB,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC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,CAAC;IAClC,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ClientConnectionState, ConnectionClient, WebsocketType } from './ConnectionClient';
3
+ import { WebsocketMessage } from './WebsocketEvents';
4
+ import { ConnectionIndicator } from '../common';
5
+ /**
6
+ * Defines a connection client that attempts to authenticate before bubbling a connection event.
7
+ */
8
+ export declare class AuthenticatedConnectionClient implements ConnectionClient {
9
+ private _inner;
10
+ private _indicator;
11
+ private _connectionStateChanged;
12
+ constructor(inner: ConnectionClient, indicator: ConnectionIndicator);
13
+ get info(): import("../common").ConnectionInfo;
14
+ get connectionState(): Observable<ClientConnectionState>;
15
+ get isConnected(): boolean;
16
+ /**
17
+ * Gets an observable for events with the given name.
18
+ * @param name The name of the events.
19
+ */
20
+ event<K extends WebsocketMessage['type']>(name: K): Observable<WebsocketType<K>>;
21
+ send(message: WebsocketMessage): void;
22
+ disconnect(): void;
23
+ connect(): void;
24
+ private _login;
25
+ }
26
+ //# sourceMappingURL=AuthenticatedConnectionClient.d.ts.map
@@ -0,0 +1,61 @@
1
+ import { BehaviorSubject, concatMap, distinctUntilKeyChanged, first, map, of, takeUntil, tap, } from 'rxjs';
2
+ /**
3
+ * Defines a connection client that attempts to authenticate before bubbling a connection event.
4
+ */
5
+ export class AuthenticatedConnectionClient {
6
+ constructor(inner, indicator) {
7
+ this._inner = inner;
8
+ this._indicator = indicator;
9
+ this._connectionStateChanged =
10
+ new BehaviorSubject({
11
+ connected: false,
12
+ info: null,
13
+ });
14
+ this._inner.connectionState
15
+ .pipe(concatMap((state) => this._login(state.connected)), distinctUntilKeyChanged('connected'))
16
+ .subscribe(this._connectionStateChanged);
17
+ }
18
+ get info() {
19
+ return this._connectionStateChanged.value.info;
20
+ }
21
+ get connectionState() {
22
+ return this._connectionStateChanged;
23
+ }
24
+ get isConnected() {
25
+ return this._inner.isConnected;
26
+ }
27
+ /**
28
+ * Gets an observable for events with the given name.
29
+ * @param name The name of the events.
30
+ */
31
+ event(name) {
32
+ return this._inner.event(name);
33
+ }
34
+ send(message) {
35
+ return this._inner.send(message);
36
+ }
37
+ disconnect() {
38
+ this._inner.disconnect();
39
+ }
40
+ connect() {
41
+ this._inner.connect();
42
+ }
43
+ _login(connected) {
44
+ if (connected) {
45
+ console.log('[AuthencatedConnectionClient] Logging in...');
46
+ const onLoginResult = this._inner.event('login_result');
47
+ this._inner.send(Object.assign({ type: 'login' }, this._indicator));
48
+ return onLoginResult.pipe(tap(() => console.log('[AuthencatedConnectionClient] Logged in.')), map((result) => ({
49
+ connected: true,
50
+ info: result.info,
51
+ })), first(), takeUntil(this._inner.connectionState.pipe(first((state) => !state.connected))));
52
+ }
53
+ else {
54
+ return of({
55
+ connected: false,
56
+ info: null,
57
+ });
58
+ }
59
+ }
60
+ }
61
+ //# sourceMappingURL=AuthenticatedConnectionClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthenticatedConnectionClient.js","sourceRoot":"","sources":["AuthenticatedConnectionClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EAEf,SAAS,EACT,uBAAuB,EACvB,KAAK,EACL,GAAG,EACH,EAAE,EACF,SAAS,EACT,GAAG,GACN,MAAM,MAAM,CAAC;AA6Bd;;GAEG;AACH,MAAM,OAAO,6BAA6B;IAKtC,YAAY,KAAuB,EAAE,SAA8B;QAC/D,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,uBAAuB;YACxB,IAAI,eAAe,CAAwB;gBACvC,SAAS,EAAE,KAAK;gBAChB,IAAI,EAAE,IAAI;aACb,CAAC,CAAC;QAEP,IAAI,CAAC,MAAM,CAAC,eAAe;aACtB,IAAI,CACD,SAAS,CAAC,CAAC,KAAK,EAAE,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,EAAE,MAAM,CAAC,IAAI;aACpB,CAAC,CAAC,EACH,KAAK,EAAE,EACP,SAAS,CACL,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAC5B,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CACrC,CACJ,CACJ,CAAC;SACL;aAAM;YACH,OAAO,EAAE,CAAC;gBACN,SAAS,EAAE,KAAK;gBAChB,IAAI,EAAE,IAAI;aACb,CAAC,CAAC;SACN;IACL,CAAC;CACJ"}
@@ -0,0 +1,59 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ConnectionInfo } from '../common/ConnectionInfo';
3
+ import { WebsocketMessage } from './WebsocketEvents';
4
+ /**
5
+ * Defines an interface that contains connection state info.
6
+ */
7
+ export interface ClientConnectionState {
8
+ /**
9
+ * Whether the client is connected.
10
+ */
11
+ connected: boolean;
12
+ /**
13
+ * The device info.
14
+ */
15
+ info: ConnectionInfo;
16
+ }
17
+ export type ActionSelector<T extends WebsocketMessage['type'], U extends {
18
+ type: WebsocketMessage['type'];
19
+ }> = U extends {
20
+ type: T;
21
+ } ? U : never;
22
+ export type WebsocketType<T extends WebsocketMessage['type']> = ActionSelector<T, WebsocketMessage>;
23
+ /**
24
+ * Defines an interface for a client connection.
25
+ * That is, a service that can send and receive arbitrary messages and track connection states.
26
+ */
27
+ export interface ConnectionClient {
28
+ /**
29
+ * Gets an observable for the connection state.
30
+ */
31
+ connectionState: Observable<ClientConnectionState>;
32
+ /**
33
+ * Whether the client is currently connected.
34
+ */
35
+ isConnected: boolean;
36
+ /**
37
+ * Gets the current connection info.
38
+ */
39
+ get info(): ConnectionInfo | null;
40
+ /**
41
+ * Gets an observable for events with the given name.
42
+ * @param name The name of the events.
43
+ */
44
+ event<K extends WebsocketMessage['type']>(name: K): Observable<WebsocketType<K>>;
45
+ /**
46
+ * Sends a message.
47
+ * @param message The message to send.
48
+ */
49
+ send(message: WebsocketMessage): void;
50
+ /**
51
+ * Tells the connection to disconnect.
52
+ */
53
+ disconnect(): void;
54
+ /**
55
+ * Tells the connection to (re)connect.
56
+ */
57
+ connect(): void;
58
+ }
59
+ //# sourceMappingURL=ConnectionClient.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ConnectionClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionClient.js","sourceRoot":"","sources":["ConnectionClient.ts"],"names":[],"mappings":""}
@@ -0,0 +1,118 @@
1
+ import { ConnectionClient } from './ConnectionClient';
2
+ import { Observable } from 'rxjs';
3
+ import { ConnectedToBranchMessage, DisconnectedFromBranchMessage, WatchBranchMessage } from './WebsocketEvents';
4
+ import { DeviceAction, DeviceActionResult, DeviceActionError, RemoteActions } from '../common/RemoteActions';
5
+ import { TimeSample } from '@casual-simulation/timesync';
6
+ export declare const DEFAULT_BRANCH_NAME = "default";
7
+ /**
8
+ * Defines a client for inst records.
9
+ */
10
+ export declare class InstRecordsClient {
11
+ private _client;
12
+ private _sentUpdates;
13
+ private _updateCounter;
14
+ private _watchedBranches;
15
+ private _connectedDevices;
16
+ private _forcedOffline;
17
+ private _timeSyncCounter;
18
+ private _info;
19
+ constructor(connection: ConnectionClient);
20
+ /**
21
+ * Gets the connection that this client is using.
22
+ */
23
+ get connection(): ConnectionClient;
24
+ /**
25
+ * Gets whether the client is forcing the connection to be offline or not.
26
+ */
27
+ get forcedOffline(): boolean;
28
+ /**
29
+ * Sets whether the client is forcing the connection to be offline or not.
30
+ */
31
+ set forcedOffline(value: boolean);
32
+ /**
33
+ * Starts watching the given branch.
34
+ * @param name The name of the branch to watch.
35
+ */
36
+ watchBranchUpdates(nameOrEvent: string | WatchBranchMessage): Observable<ClientUpdatesOrEvent>;
37
+ /**
38
+ * Watches for rate limit exceeded events.
39
+ */
40
+ watchRateLimitExceeded(): Observable<import("./WebsocketEvents").RateLimitExceededMessage>;
41
+ /**
42
+ * Gets the updates stored on the given branch.
43
+ * @param recordName The name of the record.
44
+ * @param inst The name of the inst.
45
+ * @param name The name of the branch to get.
46
+ */
47
+ getBranchUpdates(recordName: string | null, inst: string, branch: string): Observable<{
48
+ updates: string[];
49
+ timestamps?: number[];
50
+ }>;
51
+ /**
52
+ * Watches for device connection/disconnection events on the given branch.
53
+ * @param branch The branch to watch.
54
+ */
55
+ watchBranchDevices(recordName: string | null, inst: string, branch: string): Observable<ConnectedToBranchMessage | DisconnectedFromBranchMessage>;
56
+ private _disconnectDevices;
57
+ private _watchConnectedDevices;
58
+ /**
59
+ * Adds the given updates to the given branch.
60
+ * @param recordName The name of the record.
61
+ * @param inst The name of the inst.
62
+ * @param branch The name of the branch.
63
+ * @param updates The updates.
64
+ */
65
+ addUpdates(recordName: string | null, inst: string, branch: string, updates: string[]): void;
66
+ /**
67
+ * Sends the given action to devices on the given branch.
68
+ * @param branch The branch.
69
+ * @param action The action.
70
+ */
71
+ sendAction(recordName: string | null, inst: string, branch: string, action: RemoteActions): void;
72
+ /**
73
+ * Sends a SyncTimeRequest to the server.
74
+ */
75
+ sampleServerTime(): Promise<TimeSample>;
76
+ /**
77
+ * Requests the number of devices that are currently connected.
78
+ * @param branch The branch that the devices should be counted on.
79
+ */
80
+ connectionCount(recordName?: string, inst?: string, branch?: string): Observable<number>;
81
+ private _whenConnected;
82
+ private _sendAddUpdates;
83
+ private _getSentUpdates;
84
+ private _getConnectedDevices;
85
+ private _isDeviceConnected;
86
+ }
87
+ export interface ClientUpdates {
88
+ type: 'updates';
89
+ updates: string[];
90
+ }
91
+ export interface ClientUpdatesReceived {
92
+ type: 'updates_received';
93
+ }
94
+ export interface ClientAtomsReceived {
95
+ type: 'atoms_received';
96
+ }
97
+ export interface ClientEvent {
98
+ type: 'event';
99
+ action: DeviceAction | DeviceActionResult | DeviceActionError;
100
+ }
101
+ export interface BaseClientError {
102
+ type: 'error';
103
+ errorCode: string;
104
+ }
105
+ export type ClientError = MaxInstSizeReachedClientError;
106
+ export interface MaxInstSizeReachedClientError extends BaseClientError {
107
+ errorCode: 'max_size_reached';
108
+ maxBranchSizeInBytes: number;
109
+ neededBranchSizeInBytes: number;
110
+ }
111
+ export type ClientWatchBranchMessages = ClientAtomsReceived | ClientEvent;
112
+ export type ClientWatchBranchUpdatesEvents = ClientUpdates | ClientUpdatesReceived | ClientEvent | ClientError;
113
+ export type ClientUpdatesOrEvent = ClientUpdates | ClientEvent | ClientError;
114
+ export declare function isClientEvent(event: ClientWatchBranchMessages | ClientWatchBranchUpdatesEvents): event is ClientEvent;
115
+ export declare function isClientUpdates(event: ClientWatchBranchUpdatesEvents): event is ClientUpdates;
116
+ export declare function isClientUpdatesOrEvents(event: ClientWatchBranchUpdatesEvents): event is ClientUpdatesOrEvent;
117
+ export declare function isClientError(event: ClientWatchBranchUpdatesEvents): event is ClientError;
118
+ //# sourceMappingURL=InstRecordsClient.d.ts.map