@fluid-internal/presence-runtime 2.93.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.
Files changed (264) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -0
  3. package/dist/package.json +4 -0
  4. package/dist/packageVersion.d.ts +9 -0
  5. package/dist/packageVersion.d.ts.map +1 -0
  6. package/dist/packageVersion.js +12 -0
  7. package/dist/packageVersion.js.map +1 -0
  8. package/dist/runtime/extension/containerPresence.d.ts +53 -0
  9. package/dist/runtime/extension/containerPresence.d.ts.map +1 -0
  10. package/dist/runtime/extension/containerPresence.js +90 -0
  11. package/dist/runtime/extension/containerPresence.js.map +1 -0
  12. package/dist/runtime/extension/index.d.ts +6 -0
  13. package/dist/runtime/extension/index.d.ts.map +1 -0
  14. package/dist/runtime/extension/index.js +11 -0
  15. package/dist/runtime/extension/index.js.map +1 -0
  16. package/dist/runtime/presenceDatastoreManager.d.ts +146 -0
  17. package/dist/runtime/presenceDatastoreManager.d.ts.map +1 -0
  18. package/dist/runtime/presenceDatastoreManager.js +666 -0
  19. package/dist/runtime/presenceDatastoreManager.js.map +1 -0
  20. package/dist/runtime/presenceManager.d.ts +16 -0
  21. package/dist/runtime/presenceManager.d.ts.map +1 -0
  22. package/dist/runtime/presenceManager.js +140 -0
  23. package/dist/runtime/presenceManager.js.map +1 -0
  24. package/dist/runtime/protocol.d.ts +126 -0
  25. package/dist/runtime/protocol.d.ts.map +1 -0
  26. package/dist/runtime/protocol.js +20 -0
  27. package/dist/runtime/protocol.js.map +1 -0
  28. package/dist/runtime/runtimeTypes.d.ts +26 -0
  29. package/dist/runtime/runtimeTypes.d.ts.map +1 -0
  30. package/dist/runtime/runtimeTypes.js +7 -0
  31. package/dist/runtime/runtimeTypes.js.map +1 -0
  32. package/dist/runtime/systemWorkspace.d.ts +39 -0
  33. package/dist/runtime/systemWorkspace.d.ts.map +1 -0
  34. package/dist/runtime/systemWorkspace.js +264 -0
  35. package/dist/runtime/systemWorkspace.js.map +1 -0
  36. package/dist/runtime/test/presenceDatastoreManager.spec.js +618 -0
  37. package/dist/runtime/test/presenceDatastoreManager.spec.js.map +1 -0
  38. package/dist/runtime/test/presenceManager.spec.js +651 -0
  39. package/dist/runtime/test/presenceManager.spec.js.map +1 -0
  40. package/dist/runtime/test.d.ts +12 -0
  41. package/dist/runtime/test.d.ts.map +1 -0
  42. package/dist/runtime/test.js +15 -0
  43. package/dist/runtime/test.js.map +1 -0
  44. package/dist/states/index.d.ts +7 -0
  45. package/dist/states/index.d.ts.map +1 -0
  46. package/dist/states/index.js +12 -0
  47. package/dist/states/index.js.map +1 -0
  48. package/dist/states/latestMapValueManager.d.ts +10 -0
  49. package/dist/states/latestMapValueManager.d.ts.map +1 -0
  50. package/dist/states/latestMapValueManager.js +248 -0
  51. package/dist/states/latestMapValueManager.js.map +1 -0
  52. package/dist/states/latestValueManager.d.ts +10 -0
  53. package/dist/states/latestValueManager.d.ts.map +1 -0
  54. package/dist/states/latestValueManager.js +115 -0
  55. package/dist/states/latestValueManager.js.map +1 -0
  56. package/dist/states/notificationsManager.d.ts +26 -0
  57. package/dist/states/notificationsManager.d.ts.map +1 -0
  58. package/dist/states/notificationsManager.js +97 -0
  59. package/dist/states/notificationsManager.js.map +1 -0
  60. package/dist/states/presence.d.ts +11 -0
  61. package/dist/states/presence.d.ts.map +1 -0
  62. package/dist/states/presence.js +7 -0
  63. package/dist/states/presence.js.map +1 -0
  64. package/dist/states/stateFactory.d.ts +18 -0
  65. package/dist/states/stateFactory.d.ts.map +1 -0
  66. package/dist/states/stateFactory.js +23 -0
  67. package/dist/states/stateFactory.js.map +1 -0
  68. package/dist/states/test/batching.spec.js +843 -0
  69. package/dist/states/test/batching.spec.js.map +1 -0
  70. package/dist/states/test/broadcastControlsTests.js +60 -0
  71. package/dist/states/test/broadcastControlsTests.js.map +1 -0
  72. package/dist/states/test/eventing.spec.js +576 -0
  73. package/dist/states/test/eventing.spec.js.map +1 -0
  74. package/dist/states/test/latestMapValueManager.spec.js +210 -0
  75. package/dist/states/test/latestMapValueManager.spec.js.map +1 -0
  76. package/dist/states/test/latestValueManager.spec.js +193 -0
  77. package/dist/states/test/latestValueManager.spec.js.map +1 -0
  78. package/dist/states/test/mockEphemeralRuntime.js +11 -0
  79. package/dist/states/test/mockEphemeralRuntime.js.map +1 -0
  80. package/dist/states/test/notificationsManager.spec.js +460 -0
  81. package/dist/states/test/notificationsManager.spec.js.map +1 -0
  82. package/dist/states/test/presenceStates.spec.js +73 -0
  83. package/dist/states/test/presenceStates.spec.js.map +1 -0
  84. package/dist/states/test/schemaValidation/protocol.spec.js +246 -0
  85. package/dist/states/test/schemaValidation/protocol.spec.js.map +1 -0
  86. package/dist/states/test/schemaValidation/valueManagers.spec.js +784 -0
  87. package/dist/states/test/schemaValidation/valueManagers.spec.js.map +1 -0
  88. package/dist/states/test/testUtils.js +21 -0
  89. package/dist/states/test/testUtils.js.map +1 -0
  90. package/dist/states/validatedGetter.d.ts +18 -0
  91. package/dist/states/validatedGetter.d.ts.map +1 -0
  92. package/dist/states/validatedGetter.js +43 -0
  93. package/dist/states/validatedGetter.js.map +1 -0
  94. package/dist/test/mockEphemeralRuntime.js +175 -0
  95. package/dist/test/mockEphemeralRuntime.js.map +1 -0
  96. package/dist/test/testUtils.js +262 -0
  97. package/dist/test/testUtils.js.map +1 -0
  98. package/dist/test/utils/index.js +27 -0
  99. package/dist/test/utils/index.js.map +1 -0
  100. package/dist/utils/broadcastControls.d.ts +37 -0
  101. package/dist/utils/broadcastControls.d.ts.map +1 -0
  102. package/dist/utils/broadcastControls.js +60 -0
  103. package/dist/utils/broadcastControls.js.map +1 -0
  104. package/dist/utils/index.d.ts +9 -0
  105. package/dist/utils/index.d.ts.map +1 -0
  106. package/dist/utils/index.js +26 -0
  107. package/dist/utils/index.js.map +1 -0
  108. package/dist/utils/internalUtils.d.ts +125 -0
  109. package/dist/utils/internalUtils.d.ts.map +1 -0
  110. package/dist/utils/internalUtils.js +99 -0
  111. package/dist/utils/internalUtils.js.map +1 -0
  112. package/dist/utils/test/timerManager.spec.js +93 -0
  113. package/dist/utils/test/timerManager.spec.js.map +1 -0
  114. package/dist/utils/timerManager.d.ts +37 -0
  115. package/dist/utils/timerManager.d.ts.map +1 -0
  116. package/dist/utils/timerManager.js +65 -0
  117. package/dist/utils/timerManager.js.map +1 -0
  118. package/dist/utils/valueManager.d.ts +14 -0
  119. package/dist/utils/valueManager.d.ts.map +1 -0
  120. package/dist/utils/valueManager.js +22 -0
  121. package/dist/utils/valueManager.js.map +1 -0
  122. package/dist/workspace/index.d.ts +7 -0
  123. package/dist/workspace/index.d.ts.map +1 -0
  124. package/dist/workspace/index.js +14 -0
  125. package/dist/workspace/index.js.map +1 -0
  126. package/dist/workspace/presenceStates.d.ts +61 -0
  127. package/dist/workspace/presenceStates.d.ts.map +1 -0
  128. package/dist/workspace/presenceStates.js +235 -0
  129. package/dist/workspace/presenceStates.js.map +1 -0
  130. package/dist/workspace/stateDatastore.d.ts +17 -0
  131. package/dist/workspace/stateDatastore.d.ts.map +1 -0
  132. package/dist/workspace/stateDatastore.js +24 -0
  133. package/dist/workspace/stateDatastore.js.map +1 -0
  134. package/lib/packageVersion.d.ts +9 -0
  135. package/lib/packageVersion.d.ts.map +1 -0
  136. package/lib/packageVersion.js +9 -0
  137. package/lib/packageVersion.js.map +1 -0
  138. package/lib/runtime/extension/containerPresence.d.ts +53 -0
  139. package/lib/runtime/extension/containerPresence.d.ts.map +1 -0
  140. package/lib/runtime/extension/containerPresence.js +87 -0
  141. package/lib/runtime/extension/containerPresence.js.map +1 -0
  142. package/lib/runtime/extension/index.d.ts +6 -0
  143. package/lib/runtime/extension/index.d.ts.map +1 -0
  144. package/lib/runtime/extension/index.js +6 -0
  145. package/lib/runtime/extension/index.js.map +1 -0
  146. package/lib/runtime/presenceDatastoreManager.d.ts +146 -0
  147. package/lib/runtime/presenceDatastoreManager.d.ts.map +1 -0
  148. package/lib/runtime/presenceDatastoreManager.js +662 -0
  149. package/lib/runtime/presenceDatastoreManager.js.map +1 -0
  150. package/lib/runtime/presenceManager.d.ts +16 -0
  151. package/lib/runtime/presenceManager.d.ts.map +1 -0
  152. package/lib/runtime/presenceManager.js +136 -0
  153. package/lib/runtime/presenceManager.js.map +1 -0
  154. package/lib/runtime/protocol.d.ts +126 -0
  155. package/lib/runtime/protocol.d.ts.map +1 -0
  156. package/lib/runtime/protocol.js +17 -0
  157. package/lib/runtime/protocol.js.map +1 -0
  158. package/lib/runtime/runtimeTypes.d.ts +26 -0
  159. package/lib/runtime/runtimeTypes.d.ts.map +1 -0
  160. package/lib/runtime/runtimeTypes.js +6 -0
  161. package/lib/runtime/runtimeTypes.js.map +1 -0
  162. package/lib/runtime/systemWorkspace.d.ts +39 -0
  163. package/lib/runtime/systemWorkspace.d.ts.map +1 -0
  164. package/lib/runtime/systemWorkspace.js +260 -0
  165. package/lib/runtime/systemWorkspace.js.map +1 -0
  166. package/lib/runtime/test/presenceDatastoreManager.spec.js +616 -0
  167. package/lib/runtime/test/presenceDatastoreManager.spec.js.map +1 -0
  168. package/lib/runtime/test/presenceManager.spec.js +649 -0
  169. package/lib/runtime/test/presenceManager.spec.js.map +1 -0
  170. package/lib/runtime/test.d.ts +12 -0
  171. package/lib/runtime/test.d.ts.map +1 -0
  172. package/lib/runtime/test.js +10 -0
  173. package/lib/runtime/test.js.map +1 -0
  174. package/lib/states/index.d.ts +7 -0
  175. package/lib/states/index.d.ts.map +1 -0
  176. package/lib/states/index.js +7 -0
  177. package/lib/states/index.js.map +1 -0
  178. package/lib/states/latestMapValueManager.d.ts +10 -0
  179. package/lib/states/latestMapValueManager.d.ts.map +1 -0
  180. package/lib/states/latestMapValueManager.js +244 -0
  181. package/lib/states/latestMapValueManager.js.map +1 -0
  182. package/lib/states/latestValueManager.d.ts +10 -0
  183. package/lib/states/latestValueManager.d.ts.map +1 -0
  184. package/lib/states/latestValueManager.js +111 -0
  185. package/lib/states/latestValueManager.js.map +1 -0
  186. package/lib/states/notificationsManager.d.ts +26 -0
  187. package/lib/states/notificationsManager.d.ts.map +1 -0
  188. package/lib/states/notificationsManager.js +93 -0
  189. package/lib/states/notificationsManager.js.map +1 -0
  190. package/lib/states/presence.d.ts +11 -0
  191. package/lib/states/presence.d.ts.map +1 -0
  192. package/lib/states/presence.js +6 -0
  193. package/lib/states/presence.js.map +1 -0
  194. package/lib/states/stateFactory.d.ts +18 -0
  195. package/lib/states/stateFactory.d.ts.map +1 -0
  196. package/lib/states/stateFactory.js +20 -0
  197. package/lib/states/stateFactory.js.map +1 -0
  198. package/lib/states/test/batching.spec.js +841 -0
  199. package/lib/states/test/batching.spec.js.map +1 -0
  200. package/lib/states/test/broadcastControlsTests.js +56 -0
  201. package/lib/states/test/broadcastControlsTests.js.map +1 -0
  202. package/lib/states/test/eventing.spec.js +574 -0
  203. package/lib/states/test/eventing.spec.js.map +1 -0
  204. package/lib/states/test/latestMapValueManager.spec.js +206 -0
  205. package/lib/states/test/latestMapValueManager.spec.js.map +1 -0
  206. package/lib/states/test/latestValueManager.spec.js +189 -0
  207. package/lib/states/test/latestValueManager.spec.js.map +1 -0
  208. package/lib/states/test/mockEphemeralRuntime.js +6 -0
  209. package/lib/states/test/mockEphemeralRuntime.js.map +1 -0
  210. package/lib/states/test/notificationsManager.spec.js +456 -0
  211. package/lib/states/test/notificationsManager.spec.js.map +1 -0
  212. package/lib/states/test/presenceStates.spec.js +69 -0
  213. package/lib/states/test/presenceStates.spec.js.map +1 -0
  214. package/lib/states/test/schemaValidation/protocol.spec.js +244 -0
  215. package/lib/states/test/schemaValidation/protocol.spec.js.map +1 -0
  216. package/lib/states/test/schemaValidation/valueManagers.spec.js +782 -0
  217. package/lib/states/test/schemaValidation/valueManagers.spec.js.map +1 -0
  218. package/lib/states/test/testUtils.js +6 -0
  219. package/lib/states/test/testUtils.js.map +1 -0
  220. package/lib/states/validatedGetter.d.ts +18 -0
  221. package/lib/states/validatedGetter.d.ts.map +1 -0
  222. package/lib/states/validatedGetter.js +39 -0
  223. package/lib/states/validatedGetter.js.map +1 -0
  224. package/lib/test/mockEphemeralRuntime.js +171 -0
  225. package/lib/test/mockEphemeralRuntime.js.map +1 -0
  226. package/lib/test/testUtils.js +251 -0
  227. package/lib/test/testUtils.js.map +1 -0
  228. package/lib/test/utils/index.js +8 -0
  229. package/lib/test/utils/index.js.map +1 -0
  230. package/lib/utils/broadcastControls.d.ts +37 -0
  231. package/lib/utils/broadcastControls.d.ts.map +1 -0
  232. package/lib/utils/broadcastControls.js +55 -0
  233. package/lib/utils/broadcastControls.js.map +1 -0
  234. package/lib/utils/index.d.ts +9 -0
  235. package/lib/utils/index.d.ts.map +1 -0
  236. package/lib/utils/index.js +9 -0
  237. package/lib/utils/index.js.map +1 -0
  238. package/lib/utils/internalUtils.d.ts +125 -0
  239. package/lib/utils/internalUtils.d.ts.map +1 -0
  240. package/lib/utils/internalUtils.js +90 -0
  241. package/lib/utils/internalUtils.js.map +1 -0
  242. package/lib/utils/test/timerManager.spec.js +91 -0
  243. package/lib/utils/test/timerManager.spec.js.map +1 -0
  244. package/lib/utils/timerManager.d.ts +37 -0
  245. package/lib/utils/timerManager.d.ts.map +1 -0
  246. package/lib/utils/timerManager.js +61 -0
  247. package/lib/utils/timerManager.js.map +1 -0
  248. package/lib/utils/valueManager.d.ts +14 -0
  249. package/lib/utils/valueManager.d.ts.map +1 -0
  250. package/lib/utils/valueManager.js +17 -0
  251. package/lib/utils/valueManager.js.map +1 -0
  252. package/lib/workspace/index.d.ts +7 -0
  253. package/lib/workspace/index.d.ts.map +1 -0
  254. package/lib/workspace/index.js +7 -0
  255. package/lib/workspace/index.js.map +1 -0
  256. package/lib/workspace/presenceStates.d.ts +61 -0
  257. package/lib/workspace/presenceStates.d.ts.map +1 -0
  258. package/lib/workspace/presenceStates.js +229 -0
  259. package/lib/workspace/presenceStates.js.map +1 -0
  260. package/lib/workspace/stateDatastore.d.ts +17 -0
  261. package/lib/workspace/stateDatastore.d.ts.map +1 -0
  262. package/lib/workspace/stateDatastore.js +19 -0
  263. package/lib/workspace/stateDatastore.js.map +1 -0
  264. package/package.json +158 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) Microsoft Corporation and contributors. All rights reserved.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # @fluid-internal/presence-runtime
2
+
3
+ This is an internal package containing implementations of `presence` APIs.
4
+ `presence` APIs should be accessed via `@fluidframework/presence` package.
5
+
6
+ ## Source organization
7
+
8
+ ```
9
+ @fluidframework/presence
10
+ |
11
+ +---------^---------+-------+
12
+ | | |
13
+ ./states ./runtime |
14
+ | | |
15
+ ^---------v---------+ |
16
+ | | | |
17
+ | ./workspace | |
18
+ | | | |
19
+ ^-------v-+---------^ |
20
+ | | | |
21
+ | ./utils | |
22
+ | | | |
23
+ ^-------^---v-------^-------^
24
+ |
25
+ @fluid-internal/presence-definitions
26
+ ```
27
+
28
+ ### utils
29
+
30
+ **Purpose:** Utility functions and shared implementations.
31
+
32
+ **Files:**
33
+ - `internalUtils.ts` → `objectEntries`, `objectKeys`, `getOrCreateRecord`, JSON helpers
34
+ - `timerManager.ts` → `TimerManager` class
35
+ - `broadcastControls.ts` → `OptionalBroadcastControl`, `RequiredBroadcastControl` classes
36
+ - `valueManager.ts` → `brandIVM`, `unbrandIVM`
37
+
38
+ ### workspace
39
+
40
+ **Purpose:** Workspace abstractions and state datastore contracts.
41
+
42
+ **Files:**
43
+ - `stateDatastore.ts` → `StateDatastore` interface, `handleFromDatastore`, `datastoreFromHandle`
44
+ - `presenceStates.ts` → `PresenceStatesImpl`, `createPresenceStates`, workspace implementation
45
+
46
+ ### runtime
47
+
48
+ **Purpose:** Core runtime - presence manager, datastore manager, system workspace.
49
+
50
+ **Exposes:** extension elements `ContainerPresenceFactory` and `extensionId`
51
+
52
+ **Files:**
53
+ - `extension/containerPresence.ts` → `ContainerPresenceFactory`, `extensionId`
54
+ - `presenceDatastoreManager.ts` → `PresenceDatastoreManagerImpl`
55
+ - `presenceManager.ts` → `PresenceManager` class, `createPresenceManager`
56
+ - `protocol.ts` → Message type definitions, `joinMessageType`, `datastoreUpdateMessageType`, `acknowledgementMessageType`
57
+ - `runtimeTypes.ts` → `IEphemeralRuntime`, `ExtensionHost`
58
+ - `systemWorkspace.ts` → `SystemWorkspace`, `createSystemWorkspace`
59
+
60
+ ### states
61
+
62
+ **Purpose:** State manager implementations.
63
+
64
+ **Exposes:** `StateFactory` and `Notifications` (factory)
65
+
66
+ **Files:**
67
+ - `latestMapValueManager.ts` → `latestMap` factory
68
+ - `latestValueManager.ts` → `latest` factory
69
+ - `notificationsManager.ts` → `NotificationsManager`, `Notifications` factory
70
+ - `presence.ts` → `SpecificAttendee`
71
+ - `stateFactory.ts` → `StateFactory` object
72
+ - `validatedGetter.ts` → `createValidatedGetter`
@@ -0,0 +1,4 @@
1
+ {
2
+ "type": "commonjs",
3
+ "sideEffects": false
4
+ }
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
+ */
7
+ export declare const pkgName = "@fluid-internal/presence-runtime";
8
+ export declare const pkgVersion = "2.93.0";
9
+ //# sourceMappingURL=packageVersion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,qCAAqC,CAAC;AAC1D,eAAO,MAAM,UAAU,WAAW,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ *
6
+ * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.pkgVersion = exports.pkgName = void 0;
10
+ exports.pkgName = "@fluid-internal/presence-runtime";
11
+ exports.pkgVersion = "2.93.0";
12
+ //# sourceMappingURL=packageVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,kCAAkC,CAAC;AAC7C,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-internal/presence-runtime\";\nexport const pkgVersion = \"2.93.0\";\n"]}
@@ -0,0 +1,53 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { PresenceWithNotifications } from "@fluid-internal/presence-definitions";
6
+ import type { ContainerExtension, ContainerExtensionFactory, ExtensionInstantiationResult, ExtensionRuntimeProperties as GenericExtensionRuntimeProperties, InboundExtensionMessage } from "@fluidframework/container-runtime-definitions/internal";
7
+ import type { ExtensionCompatibilityDetails } from "@fluidframework/runtime-definitions/internal";
8
+ import type { SignalMessages } from "../protocol.js";
9
+ import type { ExtensionHost, ExtensionRuntimeProperties } from "../runtimeTypes.js";
10
+ /**
11
+ * Common Presence manager for a container
12
+ */
13
+ declare class ContainerPresenceManager implements ContainerExtension<ExtensionRuntimeProperties>, ReturnType<ContainerExtensionFactory<PresenceWithNotifications, ExtensionRuntimeProperties>["instantiateExtension"]> {
14
+ readonly compatibility: {
15
+ readonly generation: 1;
16
+ readonly version: "2.93.0";
17
+ readonly capabilities: Set<never>;
18
+ };
19
+ readonly interface: PresenceWithNotifications;
20
+ readonly extension: this;
21
+ private readonly manager;
22
+ constructor(host: ExtensionHost);
23
+ handleVersionOrCapabilitiesMismatch<_TRequestedInterface>(ourExistingInstantiation: Readonly<ExtensionInstantiationResult<PresenceWithNotifications, ExtensionRuntimeProperties, []>>, newCompatibilityRequest: ExtensionCompatibilityDetails): never;
24
+ onNewUse(): void;
25
+ processSignal(addressChain: string[], message: InboundExtensionMessage<SignalMessages>, local: boolean): void;
26
+ }
27
+ /**
28
+ * {@link ContainerExtensionId} for Presence
29
+ *
30
+ * @internal
31
+ */
32
+ export declare const extensionId = "dis:bb89f4c0-80fd-4f0c-8469-4f2848ee7f4a";
33
+ /**
34
+ * {@link ContainerExtensionFactory|Factory} for Presence as {@link ContainerExtension}
35
+ *
36
+ * @internal
37
+ */
38
+ export declare const ContainerPresenceFactory: {
39
+ readonly hostRequirements: {
40
+ readonly minSupportedGeneration: 1;
41
+ readonly requiredFeatures: readonly [];
42
+ };
43
+ readonly instanceExpectations: {
44
+ readonly version: "2.71.0";
45
+ readonly generation: 1;
46
+ readonly capabilities: Set<never>;
47
+ };
48
+ readonly resolvePriorInstantiation: (existingInstantiation: ExtensionInstantiationResult<unknown, GenericExtensionRuntimeProperties, unknown[]>) => never;
49
+ readonly instantiateExtension: (host: ExtensionHost) => ContainerPresenceManager;
50
+ readonly [Symbol.hasInstance]: (instance: unknown) => instance is ContainerPresenceManager;
51
+ };
52
+ export {};
53
+ //# sourceMappingURL=containerPresence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containerPresence.d.ts","sourceRoot":"","sources":["../../../src/runtime/extension/containerPresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,KAAK,EACX,kBAAkB,EAClB,yBAAyB,EACzB,4BAA4B,EAC5B,0BAA0B,IAAI,iCAAiC,EAC/D,uBAAuB,EACvB,MAAM,wDAAwD,CAAC;AAEhE,OAAO,KAAK,EAEX,6BAA6B,EAC7B,MAAM,8CAA8C,CAAC;AAItD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAoCpF;;GAEG;AACH,cAAM,wBACL,YACC,kBAAkB,CAAC,0BAA0B,CAAC,EAC9C,UAAU,CACT,yBAAyB,CACxB,yBAAyB,EACzB,0BAA0B,CAC1B,CAAC,sBAAsB,CAAC,CACzB;IAGF,SAAgB,aAAa;;;;MAAyB;IACtD,SAAgB,SAAS,EAAE,yBAAyB,CAAC;IACrD,SAAgB,SAAS,OAAQ;IAEjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;gBAElC,IAAI,EAAE,aAAa;IAS/B,mCAAmC,CAAC,oBAAoB,EAC9D,wBAAwB,EAAE,QAAQ,CACjC,4BAA4B,CAAC,yBAAyB,EAAE,0BAA0B,EAAE,EAAE,CAAC,CACvF,EACD,uBAAuB,EAAE,6BAA6B,GACpD,KAAK;IAWD,QAAQ,IAAI,IAAI;IAIhB,aAAa,CACnB,YAAY,EAAE,MAAM,EAAE,EACtB,OAAO,EAAE,uBAAuB,CAAC,cAAc,CAAC,EAChD,KAAK,EAAE,OAAO,GACZ,IAAI;CAGP;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,6CACkD,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;gEASZ,6BACtB,OAAO,EACP,iCAAiC,EACjC,OAAO,EAAE,CACT,KACC,KAAK;4DAQmC,wBAAwB;8CAIlC,OAAO;CAMxC,CAAC"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ContainerPresenceFactory = exports.extensionId = void 0;
8
+ const internal_1 = require("@fluidframework/core-utils/internal");
9
+ const packageVersion_js_1 = require("../../packageVersion.js");
10
+ const presenceManager_js_1 = require("../presenceManager.js");
11
+ const presenceCompatibility = {
12
+ generation: 1,
13
+ version: packageVersion_js_1.pkgVersion,
14
+ capabilities: new Set([]),
15
+ };
16
+ /**
17
+ * Minimal compatible package version.
18
+ * If an existing presence extension is registered with this version or higher,
19
+ * it can be used instead of instantiating new instance from this version of
20
+ * the package (assuming also capabilities are compatible).
21
+ */
22
+ const minimalCompatiblePackageVersion = "2.71.0";
23
+ function assertCompatibilityInvariants(compatibility) {
24
+ (0, internal_1.assert)(compatibility.generation === presenceCompatibility.generation, 0xc97 /* Presence compatibility generation mismatch. */);
25
+ (0, internal_1.assert)(compatibility.version.startsWith("2."), 0xc98 /* Registered version is not major version 2. */);
26
+ (0, internal_1.assert)(Number.parseFloat(compatibility.version.slice(2)) <
27
+ Number.parseFloat(presenceCompatibility.version.slice(2)), 0xc99 /* Registered version is not less than the current version. */);
28
+ (0, internal_1.assert)(presenceCompatibility.capabilities.size === 0, 0xc9a /* Presence capabilities should be empty. */);
29
+ }
30
+ /**
31
+ * Common Presence manager for a container
32
+ */
33
+ class ContainerPresenceManager {
34
+ constructor(host) {
35
+ // ContainerExtensionFactory return elements
36
+ this.compatibility = presenceCompatibility;
37
+ this.extension = this;
38
+ this.interface = this.manager = (0, presenceManager_js_1.createPresenceManager)({
39
+ ...host,
40
+ submitSignal: (message) => {
41
+ host.submitAddressedSignal([], message);
42
+ },
43
+ });
44
+ }
45
+ handleVersionOrCapabilitiesMismatch(ourExistingInstantiation, newCompatibilityRequest) {
46
+ (0, internal_1.assert)(ourExistingInstantiation.compatibility === presenceCompatibility, 0xc9b /* Presence extension called without own compatibility details */);
47
+ assertCompatibilityInvariants(newCompatibilityRequest);
48
+ // There have not yet been any changes that would require action to upgrade.
49
+ // But also mixed runtime versions are not yet expected.
50
+ (0, internal_1.fail)(0xcb1 /* Presence is only expected to be accessed with a single version. */);
51
+ }
52
+ onNewUse() {
53
+ // No-op
54
+ }
55
+ processSignal(addressChain, message, local) {
56
+ this.manager.processSignal(addressChain, message, local);
57
+ }
58
+ }
59
+ /**
60
+ * {@link ContainerExtensionId} for Presence
61
+ *
62
+ * @internal
63
+ */
64
+ exports.extensionId = "dis:bb89f4c0-80fd-4f0c-8469-4f2848ee7f4a";
65
+ /**
66
+ * {@link ContainerExtensionFactory|Factory} for Presence as {@link ContainerExtension}
67
+ *
68
+ * @internal
69
+ */
70
+ exports.ContainerPresenceFactory = {
71
+ hostRequirements: {
72
+ minSupportedGeneration: 1,
73
+ requiredFeatures: [],
74
+ },
75
+ instanceExpectations: { ...presenceCompatibility, version: minimalCompatiblePackageVersion },
76
+ resolvePriorInstantiation(existingInstantiation) {
77
+ // Validate assumptions about existing instance
78
+ assertCompatibilityInvariants(existingInstantiation.compatibility);
79
+ // There have not yet been any changes that would require action to upgrade.
80
+ // But also mixed runtime versions are not yet expected.
81
+ (0, internal_1.fail)(0xcb2 /* Presence is only expected to be accessed with a single version. */);
82
+ },
83
+ instantiateExtension(host) {
84
+ return new ContainerPresenceManager(host);
85
+ },
86
+ [Symbol.hasInstance]: (instance) => {
87
+ return instance instanceof ContainerPresenceManager;
88
+ },
89
+ };
90
+ //# sourceMappingURL=containerPresence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containerPresence.js","sourceRoot":"","sources":["../../../src/runtime/extension/containerPresence.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAWH,kEAAmE;AAMnE,+DAAqD;AACrD,8DAA+F;AAI/F,MAAM,qBAAqB,GAAG;IAC7B,UAAU,EAAE,CAAC;IACb,OAAO,EAAE,8BAAU;IACnB,YAAY,EAAE,IAAI,GAAG,CAAC,EAAE,CAAC;CACwB,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,+BAA+B,GAAG,QAAQ,CAAC;AAEjD,SAAS,6BAA6B,CAAC,aAA4C;IAClF,IAAA,iBAAM,EACL,aAAa,CAAC,UAAU,KAAK,qBAAqB,CAAC,UAAU,EAC7D,KAAK,CAAC,iDAAiD,CACvD,CAAC;IACF,IAAA,iBAAM,EACL,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EACtC,KAAK,CAAC,gDAAgD,CACtD,CAAC;IACF,IAAA,iBAAM,EACL,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChD,MAAM,CAAC,UAAU,CAAC,qBAAqB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAC1D,KAAK,CAAC,8DAA8D,CACpE,CAAC;IACF,IAAA,iBAAM,EACL,qBAAqB,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,EAC7C,KAAK,CAAC,4CAA4C,CAClD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,wBAAwB;IAiB7B,YAAmB,IAAmB;QAPtC,4CAA4C;QAC5B,kBAAa,GAAG,qBAAq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I,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,QAAiB,EAAwC,EAAE;QACjF,OAAO,QAAQ,YAAY,wBAAwB,CAAC;IACrD,CAAC;CAID,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ILayerCompatSupportRequirements } from \"@fluid-internal/client-utils\";\nimport type { PresenceWithNotifications } from \"@fluid-internal/presence-definitions\";\nimport type {\n\tContainerExtension,\n\tContainerExtensionFactory,\n\tExtensionInstantiationResult,\n\tExtensionRuntimeProperties as GenericExtensionRuntimeProperties,\n\tInboundExtensionMessage,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tContainerExtensionId,\n\tExtensionCompatibilityDetails,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { pkgVersion } from \"../../packageVersion.js\";\nimport { createPresenceManager, type PresenceExtensionInterface } from \"../presenceManager.js\";\nimport type { SignalMessages } from \"../protocol.js\";\nimport type { ExtensionHost, ExtensionRuntimeProperties } from \"../runtimeTypes.js\";\n\nconst presenceCompatibility = {\n\tgeneration: 1,\n\tversion: pkgVersion,\n\tcapabilities: new Set([]),\n} as const satisfies ExtensionCompatibilityDetails;\n\n/**\n * Minimal compatible package version.\n * If an existing presence extension is registered with this version or higher,\n * it can be used instead of instantiating new instance from this version of\n * the package (assuming also capabilities are compatible).\n */\nconst minimalCompatiblePackageVersion = \"2.71.0\";\n\nfunction assertCompatibilityInvariants(compatibility: ExtensionCompatibilityDetails): void {\n\tassert(\n\t\tcompatibility.generation === presenceCompatibility.generation,\n\t\t0xc97 /* Presence compatibility generation mismatch. */,\n\t);\n\tassert(\n\t\tcompatibility.version.startsWith(\"2.\"),\n\t\t0xc98 /* Registered version is not major version 2. */,\n\t);\n\tassert(\n\t\tNumber.parseFloat(compatibility.version.slice(2)) <\n\t\t\tNumber.parseFloat(presenceCompatibility.version.slice(2)),\n\t\t0xc99 /* Registered version is not less than the current version. */,\n\t);\n\tassert(\n\t\tpresenceCompatibility.capabilities.size === 0,\n\t\t0xc9a /* Presence capabilities should be empty. */,\n\t);\n}\n\n/**\n * Common Presence manager for a container\n */\nclass ContainerPresenceManager\n\timplements\n\t\tContainerExtension<ExtensionRuntimeProperties>,\n\t\tReturnType<\n\t\t\tContainerExtensionFactory<\n\t\t\t\tPresenceWithNotifications,\n\t\t\t\tExtensionRuntimeProperties\n\t\t\t>[\"instantiateExtension\"]\n\t\t>\n{\n\t// ContainerExtensionFactory return elements\n\tpublic readonly compatibility = presenceCompatibility;\n\tpublic readonly interface: PresenceWithNotifications;\n\tpublic readonly extension = this;\n\n\tprivate readonly manager: PresenceExtensionInterface;\n\n\tpublic constructor(host: ExtensionHost) {\n\t\tthis.interface = this.manager = createPresenceManager({\n\t\t\t...host,\n\t\t\tsubmitSignal: (message) => {\n\t\t\t\thost.submitAddressedSignal([], message);\n\t\t\t},\n\t\t});\n\t}\n\n\tpublic handleVersionOrCapabilitiesMismatch<_TRequestedInterface>(\n\t\tourExistingInstantiation: Readonly<\n\t\t\tExtensionInstantiationResult<PresenceWithNotifications, ExtensionRuntimeProperties, []>\n\t\t>,\n\t\tnewCompatibilityRequest: ExtensionCompatibilityDetails,\n\t): never {\n\t\tassert(\n\t\t\tourExistingInstantiation.compatibility === presenceCompatibility,\n\t\t\t0xc9b /* Presence extension called without own compatibility details */,\n\t\t);\n\t\tassertCompatibilityInvariants(newCompatibilityRequest);\n\t\t// There have not yet been any changes that would require action to upgrade.\n\t\t// But also mixed runtime versions are not yet expected.\n\t\tfail(0xcb1 /* Presence is only expected to be accessed with a single version. */);\n\t}\n\n\tpublic onNewUse(): void {\n\t\t// No-op\n\t}\n\n\tpublic processSignal(\n\t\taddressChain: string[],\n\t\tmessage: InboundExtensionMessage<SignalMessages>,\n\t\tlocal: boolean,\n\t): void {\n\t\tthis.manager.processSignal(addressChain, message, local);\n\t}\n}\n\n/**\n * {@link ContainerExtensionId} for Presence\n *\n * @internal\n */\nexport const extensionId =\n\t\"dis:bb89f4c0-80fd-4f0c-8469-4f2848ee7f4a\" satisfies ContainerExtensionId;\n\n/**\n * {@link ContainerExtensionFactory|Factory} for Presence as {@link ContainerExtension}\n *\n * @internal\n */\nexport const ContainerPresenceFactory = {\n\thostRequirements: {\n\t\tminSupportedGeneration: 1,\n\t\trequiredFeatures: [],\n\t} as const satisfies ILayerCompatSupportRequirements,\n\n\tinstanceExpectations: { ...presenceCompatibility, version: minimalCompatiblePackageVersion },\n\n\tresolvePriorInstantiation(\n\t\texistingInstantiation: ExtensionInstantiationResult<\n\t\t\tunknown,\n\t\t\tGenericExtensionRuntimeProperties,\n\t\t\tunknown[]\n\t\t>,\n\t): never {\n\t\t// Validate assumptions about existing instance\n\t\tassertCompatibilityInvariants(existingInstantiation.compatibility);\n\t\t// There have not yet been any changes that would require action to upgrade.\n\t\t// But also mixed runtime versions are not yet expected.\n\t\tfail(0xcb2 /* Presence is only expected to be accessed with a single version. */);\n\t},\n\n\tinstantiateExtension(host: ExtensionHost): ContainerPresenceManager {\n\t\treturn new ContainerPresenceManager(host);\n\t},\n\n\t[Symbol.hasInstance]: (instance: unknown): instance is ContainerPresenceManager => {\n\t\treturn instance instanceof ContainerPresenceManager;\n\t},\n} as const satisfies ContainerExtensionFactory<\n\tPresenceWithNotifications,\n\tExtensionRuntimeProperties\n>;\n"]}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { ContainerPresenceFactory, extensionId } from "./containerPresence.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/extension/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.extensionId = exports.ContainerPresenceFactory = void 0;
8
+ var containerPresence_js_1 = require("./containerPresence.js");
9
+ Object.defineProperty(exports, "ContainerPresenceFactory", { enumerable: true, get: function () { return containerPresence_js_1.ContainerPresenceFactory; } });
10
+ Object.defineProperty(exports, "extensionId", { enumerable: true, get: function () { return containerPresence_js_1.extensionId; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/extension/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA+E;AAAtE,gIAAA,wBAAwB,OAAA;AAAE,mHAAA,WAAW,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ContainerPresenceFactory, extensionId } from \"./containerPresence.js\";\n"]}
@@ -0,0 +1,146 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { AttendeeId, BroadcastControlSettings, ClientConnectionId, NotificationsWorkspace, NotificationsWorkspaceSchema, PresenceWithNotifications as Presence, PresenceEvents, StatesWorkspace, StatesWorkspaceSchema, WorkspaceAddress } from "@fluid-internal/presence-definitions";
6
+ import type { AnyWorkspace } from "@fluid-internal/presence-definitions/internal";
7
+ import type { PresenceStatesInternal } from "@fluid-internal/presence-definitions/internal/workspace-runtime";
8
+ import type { InboundExtensionMessage } from "@fluidframework/container-runtime-definitions/internal";
9
+ import type { IEmitter } from "@fluidframework/core-interfaces/internal";
10
+ import type { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
11
+ import type { InternalWorkspaceAddress, SignalMessages, SystemWorkspaceDatastore } from "./protocol.js";
12
+ import type { IEphemeralRuntime } from "./runtimeTypes.js";
13
+ interface AnyWorkspaceEntry<TSchema extends StatesWorkspaceSchema> {
14
+ public: AnyWorkspace<TSchema>;
15
+ internal: PresenceStatesInternal;
16
+ }
17
+ /**
18
+ * High-level contract for manager of singleton Presence datastore
19
+ */
20
+ export interface PresenceDatastoreManager {
21
+ joinSession(clientId: ClientConnectionId, alternateProvider: ClientConnectionId | undefined): void;
22
+ onDisconnected(): void;
23
+ getWorkspace<TSchema extends Partial<StatesWorkspaceSchema<TSchemaKeys>>, TSchemaKeys extends string & keyof TSchema>(internalWorkspaceAddress: `s:${WorkspaceAddress}`, requestedContent: TSchema, controls?: BroadcastControlSettings): StatesWorkspace<TSchema, unknown, TSchemaKeys>;
24
+ getWorkspace<TSchema extends Partial<NotificationsWorkspaceSchema<TSchemaKeys>>, TSchemaKeys extends string & keyof TSchema>(internalWorkspaceAddress: `n:${WorkspaceAddress}`, requestedContent: TSchema): NotificationsWorkspace<TSchema, TSchemaKeys>;
25
+ processSignal(message: InboundExtensionMessage<SignalMessages> & {
26
+ clientId: ClientConnectionId;
27
+ }, local: boolean, optional: boolean): void;
28
+ }
29
+ /**
30
+ * Delays used for broadcasting join responses to clients.
31
+ *
32
+ * @remarks
33
+ * Exported for test coordination.
34
+ * These could be made customizable in the future to accommodate different
35
+ * session configurations.
36
+ */
37
+ export declare const broadcastJoinResponseDelaysMs: {
38
+ /**
39
+ * The delay in milliseconds before a join response is sent to any client.
40
+ * This is used to accumulate other join response requests and reduce
41
+ * network traffic.
42
+ */
43
+ readonly namedResponder: 200;
44
+ /**
45
+ * The additional delay in milliseconds a backup responder waits before sending
46
+ * a join response to allow others to respond first.
47
+ */
48
+ readonly backupResponderIncrement: 40;
49
+ };
50
+ /**
51
+ * Manages singleton datastore for all Presence.
52
+ */
53
+ export declare class PresenceDatastoreManagerImpl implements PresenceDatastoreManager {
54
+ private readonly attendeeId;
55
+ private readonly runtime;
56
+ private readonly logger;
57
+ private readonly events;
58
+ private readonly presence;
59
+ private readonly datastore;
60
+ private averageLatency;
61
+ private returnedMessages;
62
+ private readonly sendMessageTimer;
63
+ private readonly workspaces;
64
+ private readonly targetedSignalSupport;
65
+ /**
66
+ * Tracks whether this client has complete snapshot level knowledge and
67
+ * how that determination was reached.
68
+ * - "alone": no other audience members detected at join
69
+ * - "join response": another client has responded to our join request
70
+ * - "full requests": all others have requested response from us
71
+ *
72
+ * @remarks
73
+ * Only applies when not using targeted join responses.
74
+ *
75
+ * Without a complete snapshot, we cannot fully onboard any other clients.
76
+ * One exception to this is if this client is the only participant in the
77
+ * session. In such a case, there is no one to respond to the join request.
78
+ * Another exception is multiple clients attempting to join at the same
79
+ * time and thus expecting that someone has full knowledge, yet none have
80
+ * received a complete update to think they are qualified to respond.
81
+ * Generically if the number of outstanding requestors meets or exceeds the
82
+ * count of other audience members, then we can consider the snapshot
83
+ * complete (as all will have provided their own complete information in
84
+ * their join responses).
85
+ */
86
+ private reasonForCompleteSnapshot?;
87
+ /**
88
+ * Map of outstanding broadcast (join response) requests.
89
+ */
90
+ private readonly broadcastRequests;
91
+ /**
92
+ * Timer for managing broadcast (join response) request timing.
93
+ */
94
+ private readonly broadcastRequestsTimer;
95
+ constructor(attendeeId: AttendeeId, runtime: IEphemeralRuntime, logger: ITelemetryLoggerExt, events: IEmitter<PresenceEvents>, presence: Presence, systemWorkspaceDatastore: SystemWorkspaceDatastore, systemWorkspace: AnyWorkspaceEntry<StatesWorkspaceSchema>);
96
+ private getAudienceInformation;
97
+ joinSession(selfClientId: ClientConnectionId, alternateProvider?: ClientConnectionId | undefined): void;
98
+ onDisconnected(): void;
99
+ getWorkspace<TSchema extends StatesWorkspaceSchema>(internalWorkspaceAddress: InternalWorkspaceAddress, requestedContent: TSchema, controls?: BroadcastControlSettings): AnyWorkspace<TSchema>;
100
+ /**
101
+ * The combined contents of all queued updates. Will be `"sendAll"` when a
102
+ * full broadcast is pending or `undefined` when no messages are queued.
103
+ */
104
+ private queuedData;
105
+ /**
106
+ * Enqueues a new message to be sent. The message may be queued or may be sent immediately depending on the state of
107
+ * the send timer, other messages in the queue, the configured allowed latency, etc.
108
+ */
109
+ private enqueueMessage;
110
+ /**
111
+ * Send any queued signal immediately. Does nothing if no message is queued.
112
+ */
113
+ private sendQueuedMessage;
114
+ /**
115
+ * Recursively strips validation metadata (validatedValue) from datastore before broadcasting.
116
+ * This ensures that validation metadata doesn't leak into signals sent to other clients.
117
+ */
118
+ private stripValidationMetadata;
119
+ /**
120
+ * Strips validation metadata from individual value data entries.
121
+ */
122
+ private stripValidationFromValueData;
123
+ private broadcastAllKnownState;
124
+ processSignal(message: InboundExtensionMessage<SignalMessages> & {
125
+ clientId: ClientConnectionId;
126
+ }, local: boolean, optional: boolean): void;
127
+ /**
128
+ * Broadcasts a join response (complete datastore update message)
129
+ * if there is an outstanding join response request.
130
+ */
131
+ private readonly sendJoinResponseIfStillNeeded;
132
+ /**
133
+ * Handles responding to another client joining the session.
134
+ *
135
+ * @param updateProviders - list of client connection id's that requestor selected
136
+ * to provide response
137
+ * @param requestor - `requestor` is only used in telemetry. While it is the requestor's
138
+ * client connection id, that is not most important. It is important that this is a
139
+ * unique shared id across all clients that might respond as we want to monitor the
140
+ * response patterns. The convenience of being client connection id will allow
141
+ * correlation with other telemetry where it is often called just `clientId`.
142
+ */
143
+ private prepareJoinResponse;
144
+ }
145
+ export {};
146
+ //# sourceMappingURL=presenceDatastoreManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presenceDatastoreManager.d.ts","sourceRoot":"","sources":["../../src/runtime/presenceDatastoreManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,UAAU,EACV,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,EAC5B,yBAAyB,IAAI,QAAQ,EACrC,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,gBAAg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