@microsoft/live-share-react 2.0.0-internal.5 → 2.0.0-internal.6

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 (380) hide show
  1. package/.nycrc.json +9 -9
  2. package/LICENSE +64 -61
  3. package/README.md +173 -168
  4. package/bin/cjs/index.d.ts +7 -0
  5. package/bin/cjs/index.d.ts.map +1 -0
  6. package/bin/cjs/index.js +23 -0
  7. package/bin/cjs/index.js.map +1 -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.map +1 -0
  16. package/bin/cjs/internal/errors.js +48 -0
  17. package/bin/cjs/internal/errors.js.map +1 -0
  18. package/bin/cjs/internal/index.d.ts +3 -0
  19. package/bin/cjs/internal/index.d.ts.map +1 -0
  20. package/bin/cjs/internal/index.js +19 -0
  21. package/bin/cjs/internal/index.js.map +1 -0
  22. package/bin/{internal → cjs/internal}/type-guards.d.ts +1 -1
  23. package/bin/cjs/internal/type-guards.d.ts.map +1 -0
  24. package/bin/cjs/internal/type-guards.js +24 -0
  25. package/bin/cjs/internal/type-guards.js.map +1 -0
  26. package/bin/cjs/live-hooks/index.d.ts +8 -0
  27. package/bin/cjs/live-hooks/index.d.ts.map +1 -0
  28. package/bin/cjs/live-hooks/index.js +24 -0
  29. package/bin/cjs/live-hooks/index.js.map +1 -0
  30. package/bin/cjs/live-hooks/useLiveCanvas.d.ts +80 -0
  31. package/bin/cjs/live-hooks/useLiveCanvas.d.ts.map +1 -0
  32. package/bin/cjs/live-hooks/useLiveCanvas.js +244 -0
  33. package/bin/cjs/live-hooks/useLiveCanvas.js.map +1 -0
  34. package/bin/{live-hooks → cjs/live-hooks}/useLiveEvent.d.ts +37 -1
  35. package/bin/cjs/live-hooks/useLiveEvent.d.ts.map +1 -0
  36. package/bin/cjs/live-hooks/useLiveEvent.js +150 -0
  37. package/bin/cjs/live-hooks/useLiveEvent.js.map +1 -0
  38. package/bin/cjs/live-hooks/useLiveFollowMode.d.ts +163 -0
  39. package/bin/cjs/live-hooks/useLiveFollowMode.d.ts.map +1 -0
  40. package/bin/cjs/live-hooks/useLiveFollowMode.js +360 -0
  41. package/bin/cjs/live-hooks/useLiveFollowMode.js.map +1 -0
  42. package/bin/cjs/live-hooks/useLivePresence.d.ts +76 -0
  43. package/bin/cjs/live-hooks/useLivePresence.d.ts.map +1 -0
  44. package/bin/cjs/live-hooks/useLivePresence.js +166 -0
  45. package/bin/cjs/live-hooks/useLivePresence.js.map +1 -0
  46. package/bin/{live-hooks → cjs/live-hooks}/useLiveState.d.ts +46 -1
  47. package/bin/cjs/live-hooks/useLiveState.d.ts.map +1 -0
  48. package/bin/cjs/live-hooks/useLiveState.js +130 -0
  49. package/bin/cjs/live-hooks/useLiveState.js.map +1 -0
  50. package/bin/{live-hooks → cjs/live-hooks}/useLiveTimer.d.ts +56 -1
  51. package/bin/cjs/live-hooks/useLiveTimer.d.ts.map +1 -0
  52. package/bin/cjs/live-hooks/useLiveTimer.js +233 -0
  53. package/bin/cjs/live-hooks/useLiveTimer.js.map +1 -0
  54. package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts +86 -0
  55. package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
  56. package/bin/cjs/live-hooks/useMediaSynchronizer.js +301 -0
  57. package/bin/cjs/live-hooks/useMediaSynchronizer.js.map +1 -0
  58. package/bin/cjs/package.json +1 -0
  59. package/bin/{providers → cjs/providers}/AzureProvider.d.ts +9 -9
  60. package/bin/cjs/providers/AzureProvider.d.ts.map +1 -0
  61. package/bin/cjs/providers/AzureProvider.js +127 -0
  62. package/bin/cjs/providers/AzureProvider.js.map +1 -0
  63. package/bin/{providers → cjs/providers}/LiveShareProvider.d.ts +106 -4
  64. package/bin/cjs/providers/LiveShareProvider.d.ts.map +1 -0
  65. package/bin/cjs/providers/LiveShareProvider.js +205 -0
  66. package/bin/cjs/providers/LiveShareProvider.js.map +1 -0
  67. package/bin/cjs/providers/index.d.ts +3 -0
  68. package/bin/cjs/providers/index.d.ts.map +1 -0
  69. package/bin/cjs/providers/index.js +19 -0
  70. package/bin/cjs/providers/index.js.map +1 -0
  71. package/bin/cjs/shared-hooks/index.d.ts +7 -0
  72. package/bin/cjs/shared-hooks/index.d.ts.map +1 -0
  73. package/bin/cjs/shared-hooks/index.js +23 -0
  74. package/bin/cjs/shared-hooks/index.js.map +1 -0
  75. package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts +3 -0
  76. package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
  77. package/bin/cjs/shared-hooks/internals/tree-node-constants.js +6 -0
  78. package/bin/cjs/shared-hooks/internals/tree-node-constants.js.map +1 -0
  79. package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts +10 -0
  80. package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
  81. package/bin/cjs/shared-hooks/internals/tree-node-types.js +23 -0
  82. package/bin/cjs/shared-hooks/internals/tree-node-types.js.map +1 -0
  83. package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts +33 -0
  84. package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
  85. package/bin/cjs/shared-hooks/internals/tree-node-utils.js +193 -0
  86. package/bin/cjs/shared-hooks/internals/tree-node-utils.js.map +1 -0
  87. package/bin/{shared-hooks → cjs/shared-hooks}/useDynamicDDS.d.ts +4 -4
  88. package/bin/cjs/shared-hooks/useDynamicDDS.d.ts.map +1 -0
  89. package/bin/cjs/shared-hooks/useDynamicDDS.js +87 -0
  90. package/bin/cjs/shared-hooks/useDynamicDDS.js.map +1 -0
  91. package/bin/{shared-hooks → cjs/shared-hooks}/useSharedMap.d.ts +4 -2
  92. package/bin/cjs/shared-hooks/useSharedMap.d.ts.map +1 -0
  93. package/bin/cjs/shared-hooks/useSharedMap.js +134 -0
  94. package/bin/cjs/shared-hooks/useSharedMap.js.map +1 -0
  95. package/bin/{shared-hooks → cjs/shared-hooks}/useSharedState.d.ts +1 -1
  96. package/bin/cjs/shared-hooks/useSharedState.d.ts.map +1 -0
  97. package/bin/cjs/shared-hooks/useSharedState.js +80 -0
  98. package/bin/cjs/shared-hooks/useSharedState.js.map +1 -0
  99. package/bin/{shared-hooks → cjs/shared-hooks}/useSharedStateRegistry.d.ts +1 -1
  100. package/bin/cjs/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
  101. package/bin/cjs/shared-hooks/useSharedStateRegistry.js +120 -0
  102. package/bin/cjs/shared-hooks/useSharedStateRegistry.js.map +1 -0
  103. package/bin/cjs/shared-hooks/useSharedTree.d.ts +57 -0
  104. package/bin/cjs/shared-hooks/useSharedTree.d.ts.map +1 -0
  105. package/bin/cjs/shared-hooks/useSharedTree.js +123 -0
  106. package/bin/cjs/shared-hooks/useSharedTree.js.map +1 -0
  107. package/bin/cjs/shared-hooks/useTreeNode.d.ts +96 -0
  108. package/bin/cjs/shared-hooks/useTreeNode.d.ts.map +1 -0
  109. package/bin/cjs/shared-hooks/useTreeNode.js +135 -0
  110. package/bin/cjs/shared-hooks/useTreeNode.js.map +1 -0
  111. package/bin/{types → cjs/types}/ActionTypes.d.ts +7 -7
  112. package/bin/cjs/types/ActionTypes.d.ts.map +1 -0
  113. package/bin/cjs/types/ActionTypes.js +7 -0
  114. package/bin/cjs/types/ActionTypes.js.map +1 -0
  115. package/bin/cjs/types/PropTypes.d.ts +56 -0
  116. package/bin/cjs/types/PropTypes.d.ts.map +1 -0
  117. package/bin/cjs/types/PropTypes.js +7 -0
  118. package/bin/cjs/types/PropTypes.js.map +1 -0
  119. package/bin/{types → cjs/types}/ResultTypes.d.ts +46 -18
  120. package/bin/cjs/types/ResultTypes.d.ts.map +1 -0
  121. package/bin/cjs/types/ResultTypes.js +7 -0
  122. package/bin/cjs/types/ResultTypes.js.map +1 -0
  123. package/bin/cjs/types/index.d.ts +4 -0
  124. package/bin/cjs/types/index.d.ts.map +1 -0
  125. package/bin/cjs/types/index.js +20 -0
  126. package/bin/cjs/types/index.js.map +1 -0
  127. package/bin/cjs/utils/index.d.ts +2 -0
  128. package/bin/cjs/utils/index.d.ts.map +1 -0
  129. package/bin/cjs/utils/index.js +18 -0
  130. package/bin/cjs/utils/index.js.map +1 -0
  131. package/bin/cjs/utils/type-check.d.ts.map +1 -0
  132. package/bin/cjs/utils/type-check.js +62 -0
  133. package/bin/cjs/utils/type-check.js.map +1 -0
  134. package/bin/esm/index.d.ts +7 -0
  135. package/bin/esm/index.d.ts.map +1 -0
  136. package/bin/esm/index.js +7 -0
  137. package/bin/esm/index.js.map +1 -0
  138. package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts +26 -0
  139. package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
  140. package/bin/esm/interfaces/LiveInterfaceExtensions.js.map +1 -0
  141. package/bin/esm/interfaces/index.d.ts +2 -0
  142. package/bin/esm/interfaces/index.d.ts.map +1 -0
  143. package/bin/esm/interfaces/index.js +2 -0
  144. package/bin/esm/interfaces/index.js.map +1 -0
  145. package/bin/esm/internal/errors.d.ts +41 -0
  146. package/bin/esm/internal/errors.d.ts.map +1 -0
  147. package/bin/esm/internal/errors.js.map +1 -0
  148. package/bin/esm/internal/index.d.ts +3 -0
  149. package/bin/esm/internal/index.d.ts.map +1 -0
  150. package/bin/esm/internal/index.js +3 -0
  151. package/bin/esm/internal/index.js.map +1 -0
  152. package/bin/esm/internal/type-guards.d.ts +11 -0
  153. package/bin/esm/internal/type-guards.d.ts.map +1 -0
  154. package/bin/esm/internal/type-guards.js.map +1 -0
  155. package/bin/esm/live-hooks/index.d.ts +8 -0
  156. package/bin/esm/live-hooks/index.d.ts.map +1 -0
  157. package/bin/esm/live-hooks/index.js +8 -0
  158. package/bin/esm/live-hooks/index.js.map +1 -0
  159. package/bin/esm/live-hooks/useLiveCanvas.d.ts +80 -0
  160. package/bin/esm/live-hooks/useLiveCanvas.d.ts.map +1 -0
  161. package/bin/esm/live-hooks/useLiveCanvas.js +238 -0
  162. package/bin/esm/live-hooks/useLiveCanvas.js.map +1 -0
  163. package/bin/esm/live-hooks/useLiveEvent.d.ts +59 -0
  164. package/bin/esm/live-hooks/useLiveEvent.d.ts.map +1 -0
  165. package/bin/{live-hooks → esm/live-hooks}/useLiveEvent.js +41 -5
  166. package/bin/esm/live-hooks/useLiveEvent.js.map +1 -0
  167. package/bin/esm/live-hooks/useLiveFollowMode.d.ts +163 -0
  168. package/bin/esm/live-hooks/useLiveFollowMode.d.ts.map +1 -0
  169. package/bin/{live-hooks → esm/live-hooks}/useLiveFollowMode.js +148 -5
  170. package/bin/esm/live-hooks/useLiveFollowMode.js.map +1 -0
  171. package/bin/esm/live-hooks/useLivePresence.d.ts +76 -0
  172. package/bin/esm/live-hooks/useLivePresence.d.ts.map +1 -0
  173. package/bin/{live-hooks → esm/live-hooks}/useLivePresence.js +67 -13
  174. package/bin/esm/live-hooks/useLivePresence.js.map +1 -0
  175. package/bin/esm/live-hooks/useLiveState.d.ts +66 -0
  176. package/bin/esm/live-hooks/useLiveState.d.ts.map +1 -0
  177. package/bin/{live-hooks → esm/live-hooks}/useLiveState.js +48 -3
  178. package/bin/esm/live-hooks/useLiveState.js.map +1 -0
  179. package/bin/esm/live-hooks/useLiveTimer.d.ts +80 -0
  180. package/bin/esm/live-hooks/useLiveTimer.d.ts.map +1 -0
  181. package/bin/{live-hooks → esm/live-hooks}/useLiveTimer.js +58 -3
  182. package/bin/esm/live-hooks/useLiveTimer.js.map +1 -0
  183. package/bin/esm/live-hooks/useMediaSynchronizer.d.ts +86 -0
  184. package/bin/esm/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
  185. package/bin/{live-hooks → esm/live-hooks}/useMediaSynchronizer.js +65 -4
  186. package/bin/esm/live-hooks/useMediaSynchronizer.js.map +1 -0
  187. package/bin/esm/providers/AzureProvider.d.ts +113 -0
  188. package/bin/esm/providers/AzureProvider.d.ts.map +1 -0
  189. package/bin/{providers → esm/providers}/AzureProvider.js +10 -10
  190. package/bin/esm/providers/AzureProvider.js.map +1 -0
  191. package/bin/esm/providers/LiveShareProvider.d.ts +193 -0
  192. package/bin/esm/providers/LiveShareProvider.d.ts.map +1 -0
  193. package/bin/{providers → esm/providers}/LiveShareProvider.js +111 -9
  194. package/bin/esm/providers/LiveShareProvider.js.map +1 -0
  195. package/bin/esm/providers/index.d.ts +3 -0
  196. package/bin/esm/providers/index.d.ts.map +1 -0
  197. package/bin/esm/providers/index.js +3 -0
  198. package/bin/esm/providers/index.js.map +1 -0
  199. package/bin/esm/shared-hooks/index.d.ts +7 -0
  200. package/bin/esm/shared-hooks/index.d.ts.map +1 -0
  201. package/bin/esm/shared-hooks/index.js +7 -0
  202. package/bin/esm/shared-hooks/index.js.map +1 -0
  203. package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts +3 -0
  204. package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
  205. package/bin/esm/shared-hooks/internals/tree-node-constants.js +3 -0
  206. package/bin/esm/shared-hooks/internals/tree-node-constants.js.map +1 -0
  207. package/bin/esm/shared-hooks/internals/tree-node-types.d.ts +10 -0
  208. package/bin/esm/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
  209. package/bin/esm/shared-hooks/internals/tree-node-types.js +18 -0
  210. package/bin/esm/shared-hooks/internals/tree-node-types.js.map +1 -0
  211. package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts +33 -0
  212. package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
  213. package/bin/esm/shared-hooks/internals/tree-node-utils.js +188 -0
  214. package/bin/esm/shared-hooks/internals/tree-node-utils.js.map +1 -0
  215. package/bin/esm/shared-hooks/useDynamicDDS.d.ts +23 -0
  216. package/bin/esm/shared-hooks/useDynamicDDS.d.ts.map +1 -0
  217. package/bin/{shared-hooks → esm/shared-hooks}/useDynamicDDS.js +20 -11
  218. package/bin/esm/shared-hooks/useDynamicDDS.js.map +1 -0
  219. package/bin/esm/shared-hooks/useSharedMap.d.ts +25 -0
  220. package/bin/esm/shared-hooks/useSharedMap.d.ts.map +1 -0
  221. package/bin/{shared-hooks → esm/shared-hooks}/useSharedMap.js +27 -13
  222. package/bin/esm/shared-hooks/useSharedMap.js.map +1 -0
  223. package/bin/esm/shared-hooks/useSharedState.d.ts +22 -0
  224. package/bin/esm/shared-hooks/useSharedState.d.ts.map +1 -0
  225. package/bin/{shared-hooks → esm/shared-hooks}/useSharedState.js +2 -2
  226. package/bin/esm/shared-hooks/useSharedState.js.map +1 -0
  227. package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts +37 -0
  228. package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
  229. package/bin/{shared-hooks → esm/shared-hooks}/useSharedStateRegistry.js +27 -19
  230. package/bin/esm/shared-hooks/useSharedStateRegistry.js.map +1 -0
  231. package/bin/esm/shared-hooks/useSharedTree.d.ts +57 -0
  232. package/bin/esm/shared-hooks/useSharedTree.d.ts.map +1 -0
  233. package/bin/esm/shared-hooks/useSharedTree.js +117 -0
  234. package/bin/esm/shared-hooks/useSharedTree.js.map +1 -0
  235. package/bin/esm/shared-hooks/useTreeNode.d.ts +96 -0
  236. package/bin/esm/shared-hooks/useTreeNode.d.ts.map +1 -0
  237. package/bin/esm/shared-hooks/useTreeNode.js +132 -0
  238. package/bin/esm/shared-hooks/useTreeNode.js.map +1 -0
  239. package/bin/esm/types/ActionTypes.d.ts +112 -0
  240. package/bin/esm/types/ActionTypes.d.ts.map +1 -0
  241. package/bin/esm/types/ActionTypes.js.map +1 -0
  242. package/bin/esm/types/PropTypes.d.ts +56 -0
  243. package/bin/esm/types/PropTypes.d.ts.map +1 -0
  244. package/bin/esm/types/PropTypes.js.map +1 -0
  245. package/bin/esm/types/ResultTypes.d.ts +330 -0
  246. package/bin/esm/types/ResultTypes.d.ts.map +1 -0
  247. package/bin/esm/types/ResultTypes.js.map +1 -0
  248. package/bin/esm/types/index.d.ts +4 -0
  249. package/bin/esm/types/index.d.ts.map +1 -0
  250. package/bin/esm/types/index.js +4 -0
  251. package/bin/esm/types/index.js.map +1 -0
  252. package/bin/esm/utils/index.d.ts +2 -0
  253. package/bin/esm/utils/index.d.ts.map +1 -0
  254. package/bin/esm/utils/index.js +2 -0
  255. package/bin/esm/utils/index.js.map +1 -0
  256. package/bin/esm/utils/type-check.d.ts +15 -0
  257. package/bin/esm/utils/type-check.d.ts.map +1 -0
  258. package/bin/esm/utils/type-check.js.map +1 -0
  259. package/package.json +61 -47
  260. package/src/index.ts +6 -6
  261. package/src/interfaces/index.ts +1 -1
  262. package/src/internal/index.ts +2 -2
  263. package/src/internal/type-guards.ts +1 -1
  264. package/src/live-hooks/index.ts +7 -7
  265. package/src/live-hooks/useLiveCanvas.ts +154 -82
  266. package/src/live-hooks/useLiveEvent.ts +43 -7
  267. package/src/live-hooks/useLiveFollowMode.ts +149 -6
  268. package/src/live-hooks/useLivePresence.ts +74 -17
  269. package/src/live-hooks/useLiveState.ts +49 -4
  270. package/src/live-hooks/useLiveTimer.ts +59 -4
  271. package/src/live-hooks/useMediaSynchronizer.ts +70 -5
  272. package/src/providers/AzureProvider.tsx +21 -21
  273. package/src/providers/LiveShareProvider.tsx +115 -13
  274. package/src/providers/index.ts +2 -2
  275. package/src/shared-hooks/index.ts +6 -4
  276. package/src/shared-hooks/internals/tree-node-constants.ts +2 -0
  277. package/src/shared-hooks/internals/tree-node-types.ts +26 -0
  278. package/src/shared-hooks/internals/tree-node-utils.ts +269 -0
  279. package/src/shared-hooks/useDynamicDDS.ts +28 -17
  280. package/src/shared-hooks/useSharedMap.ts +42 -17
  281. package/src/shared-hooks/useSharedState.ts +6 -3
  282. package/src/shared-hooks/useSharedStateRegistry.ts +44 -22
  283. package/src/shared-hooks/useSharedTree.ts +144 -0
  284. package/src/shared-hooks/useTreeNode.ts +147 -0
  285. package/src/types/ActionTypes.ts +13 -9
  286. package/src/types/PropTypes.ts +57 -0
  287. package/src/types/ResultTypes.ts +67 -17
  288. package/src/types/index.ts +3 -3
  289. package/src/utils/index.ts +1 -1
  290. package/tsconfig.cjs.json +14 -0
  291. package/tsconfig.json +65 -70
  292. package/bin/index.d.ts +0 -7
  293. package/bin/index.d.ts.map +0 -1
  294. package/bin/index.js +0 -7
  295. package/bin/index.js.map +0 -1
  296. package/bin/interfaces/LiveInterfaceExtensions.d.ts.map +0 -1
  297. package/bin/interfaces/LiveInterfaceExtensions.js.map +0 -1
  298. package/bin/interfaces/index.d.ts +0 -2
  299. package/bin/interfaces/index.d.ts.map +0 -1
  300. package/bin/interfaces/index.js +0 -2
  301. package/bin/interfaces/index.js.map +0 -1
  302. package/bin/internal/errors.d.ts.map +0 -1
  303. package/bin/internal/errors.js.map +0 -1
  304. package/bin/internal/index.d.ts +0 -3
  305. package/bin/internal/index.d.ts.map +0 -1
  306. package/bin/internal/index.js +0 -3
  307. package/bin/internal/index.js.map +0 -1
  308. package/bin/internal/type-guards.d.ts.map +0 -1
  309. package/bin/internal/type-guards.js.map +0 -1
  310. package/bin/live-hooks/index.d.ts +0 -8
  311. package/bin/live-hooks/index.d.ts.map +0 -1
  312. package/bin/live-hooks/index.js +0 -8
  313. package/bin/live-hooks/index.js.map +0 -1
  314. package/bin/live-hooks/useLiveCanvas.d.ts +0 -29
  315. package/bin/live-hooks/useLiveCanvas.d.ts.map +0 -1
  316. package/bin/live-hooks/useLiveCanvas.js +0 -160
  317. package/bin/live-hooks/useLiveCanvas.js.map +0 -1
  318. package/bin/live-hooks/useLiveEvent.d.ts.map +0 -1
  319. package/bin/live-hooks/useLiveEvent.js.map +0 -1
  320. package/bin/live-hooks/useLiveFollowMode.d.ts +0 -24
  321. package/bin/live-hooks/useLiveFollowMode.d.ts.map +0 -1
  322. package/bin/live-hooks/useLiveFollowMode.js.map +0 -1
  323. package/bin/live-hooks/useLivePresence.d.ts +0 -26
  324. package/bin/live-hooks/useLivePresence.d.ts.map +0 -1
  325. package/bin/live-hooks/useLivePresence.js.map +0 -1
  326. package/bin/live-hooks/useLiveState.d.ts.map +0 -1
  327. package/bin/live-hooks/useLiveState.js.map +0 -1
  328. package/bin/live-hooks/useLiveTimer.d.ts.map +0 -1
  329. package/bin/live-hooks/useLiveTimer.js.map +0 -1
  330. package/bin/live-hooks/useMediaSynchronizer.d.ts +0 -25
  331. package/bin/live-hooks/useMediaSynchronizer.d.ts.map +0 -1
  332. package/bin/live-hooks/useMediaSynchronizer.js.map +0 -1
  333. package/bin/providers/AzureProvider.d.ts.map +0 -1
  334. package/bin/providers/AzureProvider.js.map +0 -1
  335. package/bin/providers/LiveShareProvider.d.ts.map +0 -1
  336. package/bin/providers/LiveShareProvider.js.map +0 -1
  337. package/bin/providers/index.d.ts +0 -3
  338. package/bin/providers/index.d.ts.map +0 -1
  339. package/bin/providers/index.js +0 -3
  340. package/bin/providers/index.js.map +0 -1
  341. package/bin/shared-hooks/index.d.ts +0 -5
  342. package/bin/shared-hooks/index.d.ts.map +0 -1
  343. package/bin/shared-hooks/index.js +0 -5
  344. package/bin/shared-hooks/index.js.map +0 -1
  345. package/bin/shared-hooks/useDynamicDDS.d.ts.map +0 -1
  346. package/bin/shared-hooks/useDynamicDDS.js.map +0 -1
  347. package/bin/shared-hooks/useSharedMap.d.ts.map +0 -1
  348. package/bin/shared-hooks/useSharedMap.js.map +0 -1
  349. package/bin/shared-hooks/useSharedState.d.ts.map +0 -1
  350. package/bin/shared-hooks/useSharedState.js.map +0 -1
  351. package/bin/shared-hooks/useSharedStateRegistry.d.ts.map +0 -1
  352. package/bin/shared-hooks/useSharedStateRegistry.js.map +0 -1
  353. package/bin/types/ActionTypes.d.ts.map +0 -1
  354. package/bin/types/ActionTypes.js.map +0 -1
  355. package/bin/types/PropTypes.d.ts +0 -8
  356. package/bin/types/PropTypes.d.ts.map +0 -1
  357. package/bin/types/PropTypes.js.map +0 -1
  358. package/bin/types/ResultTypes.d.ts.map +0 -1
  359. package/bin/types/ResultTypes.js.map +0 -1
  360. package/bin/types/index.d.ts +0 -4
  361. package/bin/types/index.d.ts.map +0 -1
  362. package/bin/types/index.js +0 -4
  363. package/bin/types/index.js.map +0 -1
  364. package/bin/utils/index.d.ts +0 -2
  365. package/bin/utils/index.d.ts.map +0 -1
  366. package/bin/utils/index.js +0 -2
  367. package/bin/utils/index.js.map +0 -1
  368. package/bin/utils/type-check.d.ts.map +0 -1
  369. package/bin/utils/type-check.js.map +0 -1
  370. package/tsconfig.build.json +0 -6
  371. /package/bin/{interfaces → cjs/interfaces}/LiveInterfaceExtensions.d.ts +0 -0
  372. /package/bin/{internal → cjs/internal}/errors.d.ts +0 -0
  373. /package/bin/{utils → cjs/utils}/type-check.d.ts +0 -0
  374. /package/bin/{interfaces → esm/interfaces}/LiveInterfaceExtensions.js +0 -0
  375. /package/bin/{internal → esm/internal}/errors.js +0 -0
  376. /package/bin/{internal → esm/internal}/type-guards.js +0 -0
  377. /package/bin/{types → esm/types}/ActionTypes.js +0 -0
  378. /package/bin/{types → esm/types}/PropTypes.js +0 -0
  379. /package/bin/{types → esm/types}/ResultTypes.js +0 -0
  380. /package/bin/{utils → esm/utils}/type-check.js +0 -0
@@ -12,14 +12,14 @@ import {
12
12
  IFollowModeState,
13
13
  } from "@microsoft/live-share";
14
14
  import React from "react";
15
- import { useDynamicDDS } from "../shared-hooks";
16
- import { useFluidObjectsContext } from "../providers";
15
+ import { useDynamicDDS } from "../shared-hooks/index.js";
16
+ import { useFluidObjectsContext } from "../providers/index.js";
17
17
  import {
18
18
  ActionContainerNotJoinedError,
19
19
  ActionLiveDataObjectInitializedError,
20
20
  ActionLiveDataObjectUndefinedError,
21
- } from "../internal";
22
- import { IUseLiveFollowModeResults } from "../types";
21
+ } from "../internal/index.js";
22
+ import { IUseLiveFollowModeResults } from "../types/index.js";
23
23
 
24
24
  /**
25
25
  * React hook for using a Live Share `LiveFollowMode`.
@@ -36,6 +36,145 @@ import { IUseLiveFollowModeResults } from "../types";
36
36
  * @param initialData The initial value for the local user's `stateValue`.
37
37
  * @param allowedRoles Optional. The user roles that are allowed to present to use `startPresenting()` or `stopPresenting()`.
38
38
  * @returns `IUseLiveFollowModeResults` results, which contains React stateful objects and callbacks.
39
+ *
40
+ * @example
41
+ ```jsx
42
+ import { FollowModeType } from "@microsoft/live-share";
43
+ import { useLiveFollowMode } from "@microsoft/live-share-react";
44
+ // As an example, we will use a fake component to denote what a 3D viewer might look like in an app
45
+ import { Example3DModelViewer } from "./components";
46
+
47
+ // Define a unique key that differentiates this usage of `useLiveFollowMode` from others in your app
48
+ const MY_UNIQUE_KEY = "follow-mode-key";
49
+
50
+ // Define the initial stateValue for the local user (optional).
51
+ const startingCameraPosition = {
52
+ x: 0,
53
+ y: 0,
54
+ z: 0,
55
+ };
56
+
57
+ // Example component for using useLiveFollowMode
58
+ export function MyLiveFollowMode() {
59
+ const {
60
+ state,
61
+ localUser,
62
+ otherUsers,
63
+ allUsers,
64
+ liveFollowMode,
65
+ update,
66
+ startPresenting,
67
+ stopPresenting,
68
+ beginSuspension,
69
+ endSuspension,
70
+ followUser,
71
+ stopFollowing,
72
+ } = useLiveFollowMode(MY_UNIQUE_KEY, startingCameraPosition);
73
+
74
+ // Example of an event listener for a camera position changed event.
75
+ // For something like a camera change event, you should use a debounce function.
76
+ function onCameraPositionChanged(position, isUserAction) {
77
+ // Broadcast change to other users so that they have their latest camera position
78
+ update(position);
79
+ // If the local user changed the position while following another user, we want to suspend.
80
+ // Note: helps to distinguish changes initiated by the local user (e.g., drag mouse) separately from other change events.
81
+ if (!isUserAction) return;
82
+ switch (state.type) {
83
+ case FollowModeType.followPresenter:
84
+ case FollowModeType.followUser: {
85
+ // This will trigger a "stateChanged" event update for the local user only.
86
+ followMode.beginSuspension();
87
+ break;
88
+ }
89
+ default: {
90
+ // No need to suspend for other types
91
+ break;
92
+ }
93
+ }
94
+ }
95
+
96
+ // Can optionally get the relevant user's presence object
97
+ const followingUser = liveFollowMode?.getUser(state.followingUserId);
98
+
99
+ // Render loading UI when creating LiveFollowMode instance for first time
100
+ if (!liveFollowMode) return <>Loading...</>;
101
+
102
+ // Render UI
103
+ return (
104
+ <div>
105
+ {state.type === FollowModeType.local && (
106
+ <div>
107
+ <p>{""}</p>
108
+ <button onClick={startPresenting}>
109
+ {"Start presenting"}
110
+ </button>
111
+ </div>
112
+ )}
113
+ {state.type === FollowModeType.activeFollowers && (
114
+ <div>
115
+ <p>{`${state.otherUsersCount} users are following you`}</p>
116
+ <button onClick={startPresenting}>
117
+ {"Present to all"}
118
+ </button>
119
+ </div>
120
+ )}
121
+ {state.type === FollowModeType.activePresenter && (
122
+ <div>
123
+ <p>{`You are actively presenting to everyone`}</p>
124
+ <button onClick={stopPresenting}>
125
+ {"Stop presenting"}
126
+ </button>
127
+ </div>
128
+ )}
129
+ {state.type === FollowModeType.followPresenter && (
130
+ <div>
131
+ <p>{`${followingUser?.displayName} is presenting to everyone`}</p>
132
+ <button onClick={startPresenting}>{"Take control"}</button>
133
+ </div>
134
+ )}
135
+ {state.type === FollowModeType.suspendFollowPresenter && (
136
+ <div>
137
+ <p>{`${followingUser?.displayName} is presenting to everyone`}</p>
138
+ <button onClick={endSuspension}>
139
+ {"Sync to presenter"}
140
+ </button>
141
+ </div>
142
+ )}
143
+ {state.type === FollowModeType.followUser && (
144
+ <div>
145
+ <p>{`You are following ${followingUser?.displayName}`}</p>
146
+ <button onClick={stopFollowing}>{"Stop following"}</button>
147
+ </div>
148
+ )}
149
+ {state.type === FollowModeType.suspendFollowUser && (
150
+ <div>
151
+ <p>{`You were following ${followingUser?.displayName}`}</p>
152
+ <button onClick={stopFollowing}>
153
+ {"Resume following"}
154
+ </button>
155
+ </div>
156
+ )}
157
+ <div>
158
+ <p>{"Follow a specific user:"}</p>
159
+ {otherUsers.map((user) => (
160
+ <button
161
+ onClick={() => {
162
+ followUser(user.userId);
163
+ }}
164
+ key={user.userId}
165
+ >
166
+ {user.displayName}
167
+ </button>
168
+ ))}
169
+ </div>
170
+ <Example3DModelViewer
171
+ cameraPosition={state.value}
172
+ onCameraPositionChanged={onCameraPositionChanged}
173
+ />
174
+ </div>
175
+ );
176
+ };
177
+ ```
39
178
  */
40
179
  export function useLiveFollowMode<TData = any>(
41
180
  uniqueKey: string,
@@ -63,12 +202,16 @@ export function useLiveFollowMode<TData = any>(
63
202
  /**
64
203
  * User facing: list of non-local user's presence objects.
65
204
  */
66
- const otherUsers = allUsers.filter((user) => !user.isLocalUser);
205
+ const otherUsers = React.useMemo(() => {
206
+ return allUsers.filter((user) => !user.isLocalUser);
207
+ }, [allUsers]);
67
208
 
68
209
  /**
69
210
  * User facing: local user's presence object.
70
211
  */
71
- const localUser = allUsers.find((user) => user.isLocalUser);
212
+ const localUser = React.useMemo(() => {
213
+ return allUsers.find((user) => user.isLocalUser);
214
+ }, [allUsers]);
72
215
 
73
216
  const { container } = useFluidObjectsContext();
74
217
 
@@ -5,20 +5,23 @@
5
5
 
6
6
  import {
7
7
  LivePresenceUser,
8
- PresenceState,
9
8
  LivePresence,
10
9
  UserMeetingRole,
11
10
  LiveDataObjectInitializeState,
11
+ LivePresenceData,
12
12
  } from "@microsoft/live-share";
13
13
  import React from "react";
14
- import { IUseLivePresenceResults, OnUpdateLivePresenceAction } from "../types";
15
- import { useDynamicDDS } from "../shared-hooks";
16
- import { useFluidObjectsContext } from "../providers";
14
+ import {
15
+ IUseLivePresenceResults,
16
+ OnUpdateLivePresenceAction,
17
+ } from "../types/index.js";
18
+ import { useDynamicDDS } from "../shared-hooks/index.js";
19
+ import { useFluidObjectsContext } from "../providers/index.js";
17
20
  import {
18
21
  ActionContainerNotJoinedError,
19
22
  ActionLiveDataObjectInitializedError,
20
23
  ActionLiveDataObjectUndefinedError,
21
- } from "../internal";
24
+ } from "../internal/index.js";
22
25
 
23
26
  /**
24
27
  * React hook for using a Live Share `LivePresence`.
@@ -31,17 +34,66 @@ import {
31
34
  *
32
35
  * @template TData Optional typing for the custom user presence data object. Default is `object` type.
33
36
  * @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.
37
+ * @param initialData Initial presence data object for the user. Can be value or a function to get the value.
36
38
  * @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
37
39
  * will be created, otherwise it will use the existing one. Default value is ":<dds-default>"
38
40
  * @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
39
41
  * to update the local user's presence and the `LivePresence` Fluid object.
42
+ *
43
+ * @example
44
+ ```jsx
45
+ import { useLivePresence } from "@microsoft/live-share-react";
46
+
47
+ // Define a unique key that differentiates this usage of `useLivePresence` from others in your app
48
+ const MY_UNIQUE_KEY = "presence-key";
49
+
50
+ // Example component for using useLivePresence
51
+ export const MyCustomPresence = () => {
52
+ const {
53
+ allUsers,
54
+ localUser,
55
+ livePresence,
56
+ updatePresence,
57
+ } = useLivePresence(MY_UNIQUE_KEY, {
58
+ picture: "DEFAULT_PROFILE_PICTURE_URL",
59
+ readyToStart: false,
60
+ });
61
+
62
+ // Callback to update the user's presence
63
+ const onToggleReady = () => {
64
+ updatePresence({
65
+ ...localUser.data,
66
+ readyToStart: !localUser.data.readyToStart,
67
+ });
68
+ }
69
+
70
+ // Render loading UI while loading LivePresence for first time
71
+ if (!livePresence) return <>Loading...</>;
72
+
73
+ // Render presence UI
74
+ return (
75
+ {allUsers.map((user) => (
76
+ <div key={user.userId}>
77
+ <div>
78
+ {user.displayName}
79
+ </div>
80
+ <div>
81
+ {`Ready: ${user.data.readyToStart}`}
82
+ </div>
83
+ {user.isLocalUser && (
84
+ <button onClick={onToggleReady}>
85
+ {"Toggle ready"}
86
+ </button>
87
+ )}
88
+ </div>
89
+ ))}
90
+ );
91
+ }
92
+ ```
40
93
  */
41
- export function useLivePresence<TData extends object = object>(
94
+ export function useLivePresence<TData extends LivePresenceData = any>(
42
95
  uniqueKey: string,
43
- initialData?: TData | (() => TData) | undefined,
44
- initialPresenceState: PresenceState = PresenceState.online,
96
+ initialData: TData | (() => TData),
45
97
  allowedRoles?: UserMeetingRole[]
46
98
  ): IUseLivePresenceResults<TData> {
47
99
  /**
@@ -55,18 +107,22 @@ export function useLivePresence<TData extends object = object>(
55
107
  */
56
108
  const { dds: livePresence } = useDynamicDDS<LivePresence<TData>>(
57
109
  uniqueKey,
58
- LivePresence<TData>
110
+ LivePresence
59
111
  );
60
112
 
61
113
  /**
62
114
  * User facing: list of non-local user's presence objects.
63
115
  */
64
- const otherUsers = allUsers.filter((user) => !user.isLocalUser);
116
+ const otherUsers = React.useMemo(() => {
117
+ return allUsers.filter((user) => !user.isLocalUser);
118
+ }, [allUsers]);
65
119
 
66
120
  /**
67
121
  * User facing: local user's presence object.
68
122
  */
69
- const localUser = allUsers.find((user) => user.isLocalUser);
123
+ const localUser = React.useMemo(() => {
124
+ return allUsers.find((user) => user.isLocalUser);
125
+ }, [allUsers]);
70
126
 
71
127
  const { container } = useFluidObjectsContext();
72
128
 
@@ -74,7 +130,7 @@ export function useLivePresence<TData extends object = object>(
74
130
  * User facing: callback to update the local user's presence.
75
131
  */
76
132
  const updatePresence: OnUpdateLivePresenceAction<TData> = React.useCallback(
77
- async (data?: TData | undefined, state?: PresenceState | undefined) => {
133
+ async (data: TData) => {
78
134
  if (!container) {
79
135
  throw new ActionContainerNotJoinedError(
80
136
  "livePresence",
@@ -93,7 +149,7 @@ export function useLivePresence<TData extends object = object>(
93
149
  "updatePresence"
94
150
  );
95
151
  }
96
- return await livePresence.update(data, state);
152
+ return await livePresence.update(data);
97
153
  },
98
154
  [container, livePresence]
99
155
  );
@@ -121,7 +177,6 @@ export function useLivePresence<TData extends object = object>(
121
177
  isInitialDataCallback<TData>(initialData)
122
178
  ? initialData()
123
179
  : initialData,
124
- initialPresenceState,
125
180
  allowedRoles
126
181
  );
127
182
  }
@@ -141,6 +196,8 @@ export function useLivePresence<TData extends object = object>(
141
196
  };
142
197
  }
143
198
 
144
- function isInitialDataCallback<TData>(value: any): value is () => TData {
199
+ function isInitialDataCallback<TData extends LivePresenceData>(
200
+ value: any
201
+ ): value is () => TData {
145
202
  return typeof value === "function";
146
203
  }
@@ -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,
@@ -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,