@microsoft/live-share-react 1.0.0-preview.8 → 1.0.1-preview.1
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/README.md +99 -34
- package/bin/index.d.ts +6 -6
- package/bin/index.js +6 -6
- package/bin/interfaces/LiveInterfaceExtensions.d.ts +25 -8
- package/bin/interfaces/LiveInterfaceExtensions.d.ts.map +1 -1
- package/bin/interfaces/LiveInterfaceExtensions.js +5 -5
- package/bin/interfaces/index.d.ts +1 -1
- package/bin/interfaces/index.js +1 -1
- package/bin/internal/errors.d.ts +26 -0
- package/bin/internal/errors.d.ts.map +1 -0
- package/bin/internal/errors.js +39 -0
- package/bin/internal/errors.js.map +1 -0
- package/bin/internal/index.d.ts +4 -0
- package/bin/internal/index.d.ts.map +1 -0
- package/bin/internal/index.js +4 -0
- package/bin/internal/index.js.map +1 -0
- package/bin/internal/type-guards.d.ts +6 -0
- package/bin/internal/type-guards.d.ts.map +1 -0
- package/bin/internal/type-guards.js +8 -0
- package/bin/internal/type-guards.js.map +1 -0
- package/bin/{internal-hooks → internal}/useSharedStateRegistry.d.ts +30 -30
- package/bin/internal/useSharedStateRegistry.d.ts.map +1 -0
- package/bin/{internal-hooks → internal}/useSharedStateRegistry.js +101 -99
- package/bin/internal/useSharedStateRegistry.js.map +1 -0
- package/bin/live-hooks/index.d.ts +6 -6
- package/bin/live-hooks/index.js +6 -6
- package/bin/live-hooks/useLiveCanvas.d.ts +27 -27
- package/bin/live-hooks/useLiveCanvas.d.ts.map +1 -1
- package/bin/live-hooks/useLiveCanvas.js +158 -166
- package/bin/live-hooks/useLiveCanvas.js.map +1 -1
- package/bin/live-hooks/useLiveEvent.d.ts +21 -21
- package/bin/live-hooks/useLiveEvent.d.ts.map +1 -1
- package/bin/live-hooks/useLiveEvent.js +100 -85
- package/bin/live-hooks/useLiveEvent.js.map +1 -1
- package/bin/live-hooks/useLivePresence.d.ts +25 -25
- package/bin/live-hooks/useLivePresence.d.ts.map +1 -1
- package/bin/live-hooks/useLivePresence.js +106 -92
- package/bin/live-hooks/useLivePresence.js.map +1 -1
- package/bin/live-hooks/useLiveState.d.ts +19 -19
- package/bin/live-hooks/useLiveState.d.ts.map +1 -1
- package/bin/live-hooks/useLiveState.js +79 -70
- package/bin/live-hooks/useLiveState.js.map +1 -1
- package/bin/live-hooks/useLiveTimer.d.ts +7 -7
- package/bin/live-hooks/useLiveTimer.d.ts.map +1 -1
- package/bin/live-hooks/useLiveTimer.js +150 -131
- package/bin/live-hooks/useLiveTimer.js.map +1 -1
- package/bin/live-hooks/useMediaSynchronizer.d.ts +22 -22
- package/bin/live-hooks/useMediaSynchronizer.d.ts.map +1 -1
- package/bin/live-hooks/useMediaSynchronizer.js +206 -161
- package/bin/live-hooks/useMediaSynchronizer.js.map +1 -1
- package/bin/providers/AzureProvider.d.ts +33 -33
- package/bin/providers/AzureProvider.d.ts.map +1 -1
- package/bin/providers/AzureProvider.js +101 -101
- package/bin/providers/AzureProvider.js.map +1 -1
- package/bin/providers/LiveShareProvider.d.ts +62 -41
- package/bin/providers/LiveShareProvider.d.ts.map +1 -1
- package/bin/providers/LiveShareProvider.js +68 -65
- package/bin/providers/LiveShareProvider.js.map +1 -1
- package/bin/providers/index.d.ts +2 -2
- package/bin/providers/index.js +2 -2
- package/bin/shared-hooks/index.d.ts +3 -4
- package/bin/shared-hooks/index.d.ts.map +1 -1
- package/bin/shared-hooks/index.js +3 -4
- package/bin/shared-hooks/index.js.map +1 -1
- package/bin/shared-hooks/useDynamicDDS.d.ts +18 -18
- package/bin/shared-hooks/useDynamicDDS.d.ts.map +1 -1
- package/bin/shared-hooks/useDynamicDDS.js +67 -67
- package/bin/shared-hooks/useDynamicDDS.js.map +1 -1
- package/bin/shared-hooks/useSharedMap.d.ts +21 -21
- package/bin/shared-hooks/useSharedMap.d.ts.map +1 -1
- package/bin/shared-hooks/useSharedMap.js +112 -105
- package/bin/shared-hooks/useSharedMap.js.map +1 -1
- package/bin/shared-hooks/useSharedState.d.ts +20 -20
- package/bin/shared-hooks/useSharedState.d.ts.map +1 -1
- package/bin/shared-hooks/useSharedState.js +72 -62
- package/bin/shared-hooks/useSharedState.js.map +1 -1
- package/bin/types/ActionTypes.d.ts +111 -29
- package/bin/types/ActionTypes.d.ts.map +1 -1
- package/bin/types/ActionTypes.js +5 -5
- package/bin/types/PropTypes.d.ts +7 -7
- package/bin/types/PropTypes.d.ts.map +1 -1
- package/bin/types/PropTypes.js +5 -5
- package/bin/types/ResultTypes.d.ts +174 -162
- package/bin/types/ResultTypes.d.ts.map +1 -1
- package/bin/types/ResultTypes.js +5 -5
- package/bin/types/index.d.ts +3 -3
- package/bin/types/index.js +3 -3
- package/bin/utils/index.d.ts +1 -1
- package/bin/utils/index.js +1 -1
- package/bin/utils/type-check.d.ts +14 -14
- package/bin/utils/type-check.js +53 -53
- package/package.json +18 -14
- package/src/interfaces/LiveInterfaceExtensions.ts +19 -2
- package/src/internal/errors.ts +48 -0
- package/src/internal/index.ts +3 -0
- package/src/internal/type-guards.ts +9 -0
- package/src/{internal-hooks → internal}/useSharedStateRegistry.ts +6 -5
- package/src/live-hooks/useLiveCanvas.ts +12 -20
- package/src/live-hooks/useLiveEvent.ts +41 -22
- package/src/live-hooks/useLivePresence.ts +52 -33
- package/src/live-hooks/useLiveState.ts +48 -53
- package/src/live-hooks/useLiveTimer.ts +50 -41
- package/src/live-hooks/useMediaSynchronizer.ts +108 -41
- package/src/providers/AzureProvider.tsx +3 -8
- package/src/providers/LiveShareProvider.tsx +46 -16
- package/src/shared-hooks/index.ts +0 -1
- package/src/shared-hooks/useDynamicDDS.ts +15 -8
- package/src/shared-hooks/useSharedMap.ts +48 -22
- package/src/shared-hooks/useSharedState.ts +15 -5
- package/src/types/ActionTypes.ts +100 -15
- package/src/types/ResultTypes.ts +23 -9
- package/bin/internal-hooks/index.d.ts +0 -2
- package/bin/internal-hooks/index.d.ts.map +0 -1
- package/bin/internal-hooks/index.js +0 -2
- package/bin/internal-hooks/index.js.map +0 -1
- package/bin/internal-hooks/useDynamicDDSRegistry.d.ts +0 -14
- package/bin/internal-hooks/useDynamicDDSRegistry.d.ts.map +0 -1
- package/bin/internal-hooks/useDynamicDDSRegistry.js +0 -142
- package/bin/internal-hooks/useDynamicDDSRegistry.js.map +0 -1
- package/bin/internal-hooks/useSharedStateRegistry.d.ts.map +0 -1
- package/bin/internal-hooks/useSharedStateRegistry.js.map +0 -1
- package/bin/internal-hooks/useStateRef.d.ts +0 -7
- package/bin/internal-hooks/useStateRef.d.ts.map +0 -1
- package/bin/internal-hooks/useStateRef.js +0 -15
- package/bin/internal-hooks/useStateRef.js.map +0 -1
- package/bin/live-hooks/useLiveAICompletion.d.ts +0 -29
- package/bin/live-hooks/useLiveAICompletion.d.ts.map +0 -1
- package/bin/live-hooks/useLiveAICompletion.js +0 -186
- package/bin/live-hooks/useLiveAICompletion.js.map +0 -1
- package/bin/live-hooks/useLiveCoPilot.d.ts +0 -28
- package/bin/live-hooks/useLiveCoPilot.d.ts.map +0 -1
- package/bin/live-hooks/useLiveCoPilot.js +0 -178
- package/bin/live-hooks/useLiveCoPilot.js.map +0 -1
- package/bin/live-share-turbo/AzureTurboClient.d.ts +0 -39
- package/bin/live-share-turbo/AzureTurboClient.d.ts.map +0 -1
- package/bin/live-share-turbo/AzureTurboClient.js +0 -56
- package/bin/live-share-turbo/AzureTurboClient.js.map +0 -1
- package/bin/live-share-turbo/LiveShareTurboClient.d.ts +0 -53
- package/bin/live-share-turbo/LiveShareTurboClient.d.ts.map +0 -1
- package/bin/live-share-turbo/LiveShareTurboClient.js +0 -69
- package/bin/live-share-turbo/LiveShareTurboClient.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboDataObject.d.ts +0 -31
- package/bin/live-share-turbo/dds-objects/TurboDataObject.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboDataObject.js +0 -75
- package/bin/live-share-turbo/dds-objects/TurboDataObject.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.d.ts +0 -48
- package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.js +0 -104
- package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveEvent.d.ts +0 -28
- package/bin/live-share-turbo/dds-objects/TurboLiveEvent.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveEvent.js +0 -68
- package/bin/live-share-turbo/dds-objects/TurboLiveEvent.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.d.ts +0 -60
- package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.js +0 -111
- package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLivePresence.d.ts +0 -77
- package/bin/live-share-turbo/dds-objects/TurboLivePresence.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLivePresence.js +0 -137
- package/bin/live-share-turbo/dds-objects/TurboLivePresence.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveState.d.ts +0 -30
- package/bin/live-share-turbo/dds-objects/TurboLiveState.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveState.js +0 -74
- package/bin/live-share-turbo/dds-objects/TurboLiveState.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboSharedMap.d.ts +0 -61
- package/bin/live-share-turbo/dds-objects/TurboSharedMap.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboSharedMap.js +0 -108
- package/bin/live-share-turbo/dds-objects/TurboSharedMap.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/index.d.ts +0 -8
- package/bin/live-share-turbo/dds-objects/index.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/index.js +0 -8
- package/bin/live-share-turbo/dds-objects/index.js.map +0 -1
- package/bin/live-share-turbo/index.d.ts +0 -5
- package/bin/live-share-turbo/index.d.ts.map +0 -1
- package/bin/live-share-turbo/index.js +0 -5
- package/bin/live-share-turbo/index.js.map +0 -1
- package/bin/live-share-turbo/interfaces/IFluidTurboClient.d.ts +0 -15
- package/bin/live-share-turbo/interfaces/IFluidTurboClient.d.ts.map +0 -1
- package/bin/live-share-turbo/interfaces/IFluidTurboClient.js +0 -2
- package/bin/live-share-turbo/interfaces/IFluidTurboClient.js.map +0 -1
- package/bin/live-share-turbo/interfaces/index.d.ts +0 -3
- package/bin/live-share-turbo/interfaces/index.d.ts.map +0 -1
- package/bin/live-share-turbo/interfaces/index.js +0 -3
- package/bin/live-share-turbo/interfaces/index.js.map +0 -1
- package/bin/live-share-turbo/internals/FluidTurboClient.d.ts +0 -39
- package/bin/live-share-turbo/internals/FluidTurboClient.d.ts.map +0 -1
- package/bin/live-share-turbo/internals/FluidTurboClient.js +0 -121
- package/bin/live-share-turbo/internals/FluidTurboClient.js.map +0 -1
- package/bin/live-share-turbo/internals/index.d.ts +0 -2
- package/bin/live-share-turbo/internals/index.d.ts.map +0 -1
- package/bin/live-share-turbo/internals/index.js +0 -2
- package/bin/live-share-turbo/internals/index.js.map +0 -1
- package/bin/live-share-turbo/internals/types.d.ts +0 -4
- package/bin/live-share-turbo/internals/types.d.ts.map +0 -1
- package/bin/live-share-turbo/internals/types.js +0 -2
- package/bin/live-share-turbo/internals/types.js.map +0 -1
- package/bin/providers/FluidContextProvider.d.ts +0 -34
- package/bin/providers/FluidContextProvider.d.ts.map +0 -1
- package/bin/providers/FluidContextProvider.js +0 -99
- package/bin/providers/FluidContextProvider.js.map +0 -1
- package/bin/providers/LiveShareContextProvider.d.ts +0 -42
- package/bin/providers/LiveShareContextProvider.d.ts.map +0 -1
- package/bin/providers/LiveShareContextProvider.js +0 -63
- package/bin/providers/LiveShareContextProvider.js.map +0 -1
- package/bin/shared-hooks/useLockedTask.d.ts +0 -11
- package/bin/shared-hooks/useLockedTask.d.ts.map +0 -1
- package/bin/shared-hooks/useLockedTask.js +0 -82
- package/bin/shared-hooks/useLockedTask.js.map +0 -1
- package/bin/shared-hooks/useTaskManager.d.ts +0 -13
- package/bin/shared-hooks/useTaskManager.d.ts.map +0 -1
- package/bin/shared-hooks/useTaskManager.js +0 -86
- package/bin/shared-hooks/useTaskManager.js.map +0 -1
- package/bin/utils/getContainerSchema.d.ts +0 -8
- package/bin/utils/getContainerSchema.d.ts.map +0 -1
- package/bin/utils/getContainerSchema.js +0 -41
- package/bin/utils/getContainerSchema.js.map +0 -1
- package/src/internal-hooks/index.ts +0 -1
- package/src/shared-hooks/useTaskManager.ts +0 -82
- package/tinylicious.log +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveCanvas.js","sourceRoot":"","sources":["../../src/live-hooks/useLiveCanvas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGH,aAAa,
|
|
1
|
+
{"version":3,"file":"useLiveCanvas.js","sourceRoot":"","sources":["../../src/live-hooks/useLiveCanvas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGH,aAAa,EAGb,UAAU,GACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,aAAa,CACzB,SAAiB,EACjB,gBAA8D,EAC9D,MAAgB,EAChB,IAAiB,EACjB,SAAkB,EAClB,MAAe,EACf,KAAc,EACd,cAAqC,EACrC,cAAwB,EACxB,mBAA4B;IAE5B;;OAEG;IACH,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAiB,CAAC;IAE1E;;OAEG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E,KAAK;QAChB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG;QACd,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO;QAClB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI;QACf,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ;QACnB,aAAa;KAChB,CAAC,CAAC;IAEH;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,UAAU,IAAI,cAAc,KAAK,SAAS,EAAE;YAC5C,UAAU,CAAC,cAAc,GAAG,cAAc,CAAC;SAC9C;IACL,CAAC,EAAE,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;IAEjC;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,UAAU,IAAI,mBAAmB,EAAE;YACnC,UAAU,CAAC,wBAAwB,GAAG,GAAuB,EAAE;gBAC3D,OAAO,mBAAmB,CAAC;YAC/B,CAAC,CAAC;SACL;IACL,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC;IAEtC;;OAEG;IACH,OAAO;QACH,aAAa;QACb,UAAU;KACb,CAAC;AACN,CAAC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
import { UserMeetingRole } from "@microsoft/live-share";
|
|
6
|
-
import { IUseLiveEventResults, OnReceivedLiveEventAction } from "../types";
|
|
7
|
-
/**
|
|
8
|
-
* React hook for using a Live Share `LiveEvent`.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* Use this hook if you want to send transient JSON objects to everyone connected to the Fluid container,
|
|
12
|
-
* such as when sending push notifications or reactions.
|
|
13
|
-
*
|
|
14
|
-
* @template TEvent Optional typing for events sent & received. Default is `object` type.
|
|
15
|
-
* @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one
|
|
16
|
-
* will be created, otherwise it will use the existing one.
|
|
17
|
-
* @param allowedRoles Optional. The meeting roles eligible to send events through this object.
|
|
18
|
-
* @param onReceivedEvent Optional. Callback method to be called when a new notification is received.
|
|
19
|
-
* @returns stateful `latestEvent` & `allEvents` list, `sendEvent` callback, and the `liveEvent` object.
|
|
20
|
-
*/
|
|
21
|
-
export declare function useLiveEvent<TEvent
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import { UserMeetingRole } from "@microsoft/live-share";
|
|
6
|
+
import { IUseLiveEventResults, OnReceivedLiveEventAction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* React hook for using a Live Share `LiveEvent`.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Use this hook if you want to send transient JSON objects to everyone connected to the Fluid container,
|
|
12
|
+
* such as when sending push notifications or reactions.
|
|
13
|
+
*
|
|
14
|
+
* @template TEvent Optional typing for events sent & received. Default is `object` type.
|
|
15
|
+
* @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one
|
|
16
|
+
* will be created, otherwise it will use the existing one.
|
|
17
|
+
* @param allowedRoles Optional. The meeting roles eligible to send events through this object.
|
|
18
|
+
* @param onReceivedEvent Optional. Callback method to be called when a new notification is received.
|
|
19
|
+
* @returns stateful `latestEvent` & `allEvents` list, `sendEvent` callback, and the `liveEvent` object.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useLiveEvent<TEvent = any>(uniqueKey: string, allowedRoles?: UserMeetingRole[], onReceivedEvent?: OnReceivedLiveEventAction<TEvent>): IUseLiveEventResults<TEvent>;
|
|
22
22
|
//# sourceMappingURL=useLiveEvent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveEvent.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLiveEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,eAAe,EAElB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,oBAAoB,EACpB,yBAAyB,EAE5B,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useLiveEvent.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLiveEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,eAAe,EAElB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,oBAAoB,EACpB,yBAAyB,EAE5B,MAAM,UAAU,CAAC;AAUlB;;;;;;;;;;;;;GAaG;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,CA4F9B"}
|
|
@@ -1,86 +1,101 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
import { LiveEventEvents, LiveEvent, } from "@microsoft/live-share";
|
|
15
|
+
import React from "react";
|
|
16
|
+
import { useDynamicDDS } from "../shared-hooks";
|
|
17
|
+
import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, ActionLiveDataObjectUndefinedError, } from "../internal";
|
|
18
|
+
import { useFluidObjectsContext } from "../providers";
|
|
19
|
+
/**
|
|
20
|
+
* React hook for using a Live Share `LiveEvent`.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* Use this hook if you want to send transient JSON objects to everyone connected to the Fluid container,
|
|
24
|
+
* such as when sending push notifications or reactions.
|
|
25
|
+
*
|
|
26
|
+
* @template TEvent Optional typing for events sent & received. Default is `object` type.
|
|
27
|
+
* @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one
|
|
28
|
+
* will be created, otherwise it will use the existing one.
|
|
29
|
+
* @param allowedRoles Optional. The meeting roles eligible to send events through this object.
|
|
30
|
+
* @param onReceivedEvent Optional. Callback method to be called when a new notification is received.
|
|
31
|
+
* @returns stateful `latestEvent` & `allEvents` list, `sendEvent` callback, and the `liveEvent` object.
|
|
32
|
+
*/
|
|
33
|
+
export function useLiveEvent(uniqueKey, allowedRoles, onReceivedEvent) {
|
|
34
|
+
/**
|
|
35
|
+
* Stateful latest event (user facing) and its non-user-facing setter method.
|
|
36
|
+
*/
|
|
37
|
+
const [latestEvent, setLatestReceived] = React.useState();
|
|
38
|
+
/**
|
|
39
|
+
* Reference for all received/sent events. The current value of this is user-facing. Because
|
|
40
|
+
* this is always set at the same time as latestEvent, it is effectively a stateful value.
|
|
41
|
+
*/
|
|
42
|
+
const allEventsRef = React.useRef([]);
|
|
43
|
+
/**
|
|
44
|
+
* User facing: dynamically load the DDS for the given unique key.
|
|
45
|
+
*/
|
|
46
|
+
const { dds: liveEvent } = useDynamicDDS(uniqueKey, (LiveEvent));
|
|
47
|
+
const { container } = useFluidObjectsContext();
|
|
48
|
+
/**
|
|
49
|
+
* User facing: callback to send event through `LiveEvent`
|
|
50
|
+
*/
|
|
51
|
+
const sendEvent = React.useCallback((event) => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
if (!container) {
|
|
53
|
+
throw new ActionContainerNotJoinedError("liveEvent", "sendEvent");
|
|
54
|
+
}
|
|
55
|
+
if (liveEvent === undefined) {
|
|
56
|
+
throw new ActionLiveDataObjectUndefinedError("liveEvent", "sendEvent");
|
|
57
|
+
}
|
|
58
|
+
if (!liveEvent.isInitialized) {
|
|
59
|
+
throw new ActionLiveDataObjectInitializedError("liveEvent", "sendEvent");
|
|
60
|
+
}
|
|
61
|
+
return yield liveEvent.send(event);
|
|
62
|
+
}), [container, liveEvent]);
|
|
63
|
+
/**
|
|
64
|
+
* Setup change listeners and start `LiveEvent` if needed
|
|
65
|
+
*/
|
|
66
|
+
React.useEffect(() => {
|
|
67
|
+
if ((liveEvent === null || liveEvent === void 0 ? void 0 : liveEvent.isInitialized) === undefined)
|
|
68
|
+
return;
|
|
69
|
+
// Register event listener
|
|
70
|
+
const onEventReceived = (event, local, clientId, timestamp) => {
|
|
71
|
+
// If developer passed the optional onReceivedEvent callback, we
|
|
72
|
+
// call it.
|
|
73
|
+
onReceivedEvent === null || onReceivedEvent === void 0 ? void 0 : onReceivedEvent(event, local);
|
|
74
|
+
// Set the received event to our local state
|
|
75
|
+
const received = {
|
|
76
|
+
value: event,
|
|
77
|
+
local,
|
|
78
|
+
clientId,
|
|
79
|
+
timestamp,
|
|
80
|
+
};
|
|
81
|
+
allEventsRef.current = [...allEventsRef.current, received];
|
|
82
|
+
setLatestReceived(received);
|
|
83
|
+
};
|
|
84
|
+
liveEvent.on(LiveEventEvents.received, onEventReceived);
|
|
85
|
+
if (!liveEvent.isInitialized) {
|
|
86
|
+
// Start live event
|
|
87
|
+
liveEvent.initialize(allowedRoles);
|
|
88
|
+
}
|
|
89
|
+
return () => {
|
|
90
|
+
// on unmount, remove event listeners
|
|
91
|
+
liveEvent === null || liveEvent === void 0 ? void 0 : liveEvent.off(LiveEventEvents.received, onEventReceived);
|
|
92
|
+
};
|
|
93
|
+
}, [liveEvent]);
|
|
94
|
+
return {
|
|
95
|
+
latestEvent,
|
|
96
|
+
allEvents: allEventsRef.current,
|
|
97
|
+
sendEvent,
|
|
98
|
+
liveEvent,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
86
101
|
//# sourceMappingURL=useLiveEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveEvent.js","sourceRoot":"","sources":["../../src/live-hooks/useLiveEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"useLiveEvent.js","sourceRoot":"","sources":["../../src/live-hooks/useLiveEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;AAEH,OAAO,EACH,eAAe,EAEf,SAAS,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACH,6BAA6B,EAC7B,oCAAoC,EACpC,kCAAkC,GACrC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY,CACxB,SAAiB,EACjB,YAAgC,EAChC,eAAmD;IAEnD;;OAEG;IACH,MAAM,CAAC,WAAW,EAAE,iBAAiB,CAAC,GAClC,KAAK,CAAC,QAAQ,EAA6B,CAAC;IAChD;;;OAGG;IACH,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAA8B,EAAE,CAAC,CAAC;IACnE;;OAEG;IACH,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,aAAa,CACpC,SAAS,EACT,CAAA,SAAiB,CAAA,CACpB,CAAC;IAEF,MAAM,EAAE,SAAS,EAAE,GAAG,sBAAsB,EAAE,CAAC;IAE/C;;OAEG;IACH,MAAM,SAAS,GAAgC,KAAK,CAAC,WAAW,CAC5D,CAAO,KAAa,EAAE,EAAE;QACpB,IAAI,CAAC,SAAS,EAAE;YACZ,MAAM,IAAI,6BAA6B,CACnC,WAAW,EACX,WAAW,CACd,CAAC;SACL;QAC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e,CAAC,CAAC;QAC9D,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO;QACH,WAAW;QACX,SAAS,EAAE,YAAY,CAAC,OAAO;QAC/B,SAAS;QACT,SAAS;KACZ,CAAC;AACN,CAAC"}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
import { PresenceState } from "@microsoft/live-share";
|
|
6
|
-
import { IUseLivePresenceResults } from "../types";
|
|
7
|
-
/**
|
|
8
|
-
* React hook for using a Live Share `LivePresence`.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* Use this hook if you want to track presence for who is currently using this component, such as
|
|
12
|
-
* who is online or who is viewing a specific document. With presence, you can sent along any custom
|
|
13
|
-
* user data. This is useful for rendering a list of users, profile pictures, cursor positions, and more.
|
|
14
|
-
*
|
|
15
|
-
* @template TData Optional typing for the custom user presence data object. Default is `object` type.
|
|
16
|
-
|
|
17
|
-
* @param userId Optional. The unique ID for a user. If none is provided, a random UUID will be generated.
|
|
18
|
-
* @param initialData Optional. Initial presence data object for the user.
|
|
19
|
-
* @param initialPresenceState Optional. Initial status of the user's presence. Default is online.
|
|
20
|
-
* @param
|
|
21
|
-
* will be created, otherwise it will use the existing one. Default value is ":<dds-default>"
|
|
22
|
-
* @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
|
|
23
|
-
* to update the local user's presence and the `LivePresence` Fluid object.
|
|
24
|
-
*/
|
|
25
|
-
export declare function useLivePresence<TData extends object = object>(
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import { PresenceState, UserMeetingRole } from "@microsoft/live-share";
|
|
6
|
+
import { IUseLivePresenceResults } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* React hook for using a Live Share `LivePresence`.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Use this hook if you want to track presence for who is currently using this component, such as
|
|
12
|
+
* who is online or who is viewing a specific document. With presence, you can sent along any custom
|
|
13
|
+
* user data. This is useful for rendering a list of users, profile pictures, cursor positions, and more.
|
|
14
|
+
*
|
|
15
|
+
* @template TData Optional typing for the custom user presence data object. Default is `object` type.
|
|
16
|
+
* @param uniqueKey The unique key for `LivePresence`. If one does not yet exist, a new one
|
|
17
|
+
* @param userId Optional. The unique ID for a user. If none is provided, a random UUID will be generated.
|
|
18
|
+
* @param initialData Optional. Initial presence data object for the user. Can be value or a function to get the value.
|
|
19
|
+
* @param initialPresenceState Optional. Initial status of the user's presence. Default is online.
|
|
20
|
+
* @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
|
|
21
|
+
* will be created, otherwise it will use the existing one. Default value is ":<dds-default>"
|
|
22
|
+
* @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
|
|
23
|
+
* to update the local user's presence and the `LivePresence` Fluid object.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useLivePresence<TData extends object = object>(uniqueKey: string, initialData?: TData | (() => TData) | undefined, initialPresenceState?: PresenceState, allowedRoles?: UserMeetingRole[]): IUseLivePresenceResults<TData>;
|
|
26
26
|
//# sourceMappingURL=useLivePresence.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLivePresence.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLivePresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,aAAa,
|
|
1
|
+
{"version":3,"file":"useLivePresence.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLivePresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,aAAa,EAEb,eAAe,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,uBAAuB,EAA8B,MAAM,UAAU,CAAC;AAS/E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACzD,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,SAAS,EAC/C,oBAAoB,GAAE,aAAoC,EAC1D,YAAY,CAAC,EAAE,eAAe,EAAE,GACjC,uBAAuB,CAAC,KAAK,CAAC,CA8FhC"}
|
|
@@ -1,93 +1,107 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (livePresence
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
livePresence
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
import { PresenceState, LivePresence, } from "@microsoft/live-share";
|
|
15
|
+
import React from "react";
|
|
16
|
+
import { useDynamicDDS } from "../shared-hooks";
|
|
17
|
+
import { useFluidObjectsContext } from "../providers";
|
|
18
|
+
import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, ActionLiveDataObjectUndefinedError, } from "../internal";
|
|
19
|
+
/**
|
|
20
|
+
* React hook for using a Live Share `LivePresence`.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* Use this hook if you want to track presence for who is currently using this component, such as
|
|
24
|
+
* who is online or who is viewing a specific document. With presence, you can sent along any custom
|
|
25
|
+
* user data. This is useful for rendering a list of users, profile pictures, cursor positions, and more.
|
|
26
|
+
*
|
|
27
|
+
* @template TData Optional typing for the custom user presence data object. Default is `object` type.
|
|
28
|
+
* @param uniqueKey The unique key for `LivePresence`. If one does not yet exist, a new one
|
|
29
|
+
* @param userId Optional. The unique ID for a user. If none is provided, a random UUID will be generated.
|
|
30
|
+
* @param initialData Optional. Initial presence data object for the user. Can be value or a function to get the value.
|
|
31
|
+
* @param initialPresenceState Optional. Initial status of the user's presence. Default is online.
|
|
32
|
+
* @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
|
|
33
|
+
* will be created, otherwise it will use the existing one. Default value is ":<dds-default>"
|
|
34
|
+
* @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
|
|
35
|
+
* to update the local user's presence and the `LivePresence` Fluid object.
|
|
36
|
+
*/
|
|
37
|
+
export function useLivePresence(uniqueKey, initialData, initialPresenceState = PresenceState.online, allowedRoles) {
|
|
38
|
+
/**
|
|
39
|
+
* Stateful all user presence list and its non-user-facing setter method.
|
|
40
|
+
*/
|
|
41
|
+
const [allUsers, setAllUsers] = React.useState([]);
|
|
42
|
+
/**
|
|
43
|
+
* User facing: dynamically load the DDS for the given unique key.
|
|
44
|
+
*/
|
|
45
|
+
const { dds: livePresence } = useDynamicDDS(uniqueKey, (LivePresence));
|
|
46
|
+
/**
|
|
47
|
+
* User facing: list of non-local user's presence objects.
|
|
48
|
+
*/
|
|
49
|
+
const otherUsers = allUsers.filter((user) => !user.isLocalUser);
|
|
50
|
+
/**
|
|
51
|
+
* User facing: local user's presence object.
|
|
52
|
+
*/
|
|
53
|
+
const localUser = allUsers.find((user) => user.isLocalUser);
|
|
54
|
+
const { container } = useFluidObjectsContext();
|
|
55
|
+
/**
|
|
56
|
+
* User facing: callback to update the local user's presence.
|
|
57
|
+
*/
|
|
58
|
+
const updatePresence = React.useCallback((data, state) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
if (!container) {
|
|
60
|
+
throw new ActionContainerNotJoinedError("livePresence", "updatePresence");
|
|
61
|
+
}
|
|
62
|
+
if (livePresence === undefined) {
|
|
63
|
+
throw new ActionLiveDataObjectUndefinedError("livePresence", "updatePresence");
|
|
64
|
+
}
|
|
65
|
+
if (!livePresence.isInitialized) {
|
|
66
|
+
throw new ActionLiveDataObjectInitializedError("livePresence", "updatePresence");
|
|
67
|
+
}
|
|
68
|
+
return yield livePresence.update(data, state);
|
|
69
|
+
}), [container, livePresence]);
|
|
70
|
+
/**
|
|
71
|
+
* Setup change listeners and start `LivePresence` if needed
|
|
72
|
+
*/
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
if (livePresence === undefined)
|
|
75
|
+
return;
|
|
76
|
+
const onPresenceChanged = () => {
|
|
77
|
+
const updatedLocalUsers = [];
|
|
78
|
+
livePresence === null || livePresence === void 0 ? void 0 : livePresence.getUsers().forEach((user) => {
|
|
79
|
+
updatedLocalUsers.push(user);
|
|
80
|
+
});
|
|
81
|
+
setAllUsers(updatedLocalUsers);
|
|
82
|
+
};
|
|
83
|
+
livePresence.on("presenceChanged", onPresenceChanged);
|
|
84
|
+
if (!livePresence.isInitialized) {
|
|
85
|
+
livePresence.initialize(isInitialDataCallback(initialData)
|
|
86
|
+
? initialData()
|
|
87
|
+
: initialData, initialPresenceState, allowedRoles);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
onPresenceChanged();
|
|
91
|
+
}
|
|
92
|
+
return () => {
|
|
93
|
+
livePresence === null || livePresence === void 0 ? void 0 : livePresence.off("presenceChanged", onPresenceChanged);
|
|
94
|
+
};
|
|
95
|
+
}, [livePresence]);
|
|
96
|
+
return {
|
|
97
|
+
localUser,
|
|
98
|
+
otherUsers,
|
|
99
|
+
allUsers,
|
|
100
|
+
livePresence,
|
|
101
|
+
updatePresence,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function isInitialDataCallback(value) {
|
|
105
|
+
return typeof value === "function";
|
|
106
|
+
}
|
|
93
107
|
//# sourceMappingURL=useLivePresence.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLivePresence.js","sourceRoot":"","sources":["../../src/live-hooks/useLivePresence.ts"],"names":[],"mappings":"AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"useLivePresence.js","sourceRoot":"","sources":["../../src/live-hooks/useLivePresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;AAEH,OAAO,EAEH,aAAa,EACb,YAAY,GAEf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EACH,6BAA6B,EAC7B,oCAAoC,EACpC,kCAAkC,GACrC,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe,CAC3B,SAAiB,EACjB,WAA+C,EAC/C,uBAAsC,aAAa,CAAC,MAAM,EAC1D,YAAgC;IAEhC;;OAEG;IACH,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAC1C,EAAE,CACL,CAAC;IACF;;OAEG;IACH,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,aAAa,CACvC,SAAS,EACT,CAAA,YAAmB,CAAA,CACtB,CAAC;IAEF;;OAEG;IACH,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAEhE;;OAEG;IACH,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAE5D,MAAM,EAAE,SAAS,EAAE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CACf,CAAC;SACL;aAAM;YACH,iBAAiB,EAAE,CAAC;SACvB;QAED,OAAO,GAAG,EAAE;YACR,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAC5D,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO;QACH,SAAS;QACT,UAAU;QACV,QAAQ;QACR,YAAY;QACZ,cAAc;KACjB,CAAC;AACN,CAAC;AAED,SAAS,qBAAqB,CAAQ,KAAU;IAC5C,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACvC,CAAC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
import { UserMeetingRole } from "@microsoft/live-share";
|
|
6
|
-
import { SetLiveStateAction } from "../types";
|
|
7
|
-
/**
|
|
8
|
-
* React hook for using a Live Share `LiveState`.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* Use this hook if you want to synchronize app state that will reset when all users leave the session.
|
|
12
|
-
*
|
|
13
|
-
* @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one will be created, otherwise it will use the existing one.
|
|
14
|
-
* @param initialState Optional. the initial state value of type TState
|
|
15
|
-
* @param
|
|
16
|
-
* @
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
export declare function useLiveState<TState
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import { LiveState, UserMeetingRole } from "@microsoft/live-share";
|
|
6
|
+
import { SetLiveStateAction } from "../types";
|
|
7
|
+
/**
|
|
8
|
+
* React hook for using a Live Share `LiveState`.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Use this hook if you want to synchronize app state that will reset when all users leave the session.
|
|
12
|
+
*
|
|
13
|
+
* @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one will be created, otherwise it will use the existing one.
|
|
14
|
+
* @param initialState Optional. the initial state value of type TState
|
|
15
|
+
* @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
|
|
16
|
+
* @returns ordered values: first value is the synchronized state value and the second is a setter to change the state value.
|
|
17
|
+
* The setter returns a void promise, which will throw if the user does not have the required roles to set.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useLiveState<TState = any>(uniqueKey: string, initialState: TState, allowedRoles?: UserMeetingRole[]): [TState, SetLiveStateAction<TState>, LiveState<TState> | undefined];
|
|
20
20
|
//# sourceMappingURL=useLiveState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveState.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLiveState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"useLiveState.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLiveState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAU9C;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAG,GAAG,EACrC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,eAAe,EAAE,GACjC,CAAC,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAqErE"}
|