@microsoft/live-share-react 2.0.0-internal.1 → 2.0.0-internal.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +64 -61
- package/README.md +173 -168
- package/bin/cjs/index.d.ts +7 -0
- package/bin/cjs/index.d.ts.map +1 -0
- package/bin/cjs/index.js +23 -0
- package/bin/cjs/index.js.map +1 -0
- package/bin/cjs/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
- package/bin/cjs/interfaces/LiveInterfaceExtensions.js +7 -0
- package/bin/cjs/interfaces/LiveInterfaceExtensions.js.map +1 -0
- package/bin/cjs/interfaces/index.d.ts +2 -0
- package/bin/cjs/interfaces/index.d.ts.map +1 -0
- package/bin/cjs/interfaces/index.js +18 -0
- package/bin/cjs/interfaces/index.js.map +1 -0
- package/bin/cjs/internal/errors.d.ts.map +1 -0
- package/bin/cjs/internal/errors.js +48 -0
- package/bin/cjs/internal/errors.js.map +1 -0
- package/bin/cjs/internal/index.d.ts +3 -0
- package/bin/cjs/internal/index.d.ts.map +1 -0
- package/bin/cjs/internal/index.js +19 -0
- package/bin/cjs/internal/index.js.map +1 -0
- package/bin/{internal → cjs/internal}/type-guards.d.ts +1 -1
- package/bin/cjs/internal/type-guards.d.ts.map +1 -0
- package/bin/cjs/internal/type-guards.js +24 -0
- package/bin/cjs/internal/type-guards.js.map +1 -0
- package/bin/cjs/live-hooks/index.d.ts +8 -0
- package/bin/cjs/live-hooks/index.d.ts.map +1 -0
- package/bin/cjs/live-hooks/index.js +24 -0
- package/bin/cjs/live-hooks/index.js.map +1 -0
- package/bin/cjs/live-hooks/useLiveCanvas.d.ts +80 -0
- package/bin/cjs/live-hooks/useLiveCanvas.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLiveCanvas.js +244 -0
- package/bin/cjs/live-hooks/useLiveCanvas.js.map +1 -0
- package/bin/{live-hooks → cjs/live-hooks}/useLiveEvent.d.ts +37 -1
- package/bin/cjs/live-hooks/useLiveEvent.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLiveEvent.js +150 -0
- package/bin/cjs/live-hooks/useLiveEvent.js.map +1 -0
- package/bin/cjs/live-hooks/useLiveFollowMode.d.ts +163 -0
- package/bin/cjs/live-hooks/useLiveFollowMode.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLiveFollowMode.js +360 -0
- package/bin/cjs/live-hooks/useLiveFollowMode.js.map +1 -0
- package/bin/cjs/live-hooks/useLivePresence.d.ts +76 -0
- package/bin/cjs/live-hooks/useLivePresence.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLivePresence.js +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.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 +66 -5
- package/bin/esm/live-hooks/useMediaSynchronizer.js.map +1 -0
- package/bin/esm/providers/AzureProvider.d.ts +113 -0
- package/bin/esm/providers/AzureProvider.d.ts.map +1 -0
- package/bin/{providers → esm/providers}/AzureProvider.js +10 -10
- package/bin/esm/providers/AzureProvider.js.map +1 -0
- package/bin/esm/providers/LiveShareProvider.d.ts +193 -0
- package/bin/esm/providers/LiveShareProvider.d.ts.map +1 -0
- package/bin/{providers → esm/providers}/LiveShareProvider.js +111 -9
- package/bin/esm/providers/LiveShareProvider.js.map +1 -0
- package/bin/esm/providers/index.d.ts +3 -0
- package/bin/esm/providers/index.d.ts.map +1 -0
- package/bin/esm/providers/index.js +3 -0
- package/bin/esm/providers/index.js.map +1 -0
- package/bin/esm/shared-hooks/index.d.ts +7 -0
- package/bin/esm/shared-hooks/index.d.ts.map +1 -0
- package/bin/esm/shared-hooks/index.js +7 -0
- package/bin/esm/shared-hooks/index.js.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts +3 -0
- package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-constants.js +3 -0
- package/bin/esm/shared-hooks/internals/tree-node-constants.js.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-types.d.ts +10 -0
- package/bin/esm/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-types.js +18 -0
- package/bin/esm/shared-hooks/internals/tree-node-types.js.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts +33 -0
- package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-utils.js +188 -0
- package/bin/esm/shared-hooks/internals/tree-node-utils.js.map +1 -0
- package/bin/esm/shared-hooks/useDynamicDDS.d.ts +23 -0
- package/bin/esm/shared-hooks/useDynamicDDS.d.ts.map +1 -0
- package/bin/{shared-hooks → esm/shared-hooks}/useDynamicDDS.js +20 -11
- package/bin/esm/shared-hooks/useDynamicDDS.js.map +1 -0
- package/bin/esm/shared-hooks/useSharedMap.d.ts +25 -0
- package/bin/esm/shared-hooks/useSharedMap.d.ts.map +1 -0
- package/bin/{shared-hooks → esm/shared-hooks}/useSharedMap.js +27 -13
- package/bin/esm/shared-hooks/useSharedMap.js.map +1 -0
- package/bin/esm/shared-hooks/useSharedState.d.ts +22 -0
- package/bin/esm/shared-hooks/useSharedState.d.ts.map +1 -0
- package/bin/{shared-hooks → esm/shared-hooks}/useSharedState.js +2 -2
- package/bin/esm/shared-hooks/useSharedState.js.map +1 -0
- package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts +37 -0
- package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
- package/bin/{shared-hooks → esm/shared-hooks}/useSharedStateRegistry.js +27 -19
- package/bin/esm/shared-hooks/useSharedStateRegistry.js.map +1 -0
- package/bin/esm/shared-hooks/useSharedTree.d.ts +57 -0
- package/bin/esm/shared-hooks/useSharedTree.d.ts.map +1 -0
- package/bin/esm/shared-hooks/useSharedTree.js +117 -0
- package/bin/esm/shared-hooks/useSharedTree.js.map +1 -0
- package/bin/esm/shared-hooks/useTreeNode.d.ts +96 -0
- package/bin/esm/shared-hooks/useTreeNode.d.ts.map +1 -0
- package/bin/esm/shared-hooks/useTreeNode.js +132 -0
- package/bin/esm/shared-hooks/useTreeNode.js.map +1 -0
- package/bin/esm/types/ActionTypes.d.ts +112 -0
- package/bin/esm/types/ActionTypes.d.ts.map +1 -0
- package/bin/esm/types/ActionTypes.js.map +1 -0
- package/bin/esm/types/PropTypes.d.ts +56 -0
- package/bin/esm/types/PropTypes.d.ts.map +1 -0
- package/bin/esm/types/PropTypes.js.map +1 -0
- package/bin/esm/types/ResultTypes.d.ts +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 -47
- package/src/index.ts +6 -6
- package/src/interfaces/index.ts +1 -1
- package/src/internal/index.ts +2 -2
- package/src/internal/type-guards.ts +1 -1
- package/src/live-hooks/index.ts +7 -7
- package/src/live-hooks/useLiveCanvas.ts +154 -82
- package/src/live-hooks/useLiveEvent.ts +43 -7
- package/src/live-hooks/useLiveFollowMode.ts +149 -6
- package/src/live-hooks/useLivePresence.ts +80 -17
- package/src/live-hooks/useLiveState.ts +54 -6
- package/src/live-hooks/useLiveTimer.ts +59 -4
- package/src/live-hooks/useMediaSynchronizer.ts +71 -6
- package/src/providers/AzureProvider.tsx +21 -21
- package/src/providers/LiveShareProvider.tsx +115 -13
- package/src/providers/index.ts +2 -2
- package/src/shared-hooks/index.ts +6 -4
- package/src/shared-hooks/internals/tree-node-constants.ts +2 -0
- package/src/shared-hooks/internals/tree-node-types.ts +26 -0
- package/src/shared-hooks/internals/tree-node-utils.ts +269 -0
- package/src/shared-hooks/useDynamicDDS.ts +28 -17
- package/src/shared-hooks/useSharedMap.ts +42 -17
- package/src/shared-hooks/useSharedState.ts +6 -3
- package/src/shared-hooks/useSharedStateRegistry.ts +44 -22
- package/src/shared-hooks/useSharedTree.ts +144 -0
- package/src/shared-hooks/useTreeNode.ts +147 -0
- package/src/types/ActionTypes.ts +13 -9
- package/src/types/PropTypes.ts +57 -0
- package/src/types/ResultTypes.ts +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.map +0 -1
- package/bin/live-hooks/index.d.ts +0 -8
- package/bin/live-hooks/index.d.ts.map +0 -1
- package/bin/live-hooks/index.js +0 -8
- package/bin/live-hooks/index.js.map +0 -1
- package/bin/live-hooks/useLiveCanvas.d.ts +0 -29
- package/bin/live-hooks/useLiveCanvas.d.ts.map +0 -1
- package/bin/live-hooks/useLiveCanvas.js +0 -160
- package/bin/live-hooks/useLiveCanvas.js.map +0 -1
- package/bin/live-hooks/useLiveEvent.d.ts.map +0 -1
- package/bin/live-hooks/useLiveEvent.js.map +0 -1
- package/bin/live-hooks/useLiveFollowMode.d.ts +0 -24
- package/bin/live-hooks/useLiveFollowMode.d.ts.map +0 -1
- package/bin/live-hooks/useLiveFollowMode.js.map +0 -1
- package/bin/live-hooks/useLivePresence.d.ts +0 -26
- package/bin/live-hooks/useLivePresence.d.ts.map +0 -1
- package/bin/live-hooks/useLivePresence.js.map +0 -1
- package/bin/live-hooks/useLiveState.d.ts.map +0 -1
- package/bin/live-hooks/useLiveState.js.map +0 -1
- package/bin/live-hooks/useLiveTimer.d.ts.map +0 -1
- package/bin/live-hooks/useLiveTimer.js.map +0 -1
- package/bin/live-hooks/useMediaSynchronizer.d.ts +0 -25
- package/bin/live-hooks/useMediaSynchronizer.d.ts.map +0 -1
- package/bin/live-hooks/useMediaSynchronizer.js.map +0 -1
- package/bin/providers/AzureProvider.d.ts.map +0 -1
- package/bin/providers/AzureProvider.js.map +0 -1
- package/bin/providers/LiveShareProvider.d.ts.map +0 -1
- package/bin/providers/LiveShareProvider.js.map +0 -1
- package/bin/providers/index.d.ts +0 -3
- package/bin/providers/index.d.ts.map +0 -1
- package/bin/providers/index.js +0 -3
- package/bin/providers/index.js.map +0 -1
- package/bin/shared-hooks/index.d.ts +0 -5
- package/bin/shared-hooks/index.d.ts.map +0 -1
- package/bin/shared-hooks/index.js +0 -5
- package/bin/shared-hooks/index.js.map +0 -1
- package/bin/shared-hooks/useDynamicDDS.d.ts.map +0 -1
- package/bin/shared-hooks/useDynamicDDS.js.map +0 -1
- package/bin/shared-hooks/useSharedMap.d.ts.map +0 -1
- package/bin/shared-hooks/useSharedMap.js.map +0 -1
- package/bin/shared-hooks/useSharedState.d.ts.map +0 -1
- package/bin/shared-hooks/useSharedState.js.map +0 -1
- package/bin/shared-hooks/useSharedStateRegistry.d.ts.map +0 -1
- package/bin/shared-hooks/useSharedStateRegistry.js.map +0 -1
- package/bin/types/ActionTypes.d.ts.map +0 -1
- package/bin/types/ActionTypes.js.map +0 -1
- package/bin/types/PropTypes.d.ts +0 -8
- package/bin/types/PropTypes.d.ts.map +0 -1
- package/bin/types/PropTypes.js.map +0 -1
- package/bin/types/ResultTypes.d.ts.map +0 -1
- package/bin/types/ResultTypes.js.map +0 -1
- package/bin/types/index.d.ts +0 -4
- package/bin/types/index.d.ts.map +0 -1
- package/bin/types/index.js +0 -4
- package/bin/types/index.js.map +0 -1
- package/bin/utils/index.d.ts +0 -2
- package/bin/utils/index.d.ts.map +0 -1
- package/bin/utils/index.js +0 -2
- package/bin/utils/index.js.map +0 -1
- package/bin/utils/type-check.d.ts.map +0 -1
- package/bin/utils/type-check.js.map +0 -1
- package/tsconfig.build.json +0 -6
- /package/bin/{interfaces → cjs/interfaces}/LiveInterfaceExtensions.d.ts +0 -0
- /package/bin/{internal → cjs/internal}/errors.d.ts +0 -0
- /package/bin/{utils → cjs/utils}/type-check.d.ts +0 -0
- /package/bin/{interfaces → esm/interfaces}/LiveInterfaceExtensions.js +0 -0
- /package/bin/{internal → esm/internal}/errors.js +0 -0
- /package/bin/{internal → esm/internal}/type-guards.js +0 -0
- /package/bin/{types → esm/types}/ActionTypes.js +0 -0
- /package/bin/{types → esm/types}/PropTypes.js +0 -0
- /package/bin/{types → esm/types}/ResultTypes.js +0 -0
- /package/bin/{utils → esm/utils}/type-check.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,mDAAiC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["../../../src/internal/type-guards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EACtC,KAAK,EAAE,GAAG,GACX,KAAK,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAEpC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,gBAAgB,CAKxE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPrevStateCallback = isPrevStateCallback;
|
|
4
|
+
exports.isITeamsJsSdkError = isITeamsJsSdkError;
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
* Used for useLiveState and useSharedState for checking if a value is a prevState callback
|
|
8
|
+
*/
|
|
9
|
+
function isPrevStateCallback(value) {
|
|
10
|
+
return typeof value === "function";
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @hidden
|
|
14
|
+
*/
|
|
15
|
+
function isITeamsJsSdkError(value) {
|
|
16
|
+
if (!value)
|
|
17
|
+
return false;
|
|
18
|
+
if (typeof value.errorCode !== "number")
|
|
19
|
+
return false;
|
|
20
|
+
if (value.message === undefined)
|
|
21
|
+
return true;
|
|
22
|
+
return typeof value.message === "string";
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=type-guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-guards.js","sourceRoot":"","sources":["../../../src/internal/type-guards.ts"],"names":[],"mappings":";;AAMA,kDAIC;AAKD,gDAKC;AAlBD;;;GAGG;AACH,SAAgB,mBAAmB,CAC/B,KAAU;IAEV,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAAU;IACzC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,IAAI,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC7C,OAAO,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./useLivePresence.js";
|
|
2
|
+
export * from "./useLiveFollowMode.js";
|
|
3
|
+
export * from "./useLiveState.js";
|
|
4
|
+
export * from "./useMediaSynchronizer.js";
|
|
5
|
+
export * from "./useLiveEvent.js";
|
|
6
|
+
export * from "./useLiveCanvas.js";
|
|
7
|
+
export * from "./useLiveTimer.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/live-hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useLivePresence.js"), exports);
|
|
18
|
+
__exportStar(require("./useLiveFollowMode.js"), exports);
|
|
19
|
+
__exportStar(require("./useLiveState.js"), exports);
|
|
20
|
+
__exportStar(require("./useMediaSynchronizer.js"), exports);
|
|
21
|
+
__exportStar(require("./useLiveEvent.js"), exports);
|
|
22
|
+
__exportStar(require("./useLiveCanvas.js"), exports);
|
|
23
|
+
__exportStar(require("./useLiveTimer.js"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/live-hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,yDAAuC;AACvC,oDAAkC;AAClC,4DAA0C;AAC1C,oDAAkC;AAClC,qDAAmC;AACnC,oDAAkC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { IUseLiveCanvasOptionalProps, IUseLiveCanvasResults } from "../types/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* React hook for using a Live Share Canvas `LiveCanvas` and `InkingManager`.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Use this hook to set up an `LiveCanvas` object, which is used for collaborative inking. It takes several input parameters, including a unique key,
|
|
12
|
+
* a reference to a canvas element, and various settings for the inking tool, brush, and canvas offset and scale.
|
|
13
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
14
|
+
*
|
|
15
|
+
* @param uniqueKey the unique key for the `LiveCanvas`. If one does not yet exist, a new one.
|
|
16
|
+
* @param canvasElementRef the HTML div element ref or document ID that `InkingManager` will use for canvas-based collaboration.
|
|
17
|
+
* @param props Optional. Other optional props.
|
|
18
|
+
* @param props.active Optional. Stateful boolean that will activate/de-activate `InkingManager` accordingly.
|
|
19
|
+
* @param props.tool Optional. Stateful enum for what tool to use in the `InkingManager`.
|
|
20
|
+
* @param props.lineBrush Optional. Stateful lineBrush object for the selected lineBrush options to use in `InkingManager`.
|
|
21
|
+
* @param props.offset Optional. Stateful offset point to use in the `InkingManager`. Gets the viewport offset. Defaults to 0,0.
|
|
22
|
+
* @param props.scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
|
|
23
|
+
* @param props.referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
|
|
24
|
+
* @param props.isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
|
|
25
|
+
* @param props.localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
|
|
26
|
+
* @param props.node Optional. A Fluid `LiveCanvasTree` `TreeNode` instance to swap out the underlying storage solution for strokes.
|
|
27
|
+
* To learn more, look at Fluid's [SharedTree](https://fluidframework.com/docs/data-structures/tree/) documentation.
|
|
28
|
+
* @param allowedRoles Optional. The user roles that are allowed to start/stop/pause the timer.
|
|
29
|
+
*
|
|
30
|
+
* @returns `IUseLiveCanvasResults` object that contains the `liveCanvas` data object and `inkingManager`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
```jsx
|
|
34
|
+
import { useLiveCanvas } from "@microsoft/live-share-react";
|
|
35
|
+
import { InkingTool } from "@microsoft/live-share-canvas";
|
|
36
|
+
import { useRef } from "react";
|
|
37
|
+
|
|
38
|
+
// Unique identifier that distinguishes this useLiveCanvas from others in your app
|
|
39
|
+
const UNIQUE_KEY = "CUSTOM-LIVE-CANVAS";
|
|
40
|
+
|
|
41
|
+
// Example component
|
|
42
|
+
export function ExampleLiveCanvas() {
|
|
43
|
+
const liveCanvasRef = useRef(null);
|
|
44
|
+
const { liveCanvas, inkingManager } = useLiveCanvas(
|
|
45
|
+
"CUSTOM-LIVE-CANVAS",
|
|
46
|
+
liveCanvasRef,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div style={{ position: "absolute"}}>
|
|
51
|
+
<div
|
|
52
|
+
ref={liveCanvasRef}
|
|
53
|
+
// Best practice is to not define inline styles
|
|
54
|
+
style={{ width: "556px", height: "224px" }}
|
|
55
|
+
/>
|
|
56
|
+
{!!liveCanvas && (
|
|
57
|
+
<div>
|
|
58
|
+
<button
|
|
59
|
+
onClick={() => {
|
|
60
|
+
inkingManager.tool = InkingTool.pen;
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{"Pen"}
|
|
64
|
+
</button>
|
|
65
|
+
<button
|
|
66
|
+
onClick={() => {
|
|
67
|
+
inkingManager.tool = InkingTool.laserPointer;
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
{"Laser pointer"}
|
|
71
|
+
</button>
|
|
72
|
+
</div>
|
|
73
|
+
)}
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
```
|
|
78
|
+
*/
|
|
79
|
+
export declare function useLiveCanvas(uniqueKey: string, canvasElementRef: React.RefObject<HTMLElement | null> | string, props?: IUseLiveCanvasOptionalProps): IUseLiveCanvasResults;
|
|
80
|
+
//# sourceMappingURL=useLiveCanvas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLiveCanvas.d.ts","sourceRoot":"","sources":["../../../src/live-hooks/useLiveCanvas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACH,2BAA2B,EAC3B,qBAAqB,EACxB,MAAM,mBAAmB,CAAC;AAK3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AACH,wBAAgB,aAAa,CACzB,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,MAAM,EAC9D,KAAK,CAAC,EAAE,2BAA2B,GACpC,qBAAqB,CA0KvB"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.useLiveCanvas = useLiveCanvas;
|
|
11
|
+
const live_share_canvas_1 = require("@microsoft/live-share-canvas");
|
|
12
|
+
const react_1 = __importDefault(require("react"));
|
|
13
|
+
const index_js_1 = require("../shared-hooks/index.js");
|
|
14
|
+
const index_js_2 = require("../utils/index.js");
|
|
15
|
+
const tree_node_utils_js_1 = require("../shared-hooks/internals/tree-node-utils.js");
|
|
16
|
+
const live_share_1 = require("@microsoft/live-share");
|
|
17
|
+
/**
|
|
18
|
+
* React hook for using a Live Share Canvas `LiveCanvas` and `InkingManager`.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Use this hook to set up an `LiveCanvas` object, which is used for collaborative inking. It takes several input parameters, including a unique key,
|
|
22
|
+
* a reference to a canvas element, and various settings for the inking tool, brush, and canvas offset and scale.
|
|
23
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
24
|
+
*
|
|
25
|
+
* @param uniqueKey the unique key for the `LiveCanvas`. If one does not yet exist, a new one.
|
|
26
|
+
* @param canvasElementRef the HTML div element ref or document ID that `InkingManager` will use for canvas-based collaboration.
|
|
27
|
+
* @param props Optional. Other optional props.
|
|
28
|
+
* @param props.active Optional. Stateful boolean that will activate/de-activate `InkingManager` accordingly.
|
|
29
|
+
* @param props.tool Optional. Stateful enum for what tool to use in the `InkingManager`.
|
|
30
|
+
* @param props.lineBrush Optional. Stateful lineBrush object for the selected lineBrush options to use in `InkingManager`.
|
|
31
|
+
* @param props.offset Optional. Stateful offset point to use in the `InkingManager`. Gets the viewport offset. Defaults to 0,0.
|
|
32
|
+
* @param props.scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
|
|
33
|
+
* @param props.referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
|
|
34
|
+
* @param props.isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
|
|
35
|
+
* @param props.localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
|
|
36
|
+
* @param props.node Optional. A Fluid `LiveCanvasTree` `TreeNode` instance to swap out the underlying storage solution for strokes.
|
|
37
|
+
* To learn more, look at Fluid's [SharedTree](https://fluidframework.com/docs/data-structures/tree/) documentation.
|
|
38
|
+
* @param allowedRoles Optional. The user roles that are allowed to start/stop/pause the timer.
|
|
39
|
+
*
|
|
40
|
+
* @returns `IUseLiveCanvasResults` object that contains the `liveCanvas` data object and `inkingManager`.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
```jsx
|
|
44
|
+
import { useLiveCanvas } from "@microsoft/live-share-react";
|
|
45
|
+
import { InkingTool } from "@microsoft/live-share-canvas";
|
|
46
|
+
import { useRef } from "react";
|
|
47
|
+
|
|
48
|
+
// Unique identifier that distinguishes this useLiveCanvas from others in your app
|
|
49
|
+
const UNIQUE_KEY = "CUSTOM-LIVE-CANVAS";
|
|
50
|
+
|
|
51
|
+
// Example component
|
|
52
|
+
export function ExampleLiveCanvas() {
|
|
53
|
+
const liveCanvasRef = useRef(null);
|
|
54
|
+
const { liveCanvas, inkingManager } = useLiveCanvas(
|
|
55
|
+
"CUSTOM-LIVE-CANVAS",
|
|
56
|
+
liveCanvasRef,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div style={{ position: "absolute"}}>
|
|
61
|
+
<div
|
|
62
|
+
ref={liveCanvasRef}
|
|
63
|
+
// Best practice is to not define inline styles
|
|
64
|
+
style={{ width: "556px", height: "224px" }}
|
|
65
|
+
/>
|
|
66
|
+
{!!liveCanvas && (
|
|
67
|
+
<div>
|
|
68
|
+
<button
|
|
69
|
+
onClick={() => {
|
|
70
|
+
inkingManager.tool = InkingTool.pen;
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
{"Pen"}
|
|
74
|
+
</button>
|
|
75
|
+
<button
|
|
76
|
+
onClick={() => {
|
|
77
|
+
inkingManager.tool = InkingTool.laserPointer;
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
80
|
+
{"Laser pointer"}
|
|
81
|
+
</button>
|
|
82
|
+
</div>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
```
|
|
88
|
+
*/
|
|
89
|
+
function useLiveCanvas(uniqueKey, canvasElementRef, props) {
|
|
90
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
91
|
+
/**
|
|
92
|
+
* User facing: inking manager instance
|
|
93
|
+
*/
|
|
94
|
+
const [inkingManager, setInkingManager] = react_1.default.useState();
|
|
95
|
+
/**
|
|
96
|
+
* User facing: dynamically load the DDS for the given unique key.
|
|
97
|
+
*/
|
|
98
|
+
const { dds: liveCanvas } = (0, index_js_1.useDynamicDDS)(uniqueKey, live_share_canvas_1.LiveCanvas);
|
|
99
|
+
// This should change less frequently then node if they are using `useTreeNode`
|
|
100
|
+
// We need the raw node anyways to apply event listeners
|
|
101
|
+
const rawNode = (0, tree_node_utils_js_1.getRawNode)(props === null || props === void 0 ? void 0 : props.node);
|
|
102
|
+
/**
|
|
103
|
+
* Setup the InkingManager and LiveCanvas
|
|
104
|
+
*/
|
|
105
|
+
react_1.default.useEffect(() => {
|
|
106
|
+
// if the component is already listening or liveCanvas is not yet initialized, return
|
|
107
|
+
if (!liveCanvas)
|
|
108
|
+
return;
|
|
109
|
+
// get the canvas element from the ref or document
|
|
110
|
+
let htmlElement;
|
|
111
|
+
if ((0, index_js_2.isRefObject)(canvasElementRef)) {
|
|
112
|
+
htmlElement = canvasElementRef.current;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
htmlElement = document.getElementById(canvasElementRef);
|
|
116
|
+
}
|
|
117
|
+
if (htmlElement === null)
|
|
118
|
+
return;
|
|
119
|
+
// Clear out existing nodes
|
|
120
|
+
function removeAllChildren(node) {
|
|
121
|
+
node.childNodes.forEach((childNode) => {
|
|
122
|
+
removeAllChildren(childNode);
|
|
123
|
+
childNode.remove();
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
removeAllChildren(htmlElement);
|
|
127
|
+
// Create the InkingManager and initialize the liveCanvas with it
|
|
128
|
+
const inkingManager = new live_share_canvas_1.InkingManager(htmlElement);
|
|
129
|
+
setInkingManager(inkingManager);
|
|
130
|
+
liveCanvas.initialize(inkingManager, props === null || props === void 0 ? void 0 : props.allowedRoles, rawNode);
|
|
131
|
+
// cleanup function to be called when the component is unmount
|
|
132
|
+
return () => {
|
|
133
|
+
inkingManager.removeAllListeners();
|
|
134
|
+
};
|
|
135
|
+
},
|
|
136
|
+
// Intentionally ommitting rawNode from deps because we only want to initialize once,
|
|
137
|
+
// whereas rawNode may change many times.
|
|
138
|
+
[liveCanvas, props === null || props === void 0 ? void 0 : props.allowedRoles]);
|
|
139
|
+
/**
|
|
140
|
+
* Set the node if it changes while LiveCanvas is initialized
|
|
141
|
+
*/
|
|
142
|
+
react_1.default.useEffect(() => {
|
|
143
|
+
if (!rawNode ||
|
|
144
|
+
(liveCanvas === null || liveCanvas === void 0 ? void 0 : liveCanvas.initializeState) !==
|
|
145
|
+
live_share_1.LiveDataObjectInitializeState.succeeded)
|
|
146
|
+
return;
|
|
147
|
+
liveCanvas.setTreeNode(rawNode);
|
|
148
|
+
}, [liveCanvas, rawNode]);
|
|
149
|
+
/**
|
|
150
|
+
* Activate or deactivate the inkingManager based on the 'active' prop
|
|
151
|
+
*/
|
|
152
|
+
react_1.default.useEffect(() => {
|
|
153
|
+
if (inkingManager && (props === null || props === void 0 ? void 0 : props.active) !== undefined) {
|
|
154
|
+
if (props === null || props === void 0 ? void 0 : props.active) {
|
|
155
|
+
inkingManager.activate();
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
inkingManager.deactivate();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, [props === null || props === void 0 ? void 0 : props.active, inkingManager]);
|
|
162
|
+
/**
|
|
163
|
+
* Sets the tool of the inkingManager based on the 'tool' prop
|
|
164
|
+
*/
|
|
165
|
+
react_1.default.useEffect(() => {
|
|
166
|
+
if (inkingManager && (props === null || props === void 0 ? void 0 : props.tool) !== undefined) {
|
|
167
|
+
inkingManager.tool = props.tool;
|
|
168
|
+
}
|
|
169
|
+
}, [props === null || props === void 0 ? void 0 : props.tool, inkingManager]);
|
|
170
|
+
/**
|
|
171
|
+
* Sets the offset of the inkingManager based on the 'offset' prop
|
|
172
|
+
*/
|
|
173
|
+
react_1.default.useEffect(() => {
|
|
174
|
+
if (inkingManager && (props === null || props === void 0 ? void 0 : props.offset) !== undefined) {
|
|
175
|
+
inkingManager.offset = {
|
|
176
|
+
x: props === null || props === void 0 ? void 0 : props.offset.x,
|
|
177
|
+
y: props === null || props === void 0 ? void 0 : props.offset.y,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}, [(_a = props === null || props === void 0 ? void 0 : props.offset) === null || _a === void 0 ? void 0 : _a.x, (_b = props === null || props === void 0 ? void 0 : props.offset) === null || _b === void 0 ? void 0 : _b.y, inkingManager]);
|
|
181
|
+
/**
|
|
182
|
+
* Sets the scale of the inkingManager based on the 'scale' prop
|
|
183
|
+
*/
|
|
184
|
+
react_1.default.useEffect(() => {
|
|
185
|
+
if (inkingManager && (props === null || props === void 0 ? void 0 : props.scale) !== undefined) {
|
|
186
|
+
inkingManager.scale = props === null || props === void 0 ? void 0 : props.scale;
|
|
187
|
+
}
|
|
188
|
+
}, [props === null || props === void 0 ? void 0 : props.scale, inkingManager]);
|
|
189
|
+
/**
|
|
190
|
+
* Sets the referencePoint of the inkingManager based on the 'referencePoint' prop
|
|
191
|
+
*/
|
|
192
|
+
react_1.default.useEffect(() => {
|
|
193
|
+
if (inkingManager && (props === null || props === void 0 ? void 0 : props.referencePoint) !== undefined) {
|
|
194
|
+
inkingManager.referencePoint = props === null || props === void 0 ? void 0 : props.referencePoint;
|
|
195
|
+
}
|
|
196
|
+
}, [props === null || props === void 0 ? void 0 : props.referencePoint, inkingManager]);
|
|
197
|
+
/**
|
|
198
|
+
* Sets the lineBrush of the inkingManager based on the 'lineBrush' prop
|
|
199
|
+
*/
|
|
200
|
+
react_1.default.useEffect(() => {
|
|
201
|
+
if (inkingManager && (props === null || props === void 0 ? void 0 : props.lineBrush)) {
|
|
202
|
+
inkingManager.lineBrush = {
|
|
203
|
+
color: props.lineBrush.color,
|
|
204
|
+
tip: props.lineBrush.tip,
|
|
205
|
+
tipSize: props.lineBrush.tipSize,
|
|
206
|
+
type: props.lineBrush.type,
|
|
207
|
+
endArrow: props.lineBrush.endArrow,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}, [
|
|
211
|
+
(_c = props === null || props === void 0 ? void 0 : props.lineBrush) === null || _c === void 0 ? void 0 : _c.color,
|
|
212
|
+
(_d = props === null || props === void 0 ? void 0 : props.lineBrush) === null || _d === void 0 ? void 0 : _d.tip,
|
|
213
|
+
(_e = props === null || props === void 0 ? void 0 : props.lineBrush) === null || _e === void 0 ? void 0 : _e.tipSize,
|
|
214
|
+
(_f = props === null || props === void 0 ? void 0 : props.lineBrush) === null || _f === void 0 ? void 0 : _f.type,
|
|
215
|
+
(_g = props === null || props === void 0 ? void 0 : props.lineBrush) === null || _g === void 0 ? void 0 : _g.endArrow,
|
|
216
|
+
inkingManager,
|
|
217
|
+
]);
|
|
218
|
+
/**
|
|
219
|
+
* Sets the isCursorShared of the liveCanvas based on the 'isCursorShared' prop
|
|
220
|
+
*/
|
|
221
|
+
react_1.default.useEffect(() => {
|
|
222
|
+
if (liveCanvas && (props === null || props === void 0 ? void 0 : props.isCursorShared) !== undefined) {
|
|
223
|
+
liveCanvas.isCursorShared = props.isCursorShared;
|
|
224
|
+
}
|
|
225
|
+
}, [props === null || props === void 0 ? void 0 : props.isCursorShared, liveCanvas]);
|
|
226
|
+
/**
|
|
227
|
+
* Sets the onGetLocalUserInfo method of the liveCanvas based on the 'localUserCursor' prop
|
|
228
|
+
*/
|
|
229
|
+
react_1.default.useEffect(() => {
|
|
230
|
+
if (liveCanvas && (props === null || props === void 0 ? void 0 : props.localUserPictureUrl)) {
|
|
231
|
+
liveCanvas.onGetLocalUserPictureUrl = () => {
|
|
232
|
+
return props.localUserPictureUrl;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}, [props === null || props === void 0 ? void 0 : props.localUserPictureUrl, liveCanvas]);
|
|
236
|
+
/**
|
|
237
|
+
* Return hook response
|
|
238
|
+
*/
|
|
239
|
+
return {
|
|
240
|
+
inkingManager,
|
|
241
|
+
liveCanvas,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=useLiveCanvas.js.map
|
|
@@ -0,0 +1 @@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ACH,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,UAAU,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,MAAK,SAAS,EAAE,CAAC;YACpD,UAAU,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;QACrD,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;IAExC;;OAEG;IACH,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,UAAU,KAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,mBAAmB,CAAA,EAAE,CAAC;YAC3C,UAAU,CAAC,wBAAwB,GAAG,GAAuB,EAAE;gBAC3D,OAAO,KAAK,CAAC,mBAAmB,CAAC;YACrC,CAAC,CAAC;QACN,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC;IAE7C;;OAEG;IACH,OAAO;QACH,aAAa;QACb,UAAU;KACb,CAAC;AACN,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the Microsoft Live Share SDK License.
|
|
4
4
|
*/
|
|
5
5
|
import { UserMeetingRole } from "@microsoft/live-share";
|
|
6
|
-
import { IUseLiveEventResults, OnReceivedLiveEventAction } from "../types";
|
|
6
|
+
import { IUseLiveEventResults, OnReceivedLiveEventAction } from "../types/index.js";
|
|
7
7
|
/**
|
|
8
8
|
* React hook for using a Live Share `LiveEvent`.
|
|
9
9
|
*
|
|
@@ -18,6 +18,42 @@ import { IUseLiveEventResults, OnReceivedLiveEventAction } from "../types";
|
|
|
18
18
|
* @param allowedRoles Optional. The meeting roles eligible to send events through this object.
|
|
19
19
|
* @param onReceivedEvent Optional. Callback method to be called when a new notification is received.
|
|
20
20
|
* @returns stateful `latestEvent` & `allEvents` list, `sendEvent` callback, and the `liveEvent` object.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
```jsx
|
|
24
|
+
import { useLiveEvent } from "@microsoft/live-share-react";
|
|
25
|
+
|
|
26
|
+
const emojis = ["❤️", "😂", "👍", "👎"];
|
|
27
|
+
|
|
28
|
+
// Define a unique key that differentiates this usage of `useLiveEvent` from others in your app
|
|
29
|
+
const MY_UNIQUE_KEY = "event-key";
|
|
30
|
+
|
|
31
|
+
// Example component for using useLiveEvent
|
|
32
|
+
export const MyCustomEvent = () => {
|
|
33
|
+
const { latestEvent, liveEvent, sendEvent } = useLiveEvent(MY_UNIQUE_KEY);
|
|
34
|
+
|
|
35
|
+
// Render loading UI when creating LiveEvent instance for first time
|
|
36
|
+
if (!liveEvent) return <>Loading...</>;
|
|
37
|
+
|
|
38
|
+
// Render UI
|
|
39
|
+
return (
|
|
40
|
+
<div>
|
|
41
|
+
{`Latest event: ${latestEvent?.value}, from local user: ${latestEvent?.local}`}
|
|
42
|
+
{"Select a planet below:"}
|
|
43
|
+
{emojis.map((emoji) => (
|
|
44
|
+
<button
|
|
45
|
+
key={emoji}
|
|
46
|
+
onClick={() => {
|
|
47
|
+
sendEvent(emoji);
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
{emoji}
|
|
51
|
+
</button>
|
|
52
|
+
))}
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
```
|
|
21
57
|
*/
|
|
22
58
|
export declare function useLiveEvent<TEvent = any>(uniqueKey: string, allowedRoles?: UserMeetingRole[], onReceivedEvent?: OnReceivedLiveEventAction<TEvent>): IUseLiveEventResults<TEvent>;
|
|
23
59
|
//# sourceMappingURL=useLiveEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLiveEvent.d.ts","sourceRoot":"","sources":["../../../src/live-hooks/useLiveEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,eAAe,EAGlB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,oBAAoB,EACpB,yBAAyB,EAE5B,MAAM,mBAAmB,CAAC;AAU3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAG,GAAG,EACrC,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,eAAe,EAAE,EAChC,eAAe,CAAC,EAAE,yBAAyB,CAAC,MAAM,CAAC,GACpD,oBAAoB,CAAC,MAAM,CAAC,CAoG9B"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
5
|
+
*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.useLiveEvent = useLiveEvent;
|
|
20
|
+
const live_share_1 = require("@microsoft/live-share");
|
|
21
|
+
const react_1 = __importDefault(require("react"));
|
|
22
|
+
const index_js_1 = require("../shared-hooks/index.js");
|
|
23
|
+
const index_js_2 = require("../internal/index.js");
|
|
24
|
+
const index_js_3 = require("../providers/index.js");
|
|
25
|
+
/**
|
|
26
|
+
* React hook for using a Live Share `LiveEvent`.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* Use this hook if you want to send transient JSON objects to everyone connected to the Fluid container,
|
|
30
|
+
* such as when sending push notifications or reactions.
|
|
31
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
32
|
+
*
|
|
33
|
+
* @template TEvent Optional typing for events sent & received. Default is `object` type.
|
|
34
|
+
* @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one
|
|
35
|
+
* will be created, otherwise it will use the existing one.
|
|
36
|
+
* @param allowedRoles Optional. The meeting roles eligible to send events through this object.
|
|
37
|
+
* @param onReceivedEvent Optional. Callback method to be called when a new notification is received.
|
|
38
|
+
* @returns stateful `latestEvent` & `allEvents` list, `sendEvent` callback, and the `liveEvent` object.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
```jsx
|
|
42
|
+
import { useLiveEvent } from "@microsoft/live-share-react";
|
|
43
|
+
|
|
44
|
+
const emojis = ["❤️", "😂", "👍", "👎"];
|
|
45
|
+
|
|
46
|
+
// Define a unique key that differentiates this usage of `useLiveEvent` from others in your app
|
|
47
|
+
const MY_UNIQUE_KEY = "event-key";
|
|
48
|
+
|
|
49
|
+
// Example component for using useLiveEvent
|
|
50
|
+
export const MyCustomEvent = () => {
|
|
51
|
+
const { latestEvent, liveEvent, sendEvent } = useLiveEvent(MY_UNIQUE_KEY);
|
|
52
|
+
|
|
53
|
+
// Render loading UI when creating LiveEvent instance for first time
|
|
54
|
+
if (!liveEvent) return <>Loading...</>;
|
|
55
|
+
|
|
56
|
+
// Render UI
|
|
57
|
+
return (
|
|
58
|
+
<div>
|
|
59
|
+
{`Latest event: ${latestEvent?.value}, from local user: ${latestEvent?.local}`}
|
|
60
|
+
{"Select a planet below:"}
|
|
61
|
+
{emojis.map((emoji) => (
|
|
62
|
+
<button
|
|
63
|
+
key={emoji}
|
|
64
|
+
onClick={() => {
|
|
65
|
+
sendEvent(emoji);
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
{emoji}
|
|
69
|
+
</button>
|
|
70
|
+
))}
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
```
|
|
75
|
+
*/
|
|
76
|
+
function useLiveEvent(uniqueKey, allowedRoles, onReceivedEvent) {
|
|
77
|
+
/**
|
|
78
|
+
* Stateful latest event (user facing) and its non-user-facing setter method.
|
|
79
|
+
*/
|
|
80
|
+
const [latestEvent, setLatestReceived] = react_1.default.useState();
|
|
81
|
+
/**
|
|
82
|
+
* Reference for all received/sent events. The current value of this is user-facing. Because
|
|
83
|
+
* this is always set at the same time as latestEvent, it is effectively a stateful value.
|
|
84
|
+
*/
|
|
85
|
+
const allEventsRef = react_1.default.useRef([]);
|
|
86
|
+
/**
|
|
87
|
+
* User facing: dynamically load the DDS for the given unique key.
|
|
88
|
+
*/
|
|
89
|
+
const { dds: liveEvent } = (0, index_js_1.useDynamicDDS)(uniqueKey, (live_share_1.LiveEvent));
|
|
90
|
+
const { container } = (0, index_js_3.useFluidObjectsContext)();
|
|
91
|
+
/**
|
|
92
|
+
* User facing: callback to send event through `LiveEvent`
|
|
93
|
+
*/
|
|
94
|
+
const sendEvent = react_1.default.useCallback((event, targetClientId) => __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
if (!container) {
|
|
96
|
+
throw new index_js_2.ActionContainerNotJoinedError("liveEvent", "sendEvent");
|
|
97
|
+
}
|
|
98
|
+
if (liveEvent === undefined) {
|
|
99
|
+
throw new index_js_2.ActionLiveDataObjectUndefinedError("liveEvent", "sendEvent");
|
|
100
|
+
}
|
|
101
|
+
if (!liveEvent.isInitialized) {
|
|
102
|
+
throw new index_js_2.ActionLiveDataObjectInitializedError("liveEvent", "sendEvent");
|
|
103
|
+
}
|
|
104
|
+
return yield liveEvent.send(event, targetClientId);
|
|
105
|
+
}), [container, liveEvent]);
|
|
106
|
+
/**
|
|
107
|
+
* Setup change listeners and start `LiveEvent` if needed
|
|
108
|
+
*/
|
|
109
|
+
react_1.default.useEffect(() => {
|
|
110
|
+
if ((liveEvent === null || liveEvent === void 0 ? void 0 : liveEvent.isInitialized) === undefined)
|
|
111
|
+
return;
|
|
112
|
+
// Register event listener
|
|
113
|
+
const onEventReceived = (event, local, clientId, timestamp) => {
|
|
114
|
+
// If developer passed the optional onReceivedEvent callback, we
|
|
115
|
+
// call it.
|
|
116
|
+
onReceivedEvent === null || onReceivedEvent === void 0 ? void 0 : onReceivedEvent(event, local);
|
|
117
|
+
// Set the received event to our local state
|
|
118
|
+
const received = {
|
|
119
|
+
value: event,
|
|
120
|
+
local,
|
|
121
|
+
clientId,
|
|
122
|
+
timestamp,
|
|
123
|
+
};
|
|
124
|
+
allEventsRef.current = [...allEventsRef.current, received];
|
|
125
|
+
setLatestReceived(received);
|
|
126
|
+
};
|
|
127
|
+
// Reset the events list if it allEventRef.current is non-empty.
|
|
128
|
+
// This happens when the `id` a developer provides changes on the fly.
|
|
129
|
+
if (allEventsRef.current.length > 0) {
|
|
130
|
+
allEventsRef.current = [];
|
|
131
|
+
setLatestReceived(undefined);
|
|
132
|
+
}
|
|
133
|
+
liveEvent.on(live_share_1.LiveEventEvents.received, onEventReceived);
|
|
134
|
+
if (liveEvent.initializeState === live_share_1.LiveDataObjectInitializeState.needed) {
|
|
135
|
+
// Start live event
|
|
136
|
+
liveEvent.initialize(allowedRoles);
|
|
137
|
+
}
|
|
138
|
+
return () => {
|
|
139
|
+
// on unmount, remove event listeners
|
|
140
|
+
liveEvent === null || liveEvent === void 0 ? void 0 : liveEvent.off(live_share_1.LiveEventEvents.received, onEventReceived);
|
|
141
|
+
};
|
|
142
|
+
}, [liveEvent]);
|
|
143
|
+
return {
|
|
144
|
+
latestEvent,
|
|
145
|
+
allEvents: allEventsRef.current,
|
|
146
|
+
sendEvent,
|
|
147
|
+
liveEvent,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=useLiveEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLiveEvent.js","sourceRoot":"","sources":["../../../src/live-hooks/useLiveEvent.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;AA0EH,oCAwGC;AAhLD,sDAK+B;AAC/B,kDAA0B;AAO1B,uDAAyD;AACzD,mDAI8B;AAC9B,oDAA+D;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,SAAgB,YAAY,CACxB,SAAiB,EACjB,YAAgC,EAChC,eAAmD;IAEnD;;OAEG;IACH,MAAM,CAAC,WAAW,EAAE,iBAAiB,CAAC,GAClC,eAAK,CAAC,QAAQ,EAA6B,CAAC;IAChD;;;OAGG;IACH,MAAM,YAAY,GAAG,eAAK,CAAC,MAAM,CAA8B,EAAE,CAAC,CAAC;IACnE;;OAEG;IACH,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,IAAA,wBAAa,EACpC,SAAS,EACT,CAAA,sBAAiB,CAAA,CACpB,CAAC;IAEF,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,iCAAsB,GAAE,CAAC;IAE/C;;OAEG;IACH,MAAM,SAAS,GAAgC,eAAK,CAAC,WAAW,CAC5D,CAAO,KAAa,EAAE,cAAuB,EAAE,EAAE;QAC7C,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,MAAM,IAAI,wCAA6B,CACnC,WAAW,EACX,WAAW,CACd,CAAC;QACN,CAAC;QACD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,6CAAkC,CACxC,WAAW,EACX,WAAW,CACd,CAAC;QACN,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC;YAC3B,MAAM,IAAI,+CAAoC,CAC1C,WAAW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