@microsoft/live-share-react 1.4.0-preview.0 → 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.
- 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/{internal → cjs/internal}/errors.d.ts +15 -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 +5 -0
- 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 +170 -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 +134 -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 +50 -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 +20 -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 +71 -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 +54 -5
- 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 +12 -12
- 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/esm/providers/LiveShareProvider.js +197 -0
- 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 +334 -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 -50
- package/src/index.ts +6 -6
- package/src/interfaces/index.ts +1 -1
- package/src/internal/errors.ts +16 -0
- package/src/internal/index.ts +2 -2
- package/src/internal/type-guards.ts +12 -0
- 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 +80 -17
- package/src/live-hooks/useLiveState.ts +54 -6
- 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 +126 -12
- 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 +71 -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/.nycrc.json +0 -10
- 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 +0 -8
- 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 +0 -87
- 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/{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/{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
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import { UserMeetingRole } from "@microsoft/live-share";
|
|
6
|
+
import { IUseLiveFollowModeResults } from "../types/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* React hook for using a Live Share `LiveFollowMode`.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Use this hook if you want to add the ability to follow specific users or let a user present to everyone in the session.
|
|
12
|
+
* Each user has their own `stateValue`, which is the value other users will reference when that user is presenting or being followed.
|
|
13
|
+
* The `state` response includes the user's `value` that the local user is "following", whether it be their own or someone else's.
|
|
14
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
15
|
+
*
|
|
16
|
+
* @template TData Optional typing for the custom user presence data object. Default is `object` type.
|
|
17
|
+
*
|
|
18
|
+
* @param uniqueKey The unique key for `LiveFollowMode`. If one does not yet exist, a new one will be created.
|
|
19
|
+
* @param initialData The initial value for the local user's `stateValue`.
|
|
20
|
+
* @param allowedRoles Optional. The user roles that are allowed to present to use `startPresenting()` or `stopPresenting()`.
|
|
21
|
+
* @returns `IUseLiveFollowModeResults` results, which contains React stateful objects and callbacks.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
```jsx
|
|
25
|
+
import { FollowModeType } from "@microsoft/live-share";
|
|
26
|
+
import { useLiveFollowMode } from "@microsoft/live-share-react";
|
|
27
|
+
// As an example, we will use a fake component to denote what a 3D viewer might look like in an app
|
|
28
|
+
import { Example3DModelViewer } from "./components";
|
|
29
|
+
|
|
30
|
+
// Define a unique key that differentiates this usage of `useLiveFollowMode` from others in your app
|
|
31
|
+
const MY_UNIQUE_KEY = "follow-mode-key";
|
|
32
|
+
|
|
33
|
+
// Define the initial stateValue for the local user (optional).
|
|
34
|
+
const startingCameraPosition = {
|
|
35
|
+
x: 0,
|
|
36
|
+
y: 0,
|
|
37
|
+
z: 0,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Example component for using useLiveFollowMode
|
|
41
|
+
export function MyLiveFollowMode() {
|
|
42
|
+
const {
|
|
43
|
+
state,
|
|
44
|
+
localUser,
|
|
45
|
+
otherUsers,
|
|
46
|
+
allUsers,
|
|
47
|
+
liveFollowMode,
|
|
48
|
+
update,
|
|
49
|
+
startPresenting,
|
|
50
|
+
stopPresenting,
|
|
51
|
+
beginSuspension,
|
|
52
|
+
endSuspension,
|
|
53
|
+
followUser,
|
|
54
|
+
stopFollowing,
|
|
55
|
+
} = useLiveFollowMode(MY_UNIQUE_KEY, startingCameraPosition);
|
|
56
|
+
|
|
57
|
+
// Example of an event listener for a camera position changed event.
|
|
58
|
+
// For something like a camera change event, you should use a debounce function.
|
|
59
|
+
function onCameraPositionChanged(position, isUserAction) {
|
|
60
|
+
// Broadcast change to other users so that they have their latest camera position
|
|
61
|
+
update(position);
|
|
62
|
+
// If the local user changed the position while following another user, we want to suspend.
|
|
63
|
+
// Note: helps to distinguish changes initiated by the local user (e.g., drag mouse) separately from other change events.
|
|
64
|
+
if (!isUserAction) return;
|
|
65
|
+
switch (state.type) {
|
|
66
|
+
case FollowModeType.followPresenter:
|
|
67
|
+
case FollowModeType.followUser: {
|
|
68
|
+
// This will trigger a "stateChanged" event update for the local user only.
|
|
69
|
+
followMode.beginSuspension();
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
default: {
|
|
73
|
+
// No need to suspend for other types
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Can optionally get the relevant user's presence object
|
|
80
|
+
const followingUser = liveFollowMode?.getUser(state.followingUserId);
|
|
81
|
+
|
|
82
|
+
// Render loading UI when creating LiveFollowMode instance for first time
|
|
83
|
+
if (!liveFollowMode) return <>Loading...</>;
|
|
84
|
+
|
|
85
|
+
// Render UI
|
|
86
|
+
return (
|
|
87
|
+
<div>
|
|
88
|
+
{state.type === FollowModeType.local && (
|
|
89
|
+
<div>
|
|
90
|
+
<p>{""}</p>
|
|
91
|
+
<button onClick={startPresenting}>
|
|
92
|
+
{"Start presenting"}
|
|
93
|
+
</button>
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
96
|
+
{state.type === FollowModeType.activeFollowers && (
|
|
97
|
+
<div>
|
|
98
|
+
<p>{`${state.otherUsersCount} users are following you`}</p>
|
|
99
|
+
<button onClick={startPresenting}>
|
|
100
|
+
{"Present to all"}
|
|
101
|
+
</button>
|
|
102
|
+
</div>
|
|
103
|
+
)}
|
|
104
|
+
{state.type === FollowModeType.activePresenter && (
|
|
105
|
+
<div>
|
|
106
|
+
<p>{`You are actively presenting to everyone`}</p>
|
|
107
|
+
<button onClick={stopPresenting}>
|
|
108
|
+
{"Stop presenting"}
|
|
109
|
+
</button>
|
|
110
|
+
</div>
|
|
111
|
+
)}
|
|
112
|
+
{state.type === FollowModeType.followPresenter && (
|
|
113
|
+
<div>
|
|
114
|
+
<p>{`${followingUser?.displayName} is presenting to everyone`}</p>
|
|
115
|
+
<button onClick={startPresenting}>{"Take control"}</button>
|
|
116
|
+
</div>
|
|
117
|
+
)}
|
|
118
|
+
{state.type === FollowModeType.suspendFollowPresenter && (
|
|
119
|
+
<div>
|
|
120
|
+
<p>{`${followingUser?.displayName} is presenting to everyone`}</p>
|
|
121
|
+
<button onClick={endSuspension}>
|
|
122
|
+
{"Sync to presenter"}
|
|
123
|
+
</button>
|
|
124
|
+
</div>
|
|
125
|
+
)}
|
|
126
|
+
{state.type === FollowModeType.followUser && (
|
|
127
|
+
<div>
|
|
128
|
+
<p>{`You are following ${followingUser?.displayName}`}</p>
|
|
129
|
+
<button onClick={stopFollowing}>{"Stop following"}</button>
|
|
130
|
+
</div>
|
|
131
|
+
)}
|
|
132
|
+
{state.type === FollowModeType.suspendFollowUser && (
|
|
133
|
+
<div>
|
|
134
|
+
<p>{`You were following ${followingUser?.displayName}`}</p>
|
|
135
|
+
<button onClick={stopFollowing}>
|
|
136
|
+
{"Resume following"}
|
|
137
|
+
</button>
|
|
138
|
+
</div>
|
|
139
|
+
)}
|
|
140
|
+
<div>
|
|
141
|
+
<p>{"Follow a specific user:"}</p>
|
|
142
|
+
{otherUsers.map((user) => (
|
|
143
|
+
<button
|
|
144
|
+
onClick={() => {
|
|
145
|
+
followUser(user.userId);
|
|
146
|
+
}}
|
|
147
|
+
key={user.userId}
|
|
148
|
+
>
|
|
149
|
+
{user.displayName}
|
|
150
|
+
</button>
|
|
151
|
+
))}
|
|
152
|
+
</div>
|
|
153
|
+
<Example3DModelViewer
|
|
154
|
+
cameraPosition={state.value}
|
|
155
|
+
onCameraPositionChanged={onCameraPositionChanged}
|
|
156
|
+
/>
|
|
157
|
+
</div>
|
|
158
|
+
);
|
|
159
|
+
};
|
|
160
|
+
```
|
|
161
|
+
*/
|
|
162
|
+
export declare function useLiveFollowMode<TData = any>(uniqueKey: string, initialData: TData | (() => TData), allowedRoles?: UserMeetingRole[]): IUseLiveFollowModeResults<TData>;
|
|
163
|
+
//# sourceMappingURL=useLiveFollowMode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLiveFollowMode.d.ts","sourceRoot":"","sources":["../../../src/live-hooks/useLiveFollowMode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,eAAe,EAKlB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0JG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,GAAG,GAAG,EACzC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,EAClC,YAAY,CAAC,EAAE,eAAe,EAAE,GACjC,yBAAyB,CAAC,KAAK,CAAC,CA+QlC"}
|
|
@@ -13,9 +13,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
};
|
|
14
14
|
import { LiveDataObjectInitializeState, LiveFollowMode, } from "@microsoft/live-share";
|
|
15
15
|
import React from "react";
|
|
16
|
-
import { useDynamicDDS } from "../shared-hooks";
|
|
17
|
-
import { useFluidObjectsContext } from "../providers";
|
|
18
|
-
import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, ActionLiveDataObjectUndefinedError, } from "../internal";
|
|
16
|
+
import { useDynamicDDS } from "../shared-hooks/index.js";
|
|
17
|
+
import { useFluidObjectsContext } from "../providers/index.js";
|
|
18
|
+
import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, ActionLiveDataObjectUndefinedError, } from "../internal/index.js";
|
|
19
19
|
/**
|
|
20
20
|
* React hook for using a Live Share `LiveFollowMode`.
|
|
21
21
|
*
|
|
@@ -31,6 +31,145 @@ import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, Ac
|
|
|
31
31
|
* @param initialData The initial value for the local user's `stateValue`.
|
|
32
32
|
* @param allowedRoles Optional. The user roles that are allowed to present to use `startPresenting()` or `stopPresenting()`.
|
|
33
33
|
* @returns `IUseLiveFollowModeResults` results, which contains React stateful objects and callbacks.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
```jsx
|
|
37
|
+
import { FollowModeType } from "@microsoft/live-share";
|
|
38
|
+
import { useLiveFollowMode } from "@microsoft/live-share-react";
|
|
39
|
+
// As an example, we will use a fake component to denote what a 3D viewer might look like in an app
|
|
40
|
+
import { Example3DModelViewer } from "./components";
|
|
41
|
+
|
|
42
|
+
// Define a unique key that differentiates this usage of `useLiveFollowMode` from others in your app
|
|
43
|
+
const MY_UNIQUE_KEY = "follow-mode-key";
|
|
44
|
+
|
|
45
|
+
// Define the initial stateValue for the local user (optional).
|
|
46
|
+
const startingCameraPosition = {
|
|
47
|
+
x: 0,
|
|
48
|
+
y: 0,
|
|
49
|
+
z: 0,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Example component for using useLiveFollowMode
|
|
53
|
+
export function MyLiveFollowMode() {
|
|
54
|
+
const {
|
|
55
|
+
state,
|
|
56
|
+
localUser,
|
|
57
|
+
otherUsers,
|
|
58
|
+
allUsers,
|
|
59
|
+
liveFollowMode,
|
|
60
|
+
update,
|
|
61
|
+
startPresenting,
|
|
62
|
+
stopPresenting,
|
|
63
|
+
beginSuspension,
|
|
64
|
+
endSuspension,
|
|
65
|
+
followUser,
|
|
66
|
+
stopFollowing,
|
|
67
|
+
} = useLiveFollowMode(MY_UNIQUE_KEY, startingCameraPosition);
|
|
68
|
+
|
|
69
|
+
// Example of an event listener for a camera position changed event.
|
|
70
|
+
// For something like a camera change event, you should use a debounce function.
|
|
71
|
+
function onCameraPositionChanged(position, isUserAction) {
|
|
72
|
+
// Broadcast change to other users so that they have their latest camera position
|
|
73
|
+
update(position);
|
|
74
|
+
// If the local user changed the position while following another user, we want to suspend.
|
|
75
|
+
// Note: helps to distinguish changes initiated by the local user (e.g., drag mouse) separately from other change events.
|
|
76
|
+
if (!isUserAction) return;
|
|
77
|
+
switch (state.type) {
|
|
78
|
+
case FollowModeType.followPresenter:
|
|
79
|
+
case FollowModeType.followUser: {
|
|
80
|
+
// This will trigger a "stateChanged" event update for the local user only.
|
|
81
|
+
followMode.beginSuspension();
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
default: {
|
|
85
|
+
// No need to suspend for other types
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Can optionally get the relevant user's presence object
|
|
92
|
+
const followingUser = liveFollowMode?.getUser(state.followingUserId);
|
|
93
|
+
|
|
94
|
+
// Render loading UI when creating LiveFollowMode instance for first time
|
|
95
|
+
if (!liveFollowMode) return <>Loading...</>;
|
|
96
|
+
|
|
97
|
+
// Render UI
|
|
98
|
+
return (
|
|
99
|
+
<div>
|
|
100
|
+
{state.type === FollowModeType.local && (
|
|
101
|
+
<div>
|
|
102
|
+
<p>{""}</p>
|
|
103
|
+
<button onClick={startPresenting}>
|
|
104
|
+
{"Start presenting"}
|
|
105
|
+
</button>
|
|
106
|
+
</div>
|
|
107
|
+
)}
|
|
108
|
+
{state.type === FollowModeType.activeFollowers && (
|
|
109
|
+
<div>
|
|
110
|
+
<p>{`${state.otherUsersCount} users are following you`}</p>
|
|
111
|
+
<button onClick={startPresenting}>
|
|
112
|
+
{"Present to all"}
|
|
113
|
+
</button>
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
{state.type === FollowModeType.activePresenter && (
|
|
117
|
+
<div>
|
|
118
|
+
<p>{`You are actively presenting to everyone`}</p>
|
|
119
|
+
<button onClick={stopPresenting}>
|
|
120
|
+
{"Stop presenting"}
|
|
121
|
+
</button>
|
|
122
|
+
</div>
|
|
123
|
+
)}
|
|
124
|
+
{state.type === FollowModeType.followPresenter && (
|
|
125
|
+
<div>
|
|
126
|
+
<p>{`${followingUser?.displayName} is presenting to everyone`}</p>
|
|
127
|
+
<button onClick={startPresenting}>{"Take control"}</button>
|
|
128
|
+
</div>
|
|
129
|
+
)}
|
|
130
|
+
{state.type === FollowModeType.suspendFollowPresenter && (
|
|
131
|
+
<div>
|
|
132
|
+
<p>{`${followingUser?.displayName} is presenting to everyone`}</p>
|
|
133
|
+
<button onClick={endSuspension}>
|
|
134
|
+
{"Sync to presenter"}
|
|
135
|
+
</button>
|
|
136
|
+
</div>
|
|
137
|
+
)}
|
|
138
|
+
{state.type === FollowModeType.followUser && (
|
|
139
|
+
<div>
|
|
140
|
+
<p>{`You are following ${followingUser?.displayName}`}</p>
|
|
141
|
+
<button onClick={stopFollowing}>{"Stop following"}</button>
|
|
142
|
+
</div>
|
|
143
|
+
)}
|
|
144
|
+
{state.type === FollowModeType.suspendFollowUser && (
|
|
145
|
+
<div>
|
|
146
|
+
<p>{`You were following ${followingUser?.displayName}`}</p>
|
|
147
|
+
<button onClick={stopFollowing}>
|
|
148
|
+
{"Resume following"}
|
|
149
|
+
</button>
|
|
150
|
+
</div>
|
|
151
|
+
)}
|
|
152
|
+
<div>
|
|
153
|
+
<p>{"Follow a specific user:"}</p>
|
|
154
|
+
{otherUsers.map((user) => (
|
|
155
|
+
<button
|
|
156
|
+
onClick={() => {
|
|
157
|
+
followUser(user.userId);
|
|
158
|
+
}}
|
|
159
|
+
key={user.userId}
|
|
160
|
+
>
|
|
161
|
+
{user.displayName}
|
|
162
|
+
</button>
|
|
163
|
+
))}
|
|
164
|
+
</div>
|
|
165
|
+
<Example3DModelViewer
|
|
166
|
+
cameraPosition={state.value}
|
|
167
|
+
onCameraPositionChanged={onCameraPositionChanged}
|
|
168
|
+
/>
|
|
169
|
+
</div>
|
|
170
|
+
);
|
|
171
|
+
};
|
|
172
|
+
```
|
|
34
173
|
*/
|
|
35
174
|
export function useLiveFollowMode(uniqueKey, initialData, allowedRoles) {
|
|
36
175
|
/**
|
|
@@ -48,11 +187,15 @@ export function useLiveFollowMode(uniqueKey, initialData, allowedRoles) {
|
|
|
48
187
|
/**
|
|
49
188
|
* User facing: list of non-local user's presence objects.
|
|
50
189
|
*/
|
|
51
|
-
const otherUsers =
|
|
190
|
+
const otherUsers = React.useMemo(() => {
|
|
191
|
+
return allUsers.filter((user) => !user.isLocalUser);
|
|
192
|
+
}, [allUsers]);
|
|
52
193
|
/**
|
|
53
194
|
* User facing: local user's presence object.
|
|
54
195
|
*/
|
|
55
|
-
const localUser =
|
|
196
|
+
const localUser = React.useMemo(() => {
|
|
197
|
+
return allUsers.find((user) => user.isLocalUser);
|
|
198
|
+
}, [allUsers]);
|
|
56
199
|
const { container } = useFluidObjectsContext();
|
|
57
200
|
/**
|
|
58
201
|
* User facing: callback to update the local user's custom data for their follow state.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLiveFollowMode.js","sourceRoot":"","sources":["../../../src/live-hooks/useLiveFollowMode.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;AAEH,OAAO,EAGH,6BAA6B,EAC7B,cAAc,GAGjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EACH,6BAA6B,EAC7B,oCAAoC,EACpC,kCAAkC,GACrC,MAAM,sBAAsB,CAAC;AAG9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0JG;AACH,MAAM,UAAU,iBAAiB,CAC7B,SAAiB,EACjB,WAAkC,EAClC,YAAgC;IAEhC;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,EAA2B,CAAC;IACpE;;OAEG;IACH,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAE5C,EAAE,CAAC,CAAC;IACN;;OAEG;IACH,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,aAAa,CACzC,SAAS,EACT,CAAA,cAAqB,CAAA,CACxB,CAAC;IAEF;;OAEG;IACH,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAClC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IA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AAc,CAAC,UAAU,CACrB,qBAAqB,CAAQ,WAAW,CAAC;gBACrC,CAAC,CAAC,WAAW,EAAE;gBACf,CAAC,CAAC,WAAW,EACjB,YAAY,CACf,CAAC;QACN,CAAC;QACD,iBAAiB,EAAE,CAAC;QACpB,cAAc,EAAE,CAAC;QAEjB,OAAO,GAAG,EAAE;YACR,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;YAC1D,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QACxD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,OAAO;QACH,KAAK;QACL,SAAS;QACT,UAAU;QACV,QAAQ;QACR,cAAc;QACd,MAAM;QACN,eAAe;QACf,cAAc;QACd,eAAe;QACf,aAAa;QACb,UAAU;QACV,aAAa;KAChB,CAAC;AACN,CAAC;AAED,SAAS,qBAAqB,CAAQ,KAAU;IAC5C,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import { UserMeetingRole, LivePresenceData } from "@microsoft/live-share";
|
|
6
|
+
import { IUseLivePresenceResults } from "../types/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* React hook for using a Live Share `LivePresence`.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Use this hook if you want to track presence for who is currently using this component, such as
|
|
12
|
+
* who is online or who is viewing a specific document. With presence, you can sent along any custom
|
|
13
|
+
* user data. This is useful for rendering a list of users, profile pictures, cursor positions, and more.
|
|
14
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
15
|
+
*
|
|
16
|
+
* @template TData Optional typing for the custom user presence data object. Default is `object` type.
|
|
17
|
+
* @param uniqueKey The unique key for `LivePresence`. If one does not yet exist, a new one will be created.
|
|
18
|
+
* @param initialData Initial presence data object for the user. Can be value or a function to get the value.
|
|
19
|
+
* @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
|
|
20
|
+
* will be created, otherwise it will use the existing one. Default value is ":<dds-default>"
|
|
21
|
+
* @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
|
|
22
|
+
* to update the local user's presence and the `LivePresence` Fluid object.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
```jsx
|
|
26
|
+
import { useLivePresence } from "@microsoft/live-share-react";
|
|
27
|
+
|
|
28
|
+
// Define a unique key that differentiates this usage of `useLivePresence` from others in your app
|
|
29
|
+
const MY_UNIQUE_KEY = "presence-key";
|
|
30
|
+
|
|
31
|
+
// Example component for using useLivePresence
|
|
32
|
+
export const MyCustomPresence = () => {
|
|
33
|
+
const {
|
|
34
|
+
allUsers,
|
|
35
|
+
localUser,
|
|
36
|
+
livePresence,
|
|
37
|
+
updatePresence,
|
|
38
|
+
} = useLivePresence(MY_UNIQUE_KEY, {
|
|
39
|
+
picture: "DEFAULT_PROFILE_PICTURE_URL",
|
|
40
|
+
readyToStart: false,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Callback to update the user's presence
|
|
44
|
+
const onToggleReady = () => {
|
|
45
|
+
updatePresence({
|
|
46
|
+
...localUser.data,
|
|
47
|
+
readyToStart: !localUser.data.readyToStart,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Render loading UI while loading LivePresence for first time
|
|
52
|
+
if (!livePresence) return <>Loading...</>;
|
|
53
|
+
|
|
54
|
+
// Render presence UI
|
|
55
|
+
return (
|
|
56
|
+
{allUsers.map((user) => (
|
|
57
|
+
<div key={user.userId}>
|
|
58
|
+
<div>
|
|
59
|
+
{user.displayName}
|
|
60
|
+
</div>
|
|
61
|
+
<div>
|
|
62
|
+
{`Ready: ${user.data.readyToStart}`}
|
|
63
|
+
</div>
|
|
64
|
+
{user.isLocalUser && (
|
|
65
|
+
<button onClick={onToggleReady}>
|
|
66
|
+
{"Toggle ready"}
|
|
67
|
+
</button>
|
|
68
|
+
)}
|
|
69
|
+
</div>
|
|
70
|
+
))}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
*/
|
|
75
|
+
export declare function useLivePresence<TData extends LivePresenceData = any>(uniqueKey: string, initialData: TData | (() => TData), allowedRoles?: UserMeetingRole[]): IUseLivePresenceResults<TData>;
|
|
76
|
+
//# sourceMappingURL=useLivePresence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLivePresence.d.ts","sourceRoot":"","sources":["../../../src/live-hooks/useLivePresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGH,eAAe,EAEf,gBAAgB,EAEnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,uBAAuB,EAE1B,MAAM,mBAAmB,CAAC;AAS3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,wBAAgB,eAAe,CAAC,KAAK,SAAS,gBAAgB,GAAG,GAAG,EAChE,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,EAClC,YAAY,CAAC,EAAE,eAAe,EAAE,GACjC,uBAAuB,CAAC,KAAK,CAAC,CAwGhC"}
|
|
@@ -11,11 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
|
-
import {
|
|
14
|
+
import { LivePresence, LiveDataObjectInitializeState, PresenceStatus, } from "@microsoft/live-share";
|
|
15
15
|
import React from "react";
|
|
16
|
-
import { useDynamicDDS } from "../shared-hooks";
|
|
17
|
-
import { useFluidObjectsContext } from "../providers";
|
|
18
|
-
import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, ActionLiveDataObjectUndefinedError, } from "../internal";
|
|
16
|
+
import { useDynamicDDS } from "../shared-hooks/index.js";
|
|
17
|
+
import { useFluidObjectsContext } from "../providers/index.js";
|
|
18
|
+
import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, ActionLiveDataObjectUndefinedError, } from "../internal/index.js";
|
|
19
19
|
/**
|
|
20
20
|
* React hook for using a Live Share `LivePresence`.
|
|
21
21
|
*
|
|
@@ -27,14 +27,64 @@ import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, Ac
|
|
|
27
27
|
*
|
|
28
28
|
* @template TData Optional typing for the custom user presence data object. Default is `object` type.
|
|
29
29
|
* @param uniqueKey The unique key for `LivePresence`. If one does not yet exist, a new one will be created.
|
|
30
|
-
* @param initialData
|
|
31
|
-
* @param initialPresenceState Optional. Initial status of the user's presence. Default is online.
|
|
30
|
+
* @param initialData Initial presence data object for the user. Can be value or a function to get the value.
|
|
32
31
|
* @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
|
|
33
32
|
* will be created, otherwise it will use the existing one. Default value is ":<dds-default>"
|
|
34
33
|
* @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
|
|
35
34
|
* to update the local user's presence and the `LivePresence` Fluid object.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
```jsx
|
|
38
|
+
import { useLivePresence } from "@microsoft/live-share-react";
|
|
39
|
+
|
|
40
|
+
// Define a unique key that differentiates this usage of `useLivePresence` from others in your app
|
|
41
|
+
const MY_UNIQUE_KEY = "presence-key";
|
|
42
|
+
|
|
43
|
+
// Example component for using useLivePresence
|
|
44
|
+
export const MyCustomPresence = () => {
|
|
45
|
+
const {
|
|
46
|
+
allUsers,
|
|
47
|
+
localUser,
|
|
48
|
+
livePresence,
|
|
49
|
+
updatePresence,
|
|
50
|
+
} = useLivePresence(MY_UNIQUE_KEY, {
|
|
51
|
+
picture: "DEFAULT_PROFILE_PICTURE_URL",
|
|
52
|
+
readyToStart: false,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Callback to update the user's presence
|
|
56
|
+
const onToggleReady = () => {
|
|
57
|
+
updatePresence({
|
|
58
|
+
...localUser.data,
|
|
59
|
+
readyToStart: !localUser.data.readyToStart,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Render loading UI while loading LivePresence for first time
|
|
64
|
+
if (!livePresence) return <>Loading...</>;
|
|
65
|
+
|
|
66
|
+
// Render presence UI
|
|
67
|
+
return (
|
|
68
|
+
{allUsers.map((user) => (
|
|
69
|
+
<div key={user.userId}>
|
|
70
|
+
<div>
|
|
71
|
+
{user.displayName}
|
|
72
|
+
</div>
|
|
73
|
+
<div>
|
|
74
|
+
{`Ready: ${user.data.readyToStart}`}
|
|
75
|
+
</div>
|
|
76
|
+
{user.isLocalUser && (
|
|
77
|
+
<button onClick={onToggleReady}>
|
|
78
|
+
{"Toggle ready"}
|
|
79
|
+
</button>
|
|
80
|
+
)}
|
|
81
|
+
</div>
|
|
82
|
+
))}
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
```
|
|
36
86
|
*/
|
|
37
|
-
export function useLivePresence(uniqueKey, initialData,
|
|
87
|
+
export function useLivePresence(uniqueKey, initialData, allowedRoles) {
|
|
38
88
|
/**
|
|
39
89
|
* Stateful all user presence list and its non-user-facing setter method.
|
|
40
90
|
*/
|
|
@@ -42,20 +92,27 @@ export function useLivePresence(uniqueKey, initialData, initialPresenceState = P
|
|
|
42
92
|
/**
|
|
43
93
|
* User facing: dynamically load the DDS for the given unique key.
|
|
44
94
|
*/
|
|
45
|
-
const { dds: livePresence } = useDynamicDDS(uniqueKey,
|
|
95
|
+
const { dds: livePresence } = useDynamicDDS(uniqueKey, LivePresence);
|
|
46
96
|
/**
|
|
47
97
|
* User facing: list of non-local user's presence objects.
|
|
48
98
|
*/
|
|
49
|
-
const otherUsers =
|
|
99
|
+
const otherUsers = React.useMemo(() => {
|
|
100
|
+
return allUsers.filter((user) => !user.isLocalUser);
|
|
101
|
+
}, [allUsers]);
|
|
50
102
|
/**
|
|
51
103
|
* User facing: local user's presence object.
|
|
52
104
|
*/
|
|
53
|
-
const localUser =
|
|
105
|
+
const localUser = React.useMemo(() => {
|
|
106
|
+
return allUsers.find((user) => user.isLocalUser);
|
|
107
|
+
}, [allUsers]);
|
|
108
|
+
const onlineUsers = React.useMemo(() => {
|
|
109
|
+
return allUsers.filter((user) => user.status === PresenceStatus.online);
|
|
110
|
+
}, [allUsers]);
|
|
54
111
|
const { container } = useFluidObjectsContext();
|
|
55
112
|
/**
|
|
56
113
|
* User facing: callback to update the local user's presence.
|
|
57
114
|
*/
|
|
58
|
-
const updatePresence = React.useCallback((data
|
|
115
|
+
const updatePresence = React.useCallback((data) => __awaiter(this, void 0, void 0, function* () {
|
|
59
116
|
if (!container) {
|
|
60
117
|
throw new ActionContainerNotJoinedError("livePresence", "updatePresence");
|
|
61
118
|
}
|
|
@@ -65,7 +122,7 @@ export function useLivePresence(uniqueKey, initialData, initialPresenceState = P
|
|
|
65
122
|
if (!livePresence.isInitialized) {
|
|
66
123
|
throw new ActionLiveDataObjectInitializedError("livePresence", "updatePresence");
|
|
67
124
|
}
|
|
68
|
-
return yield livePresence.update(data
|
|
125
|
+
return yield livePresence.update(data);
|
|
69
126
|
}), [container, livePresence]);
|
|
70
127
|
/**
|
|
71
128
|
* Setup change listeners and start `LivePresence` if needed
|
|
@@ -85,7 +142,7 @@ export function useLivePresence(uniqueKey, initialData, initialPresenceState = P
|
|
|
85
142
|
LiveDataObjectInitializeState.needed) {
|
|
86
143
|
livePresence.initialize(isInitialDataCallback(initialData)
|
|
87
144
|
? initialData()
|
|
88
|
-
: initialData,
|
|
145
|
+
: initialData, allowedRoles);
|
|
89
146
|
}
|
|
90
147
|
onPresenceChanged();
|
|
91
148
|
return () => {
|
|
@@ -96,6 +153,7 @@ export function useLivePresence(uniqueKey, initialData, initialPresenceState = P
|
|
|
96
153
|
localUser,
|
|
97
154
|
otherUsers,
|
|
98
155
|
allUsers,
|
|
156
|
+
onlineUsers,
|
|
99
157
|
livePresence,
|
|
100
158
|
updatePresence,
|
|
101
159
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLivePresence.js","sourceRoot":"","sources":["../../../src/live-hooks/useLivePresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;AAEH,OAAO,EAEH,YAAY,EAEZ,6BAA6B,EAE7B,cAAc,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EACH,6BAA6B,EAC7B,oCAAoC,EACpC,kCAAkC,GACrC,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,MAAM,UAAU,eAAe,CAC3B,SAAiB,EACjB,WAAkC,EAClC,YAAgC;IAEhC;;OAEG;IACH,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAC1C,EAAE,CACL,CAAC;IACF;;OAEG;IACH,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,aAAa,CACvC,SAAS,EACT,YAAY,CACf,CAAC;IAEF;;OAEG;IACH,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAClC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,WA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QAEvC,MAAM,iBAAiB,GAAG,GAAG,EAAE;YAC3B,MAAM,iBAAiB,GAA8B,EAAE,CAAC;YACxD,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACtC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjC,CAAC,CAAC,CAAC;YACH,WAAW,CAAC,iBAAiB,CAAC,CAAC;QACnC,CAAC,CAAC;QACF,YAAY,CAAC,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAEtD,IACI,YAAY,CAAC,eAAe;YAC5B,6BAA6B,CAAC,MAAM,EACtC,CAAC;YACC,YAAY,CAAC,UAAU,CACnB,qBAAqB,CAAQ,WAAW,CAAC;gBACrC,CAAC,CAAC,WAAW,EAAE;gBACf,CAAC,CAAC,WAAW,EACjB,YAAY,CACf,CAAC;QACN,CAAC;QACD,iBAAiB,EAAE,CAAC;QAEpB,OAAO,GAAG,EAAE;YACR,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAC5D,CAAC,CAAC;IACN,CAAC,EAAE,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"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import { LiveState, UserMeetingRole } from "@microsoft/live-share";
|
|
6
|
+
import { SetLiveStateAction } from "../types/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* React hook for using a Live Share `LiveState`.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Use this hook if you want to synchronize app state that will reset when all users leave the session.
|
|
12
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
13
|
+
*
|
|
14
|
+
* @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.
|
|
15
|
+
* @param initialState Optional. the initial state value of type TState
|
|
16
|
+
* @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
|
|
17
|
+
* @returns ordered values: first value is the synchronized state value and the second is a setter to change the state value.
|
|
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
|
+
```
|
|
64
|
+
*/
|
|
65
|
+
export declare function useLiveState<TState = any>(uniqueKey: string, initialState: TState, allowedRoles?: UserMeetingRole[]): [TState, SetLiveStateAction<TState>, LiveState<TState> | undefined];
|
|
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"}
|