@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.
- package/.nycrc.json +9 -9
- package/LICENSE +64 -61
- package/README.md +173 -168
- package/bin/cjs/index.d.ts +7 -0
- package/bin/cjs/index.d.ts.map +1 -0
- package/bin/cjs/index.js +23 -0
- package/bin/cjs/index.js.map +1 -0
- package/bin/cjs/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
- package/bin/cjs/interfaces/LiveInterfaceExtensions.js +7 -0
- package/bin/cjs/interfaces/LiveInterfaceExtensions.js.map +1 -0
- package/bin/cjs/interfaces/index.d.ts +2 -0
- package/bin/cjs/interfaces/index.d.ts.map +1 -0
- package/bin/cjs/interfaces/index.js +18 -0
- package/bin/cjs/interfaces/index.js.map +1 -0
- package/bin/cjs/internal/errors.d.ts.map +1 -0
- package/bin/cjs/internal/errors.js +48 -0
- package/bin/cjs/internal/errors.js.map +1 -0
- package/bin/cjs/internal/index.d.ts +3 -0
- package/bin/cjs/internal/index.d.ts.map +1 -0
- package/bin/cjs/internal/index.js +19 -0
- package/bin/cjs/internal/index.js.map +1 -0
- package/bin/{internal → cjs/internal}/type-guards.d.ts +1 -1
- package/bin/cjs/internal/type-guards.d.ts.map +1 -0
- package/bin/cjs/internal/type-guards.js +24 -0
- package/bin/cjs/internal/type-guards.js.map +1 -0
- package/bin/cjs/live-hooks/index.d.ts +8 -0
- package/bin/cjs/live-hooks/index.d.ts.map +1 -0
- package/bin/cjs/live-hooks/index.js +24 -0
- package/bin/cjs/live-hooks/index.js.map +1 -0
- package/bin/cjs/live-hooks/useLiveCanvas.d.ts +80 -0
- package/bin/cjs/live-hooks/useLiveCanvas.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLiveCanvas.js +244 -0
- package/bin/cjs/live-hooks/useLiveCanvas.js.map +1 -0
- package/bin/{live-hooks → cjs/live-hooks}/useLiveEvent.d.ts +37 -1
- package/bin/cjs/live-hooks/useLiveEvent.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLiveEvent.js +150 -0
- package/bin/cjs/live-hooks/useLiveEvent.js.map +1 -0
- package/bin/cjs/live-hooks/useLiveFollowMode.d.ts +163 -0
- package/bin/cjs/live-hooks/useLiveFollowMode.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLiveFollowMode.js +360 -0
- package/bin/cjs/live-hooks/useLiveFollowMode.js.map +1 -0
- package/bin/cjs/live-hooks/useLivePresence.d.ts +76 -0
- package/bin/cjs/live-hooks/useLivePresence.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLivePresence.js +166 -0
- package/bin/cjs/live-hooks/useLivePresence.js.map +1 -0
- package/bin/{live-hooks → cjs/live-hooks}/useLiveState.d.ts +46 -1
- package/bin/cjs/live-hooks/useLiveState.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLiveState.js +130 -0
- package/bin/cjs/live-hooks/useLiveState.js.map +1 -0
- package/bin/{live-hooks → cjs/live-hooks}/useLiveTimer.d.ts +56 -1
- package/bin/cjs/live-hooks/useLiveTimer.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLiveTimer.js +233 -0
- package/bin/cjs/live-hooks/useLiveTimer.js.map +1 -0
- package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts +86 -0
- package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useMediaSynchronizer.js +301 -0
- package/bin/cjs/live-hooks/useMediaSynchronizer.js.map +1 -0
- package/bin/cjs/package.json +1 -0
- package/bin/{providers → cjs/providers}/AzureProvider.d.ts +9 -9
- package/bin/cjs/providers/AzureProvider.d.ts.map +1 -0
- package/bin/cjs/providers/AzureProvider.js +127 -0
- package/bin/cjs/providers/AzureProvider.js.map +1 -0
- package/bin/{providers → cjs/providers}/LiveShareProvider.d.ts +106 -4
- package/bin/cjs/providers/LiveShareProvider.d.ts.map +1 -0
- package/bin/cjs/providers/LiveShareProvider.js +205 -0
- package/bin/cjs/providers/LiveShareProvider.js.map +1 -0
- package/bin/cjs/providers/index.d.ts +3 -0
- package/bin/cjs/providers/index.d.ts.map +1 -0
- package/bin/cjs/providers/index.js +19 -0
- package/bin/cjs/providers/index.js.map +1 -0
- package/bin/cjs/shared-hooks/index.d.ts +7 -0
- package/bin/cjs/shared-hooks/index.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/index.js +23 -0
- package/bin/cjs/shared-hooks/index.js.map +1 -0
- package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts +3 -0
- package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/internals/tree-node-constants.js +6 -0
- package/bin/cjs/shared-hooks/internals/tree-node-constants.js.map +1 -0
- package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts +10 -0
- package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/internals/tree-node-types.js +23 -0
- package/bin/cjs/shared-hooks/internals/tree-node-types.js.map +1 -0
- package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts +33 -0
- package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/internals/tree-node-utils.js +193 -0
- package/bin/cjs/shared-hooks/internals/tree-node-utils.js.map +1 -0
- package/bin/{shared-hooks → cjs/shared-hooks}/useDynamicDDS.d.ts +4 -4
- package/bin/cjs/shared-hooks/useDynamicDDS.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/useDynamicDDS.js +87 -0
- package/bin/cjs/shared-hooks/useDynamicDDS.js.map +1 -0
- package/bin/{shared-hooks → cjs/shared-hooks}/useSharedMap.d.ts +4 -2
- package/bin/cjs/shared-hooks/useSharedMap.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/useSharedMap.js +134 -0
- package/bin/cjs/shared-hooks/useSharedMap.js.map +1 -0
- package/bin/{shared-hooks → cjs/shared-hooks}/useSharedState.d.ts +1 -1
- package/bin/cjs/shared-hooks/useSharedState.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/useSharedState.js +80 -0
- package/bin/cjs/shared-hooks/useSharedState.js.map +1 -0
- package/bin/{shared-hooks → cjs/shared-hooks}/useSharedStateRegistry.d.ts +1 -1
- package/bin/cjs/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/useSharedStateRegistry.js +120 -0
- package/bin/cjs/shared-hooks/useSharedStateRegistry.js.map +1 -0
- package/bin/cjs/shared-hooks/useSharedTree.d.ts +57 -0
- package/bin/cjs/shared-hooks/useSharedTree.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/useSharedTree.js +123 -0
- package/bin/cjs/shared-hooks/useSharedTree.js.map +1 -0
- package/bin/cjs/shared-hooks/useTreeNode.d.ts +96 -0
- package/bin/cjs/shared-hooks/useTreeNode.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/useTreeNode.js +135 -0
- package/bin/cjs/shared-hooks/useTreeNode.js.map +1 -0
- package/bin/{types → cjs/types}/ActionTypes.d.ts +7 -7
- package/bin/cjs/types/ActionTypes.d.ts.map +1 -0
- package/bin/cjs/types/ActionTypes.js +7 -0
- package/bin/cjs/types/ActionTypes.js.map +1 -0
- package/bin/cjs/types/PropTypes.d.ts +56 -0
- package/bin/cjs/types/PropTypes.d.ts.map +1 -0
- package/bin/cjs/types/PropTypes.js +7 -0
- package/bin/cjs/types/PropTypes.js.map +1 -0
- package/bin/{types → cjs/types}/ResultTypes.d.ts +46 -18
- package/bin/cjs/types/ResultTypes.d.ts.map +1 -0
- package/bin/cjs/types/ResultTypes.js +7 -0
- package/bin/cjs/types/ResultTypes.js.map +1 -0
- package/bin/cjs/types/index.d.ts +4 -0
- package/bin/cjs/types/index.d.ts.map +1 -0
- package/bin/cjs/types/index.js +20 -0
- package/bin/cjs/types/index.js.map +1 -0
- package/bin/cjs/utils/index.d.ts +2 -0
- package/bin/cjs/utils/index.d.ts.map +1 -0
- package/bin/cjs/utils/index.js +18 -0
- package/bin/cjs/utils/index.js.map +1 -0
- package/bin/cjs/utils/type-check.d.ts.map +1 -0
- package/bin/cjs/utils/type-check.js +62 -0
- package/bin/cjs/utils/type-check.js.map +1 -0
- package/bin/esm/index.d.ts +7 -0
- package/bin/esm/index.d.ts.map +1 -0
- package/bin/esm/index.js +7 -0
- package/bin/esm/index.js.map +1 -0
- package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts +26 -0
- package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
- package/bin/esm/interfaces/LiveInterfaceExtensions.js.map +1 -0
- package/bin/esm/interfaces/index.d.ts +2 -0
- package/bin/esm/interfaces/index.d.ts.map +1 -0
- package/bin/esm/interfaces/index.js +2 -0
- package/bin/esm/interfaces/index.js.map +1 -0
- package/bin/esm/internal/errors.d.ts +41 -0
- package/bin/esm/internal/errors.d.ts.map +1 -0
- package/bin/esm/internal/errors.js.map +1 -0
- package/bin/esm/internal/index.d.ts +3 -0
- package/bin/esm/internal/index.d.ts.map +1 -0
- package/bin/esm/internal/index.js +3 -0
- package/bin/esm/internal/index.js.map +1 -0
- package/bin/esm/internal/type-guards.d.ts +11 -0
- package/bin/esm/internal/type-guards.d.ts.map +1 -0
- package/bin/esm/internal/type-guards.js.map +1 -0
- package/bin/esm/live-hooks/index.d.ts +8 -0
- package/bin/esm/live-hooks/index.d.ts.map +1 -0
- package/bin/esm/live-hooks/index.js +8 -0
- package/bin/esm/live-hooks/index.js.map +1 -0
- package/bin/esm/live-hooks/useLiveCanvas.d.ts +80 -0
- package/bin/esm/live-hooks/useLiveCanvas.d.ts.map +1 -0
- package/bin/esm/live-hooks/useLiveCanvas.js +238 -0
- package/bin/esm/live-hooks/useLiveCanvas.js.map +1 -0
- package/bin/esm/live-hooks/useLiveEvent.d.ts +59 -0
- package/bin/esm/live-hooks/useLiveEvent.d.ts.map +1 -0
- package/bin/{live-hooks → esm/live-hooks}/useLiveEvent.js +41 -5
- package/bin/esm/live-hooks/useLiveEvent.js.map +1 -0
- package/bin/esm/live-hooks/useLiveFollowMode.d.ts +163 -0
- package/bin/esm/live-hooks/useLiveFollowMode.d.ts.map +1 -0
- package/bin/{live-hooks → esm/live-hooks}/useLiveFollowMode.js +148 -5
- package/bin/esm/live-hooks/useLiveFollowMode.js.map +1 -0
- package/bin/esm/live-hooks/useLivePresence.d.ts +76 -0
- package/bin/esm/live-hooks/useLivePresence.d.ts.map +1 -0
- package/bin/{live-hooks → esm/live-hooks}/useLivePresence.js +67 -13
- package/bin/esm/live-hooks/useLivePresence.js.map +1 -0
- package/bin/esm/live-hooks/useLiveState.d.ts +66 -0
- package/bin/esm/live-hooks/useLiveState.d.ts.map +1 -0
- package/bin/{live-hooks → esm/live-hooks}/useLiveState.js +48 -3
- package/bin/esm/live-hooks/useLiveState.js.map +1 -0
- package/bin/esm/live-hooks/useLiveTimer.d.ts +80 -0
- package/bin/esm/live-hooks/useLiveTimer.d.ts.map +1 -0
- package/bin/{live-hooks → esm/live-hooks}/useLiveTimer.js +58 -3
- package/bin/esm/live-hooks/useLiveTimer.js.map +1 -0
- package/bin/esm/live-hooks/useMediaSynchronizer.d.ts +86 -0
- package/bin/esm/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
- package/bin/{live-hooks → esm/live-hooks}/useMediaSynchronizer.js +65 -4
- package/bin/esm/live-hooks/useMediaSynchronizer.js.map +1 -0
- package/bin/esm/providers/AzureProvider.d.ts +113 -0
- package/bin/esm/providers/AzureProvider.d.ts.map +1 -0
- package/bin/{providers → esm/providers}/AzureProvider.js +10 -10
- package/bin/esm/providers/AzureProvider.js.map +1 -0
- package/bin/esm/providers/LiveShareProvider.d.ts +193 -0
- package/bin/esm/providers/LiveShareProvider.d.ts.map +1 -0
- package/bin/{providers → esm/providers}/LiveShareProvider.js +111 -9
- package/bin/esm/providers/LiveShareProvider.js.map +1 -0
- package/bin/esm/providers/index.d.ts +3 -0
- package/bin/esm/providers/index.d.ts.map +1 -0
- package/bin/esm/providers/index.js +3 -0
- package/bin/esm/providers/index.js.map +1 -0
- package/bin/esm/shared-hooks/index.d.ts +7 -0
- package/bin/esm/shared-hooks/index.d.ts.map +1 -0
- package/bin/esm/shared-hooks/index.js +7 -0
- package/bin/esm/shared-hooks/index.js.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts +3 -0
- package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-constants.js +3 -0
- package/bin/esm/shared-hooks/internals/tree-node-constants.js.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-types.d.ts +10 -0
- package/bin/esm/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-types.js +18 -0
- package/bin/esm/shared-hooks/internals/tree-node-types.js.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts +33 -0
- package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-utils.js +188 -0
- package/bin/esm/shared-hooks/internals/tree-node-utils.js.map +1 -0
- package/bin/esm/shared-hooks/useDynamicDDS.d.ts +23 -0
- package/bin/esm/shared-hooks/useDynamicDDS.d.ts.map +1 -0
- package/bin/{shared-hooks → esm/shared-hooks}/useDynamicDDS.js +20 -11
- package/bin/esm/shared-hooks/useDynamicDDS.js.map +1 -0
- package/bin/esm/shared-hooks/useSharedMap.d.ts +25 -0
- package/bin/esm/shared-hooks/useSharedMap.d.ts.map +1 -0
- package/bin/{shared-hooks → esm/shared-hooks}/useSharedMap.js +27 -13
- package/bin/esm/shared-hooks/useSharedMap.js.map +1 -0
- package/bin/esm/shared-hooks/useSharedState.d.ts +22 -0
- package/bin/esm/shared-hooks/useSharedState.d.ts.map +1 -0
- package/bin/{shared-hooks → esm/shared-hooks}/useSharedState.js +2 -2
- package/bin/esm/shared-hooks/useSharedState.js.map +1 -0
- package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts +37 -0
- package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
- package/bin/{shared-hooks → esm/shared-hooks}/useSharedStateRegistry.js +27 -19
- package/bin/esm/shared-hooks/useSharedStateRegistry.js.map +1 -0
- package/bin/esm/shared-hooks/useSharedTree.d.ts +57 -0
- package/bin/esm/shared-hooks/useSharedTree.d.ts.map +1 -0
- package/bin/esm/shared-hooks/useSharedTree.js +117 -0
- package/bin/esm/shared-hooks/useSharedTree.js.map +1 -0
- package/bin/esm/shared-hooks/useTreeNode.d.ts +96 -0
- package/bin/esm/shared-hooks/useTreeNode.d.ts.map +1 -0
- package/bin/esm/shared-hooks/useTreeNode.js +132 -0
- package/bin/esm/shared-hooks/useTreeNode.js.map +1 -0
- package/bin/esm/types/ActionTypes.d.ts +112 -0
- package/bin/esm/types/ActionTypes.d.ts.map +1 -0
- package/bin/esm/types/ActionTypes.js.map +1 -0
- package/bin/esm/types/PropTypes.d.ts +56 -0
- package/bin/esm/types/PropTypes.d.ts.map +1 -0
- package/bin/esm/types/PropTypes.js.map +1 -0
- package/bin/esm/types/ResultTypes.d.ts +330 -0
- package/bin/esm/types/ResultTypes.d.ts.map +1 -0
- package/bin/esm/types/ResultTypes.js.map +1 -0
- package/bin/esm/types/index.d.ts +4 -0
- package/bin/esm/types/index.d.ts.map +1 -0
- package/bin/esm/types/index.js +4 -0
- package/bin/esm/types/index.js.map +1 -0
- package/bin/esm/utils/index.d.ts +2 -0
- package/bin/esm/utils/index.d.ts.map +1 -0
- package/bin/esm/utils/index.js +2 -0
- package/bin/esm/utils/index.js.map +1 -0
- package/bin/esm/utils/type-check.d.ts +15 -0
- package/bin/esm/utils/type-check.d.ts.map +1 -0
- package/bin/esm/utils/type-check.js.map +1 -0
- package/package.json +61 -47
- package/src/index.ts +6 -6
- package/src/interfaces/index.ts +1 -1
- package/src/internal/index.ts +2 -2
- package/src/internal/type-guards.ts +1 -1
- package/src/live-hooks/index.ts +7 -7
- package/src/live-hooks/useLiveCanvas.ts +154 -82
- package/src/live-hooks/useLiveEvent.ts +43 -7
- package/src/live-hooks/useLiveFollowMode.ts +149 -6
- package/src/live-hooks/useLivePresence.ts +74 -17
- package/src/live-hooks/useLiveState.ts +49 -4
- package/src/live-hooks/useLiveTimer.ts +59 -4
- package/src/live-hooks/useMediaSynchronizer.ts +70 -5
- package/src/providers/AzureProvider.tsx +21 -21
- package/src/providers/LiveShareProvider.tsx +115 -13
- package/src/providers/index.ts +2 -2
- package/src/shared-hooks/index.ts +6 -4
- package/src/shared-hooks/internals/tree-node-constants.ts +2 -0
- package/src/shared-hooks/internals/tree-node-types.ts +26 -0
- package/src/shared-hooks/internals/tree-node-utils.ts +269 -0
- package/src/shared-hooks/useDynamicDDS.ts +28 -17
- package/src/shared-hooks/useSharedMap.ts +42 -17
- package/src/shared-hooks/useSharedState.ts +6 -3
- package/src/shared-hooks/useSharedStateRegistry.ts +44 -22
- package/src/shared-hooks/useSharedTree.ts +144 -0
- package/src/shared-hooks/useTreeNode.ts +147 -0
- package/src/types/ActionTypes.ts +13 -9
- package/src/types/PropTypes.ts +57 -0
- package/src/types/ResultTypes.ts +67 -17
- package/src/types/index.ts +3 -3
- package/src/utils/index.ts +1 -1
- package/tsconfig.cjs.json +14 -0
- package/tsconfig.json +65 -70
- package/bin/index.d.ts +0 -7
- package/bin/index.d.ts.map +0 -1
- package/bin/index.js +0 -7
- package/bin/index.js.map +0 -1
- package/bin/interfaces/LiveInterfaceExtensions.d.ts.map +0 -1
- package/bin/interfaces/LiveInterfaceExtensions.js.map +0 -1
- package/bin/interfaces/index.d.ts +0 -2
- package/bin/interfaces/index.d.ts.map +0 -1
- package/bin/interfaces/index.js +0 -2
- package/bin/interfaces/index.js.map +0 -1
- package/bin/internal/errors.d.ts.map +0 -1
- package/bin/internal/errors.js.map +0 -1
- package/bin/internal/index.d.ts +0 -3
- package/bin/internal/index.d.ts.map +0 -1
- package/bin/internal/index.js +0 -3
- package/bin/internal/index.js.map +0 -1
- package/bin/internal/type-guards.d.ts.map +0 -1
- package/bin/internal/type-guards.js.map +0 -1
- package/bin/live-hooks/index.d.ts +0 -8
- package/bin/live-hooks/index.d.ts.map +0 -1
- package/bin/live-hooks/index.js +0 -8
- package/bin/live-hooks/index.js.map +0 -1
- package/bin/live-hooks/useLiveCanvas.d.ts +0 -29
- package/bin/live-hooks/useLiveCanvas.d.ts.map +0 -1
- package/bin/live-hooks/useLiveCanvas.js +0 -160
- package/bin/live-hooks/useLiveCanvas.js.map +0 -1
- package/bin/live-hooks/useLiveEvent.d.ts.map +0 -1
- package/bin/live-hooks/useLiveEvent.js.map +0 -1
- package/bin/live-hooks/useLiveFollowMode.d.ts +0 -24
- package/bin/live-hooks/useLiveFollowMode.d.ts.map +0 -1
- package/bin/live-hooks/useLiveFollowMode.js.map +0 -1
- package/bin/live-hooks/useLivePresence.d.ts +0 -26
- package/bin/live-hooks/useLivePresence.d.ts.map +0 -1
- package/bin/live-hooks/useLivePresence.js.map +0 -1
- package/bin/live-hooks/useLiveState.d.ts.map +0 -1
- package/bin/live-hooks/useLiveState.js.map +0 -1
- package/bin/live-hooks/useLiveTimer.d.ts.map +0 -1
- package/bin/live-hooks/useLiveTimer.js.map +0 -1
- package/bin/live-hooks/useMediaSynchronizer.d.ts +0 -25
- package/bin/live-hooks/useMediaSynchronizer.d.ts.map +0 -1
- package/bin/live-hooks/useMediaSynchronizer.js.map +0 -1
- package/bin/providers/AzureProvider.d.ts.map +0 -1
- package/bin/providers/AzureProvider.js.map +0 -1
- package/bin/providers/LiveShareProvider.d.ts.map +0 -1
- package/bin/providers/LiveShareProvider.js.map +0 -1
- package/bin/providers/index.d.ts +0 -3
- package/bin/providers/index.d.ts.map +0 -1
- package/bin/providers/index.js +0 -3
- package/bin/providers/index.js.map +0 -1
- package/bin/shared-hooks/index.d.ts +0 -5
- package/bin/shared-hooks/index.d.ts.map +0 -1
- package/bin/shared-hooks/index.js +0 -5
- package/bin/shared-hooks/index.js.map +0 -1
- package/bin/shared-hooks/useDynamicDDS.d.ts.map +0 -1
- package/bin/shared-hooks/useDynamicDDS.js.map +0 -1
- package/bin/shared-hooks/useSharedMap.d.ts.map +0 -1
- package/bin/shared-hooks/useSharedMap.js.map +0 -1
- package/bin/shared-hooks/useSharedState.d.ts.map +0 -1
- package/bin/shared-hooks/useSharedState.js.map +0 -1
- package/bin/shared-hooks/useSharedStateRegistry.d.ts.map +0 -1
- package/bin/shared-hooks/useSharedStateRegistry.js.map +0 -1
- package/bin/types/ActionTypes.d.ts.map +0 -1
- package/bin/types/ActionTypes.js.map +0 -1
- package/bin/types/PropTypes.d.ts +0 -8
- package/bin/types/PropTypes.d.ts.map +0 -1
- package/bin/types/PropTypes.js.map +0 -1
- package/bin/types/ResultTypes.d.ts.map +0 -1
- package/bin/types/ResultTypes.js.map +0 -1
- package/bin/types/index.d.ts +0 -4
- package/bin/types/index.d.ts.map +0 -1
- package/bin/types/index.js +0 -4
- package/bin/types/index.js.map +0 -1
- package/bin/utils/index.d.ts +0 -2
- package/bin/utils/index.d.ts.map +0 -1
- package/bin/utils/index.js +0 -2
- package/bin/utils/index.js.map +0 -1
- package/bin/utils/type-check.d.ts.map +0 -1
- package/bin/utils/type-check.js.map +0 -1
- package/tsconfig.build.json +0 -6
- /package/bin/{interfaces → cjs/interfaces}/LiveInterfaceExtensions.d.ts +0 -0
- /package/bin/{internal → cjs/internal}/errors.d.ts +0 -0
- /package/bin/{utils → cjs/utils}/type-check.d.ts +0 -0
- /package/bin/{interfaces → esm/interfaces}/LiveInterfaceExtensions.js +0 -0
- /package/bin/{internal → esm/internal}/errors.js +0 -0
- /package/bin/{internal → esm/internal}/type-guards.js +0 -0
- /package/bin/{types → esm/types}/ActionTypes.js +0 -0
- /package/bin/{types → esm/types}/PropTypes.js +0 -0
- /package/bin/{types → esm/types}/ResultTypes.js +0 -0
- /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 =
|
|
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 =
|
|
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 {
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
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
|
|
94
|
+
export function useLivePresence<TData extends LivePresenceData = any>(
|
|
42
95
|
uniqueKey: string,
|
|
43
|
-
initialData
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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,
|