@microsoft/live-share-react 1.0.0-preview.22 → 1.0.0-preview.24

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 (173) hide show
  1. package/README.md +7 -10
  2. package/bin/interfaces/LiveInterfaceExtensions.d.ts +17 -0
  3. package/bin/interfaces/LiveInterfaceExtensions.d.ts.map +1 -1
  4. package/bin/internal/errors.d.ts +26 -0
  5. package/bin/internal/errors.d.ts.map +1 -0
  6. package/bin/internal/errors.js +39 -0
  7. package/bin/internal/errors.js.map +1 -0
  8. package/bin/internal/index.d.ts +4 -0
  9. package/bin/internal/index.d.ts.map +1 -0
  10. package/bin/internal/index.js +4 -0
  11. package/bin/internal/index.js.map +1 -0
  12. package/bin/internal/type-guards.d.ts +6 -0
  13. package/bin/internal/type-guards.d.ts.map +1 -0
  14. package/bin/internal/type-guards.js +8 -0
  15. package/bin/internal/type-guards.js.map +1 -0
  16. package/bin/internal/useSharedStateRegistry.d.ts.map +1 -0
  17. package/bin/internal/useSharedStateRegistry.js.map +1 -0
  18. package/bin/live-hooks/useLiveEvent.d.ts.map +1 -1
  19. package/bin/live-hooks/useLiveEvent.js +12 -4
  20. package/bin/live-hooks/useLiveEvent.js.map +1 -1
  21. package/bin/live-hooks/useLivePresence.d.ts +2 -2
  22. package/bin/live-hooks/useLivePresence.d.ts.map +1 -1
  23. package/bin/live-hooks/useLivePresence.js +19 -14
  24. package/bin/live-hooks/useLivePresence.js.map +1 -1
  25. package/bin/live-hooks/useLiveState.d.ts +2 -2
  26. package/bin/live-hooks/useLiveState.d.ts.map +1 -1
  27. package/bin/live-hooks/useLiveState.js +15 -8
  28. package/bin/live-hooks/useLiveState.js.map +1 -1
  29. package/bin/live-hooks/useLiveTimer.d.ts.map +1 -1
  30. package/bin/live-hooks/useLiveTimer.js +21 -15
  31. package/bin/live-hooks/useLiveTimer.js.map +1 -1
  32. package/bin/live-hooks/useMediaSynchronizer.d.ts.map +1 -1
  33. package/bin/live-hooks/useMediaSynchronizer.js +31 -12
  34. package/bin/live-hooks/useMediaSynchronizer.js.map +1 -1
  35. package/bin/providers/AzureProvider.d.ts +1 -1
  36. package/bin/providers/AzureProvider.d.ts.map +1 -1
  37. package/bin/providers/AzureProvider.js +1 -1
  38. package/bin/providers/AzureProvider.js.map +1 -1
  39. package/bin/providers/LiveShareProvider.js +1 -1
  40. package/bin/providers/LiveShareProvider.js.map +1 -1
  41. package/bin/shared-hooks/useSharedMap.d.ts.map +1 -1
  42. package/bin/shared-hooks/useSharedMap.js +15 -8
  43. package/bin/shared-hooks/useSharedMap.js.map +1 -1
  44. package/bin/shared-hooks/useSharedState.d.ts.map +1 -1
  45. package/bin/shared-hooks/useSharedState.js +9 -3
  46. package/bin/shared-hooks/useSharedState.js.map +1 -1
  47. package/bin/types/ActionTypes.d.ts +8 -2
  48. package/bin/types/ActionTypes.d.ts.map +1 -1
  49. package/package.json +9 -9
  50. package/src/interfaces/LiveInterfaceExtensions.ts +17 -0
  51. package/src/internal/errors.ts +48 -0
  52. package/src/internal/index.ts +3 -0
  53. package/src/internal/type-guards.ts +9 -0
  54. package/src/live-hooks/useLiveEvent.ts +29 -6
  55. package/src/live-hooks/useLivePresence.ts +33 -21
  56. package/src/live-hooks/useLiveState.ts +31 -17
  57. package/src/live-hooks/useLiveTimer.ts +32 -26
  58. package/src/live-hooks/useMediaSynchronizer.ts +60 -8
  59. package/src/providers/AzureProvider.tsx +1 -1
  60. package/src/providers/LiveShareProvider.tsx +1 -1
  61. package/src/shared-hooks/useSharedMap.ts +29 -10
  62. package/src/shared-hooks/useSharedState.ts +9 -3
  63. package/src/types/ActionTypes.ts +10 -2
  64. package/bin/internal-hooks/index.d.ts +0 -2
  65. package/bin/internal-hooks/index.d.ts.map +0 -1
  66. package/bin/internal-hooks/index.js +0 -2
  67. package/bin/internal-hooks/index.js.map +0 -1
  68. package/bin/internal-hooks/useDynamicDDSRegistry.d.ts +0 -14
  69. package/bin/internal-hooks/useDynamicDDSRegistry.d.ts.map +0 -1
  70. package/bin/internal-hooks/useDynamicDDSRegistry.js +0 -142
  71. package/bin/internal-hooks/useDynamicDDSRegistry.js.map +0 -1
  72. package/bin/internal-hooks/useSharedStateRegistry.d.ts.map +0 -1
  73. package/bin/internal-hooks/useSharedStateRegistry.js.map +0 -1
  74. package/bin/internal-hooks/useStateRef.d.ts +0 -7
  75. package/bin/internal-hooks/useStateRef.d.ts.map +0 -1
  76. package/bin/internal-hooks/useStateRef.js +0 -15
  77. package/bin/internal-hooks/useStateRef.js.map +0 -1
  78. package/bin/live-hooks/useLiveAICompletion.d.ts +0 -29
  79. package/bin/live-hooks/useLiveAICompletion.d.ts.map +0 -1
  80. package/bin/live-hooks/useLiveAICompletion.js +0 -186
  81. package/bin/live-hooks/useLiveAICompletion.js.map +0 -1
  82. package/bin/live-hooks/useLiveCoPilot.d.ts +0 -28
  83. package/bin/live-hooks/useLiveCoPilot.d.ts.map +0 -1
  84. package/bin/live-hooks/useLiveCoPilot.js +0 -178
  85. package/bin/live-hooks/useLiveCoPilot.js.map +0 -1
  86. package/bin/live-share-turbo/AzureTurboClient.d.ts +0 -39
  87. package/bin/live-share-turbo/AzureTurboClient.d.ts.map +0 -1
  88. package/bin/live-share-turbo/AzureTurboClient.js +0 -56
  89. package/bin/live-share-turbo/AzureTurboClient.js.map +0 -1
  90. package/bin/live-share-turbo/LiveShareTurboClient.d.ts +0 -53
  91. package/bin/live-share-turbo/LiveShareTurboClient.d.ts.map +0 -1
  92. package/bin/live-share-turbo/LiveShareTurboClient.js +0 -69
  93. package/bin/live-share-turbo/LiveShareTurboClient.js.map +0 -1
  94. package/bin/live-share-turbo/dds-objects/TurboDataObject.d.ts +0 -31
  95. package/bin/live-share-turbo/dds-objects/TurboDataObject.d.ts.map +0 -1
  96. package/bin/live-share-turbo/dds-objects/TurboDataObject.js +0 -75
  97. package/bin/live-share-turbo/dds-objects/TurboDataObject.js.map +0 -1
  98. package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.d.ts +0 -48
  99. package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.d.ts.map +0 -1
  100. package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.js +0 -104
  101. package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.js.map +0 -1
  102. package/bin/live-share-turbo/dds-objects/TurboLiveEvent.d.ts +0 -28
  103. package/bin/live-share-turbo/dds-objects/TurboLiveEvent.d.ts.map +0 -1
  104. package/bin/live-share-turbo/dds-objects/TurboLiveEvent.js +0 -68
  105. package/bin/live-share-turbo/dds-objects/TurboLiveEvent.js.map +0 -1
  106. package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.d.ts +0 -60
  107. package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.d.ts.map +0 -1
  108. package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.js +0 -111
  109. package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.js.map +0 -1
  110. package/bin/live-share-turbo/dds-objects/TurboLivePresence.d.ts +0 -77
  111. package/bin/live-share-turbo/dds-objects/TurboLivePresence.d.ts.map +0 -1
  112. package/bin/live-share-turbo/dds-objects/TurboLivePresence.js +0 -137
  113. package/bin/live-share-turbo/dds-objects/TurboLivePresence.js.map +0 -1
  114. package/bin/live-share-turbo/dds-objects/TurboLiveState.d.ts +0 -30
  115. package/bin/live-share-turbo/dds-objects/TurboLiveState.d.ts.map +0 -1
  116. package/bin/live-share-turbo/dds-objects/TurboLiveState.js +0 -74
  117. package/bin/live-share-turbo/dds-objects/TurboLiveState.js.map +0 -1
  118. package/bin/live-share-turbo/dds-objects/TurboSharedMap.d.ts +0 -61
  119. package/bin/live-share-turbo/dds-objects/TurboSharedMap.d.ts.map +0 -1
  120. package/bin/live-share-turbo/dds-objects/TurboSharedMap.js +0 -108
  121. package/bin/live-share-turbo/dds-objects/TurboSharedMap.js.map +0 -1
  122. package/bin/live-share-turbo/dds-objects/index.d.ts +0 -8
  123. package/bin/live-share-turbo/dds-objects/index.d.ts.map +0 -1
  124. package/bin/live-share-turbo/dds-objects/index.js +0 -8
  125. package/bin/live-share-turbo/dds-objects/index.js.map +0 -1
  126. package/bin/live-share-turbo/index.d.ts +0 -5
  127. package/bin/live-share-turbo/index.d.ts.map +0 -1
  128. package/bin/live-share-turbo/index.js +0 -5
  129. package/bin/live-share-turbo/index.js.map +0 -1
  130. package/bin/live-share-turbo/interfaces/IFluidTurboClient.d.ts +0 -15
  131. package/bin/live-share-turbo/interfaces/IFluidTurboClient.d.ts.map +0 -1
  132. package/bin/live-share-turbo/interfaces/IFluidTurboClient.js +0 -2
  133. package/bin/live-share-turbo/interfaces/IFluidTurboClient.js.map +0 -1
  134. package/bin/live-share-turbo/interfaces/index.d.ts +0 -3
  135. package/bin/live-share-turbo/interfaces/index.d.ts.map +0 -1
  136. package/bin/live-share-turbo/interfaces/index.js +0 -3
  137. package/bin/live-share-turbo/interfaces/index.js.map +0 -1
  138. package/bin/live-share-turbo/internals/FluidTurboClient.d.ts +0 -39
  139. package/bin/live-share-turbo/internals/FluidTurboClient.d.ts.map +0 -1
  140. package/bin/live-share-turbo/internals/FluidTurboClient.js +0 -121
  141. package/bin/live-share-turbo/internals/FluidTurboClient.js.map +0 -1
  142. package/bin/live-share-turbo/internals/index.d.ts +0 -2
  143. package/bin/live-share-turbo/internals/index.d.ts.map +0 -1
  144. package/bin/live-share-turbo/internals/index.js +0 -2
  145. package/bin/live-share-turbo/internals/index.js.map +0 -1
  146. package/bin/live-share-turbo/internals/types.d.ts +0 -4
  147. package/bin/live-share-turbo/internals/types.d.ts.map +0 -1
  148. package/bin/live-share-turbo/internals/types.js +0 -2
  149. package/bin/live-share-turbo/internals/types.js.map +0 -1
  150. package/bin/providers/FluidContextProvider.d.ts +0 -34
  151. package/bin/providers/FluidContextProvider.d.ts.map +0 -1
  152. package/bin/providers/FluidContextProvider.js +0 -99
  153. package/bin/providers/FluidContextProvider.js.map +0 -1
  154. package/bin/providers/LiveShareContextProvider.d.ts +0 -42
  155. package/bin/providers/LiveShareContextProvider.d.ts.map +0 -1
  156. package/bin/providers/LiveShareContextProvider.js +0 -63
  157. package/bin/providers/LiveShareContextProvider.js.map +0 -1
  158. package/bin/shared-hooks/useLockedTask.d.ts +0 -11
  159. package/bin/shared-hooks/useLockedTask.d.ts.map +0 -1
  160. package/bin/shared-hooks/useLockedTask.js +0 -82
  161. package/bin/shared-hooks/useLockedTask.js.map +0 -1
  162. package/bin/shared-hooks/useTaskManager.d.ts +0 -13
  163. package/bin/shared-hooks/useTaskManager.d.ts.map +0 -1
  164. package/bin/shared-hooks/useTaskManager.js +0 -86
  165. package/bin/shared-hooks/useTaskManager.js.map +0 -1
  166. package/bin/utils/getContainerSchema.d.ts +0 -8
  167. package/bin/utils/getContainerSchema.d.ts.map +0 -1
  168. package/bin/utils/getContainerSchema.js +0 -41
  169. package/bin/utils/getContainerSchema.js.map +0 -1
  170. package/src/internal-hooks/index.ts +0 -1
  171. /package/bin/{internal-hooks → internal}/useSharedStateRegistry.d.ts +0 -0
  172. /package/bin/{internal-hooks → internal}/useSharedStateRegistry.js +0 -0
  173. /package/src/{internal-hooks → internal}/useSharedStateRegistry.ts +0 -0
@@ -1,142 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { useCallback, useEffect, useRef } from "react";
11
- /**
12
- * Hook used internally to keep track of the DDSSetStateActionMap for each unique key. It gets DDS objects for provided keys where they exist and creates
13
- * them where they do not, providing the DDS objects to components that use them.
14
- *
15
- * @param results IAzureContainerResults response or undefined
16
- * @returns IDynamicDDSRegistry object
17
- */
18
- export const useDynamicDDSRegistry = (results) => {
19
- const registeredDDSSetStateActionMapRef = useRef(new Map());
20
- // Get the DDS from dynamicObjects for a given key, if known
21
- const getDDS = useCallback((key) => __awaiter(void 0, void 0, void 0, function* () {
22
- const dynamicObjectMap = results === null || results === void 0 ? void 0 : results.container.initialObjects.dynamicObjects;
23
- if (dynamicObjectMap) {
24
- const handleValue = dynamicObjectMap.get(key);
25
- if (handleValue) {
26
- const dds = yield handleValue.get();
27
- return dds;
28
- }
29
- else {
30
- return undefined;
31
- }
32
- }
33
- else {
34
- throw new Error("getDDS should never be called if dynamicObjects is undefined");
35
- }
36
- }), [results]);
37
- // Create a new DDS of type T in dynamicObjects
38
- const createDDS = useCallback((key, objectClass) => __awaiter(void 0, void 0, void 0, function* () {
39
- const dynamicObjectMap = results === null || results === void 0 ? void 0 : results.container.initialObjects.dynamicObjects;
40
- if (dynamicObjectMap) {
41
- // Create a new DDS and set the handle to the DDS
42
- const dds = yield results.container.create(objectClass);
43
- dynamicObjectMap.set(key, dds.handle);
44
- return dds;
45
- }
46
- else {
47
- throw new Error("createDDS: should never be called if dynamicObjectsMap is undefined");
48
- }
49
- }), [results]);
50
- // Callback for hooks (e.g., useSharedMap) to register a new set state action so they
51
- // always have the most recent DDS. If one does not exist, we create it here.
52
- const registerDDSSetStateAction = useCallback((uniqueKey, componentId, objectClass, setLocalStateAction, onDidFirstInitialize) => __awaiter(void 0, void 0, void 0, function* () {
53
- let shouldCreateIfNeeded = false;
54
- let actionsMap = registeredDDSSetStateActionMapRef.current.get(uniqueKey);
55
- if (actionsMap) {
56
- if (!actionsMap.has(componentId)) {
57
- shouldCreateIfNeeded = true;
58
- actionsMap.set(componentId, setLocalStateAction);
59
- }
60
- }
61
- else {
62
- shouldCreateIfNeeded = true;
63
- actionsMap = new Map();
64
- actionsMap.set(componentId, setLocalStateAction);
65
- registeredDDSSetStateActionMapRef.current.set(uniqueKey, actionsMap);
66
- }
67
- try {
68
- // Set initial values, if known
69
- let dds = yield getDDS(uniqueKey);
70
- if (dds) {
71
- setLocalStateAction(dds);
72
- }
73
- else if (shouldCreateIfNeeded) {
74
- // Create a new DDS of type T
75
- dds = yield createDDS(uniqueKey, objectClass);
76
- setLocalStateAction(dds);
77
- onDidFirstInitialize === null || onDidFirstInitialize === void 0 ? void 0 : onDidFirstInitialize(dds);
78
- }
79
- }
80
- catch (error) {
81
- throw error;
82
- }
83
- }), [results]);
84
- // Callback for hooks (e.g., useSharedMap) to unregister their set state actions
85
- const unregisterDDSSetStateAction = useCallback((uniqueKey, componentId) => {
86
- let actionsMap = registeredDDSSetStateActionMapRef.current.get(uniqueKey);
87
- if (actionsMap === null || actionsMap === void 0 ? void 0 : actionsMap.has(componentId)) {
88
- actionsMap.delete(componentId);
89
- }
90
- }, []);
91
- // Initial setup
92
- useEffect(() => {
93
- if (!results)
94
- return;
95
- const { container } = results;
96
- const dynamicObjectMap = container.initialObjects
97
- .dynamicObjects;
98
- // Register value changed listener
99
- const valueChangedListener = (changed, local) => {
100
- if (local)
101
- return;
102
- if (registeredDDSSetStateActionMapRef.current.has(changed.key)) {
103
- const actionMap = registeredDDSSetStateActionMapRef.current.get(changed.key);
104
- // Get the DDS for the changed value, if known
105
- getDDS(changed.key)
106
- .then((dds) => {
107
- // Update each component that has registered an action in actionMap
108
- actionMap === null || actionMap === void 0 ? void 0 : actionMap.forEach((setLocalStateHandler) => {
109
- setLocalStateHandler(dds);
110
- });
111
- })
112
- .catch((error) => console.error(error));
113
- }
114
- };
115
- dynamicObjectMap.on("valueChanged", valueChangedListener);
116
- // Set initial values
117
- dynamicObjectMap.forEach((handleValue, key) => {
118
- const actionMap = registeredDDSSetStateActionMapRef.current.get(key);
119
- if (handleValue) {
120
- handleValue
121
- .get()
122
- .then((dds) => {
123
- // Update each component that has registered an action in actionMap
124
- actionMap === null || actionMap === void 0 ? void 0 : actionMap.forEach((setLocalStateHandler) => {
125
- setLocalStateHandler(dds);
126
- });
127
- })
128
- .catch((error) => {
129
- console.error(error);
130
- });
131
- }
132
- });
133
- return () => {
134
- dynamicObjectMap.off("valueChanged", valueChangedListener);
135
- };
136
- }, [results]);
137
- return {
138
- registerDDSSetStateAction,
139
- unregisterDDSSetStateAction,
140
- };
141
- };
142
- //# sourceMappingURL=useDynamicDDSRegistry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDynamicDDSRegistry.js","sourceRoot":"","sources":["../../src/internal-hooks/useDynamicDDSRegistry.ts"],"names":[],"mappings":";;;;;;;;;AAOA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAavD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACjC,OAA2C,EACxB,EAAE;IACrB,MAAM,iCAAiC,GAAG,MAAM,CAE9C,IAAI,GAAG,EAAE,CAAC,CAAC;IAEb,4DAA4D;IAC5D,MAAM,MAAM,GAAG,WAAW,CACtB,CACI,GAAW,EACW,EAAE;QACxB,MAAM,gBAAgB,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC,cAAc,CACrD,cAAuC,CAAC;QAC7C,IAAI,gBAAgB,EAAE;YAClB,MAAM,WAAW,GAAG,gBAAgB,CAAC,GAAG,CAEtC,GAAG,CAAC,CAAC;YACP,IAAI,WAAW,EAAE;gBACb,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE,CAAC;gBACpC,OAAO,GAAG,CAAC;aACd;iBAAM;gBACH,OAAO,SAAS,CAAC;aACpB;SACJ;aAAM;YACH,MAAM,IAAI,KAAK,CACX,8DAA8D,CACjE,CAAC;SACL;IACL,CAAC,CAAA,EACD,CAAC,OAAO,CAAC,CACZ,CAAC;IAEF,+CAA+C;IAC/C,MAAM,SAAS,GAAG,WAAW,CACzB,CACI,GAAW,EACX,WAAmC,EACzB,EAAE;QACZ,MAAM,gBAAgB,GAAG,OAAO,aAAP,OAAO,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"version":3,"file":"useSharedStateRegistry.d.ts","sourceRoot":"","sources":["../../src/internal-hooks/useSharedStateRegistry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACH,uBAAuB,EACvB,sBAAsB,EACtB,4BAA4B,EAE5B,8BAA8B,EAC9B,uBAAuB,EAC1B,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,4BAA4B;IACzC;;OAEG;IACH,4BAA4B,EAAE,4BAA4B,CAAC;IAC3D;;OAEG;IACH,8BAA8B,EAAE,8BAA8B,CAAC;IAC/D;;OAEG;IACH,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C;;OAEG;IACH,iBAAiB,EAAE,uBAAuB,CAAC;CAC9C;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,YACtB,sBAAsB,GAAG,SAAS,KAC5C,4BAwHF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSharedStateRegistry.js","sourceRoot":"","sources":["../../src/internal-hooks/useSharedStateRegistry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AA6B1B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAClC,OAA2C,EACf,EAAE;IAC9B,MAAM,oCAAoC,GAAG,KAAK,CAAC,MAAM,CAEvD,IAAI,GAAG,EAAE,CAAC,CAAC;IAEb;;OAEG;IACH,MAAM,4BAA4B,GAAG,KAAK,CAAC,WAAW,CAClD,CACI,SAAiB,EACjB,WAAmB,EACnB,mBAAwC,EAC1C,EAAE;QACA,IAAI,UAAU,GACV,oCAAoC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAChE,IAAI,UAAU,EAAE;YACZ,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;gBAC9B,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;aACpD;SACJ;aAAM;YACH,UAAU,GAAG,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AE,GAAW,EAAE,EAAE;YACzC,MAAM,SAAS,GACX,oCAAoC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC1D,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,CAAC,CAAC,oBAAoB,EAAE,EAAE;gBACxC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACR,QAAQ,CAAC,GAAG,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC;QACvD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO;QACH,4BAA4B;QAC5B,8BAA8B;QAC9B,iBAAiB;QACjB,iBAAiB;KACpB,CAAC;AACN,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { MutableRefObject } from "react";
6
- export declare function useStateRef<T>(initialValue: T): [T, MutableRefObject<T>, (value: T) => void];
7
- //# sourceMappingURL=useStateRef.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useStateRef.d.ts","sourceRoot":"","sources":["../../src/internal-hooks/useStateRef.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAiC,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAExE,wBAAgB,WAAW,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAa5F"}
@@ -1,15 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { useState, useRef, useCallback } from "react";
6
- export function useStateRef(initialValue) {
7
- const reference = useRef(initialValue);
8
- const [state, setState] = useState(reference.current);
9
- const setValue = useCallback((value) => {
10
- reference.current = value;
11
- setState(reference.current);
12
- }, [reference, setState]);
13
- return [state, reference, setValue];
14
- }
15
- //# sourceMappingURL=useStateRef.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useStateRef.js","sourceRoot":"","sources":["../../src/internal-hooks/useStateRef.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAoB,MAAM,OAAO,CAAC;AAExE,MAAM,UAAU,WAAW,CAAI,YAAe;IAC5C,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IACvC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAEtD,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,KAAQ,EAAE,EAAE;QACX,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;QAC1B,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC,EACD,CAAC,SAAS,EAAE,QAAQ,CAAC,CACtB,CAAC;IAEF,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AACtC,CAAC"}
@@ -1,29 +0,0 @@
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 { IUseLiveAICompletionResults } from "../types";
7
- /**
8
- * React hook for using a Live Share Turbo `LiveAICompletion`. Intended for use with OpenAI's Completion API.
9
- *
10
- * @remarks
11
- * Use this hook to set up an `LiveAICompletion` object, which is used for using AI completions collaboratively at minimal cost.
12
- *
13
- * @param uniqueKey the unique key for the `LiveAICompletion`. 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
19
- * false.
20
- * @param debounceDelayMilliseconds Optional. Stateful number that changes the debounce interval when `autoCompletions` is true. Default value is 2500.
21
- * @param lockPrompt Optional. Stateful boolean that when true, will restrict prompt changes to only the user with `haveCompletionLock` set to true. Default
22
- * value is false.
23
- * @param lockCompletion Optional. Stateful boolean that when true, will restrict manual completion changes to only the user with `haveCompletionLock`
24
- * set to true. This does not impact the `autoCompletions` setting, because `autoCompletions` already has this behavior. Default value is false.
25
- *
26
- * @returns IUseLiveAICompletionResults object that contains stateful responses and callback methods from `LiveAICompletion`.
27
- */
28
- export declare const useLiveAICompletion: (uniqueKey: string, onGetCompletion: (promptValue: string) => Promise<string>, allowedRoles?: UserMeetingRole[], defaultPromptValue?: string, autoCompletions?: boolean, debounceDelayMilliseconds?: number, lockPrompt?: boolean, lockCompletion?: boolean) => IUseLiveAICompletionResults;
29
- //# sourceMappingURL=useLiveAICompletion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLiveAICompletion.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLiveAICompletion.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAOxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAGvD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,mBAAmB,cACjB,MAAM,iCACc,MAAM,KAAK,QAAQ,MAAM,CAAC,iBAC1C,eAAe,EAAE,uBACX,MAAM,oBACT,OAAO,8BACG,MAAM,eACrB,OAAO,mBACH,OAAO,KACzB,2BAyMF,CAAC"}
@@ -1,186 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLiveAICompletion.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YAAY;QACZ,eAAe;QACf,kBAAkB;QAClB,gBAAgB;QAChB,WAAW;QACX,cAAc;KACjB,CAAC;AACN,CAAC,CAAC"}
@@ -1,28 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,178 +0,0 @@
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