@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
|
@@ -5,20 +5,24 @@
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
LivePresenceUser,
|
|
8
|
-
PresenceState,
|
|
9
8
|
LivePresence,
|
|
10
9
|
UserMeetingRole,
|
|
11
10
|
LiveDataObjectInitializeState,
|
|
11
|
+
LivePresenceData,
|
|
12
|
+
PresenceStatus,
|
|
12
13
|
} from "@microsoft/live-share";
|
|
13
14
|
import React from "react";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
import {
|
|
16
|
+
IUseLivePresenceResults,
|
|
17
|
+
OnUpdateLivePresenceAction,
|
|
18
|
+
} from "../types/index.js";
|
|
19
|
+
import { useDynamicDDS } from "../shared-hooks/index.js";
|
|
20
|
+
import { useFluidObjectsContext } from "../providers/index.js";
|
|
17
21
|
import {
|
|
18
22
|
ActionContainerNotJoinedError,
|
|
19
23
|
ActionLiveDataObjectInitializedError,
|
|
20
24
|
ActionLiveDataObjectUndefinedError,
|
|
21
|
-
} from "../internal";
|
|
25
|
+
} from "../internal/index.js";
|
|
22
26
|
|
|
23
27
|
/**
|
|
24
28
|
* React hook for using a Live Share `LivePresence`.
|
|
@@ -31,17 +35,66 @@ import {
|
|
|
31
35
|
*
|
|
32
36
|
* @template TData Optional typing for the custom user presence data object. Default is `object` type.
|
|
33
37
|
* @param uniqueKey The unique key for `LivePresence`. If one does not yet exist, a new one will be created.
|
|
34
|
-
* @param initialData
|
|
35
|
-
* @param initialPresenceState Optional. Initial status of the user's presence. Default is online.
|
|
38
|
+
* @param initialData Initial presence data object for the user. Can be value or a function to get the value.
|
|
36
39
|
* @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
|
|
37
40
|
* will be created, otherwise it will use the existing one. Default value is ":<dds-default>"
|
|
38
41
|
* @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
|
|
39
42
|
* to update the local user's presence and the `LivePresence` Fluid object.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
```jsx
|
|
46
|
+
import { useLivePresence } from "@microsoft/live-share-react";
|
|
47
|
+
|
|
48
|
+
// Define a unique key that differentiates this usage of `useLivePresence` from others in your app
|
|
49
|
+
const MY_UNIQUE_KEY = "presence-key";
|
|
50
|
+
|
|
51
|
+
// Example component for using useLivePresence
|
|
52
|
+
export const MyCustomPresence = () => {
|
|
53
|
+
const {
|
|
54
|
+
allUsers,
|
|
55
|
+
localUser,
|
|
56
|
+
livePresence,
|
|
57
|
+
updatePresence,
|
|
58
|
+
} = useLivePresence(MY_UNIQUE_KEY, {
|
|
59
|
+
picture: "DEFAULT_PROFILE_PICTURE_URL",
|
|
60
|
+
readyToStart: false,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Callback to update the user's presence
|
|
64
|
+
const onToggleReady = () => {
|
|
65
|
+
updatePresence({
|
|
66
|
+
...localUser.data,
|
|
67
|
+
readyToStart: !localUser.data.readyToStart,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Render loading UI while loading LivePresence for first time
|
|
72
|
+
if (!livePresence) return <>Loading...</>;
|
|
73
|
+
|
|
74
|
+
// Render presence UI
|
|
75
|
+
return (
|
|
76
|
+
{allUsers.map((user) => (
|
|
77
|
+
<div key={user.userId}>
|
|
78
|
+
<div>
|
|
79
|
+
{user.displayName}
|
|
80
|
+
</div>
|
|
81
|
+
<div>
|
|
82
|
+
{`Ready: ${user.data.readyToStart}`}
|
|
83
|
+
</div>
|
|
84
|
+
{user.isLocalUser && (
|
|
85
|
+
<button onClick={onToggleReady}>
|
|
86
|
+
{"Toggle ready"}
|
|
87
|
+
</button>
|
|
88
|
+
)}
|
|
89
|
+
</div>
|
|
90
|
+
))}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
40
94
|
*/
|
|
41
|
-
export function useLivePresence<TData extends
|
|
95
|
+
export function useLivePresence<TData extends LivePresenceData = any>(
|
|
42
96
|
uniqueKey: string,
|
|
43
|
-
initialData
|
|
44
|
-
initialPresenceState: PresenceState = PresenceState.online,
|
|
97
|
+
initialData: TData | (() => TData),
|
|
45
98
|
allowedRoles?: UserMeetingRole[]
|
|
46
99
|
): IUseLivePresenceResults<TData> {
|
|
47
100
|
/**
|
|
@@ -55,18 +108,26 @@ export function useLivePresence<TData extends object = object>(
|
|
|
55
108
|
*/
|
|
56
109
|
const { dds: livePresence } = useDynamicDDS<LivePresence<TData>>(
|
|
57
110
|
uniqueKey,
|
|
58
|
-
LivePresence
|
|
111
|
+
LivePresence
|
|
59
112
|
);
|
|
60
113
|
|
|
61
114
|
/**
|
|
62
115
|
* User facing: list of non-local user's presence objects.
|
|
63
116
|
*/
|
|
64
|
-
const otherUsers =
|
|
117
|
+
const otherUsers = React.useMemo(() => {
|
|
118
|
+
return allUsers.filter((user) => !user.isLocalUser);
|
|
119
|
+
}, [allUsers]);
|
|
65
120
|
|
|
66
121
|
/**
|
|
67
122
|
* User facing: local user's presence object.
|
|
68
123
|
*/
|
|
69
|
-
const localUser =
|
|
124
|
+
const localUser = React.useMemo(() => {
|
|
125
|
+
return allUsers.find((user) => user.isLocalUser);
|
|
126
|
+
}, [allUsers]);
|
|
127
|
+
|
|
128
|
+
const onlineUsers = React.useMemo(() => {
|
|
129
|
+
return allUsers.filter((user) => user.status === PresenceStatus.online);
|
|
130
|
+
}, [allUsers]);
|
|
70
131
|
|
|
71
132
|
const { container } = useFluidObjectsContext();
|
|
72
133
|
|
|
@@ -74,7 +135,7 @@ export function useLivePresence<TData extends object = object>(
|
|
|
74
135
|
* User facing: callback to update the local user's presence.
|
|
75
136
|
*/
|
|
76
137
|
const updatePresence: OnUpdateLivePresenceAction<TData> = React.useCallback(
|
|
77
|
-
async (data
|
|
138
|
+
async (data: TData) => {
|
|
78
139
|
if (!container) {
|
|
79
140
|
throw new ActionContainerNotJoinedError(
|
|
80
141
|
"livePresence",
|
|
@@ -93,7 +154,7 @@ export function useLivePresence<TData extends object = object>(
|
|
|
93
154
|
"updatePresence"
|
|
94
155
|
);
|
|
95
156
|
}
|
|
96
|
-
return await livePresence.update(data
|
|
157
|
+
return await livePresence.update(data);
|
|
97
158
|
},
|
|
98
159
|
[container, livePresence]
|
|
99
160
|
);
|
|
@@ -121,7 +182,6 @@ export function useLivePresence<TData extends object = object>(
|
|
|
121
182
|
isInitialDataCallback<TData>(initialData)
|
|
122
183
|
? initialData()
|
|
123
184
|
: initialData,
|
|
124
|
-
initialPresenceState,
|
|
125
185
|
allowedRoles
|
|
126
186
|
);
|
|
127
187
|
}
|
|
@@ -136,11 +196,14 @@ export function useLivePresence<TData extends object = object>(
|
|
|
136
196
|
localUser,
|
|
137
197
|
otherUsers,
|
|
138
198
|
allUsers,
|
|
199
|
+
onlineUsers,
|
|
139
200
|
livePresence,
|
|
140
201
|
updatePresence,
|
|
141
202
|
};
|
|
142
203
|
}
|
|
143
204
|
|
|
144
|
-
function isInitialDataCallback<TData
|
|
205
|
+
function isInitialDataCallback<TData extends LivePresenceData>(
|
|
206
|
+
value: any
|
|
207
|
+
): value is () => TData {
|
|
145
208
|
return typeof value === "function";
|
|
146
209
|
}
|
|
@@ -9,15 +9,15 @@ import {
|
|
|
9
9
|
UserMeetingRole,
|
|
10
10
|
} from "@microsoft/live-share";
|
|
11
11
|
import React from "react";
|
|
12
|
-
import { SetLiveStateAction } from "../types";
|
|
13
|
-
import { useDynamicDDS } from "../shared-hooks";
|
|
14
|
-
import { useFluidObjectsContext } from "../providers";
|
|
12
|
+
import { SetLiveStateAction } from "../types/index.js";
|
|
13
|
+
import { useDynamicDDS } from "../shared-hooks/index.js";
|
|
14
|
+
import { useFluidObjectsContext } from "../providers/index.js";
|
|
15
15
|
import {
|
|
16
16
|
ActionContainerNotJoinedError,
|
|
17
17
|
ActionLiveDataObjectInitializedError,
|
|
18
18
|
ActionLiveDataObjectUndefinedError,
|
|
19
19
|
isPrevStateCallback,
|
|
20
|
-
} from "../internal";
|
|
20
|
+
} from "../internal/index.js";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* React hook for using a Live Share `LiveState`.
|
|
@@ -31,6 +31,51 @@ import {
|
|
|
31
31
|
* @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
|
|
32
32
|
* @returns ordered values: first value is the synchronized state value and the second is a setter to change the state value.
|
|
33
33
|
* The setter returns a void promise, which will throw if the user does not have the required roles to set.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
```jsx
|
|
37
|
+
import { useLiveState } from "@microsoft/live-share-react";
|
|
38
|
+
|
|
39
|
+
const planets = [
|
|
40
|
+
"Mercury",
|
|
41
|
+
"Venus",
|
|
42
|
+
"Earth",
|
|
43
|
+
"Mars",
|
|
44
|
+
"Jupiter",
|
|
45
|
+
"Saturn",
|
|
46
|
+
"Uranus",
|
|
47
|
+
"Neptune",
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
// Define a unique key that differentiates this usage of `useLiveState` from others in your app
|
|
51
|
+
const MY_UNIQUE_KEY = "selected-planet-key";
|
|
52
|
+
|
|
53
|
+
// Example component for using useLiveState
|
|
54
|
+
export const MyCustomState = () => {
|
|
55
|
+
const [planet, setPlanet, liveState] = useLiveState(MY_UNIQUE_KEY, planets[0]);
|
|
56
|
+
|
|
57
|
+
// Render loading UI when creating LiveState instance for first time
|
|
58
|
+
if (!liveState) return <>Loading...</>;
|
|
59
|
+
|
|
60
|
+
// Render UI
|
|
61
|
+
return (
|
|
62
|
+
<div>
|
|
63
|
+
{`Current planet: ${planet}`}
|
|
64
|
+
{"Select a planet below:"}
|
|
65
|
+
{planets.map((planet) => (
|
|
66
|
+
<button
|
|
67
|
+
key={planet}
|
|
68
|
+
onClick={() => {
|
|
69
|
+
setPlanet(planet);
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
{planet}
|
|
73
|
+
</button>
|
|
74
|
+
))}
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
```
|
|
34
79
|
*/
|
|
35
80
|
export function useLiveState<TState = any>(
|
|
36
81
|
uniqueKey: string,
|
|
@@ -95,9 +140,12 @@ export function useLiveState<TState = any>(
|
|
|
95
140
|
if (
|
|
96
141
|
liveState.initializeState === LiveDataObjectInitializeState.needed
|
|
97
142
|
) {
|
|
98
|
-
liveState
|
|
143
|
+
liveState
|
|
144
|
+
.initialize(initialState, allowedRoles)
|
|
145
|
+
.then(() => onStateChanged(liveState.state));
|
|
146
|
+
} else {
|
|
147
|
+
onStateChanged(liveState.state);
|
|
99
148
|
}
|
|
100
|
-
onStateChanged(liveState.state);
|
|
101
149
|
|
|
102
150
|
return () => {
|
|
103
151
|
liveState?.off("stateChanged", onStateChanged);
|
|
@@ -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,
|
|
@@ -3,21 +3,19 @@
|
|
|
3
3
|
* Licensed under the Microsoft Live Share SDK License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { ContainerSchema, IFluidContainer } from "fluid-framework";
|
|
7
7
|
import React from "react";
|
|
8
8
|
import {
|
|
9
9
|
AzureClientProps,
|
|
10
10
|
AzureContainerServices,
|
|
11
11
|
} from "@fluidframework/azure-client";
|
|
12
|
-
import { IAzureContainerResults } from "../types";
|
|
12
|
+
import { IAzureContainerResults } from "../types/index.js";
|
|
13
13
|
import {
|
|
14
14
|
ISharedStateRegistryResponse,
|
|
15
15
|
useSharedStateRegistry,
|
|
16
|
-
} from "../shared-hooks";
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
IFluidTurboClient,
|
|
20
|
-
} from "@microsoft/live-share-turbo";
|
|
16
|
+
} from "../shared-hooks/index.js";
|
|
17
|
+
import { AzureLiveShareClient } from "@microsoft/live-share";
|
|
18
|
+
import { BaseLiveShareClient } from "@microsoft/live-share/internal";
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
21
|
* React Context provider values for `<AzureProvider>` and `<LiveShareProvider>`.
|
|
@@ -29,7 +27,7 @@ export interface IFluidContext extends ISharedStateRegistryResponse {
|
|
|
29
27
|
/**
|
|
30
28
|
* The Fluid Turbo client used for connecting to the Fluid container.
|
|
31
29
|
*/
|
|
32
|
-
clientRef: React.MutableRefObject<
|
|
30
|
+
clientRef: React.MutableRefObject<BaseLiveShareClient>;
|
|
33
31
|
/**
|
|
34
32
|
* Stateful Fluid container.
|
|
35
33
|
*/
|
|
@@ -54,7 +52,7 @@ export interface IFluidContext extends ISharedStateRegistryResponse {
|
|
|
54
52
|
*/
|
|
55
53
|
getContainer: (
|
|
56
54
|
containerId: string,
|
|
57
|
-
|
|
55
|
+
fluidContainerSchema?: ContainerSchema
|
|
58
56
|
) => Promise<IAzureContainerResults>;
|
|
59
57
|
/**
|
|
60
58
|
* React callback function to create and connect to a new Fluid container.
|
|
@@ -67,7 +65,7 @@ export interface IFluidContext extends ISharedStateRegistryResponse {
|
|
|
67
65
|
* @returns promise that returns a results object once complete (e.g., container, services, etc.)
|
|
68
66
|
*/
|
|
69
67
|
createContainer: (
|
|
70
|
-
|
|
68
|
+
fluidContainerSchema?: ContainerSchema,
|
|
71
69
|
onInitializeContainer?: (container: IFluidContainer) => void
|
|
72
70
|
) => Promise<IAzureContainerResults>;
|
|
73
71
|
}
|
|
@@ -125,9 +123,9 @@ export interface IAzureProviderProps {
|
|
|
125
123
|
*/
|
|
126
124
|
createOnLoad?: boolean;
|
|
127
125
|
/**
|
|
128
|
-
* The initial
|
|
126
|
+
* The initial schema to use when {@link joinOnLoad} or {@link createOnLoad} is true.
|
|
129
127
|
*/
|
|
130
|
-
|
|
128
|
+
fluidContainerSchema?: ContainerSchema;
|
|
131
129
|
/**
|
|
132
130
|
* Flag to control whether or not to connect to an existing container on first mount.
|
|
133
131
|
*
|
|
@@ -142,8 +140,8 @@ export interface IAzureProviderProps {
|
|
|
142
140
|
*/
|
|
143
141
|
export const AzureProvider: React.FC<IAzureProviderProps> = (props) => {
|
|
144
142
|
const startedRef = React.useRef<boolean>(false);
|
|
145
|
-
const clientRef = React.useRef<
|
|
146
|
-
new
|
|
143
|
+
const clientRef = React.useRef<AzureLiveShareClient>(
|
|
144
|
+
new AzureLiveShareClient(props.clientOptions)
|
|
147
145
|
);
|
|
148
146
|
const [results, setResults] = React.useState<
|
|
149
147
|
IAzureContainerResults | undefined
|
|
@@ -158,14 +156,14 @@ export const AzureProvider: React.FC<IAzureProviderProps> = (props) => {
|
|
|
158
156
|
const getContainer = React.useCallback(
|
|
159
157
|
async (
|
|
160
158
|
containerId: string,
|
|
161
|
-
|
|
159
|
+
fluidContainerSchema?: ContainerSchema
|
|
162
160
|
): Promise<IAzureContainerResults> => {
|
|
163
161
|
return new Promise(async (resolve, reject) => {
|
|
164
162
|
try {
|
|
165
163
|
const results: IAzureContainerResults =
|
|
166
164
|
await clientRef.current.getContainer(
|
|
167
165
|
containerId,
|
|
168
|
-
|
|
166
|
+
fluidContainerSchema
|
|
169
167
|
);
|
|
170
168
|
setResults(results);
|
|
171
169
|
resolve(results);
|
|
@@ -185,13 +183,15 @@ export const AzureProvider: React.FC<IAzureProviderProps> = (props) => {
|
|
|
185
183
|
*/
|
|
186
184
|
const createContainer = React.useCallback(
|
|
187
185
|
async (
|
|
188
|
-
|
|
186
|
+
fluidContainerSchema?: ContainerSchema,
|
|
189
187
|
onInitializeContainer?: (container: IFluidContainer) => void
|
|
190
188
|
): Promise<IAzureContainerResults> => {
|
|
191
189
|
return new Promise(async (resolve, reject) => {
|
|
192
190
|
try {
|
|
193
191
|
const results: IAzureContainerResults =
|
|
194
|
-
await clientRef.current.createContainer(
|
|
192
|
+
await clientRef.current.createContainer(
|
|
193
|
+
fluidContainerSchema
|
|
194
|
+
);
|
|
195
195
|
if (onInitializeContainer) {
|
|
196
196
|
onInitializeContainer(results.container);
|
|
197
197
|
}
|
|
@@ -225,16 +225,16 @@ export const AzureProvider: React.FC<IAzureProviderProps> = (props) => {
|
|
|
225
225
|
return;
|
|
226
226
|
startedRef.current = true;
|
|
227
227
|
if (props.containerId && props.joinOnLoad) {
|
|
228
|
-
getContainer(props.containerId, props.
|
|
228
|
+
getContainer(props.containerId, props.fluidContainerSchema);
|
|
229
229
|
} else if (!props.containerId && props.createOnLoad) {
|
|
230
|
-
createContainer(props.
|
|
230
|
+
createContainer(props.fluidContainerSchema);
|
|
231
231
|
}
|
|
232
232
|
}, [
|
|
233
233
|
results?.container?.connectionState,
|
|
234
234
|
props.containerId,
|
|
235
235
|
props.createOnLoad,
|
|
236
236
|
props.joinOnLoad,
|
|
237
|
-
props.
|
|
237
|
+
props.fluidContainerSchema,
|
|
238
238
|
getContainer,
|
|
239
239
|
createContainer,
|
|
240
240
|
]);
|