@microsoft/live-share-react 2.0.0-internal.1 → 2.0.0-internal.11

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 (313) hide show
  1. package/LICENSE +64 -61
  2. package/README.md +169 -164
  3. package/bin/cjs/index.d.ts +7 -0
  4. package/bin/cjs/index.d.ts.map +1 -0
  5. package/bin/cjs/index.js +23 -0
  6. package/bin/cjs/index.js.map +1 -0
  7. package/bin/cjs/interfaces/LiveInterfaceExtensions.d.ts +26 -0
  8. package/bin/cjs/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
  9. package/bin/cjs/interfaces/LiveInterfaceExtensions.js +7 -0
  10. package/bin/cjs/interfaces/LiveInterfaceExtensions.js.map +1 -0
  11. package/bin/cjs/interfaces/index.d.ts +2 -0
  12. package/bin/cjs/interfaces/index.d.ts.map +1 -0
  13. package/bin/cjs/interfaces/index.js +18 -0
  14. package/bin/cjs/interfaces/index.js.map +1 -0
  15. package/bin/cjs/internal/errors.d.ts +41 -0
  16. package/bin/cjs/internal/errors.d.ts.map +1 -0
  17. package/bin/cjs/internal/errors.js +48 -0
  18. package/bin/cjs/internal/errors.js.map +1 -0
  19. package/bin/cjs/internal/index.d.ts +3 -0
  20. package/bin/cjs/internal/index.d.ts.map +1 -0
  21. package/bin/cjs/internal/index.js +19 -0
  22. package/bin/cjs/internal/index.js.map +1 -0
  23. package/bin/cjs/internal/type-guards.d.ts +11 -0
  24. package/bin/cjs/internal/type-guards.d.ts.map +1 -0
  25. package/bin/cjs/internal/type-guards.js +24 -0
  26. package/bin/cjs/internal/type-guards.js.map +1 -0
  27. package/bin/cjs/live-hooks/index.d.ts +8 -0
  28. package/bin/cjs/live-hooks/index.d.ts.map +1 -0
  29. package/bin/cjs/live-hooks/index.js +24 -0
  30. package/bin/cjs/live-hooks/index.js.map +1 -0
  31. package/bin/cjs/live-hooks/useLiveCanvas.d.ts +80 -0
  32. package/bin/cjs/live-hooks/useLiveCanvas.d.ts.map +1 -0
  33. package/bin/cjs/live-hooks/useLiveCanvas.js +244 -0
  34. package/bin/cjs/live-hooks/useLiveCanvas.js.map +1 -0
  35. package/bin/cjs/live-hooks/useLiveEvent.d.ts +59 -0
  36. package/bin/cjs/live-hooks/useLiveEvent.d.ts.map +1 -0
  37. package/bin/cjs/live-hooks/useLiveEvent.js +150 -0
  38. package/bin/cjs/live-hooks/useLiveEvent.js.map +1 -0
  39. package/bin/cjs/live-hooks/useLiveFollowMode.d.ts +163 -0
  40. package/bin/cjs/live-hooks/useLiveFollowMode.d.ts.map +1 -0
  41. package/bin/cjs/live-hooks/useLiveFollowMode.js +360 -0
  42. package/bin/cjs/live-hooks/useLiveFollowMode.js.map +1 -0
  43. package/bin/cjs/live-hooks/useLivePresence.d.ts +76 -0
  44. package/bin/cjs/live-hooks/useLivePresence.d.ts.map +1 -0
  45. package/bin/cjs/live-hooks/useLivePresence.js +170 -0
  46. package/bin/cjs/live-hooks/useLivePresence.js.map +1 -0
  47. package/bin/cjs/live-hooks/useLiveState.d.ts +66 -0
  48. package/bin/cjs/live-hooks/useLiveState.d.ts.map +1 -0
  49. package/bin/cjs/live-hooks/useLiveState.js +134 -0
  50. package/bin/cjs/live-hooks/useLiveState.js.map +1 -0
  51. package/bin/cjs/live-hooks/useLiveTimer.d.ts +80 -0
  52. package/bin/cjs/live-hooks/useLiveTimer.d.ts.map +1 -0
  53. package/bin/cjs/live-hooks/useLiveTimer.js +233 -0
  54. package/bin/cjs/live-hooks/useLiveTimer.js.map +1 -0
  55. package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts +86 -0
  56. package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
  57. package/bin/cjs/live-hooks/useMediaSynchronizer.js +301 -0
  58. package/bin/cjs/live-hooks/useMediaSynchronizer.js.map +1 -0
  59. package/bin/cjs/package.json +1 -0
  60. package/bin/cjs/providers/AzureProvider.d.ts +113 -0
  61. package/bin/cjs/providers/AzureProvider.d.ts.map +1 -0
  62. package/bin/cjs/providers/AzureProvider.js +127 -0
  63. package/bin/cjs/providers/AzureProvider.js.map +1 -0
  64. package/bin/cjs/providers/LiveShareProvider.d.ts +193 -0
  65. package/bin/cjs/providers/LiveShareProvider.d.ts.map +1 -0
  66. package/bin/cjs/providers/LiveShareProvider.js +205 -0
  67. package/bin/cjs/providers/LiveShareProvider.js.map +1 -0
  68. package/bin/cjs/providers/index.d.ts +3 -0
  69. package/bin/cjs/providers/index.d.ts.map +1 -0
  70. package/bin/cjs/providers/index.js +19 -0
  71. package/bin/cjs/providers/index.js.map +1 -0
  72. package/bin/cjs/shared-hooks/index.d.ts +7 -0
  73. package/bin/cjs/shared-hooks/index.d.ts.map +1 -0
  74. package/bin/cjs/shared-hooks/index.js +23 -0
  75. package/bin/cjs/shared-hooks/index.js.map +1 -0
  76. package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts +3 -0
  77. package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
  78. package/bin/cjs/shared-hooks/internals/tree-node-constants.js +6 -0
  79. package/bin/cjs/shared-hooks/internals/tree-node-constants.js.map +1 -0
  80. package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts +10 -0
  81. package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
  82. package/bin/cjs/shared-hooks/internals/tree-node-types.js +23 -0
  83. package/bin/cjs/shared-hooks/internals/tree-node-types.js.map +1 -0
  84. package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts +33 -0
  85. package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
  86. package/bin/cjs/shared-hooks/internals/tree-node-utils.js +193 -0
  87. package/bin/cjs/shared-hooks/internals/tree-node-utils.js.map +1 -0
  88. package/bin/cjs/shared-hooks/useDynamicDDS.d.ts +23 -0
  89. package/bin/cjs/shared-hooks/useDynamicDDS.d.ts.map +1 -0
  90. package/bin/cjs/shared-hooks/useDynamicDDS.js +87 -0
  91. package/bin/cjs/shared-hooks/useDynamicDDS.js.map +1 -0
  92. package/bin/cjs/shared-hooks/useSharedMap.d.ts +25 -0
  93. package/bin/cjs/shared-hooks/useSharedMap.d.ts.map +1 -0
  94. package/bin/cjs/shared-hooks/useSharedMap.js +134 -0
  95. package/bin/cjs/shared-hooks/useSharedMap.js.map +1 -0
  96. package/bin/cjs/shared-hooks/useSharedState.d.ts +22 -0
  97. package/bin/cjs/shared-hooks/useSharedState.d.ts.map +1 -0
  98. package/bin/cjs/shared-hooks/useSharedState.js +80 -0
  99. package/bin/cjs/shared-hooks/useSharedState.js.map +1 -0
  100. package/bin/cjs/shared-hooks/useSharedStateRegistry.d.ts +37 -0
  101. package/bin/cjs/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
  102. package/bin/cjs/shared-hooks/useSharedStateRegistry.js +120 -0
  103. package/bin/cjs/shared-hooks/useSharedStateRegistry.js.map +1 -0
  104. package/bin/cjs/shared-hooks/useSharedTree.d.ts +57 -0
  105. package/bin/cjs/shared-hooks/useSharedTree.d.ts.map +1 -0
  106. package/bin/cjs/shared-hooks/useSharedTree.js +123 -0
  107. package/bin/cjs/shared-hooks/useSharedTree.js.map +1 -0
  108. package/bin/cjs/shared-hooks/useTreeNode.d.ts +96 -0
  109. package/bin/cjs/shared-hooks/useTreeNode.d.ts.map +1 -0
  110. package/bin/cjs/shared-hooks/useTreeNode.js +135 -0
  111. package/bin/cjs/shared-hooks/useTreeNode.js.map +1 -0
  112. package/bin/cjs/types/ActionTypes.d.ts +112 -0
  113. package/bin/cjs/types/ActionTypes.d.ts.map +1 -0
  114. package/bin/cjs/types/ActionTypes.js +7 -0
  115. package/bin/cjs/types/ActionTypes.js.map +1 -0
  116. package/bin/cjs/types/PropTypes.d.ts +56 -0
  117. package/bin/cjs/types/PropTypes.d.ts.map +1 -0
  118. package/bin/cjs/types/PropTypes.js +7 -0
  119. package/bin/cjs/types/PropTypes.js.map +1 -0
  120. package/bin/cjs/types/ResultTypes.d.ts +334 -0
  121. package/bin/cjs/types/ResultTypes.d.ts.map +1 -0
  122. package/bin/cjs/types/ResultTypes.js +7 -0
  123. package/bin/cjs/types/ResultTypes.js.map +1 -0
  124. package/bin/cjs/types/index.d.ts +4 -0
  125. package/bin/cjs/types/index.d.ts.map +1 -0
  126. package/bin/cjs/types/index.js +20 -0
  127. package/bin/cjs/types/index.js.map +1 -0
  128. package/bin/cjs/utils/index.d.ts +2 -0
  129. package/bin/cjs/utils/index.d.ts.map +1 -0
  130. package/bin/cjs/utils/index.js +18 -0
  131. package/bin/cjs/utils/index.js.map +1 -0
  132. package/bin/cjs/utils/type-check.d.ts +15 -0
  133. package/bin/cjs/utils/type-check.d.ts.map +1 -0
  134. package/bin/cjs/utils/type-check.js +62 -0
  135. package/bin/cjs/utils/type-check.js.map +1 -0
  136. package/bin/esm/index.d.ts +7 -0
  137. package/bin/esm/index.d.ts.map +1 -0
  138. package/bin/esm/index.js +7 -0
  139. package/bin/esm/index.js.map +1 -0
  140. package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts +26 -0
  141. package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
  142. package/bin/esm/interfaces/LiveInterfaceExtensions.js +6 -0
  143. package/bin/esm/interfaces/LiveInterfaceExtensions.js.map +1 -0
  144. package/bin/esm/interfaces/index.d.ts +2 -0
  145. package/bin/esm/interfaces/index.d.ts.map +1 -0
  146. package/bin/esm/interfaces/index.js +2 -0
  147. package/bin/esm/interfaces/index.js.map +1 -0
  148. package/bin/esm/internal/errors.d.ts +41 -0
  149. package/bin/esm/internal/errors.d.ts.map +1 -0
  150. package/bin/esm/internal/errors.js +42 -0
  151. package/bin/esm/internal/errors.js.map +1 -0
  152. package/bin/esm/internal/index.d.ts +3 -0
  153. package/bin/esm/internal/index.d.ts.map +1 -0
  154. package/bin/esm/internal/index.js +3 -0
  155. package/bin/esm/internal/index.js.map +1 -0
  156. package/bin/esm/internal/type-guards.d.ts +11 -0
  157. package/bin/esm/internal/type-guards.d.ts.map +1 -0
  158. package/bin/esm/internal/type-guards.js +20 -0
  159. package/bin/esm/internal/type-guards.js.map +1 -0
  160. package/bin/esm/live-hooks/index.d.ts +8 -0
  161. package/bin/esm/live-hooks/index.d.ts.map +1 -0
  162. package/bin/esm/live-hooks/index.js +8 -0
  163. package/bin/esm/live-hooks/index.js.map +1 -0
  164. package/bin/esm/live-hooks/useLiveCanvas.d.ts +80 -0
  165. package/bin/esm/live-hooks/useLiveCanvas.d.ts.map +1 -0
  166. package/bin/esm/live-hooks/useLiveCanvas.js +238 -0
  167. package/bin/esm/live-hooks/useLiveCanvas.js.map +1 -0
  168. package/bin/esm/live-hooks/useLiveEvent.d.ts +59 -0
  169. package/bin/esm/live-hooks/useLiveEvent.d.ts.map +1 -0
  170. package/bin/esm/live-hooks/useLiveEvent.js +144 -0
  171. package/bin/esm/live-hooks/useLiveEvent.js.map +1 -0
  172. package/bin/esm/live-hooks/useLiveFollowMode.d.ts +163 -0
  173. package/bin/esm/live-hooks/useLiveFollowMode.d.ts.map +1 -0
  174. package/bin/esm/live-hooks/useLiveFollowMode.js +354 -0
  175. package/bin/esm/live-hooks/useLiveFollowMode.js.map +1 -0
  176. package/bin/esm/live-hooks/useLivePresence.d.ts +76 -0
  177. package/bin/esm/live-hooks/useLivePresence.d.ts.map +1 -0
  178. package/bin/esm/live-hooks/useLivePresence.js +164 -0
  179. package/bin/esm/live-hooks/useLivePresence.js.map +1 -0
  180. package/bin/esm/live-hooks/useLiveState.d.ts +66 -0
  181. package/bin/esm/live-hooks/useLiveState.d.ts.map +1 -0
  182. package/bin/esm/live-hooks/useLiveState.js +128 -0
  183. package/bin/esm/live-hooks/useLiveState.js.map +1 -0
  184. package/bin/esm/live-hooks/useLiveTimer.d.ts +80 -0
  185. package/bin/esm/live-hooks/useLiveTimer.d.ts.map +1 -0
  186. package/bin/esm/live-hooks/useLiveTimer.js +227 -0
  187. package/bin/esm/live-hooks/useLiveTimer.js.map +1 -0
  188. package/bin/esm/live-hooks/useMediaSynchronizer.d.ts +86 -0
  189. package/bin/esm/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
  190. package/bin/esm/live-hooks/useMediaSynchronizer.js +295 -0
  191. package/bin/esm/live-hooks/useMediaSynchronizer.js.map +1 -0
  192. package/bin/esm/providers/AzureProvider.d.ts +113 -0
  193. package/bin/esm/providers/AzureProvider.d.ts.map +1 -0
  194. package/bin/esm/providers/AzureProvider.js +119 -0
  195. package/bin/esm/providers/AzureProvider.js.map +1 -0
  196. package/bin/esm/providers/LiveShareProvider.d.ts +193 -0
  197. package/bin/esm/providers/LiveShareProvider.d.ts.map +1 -0
  198. package/bin/esm/providers/LiveShareProvider.js +197 -0
  199. package/bin/esm/providers/LiveShareProvider.js.map +1 -0
  200. package/bin/esm/providers/index.d.ts +3 -0
  201. package/bin/esm/providers/index.d.ts.map +1 -0
  202. package/bin/esm/providers/index.js +3 -0
  203. package/bin/esm/providers/index.js.map +1 -0
  204. package/bin/esm/shared-hooks/index.d.ts +7 -0
  205. package/bin/esm/shared-hooks/index.d.ts.map +1 -0
  206. package/bin/esm/shared-hooks/index.js +7 -0
  207. package/bin/esm/shared-hooks/index.js.map +1 -0
  208. package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts +3 -0
  209. package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
  210. package/bin/esm/shared-hooks/internals/tree-node-constants.js +3 -0
  211. package/bin/esm/shared-hooks/internals/tree-node-constants.js.map +1 -0
  212. package/bin/esm/shared-hooks/internals/tree-node-types.d.ts +10 -0
  213. package/bin/esm/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
  214. package/bin/esm/shared-hooks/internals/tree-node-types.js +18 -0
  215. package/bin/esm/shared-hooks/internals/tree-node-types.js.map +1 -0
  216. package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts +33 -0
  217. package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
  218. package/bin/esm/shared-hooks/internals/tree-node-utils.js +188 -0
  219. package/bin/esm/shared-hooks/internals/tree-node-utils.js.map +1 -0
  220. package/bin/esm/shared-hooks/useDynamicDDS.d.ts +23 -0
  221. package/bin/esm/shared-hooks/useDynamicDDS.d.ts.map +1 -0
  222. package/bin/esm/shared-hooks/useDynamicDDS.js +81 -0
  223. package/bin/esm/shared-hooks/useDynamicDDS.js.map +1 -0
  224. package/bin/esm/shared-hooks/useSharedMap.d.ts +25 -0
  225. package/bin/esm/shared-hooks/useSharedMap.d.ts.map +1 -0
  226. package/bin/esm/shared-hooks/useSharedMap.js +128 -0
  227. package/bin/esm/shared-hooks/useSharedMap.js.map +1 -0
  228. package/bin/esm/shared-hooks/useSharedState.d.ts +22 -0
  229. package/bin/esm/shared-hooks/useSharedState.d.ts.map +1 -0
  230. package/bin/esm/shared-hooks/useSharedState.js +74 -0
  231. package/bin/esm/shared-hooks/useSharedState.js.map +1 -0
  232. package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts +37 -0
  233. package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
  234. package/bin/esm/shared-hooks/useSharedStateRegistry.js +113 -0
  235. package/bin/esm/shared-hooks/useSharedStateRegistry.js.map +1 -0
  236. package/bin/esm/shared-hooks/useSharedTree.d.ts +57 -0
  237. package/bin/esm/shared-hooks/useSharedTree.d.ts.map +1 -0
  238. package/bin/esm/shared-hooks/useSharedTree.js +117 -0
  239. package/bin/esm/shared-hooks/useSharedTree.js.map +1 -0
  240. package/bin/esm/shared-hooks/useTreeNode.d.ts +96 -0
  241. package/bin/esm/shared-hooks/useTreeNode.d.ts.map +1 -0
  242. package/bin/esm/shared-hooks/useTreeNode.js +132 -0
  243. package/bin/esm/shared-hooks/useTreeNode.js.map +1 -0
  244. package/bin/esm/types/ActionTypes.d.ts +112 -0
  245. package/bin/esm/types/ActionTypes.d.ts.map +1 -0
  246. package/bin/esm/types/ActionTypes.js +6 -0
  247. package/bin/esm/types/ActionTypes.js.map +1 -0
  248. package/bin/esm/types/PropTypes.d.ts +56 -0
  249. package/bin/esm/types/PropTypes.d.ts.map +1 -0
  250. package/bin/esm/types/PropTypes.js +6 -0
  251. package/bin/esm/types/PropTypes.js.map +1 -0
  252. package/bin/esm/types/ResultTypes.d.ts +334 -0
  253. package/bin/esm/types/ResultTypes.d.ts.map +1 -0
  254. package/bin/esm/types/ResultTypes.js +6 -0
  255. package/bin/esm/types/ResultTypes.js.map +1 -0
  256. package/bin/esm/types/index.d.ts +4 -0
  257. package/bin/esm/types/index.d.ts.map +1 -0
  258. package/bin/esm/types/index.js +4 -0
  259. package/bin/esm/types/index.js.map +1 -0
  260. package/bin/esm/utils/index.d.ts +2 -0
  261. package/bin/esm/utils/index.d.ts.map +1 -0
  262. package/bin/esm/utils/index.js +2 -0
  263. package/bin/esm/utils/index.js.map +1 -0
  264. package/bin/esm/utils/type-check.d.ts +15 -0
  265. package/bin/esm/utils/type-check.d.ts.map +1 -0
  266. package/bin/esm/utils/type-check.js +54 -0
  267. package/bin/esm/utils/type-check.js.map +1 -0
  268. package/bin/live-hooks/useLiveCanvas.js +1 -1
  269. package/bin/live-hooks/useLiveCanvas.js.map +1 -1
  270. package/bin/live-hooks/useLiveState.d.ts.map +1 -1
  271. package/bin/live-hooks/useLiveState.js +6 -2
  272. package/bin/live-hooks/useLiveState.js.map +1 -1
  273. package/bin/live-hooks/useMediaSynchronizer.js +1 -1
  274. package/bin/live-hooks/useMediaSynchronizer.js.map +1 -1
  275. package/bin/providers/AzureProvider.js +2 -2
  276. package/bin/providers/AzureProvider.js.map +1 -1
  277. package/bin/providers/LiveShareProvider.js +3 -3
  278. package/bin/providers/LiveShareProvider.js.map +1 -1
  279. package/package.json +61 -47
  280. package/src/index.ts +6 -6
  281. package/src/interfaces/index.ts +1 -1
  282. package/src/internal/index.ts +2 -2
  283. package/src/internal/type-guards.ts +1 -1
  284. package/src/live-hooks/index.ts +7 -7
  285. package/src/live-hooks/useLiveCanvas.ts +154 -82
  286. package/src/live-hooks/useLiveEvent.ts +43 -7
  287. package/src/live-hooks/useLiveFollowMode.ts +149 -6
  288. package/src/live-hooks/useLivePresence.ts +80 -17
  289. package/src/live-hooks/useLiveState.ts +54 -6
  290. package/src/live-hooks/useLiveTimer.ts +59 -4
  291. package/src/live-hooks/useMediaSynchronizer.ts +71 -6
  292. package/src/providers/AzureProvider.tsx +21 -21
  293. package/src/providers/LiveShareProvider.tsx +115 -13
  294. package/src/providers/index.ts +2 -2
  295. package/src/shared-hooks/index.ts +6 -4
  296. package/src/shared-hooks/internals/tree-node-constants.ts +2 -0
  297. package/src/shared-hooks/internals/tree-node-types.ts +26 -0
  298. package/src/shared-hooks/internals/tree-node-utils.ts +269 -0
  299. package/src/shared-hooks/useDynamicDDS.ts +28 -17
  300. package/src/shared-hooks/useSharedMap.ts +42 -17
  301. package/src/shared-hooks/useSharedState.ts +6 -3
  302. package/src/shared-hooks/useSharedStateRegistry.ts +44 -22
  303. package/src/shared-hooks/useSharedTree.ts +144 -0
  304. package/src/shared-hooks/useTreeNode.ts +147 -0
  305. package/src/types/ActionTypes.ts +13 -9
  306. package/src/types/PropTypes.ts +57 -0
  307. package/src/types/ResultTypes.ts +71 -17
  308. package/src/types/index.ts +3 -3
  309. package/src/utils/index.ts +1 -1
  310. package/tsconfig.cjs.json +14 -0
  311. package/tsconfig.json +65 -70
  312. package/.nycrc.json +0 -10
  313. package/tsconfig.build.json +0 -6
@@ -5,20 +5,24 @@
5
5
 
6
6
  import {
7
7
  LivePresenceUser,
8
- PresenceState,
9
8
  LivePresence,
10
9
  UserMeetingRole,
11
10
  LiveDataObjectInitializeState,
11
+ LivePresenceData,
12
+ PresenceStatus,
12
13
  } from "@microsoft/live-share";
13
14
  import React from "react";
14
- import { IUseLivePresenceResults, OnUpdateLivePresenceAction } from "../types";
15
- import { useDynamicDDS } from "../shared-hooks";
16
- import { useFluidObjectsContext } from "../providers";
15
+ import {
16
+ IUseLivePresenceResults,
17
+ OnUpdateLivePresenceAction,
18
+ } from "../types/index.js";
19
+ import { useDynamicDDS } from "../shared-hooks/index.js";
20
+ import { useFluidObjectsContext } from "../providers/index.js";
17
21
  import {
18
22
  ActionContainerNotJoinedError,
19
23
  ActionLiveDataObjectInitializedError,
20
24
  ActionLiveDataObjectUndefinedError,
21
- } from "../internal";
25
+ } from "../internal/index.js";
22
26
 
23
27
  /**
24
28
  * React hook for using a Live Share `LivePresence`.
@@ -31,17 +35,66 @@ import {
31
35
  *
32
36
  * @template TData Optional typing for the custom user presence data object. Default is `object` type.
33
37
  * @param uniqueKey The unique key for `LivePresence`. If one does not yet exist, a new one will be created.
34
- * @param initialData Optional. Initial presence data object for the user. Can be value or a function to get the value.
35
- * @param initialPresenceState Optional. Initial status of the user's presence. Default is online.
38
+ * @param initialData Initial presence data object for the user. Can be value or a function to get the value.
36
39
  * @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
37
40
  * will be created, otherwise it will use the existing one. Default value is ":<dds-default>"
38
41
  * @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
39
42
  * to update the local user's presence and the `LivePresence` Fluid object.
43
+ *
44
+ * @example
45
+ ```jsx
46
+ import { useLivePresence } from "@microsoft/live-share-react";
47
+
48
+ // Define a unique key that differentiates this usage of `useLivePresence` from others in your app
49
+ const MY_UNIQUE_KEY = "presence-key";
50
+
51
+ // Example component for using useLivePresence
52
+ export const MyCustomPresence = () => {
53
+ const {
54
+ allUsers,
55
+ localUser,
56
+ livePresence,
57
+ updatePresence,
58
+ } = useLivePresence(MY_UNIQUE_KEY, {
59
+ picture: "DEFAULT_PROFILE_PICTURE_URL",
60
+ readyToStart: false,
61
+ });
62
+
63
+ // Callback to update the user's presence
64
+ const onToggleReady = () => {
65
+ updatePresence({
66
+ ...localUser.data,
67
+ readyToStart: !localUser.data.readyToStart,
68
+ });
69
+ }
70
+
71
+ // Render loading UI while loading LivePresence for first time
72
+ if (!livePresence) return <>Loading...</>;
73
+
74
+ // Render presence UI
75
+ return (
76
+ {allUsers.map((user) => (
77
+ <div key={user.userId}>
78
+ <div>
79
+ {user.displayName}
80
+ </div>
81
+ <div>
82
+ {`Ready: ${user.data.readyToStart}`}
83
+ </div>
84
+ {user.isLocalUser && (
85
+ <button onClick={onToggleReady}>
86
+ {"Toggle ready"}
87
+ </button>
88
+ )}
89
+ </div>
90
+ ))}
91
+ );
92
+ }
93
+ ```
40
94
  */
41
- export function useLivePresence<TData extends object = object>(
95
+ export function useLivePresence<TData extends LivePresenceData = any>(
42
96
  uniqueKey: string,
43
- initialData?: TData | (() => TData) | undefined,
44
- initialPresenceState: PresenceState = PresenceState.online,
97
+ initialData: TData | (() => TData),
45
98
  allowedRoles?: UserMeetingRole[]
46
99
  ): IUseLivePresenceResults<TData> {
47
100
  /**
@@ -55,18 +108,26 @@ export function useLivePresence<TData extends object = object>(
55
108
  */
56
109
  const { dds: livePresence } = useDynamicDDS<LivePresence<TData>>(
57
110
  uniqueKey,
58
- LivePresence<TData>
111
+ LivePresence
59
112
  );
60
113
 
61
114
  /**
62
115
  * User facing: list of non-local user's presence objects.
63
116
  */
64
- const otherUsers = allUsers.filter((user) => !user.isLocalUser);
117
+ const otherUsers = React.useMemo(() => {
118
+ return allUsers.filter((user) => !user.isLocalUser);
119
+ }, [allUsers]);
65
120
 
66
121
  /**
67
122
  * User facing: local user's presence object.
68
123
  */
69
- const localUser = allUsers.find((user) => user.isLocalUser);
124
+ const localUser = React.useMemo(() => {
125
+ return allUsers.find((user) => user.isLocalUser);
126
+ }, [allUsers]);
127
+
128
+ const onlineUsers = React.useMemo(() => {
129
+ return allUsers.filter((user) => user.status === PresenceStatus.online);
130
+ }, [allUsers]);
70
131
 
71
132
  const { container } = useFluidObjectsContext();
72
133
 
@@ -74,7 +135,7 @@ export function useLivePresence<TData extends object = object>(
74
135
  * User facing: callback to update the local user's presence.
75
136
  */
76
137
  const updatePresence: OnUpdateLivePresenceAction<TData> = React.useCallback(
77
- async (data?: TData | undefined, state?: PresenceState | undefined) => {
138
+ async (data: TData) => {
78
139
  if (!container) {
79
140
  throw new ActionContainerNotJoinedError(
80
141
  "livePresence",
@@ -93,7 +154,7 @@ export function useLivePresence<TData extends object = object>(
93
154
  "updatePresence"
94
155
  );
95
156
  }
96
- return await livePresence.update(data, state);
157
+ return await livePresence.update(data);
97
158
  },
98
159
  [container, livePresence]
99
160
  );
@@ -121,7 +182,6 @@ export function useLivePresence<TData extends object = object>(
121
182
  isInitialDataCallback<TData>(initialData)
122
183
  ? initialData()
123
184
  : initialData,
124
- initialPresenceState,
125
185
  allowedRoles
126
186
  );
127
187
  }
@@ -136,11 +196,14 @@ export function useLivePresence<TData extends object = object>(
136
196
  localUser,
137
197
  otherUsers,
138
198
  allUsers,
199
+ onlineUsers,
139
200
  livePresence,
140
201
  updatePresence,
141
202
  };
142
203
  }
143
204
 
144
- function isInitialDataCallback<TData>(value: any): value is () => TData {
205
+ function isInitialDataCallback<TData extends LivePresenceData>(
206
+ value: any
207
+ ): value is () => TData {
145
208
  return typeof value === "function";
146
209
  }
@@ -9,15 +9,15 @@ import {
9
9
  UserMeetingRole,
10
10
  } from "@microsoft/live-share";
11
11
  import React from "react";
12
- import { SetLiveStateAction } from "../types";
13
- import { useDynamicDDS } from "../shared-hooks";
14
- import { useFluidObjectsContext } from "../providers";
12
+ import { SetLiveStateAction } from "../types/index.js";
13
+ import { useDynamicDDS } from "../shared-hooks/index.js";
14
+ import { useFluidObjectsContext } from "../providers/index.js";
15
15
  import {
16
16
  ActionContainerNotJoinedError,
17
17
  ActionLiveDataObjectInitializedError,
18
18
  ActionLiveDataObjectUndefinedError,
19
19
  isPrevStateCallback,
20
- } from "../internal";
20
+ } from "../internal/index.js";
21
21
 
22
22
  /**
23
23
  * React hook for using a Live Share `LiveState`.
@@ -31,6 +31,51 @@ import {
31
31
  * @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
32
32
  * @returns ordered values: first value is the synchronized state value and the second is a setter to change the state value.
33
33
  * The setter returns a void promise, which will throw if the user does not have the required roles to set.
34
+ *
35
+ * @example
36
+ ```jsx
37
+ import { useLiveState } from "@microsoft/live-share-react";
38
+
39
+ const planets = [
40
+ "Mercury",
41
+ "Venus",
42
+ "Earth",
43
+ "Mars",
44
+ "Jupiter",
45
+ "Saturn",
46
+ "Uranus",
47
+ "Neptune",
48
+ ];
49
+
50
+ // Define a unique key that differentiates this usage of `useLiveState` from others in your app
51
+ const MY_UNIQUE_KEY = "selected-planet-key";
52
+
53
+ // Example component for using useLiveState
54
+ export const MyCustomState = () => {
55
+ const [planet, setPlanet, liveState] = useLiveState(MY_UNIQUE_KEY, planets[0]);
56
+
57
+ // Render loading UI when creating LiveState instance for first time
58
+ if (!liveState) return <>Loading...</>;
59
+
60
+ // Render UI
61
+ return (
62
+ <div>
63
+ {`Current planet: ${planet}`}
64
+ {"Select a planet below:"}
65
+ {planets.map((planet) => (
66
+ <button
67
+ key={planet}
68
+ onClick={() => {
69
+ setPlanet(planet);
70
+ }}
71
+ >
72
+ {planet}
73
+ </button>
74
+ ))}
75
+ </div>
76
+ );
77
+ };
78
+ ```
34
79
  */
35
80
  export function useLiveState<TState = any>(
36
81
  uniqueKey: string,
@@ -95,9 +140,12 @@ export function useLiveState<TState = any>(
95
140
  if (
96
141
  liveState.initializeState === LiveDataObjectInitializeState.needed
97
142
  ) {
98
- liveState.initialize(initialState, allowedRoles);
143
+ liveState
144
+ .initialize(initialState, allowedRoles)
145
+ .then(() => onStateChanged(liveState.state));
146
+ } else {
147
+ onStateChanged(liveState.state);
99
148
  }
100
- onStateChanged(liveState.state);
101
149
 
102
150
  return () => {
103
151
  liveState?.off("stateChanged", onStateChanged);
@@ -21,14 +21,14 @@ import {
21
21
  OnTimerDidPlayAction,
22
22
  OnTimerDidStartAction,
23
23
  OnTimerTickAction,
24
- } from "../types";
25
- import { useDynamicDDS } from "../shared-hooks";
26
- import { useFluidObjectsContext } from "../providers";
24
+ } from "../types/index.js";
25
+ import { useDynamicDDS } from "../shared-hooks/index.js";
26
+ import { useFluidObjectsContext } from "../providers/index.js";
27
27
  import {
28
28
  ActionContainerNotJoinedError,
29
29
  ActionLiveDataObjectInitializedError,
30
30
  ActionLiveDataObjectUndefinedError,
31
- } from "../internal";
31
+ } from "../internal/index.js";
32
32
 
33
33
  /**
34
34
  * React hook for using Live Share's `LiveTimer` DDS.
@@ -46,6 +46,61 @@ import {
46
46
  * @param onPlay Optional. event handler callback for when the timer is resumed.
47
47
  * @param onFinish Optional. event handler callback for when the timer finishes.
48
48
  * @returns results and callbacks exposed via the hook.
49
+ *
50
+ * @example
51
+ ```jsx
52
+ import { useLiveTimer } from "@microsoft/live-share-react";
53
+
54
+ // Define a unique key that differentiates this usage of `useLiveTimer` from others in your app
55
+ const MY_UNIQUE_KEY = "timer-key";
56
+
57
+ // Example component for using useLiveTimer
58
+ export function CountdownTimer() {
59
+ const {
60
+ milliRemaining,
61
+ timerConfig,
62
+ liveTimer,
63
+ start,
64
+ pause,
65
+ play,
66
+ } = useLiveTimer("TIMER-ID");
67
+
68
+ // Render loading UI when creating LiveTimer instance for first time
69
+ if (!liveTimer) return <>Loading...</>;
70
+
71
+ return (
72
+ <div>
73
+ <button
74
+ onClick={() => {
75
+ start(60 * 1000);
76
+ }}
77
+ >
78
+ {timerConfig === undefined ? "Start" : "Reset"}
79
+ </button>
80
+ {timerConfig !== undefined && (
81
+ <button
82
+ onClick={() => {
83
+ if (timerConfig.running) {
84
+ pause();
85
+ } else {
86
+ play();
87
+ }
88
+ }}
89
+ >
90
+ {timerConfig.running ? "Pause" : "Play"}
91
+ </button>
92
+ )}
93
+ {milliRemaining !== undefined && (
94
+ <p>
95
+ {`${Math.round(milliRemaining / 1000)} / ${
96
+ Math.round(timerConfig.duration) / 1000
97
+ }`}
98
+ </p>
99
+ )}
100
+ </div>
101
+ );
102
+ }
103
+ ```
49
104
  */
50
105
  export function useLiveTimer(
51
106
  uniqueKey: string,
@@ -16,14 +16,18 @@ import {
16
16
  MediaPlayerSynchronizer,
17
17
  MediaSessionCoordinatorSuspension,
18
18
  } from "@microsoft/live-share-media";
19
- import { isExtendedMediaMetadata, isMediaElement, isRefObject } from "../utils";
20
- import { useDynamicDDS } from "../shared-hooks";
21
- import { IUseMediaSynchronizerResults } from "../types";
22
- import { useFluidObjectsContext } from "../providers";
19
+ import {
20
+ isExtendedMediaMetadata,
21
+ isMediaElement,
22
+ isRefObject,
23
+ } from "../utils/index.js";
24
+ import { useDynamicDDS } from "../shared-hooks/index.js";
25
+ import { IUseMediaSynchronizerResults } from "../types/index.js";
26
+ import { useFluidObjectsContext } from "../providers/index.js";
23
27
  import {
24
28
  ActionContainerNotJoinedError,
25
29
  ActionLiveDataObjectUndefinedError,
26
- } from "../internal";
30
+ } from "../internal/index.js";
27
31
 
28
32
  /**
29
33
  * React hook for using a Live Share media `MediaPlayerSynchronizer`.
@@ -39,6 +43,67 @@ import {
39
43
  * @param viewOnly Optional. Flag for whether or not the media synchronizer should be in viewOnly mode.
40
44
  * @param canSendPositionUpdates Optional. Controls whether or not the local client is allowed to send position updates to the group.
41
45
  * @returns IUseMediaSynchronizerResults object.
46
+ *
47
+ * @example
48
+ ```jsx
49
+ import { useMediaSynchronizer } from "@microsoft/live-share-react";
50
+ import { UserMeetingRole } from "@microsoft/live-share";
51
+ import { MediaPlayerSynchronizerEvents } from "@microsoft/live-share-media";
52
+ import { useRef, useEffect } from "react";
53
+
54
+ const ALLOWED_ROLES = [UserMeetingRole.organizer, UserMeetingRole.presenter];
55
+
56
+ const INITIAL_TRACK = "<YOUR_VIDEO_URL>";
57
+
58
+ // Define a unique key that distinguishes this `useMediaSynchronizer` from others in your app
59
+ const UNIQUE_KEY = "MEDIA-SESSION-ID";
60
+
61
+ export function VideoPlayer() {
62
+ const videoRef = useRef(null);
63
+ const { play, pause, seekTo, mediaSynchronizer } = useMediaSynchronizer(
64
+ UNIQUE_KEY,
65
+ videoRef,
66
+ INITIAL_TRACK,
67
+ ALLOWED_ROLES
68
+ );
69
+
70
+ // Listen for groupaction events (optional)
71
+ useEffect(() => {
72
+ // Listen for player group actions for errors (e.g., play error)
73
+ const onGroupAction = (evt: IMediaPlayerSynchronizerEvent) => {
74
+ // See which user made the change (e.g., to display a notification)
75
+ const clientInfo = await synchronizer.mediaSession.getClientInfo(evt.details.clientId);
76
+ };
77
+ mediaSynchronizer?.addEventListener(
78
+ MediaPlayerSynchronizerEvents.groupaction,
79
+ onGroupAction
80
+ );
81
+ return () => {
82
+ mediaSynchronizer?.removeEventListener(
83
+ MediaPlayerSynchronizerEvents.groupaction,
84
+ onGroupAction
85
+ );
86
+ };
87
+ }, [mediaSynchronizer]);
88
+
89
+ return (
90
+ <div>
91
+ <video ref={videoRef} />
92
+ <button onClick={play}>
93
+ Play
94
+ </button>
95
+ <button onClick={pause}>
96
+ Pause
97
+ </button>
98
+ <button onClick={() => {
99
+ seekTo(0);
100
+ }}>
101
+ Start over
102
+ </button>
103
+ </div>
104
+ );
105
+ }
106
+ ```
42
107
  */
43
108
  export function useMediaSynchronizer(
44
109
  uniqueKey: string,
@@ -250,7 +315,7 @@ export function useMediaSynchronizer(
250
315
  synchronizer.removeAllListeners();
251
316
  mediaSession.removeAllListeners();
252
317
  synchronizer?.end();
253
- // mediaSession?.dispose();
318
+ mediaSession?.dispose();
254
319
  };
255
320
  }, [mediaSession, mediaPlayerElement]);
256
321
 
@@ -3,21 +3,19 @@
3
3
  * Licensed under the Microsoft Live Share SDK License.
4
4
  */
5
5
 
6
- import { IFluidContainer, LoadableObjectClassRecord } from "fluid-framework";
6
+ import { ContainerSchema, IFluidContainer } from "fluid-framework";
7
7
  import React from "react";
8
8
  import {
9
9
  AzureClientProps,
10
10
  AzureContainerServices,
11
11
  } from "@fluidframework/azure-client";
12
- import { IAzureContainerResults } from "../types";
12
+ import { IAzureContainerResults } from "../types/index.js";
13
13
  import {
14
14
  ISharedStateRegistryResponse,
15
15
  useSharedStateRegistry,
16
- } from "../shared-hooks";
17
- import {
18
- AzureTurboClient,
19
- IFluidTurboClient,
20
- } from "@microsoft/live-share-turbo";
16
+ } from "../shared-hooks/index.js";
17
+ import { AzureLiveShareClient } from "@microsoft/live-share";
18
+ import { BaseLiveShareClient } from "@microsoft/live-share/internal";
21
19
 
22
20
  /**
23
21
  * React Context provider values for `<AzureProvider>` and `<LiveShareProvider>`.
@@ -29,7 +27,7 @@ export interface IFluidContext extends ISharedStateRegistryResponse {
29
27
  /**
30
28
  * The Fluid Turbo client used for connecting to the Fluid container.
31
29
  */
32
- clientRef: React.MutableRefObject<IFluidTurboClient>;
30
+ clientRef: React.MutableRefObject<BaseLiveShareClient>;
33
31
  /**
34
32
  * Stateful Fluid container.
35
33
  */
@@ -54,7 +52,7 @@ export interface IFluidContext extends ISharedStateRegistryResponse {
54
52
  */
55
53
  getContainer: (
56
54
  containerId: string,
57
- initialObjects?: LoadableObjectClassRecord
55
+ fluidContainerSchema?: ContainerSchema
58
56
  ) => Promise<IAzureContainerResults>;
59
57
  /**
60
58
  * React callback function to create and connect to a new Fluid container.
@@ -67,7 +65,7 @@ export interface IFluidContext extends ISharedStateRegistryResponse {
67
65
  * @returns promise that returns a results object once complete (e.g., container, services, etc.)
68
66
  */
69
67
  createContainer: (
70
- initialObjects?: LoadableObjectClassRecord,
68
+ fluidContainerSchema?: ContainerSchema,
71
69
  onInitializeContainer?: (container: IFluidContainer) => void
72
70
  ) => Promise<IAzureContainerResults>;
73
71
  }
@@ -125,9 +123,9 @@ export interface IAzureProviderProps {
125
123
  */
126
124
  createOnLoad?: boolean;
127
125
  /**
128
- * The initial object schema to use when {@link joinOnLoad} or {@link createOnLoad} is true.
126
+ * The initial schema to use when {@link joinOnLoad} or {@link createOnLoad} is true.
129
127
  */
130
- initialObjects?: LoadableObjectClassRecord;
128
+ fluidContainerSchema?: ContainerSchema;
131
129
  /**
132
130
  * Flag to control whether or not to connect to an existing container on first mount.
133
131
  *
@@ -142,8 +140,8 @@ export interface IAzureProviderProps {
142
140
  */
143
141
  export const AzureProvider: React.FC<IAzureProviderProps> = (props) => {
144
142
  const startedRef = React.useRef<boolean>(false);
145
- const clientRef = React.useRef<AzureTurboClient>(
146
- new AzureTurboClient(props.clientOptions)
143
+ const clientRef = React.useRef<AzureLiveShareClient>(
144
+ new AzureLiveShareClient(props.clientOptions)
147
145
  );
148
146
  const [results, setResults] = React.useState<
149
147
  IAzureContainerResults | undefined
@@ -158,14 +156,14 @@ export const AzureProvider: React.FC<IAzureProviderProps> = (props) => {
158
156
  const getContainer = React.useCallback(
159
157
  async (
160
158
  containerId: string,
161
- initialObjects?: LoadableObjectClassRecord
159
+ fluidContainerSchema?: ContainerSchema
162
160
  ): Promise<IAzureContainerResults> => {
163
161
  return new Promise(async (resolve, reject) => {
164
162
  try {
165
163
  const results: IAzureContainerResults =
166
164
  await clientRef.current.getContainer(
167
165
  containerId,
168
- initialObjects
166
+ fluidContainerSchema
169
167
  );
170
168
  setResults(results);
171
169
  resolve(results);
@@ -185,13 +183,15 @@ export const AzureProvider: React.FC<IAzureProviderProps> = (props) => {
185
183
  */
186
184
  const createContainer = React.useCallback(
187
185
  async (
188
- initialObjects?: LoadableObjectClassRecord,
186
+ fluidContainerSchema?: ContainerSchema,
189
187
  onInitializeContainer?: (container: IFluidContainer) => void
190
188
  ): Promise<IAzureContainerResults> => {
191
189
  return new Promise(async (resolve, reject) => {
192
190
  try {
193
191
  const results: IAzureContainerResults =
194
- await clientRef.current.createContainer(initialObjects);
192
+ await clientRef.current.createContainer(
193
+ fluidContainerSchema
194
+ );
195
195
  if (onInitializeContainer) {
196
196
  onInitializeContainer(results.container);
197
197
  }
@@ -225,16 +225,16 @@ export const AzureProvider: React.FC<IAzureProviderProps> = (props) => {
225
225
  return;
226
226
  startedRef.current = true;
227
227
  if (props.containerId && props.joinOnLoad) {
228
- getContainer(props.containerId, props.initialObjects);
228
+ getContainer(props.containerId, props.fluidContainerSchema);
229
229
  } else if (!props.containerId && props.createOnLoad) {
230
- createContainer(props.initialObjects);
230
+ createContainer(props.fluidContainerSchema);
231
231
  }
232
232
  }, [
233
233
  results?.container?.connectionState,
234
234
  props.containerId,
235
235
  props.createOnLoad,
236
236
  props.joinOnLoad,
237
- props.initialObjects,
237
+ props.fluidContainerSchema,
238
238
  getContainer,
239
239
  createContainer,
240
240
  ]);