@fluidframework/react 0.41.4 → 2.62.0

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,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSyncedArray = exports.setSyncedArrayConfig = void 0;
4
- /*!
5
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
6
- * Licensed under the MIT License.
7
- */
8
- const sequence_1 = require("@fluidframework/sequence");
9
- const fluidSyncedArray_1 = require("./fluidSyncedArray");
10
- /**
11
- * Function to set the config for a synced array on a syncedDataObject's SharedMap synced state. This
12
- * will initialize and provide a SharedObjectSequence<T> for the view to use through a T[] interface.
13
- * This SharedObjectSequence provided is automatically bound to the state update of the
14
- * functional view useSyncedArray is called in.
15
- * @param syncedDataObject - The Fluid data object on which the synced state config is being set
16
- * @param syncedStateId - The ID of the view state that this config schema is being set for
17
- * @param defaultValue - The default values in the view array prior to the SharedObjectSequence initializing
18
- * @param sharedObjectCreate - The creation function for the SharedObjectSequence. This can be set to
19
- * pre-increment the sequence with initial values.
20
- */
21
- function setSyncedArrayConfig(syncedDataObject, syncedStateId, defaultValue = [], sharedObjectCreate = sequence_1.SharedObjectSequence.create) {
22
- fluidSyncedArray_1.setFluidSyncedArrayConfig(syncedDataObject, syncedStateId, "values", "values", { values: defaultValue }, sharedObjectCreate);
23
- }
24
- exports.setSyncedArrayConfig = setSyncedArrayConfig;
25
- /**
26
- * Function to use the synced array state powered by a SharedObjectSequence<T> that has been prepared for this view
27
- * @param syncedDataObject - The Fluid data object that holds the synced state config for this view
28
- * @param syncedStateId - The ID of this view state
29
- * @returns [
30
- * the array of T objects currently in the SharedObjectSequence,
31
- * the reducer to modify values on the SharedObjectSequence
32
- * ]
33
- */
34
- function useSyncedArray(syncedDataObject, syncedStateId, defaultValue = []) {
35
- const [state, reducer] = fluidSyncedArray_1.useSyncedArrayReducerFluid(syncedDataObject, syncedStateId, "values", "values", { values: defaultValue });
36
- const pureReducer = {
37
- add: (value) => reducer.add.function(state, value),
38
- };
39
- return [state.viewState.values, pureReducer];
40
- }
41
- exports.useSyncedArray = useSyncedArray;
42
- //# 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,uDAAgE;AAGhE,yDAA2F;AAE3F;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAChC,gBAAkC,EAClC,aAAqB,EACrB,eAAoB,EAAE,EACtB,kBAAkB,GAAG,+BAAoB,CAAC,MAAM;IAEhD,4CAAyB,CACrB,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,EAAE,MAAM,EAAE,YAAY,EAAE,EACxB,kBAAkB,CACrB,CAAC;AACN,CAAC;AAdD,oDAcC;AAED;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAC1B,gBAAkC,EAClC,aAAqB,EACrB,eAAe,EAAS;IAIxB,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,6CAA0B,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;AAnBD,wCAmBC","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,11 +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 { IViewState, IFluidState, ICombinedState, IFluidDataProps, SyncedDataObject } from "../..";
7
- import { IFluidSyncedCounterReducer } from "./interface";
8
- export declare function setFluidSyncedCounterConfig<SV extends IViewState, SF extends IFluidState>(syncedDataObject: SyncedDataObject, syncedStateId: string, viewKey: keyof SV, fluidKey: keyof SF, defaultViewState: SV, sharedObjectCreate?: typeof SharedCounter.create): void;
9
- export declare function generateSyncedCounterReducer<SV extends IViewState, SF extends IFluidState>(viewKey: keyof SV, fluidKey: keyof SF): IFluidSyncedCounterReducer<SV, SF>;
10
- export declare function useSyncedCounterReducerFluid<SV extends IViewState, SF extends IFluidState>(syncedDataObject: SyncedDataObject, syncedStateId: string, viewKey: keyof SV, fluidKey: keyof SF, defaultViewState: SV): [ICombinedState<SV, SF, IFluidDataProps>, IFluidSyncedCounterReducer<SV, SF>, {}];
11
- //# sourceMappingURL=fluidSyncedCounter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fluidSyncedCounter.d.ts","sourceRoot":"","sources":["../../../src/syncedObjects/counter/fluidSyncedCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EACH,UAAU,EACV,WAAW,EACX,cAAc,EACd,eAAe,EAEf,gBAAgB,EACnB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAEzD,wBAAgB,2BAA2B,CACvC,EAAE,SAAS,UAAU,EACrB,EAAE,SAAS,WAAW,EAEtB,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,EAAE,MAAM,EAAE,EAClB,gBAAgB,EAAE,EAAE,EACpB,kBAAkB,8BAAuB,QA4C5C;AAED,wBAAgB,4BAA4B,CACxC,EAAE,SAAS,UAAU,EACrB,EAAE,SAAS,WAAW,EACxB,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,0BAA0B,CAAC,EAAE,EAAE,EAAE,CAAC,CAiB3E;AAED,wBAAgB,4BAA4B,CACxC,EAAE,SAAS,UAAU,EACrB,EAAE,SAAS,WAAW,EAEtB,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,EAAE,MAAM,EAAE,EAClB,gBAAgB,EAAE,EAAE,GAErB,CAAC,cAAc,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,CAAC,EAAE,0BAA0B,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAkBnF"}
@@ -1,79 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.useSyncedCounterReducerFluid = exports.generateSyncedCounterReducer = exports.setFluidSyncedCounterConfig = void 0;
8
- const counter_1 = require("@fluidframework/counter");
9
- const __1 = require("../..");
10
- function setFluidSyncedCounterConfig(syncedDataObject, syncedStateId, viewKey, fluidKey, defaultViewState, sharedObjectCreate = counter_1.SharedCounter.create) {
11
- syncedDataObject.setFluidConfig(syncedStateId, {
12
- syncedStateId,
13
- fluidToView: new Map([
14
- [
15
- fluidKey,
16
- {
17
- type: counter_1.SharedCounter.name,
18
- viewKey,
19
- viewConverter: (viewState, fluidState) => {
20
- if (fluidState[fluidKey] === undefined) {
21
- throw Error("Fluid state was not initialized");
22
- }
23
- viewState[viewKey] = fluidState[fluidKey].value;
24
- return viewState;
25
- },
26
- sharedObjectCreate,
27
- listenedEvents: ["incremented"],
28
- },
29
- ],
30
- ]),
31
- viewToFluid: new Map([
32
- [
33
- viewKey,
34
- {
35
- type: "number",
36
- fluidKey,
37
- fluidConverter: (viewState, fluidState) => {
38
- if (fluidState[fluidKey] === undefined) {
39
- throw Error("Fluid state was not initialized");
40
- }
41
- viewState[viewKey] = fluidState[fluidKey].value;
42
- return fluidState;
43
- },
44
- },
45
- ],
46
- ]),
47
- defaultViewState,
48
- });
49
- }
50
- exports.setFluidSyncedCounterConfig = setFluidSyncedCounterConfig;
51
- function generateSyncedCounterReducer(viewKey, fluidKey) {
52
- const syncedCounterReducer = {
53
- increment: {
54
- function: (state, step) => {
55
- var _a;
56
- if (((_a = state === null || state === void 0 ? void 0 : state.fluidState) === null || _a === void 0 ? void 0 : _a[fluidKey]) === undefined) {
57
- throw Error("State was not initialized prior to dispatch call");
58
- }
59
- const counter = state.fluidState[fluidKey];
60
- counter.increment(step);
61
- state.viewState[viewKey] = counter.value;
62
- return { state };
63
- },
64
- },
65
- };
66
- return syncedCounterReducer;
67
- }
68
- exports.generateSyncedCounterReducer = generateSyncedCounterReducer;
69
- function useSyncedCounterReducerFluid(syncedDataObject, syncedStateId, viewKey, fluidKey, defaultViewState) {
70
- const syncedCounterReducer = generateSyncedCounterReducer(viewKey, fluidKey);
71
- return __1.useReducerFluid({
72
- syncedDataObject,
73
- syncedStateId,
74
- reducer: syncedCounterReducer,
75
- selector: {},
76
- }, defaultViewState);
77
- }
78
- exports.useSyncedCounterReducerFluid = useSyncedCounterReducerFluid;
79
- //# 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,qDAAwD;AACxD,6BAOe;AAGf,SAAgB,2BAA2B,CAIvC,gBAAkC,EAClC,aAAqB,EACrB,OAAiB,EACjB,QAAkB,EAClB,gBAAoB,EACpB,kBAAkB,GAAG,uBAAa,CAAC,MAAM;IAEzC,gBAAgB,CAAC,cAAc,CAAS,aAAa,EAAE;QACnD,aAAa;QACb,WAAW,EAAE,IAAI,GAAG,CAAC;YACjB;gBACI,QAAQ;gBACR;oBACI,IAAI,EAAE,uBAAa,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;AArDD,kEAqDC;AAED,SAAgB,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;AApBD,oEAoBC;AAED,SAAgB,4BAA4B,CAIxC,gBAAkC,EAClC,aAAqB,EACrB,OAAiB,EACjB,QAAkB,EAClB,gBAAoB;IAGpB,MAAM,oBAAoB,GAAG,4BAA4B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7E,OAAO,mBAAe,CAQlB;QACI,gBAAgB;QAChB,aAAa;QACb,OAAO,EAAE,oBAAoB;QAC7B,QAAQ,EAAE,EAAE;KACf,EACD,gBAAgB,CACnB,CAAC;AACN,CAAC;AA5BD,oEA4BC","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.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/syncedObjects/counter/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./syncedCounter"), exports);
18
- __exportStar(require("./interface"), exports);
19
- //# 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,kDAAgC;AAChC,8CAA4B","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,32 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { ISharedCounter } from "@fluidframework/counter";
6
- import { IViewState, IFluidState, IFluidReducer, IFluidDataProps, FluidStateUpdateFunction } from "../..";
7
- /**
8
- * The state interface exposed to the view for the synced counter
9
- */
10
- export interface ISyncedCounterViewState extends IViewState {
11
- value: number;
12
- }
13
- /**
14
- * The state interface for the Fluid data source that powers the synced counter
15
- */
16
- export interface ISyncedCounterFluidState extends IFluidState {
17
- counter: ISharedCounter;
18
- }
19
- /**
20
- * The reducer interface for incrementing the synced counter
21
- */
22
- export interface ISyncedCounterReducer {
23
- increment: (step: number) => void;
24
- }
25
- /**
26
- * The underlying reducer interface passed to the useReducerFluid hook to bind the view and Fluid
27
- * state definitions together
28
- */
29
- export interface IFluidSyncedCounterReducer<SV extends IViewState, SF extends IFluidState> extends IFluidReducer<SV, SF, IFluidDataProps> {
30
- increment: FluidStateUpdateFunction<SV, SF, IFluidDataProps>;
31
- }
32
- //# sourceMappingURL=interface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/syncedObjects/counter/interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACH,UAAU,EACV,WAAW,EACX,aAAa,EACb,eAAe,EACf,wBAAwB,EAC3B,MAAM,OAAO,CAAC;AAEf;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,UAAU;IACvD,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IACzD,OAAO,EAAE,cAAc,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B,CACvC,EAAE,SAAS,UAAU,EACrB,EAAE,SAAS,WAAW,CACpB,SAAQ,aAAa,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,CAAC;IAChD,SAAS,EAAE,wBAAwB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,CAAC,CAAC;CAChE"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# 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,29 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
6
- import { SharedCounter } from "@fluidframework/counter";
7
- import { SyncedDataObject } from "../..";
8
- import { ISyncedCounterReducer } from "./interface";
9
- /**
10
- * Function to set the config for a synced counter on a syncedDataObject's SharedMap synced state. This
11
- * will initialize and provide a SharedCount for the view to use. This SharedString provided is automatically
12
- * bound to the state update of the functional view useSyncedCounter is called in.
13
- * @param syncedDataObject - The Fluid data object on which the synced state config is being set
14
- * @param syncedStateId - The ID of the view state that this config schema is being set for
15
- * @param defaultValue - The default number the view value will be set to prior to the Fluid counter initializing
16
- * @param sharedObjectCreate - The creation function for the SharedCounter. This can be set to pre-increment the counter
17
- */
18
- export declare function setSyncedCounterConfig(syncedDataObject: SyncedDataObject, syncedStateId: string, defaultValue?: number, sharedObjectCreate?: (runtime: IFluidDataStoreRuntime) => SharedCounter): void;
19
- /**
20
- * Function to use the synced counter state powered by a SharedCounter that has been prepared for this view
21
- * @param syncedDataObject - The Fluid data object that holds the synced state config for this view
22
- * @param syncedStateId - The ID of this view state
23
- * @returns [
24
- * the number that the SharedCounter has been incremented to,
25
- * the reducer to modify the SharedCounter by incrementing it
26
- * ]
27
- */
28
- export declare function useSyncedCounter(syncedDataObject: SyncedDataObject, syncedStateId: string, defaultValue?: number): [number, ISyncedCounterReducer];
29
- //# sourceMappingURL=syncedCounter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncedCounter.d.ts","sourceRoot":"","sources":["../../../src/syncedObjects/counter/syncedCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAqD,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGvG;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAClC,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,MAAM,EACrB,YAAY,GAAE,MAAU,EACxB,kBAAkB,GAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,aAAoC,QAUhG;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC5B,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,MAAM,EACrB,YAAY,GAAE,MAAU,GACzB,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAejC"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSyncedCounter = exports.setSyncedCounterConfig = void 0;
4
- const counter_1 = require("@fluidframework/counter");
5
- const fluidSyncedCounter_1 = require("./fluidSyncedCounter");
6
- /**
7
- * Function to set the config for a synced counter on a syncedDataObject's SharedMap synced state. This
8
- * will initialize and provide a SharedCount for the view to use. This SharedString provided is automatically
9
- * bound to the state update of the functional view useSyncedCounter is called in.
10
- * @param syncedDataObject - The Fluid data object on which the synced state config is being set
11
- * @param syncedStateId - The ID of the view state that this config schema is being set for
12
- * @param defaultValue - The default number the view value will be set to prior to the Fluid counter initializing
13
- * @param sharedObjectCreate - The creation function for the SharedCounter. This can be set to pre-increment the counter
14
- */
15
- function setSyncedCounterConfig(syncedDataObject, syncedStateId, defaultValue = 0, sharedObjectCreate = counter_1.SharedCounter.create) {
16
- fluidSyncedCounter_1.setFluidSyncedCounterConfig(syncedDataObject, syncedStateId, "value", "counter", { value: defaultValue }, sharedObjectCreate);
17
- }
18
- exports.setSyncedCounterConfig = setSyncedCounterConfig;
19
- /**
20
- * Function to use the synced counter state powered by a SharedCounter that has been prepared for this view
21
- * @param syncedDataObject - The Fluid data object that holds the synced state config for this view
22
- * @param syncedStateId - The ID of this view state
23
- * @returns [
24
- * the number that the SharedCounter has been incremented to,
25
- * the reducer to modify the SharedCounter by incrementing it
26
- * ]
27
- */
28
- function useSyncedCounter(syncedDataObject, syncedStateId, defaultValue = 0) {
29
- const [state, fluidReducer] = fluidSyncedCounter_1.useSyncedCounterReducerFluid(syncedDataObject, syncedStateId, "value", "counter", { value: defaultValue });
30
- const reducer = {
31
- increment: (step) => fluidReducer.increment.function(state, step),
32
- };
33
- return [state.viewState.value, reducer];
34
- }
35
- exports.useSyncedCounter = useSyncedCounter;
36
- //# sourceMappingURL=syncedCounter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncedCounter.js","sourceRoot":"","sources":["../../../src/syncedObjects/counter/syncedCounter.ts"],"names":[],"mappings":";;;AAKA,qDAAwD;AAGxD,6DAAiG;AAEjG;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CAClC,gBAAkC,EAClC,aAAqB,EACrB,eAAuB,CAAC,EACxB,qBAAyE,uBAAa,CAAC,MAAM;IAE7F,gDAA2B,CACvB,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,SAAS,EACT,EAAE,KAAK,EAAE,YAAY,EAAE,EACvB,kBAAkB,CACrB,CAAC;AACN,CAAC;AAdD,wDAcC;AAED;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,CAC5B,gBAAkC,EAClC,aAAqB,EACrB,eAAuB,CAAC;IAIxB,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,GAAG,iDAA4B,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;AAnBD,4CAmBC","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.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","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"}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./array"), exports);
18
- __exportStar(require("./counter"), exports);
19
- __exportStar(require("./string"), exports);
20
- __exportStar(require("./object"), exports);
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/syncedObjects/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,0CAAwB;AACxB,4CAA0B;AAC1B,2CAAyB;AACzB,2CAAyB","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.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/syncedObjects/object/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./syncedObject"), exports);
18
- __exportStar(require("./interface"), exports);
19
- //# 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,iDAA+B;AAC/B,8CAA4B","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,13 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { IFluidReactState } from "../..";
6
- /**
7
- * The synced state definition that will fill the value parameter with the type T object that will be
8
- * defined in the synced state config
9
- */
10
- export interface ISyncedMapState<T> extends IFluidReactState {
11
- value: T;
12
- }
13
- //# sourceMappingURL=interface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/syncedObjects/object/interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEzC;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,CAAE,SAAQ,gBAAgB;IACxD,KAAK,EAAE,CAAC,CAAC;CACZ"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- //# 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,22 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { SyncedDataObject } from "../..";
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 declare function setSyncedObjectConfig<T>(syncedDataObject: SyncedDataObject, syncedStateId: string, defaultValue: T): void;
14
- /**
15
- * Function to use the synced state of type T that has been prepared for this view
16
- * @param syncedDataObject - The Fluid data object that holds the synced state config for this view
17
- * @param syncedStateId - The ID of this view state
18
- * @param defaultValue - The default value of type T that the view state will be initialized with
19
- * @returns [the initialized synced state of type T, a synced setState call for the state]
20
- */
21
- export declare function useSyncedObject<T>(syncedDataObject: SyncedDataObject, syncedStateId: string, defaultValue: T): [T, (newState: T) => void];
22
- //# sourceMappingURL=syncedObject.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncedObject.d.ts","sourceRoot":"","sources":["../../../src/syncedObjects/object/syncedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAIzC;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,CAAC,QAclB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC7B,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,CAAC,GAChB,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAC,CAQ5B"}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.useSyncedObject = exports.setSyncedObjectConfig = void 0;
8
- const useStateFluid_1 = require("../../useStateFluid");
9
- /**
10
- * Function to set the config for any type T object on a syncedDataObject's SharedMap synced state
11
- * @param syncedDataObject - The Fluid data object on which the synced state config is being set
12
- * @param syncedStateId - The ID of the view state that this config schema is being set for
13
- * @param defaultValue - The default value of type T that the state will be initialized with prior to
14
- * Fluid initialization
15
- */
16
- function setSyncedObjectConfig(syncedDataObject, syncedStateId, defaultValue) {
17
- syncedDataObject.setConfig(syncedStateId, {
18
- syncedStateId,
19
- fluidToView: new Map([
20
- [
21
- "value", {
22
- type: "any",
23
- viewKey: "value",
24
- },
25
- ],
26
- ]),
27
- defaultViewState: { value: defaultValue },
28
- });
29
- }
30
- exports.setSyncedObjectConfig = setSyncedObjectConfig;
31
- /**
32
- * Function to use the synced state of type T that has been prepared for this view
33
- * @param syncedDataObject - The Fluid data object that holds the synced state config for this view
34
- * @param syncedStateId - The ID of this view state
35
- * @param defaultValue - The default value of type T that the view state will be initialized with
36
- * @returns [the initialized synced state of type T, a synced setState call for the state]
37
- */
38
- function useSyncedObject(syncedDataObject, syncedStateId, defaultValue) {
39
- const [state, setState] = useStateFluid_1.useStateFluid({
40
- syncedDataObject,
41
- syncedStateId,
42
- }, { value: defaultValue });
43
- return [state.value, (newState) => setState({ value: newState })];
44
- }
45
- exports.useSyncedObject = useSyncedObject;
46
- //# 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,uDAAoD;AAGpD;;;;;;GAMG;AACH,SAAgB,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;AAjBD,sDAiBC;AAED;;;;;;GAMG;AACH,SAAgB,eAAe,CAC3B,gBAAkC,EAClC,aAAqB,EACrB,YAAe;IAEf,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,6BAAa,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;AAZD,0CAYC","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.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/syncedObjects/string/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./syncedString"), exports);
18
- __exportStar(require("./interface"), exports);
19
- //# 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,iDAA+B;AAC/B,8CAA4B","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,16 +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 { IFluidReactState } from "../..";
7
- /**
8
- * The state definition for a synced string
9
- * TODO: Add a proper SharedString to string mapping but, for now, you can pass the pre-initialized SharedString
10
- * directly into the CollaborativeInput provided by the react-inputs package from within
11
- * the React functional view useSyncedString is called in
12
- */
13
- export interface ISyncedStringState extends IFluidReactState {
14
- value?: SharedString;
15
- }
16
- //# sourceMappingURL=interface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/syncedObjects/string/interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IACxD,KAAK,CAAC,EAAE,YAAY,CAAC;CACxB"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- //# 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"]}