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

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 +170 -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 +50 -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 +71 -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 +334 -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 +80 -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 +71 -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,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,
@@ -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,