@fluidframework/react 0.41.4 → 2.63.0-358419

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 (342) hide show
  1. package/.eslintrc.cjs +11 -0
  2. package/.mocharc.cjs +15 -0
  3. package/CHANGELOG.md +282 -0
  4. package/README.md +122 -273
  5. package/api-extractor/api-extractor-lint-alpha.cjs.json +5 -0
  6. package/api-extractor/api-extractor-lint-alpha.esm.json +5 -0
  7. package/api-extractor/api-extractor-lint-beta.cjs.json +5 -0
  8. package/api-extractor/api-extractor-lint-beta.esm.json +5 -0
  9. package/api-extractor/api-extractor-lint-bundle.json +5 -0
  10. package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
  11. package/api-extractor/api-extractor-lint-public.esm.json +5 -0
  12. package/api-extractor-lint.json +4 -0
  13. package/api-extractor.json +2 -2
  14. package/api-report/react.alpha.api.md +114 -0
  15. package/api-report/react.beta.api.md +7 -0
  16. package/api-report/react.public.api.md +7 -0
  17. package/biome.jsonc +4 -0
  18. package/dist/alpha.d.ts +45 -0
  19. package/dist/beta.d.ts +15 -0
  20. package/dist/index.d.ts +11 -7
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +19 -17
  23. package/dist/index.js.map +1 -1
  24. package/dist/package.json +4 -0
  25. package/dist/propNode.d.ts +114 -0
  26. package/dist/propNode.d.ts.map +1 -0
  27. package/dist/propNode.js +43 -0
  28. package/dist/propNode.js.map +1 -0
  29. package/dist/public.d.ts +15 -0
  30. package/dist/reactSharedTreeView.d.ts +119 -0
  31. package/dist/reactSharedTreeView.d.ts.map +1 -0
  32. package/dist/reactSharedTreeView.js +206 -0
  33. package/dist/reactSharedTreeView.js.map +1 -0
  34. package/dist/simpleIdentifier.d.ts +19 -0
  35. package/dist/simpleIdentifier.d.ts.map +1 -0
  36. package/dist/simpleIdentifier.js +33 -0
  37. package/dist/simpleIdentifier.js.map +1 -0
  38. package/dist/useObservation.d.ts +83 -0
  39. package/dist/useObservation.d.ts.map +1 -0
  40. package/dist/useObservation.js +295 -0
  41. package/dist/useObservation.js.map +1 -0
  42. package/dist/useTree.d.ts +80 -0
  43. package/dist/useTree.d.ts.map +1 -0
  44. package/dist/useTree.js +137 -0
  45. package/dist/useTree.js.map +1 -0
  46. package/lib/alpha.d.ts +45 -0
  47. package/lib/beta.d.ts +15 -0
  48. package/lib/index.d.ts +16 -0
  49. package/lib/index.d.ts.map +1 -0
  50. package/lib/index.js +4 -7
  51. package/lib/index.js.map +1 -1
  52. package/lib/package.json +4 -0
  53. package/lib/propNode.d.ts +114 -0
  54. package/lib/propNode.d.ts.map +1 -0
  55. package/lib/propNode.js +36 -0
  56. package/lib/propNode.js.map +1 -0
  57. package/lib/public.d.ts +15 -0
  58. package/lib/reactSharedTreeView.d.ts +119 -0
  59. package/lib/reactSharedTreeView.d.ts.map +1 -0
  60. package/lib/reactSharedTreeView.js +176 -0
  61. package/lib/reactSharedTreeView.js.map +1 -0
  62. package/lib/simpleIdentifier.d.ts +19 -0
  63. package/lib/simpleIdentifier.d.ts.map +1 -0
  64. package/lib/simpleIdentifier.js +29 -0
  65. package/lib/simpleIdentifier.js.map +1 -0
  66. package/lib/test/propNode.spec.js +120 -0
  67. package/lib/test/propNode.spec.js.map +1 -0
  68. package/lib/test/reactSharedTreeView.spec.js +71 -0
  69. package/lib/test/reactSharedTreeView.spec.js.map +1 -0
  70. package/lib/test/simpleIdentifier.spec.js +18 -0
  71. package/lib/test/simpleIdentifier.spec.js.map +1 -0
  72. package/lib/test/useObservation.spec.js +162 -0
  73. package/lib/test/useObservation.spec.js.map +1 -0
  74. package/lib/test/useTree.spec.js +165 -0
  75. package/lib/test/useTree.spec.js.map +1 -0
  76. package/lib/tsdoc-metadata.json +11 -0
  77. package/lib/useObservation.d.ts +83 -0
  78. package/lib/useObservation.d.ts.map +1 -0
  79. package/lib/useObservation.js +266 -0
  80. package/lib/useObservation.js.map +1 -0
  81. package/lib/useTree.d.ts +80 -0
  82. package/lib/useTree.d.ts.map +1 -0
  83. package/lib/useTree.js +105 -0
  84. package/lib/useTree.js.map +1 -0
  85. package/package.json +150 -51
  86. package/react.test-files.tar +0 -0
  87. package/src/index.ts +42 -7
  88. package/src/propNode.ts +164 -0
  89. package/src/reactSharedTreeView.tsx +327 -0
  90. package/src/simpleIdentifier.ts +31 -0
  91. package/src/useObservation.ts +376 -0
  92. package/src/useTree.ts +147 -0
  93. package/tsconfig.cjs.json +7 -0
  94. package/tsconfig.json +12 -15
  95. package/tsdoc.json +4 -0
  96. package/.eslintrc.js +0 -11
  97. package/dist/createContextFluid.d.ts +0 -7
  98. package/dist/createContextFluid.d.ts.map +0 -1
  99. package/dist/createContextFluid.js +0 -46
  100. package/dist/createContextFluid.js.map +0 -1
  101. package/dist/helpers/generateFluidObjectSchema.d.ts +0 -16
  102. package/dist/helpers/generateFluidObjectSchema.d.ts.map +0 -1
  103. package/dist/helpers/generateFluidObjectSchema.js +0 -75
  104. package/dist/helpers/generateFluidObjectSchema.js.map +0 -1
  105. package/dist/helpers/getFluidFromView.d.ts +0 -15
  106. package/dist/helpers/getFluidFromView.d.ts.map +0 -1
  107. package/dist/helpers/getFluidFromView.js +0 -30
  108. package/dist/helpers/getFluidFromView.js.map +0 -1
  109. package/dist/helpers/getFluidState.d.ts +0 -15
  110. package/dist/helpers/getFluidState.d.ts.map +0 -1
  111. package/dist/helpers/getFluidState.js +0 -47
  112. package/dist/helpers/getFluidState.js.map +0 -1
  113. package/dist/helpers/getSchema.d.ts +0 -13
  114. package/dist/helpers/getSchema.d.ts.map +0 -1
  115. package/dist/helpers/getSchema.js +0 -15
  116. package/dist/helpers/getSchema.js.map +0 -1
  117. package/dist/helpers/getViewFromFluid.d.ts +0 -18
  118. package/dist/helpers/getViewFromFluid.d.ts.map +0 -1
  119. package/dist/helpers/getViewFromFluid.js +0 -47
  120. package/dist/helpers/getViewFromFluid.js.map +0 -1
  121. package/dist/helpers/index.d.ts +0 -16
  122. package/dist/helpers/index.d.ts.map +0 -1
  123. package/dist/helpers/index.js +0 -28
  124. package/dist/helpers/index.js.map +0 -1
  125. package/dist/helpers/initializeState.d.ts +0 -22
  126. package/dist/helpers/initializeState.d.ts.map +0 -1
  127. package/dist/helpers/initializeState.js +0 -77
  128. package/dist/helpers/initializeState.js.map +0 -1
  129. package/dist/helpers/internalInterface.d.ts +0 -15
  130. package/dist/helpers/internalInterface.d.ts.map +0 -1
  131. package/dist/helpers/internalInterface.js +0 -7
  132. package/dist/helpers/internalInterface.js.map +0 -1
  133. package/dist/helpers/rootCallbackListener.d.ts +0 -24
  134. package/dist/helpers/rootCallbackListener.d.ts.map +0 -1
  135. package/dist/helpers/rootCallbackListener.js +0 -55
  136. package/dist/helpers/rootCallbackListener.js.map +0 -1
  137. package/dist/helpers/setComponentSchema.d.ts +0 -14
  138. package/dist/helpers/setComponentSchema.d.ts.map +0 -1
  139. package/dist/helpers/setComponentSchema.js +0 -18
  140. package/dist/helpers/setComponentSchema.js.map +0 -1
  141. package/dist/helpers/setFluidState.d.ts +0 -20
  142. package/dist/helpers/setFluidState.d.ts.map +0 -1
  143. package/dist/helpers/setFluidState.js +0 -94
  144. package/dist/helpers/setFluidState.js.map +0 -1
  145. package/dist/helpers/syncState.d.ts +0 -25
  146. package/dist/helpers/syncState.d.ts.map +0 -1
  147. package/dist/helpers/syncState.js +0 -98
  148. package/dist/helpers/syncState.js.map +0 -1
  149. package/dist/helpers/updateStateAndFluidObjectMap.d.ts +0 -29
  150. package/dist/helpers/updateStateAndFluidObjectMap.d.ts.map +0 -1
  151. package/dist/helpers/updateStateAndFluidObjectMap.js +0 -30
  152. package/dist/helpers/updateStateAndFluidObjectMap.js.map +0 -1
  153. package/dist/helpers/utils.d.ts +0 -12
  154. package/dist/helpers/utils.d.ts.map +0 -1
  155. package/dist/helpers/utils.js +0 -74
  156. package/dist/helpers/utils.js.map +0 -1
  157. package/dist/interface.d.ts +0 -444
  158. package/dist/interface.d.ts.map +0 -1
  159. package/dist/interface.js +0 -18
  160. package/dist/interface.js.map +0 -1
  161. package/dist/reactView.d.ts +0 -32
  162. package/dist/reactView.d.ts.map +0 -1
  163. package/dist/reactView.js +0 -79
  164. package/dist/reactView.js.map +0 -1
  165. package/dist/syncedDataObject.d.ts +0 -80
  166. package/dist/syncedDataObject.d.ts.map +0 -1
  167. package/dist/syncedDataObject.js +0 -249
  168. package/dist/syncedDataObject.js.map +0 -1
  169. package/dist/syncedObjects/array/fluidSyncedArray.d.ts +0 -11
  170. package/dist/syncedObjects/array/fluidSyncedArray.d.ts.map +0 -1
  171. package/dist/syncedObjects/array/fluidSyncedArray.js +0 -78
  172. package/dist/syncedObjects/array/fluidSyncedArray.js.map +0 -1
  173. package/dist/syncedObjects/array/index.d.ts +0 -7
  174. package/dist/syncedObjects/array/index.d.ts.map +0 -1
  175. package/dist/syncedObjects/array/index.js +0 -19
  176. package/dist/syncedObjects/array/index.js.map +0 -1
  177. package/dist/syncedObjects/array/interface.d.ts +0 -33
  178. package/dist/syncedObjects/array/interface.d.ts.map +0 -1
  179. package/dist/syncedObjects/array/interface.js +0 -3
  180. package/dist/syncedObjects/array/interface.js.map +0 -1
  181. package/dist/syncedObjects/array/syncedArray.d.ts +0 -30
  182. package/dist/syncedObjects/array/syncedArray.d.ts.map +0 -1
  183. package/dist/syncedObjects/array/syncedArray.js +0 -42
  184. package/dist/syncedObjects/array/syncedArray.js.map +0 -1
  185. package/dist/syncedObjects/counter/fluidSyncedCounter.d.ts +0 -11
  186. package/dist/syncedObjects/counter/fluidSyncedCounter.d.ts.map +0 -1
  187. package/dist/syncedObjects/counter/fluidSyncedCounter.js +0 -79
  188. package/dist/syncedObjects/counter/fluidSyncedCounter.js.map +0 -1
  189. package/dist/syncedObjects/counter/index.d.ts +0 -7
  190. package/dist/syncedObjects/counter/index.d.ts.map +0 -1
  191. package/dist/syncedObjects/counter/index.js +0 -19
  192. package/dist/syncedObjects/counter/index.js.map +0 -1
  193. package/dist/syncedObjects/counter/interface.d.ts +0 -32
  194. package/dist/syncedObjects/counter/interface.d.ts.map +0 -1
  195. package/dist/syncedObjects/counter/interface.js +0 -3
  196. package/dist/syncedObjects/counter/interface.js.map +0 -1
  197. package/dist/syncedObjects/counter/syncedCounter.d.ts +0 -29
  198. package/dist/syncedObjects/counter/syncedCounter.d.ts.map +0 -1
  199. package/dist/syncedObjects/counter/syncedCounter.js +0 -36
  200. package/dist/syncedObjects/counter/syncedCounter.js.map +0 -1
  201. package/dist/syncedObjects/index.d.ts +0 -9
  202. package/dist/syncedObjects/index.d.ts.map +0 -1
  203. package/dist/syncedObjects/index.js +0 -21
  204. package/dist/syncedObjects/index.js.map +0 -1
  205. package/dist/syncedObjects/object/index.d.ts +0 -7
  206. package/dist/syncedObjects/object/index.d.ts.map +0 -1
  207. package/dist/syncedObjects/object/index.js +0 -19
  208. package/dist/syncedObjects/object/index.js.map +0 -1
  209. package/dist/syncedObjects/object/interface.d.ts +0 -13
  210. package/dist/syncedObjects/object/interface.d.ts.map +0 -1
  211. package/dist/syncedObjects/object/interface.js +0 -7
  212. package/dist/syncedObjects/object/interface.js.map +0 -1
  213. package/dist/syncedObjects/object/syncedObject.d.ts +0 -22
  214. package/dist/syncedObjects/object/syncedObject.d.ts.map +0 -1
  215. package/dist/syncedObjects/object/syncedObject.js +0 -46
  216. package/dist/syncedObjects/object/syncedObject.js.map +0 -1
  217. package/dist/syncedObjects/string/index.d.ts +0 -7
  218. package/dist/syncedObjects/string/index.d.ts.map +0 -1
  219. package/dist/syncedObjects/string/index.js +0 -19
  220. package/dist/syncedObjects/string/index.js.map +0 -1
  221. package/dist/syncedObjects/string/interface.d.ts +0 -16
  222. package/dist/syncedObjects/string/interface.d.ts.map +0 -1
  223. package/dist/syncedObjects/string/interface.js +0 -7
  224. package/dist/syncedObjects/string/interface.js.map +0 -1
  225. package/dist/syncedObjects/string/syncedString.d.ts +0 -25
  226. package/dist/syncedObjects/string/syncedString.d.ts.map +0 -1
  227. package/dist/syncedObjects/string/syncedString.js +0 -53
  228. package/dist/syncedObjects/string/syncedString.js.map +0 -1
  229. package/dist/useReducerFluid.d.ts +0 -7
  230. package/dist/useReducerFluid.d.ts.map +0 -1
  231. package/dist/useReducerFluid.js +0 -219
  232. package/dist/useReducerFluid.js.map +0 -1
  233. package/dist/useStateFluid.d.ts +0 -10
  234. package/dist/useStateFluid.d.ts.map +0 -1
  235. package/dist/useStateFluid.js +0 -67
  236. package/dist/useStateFluid.js.map +0 -1
  237. package/lib/createContextFluid.js +0 -23
  238. package/lib/createContextFluid.js.map +0 -1
  239. package/lib/helpers/generateFluidObjectSchema.js +0 -71
  240. package/lib/helpers/generateFluidObjectSchema.js.map +0 -1
  241. package/lib/helpers/getFluidFromView.js +0 -26
  242. package/lib/helpers/getFluidFromView.js.map +0 -1
  243. package/lib/helpers/getFluidState.js +0 -43
  244. package/lib/helpers/getFluidState.js.map +0 -1
  245. package/lib/helpers/getSchema.js +0 -11
  246. package/lib/helpers/getSchema.js.map +0 -1
  247. package/lib/helpers/getViewFromFluid.js +0 -43
  248. package/lib/helpers/getViewFromFluid.js.map +0 -1
  249. package/lib/helpers/index.js +0 -16
  250. package/lib/helpers/index.js.map +0 -1
  251. package/lib/helpers/initializeState.js +0 -73
  252. package/lib/helpers/initializeState.js.map +0 -1
  253. package/lib/helpers/internalInterface.js +0 -6
  254. package/lib/helpers/internalInterface.js.map +0 -1
  255. package/lib/helpers/rootCallbackListener.js +0 -51
  256. package/lib/helpers/rootCallbackListener.js.map +0 -1
  257. package/lib/helpers/setComponentSchema.js +0 -14
  258. package/lib/helpers/setComponentSchema.js.map +0 -1
  259. package/lib/helpers/setFluidState.js +0 -90
  260. package/lib/helpers/setFluidState.js.map +0 -1
  261. package/lib/helpers/syncState.js +0 -94
  262. package/lib/helpers/syncState.js.map +0 -1
  263. package/lib/helpers/updateStateAndFluidObjectMap.js +0 -26
  264. package/lib/helpers/updateStateAndFluidObjectMap.js.map +0 -1
  265. package/lib/helpers/utils.js +0 -67
  266. package/lib/helpers/utils.js.map +0 -1
  267. package/lib/interface.js +0 -8
  268. package/lib/interface.js.map +0 -1
  269. package/lib/reactView.js +0 -56
  270. package/lib/reactView.js.map +0 -1
  271. package/lib/syncedDataObject.js +0 -245
  272. package/lib/syncedDataObject.js.map +0 -1
  273. package/lib/syncedObjects/array/fluidSyncedArray.js +0 -72
  274. package/lib/syncedObjects/array/fluidSyncedArray.js.map +0 -1
  275. package/lib/syncedObjects/array/index.js +0 -7
  276. package/lib/syncedObjects/array/index.js.map +0 -1
  277. package/lib/syncedObjects/array/interface.js +0 -2
  278. package/lib/syncedObjects/array/interface.js.map +0 -1
  279. package/lib/syncedObjects/array/syncedArray.js +0 -37
  280. package/lib/syncedObjects/array/syncedArray.js.map +0 -1
  281. package/lib/syncedObjects/counter/fluidSyncedCounter.js +0 -73
  282. package/lib/syncedObjects/counter/fluidSyncedCounter.js.map +0 -1
  283. package/lib/syncedObjects/counter/index.js +0 -7
  284. package/lib/syncedObjects/counter/index.js.map +0 -1
  285. package/lib/syncedObjects/counter/interface.js +0 -2
  286. package/lib/syncedObjects/counter/interface.js.map +0 -1
  287. package/lib/syncedObjects/counter/syncedCounter.js +0 -31
  288. package/lib/syncedObjects/counter/syncedCounter.js.map +0 -1
  289. package/lib/syncedObjects/index.js +0 -9
  290. package/lib/syncedObjects/index.js.map +0 -1
  291. package/lib/syncedObjects/object/index.js +0 -7
  292. package/lib/syncedObjects/object/index.js.map +0 -1
  293. package/lib/syncedObjects/object/interface.js +0 -6
  294. package/lib/syncedObjects/object/interface.js.map +0 -1
  295. package/lib/syncedObjects/object/syncedObject.js +0 -41
  296. package/lib/syncedObjects/object/syncedObject.js.map +0 -1
  297. package/lib/syncedObjects/string/index.js +0 -7
  298. package/lib/syncedObjects/string/index.js.map +0 -1
  299. package/lib/syncedObjects/string/interface.js +0 -6
  300. package/lib/syncedObjects/string/interface.js.map +0 -1
  301. package/lib/syncedObjects/string/syncedString.js +0 -48
  302. package/lib/syncedObjects/string/syncedString.js.map +0 -1
  303. package/lib/useReducerFluid.js +0 -196
  304. package/lib/useReducerFluid.js.map +0 -1
  305. package/lib/useStateFluid.js +0 -44
  306. package/lib/useStateFluid.js.map +0 -1
  307. package/src/createContextFluid.tsx +0 -33
  308. package/src/helpers/generateFluidObjectSchema.ts +0 -95
  309. package/src/helpers/getFluidFromView.ts +0 -38
  310. package/src/helpers/getFluidState.ts +0 -67
  311. package/src/helpers/getSchema.ts +0 -18
  312. package/src/helpers/getViewFromFluid.ts +0 -68
  313. package/src/helpers/index.tsx +0 -16
  314. package/src/helpers/initializeState.ts +0 -162
  315. package/src/helpers/internalInterface.ts +0 -16
  316. package/src/helpers/rootCallbackListener.ts +0 -104
  317. package/src/helpers/setComponentSchema.ts +0 -21
  318. package/src/helpers/setFluidState.ts +0 -116
  319. package/src/helpers/syncState.ts +0 -159
  320. package/src/helpers/updateStateAndFluidObjectMap.ts +0 -85
  321. package/src/helpers/utils.tsx +0 -109
  322. package/src/interface.ts +0 -617
  323. package/src/reactView.tsx +0 -108
  324. package/src/syncedDataObject.ts +0 -337
  325. package/src/syncedObjects/array/fluidSyncedArray.ts +0 -126
  326. package/src/syncedObjects/array/index.ts +0 -7
  327. package/src/syncedObjects/array/interface.ts +0 -45
  328. package/src/syncedObjects/array/syncedArray.ts +0 -65
  329. package/src/syncedObjects/counter/fluidSyncedCounter.ts +0 -122
  330. package/src/syncedObjects/counter/index.ts +0 -7
  331. package/src/syncedObjects/counter/interface.ts +0 -44
  332. package/src/syncedObjects/counter/syncedCounter.ts +0 -64
  333. package/src/syncedObjects/index.ts +0 -9
  334. package/src/syncedObjects/object/index.ts +0 -7
  335. package/src/syncedObjects/object/interface.ts +0 -14
  336. package/src/syncedObjects/object/syncedObject.ts +0 -55
  337. package/src/syncedObjects/string/index.ts +0 -7
  338. package/src/syncedObjects/string/interface.ts +0 -17
  339. package/src/syncedObjects/string/syncedString.ts +0 -61
  340. package/src/useReducerFluid.tsx +0 -436
  341. package/src/useStateFluid.tsx +0 -84
  342. package/tsconfig.esnext.json +0 -7
@@ -1,37 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { SharedObjectSequence } from "@fluidframework/sequence";
6
- import { setFluidSyncedArrayConfig, useSyncedArrayReducerFluid } from "./fluidSyncedArray";
7
- /**
8
- * Function to set the config for a synced array on a syncedDataObject's SharedMap synced state. This
9
- * will initialize and provide a SharedObjectSequence<T> for the view to use through a T[] interface.
10
- * This SharedObjectSequence provided is automatically bound to the state update of the
11
- * functional view useSyncedArray is called in.
12
- * @param syncedDataObject - The Fluid data object on which the synced state config is being set
13
- * @param syncedStateId - The ID of the view state that this config schema is being set for
14
- * @param defaultValue - The default values in the view array prior to the SharedObjectSequence initializing
15
- * @param sharedObjectCreate - The creation function for the SharedObjectSequence. This can be set to
16
- * pre-increment the sequence with initial values.
17
- */
18
- export function setSyncedArrayConfig(syncedDataObject, syncedStateId, defaultValue = [], sharedObjectCreate = SharedObjectSequence.create) {
19
- setFluidSyncedArrayConfig(syncedDataObject, syncedStateId, "values", "values", { values: defaultValue }, sharedObjectCreate);
20
- }
21
- /**
22
- * Function to use the synced array state powered by a SharedObjectSequence<T> that has been prepared for this view
23
- * @param syncedDataObject - The Fluid data object that holds the synced state config for this view
24
- * @param syncedStateId - The ID of this view state
25
- * @returns [
26
- * the array of T objects currently in the SharedObjectSequence,
27
- * the reducer to modify values on the SharedObjectSequence
28
- * ]
29
- */
30
- export function useSyncedArray(syncedDataObject, syncedStateId, defaultValue = []) {
31
- const [state, reducer] = useSyncedArrayReducerFluid(syncedDataObject, syncedStateId, "values", "values", { values: defaultValue });
32
- const pureReducer = {
33
- add: (value) => reducer.add.function(state, value),
34
- };
35
- return [state.viewState.values, pureReducer];
36
- }
37
- //# sourceMappingURL=syncedArray.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncedArray.js","sourceRoot":"","sources":["../../../src/syncedObjects/array/syncedArray.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAE3F;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAChC,gBAAkC,EAClC,aAAqB,EACrB,eAAoB,EAAE,EACtB,kBAAkB,GAAG,oBAAoB,CAAC,MAAM;IAEhD,yBAAyB,CACrB,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,EAAE,MAAM,EAAE,YAAY,EAAE,EACxB,kBAAkB,CACrB,CAAC;AACN,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC1B,gBAAkC,EAClC,aAAqB,EACrB,eAAe,EAAS;IAIxB,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,0BAA0B,CAC/C,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,EAAE,MAAM,EAAE,YAAY,EAAE,CAC3B,CAAC;IACF,MAAM,WAAW,GAA2B;QACxC,GAAG,EAAE,CAAC,KAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;KACxD,CAAC;IAEF,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACjD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { SharedObjectSequence } from \"@fluidframework/sequence\";\nimport { SyncedDataObject } from \"../..\";\nimport { ISyncedArrayViewState, ISyncedArrayFluidState, ISyncedArrayReducer } from \"./interface\";\nimport { setFluidSyncedArrayConfig, useSyncedArrayReducerFluid } from \"./fluidSyncedArray\";\n\n/**\n * Function to set the config for a synced array on a syncedDataObject's SharedMap synced state. This\n * will initialize and provide a SharedObjectSequence<T> for the view to use through a T[] interface.\n * This SharedObjectSequence provided is automatically bound to the state update of the\n * functional view useSyncedArray is called in.\n * @param syncedDataObject - The Fluid data object on which the synced state config is being set\n * @param syncedStateId - The ID of the view state that this config schema is being set for\n * @param defaultValue - The default values in the view array prior to the SharedObjectSequence initializing\n * @param sharedObjectCreate - The creation function for the SharedObjectSequence. This can be set to\n * pre-increment the sequence with initial values.\n */\nexport function setSyncedArrayConfig<T>(\n syncedDataObject: SyncedDataObject,\n syncedStateId: string,\n defaultValue: T[] = [],\n sharedObjectCreate = SharedObjectSequence.create,\n) {\n setFluidSyncedArrayConfig<ISyncedArrayViewState<T>, ISyncedArrayFluidState<T>>(\n syncedDataObject,\n syncedStateId,\n \"values\",\n \"values\",\n { values: defaultValue },\n sharedObjectCreate,\n );\n}\n\n/**\n * Function to use the synced array state powered by a SharedObjectSequence<T> that has been prepared for this view\n * @param syncedDataObject - The Fluid data object that holds the synced state config for this view\n * @param syncedStateId - The ID of this view state\n * @returns [\n * the array of T objects currently in the SharedObjectSequence,\n * the reducer to modify values on the SharedObjectSequence\n * ]\n */\nexport function useSyncedArray<T>(\n syncedDataObject: SyncedDataObject,\n syncedStateId: string,\n defaultValue = [] as T[],\n): [T[], ISyncedArrayReducer<T>] {\n type viewState = ISyncedArrayViewState<T>;\n type fluidState = ISyncedArrayFluidState<T>;\n const [state, reducer] = useSyncedArrayReducerFluid<viewState, fluidState>(\n syncedDataObject,\n syncedStateId,\n \"values\",\n \"values\",\n { values: defaultValue },\n );\n const pureReducer: ISyncedArrayReducer<T> = {\n add: (value: T) => reducer.add.function(state, value),\n };\n\n return [state.viewState.values, pureReducer];\n}\n"]}
@@ -1,73 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { SharedCounter } from "@fluidframework/counter";
6
- import { useReducerFluid, } from "../..";
7
- export function setFluidSyncedCounterConfig(syncedDataObject, syncedStateId, viewKey, fluidKey, defaultViewState, sharedObjectCreate = SharedCounter.create) {
8
- syncedDataObject.setFluidConfig(syncedStateId, {
9
- syncedStateId,
10
- fluidToView: new Map([
11
- [
12
- fluidKey,
13
- {
14
- type: SharedCounter.name,
15
- viewKey,
16
- viewConverter: (viewState, fluidState) => {
17
- if (fluidState[fluidKey] === undefined) {
18
- throw Error("Fluid state was not initialized");
19
- }
20
- viewState[viewKey] = fluidState[fluidKey].value;
21
- return viewState;
22
- },
23
- sharedObjectCreate,
24
- listenedEvents: ["incremented"],
25
- },
26
- ],
27
- ]),
28
- viewToFluid: new Map([
29
- [
30
- viewKey,
31
- {
32
- type: "number",
33
- fluidKey,
34
- fluidConverter: (viewState, fluidState) => {
35
- if (fluidState[fluidKey] === undefined) {
36
- throw Error("Fluid state was not initialized");
37
- }
38
- viewState[viewKey] = fluidState[fluidKey].value;
39
- return fluidState;
40
- },
41
- },
42
- ],
43
- ]),
44
- defaultViewState,
45
- });
46
- }
47
- export function generateSyncedCounterReducer(viewKey, fluidKey) {
48
- const syncedCounterReducer = {
49
- increment: {
50
- function: (state, step) => {
51
- var _a;
52
- if (((_a = state === null || state === void 0 ? void 0 : state.fluidState) === null || _a === void 0 ? void 0 : _a[fluidKey]) === undefined) {
53
- throw Error("State was not initialized prior to dispatch call");
54
- }
55
- const counter = state.fluidState[fluidKey];
56
- counter.increment(step);
57
- state.viewState[viewKey] = counter.value;
58
- return { state };
59
- },
60
- },
61
- };
62
- return syncedCounterReducer;
63
- }
64
- export function useSyncedCounterReducerFluid(syncedDataObject, syncedStateId, viewKey, fluidKey, defaultViewState) {
65
- const syncedCounterReducer = generateSyncedCounterReducer(viewKey, fluidKey);
66
- return useReducerFluid({
67
- syncedDataObject,
68
- syncedStateId,
69
- reducer: syncedCounterReducer,
70
- selector: {},
71
- }, defaultViewState);
72
- }
73
- //# sourceMappingURL=fluidSyncedCounter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fluidSyncedCounter.js","sourceRoot":"","sources":["../../../src/syncedObjects/counter/fluidSyncedCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAKH,eAAe,GAElB,MAAM,OAAO,CAAC;AAGf,MAAM,UAAU,2BAA2B,CAIvC,gBAAkC,EAClC,aAAqB,EACrB,OAAiB,EACjB,QAAkB,EAClB,gBAAoB,EACpB,kBAAkB,GAAG,aAAa,CAAC,MAAM;IAEzC,gBAAgB,CAAC,cAAc,CAAS,aAAa,EAAE;QACnD,aAAa;QACb,WAAW,EAAE,IAAI,GAAG,CAAC;YACjB;gBACI,QAAQ;gBACR;oBACI,IAAI,EAAE,aAAa,CAAC,IAAI;oBACxB,OAAO;oBACP,aAAa,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE;wBACrC,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE;4BACpC,MAAM,KAAK,CAAC,iCAAiC,CAAC,CAAC;yBAClD;wBACD,SAAS,CAAC,OAAO,CAAC,GAAI,UAAU,CAC5B,QAAQ,CACH,CAAC,KAAK,CAAC;wBAChB,OAAO,SAAS,CAAC;oBACrB,CAAC;oBACD,kBAAkB;oBAClB,cAAc,EAAE,CAAC,aAAa,CAAC;iBAClC;aACJ;SACJ,CAAC;QACF,WAAW,EAAE,IAAI,GAAG,CAAC;YACjB;gBACI,OAAO;gBACP;oBACI,IAAI,EAAE,QAAQ;oBACd,QAAQ;oBACR,cAAc,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE;wBACtC,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE;4BACpC,MAAM,KAAK,CAAC,iCAAiC,CAAC,CAAC;yBAClD;wBACD,SAAS,CAAC,OAAO,CAAC,GAAI,UAAU,CAC5B,QAAQ,CACH,CAAC,KAAK,CAAC;wBAChB,OAAO,UAAU,CAAC;oBACtB,CAAC;iBACJ;aACJ;SACJ,CAAC;QACF,gBAAgB;KACnB,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,4BAA4B,CAG1C,OAAiB,EAAE,QAAkB;IACnC,MAAM,oBAAoB,GAAG;QACzB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;;gBAC9B,IAAI,OAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAG,QAAQ,OAAM,SAAS,EAAE;oBAC7C,MAAM,KAAK,CACP,kDAAkD,CACrD,CAAC;iBACL;gBACD,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;gBAC3C,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACxB,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC;gBACzC,OAAO,EAAE,KAAK,EAAE,CAAC;YACrB,CAAC;SACJ;KACJ,CAAC;IACF,OAAO,oBAAoB,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,4BAA4B,CAIxC,gBAAkC,EAClC,aAAqB,EACrB,OAAiB,EACjB,QAAkB,EAClB,gBAAoB;IAGpB,MAAM,oBAAoB,GAAG,4BAA4B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7E,OAAO,eAAe,CAQlB;QACI,gBAAgB;QAChB,aAAa;QACb,OAAO,EAAE,oBAAoB;QAC7B,QAAQ,EAAE,EAAE;KACf,EACD,gBAAgB,CACnB,CAAC;AACN,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { SharedCounter } from \"@fluidframework/counter\";\nimport {\n IViewState,\n IFluidState,\n ICombinedState,\n IFluidDataProps,\n useReducerFluid,\n SyncedDataObject,\n} from \"../..\";\nimport { IFluidSyncedCounterReducer } from \"./interface\";\n\nexport function setFluidSyncedCounterConfig<\n SV extends IViewState,\n SF extends IFluidState\n>(\n syncedDataObject: SyncedDataObject,\n syncedStateId: string,\n viewKey: keyof SV,\n fluidKey: keyof SF,\n defaultViewState: SV,\n sharedObjectCreate = SharedCounter.create,\n) {\n syncedDataObject.setFluidConfig<SV, SF>(syncedStateId, {\n syncedStateId,\n fluidToView: new Map([\n [\n fluidKey,\n {\n type: SharedCounter.name,\n viewKey,\n viewConverter: (viewState, fluidState) => {\n if (fluidState[fluidKey] === undefined) {\n throw Error(\"Fluid state was not initialized\");\n }\n viewState[viewKey] = (fluidState[\n fluidKey\n ] as any).value;\n return viewState;\n },\n sharedObjectCreate,\n listenedEvents: [\"incremented\"],\n },\n ],\n ]),\n viewToFluid: new Map([\n [\n viewKey,\n {\n type: \"number\",\n fluidKey,\n fluidConverter: (viewState, fluidState) => {\n if (fluidState[fluidKey] === undefined) {\n throw Error(\"Fluid state was not initialized\");\n }\n viewState[viewKey] = (fluidState[\n fluidKey\n ] as any).value;\n return fluidState;\n },\n },\n ],\n ]),\n defaultViewState,\n });\n}\n\nexport function generateSyncedCounterReducer<\n SV extends IViewState,\n SF extends IFluidState\n>(viewKey: keyof SV, fluidKey: keyof SF): IFluidSyncedCounterReducer<SV, SF> {\n const syncedCounterReducer = {\n increment: {\n function: (state, step: number) => {\n if (state?.fluidState?.[fluidKey] === undefined) {\n throw Error(\n \"State was not initialized prior to dispatch call\",\n );\n }\n const counter = state.fluidState[fluidKey];\n counter.increment(step);\n state.viewState[viewKey] = counter.value;\n return { state };\n },\n },\n };\n return syncedCounterReducer;\n}\n\nexport function useSyncedCounterReducerFluid<\n SV extends IViewState,\n SF extends IFluidState\n>(\n syncedDataObject: SyncedDataObject,\n syncedStateId: string,\n viewKey: keyof SV,\n fluidKey: keyof SF,\n defaultViewState: SV,\n// eslint-disable-next-line @typescript-eslint/ban-types\n): [ICombinedState<SV, SF, IFluidDataProps>, IFluidSyncedCounterReducer<SV, SF>, {}] {\n const syncedCounterReducer = generateSyncedCounterReducer(viewKey, fluidKey);\n return useReducerFluid<\n SV,\n SF,\n IFluidSyncedCounterReducer<SV, SF>,\n // eslint-disable-next-line @typescript-eslint/ban-types\n {},\n IFluidDataProps\n >(\n {\n syncedDataObject,\n syncedStateId,\n reducer: syncedCounterReducer,\n selector: {},\n },\n defaultViewState,\n );\n}\n"]}
@@ -1,7 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- export * from "./syncedCounter";
6
- export * from "./interface";
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/syncedObjects/counter/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./syncedCounter\";\nexport * from \"./interface\";\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/syncedObjects/counter/interface.ts"],"names":[],"mappings":"","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { ISharedCounter } from \"@fluidframework/counter\";\nimport {\n IViewState,\n IFluidState,\n IFluidReducer,\n IFluidDataProps,\n FluidStateUpdateFunction,\n} from \"../..\";\n\n/**\n * The state interface exposed to the view for the synced counter\n */\nexport interface ISyncedCounterViewState extends IViewState {\n value: number;\n}\n\n/**\n * The state interface for the Fluid data source that powers the synced counter\n */\nexport interface ISyncedCounterFluidState extends IFluidState {\n counter: ISharedCounter;\n}\n\n/**\n * The reducer interface for incrementing the synced counter\n */\nexport interface ISyncedCounterReducer {\n increment: (step: number) => void;\n}\n\n/**\n * The underlying reducer interface passed to the useReducerFluid hook to bind the view and Fluid\n * state definitions together\n */\nexport interface IFluidSyncedCounterReducer<\n SV extends IViewState,\n SF extends IFluidState\n > extends IFluidReducer<SV, SF, IFluidDataProps> {\n increment: FluidStateUpdateFunction<SV, SF, IFluidDataProps>;\n}\n"]}
@@ -1,31 +0,0 @@
1
- import { SharedCounter } from "@fluidframework/counter";
2
- import { setFluidSyncedCounterConfig, useSyncedCounterReducerFluid } from "./fluidSyncedCounter";
3
- /**
4
- * Function to set the config for a synced counter on a syncedDataObject's SharedMap synced state. This
5
- * will initialize and provide a SharedCount for the view to use. This SharedString provided is automatically
6
- * bound to the state update of the functional view useSyncedCounter is called in.
7
- * @param syncedDataObject - The Fluid data object on which the synced state config is being set
8
- * @param syncedStateId - The ID of the view state that this config schema is being set for
9
- * @param defaultValue - The default number the view value will be set to prior to the Fluid counter initializing
10
- * @param sharedObjectCreate - The creation function for the SharedCounter. This can be set to pre-increment the counter
11
- */
12
- export function setSyncedCounterConfig(syncedDataObject, syncedStateId, defaultValue = 0, sharedObjectCreate = SharedCounter.create) {
13
- setFluidSyncedCounterConfig(syncedDataObject, syncedStateId, "value", "counter", { value: defaultValue }, sharedObjectCreate);
14
- }
15
- /**
16
- * Function to use the synced counter state powered by a SharedCounter that has been prepared for this view
17
- * @param syncedDataObject - The Fluid data object that holds the synced state config for this view
18
- * @param syncedStateId - The ID of this view state
19
- * @returns [
20
- * the number that the SharedCounter has been incremented to,
21
- * the reducer to modify the SharedCounter by incrementing it
22
- * ]
23
- */
24
- export function useSyncedCounter(syncedDataObject, syncedStateId, defaultValue = 0) {
25
- const [state, fluidReducer] = useSyncedCounterReducerFluid(syncedDataObject, syncedStateId, "value", "counter", { value: defaultValue });
26
- const reducer = {
27
- increment: (step) => fluidReducer.increment.function(state, step),
28
- };
29
- return [state.viewState.value, reducer];
30
- }
31
- //# sourceMappingURL=syncedCounter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncedCounter.js","sourceRoot":"","sources":["../../../src/syncedObjects/counter/syncedCounter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAEjG;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAClC,gBAAkC,EAClC,aAAqB,EACrB,eAAuB,CAAC,EACxB,qBAAyE,aAAa,CAAC,MAAM;IAE7F,2BAA2B,CACvB,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,SAAS,EACT,EAAE,KAAK,EAAE,YAAY,EAAE,EACvB,kBAAkB,CACrB,CAAC;AACN,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC5B,gBAAkC,EAClC,aAAqB,EACrB,eAAuB,CAAC;IAIxB,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,GAAG,4BAA4B,CACtD,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,SAAS,EACT,EAAE,KAAK,EAAE,YAAY,EAAE,CAC1B,CAAC;IACF,MAAM,OAAO,GAA0B;QACnC,SAAS,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;KAC5E,CAAC;IAEF,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { SharedCounter } from \"@fluidframework/counter\";\nimport { SyncedDataObject } from \"../..\";\nimport { ISyncedCounterViewState, ISyncedCounterFluidState, ISyncedCounterReducer } from \"./interface\";\nimport { setFluidSyncedCounterConfig, useSyncedCounterReducerFluid } from \"./fluidSyncedCounter\";\n\n/**\n * Function to set the config for a synced counter on a syncedDataObject's SharedMap synced state. This\n * will initialize and provide a SharedCount for the view to use. This SharedString provided is automatically\n * bound to the state update of the functional view useSyncedCounter is called in.\n * @param syncedDataObject - The Fluid data object on which the synced state config is being set\n * @param syncedStateId - The ID of the view state that this config schema is being set for\n * @param defaultValue - The default number the view value will be set to prior to the Fluid counter initializing\n * @param sharedObjectCreate - The creation function for the SharedCounter. This can be set to pre-increment the counter\n */\nexport function setSyncedCounterConfig(\n syncedDataObject: SyncedDataObject,\n syncedStateId: string,\n defaultValue: number = 0,\n sharedObjectCreate: (runtime: IFluidDataStoreRuntime) => SharedCounter = SharedCounter.create,\n) {\n setFluidSyncedCounterConfig<ISyncedCounterViewState, ISyncedCounterFluidState>(\n syncedDataObject,\n syncedStateId,\n \"value\",\n \"counter\",\n { value: defaultValue },\n sharedObjectCreate,\n );\n}\n\n/**\n * Function to use the synced counter state powered by a SharedCounter that has been prepared for this view\n * @param syncedDataObject - The Fluid data object that holds the synced state config for this view\n * @param syncedStateId - The ID of this view state\n * @returns [\n * the number that the SharedCounter has been incremented to,\n * the reducer to modify the SharedCounter by incrementing it\n * ]\n */\nexport function useSyncedCounter(\n syncedDataObject: SyncedDataObject,\n syncedStateId: string,\n defaultValue: number = 0,\n): [number, ISyncedCounterReducer] {\n type viewState = ISyncedCounterViewState;\n type fluidState = ISyncedCounterFluidState;\n const [state, fluidReducer] = useSyncedCounterReducerFluid<viewState, fluidState>(\n syncedDataObject,\n syncedStateId,\n \"value\",\n \"counter\",\n { value: defaultValue },\n );\n const reducer: ISyncedCounterReducer = {\n increment: (step: number) => fluidReducer.increment.function(state, step),\n };\n\n return [state.viewState.value, reducer];\n}\n"]}
@@ -1,9 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- export * from "./array";
6
- export * from "./counter";
7
- export * from "./string";
8
- export * from "./object";
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/syncedObjects/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./array\";\nexport * from \"./counter\";\nexport * from \"./string\";\nexport * from \"./object\";\n"]}
@@ -1,7 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- export * from "./syncedObject";
6
- export * from "./interface";
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/syncedObjects/object/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./syncedObject\";\nexport * from \"./interface\";\n"]}
@@ -1,6 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- export {};
6
- //# sourceMappingURL=interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/syncedObjects/object/interface.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidReactState } from \"../..\";\n\n/**\n * The synced state definition that will fill the value parameter with the type T object that will be\n * defined in the synced state config\n */\nexport interface ISyncedMapState<T> extends IFluidReactState {\n value: T;\n}\n"]}
@@ -1,41 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { useStateFluid } from "../../useStateFluid";
6
- /**
7
- * Function to set the config for any type T object on a syncedDataObject's SharedMap synced state
8
- * @param syncedDataObject - The Fluid data object on which the synced state config is being set
9
- * @param syncedStateId - The ID of the view state that this config schema is being set for
10
- * @param defaultValue - The default value of type T that the state will be initialized with prior to
11
- * Fluid initialization
12
- */
13
- export function setSyncedObjectConfig(syncedDataObject, syncedStateId, defaultValue) {
14
- syncedDataObject.setConfig(syncedStateId, {
15
- syncedStateId,
16
- fluidToView: new Map([
17
- [
18
- "value", {
19
- type: "any",
20
- viewKey: "value",
21
- },
22
- ],
23
- ]),
24
- defaultViewState: { value: defaultValue },
25
- });
26
- }
27
- /**
28
- * Function to use the synced state of type T that has been prepared for this view
29
- * @param syncedDataObject - The Fluid data object that holds the synced state config for this view
30
- * @param syncedStateId - The ID of this view state
31
- * @param defaultValue - The default value of type T that the view state will be initialized with
32
- * @returns [the initialized synced state of type T, a synced setState call for the state]
33
- */
34
- export function useSyncedObject(syncedDataObject, syncedStateId, defaultValue) {
35
- const [state, setState] = useStateFluid({
36
- syncedDataObject,
37
- syncedStateId,
38
- }, { value: defaultValue });
39
- return [state.value, (newState) => setState({ value: newState })];
40
- }
41
- //# sourceMappingURL=syncedObject.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncedObject.js","sourceRoot":"","sources":["../../../src/syncedObjects/object/syncedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACjC,gBAAkC,EAClC,aAAqB,EACrB,YAAe;IAEf,gBAAgB,CAAC,SAAS,CAAqB,aAAa,EAAE;QAC1D,aAAa;QACb,WAAW,EAAE,IAAI,GAAG,CAAC;YACjB;gBACI,OAAO,EAAE;oBACL,IAAI,EAAE,KAAK;oBACX,OAAO,EAAE,OAAO;iBACnB;aACJ;SACJ,CAAC;QACF,gBAAgB,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE;KAC5C,CAAC,CAAC;AACP,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC3B,gBAAkC,EAClC,aAAqB,EACrB,YAAe;IAEf,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,aAAa,CACnC;QACI,gBAAgB;QAChB,aAAa;KAChB,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAC7B,CAAC;IACF,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,QAAW,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AACzE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { SyncedDataObject } from \"../..\";\nimport { useStateFluid } from \"../../useStateFluid\";\nimport { ISyncedMapState } from \"./interface\";\n\n/**\n * Function to set the config for any type T object on a syncedDataObject's SharedMap synced state\n * @param syncedDataObject - The Fluid data object on which the synced state config is being set\n * @param syncedStateId - The ID of the view state that this config schema is being set for\n * @param defaultValue - The default value of type T that the state will be initialized with prior to\n * Fluid initialization\n */\nexport function setSyncedObjectConfig<T>(\n syncedDataObject: SyncedDataObject,\n syncedStateId: string,\n defaultValue: T,\n) {\n syncedDataObject.setConfig<ISyncedMapState<T>>(syncedStateId, {\n syncedStateId,\n fluidToView: new Map([\n [\n \"value\", {\n type: \"any\",\n viewKey: \"value\",\n },\n ],\n ]),\n defaultViewState: { value: defaultValue },\n });\n}\n\n/**\n * Function to use the synced state of type T that has been prepared for this view\n * @param syncedDataObject - The Fluid data object that holds the synced state config for this view\n * @param syncedStateId - The ID of this view state\n * @param defaultValue - The default value of type T that the view state will be initialized with\n * @returns [the initialized synced state of type T, a synced setState call for the state]\n */\nexport function useSyncedObject<T>(\n syncedDataObject: SyncedDataObject,\n syncedStateId: string,\n defaultValue: T,\n): [T, (newState: T) => void] {\n const [state, setState] = useStateFluid<ISyncedMapState<T>, ISyncedMapState<T>>(\n {\n syncedDataObject,\n syncedStateId,\n }, { value: defaultValue },\n );\n return [state.value, (newState: T) => setState({ value: newState })];\n}\n"]}
@@ -1,7 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- export * from "./syncedString";
6
- export * from "./interface";
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/syncedObjects/string/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./syncedString\";\nexport * from \"./interface\";\n"]}
@@ -1,6 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- export {};
6
- //# sourceMappingURL=interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/syncedObjects/string/interface.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { SharedString } from \"@fluidframework/sequence\";\nimport { IFluidReactState } from \"../..\";\n\n/**\n * The state definition for a synced string\n * TODO: Add a proper SharedString to string mapping but, for now, you can pass the pre-initialized SharedString\n * directly into the CollaborativeInput provided by the react-inputs package from within\n * the React functional view useSyncedString is called in\n */\nexport interface ISyncedStringState extends IFluidReactState {\n value?: SharedString;\n}\n"]}
@@ -1,48 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { SharedString } from "@fluidframework/sequence";
6
- import { useStateFluid } from "../../useStateFluid";
7
- /**
8
- * Function to set the config for a synced string on a syncedDataObject's SharedMap synced state. This
9
- * will initialize and provide a SharedString for the view to use. This SharedString provided is automatically
10
- * bound to the state update of the functional view useSyncedString is called in. It can also easily be placed
11
- * in a CollaborativeInput within a React view.
12
- * @param syncedDataObject - The Fluid data object on which the synced state config is being set
13
- * @param syncedStateId - The ID of the view state that this config schema is being set for
14
- * @param defaultValue - The default string that the SharedString will be initialized as
15
- */
16
- export function setSyncedStringConfig(syncedDataObject, syncedStateId, defaultValue) {
17
- syncedDataObject.setConfig(syncedStateId, {
18
- syncedStateId,
19
- fluidToView: new Map([
20
- [
21
- "value", {
22
- type: SharedString.name,
23
- viewKey: "value",
24
- sharedObjectCreate: (runtime) => {
25
- const url = SharedString.create(runtime);
26
- url.insertText(0, defaultValue);
27
- return url;
28
- },
29
- },
30
- ],
31
- ]),
32
- defaultViewState: {},
33
- });
34
- }
35
- /**
36
- * Function to use the SharedString state that has been prepared for this view
37
- * @param syncedDataObject - The Fluid data object that holds the synced state config for this view
38
- * @param syncedStateId - The ID of this view state
39
- * @returns [the initialized SharedString, a synced setState call for the SharedString]
40
- */
41
- export function useSyncedString(syncedDataObject, syncedStateId) {
42
- const [state, setState] = useStateFluid({
43
- syncedDataObject,
44
- syncedStateId,
45
- }, {});
46
- return [state.value, setState];
47
- }
48
- //# sourceMappingURL=syncedString.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncedString.js","sourceRoot":"","sources":["../../../src/syncedObjects/string/syncedString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACjC,gBAAkC,EAClC,aAAqB,EACrB,YAAoB;IAEpB,gBAAgB,CAAC,SAAS,CAAqB,aAAa,EAAE;QAC1D,aAAa;QACb,WAAW,EAAE,IAAI,GAAG,CAAC;YACjB;gBACI,OAAO,EAAE;oBACL,IAAI,EAAE,YAAY,CAAC,IAAI;oBACvB,OAAO,EAAE,OAAO;oBAChB,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;wBAC5B,MAAM,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;wBACzC,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;wBAChC,OAAO,GAAG,CAAC;oBACf,CAAC;iBACJ;aACJ;SACJ,CAAQ;QACT,gBAAgB,EAAE,EAAE;KACvB,CAAC,CAAC;AACP,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC3B,gBAAkC,EAClC,aAAqB;IAErB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,aAAa,CACnC;QACI,gBAAgB;QAChB,aAAa;KAChB,EAAE,EAAE,CACR,CAAC;IACF,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACnC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { SharedString } from \"@fluidframework/sequence\";\nimport { SyncedDataObject } from \"../..\";\nimport { useStateFluid } from \"../../useStateFluid\";\nimport { ISyncedStringState } from \"./interface\";\n\n/**\n * Function to set the config for a synced string on a syncedDataObject's SharedMap synced state. This\n * will initialize and provide a SharedString for the view to use. This SharedString provided is automatically\n * bound to the state update of the functional view useSyncedString is called in. It can also easily be placed\n * in a CollaborativeInput within a React view.\n * @param syncedDataObject - The Fluid data object on which the synced state config is being set\n * @param syncedStateId - The ID of the view state that this config schema is being set for\n * @param defaultValue - The default string that the SharedString will be initialized as\n */\nexport function setSyncedStringConfig(\n syncedDataObject: SyncedDataObject,\n syncedStateId: string,\n defaultValue: string,\n) {\n syncedDataObject.setConfig<ISyncedStringState>(syncedStateId, {\n syncedStateId,\n fluidToView: new Map([\n [\n \"value\", {\n type: SharedString.name,\n viewKey: \"value\",\n sharedObjectCreate: (runtime) => {\n const url = SharedString.create(runtime);\n url.insertText(0, defaultValue);\n return url;\n },\n },\n ],\n ]) as any,\n defaultViewState: {},\n });\n}\n\n/**\n * Function to use the SharedString state that has been prepared for this view\n * @param syncedDataObject - The Fluid data object that holds the synced state config for this view\n * @param syncedStateId - The ID of this view state\n * @returns [the initialized SharedString, a synced setState call for the SharedString]\n */\nexport function useSyncedString(\n syncedDataObject: SyncedDataObject,\n syncedStateId: string,\n): [SharedString | undefined, (newState: ISyncedStringState) => void] {\n const [state, setState] = useStateFluid<ISyncedStringState, ISyncedStringState>(\n {\n syncedDataObject,\n syncedStateId,\n }, {},\n );\n return [state.value, setState];\n}\n"]}
@@ -1,196 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import * as React from "react";
6
- import { instanceOfStateUpdateFunction, instanceOfAsyncStateUpdateFunction, instanceOfSelectorFunction, instanceOfFluidObjectSelectorFunction, instanceOfEffectFunction, instanceOfAsyncEffectFunction, } from "./interface";
7
- import { useStateFluid } from "./useStateFluid";
8
- import { updateStateAndFluidObjectMap, syncedStateCallbackListener, getFluidState, syncState, getSchema, } from "./helpers";
9
- export function useReducerFluid(props, initialViewState) {
10
- var _a, _b;
11
- const { syncedStateId, reducer, selector, syncedDataObject, } = props;
12
- const config = syncedDataObject.getConfig(syncedStateId);
13
- if (config === undefined) {
14
- throw Error(`Failed to find configuration for synced state ID: ${syncedStateId}`);
15
- }
16
- const dataProps = (_a = props.dataProps) !== null && _a !== void 0 ? _a : syncedDataObject.dataProps;
17
- // Get our combined synced state and setState callbacks from the useStateFluid function
18
- const [viewState, setState] = useStateFluid({
19
- syncedStateId,
20
- syncedDataObject,
21
- dataProps,
22
- }, initialViewState);
23
- const syncedState = syncedDataObject.syncedState;
24
- const { fluidToView, viewToFluid } = config;
25
- const schemaHandles = getSchema(syncedStateId, syncedState);
26
- if ((schemaHandles === null || schemaHandles === void 0 ? void 0 : schemaHandles.storedHandleMapHandle.absolutePath) === undefined) {
27
- throw Error(`Component schema not initialized prior to render for ${syncedStateId}`);
28
- }
29
- const storedHandleMap = (_b = dataProps.fluidObjectMap.get(schemaHandles === null || schemaHandles === void 0 ? void 0 : schemaHandles.storedHandleMapHandle.absolutePath)) === null || _b === void 0 ? void 0 : _b.fluidObject;
30
- if (storedHandleMap === undefined) {
31
- throw Error(`Stored handle map not initialized prior to render for ${syncedStateId}`);
32
- }
33
- // Dispatch is an in-memory object that will load the reducer actions provided by the user
34
- // and add updates to the view and Fluid state based off of the type of function and
35
- // state values that were updated. Think of it as prepping the data in the first
36
- // stage of dynamic programming. The dispatch functions are copies of the user-defined functions
37
- // but with the updates to synced state also handled
38
- const dispatch = React.useCallback((type, dispatchState, ...args) => {
39
- // Retrieve the current state that is stored on the synced state for this Fluid object ID
40
- const currentFluidState = getFluidState(syncedStateId, syncedState, dataProps.fluidObjectMap, fluidToView);
41
- if (currentFluidState === undefined) {
42
- throw Error("Attempted to dispatch function before fluid state was initialized");
43
- }
44
- const combinedDispatchFluidState = Object.assign(Object.assign({}, currentFluidState), dispatchState === null || dispatchState === void 0 ? void 0 : dispatchState.fluidState);
45
- const combinedDispatchViewState = Object.assign(Object.assign({}, viewState), dispatchState === null || dispatchState === void 0 ? void 0 : dispatchState.viewState);
46
- const combinedDispatchDataProps = Object.assign(Object.assign({}, dataProps), dispatchState === null || dispatchState === void 0 ? void 0 : dispatchState.dataProps);
47
- const combinedDispatchState = {
48
- fluidState: combinedDispatchFluidState,
49
- viewState: combinedDispatchViewState,
50
- dataProps: combinedDispatchDataProps,
51
- };
52
- const action = reducer[type];
53
- if (action !== undefined) {
54
- if (instanceOfStateUpdateFunction(action)) {
55
- // If its a synchronous state update function, call it and inspect the result
56
- // for new Fluid object handles
57
- const result = action.function(combinedDispatchState, ...args);
58
- if (result.newComponentHandles !== undefined) {
59
- // Fetch any new Fluid objects and add a listener to their synced state.
60
- // Then update the view state.
61
- const callback = syncedStateCallbackListener(combinedDispatchDataProps.fluidObjectMap, storedHandleMap, syncedStateId, syncedState, combinedDispatchDataProps.runtime, result.state.viewState, setState, fluidToView, viewToFluid);
62
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
63
- updateStateAndFluidObjectMap(result.newComponentHandles, combinedDispatchDataProps.fluidObjectMap, storedHandleMap, false, syncedStateId, syncedState, combinedDispatchDataProps.runtime, result.state.viewState, setState, callback, fluidToView, viewToFluid);
64
- }
65
- else {
66
- // Update the state directly
67
- syncState(false, syncedStateId, syncedState, combinedDispatchDataProps.runtime, result.state.viewState, setState, combinedDispatchDataProps.fluidObjectMap, fluidToView, viewToFluid);
68
- }
69
- }
70
- else if (instanceOfAsyncStateUpdateFunction(action)) {
71
- // In the case of an async function, the function promise is treated as a Thenable
72
- // and the returned result is inspected after the function has completed
73
- action.asyncFunction(combinedDispatchState, ...args).then((result) => {
74
- const callback = syncedStateCallbackListener(combinedDispatchDataProps.fluidObjectMap, storedHandleMap, syncedStateId, syncedState, combinedDispatchDataProps.runtime, result.state.viewState, setState, fluidToView, viewToFluid);
75
- if (result.newFluidHandles !== undefined) {
76
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
77
- updateStateAndFluidObjectMap(result.newFluidHandles, combinedDispatchDataProps.fluidObjectMap, storedHandleMap, false, syncedStateId, syncedState, combinedDispatchDataProps.runtime, result.state.viewState, setState, callback, fluidToView, viewToFluid);
78
- }
79
- else {
80
- syncState(false, syncedStateId, syncedState, combinedDispatchDataProps.runtime, result.state.viewState, setState, combinedDispatchDataProps.fluidObjectMap, fluidToView, viewToFluid);
81
- }
82
- });
83
- }
84
- else if (instanceOfAsyncEffectFunction(action)) {
85
- action.asyncFunction(combinedDispatchState, ...args).then(() => syncState(false, syncedStateId, syncedState, combinedDispatchDataProps.runtime, combinedDispatchState.viewState, setState, combinedDispatchDataProps.fluidObjectMap, fluidToView, viewToFluid));
86
- }
87
- else if (instanceOfEffectFunction(action)) {
88
- action.function(combinedDispatchState, ...args);
89
- syncState(false, syncedStateId, syncedState, combinedDispatchDataProps.runtime, combinedDispatchState.viewState, setState, combinedDispatchDataProps.fluidObjectMap, fluidToView, viewToFluid);
90
- }
91
- else {
92
- throw new Error(`Action with key ${action} does not match an expected reducer action interface`);
93
- }
94
- }
95
- else {
96
- throw new Error(`Action with key ${action} does not
97
- exist in the reducers provided`);
98
- }
99
- }, [reducer, viewState, setState, dataProps]);
100
- // The combinedReducer is then created using the dispatch functions we created above.
101
- // This allows us to preserve the reducer interface while injecting Fluid-specific logic
102
- // into the updating of the state. This is the second phase of DP, using the earlier created
103
- // in-memory object to access the function the user is trying to use in constant time and then,
104
- // subsequently performing it, taking the updated state, and applying it both locally and remotely
105
- const combinedReducer = {};
106
- Object.entries(reducer).forEach(([functionName, functionItem], i) => {
107
- if (functionItem.asyncFunction !== undefined) {
108
- combinedReducer[functionName] = {
109
- asyncFunction: (dispatchState, ...args) => dispatch(functionName, dispatchState, ...args),
110
- };
111
- }
112
- else {
113
- combinedReducer[functionName] = {
114
- function: (dispatchState, ...args) => dispatch(functionName, dispatchState, ...args),
115
- };
116
- }
117
- });
118
- // Fetch is an in-memory object similar to dispatch, but now made for selector actions.
119
- // Selectors are NOT used for updating the state but instead to be able to access
120
- // and add other Fluid Fluid objects using the handle provided. If the handle provided is not available
121
- // in our Fluid object map, it will be dynamically updated and setState will be called again
122
- // with the updated Fluid object map available for use.
123
- // Alternatively, if you would like to pre-load Fluid objects before React is initialized,
124
- // you can do so and provide them in dataProps.
125
- // Fetch can also be used to retrieve data from these Fluid objects as they will also be available as a parameter.
126
- const fetch = React.useCallback((type, fetchState, handle) => {
127
- // Retrieve the current state that is stored on the syncedState for this Fluid object ID
128
- const currentFluidState = getFluidState(syncedStateId, syncedState, dataProps.fluidObjectMap, fluidToView);
129
- if (currentFluidState === undefined) {
130
- throw Error("Attempted to dispatch function before fluid state was initialized");
131
- }
132
- const combinedFetchFluidState = Object.assign(Object.assign({}, currentFluidState), fetchState === null || fetchState === void 0 ? void 0 : fetchState.fluidState);
133
- const combinedFetchViewState = Object.assign(Object.assign({}, viewState), fetchState === null || fetchState === void 0 ? void 0 : fetchState.viewState);
134
- const combinedFetchDataProps = Object.assign(Object.assign({}, dataProps), fetchState === null || fetchState === void 0 ? void 0 : fetchState.dataProps);
135
- const combinedFetchState = {
136
- fluidState: combinedFetchFluidState,
137
- viewState: combinedFetchViewState,
138
- dataProps: combinedFetchDataProps,
139
- };
140
- const action = selector[type];
141
- if (action !== undefined) {
142
- if (instanceOfSelectorFunction(action)) {
143
- // Add any new handles that were returned by the selector to our list
144
- // to be loaded to the fluid Fluid object map
145
- let newHandles = [];
146
- if (handle !== undefined &&
147
- instanceOfFluidObjectSelectorFunction(action) &&
148
- combinedFetchDataProps.fluidObjectMap.get(handle.absolutePath) === undefined) {
149
- newHandles.push(handle);
150
- }
151
- const actionResult = action.function(combinedFetchState, handle);
152
- if (actionResult !== undefined &&
153
- actionResult.newComponentHandles !== undefined) {
154
- newHandles = newHandles.concat(actionResult.newComponentHandles);
155
- }
156
- // If there are handles, start a call to update the Fluid object map and then call the set state
157
- // callback when it has finished to provide the updated map in the state
158
- if (newHandles.length > 0) {
159
- const callback = syncedStateCallbackListener(combinedFetchDataProps.fluidObjectMap, storedHandleMap, syncedStateId, syncedState, combinedFetchDataProps.runtime, combinedFetchState.viewState, setState, fluidToView, viewToFluid);
160
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
161
- updateStateAndFluidObjectMap(newHandles, combinedFetchDataProps.fluidObjectMap, storedHandleMap, true, syncedStateId, syncedState, combinedFetchDataProps.runtime, combinedFetchState.viewState, setState, callback, fluidToView, viewToFluid);
162
- }
163
- // Always return the result immediately
164
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
165
- return actionResult;
166
- }
167
- else {
168
- throw new Error(`Action with key ${action} does not match an expected selector action interface`);
169
- }
170
- }
171
- else {
172
- throw new Error(`Action with key ${action} does not
173
- exist in the selectors provided`);
174
- }
175
- }, [selector, viewState, setState, dataProps]);
176
- // The combined selector is then similarly created with the Fluid-specific logic of adding any new Fluid objects
177
- // to our Fluid object map interjected into the setState logic
178
- const combinedSelector = {};
179
- Object.entries(selector).forEach(([functionName, functionItem], i) => {
180
- combinedSelector[functionName] = {
181
- function: (fetchState, handle) => fetch(functionName, fetchState, handle),
182
- };
183
- });
184
- // Retrieve the current state that is stored on the syncedState for this Fluid object ID
185
- const fluidState = getFluidState(syncedStateId, syncedState, dataProps.fluidObjectMap, fluidToView);
186
- return [
187
- {
188
- viewState,
189
- fluidState,
190
- dataProps,
191
- },
192
- combinedReducer,
193
- combinedSelector,
194
- ];
195
- }
196
- //# sourceMappingURL=useReducerFluid.js.map