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

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/LICENSE +64 -61
  2. package/README.md +173 -168
  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.map +1 -0
  8. package/bin/cjs/interfaces/LiveInterfaceExtensions.js +7 -0
  9. package/bin/cjs/interfaces/LiveInterfaceExtensions.js.map +1 -0
  10. package/bin/cjs/interfaces/index.d.ts +2 -0
  11. package/bin/cjs/interfaces/index.d.ts.map +1 -0
  12. package/bin/cjs/interfaces/index.js +18 -0
  13. package/bin/cjs/interfaces/index.js.map +1 -0
  14. package/bin/cjs/internal/errors.d.ts.map +1 -0
  15. package/bin/cjs/internal/errors.js +48 -0
  16. package/bin/cjs/internal/errors.js.map +1 -0
  17. package/bin/cjs/internal/index.d.ts +3 -0
  18. package/bin/cjs/internal/index.d.ts.map +1 -0
  19. package/bin/cjs/internal/index.js +19 -0
  20. package/bin/cjs/internal/index.js.map +1 -0
  21. package/bin/{internal → cjs/internal}/type-guards.d.ts +1 -1
  22. package/bin/cjs/internal/type-guards.d.ts.map +1 -0
  23. package/bin/cjs/internal/type-guards.js +24 -0
  24. package/bin/cjs/internal/type-guards.js.map +1 -0
  25. package/bin/cjs/live-hooks/index.d.ts +8 -0
  26. package/bin/cjs/live-hooks/index.d.ts.map +1 -0
  27. package/bin/cjs/live-hooks/index.js +24 -0
  28. package/bin/cjs/live-hooks/index.js.map +1 -0
  29. package/bin/cjs/live-hooks/useLiveCanvas.d.ts +80 -0
  30. package/bin/cjs/live-hooks/useLiveCanvas.d.ts.map +1 -0
  31. package/bin/cjs/live-hooks/useLiveCanvas.js +244 -0
  32. package/bin/cjs/live-hooks/useLiveCanvas.js.map +1 -0
  33. package/bin/{live-hooks → cjs/live-hooks}/useLiveEvent.d.ts +37 -1
  34. package/bin/cjs/live-hooks/useLiveEvent.d.ts.map +1 -0
  35. package/bin/cjs/live-hooks/useLiveEvent.js +150 -0
  36. package/bin/cjs/live-hooks/useLiveEvent.js.map +1 -0
  37. package/bin/cjs/live-hooks/useLiveFollowMode.d.ts +163 -0
  38. package/bin/cjs/live-hooks/useLiveFollowMode.d.ts.map +1 -0
  39. package/bin/cjs/live-hooks/useLiveFollowMode.js +360 -0
  40. package/bin/cjs/live-hooks/useLiveFollowMode.js.map +1 -0
  41. package/bin/cjs/live-hooks/useLivePresence.d.ts +76 -0
  42. package/bin/cjs/live-hooks/useLivePresence.d.ts.map +1 -0
  43. package/bin/cjs/live-hooks/useLivePresence.js +170 -0
  44. package/bin/cjs/live-hooks/useLivePresence.js.map +1 -0
  45. package/bin/{live-hooks → cjs/live-hooks}/useLiveState.d.ts +46 -1
  46. package/bin/cjs/live-hooks/useLiveState.d.ts.map +1 -0
  47. package/bin/cjs/live-hooks/useLiveState.js +134 -0
  48. package/bin/cjs/live-hooks/useLiveState.js.map +1 -0
  49. package/bin/{live-hooks → cjs/live-hooks}/useLiveTimer.d.ts +56 -1
  50. package/bin/cjs/live-hooks/useLiveTimer.d.ts.map +1 -0
  51. package/bin/cjs/live-hooks/useLiveTimer.js +233 -0
  52. package/bin/cjs/live-hooks/useLiveTimer.js.map +1 -0
  53. package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts +86 -0
  54. package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
  55. package/bin/cjs/live-hooks/useMediaSynchronizer.js +301 -0
  56. package/bin/cjs/live-hooks/useMediaSynchronizer.js.map +1 -0
  57. package/bin/cjs/package.json +1 -0
  58. package/bin/{providers → cjs/providers}/AzureProvider.d.ts +9 -9
  59. package/bin/cjs/providers/AzureProvider.d.ts.map +1 -0
  60. package/bin/cjs/providers/AzureProvider.js +127 -0
  61. package/bin/cjs/providers/AzureProvider.js.map +1 -0
  62. package/bin/{providers → cjs/providers}/LiveShareProvider.d.ts +106 -4
  63. package/bin/cjs/providers/LiveShareProvider.d.ts.map +1 -0
  64. package/bin/cjs/providers/LiveShareProvider.js +205 -0
  65. package/bin/cjs/providers/LiveShareProvider.js.map +1 -0
  66. package/bin/cjs/providers/index.d.ts +3 -0
  67. package/bin/cjs/providers/index.d.ts.map +1 -0
  68. package/bin/cjs/providers/index.js +19 -0
  69. package/bin/cjs/providers/index.js.map +1 -0
  70. package/bin/cjs/shared-hooks/index.d.ts +7 -0
  71. package/bin/cjs/shared-hooks/index.d.ts.map +1 -0
  72. package/bin/cjs/shared-hooks/index.js +23 -0
  73. package/bin/cjs/shared-hooks/index.js.map +1 -0
  74. package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts +3 -0
  75. package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
  76. package/bin/cjs/shared-hooks/internals/tree-node-constants.js +6 -0
  77. package/bin/cjs/shared-hooks/internals/tree-node-constants.js.map +1 -0
  78. package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts +10 -0
  79. package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
  80. package/bin/cjs/shared-hooks/internals/tree-node-types.js +23 -0
  81. package/bin/cjs/shared-hooks/internals/tree-node-types.js.map +1 -0
  82. package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts +33 -0
  83. package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
  84. package/bin/cjs/shared-hooks/internals/tree-node-utils.js +193 -0
  85. package/bin/cjs/shared-hooks/internals/tree-node-utils.js.map +1 -0
  86. package/bin/{shared-hooks → cjs/shared-hooks}/useDynamicDDS.d.ts +4 -4
  87. package/bin/cjs/shared-hooks/useDynamicDDS.d.ts.map +1 -0
  88. package/bin/cjs/shared-hooks/useDynamicDDS.js +87 -0
  89. package/bin/cjs/shared-hooks/useDynamicDDS.js.map +1 -0
  90. package/bin/{shared-hooks → cjs/shared-hooks}/useSharedMap.d.ts +4 -2
  91. package/bin/cjs/shared-hooks/useSharedMap.d.ts.map +1 -0
  92. package/bin/cjs/shared-hooks/useSharedMap.js +134 -0
  93. package/bin/cjs/shared-hooks/useSharedMap.js.map +1 -0
  94. package/bin/{shared-hooks → cjs/shared-hooks}/useSharedState.d.ts +1 -1
  95. package/bin/cjs/shared-hooks/useSharedState.d.ts.map +1 -0
  96. package/bin/cjs/shared-hooks/useSharedState.js +80 -0
  97. package/bin/cjs/shared-hooks/useSharedState.js.map +1 -0
  98. package/bin/{shared-hooks → cjs/shared-hooks}/useSharedStateRegistry.d.ts +1 -1
  99. package/bin/cjs/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
  100. package/bin/cjs/shared-hooks/useSharedStateRegistry.js +120 -0
  101. package/bin/cjs/shared-hooks/useSharedStateRegistry.js.map +1 -0
  102. package/bin/cjs/shared-hooks/useSharedTree.d.ts +57 -0
  103. package/bin/cjs/shared-hooks/useSharedTree.d.ts.map +1 -0
  104. package/bin/cjs/shared-hooks/useSharedTree.js +123 -0
  105. package/bin/cjs/shared-hooks/useSharedTree.js.map +1 -0
  106. package/bin/cjs/shared-hooks/useTreeNode.d.ts +96 -0
  107. package/bin/cjs/shared-hooks/useTreeNode.d.ts.map +1 -0
  108. package/bin/cjs/shared-hooks/useTreeNode.js +135 -0
  109. package/bin/cjs/shared-hooks/useTreeNode.js.map +1 -0
  110. package/bin/{types → cjs/types}/ActionTypes.d.ts +7 -7
  111. package/bin/cjs/types/ActionTypes.d.ts.map +1 -0
  112. package/bin/cjs/types/ActionTypes.js +7 -0
  113. package/bin/cjs/types/ActionTypes.js.map +1 -0
  114. package/bin/cjs/types/PropTypes.d.ts +56 -0
  115. package/bin/cjs/types/PropTypes.d.ts.map +1 -0
  116. package/bin/cjs/types/PropTypes.js +7 -0
  117. package/bin/cjs/types/PropTypes.js.map +1 -0
  118. package/bin/{types → cjs/types}/ResultTypes.d.ts +50 -18
  119. package/bin/cjs/types/ResultTypes.d.ts.map +1 -0
  120. package/bin/cjs/types/ResultTypes.js +7 -0
  121. package/bin/cjs/types/ResultTypes.js.map +1 -0
  122. package/bin/cjs/types/index.d.ts +4 -0
  123. package/bin/cjs/types/index.d.ts.map +1 -0
  124. package/bin/cjs/types/index.js +20 -0
  125. package/bin/cjs/types/index.js.map +1 -0
  126. package/bin/cjs/utils/index.d.ts +2 -0
  127. package/bin/cjs/utils/index.d.ts.map +1 -0
  128. package/bin/cjs/utils/index.js +18 -0
  129. package/bin/cjs/utils/index.js.map +1 -0
  130. package/bin/cjs/utils/type-check.d.ts.map +1 -0
  131. package/bin/cjs/utils/type-check.js +62 -0
  132. package/bin/cjs/utils/type-check.js.map +1 -0
  133. package/bin/esm/index.d.ts +7 -0
  134. package/bin/esm/index.d.ts.map +1 -0
  135. package/bin/esm/index.js +7 -0
  136. package/bin/esm/index.js.map +1 -0
  137. package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts +26 -0
  138. package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
  139. package/bin/esm/interfaces/LiveInterfaceExtensions.js.map +1 -0
  140. package/bin/esm/interfaces/index.d.ts +2 -0
  141. package/bin/esm/interfaces/index.d.ts.map +1 -0
  142. package/bin/esm/interfaces/index.js +2 -0
  143. package/bin/esm/interfaces/index.js.map +1 -0
  144. package/bin/esm/internal/errors.d.ts +41 -0
  145. package/bin/esm/internal/errors.d.ts.map +1 -0
  146. package/bin/esm/internal/errors.js.map +1 -0
  147. package/bin/esm/internal/index.d.ts +3 -0
  148. package/bin/esm/internal/index.d.ts.map +1 -0
  149. package/bin/esm/internal/index.js +3 -0
  150. package/bin/esm/internal/index.js.map +1 -0
  151. package/bin/esm/internal/type-guards.d.ts +11 -0
  152. package/bin/esm/internal/type-guards.d.ts.map +1 -0
  153. package/bin/esm/internal/type-guards.js.map +1 -0
  154. package/bin/esm/live-hooks/index.d.ts +8 -0
  155. package/bin/esm/live-hooks/index.d.ts.map +1 -0
  156. package/bin/esm/live-hooks/index.js +8 -0
  157. package/bin/esm/live-hooks/index.js.map +1 -0
  158. package/bin/esm/live-hooks/useLiveCanvas.d.ts +80 -0
  159. package/bin/esm/live-hooks/useLiveCanvas.d.ts.map +1 -0
  160. package/bin/esm/live-hooks/useLiveCanvas.js +238 -0
  161. package/bin/esm/live-hooks/useLiveCanvas.js.map +1 -0
  162. package/bin/esm/live-hooks/useLiveEvent.d.ts +59 -0
  163. package/bin/esm/live-hooks/useLiveEvent.d.ts.map +1 -0
  164. package/bin/{live-hooks → esm/live-hooks}/useLiveEvent.js +41 -5
  165. package/bin/esm/live-hooks/useLiveEvent.js.map +1 -0
  166. package/bin/esm/live-hooks/useLiveFollowMode.d.ts +163 -0
  167. package/bin/esm/live-hooks/useLiveFollowMode.d.ts.map +1 -0
  168. package/bin/{live-hooks → esm/live-hooks}/useLiveFollowMode.js +148 -5
  169. package/bin/esm/live-hooks/useLiveFollowMode.js.map +1 -0
  170. package/bin/esm/live-hooks/useLivePresence.d.ts +76 -0
  171. package/bin/esm/live-hooks/useLivePresence.d.ts.map +1 -0
  172. package/bin/{live-hooks → esm/live-hooks}/useLivePresence.js +71 -13
  173. package/bin/esm/live-hooks/useLivePresence.js.map +1 -0
  174. package/bin/esm/live-hooks/useLiveState.d.ts +66 -0
  175. package/bin/esm/live-hooks/useLiveState.d.ts.map +1 -0
  176. package/bin/{live-hooks → esm/live-hooks}/useLiveState.js +54 -5
  177. package/bin/esm/live-hooks/useLiveState.js.map +1 -0
  178. package/bin/esm/live-hooks/useLiveTimer.d.ts +80 -0
  179. package/bin/esm/live-hooks/useLiveTimer.d.ts.map +1 -0
  180. package/bin/{live-hooks → esm/live-hooks}/useLiveTimer.js +58 -3
  181. package/bin/esm/live-hooks/useLiveTimer.js.map +1 -0
  182. package/bin/esm/live-hooks/useMediaSynchronizer.d.ts +86 -0
  183. package/bin/esm/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
  184. package/bin/{live-hooks → esm/live-hooks}/useMediaSynchronizer.js +66 -5
  185. package/bin/esm/live-hooks/useMediaSynchronizer.js.map +1 -0
  186. package/bin/esm/providers/AzureProvider.d.ts +113 -0
  187. package/bin/esm/providers/AzureProvider.d.ts.map +1 -0
  188. package/bin/{providers → esm/providers}/AzureProvider.js +10 -10
  189. package/bin/esm/providers/AzureProvider.js.map +1 -0
  190. package/bin/esm/providers/LiveShareProvider.d.ts +193 -0
  191. package/bin/esm/providers/LiveShareProvider.d.ts.map +1 -0
  192. package/bin/{providers → esm/providers}/LiveShareProvider.js +111 -9
  193. package/bin/esm/providers/LiveShareProvider.js.map +1 -0
  194. package/bin/esm/providers/index.d.ts +3 -0
  195. package/bin/esm/providers/index.d.ts.map +1 -0
  196. package/bin/esm/providers/index.js +3 -0
  197. package/bin/esm/providers/index.js.map +1 -0
  198. package/bin/esm/shared-hooks/index.d.ts +7 -0
  199. package/bin/esm/shared-hooks/index.d.ts.map +1 -0
  200. package/bin/esm/shared-hooks/index.js +7 -0
  201. package/bin/esm/shared-hooks/index.js.map +1 -0
  202. package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts +3 -0
  203. package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
  204. package/bin/esm/shared-hooks/internals/tree-node-constants.js +3 -0
  205. package/bin/esm/shared-hooks/internals/tree-node-constants.js.map +1 -0
  206. package/bin/esm/shared-hooks/internals/tree-node-types.d.ts +10 -0
  207. package/bin/esm/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
  208. package/bin/esm/shared-hooks/internals/tree-node-types.js +18 -0
  209. package/bin/esm/shared-hooks/internals/tree-node-types.js.map +1 -0
  210. package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts +33 -0
  211. package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
  212. package/bin/esm/shared-hooks/internals/tree-node-utils.js +188 -0
  213. package/bin/esm/shared-hooks/internals/tree-node-utils.js.map +1 -0
  214. package/bin/esm/shared-hooks/useDynamicDDS.d.ts +23 -0
  215. package/bin/esm/shared-hooks/useDynamicDDS.d.ts.map +1 -0
  216. package/bin/{shared-hooks → esm/shared-hooks}/useDynamicDDS.js +20 -11
  217. package/bin/esm/shared-hooks/useDynamicDDS.js.map +1 -0
  218. package/bin/esm/shared-hooks/useSharedMap.d.ts +25 -0
  219. package/bin/esm/shared-hooks/useSharedMap.d.ts.map +1 -0
  220. package/bin/{shared-hooks → esm/shared-hooks}/useSharedMap.js +27 -13
  221. package/bin/esm/shared-hooks/useSharedMap.js.map +1 -0
  222. package/bin/esm/shared-hooks/useSharedState.d.ts +22 -0
  223. package/bin/esm/shared-hooks/useSharedState.d.ts.map +1 -0
  224. package/bin/{shared-hooks → esm/shared-hooks}/useSharedState.js +2 -2
  225. package/bin/esm/shared-hooks/useSharedState.js.map +1 -0
  226. package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts +37 -0
  227. package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
  228. package/bin/{shared-hooks → esm/shared-hooks}/useSharedStateRegistry.js +27 -19
  229. package/bin/esm/shared-hooks/useSharedStateRegistry.js.map +1 -0
  230. package/bin/esm/shared-hooks/useSharedTree.d.ts +57 -0
  231. package/bin/esm/shared-hooks/useSharedTree.d.ts.map +1 -0
  232. package/bin/esm/shared-hooks/useSharedTree.js +117 -0
  233. package/bin/esm/shared-hooks/useSharedTree.js.map +1 -0
  234. package/bin/esm/shared-hooks/useTreeNode.d.ts +96 -0
  235. package/bin/esm/shared-hooks/useTreeNode.d.ts.map +1 -0
  236. package/bin/esm/shared-hooks/useTreeNode.js +132 -0
  237. package/bin/esm/shared-hooks/useTreeNode.js.map +1 -0
  238. package/bin/esm/types/ActionTypes.d.ts +112 -0
  239. package/bin/esm/types/ActionTypes.d.ts.map +1 -0
  240. package/bin/esm/types/ActionTypes.js.map +1 -0
  241. package/bin/esm/types/PropTypes.d.ts +56 -0
  242. package/bin/esm/types/PropTypes.d.ts.map +1 -0
  243. package/bin/esm/types/PropTypes.js.map +1 -0
  244. package/bin/esm/types/ResultTypes.d.ts +334 -0
  245. package/bin/esm/types/ResultTypes.d.ts.map +1 -0
  246. package/bin/esm/types/ResultTypes.js.map +1 -0
  247. package/bin/esm/types/index.d.ts +4 -0
  248. package/bin/esm/types/index.d.ts.map +1 -0
  249. package/bin/esm/types/index.js +4 -0
  250. package/bin/esm/types/index.js.map +1 -0
  251. package/bin/esm/utils/index.d.ts +2 -0
  252. package/bin/esm/utils/index.d.ts.map +1 -0
  253. package/bin/esm/utils/index.js +2 -0
  254. package/bin/esm/utils/index.js.map +1 -0
  255. package/bin/esm/utils/type-check.d.ts +15 -0
  256. package/bin/esm/utils/type-check.d.ts.map +1 -0
  257. package/bin/esm/utils/type-check.js.map +1 -0
  258. package/package.json +61 -47
  259. package/src/index.ts +6 -6
  260. package/src/interfaces/index.ts +1 -1
  261. package/src/internal/index.ts +2 -2
  262. package/src/internal/type-guards.ts +1 -1
  263. package/src/live-hooks/index.ts +7 -7
  264. package/src/live-hooks/useLiveCanvas.ts +154 -82
  265. package/src/live-hooks/useLiveEvent.ts +43 -7
  266. package/src/live-hooks/useLiveFollowMode.ts +149 -6
  267. package/src/live-hooks/useLivePresence.ts +80 -17
  268. package/src/live-hooks/useLiveState.ts +54 -6
  269. package/src/live-hooks/useLiveTimer.ts +59 -4
  270. package/src/live-hooks/useMediaSynchronizer.ts +71 -6
  271. package/src/providers/AzureProvider.tsx +21 -21
  272. package/src/providers/LiveShareProvider.tsx +115 -13
  273. package/src/providers/index.ts +2 -2
  274. package/src/shared-hooks/index.ts +6 -4
  275. package/src/shared-hooks/internals/tree-node-constants.ts +2 -0
  276. package/src/shared-hooks/internals/tree-node-types.ts +26 -0
  277. package/src/shared-hooks/internals/tree-node-utils.ts +269 -0
  278. package/src/shared-hooks/useDynamicDDS.ts +28 -17
  279. package/src/shared-hooks/useSharedMap.ts +42 -17
  280. package/src/shared-hooks/useSharedState.ts +6 -3
  281. package/src/shared-hooks/useSharedStateRegistry.ts +44 -22
  282. package/src/shared-hooks/useSharedTree.ts +144 -0
  283. package/src/shared-hooks/useTreeNode.ts +147 -0
  284. package/src/types/ActionTypes.ts +13 -9
  285. package/src/types/PropTypes.ts +57 -0
  286. package/src/types/ResultTypes.ts +71 -17
  287. package/src/types/index.ts +3 -3
  288. package/src/utils/index.ts +1 -1
  289. package/tsconfig.cjs.json +14 -0
  290. package/tsconfig.json +65 -70
  291. package/.nycrc.json +0 -10
  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
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the Microsoft Live Share SDK License.
5
+ */
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.useLivePresence = useLivePresence;
20
+ const live_share_1 = require("@microsoft/live-share");
21
+ const react_1 = __importDefault(require("react"));
22
+ const index_js_1 = require("../shared-hooks/index.js");
23
+ const index_js_2 = require("../providers/index.js");
24
+ const index_js_3 = require("../internal/index.js");
25
+ /**
26
+ * React hook for using a Live Share `LivePresence`.
27
+ *
28
+ * @remarks
29
+ * Use this hook if you want to track presence for who is currently using this component, such as
30
+ * who is online or who is viewing a specific document. With presence, you can sent along any custom
31
+ * user data. This is useful for rendering a list of users, profile pictures, cursor positions, and more.
32
+ * This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
33
+ *
34
+ * @template TData Optional typing for the custom user presence data object. Default is `object` type.
35
+ * @param uniqueKey The unique key for `LivePresence`. If one does not yet exist, a new one will be created.
36
+ * @param initialData Initial presence data object for the user. Can be value or a function to get the value.
37
+ * @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
38
+ * will be created, otherwise it will use the existing one. Default value is ":<dds-default>"
39
+ * @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
40
+ * to update the local user's presence and the `LivePresence` Fluid object.
41
+ *
42
+ * @example
43
+ ```jsx
44
+ import { useLivePresence } from "@microsoft/live-share-react";
45
+
46
+ // Define a unique key that differentiates this usage of `useLivePresence` from others in your app
47
+ const MY_UNIQUE_KEY = "presence-key";
48
+
49
+ // Example component for using useLivePresence
50
+ export const MyCustomPresence = () => {
51
+ const {
52
+ allUsers,
53
+ localUser,
54
+ livePresence,
55
+ updatePresence,
56
+ } = useLivePresence(MY_UNIQUE_KEY, {
57
+ picture: "DEFAULT_PROFILE_PICTURE_URL",
58
+ readyToStart: false,
59
+ });
60
+
61
+ // Callback to update the user's presence
62
+ const onToggleReady = () => {
63
+ updatePresence({
64
+ ...localUser.data,
65
+ readyToStart: !localUser.data.readyToStart,
66
+ });
67
+ }
68
+
69
+ // Render loading UI while loading LivePresence for first time
70
+ if (!livePresence) return <>Loading...</>;
71
+
72
+ // Render presence UI
73
+ return (
74
+ {allUsers.map((user) => (
75
+ <div key={user.userId}>
76
+ <div>
77
+ {user.displayName}
78
+ </div>
79
+ <div>
80
+ {`Ready: ${user.data.readyToStart}`}
81
+ </div>
82
+ {user.isLocalUser && (
83
+ <button onClick={onToggleReady}>
84
+ {"Toggle ready"}
85
+ </button>
86
+ )}
87
+ </div>
88
+ ))}
89
+ );
90
+ }
91
+ ```
92
+ */
93
+ function useLivePresence(uniqueKey, initialData, allowedRoles) {
94
+ /**
95
+ * Stateful all user presence list and its non-user-facing setter method.
96
+ */
97
+ const [allUsers, setAllUsers] = react_1.default.useState([]);
98
+ /**
99
+ * User facing: dynamically load the DDS for the given unique key.
100
+ */
101
+ const { dds: livePresence } = (0, index_js_1.useDynamicDDS)(uniqueKey, live_share_1.LivePresence);
102
+ /**
103
+ * User facing: list of non-local user's presence objects.
104
+ */
105
+ const otherUsers = react_1.default.useMemo(() => {
106
+ return allUsers.filter((user) => !user.isLocalUser);
107
+ }, [allUsers]);
108
+ /**
109
+ * User facing: local user's presence object.
110
+ */
111
+ const localUser = react_1.default.useMemo(() => {
112
+ return allUsers.find((user) => user.isLocalUser);
113
+ }, [allUsers]);
114
+ const onlineUsers = react_1.default.useMemo(() => {
115
+ return allUsers.filter((user) => user.status === live_share_1.PresenceStatus.online);
116
+ }, [allUsers]);
117
+ const { container } = (0, index_js_2.useFluidObjectsContext)();
118
+ /**
119
+ * User facing: callback to update the local user's presence.
120
+ */
121
+ const updatePresence = react_1.default.useCallback((data) => __awaiter(this, void 0, void 0, function* () {
122
+ if (!container) {
123
+ throw new index_js_3.ActionContainerNotJoinedError("livePresence", "updatePresence");
124
+ }
125
+ if (livePresence === undefined) {
126
+ throw new index_js_3.ActionLiveDataObjectUndefinedError("livePresence", "updatePresence");
127
+ }
128
+ if (!livePresence.isInitialized) {
129
+ throw new index_js_3.ActionLiveDataObjectInitializedError("livePresence", "updatePresence");
130
+ }
131
+ return yield livePresence.update(data);
132
+ }), [container, livePresence]);
133
+ /**
134
+ * Setup change listeners and start `LivePresence` if needed
135
+ */
136
+ react_1.default.useEffect(() => {
137
+ if (livePresence === undefined)
138
+ return;
139
+ const onPresenceChanged = () => {
140
+ const updatedLocalUsers = [];
141
+ livePresence === null || livePresence === void 0 ? void 0 : livePresence.getUsers().forEach((user) => {
142
+ updatedLocalUsers.push(user);
143
+ });
144
+ setAllUsers(updatedLocalUsers);
145
+ };
146
+ livePresence.on("presenceChanged", onPresenceChanged);
147
+ if (livePresence.initializeState ===
148
+ live_share_1.LiveDataObjectInitializeState.needed) {
149
+ livePresence.initialize(isInitialDataCallback(initialData)
150
+ ? initialData()
151
+ : initialData, allowedRoles);
152
+ }
153
+ onPresenceChanged();
154
+ return () => {
155
+ livePresence === null || livePresence === void 0 ? void 0 : livePresence.off("presenceChanged", onPresenceChanged);
156
+ };
157
+ }, [livePresence]);
158
+ return {
159
+ localUser,
160
+ otherUsers,
161
+ allUsers,
162
+ onlineUsers,
163
+ livePresence,
164
+ updatePresence,
165
+ };
166
+ }
167
+ function isInitialDataCallback(value) {
168
+ return typeof value === "function";
169
+ }
170
+ //# sourceMappingURL=useLivePresence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLivePresence.js","sourceRoot":"","sources":["../../../src/live-hooks/useLivePresence.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;AA2FH,0CA4GC;AArMD,sDAO+B;AAC/B,kDAA0B;AAK1B,uDAAyD;AACzD,oDAA+D;AAC/D,mDAI8B;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO;QACH,SAAS;QACT,UAAU;QACV,QAAQ;QACR,WAAW;QACX,YAAY;QACZ,cAAc;KACjB,CAAC;AACN,CAAC;AAED,SAAS,qBAAqB,CAC1B,KAAU;IAEV,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACvC,CAAC"}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the Microsoft Live Share SDK License.
4
4
  */
5
5
  import { LiveState, UserMeetingRole } from "@microsoft/live-share";
6
- import { SetLiveStateAction } from "../types";
6
+ import { SetLiveStateAction } from "../types/index.js";
7
7
  /**
8
8
  * React hook for using a Live Share `LiveState`.
9
9
  *
@@ -16,6 +16,51 @@ import { SetLiveStateAction } from "../types";
16
16
  * @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
17
17
  * @returns ordered values: first value is the synchronized state value and the second is a setter to change the state value.
18
18
  * The setter returns a void promise, which will throw if the user does not have the required roles to set.
19
+ *
20
+ * @example
21
+ ```jsx
22
+ import { useLiveState } from "@microsoft/live-share-react";
23
+
24
+ const planets = [
25
+ "Mercury",
26
+ "Venus",
27
+ "Earth",
28
+ "Mars",
29
+ "Jupiter",
30
+ "Saturn",
31
+ "Uranus",
32
+ "Neptune",
33
+ ];
34
+
35
+ // Define a unique key that differentiates this usage of `useLiveState` from others in your app
36
+ const MY_UNIQUE_KEY = "selected-planet-key";
37
+
38
+ // Example component for using useLiveState
39
+ export const MyCustomState = () => {
40
+ const [planet, setPlanet, liveState] = useLiveState(MY_UNIQUE_KEY, planets[0]);
41
+
42
+ // Render loading UI when creating LiveState instance for first time
43
+ if (!liveState) return <>Loading...</>;
44
+
45
+ // Render UI
46
+ return (
47
+ <div>
48
+ {`Current planet: ${planet}`}
49
+ {"Select a planet below:"}
50
+ {planets.map((planet) => (
51
+ <button
52
+ key={planet}
53
+ onClick={() => {
54
+ setPlanet(planet);
55
+ }}
56
+ >
57
+ {planet}
58
+ </button>
59
+ ))}
60
+ </div>
61
+ );
62
+ };
63
+ ```
19
64
  */
20
65
  export declare function useLiveState<TState = any>(uniqueKey: string, initialState: TState, allowedRoles?: UserMeetingRole[]): [TState, SetLiveStateAction<TState>, LiveState<TState> | undefined];
21
66
  //# sourceMappingURL=useLiveState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveState.d.ts","sourceRoot":"","sources":["../../../src/live-hooks/useLiveState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,SAAS,EACT,eAAe,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAUvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAG,GAAG,EACrC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,eAAe,EAAE,GACjC,CAAC,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAwErE"}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the Microsoft Live Share SDK License.
5
+ */
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.useLiveState = useLiveState;
20
+ const live_share_1 = require("@microsoft/live-share");
21
+ const react_1 = __importDefault(require("react"));
22
+ const index_js_1 = require("../shared-hooks/index.js");
23
+ const index_js_2 = require("../providers/index.js");
24
+ const index_js_3 = require("../internal/index.js");
25
+ /**
26
+ * React hook for using a Live Share `LiveState`.
27
+ *
28
+ * @remarks
29
+ * Use this hook if you want to synchronize app state that will reset when all users leave the session.
30
+ * This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
31
+ *
32
+ * @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one will be created, otherwise it will use the existing one.
33
+ * @param initialState Optional. the initial state value of type TState
34
+ * @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
35
+ * @returns ordered values: first value is the synchronized state value and the second is a setter to change the state value.
36
+ * The setter returns a void promise, which will throw if the user does not have the required roles to set.
37
+ *
38
+ * @example
39
+ ```jsx
40
+ import { useLiveState } from "@microsoft/live-share-react";
41
+
42
+ const planets = [
43
+ "Mercury",
44
+ "Venus",
45
+ "Earth",
46
+ "Mars",
47
+ "Jupiter",
48
+ "Saturn",
49
+ "Uranus",
50
+ "Neptune",
51
+ ];
52
+
53
+ // Define a unique key that differentiates this usage of `useLiveState` from others in your app
54
+ const MY_UNIQUE_KEY = "selected-planet-key";
55
+
56
+ // Example component for using useLiveState
57
+ export const MyCustomState = () => {
58
+ const [planet, setPlanet, liveState] = useLiveState(MY_UNIQUE_KEY, planets[0]);
59
+
60
+ // Render loading UI when creating LiveState instance for first time
61
+ if (!liveState) return <>Loading...</>;
62
+
63
+ // Render UI
64
+ return (
65
+ <div>
66
+ {`Current planet: ${planet}`}
67
+ {"Select a planet below:"}
68
+ {planets.map((planet) => (
69
+ <button
70
+ key={planet}
71
+ onClick={() => {
72
+ setPlanet(planet);
73
+ }}
74
+ >
75
+ {planet}
76
+ </button>
77
+ ))}
78
+ </div>
79
+ );
80
+ };
81
+ ```
82
+ */
83
+ function useLiveState(uniqueKey, initialState, allowedRoles) {
84
+ const [currentState, setCurrentState] = react_1.default.useState(initialState);
85
+ /**
86
+ * User facing: dynamically load the DDS for the given unique key.
87
+ */
88
+ const { dds: liveState } = (0, index_js_1.useDynamicDDS)(uniqueKey, (live_share_1.LiveState));
89
+ const { container } = (0, index_js_2.useFluidObjectsContext)();
90
+ /**
91
+ * Change state callback that is user facing
92
+ * @param state TState to set
93
+ * @returns void promise, which will throw if the user does not have the required roles
94
+ */
95
+ const setState = react_1.default.useCallback((state) => __awaiter(this, void 0, void 0, function* () {
96
+ if (!container) {
97
+ throw new index_js_3.ActionContainerNotJoinedError("liveState", "setState");
98
+ }
99
+ if (liveState === undefined) {
100
+ throw new index_js_3.ActionLiveDataObjectUndefinedError("liveState", "setState");
101
+ }
102
+ if (!liveState.isInitialized) {
103
+ throw new index_js_3.ActionLiveDataObjectInitializedError("liveState", "setState");
104
+ }
105
+ const valueToSet = (0, index_js_3.isPrevStateCallback)(state)
106
+ ? state(liveState.state)
107
+ : state;
108
+ return yield liveState.set(valueToSet);
109
+ }), [container, liveState]);
110
+ /**
111
+ * Setup change listeners and start `LiveState` if needed
112
+ */
113
+ react_1.default.useEffect(() => {
114
+ if (liveState === undefined)
115
+ return;
116
+ const onStateChanged = (state) => {
117
+ setCurrentState(state);
118
+ };
119
+ liveState.on("stateChanged", onStateChanged);
120
+ if (liveState.initializeState === live_share_1.LiveDataObjectInitializeState.needed) {
121
+ liveState
122
+ .initialize(initialState, allowedRoles)
123
+ .then(() => onStateChanged(liveState.state));
124
+ }
125
+ else {
126
+ onStateChanged(liveState.state);
127
+ }
128
+ return () => {
129
+ liveState === null || liveState === void 0 ? void 0 : liveState.off("stateChanged", onStateChanged);
130
+ };
131
+ }, [liveState]);
132
+ return [currentState, setState, liveState];
133
+ }
134
+ //# sourceMappingURL=useLiveState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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AC;IAC3C,CAAC,CAAA,EACD,CAAC,SAAS,EAAE,SAAS,CAAC,CACzB,CAAC;IAEF;;OAEG;IACH,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO;QAEpC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE;YACrC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC,CAAC;QACF,SAAS,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QAC7C,IACI,SAAS,CAAC,eAAe,KAAK,0CAA6B,CAAC,MAAM,EACpE,CAAC;YACC,SAAS;iBACJ,UAAU,CAAC,YAAY,EAAE,YAAY,CAAC;iBACtC,IAAI,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;QACrD,CAAC;aAAM,CAAC;YACJ,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;QAED,OAAO,GAAG,EAAE;YACR,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QACnD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO,CAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC/C,CAAC"}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the Microsoft Live Share SDK License.
4
4
  */
5
5
  import { UserMeetingRole } from "@microsoft/live-share";
6
- import { IUseLiveTimerResults, OnTimerDidFinishAction, OnTimerDidPauseAction, OnTimerDidPlayAction, OnTimerDidStartAction, OnTimerTickAction } from "../types";
6
+ import { IUseLiveTimerResults, OnTimerDidFinishAction, OnTimerDidPauseAction, OnTimerDidPlayAction, OnTimerDidStartAction, OnTimerTickAction } from "../types/index.js";
7
7
  /**
8
8
  * React hook for using Live Share's `LiveTimer` DDS.
9
9
  *
@@ -20,6 +20,61 @@ import { IUseLiveTimerResults, OnTimerDidFinishAction, OnTimerDidPauseAction, On
20
20
  * @param onPlay Optional. event handler callback for when the timer is resumed.
21
21
  * @param onFinish Optional. event handler callback for when the timer finishes.
22
22
  * @returns results and callbacks exposed via the hook.
23
+ *
24
+ * @example
25
+ ```jsx
26
+ import { useLiveTimer } from "@microsoft/live-share-react";
27
+
28
+ // Define a unique key that differentiates this usage of `useLiveTimer` from others in your app
29
+ const MY_UNIQUE_KEY = "timer-key";
30
+
31
+ // Example component for using useLiveTimer
32
+ export function CountdownTimer() {
33
+ const {
34
+ milliRemaining,
35
+ timerConfig,
36
+ liveTimer,
37
+ start,
38
+ pause,
39
+ play,
40
+ } = useLiveTimer("TIMER-ID");
41
+
42
+ // Render loading UI when creating LiveTimer instance for first time
43
+ if (!liveTimer) return <>Loading...</>;
44
+
45
+ return (
46
+ <div>
47
+ <button
48
+ onClick={() => {
49
+ start(60 * 1000);
50
+ }}
51
+ >
52
+ {timerConfig === undefined ? "Start" : "Reset"}
53
+ </button>
54
+ {timerConfig !== undefined && (
55
+ <button
56
+ onClick={() => {
57
+ if (timerConfig.running) {
58
+ pause();
59
+ } else {
60
+ play();
61
+ }
62
+ }}
63
+ >
64
+ {timerConfig.running ? "Pause" : "Play"}
65
+ </button>
66
+ )}
67
+ {milliRemaining !== undefined && (
68
+ <p>
69
+ {`${Math.round(milliRemaining / 1000)} / ${
70
+ Math.round(timerConfig.duration) / 1000
71
+ }`}
72
+ </p>
73
+ )}
74
+ </div>
75
+ );
76
+ }
77
+ ```
23
78
  */
24
79
  export declare function useLiveTimer(uniqueKey: string, allowedRoles?: UserMeetingRole[], tickRate?: number, onTick?: OnTimerTickAction, onStart?: OnTimerDidStartAction, onPause?: OnTimerDidPauseAction, onPlay?: OnTimerDidPlayAction, onFinish?: OnTimerDidFinishAction): IUseLiveTimerResults;
25
80
  //# sourceMappingURL=useLiveTimer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveTimer.d.ts","sourceRoot":"","sources":["../../../src/live-hooks/useLiveTimer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGH,eAAe,EAGlB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,oBAAoB,EAIpB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACpB,MAAM,mBAAmB,CAAC;AAS3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AACH,wBAAgB,YAAY,CACxB,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,eAAe,EAAE,EAChC,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE,qBAAqB,EAC/B,OAAO,CAAC,EAAE,qBAAqB,EAC/B,MAAM,CAAC,EAAE,oBAAoB,EAC7B,QAAQ,CAAC,EAAE,sBAAsB,GAClC,oBAAoB,CA8JtB"}