@microsoft/live-share-react 1.0.0-preview.11 → 1.0.0-preview.13

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.
Files changed (215) hide show
  1. package/README.md +3 -3
  2. package/bin/index.d.ts +7 -0
  3. package/bin/index.d.ts.map +1 -0
  4. package/bin/index.js +7 -0
  5. package/bin/index.js.map +1 -0
  6. package/bin/interfaces/LiveInterfaceExtensions.d.ts +9 -0
  7. package/bin/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
  8. package/bin/interfaces/LiveInterfaceExtensions.js +6 -0
  9. package/bin/interfaces/LiveInterfaceExtensions.js.map +1 -0
  10. package/bin/interfaces/index.d.ts +2 -0
  11. package/bin/interfaces/index.d.ts.map +1 -0
  12. package/bin/interfaces/index.js +2 -0
  13. package/bin/interfaces/index.js.map +1 -0
  14. package/bin/internal-hooks/index.d.ts +2 -0
  15. package/bin/internal-hooks/index.d.ts.map +1 -0
  16. package/bin/internal-hooks/index.js +2 -0
  17. package/bin/internal-hooks/index.js.map +1 -0
  18. package/bin/internal-hooks/useDynamicDDSRegistry.d.ts +14 -0
  19. package/bin/internal-hooks/useDynamicDDSRegistry.d.ts.map +1 -0
  20. package/bin/internal-hooks/useDynamicDDSRegistry.js +142 -0
  21. package/bin/internal-hooks/useDynamicDDSRegistry.js.map +1 -0
  22. package/bin/internal-hooks/useSharedStateRegistry.d.ts +31 -0
  23. package/bin/internal-hooks/useSharedStateRegistry.d.ts.map +1 -0
  24. package/bin/internal-hooks/useSharedStateRegistry.js +102 -0
  25. package/bin/internal-hooks/useSharedStateRegistry.js.map +1 -0
  26. package/bin/internal-hooks/useStateRef.d.ts +7 -0
  27. package/bin/internal-hooks/useStateRef.d.ts.map +1 -0
  28. package/bin/internal-hooks/useStateRef.js +15 -0
  29. package/bin/internal-hooks/useStateRef.js.map +1 -0
  30. package/bin/live-hooks/index.d.ts +7 -0
  31. package/bin/live-hooks/index.d.ts.map +1 -0
  32. package/bin/live-hooks/index.js +7 -0
  33. package/bin/live-hooks/index.js.map +1 -0
  34. package/bin/live-hooks/useLiveAICompletion.d.ts +29 -0
  35. package/bin/live-hooks/useLiveAICompletion.d.ts.map +1 -0
  36. package/bin/live-hooks/useLiveAICompletion.js +186 -0
  37. package/bin/live-hooks/useLiveAICompletion.js.map +1 -0
  38. package/bin/live-hooks/useLiveCanvas.d.ts +28 -0
  39. package/bin/live-hooks/useLiveCanvas.d.ts.map +1 -0
  40. package/bin/live-hooks/useLiveCanvas.js +159 -0
  41. package/bin/live-hooks/useLiveCanvas.js.map +1 -0
  42. package/bin/live-hooks/useLiveCoPilot.d.ts +28 -0
  43. package/bin/live-hooks/useLiveCoPilot.d.ts.map +1 -0
  44. package/bin/live-hooks/useLiveCoPilot.js +178 -0
  45. package/bin/live-hooks/useLiveCoPilot.js.map +1 -0
  46. package/bin/live-hooks/useLiveEvent.d.ts +22 -0
  47. package/bin/live-hooks/useLiveEvent.d.ts.map +1 -0
  48. package/bin/live-hooks/useLiveEvent.js +93 -0
  49. package/bin/live-hooks/useLiveEvent.js.map +1 -0
  50. package/bin/live-hooks/useLivePresence.d.ts +26 -0
  51. package/bin/live-hooks/useLivePresence.d.ts.map +1 -0
  52. package/bin/live-hooks/useLivePresence.js +102 -0
  53. package/bin/live-hooks/useLivePresence.js.map +1 -0
  54. package/bin/live-hooks/useLiveState.d.ts +20 -0
  55. package/bin/live-hooks/useLiveState.d.ts.map +1 -0
  56. package/bin/live-hooks/useLiveState.js +73 -0
  57. package/bin/live-hooks/useLiveState.js.map +1 -0
  58. package/bin/live-hooks/useLiveTimer.d.ts +8 -0
  59. package/bin/live-hooks/useLiveTimer.d.ts.map +1 -0
  60. package/bin/live-hooks/useLiveTimer.js +145 -0
  61. package/bin/live-hooks/useLiveTimer.js.map +1 -0
  62. package/bin/live-hooks/useMediaSynchronizer.d.ts +23 -0
  63. package/bin/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
  64. package/bin/live-hooks/useMediaSynchronizer.js +185 -0
  65. package/bin/live-hooks/useMediaSynchronizer.js.map +1 -0
  66. package/bin/live-share-turbo/AzureTurboClient.d.ts +39 -0
  67. package/bin/live-share-turbo/AzureTurboClient.d.ts.map +1 -0
  68. package/bin/live-share-turbo/AzureTurboClient.js +56 -0
  69. package/bin/live-share-turbo/AzureTurboClient.js.map +1 -0
  70. package/bin/live-share-turbo/LiveShareTurboClient.d.ts +53 -0
  71. package/bin/live-share-turbo/LiveShareTurboClient.d.ts.map +1 -0
  72. package/bin/live-share-turbo/LiveShareTurboClient.js +69 -0
  73. package/bin/live-share-turbo/LiveShareTurboClient.js.map +1 -0
  74. package/bin/live-share-turbo/dds-objects/TurboDataObject.d.ts +31 -0
  75. package/bin/live-share-turbo/dds-objects/TurboDataObject.d.ts.map +1 -0
  76. package/bin/live-share-turbo/dds-objects/TurboDataObject.js +75 -0
  77. package/bin/live-share-turbo/dds-objects/TurboDataObject.js.map +1 -0
  78. package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.d.ts +48 -0
  79. package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.d.ts.map +1 -0
  80. package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.js +104 -0
  81. package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.js.map +1 -0
  82. package/bin/live-share-turbo/dds-objects/TurboLiveEvent.d.ts +28 -0
  83. package/bin/live-share-turbo/dds-objects/TurboLiveEvent.d.ts.map +1 -0
  84. package/bin/live-share-turbo/dds-objects/TurboLiveEvent.js +68 -0
  85. package/bin/live-share-turbo/dds-objects/TurboLiveEvent.js.map +1 -0
  86. package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.d.ts +60 -0
  87. package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.d.ts.map +1 -0
  88. package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.js +111 -0
  89. package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.js.map +1 -0
  90. package/bin/live-share-turbo/dds-objects/TurboLivePresence.d.ts +77 -0
  91. package/bin/live-share-turbo/dds-objects/TurboLivePresence.d.ts.map +1 -0
  92. package/bin/live-share-turbo/dds-objects/TurboLivePresence.js +137 -0
  93. package/bin/live-share-turbo/dds-objects/TurboLivePresence.js.map +1 -0
  94. package/bin/live-share-turbo/dds-objects/TurboLiveState.d.ts +30 -0
  95. package/bin/live-share-turbo/dds-objects/TurboLiveState.d.ts.map +1 -0
  96. package/bin/live-share-turbo/dds-objects/TurboLiveState.js +74 -0
  97. package/bin/live-share-turbo/dds-objects/TurboLiveState.js.map +1 -0
  98. package/bin/live-share-turbo/dds-objects/TurboSharedMap.d.ts +61 -0
  99. package/bin/live-share-turbo/dds-objects/TurboSharedMap.d.ts.map +1 -0
  100. package/bin/live-share-turbo/dds-objects/TurboSharedMap.js +108 -0
  101. package/bin/live-share-turbo/dds-objects/TurboSharedMap.js.map +1 -0
  102. package/bin/live-share-turbo/dds-objects/index.d.ts +8 -0
  103. package/bin/live-share-turbo/dds-objects/index.d.ts.map +1 -0
  104. package/bin/live-share-turbo/dds-objects/index.js +8 -0
  105. package/bin/live-share-turbo/dds-objects/index.js.map +1 -0
  106. package/bin/live-share-turbo/index.d.ts +5 -0
  107. package/bin/live-share-turbo/index.d.ts.map +1 -0
  108. package/bin/live-share-turbo/index.js +5 -0
  109. package/bin/live-share-turbo/index.js.map +1 -0
  110. package/bin/live-share-turbo/interfaces/IFluidTurboClient.d.ts +15 -0
  111. package/bin/live-share-turbo/interfaces/IFluidTurboClient.d.ts.map +1 -0
  112. package/bin/live-share-turbo/interfaces/IFluidTurboClient.js +2 -0
  113. package/bin/live-share-turbo/interfaces/IFluidTurboClient.js.map +1 -0
  114. package/bin/live-share-turbo/interfaces/index.d.ts +3 -0
  115. package/bin/live-share-turbo/interfaces/index.d.ts.map +1 -0
  116. package/bin/live-share-turbo/interfaces/index.js +3 -0
  117. package/bin/live-share-turbo/interfaces/index.js.map +1 -0
  118. package/bin/live-share-turbo/internals/FluidTurboClient.d.ts +39 -0
  119. package/bin/live-share-turbo/internals/FluidTurboClient.d.ts.map +1 -0
  120. package/bin/live-share-turbo/internals/FluidTurboClient.js +121 -0
  121. package/bin/live-share-turbo/internals/FluidTurboClient.js.map +1 -0
  122. package/bin/live-share-turbo/internals/index.d.ts +2 -0
  123. package/bin/live-share-turbo/internals/index.d.ts.map +1 -0
  124. package/bin/live-share-turbo/internals/index.js +2 -0
  125. package/bin/live-share-turbo/internals/index.js.map +1 -0
  126. package/bin/live-share-turbo/internals/types.d.ts +4 -0
  127. package/bin/live-share-turbo/internals/types.d.ts.map +1 -0
  128. package/bin/live-share-turbo/internals/types.js +2 -0
  129. package/bin/live-share-turbo/internals/types.js.map +1 -0
  130. package/bin/providers/AzureProvider.d.ts +34 -0
  131. package/bin/providers/AzureProvider.d.ts.map +1 -0
  132. package/bin/providers/AzureProvider.js +102 -0
  133. package/bin/providers/AzureProvider.js.map +1 -0
  134. package/bin/providers/FluidContextProvider.d.ts +34 -0
  135. package/bin/providers/FluidContextProvider.d.ts.map +1 -0
  136. package/bin/providers/FluidContextProvider.js +99 -0
  137. package/bin/providers/FluidContextProvider.js.map +1 -0
  138. package/bin/providers/LiveShareContextProvider.d.ts +42 -0
  139. package/bin/providers/LiveShareContextProvider.d.ts.map +1 -0
  140. package/bin/providers/LiveShareContextProvider.js +63 -0
  141. package/bin/providers/LiveShareContextProvider.js.map +1 -0
  142. package/bin/providers/LiveShareProvider.d.ts +63 -0
  143. package/bin/providers/LiveShareProvider.d.ts.map +1 -0
  144. package/bin/providers/LiveShareProvider.js +69 -0
  145. package/bin/providers/LiveShareProvider.js.map +1 -0
  146. package/bin/providers/index.d.ts +3 -0
  147. package/bin/providers/index.d.ts.map +1 -0
  148. package/bin/providers/index.js +3 -0
  149. package/bin/providers/index.js.map +1 -0
  150. package/bin/shared-hooks/index.d.ts +4 -0
  151. package/bin/shared-hooks/index.d.ts.map +1 -0
  152. package/bin/shared-hooks/index.js +4 -0
  153. package/bin/shared-hooks/index.js.map +1 -0
  154. package/bin/shared-hooks/useDynamicDDS.d.ts +19 -0
  155. package/bin/shared-hooks/useDynamicDDS.d.ts.map +1 -0
  156. package/bin/shared-hooks/useDynamicDDS.js +68 -0
  157. package/bin/shared-hooks/useDynamicDDS.js.map +1 -0
  158. package/bin/shared-hooks/useLockedTask.d.ts +11 -0
  159. package/bin/shared-hooks/useLockedTask.d.ts.map +1 -0
  160. package/bin/shared-hooks/useLockedTask.js +82 -0
  161. package/bin/shared-hooks/useLockedTask.js.map +1 -0
  162. package/bin/shared-hooks/useSharedMap.d.ts +22 -0
  163. package/bin/shared-hooks/useSharedMap.d.ts.map +1 -0
  164. package/bin/shared-hooks/useSharedMap.js +106 -0
  165. package/bin/shared-hooks/useSharedMap.js.map +1 -0
  166. package/bin/shared-hooks/useSharedState.d.ts +21 -0
  167. package/bin/shared-hooks/useSharedState.d.ts.map +1 -0
  168. package/bin/shared-hooks/useSharedState.js +67 -0
  169. package/bin/shared-hooks/useSharedState.js.map +1 -0
  170. package/bin/shared-hooks/useTaskManager.d.ts +13 -0
  171. package/bin/shared-hooks/useTaskManager.d.ts.map +1 -0
  172. package/bin/shared-hooks/useTaskManager.js +86 -0
  173. package/bin/shared-hooks/useTaskManager.js.map +1 -0
  174. package/bin/types/ActionTypes.d.ts +106 -0
  175. package/bin/types/ActionTypes.d.ts.map +1 -0
  176. package/bin/types/ActionTypes.js +6 -0
  177. package/bin/types/ActionTypes.js.map +1 -0
  178. package/bin/types/PropTypes.d.ts +8 -0
  179. package/bin/types/PropTypes.d.ts.map +1 -0
  180. package/bin/types/PropTypes.js +6 -0
  181. package/bin/types/PropTypes.js.map +1 -0
  182. package/bin/types/ResultTypes.d.ts +175 -0
  183. package/bin/types/ResultTypes.d.ts.map +1 -0
  184. package/bin/types/ResultTypes.js +6 -0
  185. package/bin/types/ResultTypes.js.map +1 -0
  186. package/bin/types/index.d.ts +4 -0
  187. package/bin/types/index.d.ts.map +1 -0
  188. package/bin/types/index.js +4 -0
  189. package/bin/types/index.js.map +1 -0
  190. package/bin/utils/getContainerSchema.d.ts +8 -0
  191. package/bin/utils/getContainerSchema.d.ts.map +1 -0
  192. package/bin/utils/getContainerSchema.js +41 -0
  193. package/bin/utils/getContainerSchema.js.map +1 -0
  194. package/bin/utils/index.d.ts +2 -0
  195. package/bin/utils/index.d.ts.map +1 -0
  196. package/bin/utils/index.js +2 -0
  197. package/bin/utils/index.js.map +1 -0
  198. package/bin/utils/type-check.d.ts +15 -0
  199. package/bin/utils/type-check.d.ts.map +1 -0
  200. package/bin/utils/type-check.js +54 -0
  201. package/bin/utils/type-check.js.map +1 -0
  202. package/package.json +13 -13
  203. package/src/internal-hooks/useSharedStateRegistry.ts +6 -5
  204. package/src/live-hooks/useLiveEvent.ts +14 -18
  205. package/src/live-hooks/useLivePresence.ts +13 -7
  206. package/src/live-hooks/useLiveState.ts +8 -6
  207. package/src/live-hooks/useLiveTimer.ts +21 -18
  208. package/src/live-hooks/useMediaSynchronizer.ts +37 -27
  209. package/src/providers/AzureProvider.tsx +2 -7
  210. package/src/providers/LiveShareProvider.tsx +45 -15
  211. package/src/shared-hooks/useDynamicDDS.ts +15 -8
  212. package/src/shared-hooks/useSharedMap.ts +17 -10
  213. package/src/shared-hooks/useSharedState.ts +5 -1
  214. package/src/types/ActionTypes.ts +89 -11
  215. package/src/types/ResultTypes.ts +22 -8
@@ -0,0 +1,186 @@
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 { LiveAICompletion, LiveAICompletionEvents, } from "@microsoft/live-share-turbo";
15
+ import React from "react";
16
+ import { useDynamicDDS } from "../shared-hooks";
17
+ /**
18
+ * React hook for using a Live Share Turbo `LiveAICompletion`. Intended for use with OpenAI's Completion API.
19
+ *
20
+ * @remarks
21
+ * Use this hook to set up an `LiveAICompletion` object, which is used for using AI completions collaboratively at minimal cost.
22
+ *
23
+ * @param uniqueKey the unique key for the `LiveAICompletion`. If one does not yet exist, a new one.
24
+ * @param onGetCompletion React useCallback function that returns a Promise<string> for the latest `promptValue`. Function is intended to
25
+ * communicate with a backend API that uses OpenAI's Completion API.
26
+ * @param allowedRoles Optional. The meeting roles eligible to send events through this object.
27
+ * @param defaultPromptValue Optional. Text that sets the default prompt value. Default value is an empty string.
28
+ * @param autoCompletions Optional. Stateful boolean that when true, will automatically send completions when the `promptValue` changes. Default value is
29
+ * false.
30
+ * @param debounceDelayMilliseconds Optional. Stateful number that changes the debounce interval when `autoCompletions` is true. Default value is 2500.
31
+ * @param lockPrompt Optional. Stateful boolean that when true, will restrict prompt changes to only the user with `haveCompletionLock` set to true. Default
32
+ * value is false.
33
+ * @param lockCompletion Optional. Stateful boolean that when true, will restrict manual completion changes to only the user with `haveCompletionLock`
34
+ * set to true. This does not impact the `autoCompletions` setting, because `autoCompletions` already has this behavior. Default value is false.
35
+ *
36
+ * @returns IUseLiveAICompletionResults object that contains stateful responses and callback methods from `LiveAICompletion`.
37
+ */
38
+ export const useLiveAICompletion = (uniqueKey, onGetCompletion, allowedRoles, defaultPromptValue, autoCompletions, debounceDelayMilliseconds, lockPrompt, lockCompletion) => {
39
+ /**
40
+ * Reference boolean for whether hook has registered "listening" events for `LiveAICompletion`.
41
+ */
42
+ const listeningRef = React.useRef(false);
43
+ /**
44
+ * @see IUseLiveAICompletionResults["promptValue"]
45
+ */
46
+ const [promptValue, setPromptValue] = React.useState("");
47
+ /**
48
+ * @see IUseLiveAICompletionResults["completionValue"]
49
+ */
50
+ const [completionValue, setCompletionValue] = React.useState();
51
+ /**
52
+ * @see IUseLiveAICompletionResults["haveCompletionLock"]
53
+ */
54
+ const [haveCompletionLock, setHaveCompletionLock] = React.useState(false);
55
+ /**
56
+ * User facing: dynamically load the DDS for the given unique key.
57
+ */
58
+ const { dds: liveAICompletion } = useDynamicDDS(uniqueKey, LiveAICompletion);
59
+ /**
60
+ * @see IUseLiveAICompletionResults["changePrompt"]
61
+ */
62
+ const changePrompt = React.useCallback((value) => {
63
+ if (liveAICompletion === undefined) {
64
+ console.error(new Error("Cannot call emitEvent when liveEvent is undefined"));
65
+ return;
66
+ }
67
+ if (!liveAICompletion.isInitialized) {
68
+ console.error(new Error("Cannot call emitEvent while liveEvent is not started"));
69
+ return;
70
+ }
71
+ return liveAICompletion.changePrompt(value);
72
+ }, [liveAICompletion]);
73
+ /**
74
+ * @see IUseLiveAICompletionResults["changePrompt"]
75
+ */
76
+ const sendCompletion = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
77
+ if (liveAICompletion === undefined) {
78
+ throw new Error("Cannot call sendCompletion while `liveAICompletion` is undefined");
79
+ }
80
+ if (!liveAICompletion.isInitialized) {
81
+ throw new Error("Cannot call sendCompletion while `liveAICompletion` is not initialized");
82
+ }
83
+ return liveAICompletion.sendCompletion();
84
+ }), [liveAICompletion]);
85
+ /**
86
+ * Sets up the `LiveAICompletion` instance.
87
+ */
88
+ React.useEffect(() => {
89
+ if (listeningRef.current ||
90
+ (liveAICompletion === null || liveAICompletion === void 0 ? void 0 : liveAICompletion.isInitialized) === undefined)
91
+ return;
92
+ listeningRef.current = true;
93
+ // Register event listeners
94
+ const onPromptChanged = (promptValue, local, completionValuePromise) => __awaiter(void 0, void 0, void 0, function* () {
95
+ setPromptValue(promptValue);
96
+ if (!liveAICompletion.haveValidCompletionValue) {
97
+ setCompletionValue(undefined);
98
+ }
99
+ try {
100
+ const completionValue = yield completionValuePromise;
101
+ setCompletionValue(completionValue);
102
+ }
103
+ catch (_a) {
104
+ // We do nothing, since this typically fails as a result of a new prompt value replacing the old on, permissions changing, etc.
105
+ }
106
+ });
107
+ const onLockGranted = () => {
108
+ setHaveCompletionLock(true);
109
+ };
110
+ const onLockLost = () => {
111
+ setHaveCompletionLock(true);
112
+ };
113
+ liveAICompletion.on(LiveAICompletionEvents.promptChanged, onPromptChanged);
114
+ liveAICompletion.on(LiveAICompletionEvents.lockGranted, onLockGranted);
115
+ liveAICompletion.on(LiveAICompletionEvents.lockLost, onLockLost);
116
+ if (!liveAICompletion.isInitialized) {
117
+ // Initialize the LiveAICompletion instance
118
+ liveAICompletion.initialize(onGetCompletion, allowedRoles, defaultPromptValue);
119
+ }
120
+ return () => {
121
+ // on unmount, remove event listeners
122
+ listeningRef.current = false;
123
+ liveAICompletion === null || liveAICompletion === void 0 ? void 0 : liveAICompletion.off(LiveAICompletionEvents.promptChanged, onPromptChanged);
124
+ liveAICompletion === null || liveAICompletion === void 0 ? void 0 : liveAICompletion.off(LiveAICompletionEvents.lockGranted, onLockGranted);
125
+ liveAICompletion === null || liveAICompletion === void 0 ? void 0 : liveAICompletion.off(LiveAICompletionEvents.lockLost, onLockLost);
126
+ };
127
+ }, [liveAICompletion]);
128
+ /**
129
+ * Sets the onGetCompletion of the `liveAICompletion` based on the 'onGetCompletion' prop
130
+ */
131
+ React.useEffect(() => {
132
+ if ((liveAICompletion === null || liveAICompletion === void 0 ? void 0 : liveAICompletion.isInitialized) === true &&
133
+ onGetCompletion !== undefined) {
134
+ liveAICompletion.onGetCompletion = onGetCompletion;
135
+ }
136
+ }, [liveAICompletion === null || liveAICompletion === void 0 ? void 0 : liveAICompletion.isInitialized, onGetCompletion]);
137
+ /**
138
+ * Sets the autoCompletions of the `liveAICompletion` based on the 'autoCompletions' prop
139
+ */
140
+ React.useEffect(() => {
141
+ if (liveAICompletion !== undefined &&
142
+ autoCompletions !== undefined &&
143
+ liveAICompletion.autoCompletions !== autoCompletions) {
144
+ liveAICompletion.autoCompletions = autoCompletions;
145
+ }
146
+ }, [liveAICompletion === null || liveAICompletion === void 0 ? void 0 : liveAICompletion.autoCompletions, autoCompletions]);
147
+ /**
148
+ * Sets the debounceDelayMilliseconds of the `liveAICompletion` based on the 'debounceDelayMilliseconds' prop
149
+ */
150
+ React.useEffect(() => {
151
+ if (liveAICompletion !== undefined &&
152
+ debounceDelayMilliseconds !== undefined &&
153
+ liveAICompletion.debounceDelayMilliseconds !== debounceDelayMilliseconds) {
154
+ liveAICompletion.debounceDelayMilliseconds = debounceDelayMilliseconds;
155
+ }
156
+ }, [liveAICompletion, debounceDelayMilliseconds]);
157
+ /**
158
+ * Sets the lockPrompt of the `liveAICompletion` based on the 'lockPrompt' prop
159
+ */
160
+ React.useEffect(() => {
161
+ if (liveAICompletion !== undefined &&
162
+ lockPrompt !== undefined &&
163
+ liveAICompletion.lockPrompt !== lockPrompt) {
164
+ liveAICompletion.lockPrompt = lockPrompt;
165
+ }
166
+ }, [liveAICompletion === null || liveAICompletion === void 0 ? void 0 : liveAICompletion.lockPrompt, lockPrompt]);
167
+ /**
168
+ * Sets the lockCompletion of the `liveAICompletion` based on the 'lockCompletion' prop
169
+ */
170
+ React.useEffect(() => {
171
+ if (liveAICompletion !== undefined &&
172
+ lockCompletion !== undefined &&
173
+ liveAICompletion.lockCompletion !== lockCompletion) {
174
+ liveAICompletion.lockCompletion = lockCompletion;
175
+ }
176
+ }, [liveAICompletion === null || liveAICompletion === void 0 ? void 0 : liveAICompletion.lockCompletion, lockCompletion]);
177
+ return {
178
+ changePrompt,
179
+ completionValue,
180
+ haveCompletionLock,
181
+ liveAICompletion,
182
+ promptValue,
183
+ sendCompletion,
184
+ };
185
+ };
186
+ //# sourceMappingURL=useLiveAICompletion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveAICompletion.js","sourceRoot":"","sources":["../../src/live-hooks/useLiveAICompletion.ts"],"names":[],"mappings":"AAAA;;;GAGG;;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AAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ import { CanvasReferencePoint, IBrush, InkingTool, IPoint } from "@microsoft/live-share-canvas";
6
+ import React from "react";
7
+ import { IUseLiveCanvasResults } from "../types";
8
+ /**
9
+ * React hook for using a Live Share Canvas `LiveCanvas` and `InkingManager`.
10
+ *
11
+ * @remarks
12
+ * Use this hook to set up an `LiveCanvas` object, which is used for collaborative inking. It takes several input parameters, including a unique key,
13
+ * a reference to a canvas element, and various settings for the inking tool, brush, and canvas offset and scale.
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 active Optional. Stateful boolean that will activate/de-activate `InkingManager` accordingly.
18
+ * @param tool Optional. Stateful enum for what tool to use in the `InkingManager`.
19
+ * @param lineBrush Optional. Stateful lineBrush object for the selected lineBrush options to use in `InkingManager`.
20
+ * @param offset Optional. Stateful offset point to use in the `InkingManager`. Gets the viewport offset. Defaults to 0,0.
21
+ * @param scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
22
+ * @param referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
23
+ * @param isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
24
+ * @param localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
25
+ * @returns IUseLiveCanvasResults object that contains the `liveCanvas` data object and `inkingManager`.
26
+ */
27
+ export declare function useLiveCanvas(uniqueKey: string, canvasElementRef: React.RefObject<HTMLElement | null> | string, active?: boolean, tool?: InkingTool, lineBrush?: IBrush, offset?: IPoint, scale?: number, referencePoint?: CanvasReferencePoint, isCursorShared?: boolean, localUserPictureUrl?: string): IUseLiveCanvasResults;
28
+ //# 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;AAEH,OAAO,EACH,oBAAoB,EACpB,MAAM,EAEN,UAAU,EACV,MAAM,EAET,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CACzB,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,MAAM,EAC9D,MAAM,CAAC,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,UAAU,EACjB,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,EACd,cAAc,CAAC,EAAE,oBAAoB,EACrC,cAAc,CAAC,EAAE,OAAO,EACxB,mBAAmB,CAAC,EAAE,MAAM,GAC7B,qBAAqB,CA6IvB"}
@@ -0,0 +1,159 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ import { InkingManager, LiveCanvas, } from "@microsoft/live-share-canvas";
6
+ import React from "react";
7
+ import { useDynamicDDS } from "../shared-hooks";
8
+ import { isRefObject } from "../utils";
9
+ /**
10
+ * React hook for using a Live Share Canvas `LiveCanvas` and `InkingManager`.
11
+ *
12
+ * @remarks
13
+ * Use this hook to set up an `LiveCanvas` object, which is used for collaborative inking. It takes several input parameters, including a unique key,
14
+ * a reference to a canvas element, and various settings for the inking tool, brush, and canvas offset and scale.
15
+ *
16
+ * @param uniqueKey the unique key for the `LiveCanvas`. If one does not yet exist, a new one.
17
+ * @param canvasElementRef the HTML div element ref or document ID that `InkingManager` will use for canvas-based collaboration.
18
+ * @param active Optional. Stateful boolean that will activate/de-activate `InkingManager` accordingly.
19
+ * @param tool Optional. Stateful enum for what tool to use in the `InkingManager`.
20
+ * @param lineBrush Optional. Stateful lineBrush object for the selected lineBrush options to use in `InkingManager`.
21
+ * @param offset Optional. Stateful offset point to use in the `InkingManager`. Gets the viewport offset. Defaults to 0,0.
22
+ * @param scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
23
+ * @param referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
24
+ * @param isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
25
+ * @param localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
26
+ * @returns IUseLiveCanvasResults object that contains the `liveCanvas` data object and `inkingManager`.
27
+ */
28
+ export function useLiveCanvas(uniqueKey, canvasElementRef, active, tool, lineBrush, offset, scale, referencePoint, isCursorShared, localUserPictureUrl) {
29
+ /**
30
+ * User facing: inking manager instance
31
+ */
32
+ const [inkingManager, setInkingManager] = React.useState();
33
+ /**
34
+ * User facing: dynamically load the DDS for the given unique key.
35
+ */
36
+ const { dds: liveCanvas } = useDynamicDDS(uniqueKey, LiveCanvas);
37
+ /**
38
+ * Setup the InkingManager and LiveCanvas
39
+ */
40
+ React.useEffect(() => {
41
+ // if the component is already listening or liveCanvas is not yet initialized, return
42
+ if (!liveCanvas)
43
+ return;
44
+ // get the canvas element from the ref or document
45
+ let htmlElement;
46
+ if (isRefObject(canvasElementRef)) {
47
+ htmlElement = canvasElementRef.current;
48
+ }
49
+ else {
50
+ htmlElement = document.getElementById(canvasElementRef);
51
+ }
52
+ if (htmlElement === null)
53
+ return;
54
+ // Create the InkingManager and initialize the liveCanvas with it
55
+ const inkingManager = new InkingManager(htmlElement);
56
+ setInkingManager(inkingManager);
57
+ liveCanvas.initialize(inkingManager);
58
+ // cleanup function to be called when the component is unmount
59
+ return () => {
60
+ liveCanvas.dispose();
61
+ inkingManager.removeAllListeners();
62
+ };
63
+ }, [liveCanvas]);
64
+ /**
65
+ * Activate or deactivate the inkingManager based on the 'active' prop
66
+ */
67
+ React.useEffect(() => {
68
+ if (inkingManager && active !== undefined) {
69
+ if (active) {
70
+ inkingManager.activate();
71
+ }
72
+ else {
73
+ inkingManager.deactivate();
74
+ }
75
+ }
76
+ }, [active, inkingManager]);
77
+ /**
78
+ * Sets the tool of the inkingManager based on the 'tool' prop
79
+ */
80
+ React.useEffect(() => {
81
+ if (inkingManager && tool !== undefined) {
82
+ inkingManager.tool = tool;
83
+ }
84
+ }, [tool, inkingManager]);
85
+ /**
86
+ * Sets the offset of the inkingManager based on the 'offset' prop
87
+ */
88
+ React.useEffect(() => {
89
+ if (inkingManager && offset !== undefined) {
90
+ inkingManager.offset = {
91
+ x: offset.x,
92
+ y: offset.y,
93
+ };
94
+ }
95
+ }, [offset === null || offset === void 0 ? void 0 : offset.x, offset === null || offset === void 0 ? void 0 : offset.y, inkingManager]);
96
+ /**
97
+ * Sets the scale of the inkingManager based on the 'scale' prop
98
+ */
99
+ React.useEffect(() => {
100
+ if (inkingManager && scale !== undefined) {
101
+ inkingManager.scale = scale;
102
+ }
103
+ }, [scale, inkingManager]);
104
+ /**
105
+ * Sets the referencePoint of the inkingManager based on the 'referencePoint' prop
106
+ */
107
+ React.useEffect(() => {
108
+ if (inkingManager && referencePoint !== undefined) {
109
+ inkingManager.referencePoint = referencePoint;
110
+ }
111
+ }, [referencePoint, inkingManager]);
112
+ /**
113
+ * Sets the lineBrush of the inkingManager based on the 'lineBrush' prop
114
+ */
115
+ React.useEffect(() => {
116
+ if (inkingManager && lineBrush) {
117
+ inkingManager.lineBrush = {
118
+ color: lineBrush.color,
119
+ tip: lineBrush.tip,
120
+ tipSize: lineBrush.tipSize,
121
+ type: lineBrush.type,
122
+ endArrow: lineBrush.endArrow,
123
+ };
124
+ }
125
+ }, [
126
+ lineBrush === null || lineBrush === void 0 ? void 0 : lineBrush.color,
127
+ lineBrush === null || lineBrush === void 0 ? void 0 : lineBrush.tip,
128
+ lineBrush === null || lineBrush === void 0 ? void 0 : lineBrush.tipSize,
129
+ lineBrush === null || lineBrush === void 0 ? void 0 : lineBrush.type,
130
+ lineBrush === null || lineBrush === void 0 ? void 0 : lineBrush.endArrow,
131
+ inkingManager,
132
+ ]);
133
+ /**
134
+ * Sets the isCursorShared of the liveCanvas based on the 'isCursorShared' prop
135
+ */
136
+ React.useEffect(() => {
137
+ if (liveCanvas && isCursorShared !== undefined) {
138
+ liveCanvas.isCursorShared = isCursorShared;
139
+ }
140
+ }, [isCursorShared, liveCanvas]);
141
+ /**
142
+ * Sets the onGetLocalUserInfo method of the liveCanvas based on the 'localUserCursor' prop
143
+ */
144
+ React.useEffect(() => {
145
+ if (liveCanvas && localUserPictureUrl) {
146
+ liveCanvas.onGetLocalUserPictureUrl = () => {
147
+ return localUserPictureUrl;
148
+ };
149
+ }
150
+ }, [localUserPictureUrl, liveCanvas]);
151
+ /**
152
+ * Return hook response
153
+ */
154
+ return {
155
+ inkingManager,
156
+ liveCanvas,
157
+ };
158
+ }
159
+ //# sourceMappingURL=useLiveCanvas.js.map
@@ -0,0 +1 @@
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,EAC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E,SAAS,CAAC,IAAI;gBACpB,QAAQ,EAAE,SAAS,CAAC,QAAQ;aAC/B,CAAC;SACL;IACL,CAAC,EAAE;QACC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,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"}
@@ -0,0 +1,28 @@
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 { IUseLiveCoPilotResults } from "../types";
7
+ /**
8
+ * React hook for using a Live Share Turbo `LiveCoPilot`. Intended for use with OpenAI's Completion API.
9
+ *
10
+ * @remarks
11
+ * Use this hook to set up an `LiveCoPilot` object, which is used for using AI completions collaboratively at minimal cost.
12
+ *
13
+ * @param uniqueKey the unique key for the `LiveCoPilot`. If one does not yet exist, a new one.
14
+ * @param onGetCompletion React useCallback function that returns a Promise<string> for the latest `promptValue`. Function is intended to
15
+ * communicate with a backend API that uses OpenAI's Completion API.
16
+ * @param allowedRoles Optional. The meeting roles eligible to send events through this object.
17
+ * @param defaultPromptValue Optional. Text that sets the default prompt value. Default value is an empty string.
18
+ * @param autoCompletions Optional. Stateful boolean that when true, will automatically send completions when the `promptValue` changes. Default value is true.
19
+ * @param debounceDelayMilliseconds Optional. Stateful number that changes the debounce interval when `autoCompletions` is true. Default value is 1000.
20
+ * @param lockPrompt Optional. Stateful boolean that when true, will restrict prompt changes to only the user with `haveCompletionLock` set to true. Default
21
+ * value is false.
22
+ * @param lockCompletion Optional. Stateful boolean that when true, will restrict manual completion changes to only the user with `haveCompletionLock`
23
+ * set to true. This does not impact the `autoCompletions` setting, because `autoCompletions` already has this behavior. Default value is false.
24
+ *
25
+ * @returns IUseLiveCoPilotResults object that contains stateful responses and callback methods from `LiveCoPilot`.
26
+ */
27
+ export declare const useLiveCoPilot: (uniqueKey: string, onGetCompletion: (promptValue: string) => Promise<string>, allowedRoles?: UserMeetingRole[], defaultPromptValue?: string, autoCompletions?: boolean, debounceDelayMilliseconds?: number, lockPrompt?: boolean, lockCompletion?: boolean) => IUseLiveCoPilotResults;
28
+ //# sourceMappingURL=useLiveCoPilot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveCoPilot.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLiveCoPilot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc,cACZ,MAAM,iCACc,MAAM,KAAK,QAAQ,MAAM,CAAC,iBAC1C,eAAe,EAAE,uBACX,MAAM,oBACT,OAAO,8BACG,MAAM,eACrB,OAAO,mBACH,OAAO,KACzB,sBA4LF,CAAC"}
@@ -0,0 +1,178 @@
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 { LiveCoPilot, LiveCoPilotEvents } from "@microsoft/live-share-turbo";
15
+ import React from "react";
16
+ import { useDynamicDDS } from "../shared-hooks";
17
+ /**
18
+ * React hook for using a Live Share Turbo `LiveCoPilot`. Intended for use with OpenAI's Completion API.
19
+ *
20
+ * @remarks
21
+ * Use this hook to set up an `LiveCoPilot` object, which is used for using AI completions collaboratively at minimal cost.
22
+ *
23
+ * @param uniqueKey the unique key for the `LiveCoPilot`. If one does not yet exist, a new one.
24
+ * @param onGetCompletion React useCallback function that returns a Promise<string> for the latest `promptValue`. Function is intended to
25
+ * communicate with a backend API that uses OpenAI's Completion API.
26
+ * @param allowedRoles Optional. The meeting roles eligible to send events through this object.
27
+ * @param defaultPromptValue Optional. Text that sets the default prompt value. Default value is an empty string.
28
+ * @param autoCompletions Optional. Stateful boolean that when true, will automatically send completions when the `promptValue` changes. Default value is true.
29
+ * @param debounceDelayMilliseconds Optional. Stateful number that changes the debounce interval when `autoCompletions` is true. Default value is 1000.
30
+ * @param lockPrompt Optional. Stateful boolean that when true, will restrict prompt changes to only the user with `haveCompletionLock` set to true. Default
31
+ * value is false.
32
+ * @param lockCompletion Optional. Stateful boolean that when true, will restrict manual completion changes to only the user with `haveCompletionLock`
33
+ * set to true. This does not impact the `autoCompletions` setting, because `autoCompletions` already has this behavior. Default value is false.
34
+ *
35
+ * @returns IUseLiveCoPilotResults object that contains stateful responses and callback methods from `LiveCoPilot`.
36
+ */
37
+ export const useLiveCoPilot = (uniqueKey, onGetCompletion, allowedRoles, defaultPromptValue, autoCompletions, debounceDelayMilliseconds, lockPrompt, lockCompletion) => {
38
+ /**
39
+ * @see IUseLiveCoPilotResults["promptValue"]
40
+ */
41
+ const [promptValue, setPromptValue] = React.useState("");
42
+ /**
43
+ * @see IUseLiveCoPilotResults["completionValue"]
44
+ */
45
+ const [completionValue, setCompletionValue] = React.useState();
46
+ /**
47
+ * @see IUseLiveCoPilotResults["haveCompletionLock"]
48
+ */
49
+ const [haveCompletionLock, setHaveCompletionLock] = React.useState(false);
50
+ /**
51
+ * User facing: dynamically load the DDS for the given unique key.
52
+ */
53
+ const { dds: liveCoPilot } = useDynamicDDS(uniqueKey, LiveCoPilot);
54
+ /**
55
+ * @see IUseLiveCoPilotResults["changePrompt"]
56
+ */
57
+ const changePrompt = React.useCallback((value) => {
58
+ if (liveCoPilot === undefined) {
59
+ console.error(new Error("Cannot call emitEvent when liveEvent is undefined"));
60
+ return;
61
+ }
62
+ if (!liveCoPilot.isInitialized) {
63
+ console.error(new Error("Cannot call emitEvent while liveEvent is not started"));
64
+ return;
65
+ }
66
+ return liveCoPilot.changePrompt(value);
67
+ }, [liveCoPilot]);
68
+ /**
69
+ * @see IUseLiveCoPilotResults["changePrompt"]
70
+ */
71
+ const sendCompletion = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
72
+ if (liveCoPilot === undefined) {
73
+ throw new Error("Cannot call sendCompletion while `liveCoPilot` is undefined");
74
+ }
75
+ if (!liveCoPilot.isInitialized) {
76
+ throw new Error("Cannot call sendCompletion while `liveCoPilot` is not initialized");
77
+ }
78
+ return liveCoPilot.sendCompletion();
79
+ }), [liveCoPilot]);
80
+ /**
81
+ * Sets up the `LiveCoPilot` instance.
82
+ */
83
+ React.useEffect(() => {
84
+ if (liveCoPilot === undefined)
85
+ return;
86
+ // Register event listeners
87
+ const onPromptChanged = (promptValue, local, completionValuePromise) => __awaiter(void 0, void 0, void 0, function* () {
88
+ setPromptValue(promptValue);
89
+ if (!liveCoPilot.haveValidCompletionValue) {
90
+ setCompletionValue(undefined);
91
+ }
92
+ try {
93
+ const completionValue = yield completionValuePromise;
94
+ setCompletionValue(completionValue);
95
+ }
96
+ catch (_a) {
97
+ // We do nothing, since this typically fails as a result of a new prompt value replacing the old on, permissions changing, etc.
98
+ }
99
+ });
100
+ const onLockGranted = () => {
101
+ setHaveCompletionLock(true);
102
+ };
103
+ const onLockLost = () => {
104
+ setHaveCompletionLock(true);
105
+ };
106
+ liveCoPilot.on(LiveCoPilotEvents.promptChanged, onPromptChanged);
107
+ liveCoPilot.on(LiveCoPilotEvents.lockGranted, onLockGranted);
108
+ liveCoPilot.on(LiveCoPilotEvents.lockLost, onLockLost);
109
+ if (!liveCoPilot.isInitialized) {
110
+ // Initialize the LiveCoPilot instance
111
+ liveCoPilot.initialize(onGetCompletion, allowedRoles, defaultPromptValue);
112
+ }
113
+ return () => {
114
+ // on unmount, remove event listeners
115
+ liveCoPilot === null || liveCoPilot === void 0 ? void 0 : liveCoPilot.off(LiveCoPilotEvents.promptChanged, onPromptChanged);
116
+ liveCoPilot === null || liveCoPilot === void 0 ? void 0 : liveCoPilot.off(LiveCoPilotEvents.lockGranted, onLockGranted);
117
+ liveCoPilot === null || liveCoPilot === void 0 ? void 0 : liveCoPilot.off(LiveCoPilotEvents.lockLost, onLockLost);
118
+ };
119
+ }, [liveCoPilot]);
120
+ /**
121
+ * Sets the onGetCompletion of the `liveCoPilot` based on the 'onGetCompletion' prop
122
+ */
123
+ React.useEffect(() => {
124
+ if ((liveCoPilot === null || liveCoPilot === void 0 ? void 0 : liveCoPilot.isInitialized) === true &&
125
+ onGetCompletion !== undefined) {
126
+ liveCoPilot.onGetCompletion = onGetCompletion;
127
+ }
128
+ }, [liveCoPilot === null || liveCoPilot === void 0 ? void 0 : liveCoPilot.isInitialized, onGetCompletion]);
129
+ /**
130
+ * Sets the autoCompletions of the `liveCoPilot` based on the 'autoCompletions' prop
131
+ */
132
+ React.useEffect(() => {
133
+ if (liveCoPilot !== undefined &&
134
+ autoCompletions !== undefined &&
135
+ liveCoPilot.autoCompletions !== autoCompletions) {
136
+ liveCoPilot.autoCompletions = autoCompletions;
137
+ }
138
+ }, [liveCoPilot === null || liveCoPilot === void 0 ? void 0 : liveCoPilot.autoCompletions, autoCompletions]);
139
+ /**
140
+ * Sets the debounceDelayMilliseconds of the `liveCoPilot` based on the 'debounceDelayMilliseconds' prop
141
+ */
142
+ React.useEffect(() => {
143
+ if (liveCoPilot !== undefined &&
144
+ debounceDelayMilliseconds !== undefined &&
145
+ liveCoPilot.debounceDelayMilliseconds !== debounceDelayMilliseconds) {
146
+ liveCoPilot.debounceDelayMilliseconds = debounceDelayMilliseconds;
147
+ }
148
+ }, [liveCoPilot, debounceDelayMilliseconds]);
149
+ /**
150
+ * Sets the lockPrompt of the `liveCoPilot` based on the 'lockPrompt' prop
151
+ */
152
+ React.useEffect(() => {
153
+ if (liveCoPilot !== undefined &&
154
+ lockPrompt !== undefined &&
155
+ liveCoPilot.lockPrompt !== lockPrompt) {
156
+ liveCoPilot.lockPrompt = lockPrompt;
157
+ }
158
+ }, [liveCoPilot === null || liveCoPilot === void 0 ? void 0 : liveCoPilot.lockPrompt, lockPrompt]);
159
+ /**
160
+ * Sets the lockCompletion of the `liveCoPilot` based on the 'lockCompletion' prop
161
+ */
162
+ React.useEffect(() => {
163
+ if (liveCoPilot !== undefined &&
164
+ lockCompletion !== undefined &&
165
+ liveCoPilot.lockCompletion !== lockCompletion) {
166
+ liveCoPilot.lockCompletion = lockCompletion;
167
+ }
168
+ }, [liveCoPilot === null || liveCoPilot === void 0 ? void 0 : liveCoPilot.lockCompletion, lockCompletion]);
169
+ return {
170
+ changePrompt,
171
+ completionValue,
172
+ haveCompletionLock,
173
+ liveCoPilot,
174
+ promptValue,
175
+ sendCompletion,
176
+ };
177
+ };
178
+ //# sourceMappingURL=useLiveCoPilot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveCoPilot.js","sourceRoot":"","sources":["../../src/live-hooks/useLiveCoPilot.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;AAGH,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC1B,SAAiB,EACjB,eAAyD,EACzD,YAAgC,EAChC,kBAA2B,EAC3B,eAAyB,EACzB,yBAAkC,EAClC,UAAoB,EACpB,cAAwB,EACF,EAAE;IACxB;;OAEG;IACH,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAS,EAAE,CAAC,CAAC;IACjE;;OAEG;IACH,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAU,CAAC;IACvE;;OAEG;IACH,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAC7C,KAAK,CAAC,QAAQ,CAAU,KAAK,CAAC,CAAC;IACnC;;OAEG;IACH,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,aAAa,CACtC,SAAS,EACT,WAAW,CACd,CAAC;IAEF;;OAEG;IACH,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAClC,CAAC,KAAa,EAAE,EAAE;QACd,IAAI,WAAW,KAAK,SAAS,EAAE;YAC3B,OAAO,CAAC,KAAK,CACT,IAAI,KAAK,CACL,mDAAmD,CACtD,CACJ,CAAC;YACF,OAAO;SACV;QAC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CAAC,eAAe,GAAG,eAAe,CAAC;SACjD;IACL,CAAC,EAAE,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC;IAEpD;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IACI,WAAW,KAAK,SAAS;YACzB,yBAAyB,KAAK,SAAS;YACvC,WAAW,CAAC,yBAAyB,KAAK,yBAAyB,EACrE;YACE,WAAW,CAAC,yBAAyB,GAAG,yBAAyB,CAAC;SACrE;IACL,CAAC,EAAE,CAAC,WAAW,EAAE,yBAAyB,CAAC,CAAC,CAAC;IAE7C;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IACI,WAAW,KAAK,SAAS;YACzB,UAAU,KAAK,SAAS;YACxB,WAAW,CAAC,UAAU,KAAK,UAAU,EACvC;YACE,WAAW,CAAC,UAAU,GAAG,UAAU,CAAC;SACvC;IACL,CAAC,EAAE,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAE1C;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IACI,WAAW,KAAK,SAAS;YACzB,cAAc,KAAK,SAAS;YAC5B,WAAW,CAAC,cAAc,KAAK,cAAc,EAC/C;YACE,WAAW,CAAC,cAAc,GAAG,cAAc,CAAC;SAC/C;IACL,CAAC,EAAE,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;IAElD,OAAO;QACH,YAAY;QACZ,eAAe;QACf,kBAAkB;QAClB,WAAW;QACX,WAAW;QACX,cAAc;KACjB,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +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 extends object = object>(uniqueKey: string, allowedRoles?: UserMeetingRole[], onReceivedEvent?: OnReceivedLiveEventAction<TEvent>): IUseLiveEventResults<TEvent>;
22
+ //# 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,EAElB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,oBAAoB,EACpB,yBAAyB,EAE5B,MAAM,UAAU,CAAC;AAIlB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,EACvD,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,eAAe,EAAE,EAChC,eAAe,CAAC,EAAE,yBAAyB,CAAC,MAAM,CAAC,GACpD,oBAAoB,CAAC,MAAM,CAAC,CA2E9B"}