@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,75 +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.generateFluidObjectSchema = void 0;
8
- const map_1 = require("@fluidframework/map");
9
- /**
10
- * Identifies which values within the Fluid and view states match
11
- * The view and Fluid matching map identify if the value in the respective states
12
- * needs a converter or not
13
- * @param runtime - The data store runtime used to create the SharedMap objects
14
- * @param fluidToView - The Fluid to view state conversion mapping
15
- * @param viewToFluid - The view to Fluid conversion state mapping
16
- * */
17
- function generateFluidObjectSchema(runtime, defaultViewState, fluidToView, viewToFluid) {
18
- // matching primitives w/ the same key in view and fluid
19
- // true if needs converter or is a Fluid object, false if not
20
- const viewMatchingMap = map_1.SharedMap.create(runtime);
21
- const fluidMatchingMap = map_1.SharedMap.create(runtime);
22
- const storedHandleMap = map_1.SharedMap.create(runtime);
23
- for (const fluidStateKey of fluidToView.keys()) {
24
- const value = fluidToView.get(fluidStateKey);
25
- if (value === undefined) {
26
- throw Error("Cannot find fluidToView value");
27
- }
28
- const { type, viewKey, viewConverter, } = value;
29
- const fluidConverter = viewToFluid === null || viewToFluid === void 0 ? void 0 : viewToFluid.get(viewKey);
30
- if (fluidConverter === undefined) {
31
- if (defaultViewState[viewKey] !== undefined
32
- && typeof (defaultViewState[viewKey]) !== type
33
- && type !== "any") {
34
- throw Error(`Failed to find Fluid converter for key ${viewKey}`);
35
- }
36
- else {
37
- continue;
38
- }
39
- }
40
- if (type === fluidConverter.type) {
41
- fluidMatchingMap.set(fluidStateKey, false);
42
- }
43
- else if (viewConverter !== undefined) {
44
- fluidMatchingMap.set(fluidStateKey, true);
45
- }
46
- else {
47
- throw Error(`Failed to find view converter for Fluid key ${fluidStateKey}`);
48
- }
49
- }
50
- if (viewToFluid !== undefined) {
51
- for (const viewStateKey of viewToFluid.keys()) {
52
- const value = viewToFluid.get(viewStateKey);
53
- if (value === undefined) {
54
- throw Error("Cannot find viewToFluid value");
55
- }
56
- const { type, fluidKey, fluidConverter, } = value;
57
- const viewConverter = fluidToView.get(fluidKey);
58
- if (viewConverter === undefined) {
59
- throw Error(`Failed to find view converter for key ${fluidKey}`);
60
- }
61
- if (type === viewConverter.type) {
62
- viewMatchingMap.set(viewStateKey, false);
63
- }
64
- else if (fluidConverter !== undefined) {
65
- viewMatchingMap.set(viewStateKey, true);
66
- }
67
- else {
68
- throw Error(`Failed to find Fluid converter for view key ${viewStateKey}`);
69
- }
70
- }
71
- }
72
- return { viewMatchingMap, fluidMatchingMap, storedHandleMap };
73
- }
74
- exports.generateFluidObjectSchema = generateFluidObjectSchema;
75
- //# sourceMappingURL=generateFluidObjectSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generateFluidObjectSchema.js","sourceRoot":"","sources":["../../src/helpers/generateFluidObjectSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6CAAgD;AAShD;;;;;;;KAOK;AACL,SAAgB,yBAAyB,CAIrC,OAA+B,EAC/B,gBAAoB,EACpB,WAAmC,EACnC,WAAoC;IAEpC,wDAAwD;IACxD,6DAA6D;IAC7D,MAAM,eAAe,GAAG,eAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,gBAAgB,GAAG,eAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,eAAe,GAAG,eAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClD,KAAK,MAAM,aAAa,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE;QAC5C,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC7C,IAAI,KAAK,KAAK,SAAS,EAAE;YACrB,MAAM,KAAK,CAAC,+BAA+B,CAAC,CAAC;SAChD;QACD,MAAM,EACF,IAAI,EACJ,OAAO,EACP,aAAa,GAChB,GAAG,KAAK,CAAC;QACV,MAAM,cAAc,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QACjD,IAAI,cAAc,KAAK,SAAS,EAAE;YAC9B,IACI,gBAAgB,CAAC,OAAO,CAAC,KAAK,SAAS;mBACpC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI;mBAC3C,IAAI,KAAK,KAAK,EACnB;gBACE,MAAM,KAAK,CAAC,0CAA0C,OAAO,EAAE,CAAC,CAAC;aACpE;iBAAM;gBACH,SAAS;aACZ;SACJ;QACD,IAAI,IAAI,KAAK,cAAc,CAAC,IAAI,EAAE;YAC9B,gBAAgB,CAAC,GAAG,CAAC,aAAuB,EAAE,KAAK,CAAC,CAAC;SACxD;aAAM,IAAI,aAAa,KAAK,SAAS,EAAE;YACpC,gBAAgB,CAAC,GAAG,CAAC,aAAuB,EAAE,IAAI,CAAC,CAAC;SACvD;aAAM;YACH,MAAM,KAAK,CAAC,+CAA+C,aAAa,EAAE,CAAC,CAAC;SAC/E;KACJ;IAED,IAAI,WAAW,KAAK,SAAS,EAAE;QAC3B,KAAK,MAAM,YAAY,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE;YAC3C,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YAC5C,IAAI,KAAK,KAAK,SAAS,EAAE;gBACrB,MAAM,KAAK,CAAC,+BAA+B,CAAC,CAAC;aAChD;YACD,MAAM,EACF,IAAI,EACJ,QAAQ,EACR,cAAc,GACjB,GAAG,KAAK,CAAC;YACV,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAChD,IAAI,aAAa,KAAK,SAAS,EAAE;gBAC7B,MAAM,KAAK,CAAC,yCAAyC,QAAQ,EAAE,CAAC,CAAC;aACpE;YACD,IAAI,IAAI,KAAK,aAAa,CAAC,IAAI,EAAE;gBAC7B,eAAe,CAAC,GAAG,CAAC,YAAsB,EAAE,KAAK,CAAC,CAAC;aACtD;iBAAM,IAAI,cAAc,KAAK,SAAS,EAAE;gBACrC,eAAe,CAAC,GAAG,CAAC,YAAsB,EAAE,IAAI,CAAC,CAAC;aACrD;iBAAM;gBACH,MAAM,KAAK,CAAC,+CAA+C,YAAY,EAAE,CAAC,CAAC;aAC9E;SACJ;KACJ;IAED,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC;AAClE,CAAC;AAvED,8DAuEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { SharedMap } from \"@fluidframework/map\";\nimport {\n IFluidState,\n IViewState,\n ViewToFluidMap,\n FluidToViewMap,\n IFluidSchema,\n} from \"../interface\";\n\n/**\n * Identifies which values within the Fluid and view states match\n * The view and Fluid matching map identify if the value in the respective states\n * needs a converter or not\n * @param runtime - The data store runtime used to create the SharedMap objects\n * @param fluidToView - The Fluid to view state conversion mapping\n * @param viewToFluid - The view to Fluid conversion state mapping\n * */\nexport function generateFluidObjectSchema<\n SV extends IViewState,\n SF extends IFluidState\n>(\n runtime: IFluidDataStoreRuntime,\n defaultViewState: SV,\n fluidToView: FluidToViewMap<SV, SF>,\n viewToFluid?: ViewToFluidMap<SV, SF>,\n): IFluidSchema {\n // matching primitives w/ the same key in view and fluid\n // true if needs converter or is a Fluid object, false if not\n const viewMatchingMap = SharedMap.create(runtime);\n const fluidMatchingMap = SharedMap.create(runtime);\n const storedHandleMap = SharedMap.create(runtime);\n for (const fluidStateKey of fluidToView.keys()) {\n const value = fluidToView.get(fluidStateKey);\n if (value === undefined) {\n throw Error(\"Cannot find fluidToView value\");\n }\n const {\n type,\n viewKey,\n viewConverter,\n } = value;\n const fluidConverter = viewToFluid?.get(viewKey);\n if (fluidConverter === undefined) {\n if (\n defaultViewState[viewKey] !== undefined\n && typeof (defaultViewState[viewKey]) !== type\n && type !== \"any\"\n ) {\n throw Error(`Failed to find Fluid converter for key ${viewKey}`);\n } else {\n continue;\n }\n }\n if (type === fluidConverter.type) {\n fluidMatchingMap.set(fluidStateKey as string, false);\n } else if (viewConverter !== undefined) {\n fluidMatchingMap.set(fluidStateKey as string, true);\n } else {\n throw Error(`Failed to find view converter for Fluid key ${fluidStateKey}`);\n }\n }\n\n if (viewToFluid !== undefined) {\n for (const viewStateKey of viewToFluid.keys()) {\n const value = viewToFluid.get(viewStateKey);\n if (value === undefined) {\n throw Error(\"Cannot find viewToFluid value\");\n }\n const {\n type,\n fluidKey,\n fluidConverter,\n } = value;\n const viewConverter = fluidToView.get(fluidKey);\n if (viewConverter === undefined) {\n throw Error(`Failed to find view converter for key ${fluidKey}`);\n }\n if (type === viewConverter.type) {\n viewMatchingMap.set(viewStateKey as string, false);\n } else if (fluidConverter !== undefined) {\n viewMatchingMap.set(viewStateKey as string, true);\n } else {\n throw Error(`Failed to find Fluid converter for view key ${viewStateKey}`);\n }\n }\n }\n\n return { viewMatchingMap, fluidMatchingMap, storedHandleMap };\n}\n"]}
@@ -1,15 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { IFluidConverter, IViewState, IFluidState } from "../interface";
6
- /**
7
- * Return a partial Fluid state containing the view state key identified converted into its
8
- * corresponding Fluid state value in the partial Fluid state returned
9
- * @param state - The current view state
10
- * @param viewKey - The view state key that needs to converted to its Fluid state
11
- * @param viewToFluid - A map of the view state values that need conversion to their Fluid state counterparts and the
12
- * respective converters
13
- */
14
- export declare function getFluidFromView<SV extends IViewState, SF extends IFluidState>(state: SV, viewKey: keyof SV, fluidState: SF, viewToFluid?: Map<keyof SV, IFluidConverter<SV, SF>>): Partial<SF>;
15
- //# sourceMappingURL=getFluidFromView.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFluidFromView.d.ts","sourceRoot":"","sources":["../../src/helpers/getFluidFromView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,eAAe,EACf,UAAU,EACV,WAAW,EACd,MAAM,cAAc,CAAC;AAEtB;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC5B,EAAE,SAAS,UAAU,EACrB,EAAE,SAAS,WAAW,EAEtB,KAAK,EAAE,EAAE,EACT,OAAO,EAAE,MAAM,EAAE,EACjB,UAAU,EAAE,EAAE,EACd,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GACrD,OAAO,CAAC,EAAE,CAAC,CAUb"}
@@ -1,30 +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.getFluidFromView = void 0;
8
- /**
9
- * Return a partial Fluid state containing the view state key identified converted into its
10
- * corresponding Fluid state value in the partial Fluid state returned
11
- * @param state - The current view state
12
- * @param viewKey - The view state key that needs to converted to its Fluid state
13
- * @param viewToFluid - A map of the view state values that need conversion to their Fluid state counterparts and the
14
- * respective converters
15
- */
16
- function getFluidFromView(state, viewKey, fluidState, viewToFluid) {
17
- var _a;
18
- const fluidConverter = (_a = viewToFluid === null || viewToFluid === void 0 ? void 0 : viewToFluid.get(viewKey)) === null || _a === void 0 ? void 0 : _a.fluidConverter;
19
- if (fluidConverter !== undefined) {
20
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
21
- return fluidConverter(state, fluidState);
22
- }
23
- else {
24
- const partialFluidState = {};
25
- partialFluidState[viewKey] = state[viewKey];
26
- return partialFluidState;
27
- }
28
- }
29
- exports.getFluidFromView = getFluidFromView;
30
- //# sourceMappingURL=getFluidFromView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFluidFromView.js","sourceRoot":"","sources":["../../src/helpers/getFluidFromView.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAI5B,KAAS,EACT,OAAiB,EACjB,UAAc,EACd,WAAoD;;IAEpD,MAAM,cAAc,SAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,GAAG,CAAC,OAAO,2CAAG,cAAc,CAAC;IACjE,IAAI,cAAc,KAAK,SAAS,EAAE;QAC9B,+DAA+D;QAC/D,OAAO,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;KAC5C;SAAM;QACH,MAAM,iBAAiB,GAAgB,EAAE,CAAC;QAC1C,iBAAiB,CAAC,OAAiB,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QACtD,OAAO,iBAAiB,CAAC;KAC5B;AACL,CAAC;AAlBD,4CAkBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IFluidConverter,\n IViewState,\n IFluidState,\n} from \"../interface\";\n\n/**\n * Return a partial Fluid state containing the view state key identified converted into its\n * corresponding Fluid state value in the partial Fluid state returned\n * @param state - The current view state\n * @param viewKey - The view state key that needs to converted to its Fluid state\n * @param viewToFluid - A map of the view state values that need conversion to their Fluid state counterparts and the\n * respective converters\n */\nexport function getFluidFromView<\n SV extends IViewState,\n SF extends IFluidState\n>(\n state: SV,\n viewKey: keyof SV,\n fluidState: SF,\n viewToFluid?: Map<keyof SV, IFluidConverter<SV, SF>>,\n): Partial<SF> {\n const fluidConverter = viewToFluid?.get(viewKey)?.fluidConverter;\n if (fluidConverter !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return fluidConverter(state, fluidState);\n } else {\n const partialFluidState: Partial<SF> = {};\n partialFluidState[viewKey as string] = state[viewKey];\n return partialFluidState;\n }\n}\n"]}
@@ -1,15 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { IViewConverter, FluidObjectMap, IViewState, IFluidState, ISyncedState } from "..";
6
- /**
7
- * Return the Fluid state from the syncedState with all handles converted into Fluid objects
8
- * @param syncedStateId - Unique ID for the synced state of this view
9
- * @param syncedState - Shared map the synced state is stored on
10
- * @param fluidObjectMap - Map of Fluid handle paths to their respective Fluid objects
11
- * @param fluidToView - Map of the Fluid state keys contains the optional syncedState key parameter,
12
- * in case the Fluid value is stored in the syncedState under a different key
13
- */
14
- export declare function getFluidState<SV extends IViewState, SF extends IFluidState>(syncedStateId: string, syncedState: ISyncedState, fluidObjectMap: FluidObjectMap, fluidToView?: Map<keyof SF, IViewConverter<SV, SF>>): SF | undefined;
15
- //# sourceMappingURL=getFluidState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFluidState.d.ts","sourceRoot":"","sources":["../../src/helpers/getFluidState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EACH,cAAc,EACd,cAAc,EACd,UAAU,EACV,WAAW,EACX,YAAY,EAEf,MAAM,IAAI,CAAC;AAEZ;;;;;;;GAOG;AACH,wBAAgB,aAAa,CACzB,EAAE,SAAS,UAAU,EACrB,EAAE,SAAS,WAAW,EAEtB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,YAAY,EACzB,cAAc,EAAE,cAAc,EAC9B,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GACpD,EAAE,GAAG,SAAS,CA+BhB"}
@@ -1,47 +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.getFluidState = void 0;
8
- /**
9
- * Return the Fluid state from the syncedState with all handles converted into Fluid objects
10
- * @param syncedStateId - Unique ID for the synced state of this view
11
- * @param syncedState - Shared map the synced state is stored on
12
- * @param fluidObjectMap - Map of Fluid handle paths to their respective Fluid objects
13
- * @param fluidToView - Map of the Fluid state keys contains the optional syncedState key parameter,
14
- * in case the Fluid value is stored in the syncedState under a different key
15
- */
16
- function getFluidState(syncedStateId, syncedState, fluidObjectMap, fluidToView) {
17
- var _a, _b, _c, _d;
18
- const fluidObjectStateHandle = syncedState.get(`syncedState-${syncedStateId}`);
19
- if (fluidObjectStateHandle === undefined) {
20
- return;
21
- }
22
- const fluidObjectState = (_a = fluidObjectMap.get(fluidObjectStateHandle.absolutePath)) === null || _a === void 0 ? void 0 : _a.fluidObject;
23
- if (fluidObjectState === undefined) {
24
- return;
25
- }
26
- const fluidState = {};
27
- for (const fluidKey of fluidObjectState.keys()) {
28
- const createCallback = (_b = fluidToView === null || fluidToView === void 0 ? void 0 : fluidToView.get(fluidKey)) === null || _b === void 0 ? void 0 : _b.sharedObjectCreate;
29
- let value = fluidObjectState.get(fluidKey);
30
- if (value !== undefined && createCallback !== undefined) {
31
- const possibleFluidObjectId = (_d = (_c = value) === null || _c === void 0 ? void 0 : _c.IFluidHandle) === null || _d === void 0 ? void 0 : _d.absolutePath;
32
- if (possibleFluidObjectId !== undefined) {
33
- value = (fluidObjectMap.get(possibleFluidObjectId));
34
- fluidState[fluidKey] = value === null || value === void 0 ? void 0 : value.fluidObject;
35
- }
36
- else {
37
- fluidState[fluidKey] = value;
38
- }
39
- }
40
- else {
41
- fluidState[fluidKey] = value;
42
- }
43
- }
44
- return fluidState;
45
- }
46
- exports.getFluidState = getFluidState;
47
- //# sourceMappingURL=getFluidState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFluidState.js","sourceRoot":"","sources":["../../src/helpers/getFluidState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgBH;;;;;;;GAOG;AACH,SAAgB,aAAa,CAIzB,aAAqB,EACrB,WAAyB,EACzB,cAA8B,EAC9B,WAAmD;;IAEnD,MAAM,sBAAsB,GAAG,WAAW,CAAC,GAAG,CAC1C,eAAe,aAAa,EAAE,CACjC,CAAC;IACF,IAAI,sBAAsB,KAAK,SAAS,EAAE;QACtC,OAAO;KACV;IACD,MAAM,gBAAgB,GAAG,MAAA,cAAc,CAAC,GAAG,CAAC,sBAAsB,CAAC,YAAY,CAAC,0CAC1E,WAAwB,CAAC;IAC/B,IAAI,gBAAgB,KAAK,SAAS,EAAE;QAChC,OAAO;KACV;IACD,MAAM,UAAU,GAAG,EAAE,CAAC;IACtB,KAAK,MAAM,QAAQ,IAAI,gBAAgB,CAAC,IAAI,EAAE,EAAE;QAC5C,MAAM,cAAc,SAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,GAAG,CAAC,QAAoB,2CACtD,kBAAkB,CAAC;QACzB,IAAI,KAAK,GAAG,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC3C,IAAI,KAAK,KAAK,SAAS,IAAI,cAAc,KAAK,SAAS,EAAE;YACrD,MAAM,qBAAqB,eAAI,KAAsB,0CAC/C,YAAY,0CAAE,YAAY,CAAC;YACjC,IAAI,qBAAqB,KAAK,SAAS,EAAE;gBACrC,KAAK,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAwB,CAAC;gBAC3E,UAAU,CAAC,QAAQ,CAAC,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW,CAAC;aAC7C;iBAAM;gBACH,UAAU,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;aAChC;SACJ;aAAM;YACH,UAAU,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;SAChC;KACJ;IACD,OAAO,UAAgB,CAAC;AAC5B,CAAC;AAvCD,sCAuCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IFluidObject,\n IFluidHandle,\n} from \"@fluidframework/core-interfaces\";\nimport { ISharedMap, SharedMap } from \"@fluidframework/map\";\nimport {\n IViewConverter,\n FluidObjectMap,\n IViewState,\n IFluidState,\n ISyncedState,\n IFluidObjectMapItem,\n} from \"..\";\n\n/**\n * Return the Fluid state from the syncedState with all handles converted into Fluid objects\n * @param syncedStateId - Unique ID for the synced state of this view\n * @param syncedState - Shared map the synced state is stored on\n * @param fluidObjectMap - Map of Fluid handle paths to their respective Fluid objects\n * @param fluidToView - Map of the Fluid state keys contains the optional syncedState key parameter,\n * in case the Fluid value is stored in the syncedState under a different key\n */\nexport function getFluidState<\n SV extends IViewState,\n SF extends IFluidState\n>(\n syncedStateId: string,\n syncedState: ISyncedState,\n fluidObjectMap: FluidObjectMap,\n fluidToView?: Map<keyof SF, IViewConverter<SV, SF>>,\n): SF | undefined {\n const fluidObjectStateHandle = syncedState.get<IFluidHandle<ISharedMap>>(\n `syncedState-${syncedStateId}`,\n );\n if (fluidObjectStateHandle === undefined) {\n return;\n }\n const fluidObjectState = fluidObjectMap.get(fluidObjectStateHandle.absolutePath)\n ?.fluidObject as SharedMap;\n if (fluidObjectState === undefined) {\n return;\n }\n const fluidState = {};\n for (const fluidKey of fluidObjectState.keys()) {\n const createCallback = fluidToView?.get(fluidKey as keyof SF)\n ?.sharedObjectCreate;\n let value = fluidObjectState.get(fluidKey);\n if (value !== undefined && createCallback !== undefined) {\n const possibleFluidObjectId = (value as IFluidObject)\n ?.IFluidHandle?.absolutePath;\n if (possibleFluidObjectId !== undefined) {\n value = (fluidObjectMap.get(possibleFluidObjectId)) as IFluidObjectMapItem;\n fluidState[fluidKey] = value?.fluidObject;\n } else {\n fluidState[fluidKey] = value;\n }\n } else {\n fluidState[fluidKey] = value;\n }\n }\n return fluidState as SF;\n}\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 { ISyncedState } from "../interface";
6
- import { IFluidSchemaHandles } from "./internalInterface";
7
- /**
8
- * Returns the schema stored on the synced state for this Fluid object
9
- * @param syncedStateId - Unique ID for this synced data object's state
10
- * @param syncedState - The shared map this Fluid shared state is stored on
11
- */
12
- export declare const getSchema: (syncedStateId: string, syncedState: ISyncedState) => IFluidSchemaHandles | undefined;
13
- //# sourceMappingURL=getSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getSchema.d.ts","sourceRoot":"","sources":["../../src/helpers/getSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,SAAS,kBACH,MAAM,eACR,YAAY,KAC1B,mBAAmB,GAAG,SAC0C,CAAC"}
@@ -1,15 +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.getSchema = void 0;
8
- /**
9
- * Returns the schema stored on the synced state for this Fluid object
10
- * @param syncedStateId - Unique ID for this synced data object's state
11
- * @param syncedState - The shared map this Fluid shared state is stored on
12
- */
13
- const getSchema = (syncedStateId, syncedState) => syncedState.get(`schema-${syncedStateId}`);
14
- exports.getSchema = getSchema;
15
- //# sourceMappingURL=getSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getSchema.js","sourceRoot":"","sources":["../../src/helpers/getSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH;;;;GAIG;AACI,MAAM,SAAS,GAAG,CACrB,aAAqB,EACrB,WAAyB,EACM,EAAE,CACjC,WAAW,CAAC,GAAG,CAAsB,UAAU,aAAa,EAAE,CAAC,CAAC;AAJvD,QAAA,SAAS,aAI8C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISyncedState } from \"../interface\";\nimport { IFluidSchemaHandles } from \"./internalInterface\";\n\n/**\n * Returns the schema stored on the synced state for this Fluid object\n * @param syncedStateId - Unique ID for this synced data object's state\n * @param syncedState - The shared map this Fluid shared state is stored on\n */\nexport const getSchema = (\n syncedStateId: string,\n syncedState: ISyncedState,\n): IFluidSchemaHandles | undefined =>\n syncedState.get<IFluidSchemaHandles>(`schema-${syncedStateId}`);\n"]}
@@ -1,18 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { FluidObjectMap, IViewConverter, IViewState, IFluidState, ISyncedState } from "../interface";
6
- /**
7
- * Return a partial view state containing the Fluid state key identified converted into its
8
- * corresponding view state value in the partial view state returned
9
- * @param syncedStateId - Unique ID for the synced state of this view
10
- * @param syncedState - The shared map this shared state is stored on
11
- * @param fluidKey - The key of the value within the Fluid state that we want converted
12
- * @param fluidObjectMap - A map of Fluid handle paths to their Fluid objects
13
- * @param fluidToView - A map of the Fluid state values that need conversion to their view state counterparts and the
14
- * respective converters
15
- * @param combinedFluidState - Optional param containing the combined Fluid state so far to fetch from
16
- */
17
- export declare function getViewFromFluid<SV extends IViewState, SF extends IFluidState>(syncedStateId: string, syncedState: ISyncedState, fluidKey: keyof SF, fluidObjectMap: FluidObjectMap, fluidToView: Map<keyof SF, IViewConverter<SV, SF>>, viewState: SV, combinedFluidState?: Partial<SF>): Partial<SV>;
18
- //# sourceMappingURL=getViewFromFluid.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getViewFromFluid.d.ts","sourceRoot":"","sources":["../../src/helpers/getViewFromFluid.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,cAAc,EACd,cAAc,EACd,UAAU,EACV,WAAW,EACX,YAAY,EACf,MAAM,cAAc,CAAC;AAGtB;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC5B,EAAE,SAAS,UAAU,EACrB,EAAE,SAAS,WAAW,EAEtB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,YAAY,EACzB,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAClD,SAAS,EAAE,EAAE,EACb,kBAAkB,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,GACjC,OAAO,CAAC,EAAE,CAAC,CA8Bb"}
@@ -1,47 +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.getViewFromFluid = void 0;
8
- const getFluidState_1 = require("./getFluidState");
9
- /**
10
- * Return a partial view state containing the Fluid state key identified converted into its
11
- * corresponding view state value in the partial view state returned
12
- * @param syncedStateId - Unique ID for the synced state of this view
13
- * @param syncedState - The shared map this shared state is stored on
14
- * @param fluidKey - The key of the value within the Fluid state that we want converted
15
- * @param fluidObjectMap - A map of Fluid handle paths to their Fluid objects
16
- * @param fluidToView - A map of the Fluid state values that need conversion to their view state counterparts and the
17
- * respective converters
18
- * @param combinedFluidState - Optional param containing the combined Fluid state so far to fetch from
19
- */
20
- function getViewFromFluid(syncedStateId, syncedState, fluidKey, fluidObjectMap, fluidToView, viewState, combinedFluidState) {
21
- var _a, _b;
22
- const fluidObjectState = getFluidState_1.getFluidState(syncedStateId, syncedState, fluidObjectMap, fluidToView);
23
- if (fluidObjectState === undefined) {
24
- throw Error("Attempted to fetch view from Fluid state before it was initialized");
25
- }
26
- let value = fluidObjectState[fluidKey];
27
- if (combinedFluidState !== undefined) {
28
- value = (_a = combinedFluidState[fluidKey]) !== null && _a !== void 0 ? _a : value;
29
- }
30
- const viewConverter = (_b = fluidToView.get(fluidKey)) === null || _b === void 0 ? void 0 : _b.viewConverter;
31
- if (viewConverter !== undefined) {
32
- const partialFluidState = {};
33
- partialFluidState[fluidKey] = value;
34
- return viewConverter(viewState, partialFluidState, fluidObjectMap);
35
- }
36
- else {
37
- const partialViewState = {};
38
- const valueAsIFluidHandle = value.IFluidHandle;
39
- const convertedValue = valueAsIFluidHandle !== undefined
40
- ? fluidObjectMap.get(valueAsIFluidHandle.absolutePath)
41
- : value;
42
- partialViewState[fluidKey] = convertedValue;
43
- return partialViewState;
44
- }
45
- }
46
- exports.getViewFromFluid = getViewFromFluid;
47
- //# sourceMappingURL=getViewFromFluid.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getViewFromFluid.js","sourceRoot":"","sources":["../../src/helpers/getViewFromFluid.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAUH,mDAAgD;AAEhD;;;;;;;;;;GAUG;AACH,SAAgB,gBAAgB,CAI5B,aAAqB,EACrB,WAAyB,EACzB,QAAkB,EAClB,cAA8B,EAC9B,WAAkD,EAClD,SAAa,EACb,kBAAgC;;IAEhC,MAAM,gBAAgB,GAAG,6BAAa,CAClC,aAAa,EACb,WAAW,EACX,cAAc,EACd,WAAW,CACd,CAAC;IACF,IAAI,gBAAgB,KAAK,SAAS,EAAE;QAChC,MAAM,KAAK,CACP,oEAAoE,CACvE,CAAC;KACL;IACD,IAAI,KAAK,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,kBAAkB,KAAK,SAAS,EAAE;QAClC,KAAK,SAAG,kBAAkB,CAAC,QAAQ,CAAC,mCAAI,KAAK,CAAC;KACjD;IACD,MAAM,aAAa,SAAG,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,0CAAE,aAAa,CAAC;IAC/D,IAAI,aAAa,KAAK,SAAS,EAAE;QAC7B,MAAM,iBAAiB,GAAgB,EAAE,CAAC;QAC1C,iBAAiB,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;QACpC,OAAO,aAAa,CAAC,SAAS,EAAE,iBAAiB,EAAE,cAAc,CAAC,CAAC;KACtE;SAAM;QACH,MAAM,gBAAgB,GAAgB,EAAE,CAAC;QACzC,MAAM,mBAAmB,GAAI,KAAsB,CAAC,YAAY,CAAC;QACjE,MAAM,cAAc,GAAG,mBAAmB,KAAK,SAAS;YACpD,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,mBAAmB,CAAC,YAAY,CAAC;YACtD,CAAC,CAAC,KAAK,CAAC;QACZ,gBAAgB,CAAC,QAAkB,CAAC,GAAG,cAAc,CAAC;QACtD,OAAO,gBAAgB,CAAC;KAC3B;AACL,CAAC;AAzCD,4CAyCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidObject } from \"@fluidframework/core-interfaces\";\nimport {\n FluidObjectMap,\n IViewConverter,\n IViewState,\n IFluidState,\n ISyncedState,\n} from \"../interface\";\nimport { getFluidState } from \"./getFluidState\";\n\n/**\n * Return a partial view state containing the Fluid state key identified converted into its\n * corresponding view state value in the partial view state returned\n * @param syncedStateId - Unique ID for the synced state of this view\n * @param syncedState - The shared map this shared state is stored on\n * @param fluidKey - The key of the value within the Fluid state that we want converted\n * @param fluidObjectMap - A map of Fluid handle paths to their Fluid objects\n * @param fluidToView - A map of the Fluid state values that need conversion to their view state counterparts and the\n * respective converters\n * @param combinedFluidState - Optional param containing the combined Fluid state so far to fetch from\n */\nexport function getViewFromFluid<\n SV extends IViewState,\n SF extends IFluidState\n>(\n syncedStateId: string,\n syncedState: ISyncedState,\n fluidKey: keyof SF,\n fluidObjectMap: FluidObjectMap,\n fluidToView: Map<keyof SF, IViewConverter<SV, SF>>,\n viewState: SV,\n combinedFluidState?: Partial<SF>,\n): Partial<SV> {\n const fluidObjectState = getFluidState(\n syncedStateId,\n syncedState,\n fluidObjectMap,\n fluidToView,\n );\n if (fluidObjectState === undefined) {\n throw Error(\n \"Attempted to fetch view from Fluid state before it was initialized\",\n );\n }\n let value = fluidObjectState[fluidKey];\n if (combinedFluidState !== undefined) {\n value = combinedFluidState[fluidKey] ?? value;\n }\n const viewConverter = fluidToView.get(fluidKey)?.viewConverter;\n if (viewConverter !== undefined) {\n const partialFluidState: Partial<SF> = {};\n partialFluidState[fluidKey] = value;\n return viewConverter(viewState, partialFluidState, fluidObjectMap);\n } else {\n const partialViewState: Partial<SV> = {};\n const valueAsIFluidHandle = (value as IFluidObject).IFluidHandle;\n const convertedValue = valueAsIFluidHandle !== undefined\n ? fluidObjectMap.get(valueAsIFluidHandle.absolutePath)\n : value;\n partialViewState[fluidKey as string] = convertedValue;\n return partialViewState;\n }\n}\n"]}
@@ -1,16 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- export * from "./getFluidFromView";
6
- export * from "./getViewFromFluid";
7
- export * from "./rootCallbackListener";
8
- export * from "./syncState";
9
- export * from "./updateStateAndFluidObjectMap";
10
- export * from "./generateFluidObjectSchema";
11
- export * from "./getFluidState";
12
- export * from "./setFluidState";
13
- export * from "./getSchema";
14
- export * from "./setComponentSchema";
15
- export * from "./initializeState";
16
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC"}
@@ -1,28 +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("./getFluidFromView"), exports);
18
- __exportStar(require("./getViewFromFluid"), exports);
19
- __exportStar(require("./rootCallbackListener"), exports);
20
- __exportStar(require("./syncState"), exports);
21
- __exportStar(require("./updateStateAndFluidObjectMap"), exports);
22
- __exportStar(require("./generateFluidObjectSchema"), exports);
23
- __exportStar(require("./getFluidState"), exports);
24
- __exportStar(require("./setFluidState"), exports);
25
- __exportStar(require("./getSchema"), exports);
26
- __exportStar(require("./setComponentSchema"), exports);
27
- __exportStar(require("./initializeState"), exports);
28
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.tsx"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,qDAAmC;AACnC,qDAAmC;AACnC,yDAAuC;AACvC,8CAA4B;AAC5B,iEAA+C;AAC/C,8DAA4C;AAC5C,kDAAgC;AAChC,kDAAgC;AAChC,8CAA4B;AAC5B,uDAAqC;AACrC,oDAAkC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./getFluidFromView\";\nexport * from \"./getViewFromFluid\";\nexport * from \"./rootCallbackListener\";\nexport * from \"./syncState\";\nexport * from \"./updateStateAndFluidObjectMap\";\nexport * from \"./generateFluidObjectSchema\";\nexport * from \"./getFluidState\";\nexport * from \"./setFluidState\";\nexport * from \"./getSchema\";\nexport * from \"./setComponentSchema\";\nexport * from \"./initializeState\";\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 { IFluidDataProps, FluidToViewMap, ViewToFluidMap, IViewState, IFluidState, ISyncedState } from "../interface";
6
- /**
7
- * Fetch the synced state for this view from the SyncedDataObject sharedState and add
8
- * listeners for all state updates
9
- * @param syncedStateId - Unique ID for this synced data object's state
10
- * @param syncedState - The synced data object's shared state map
11
- * @param fluidToView - A map of the Fluid state values that need conversion to their view state counterparts and the
12
- * respective converters
13
- * @param dataProps - Contains the runtime and fluidObjectMap to create and store DDSes
14
- * @param state - Current view state
15
- * @param setState - Callback to update view state
16
- * @param viewToFluid - A map of the view state values that need conversion to their Fluid state counterparts and the
17
- * respective converters
18
- * @param fluidToView - A map of the Fluid state values that need conversion to their view state counterparts and the
19
- * respective converters
20
- */
21
- export declare function initializeState<SV extends IViewState, SF extends IFluidState>(syncedStateId: string, syncedState: ISyncedState, dataProps: IFluidDataProps, state: SV, setState: (newState: SV, fromRootUpdate?: boolean, isLocal?: boolean) => void, fluidToView: FluidToViewMap<SV, SF>, viewToFluid?: ViewToFluidMap<SV, SF>): Promise<void>;
22
- //# sourceMappingURL=initializeState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initializeState.d.ts","sourceRoot":"","sources":["../../src/helpers/initializeState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EACH,eAAe,EACf,cAAc,EACd,cAAc,EACd,UAAU,EACV,WAAW,EACX,YAAY,EACf,MAAM,cAAc,CAAC;AAQtB;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,eAAe,CACjC,EAAE,SAAS,UAAU,EACrB,EAAE,SAAS,WAAW,EAEtB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,YAAY,EACzB,SAAS,EAAE,eAAe,EAC1B,KAAK,EAAE,EAAE,EACT,QAAQ,EAAE,CACN,QAAQ,EAAE,EAAE,EACZ,cAAc,CAAC,EAAE,OAAO,EACxB,OAAO,CAAC,EAAE,OAAO,KAChB,IAAI,EACT,WAAW,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,CAAC,EACnC,WAAW,CAAC,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,CAAC,GACrC,OAAO,CAAC,IAAI,CAAC,CA0Gf"}
@@ -1,77 +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.initializeState = void 0;
8
- const _1 = require(".");
9
- /**
10
- * Fetch the synced state for this view from the SyncedDataObject sharedState and add
11
- * listeners for all state updates
12
- * @param syncedStateId - Unique ID for this synced data object's state
13
- * @param syncedState - The synced data object's shared state map
14
- * @param fluidToView - A map of the Fluid state values that need conversion to their view state counterparts and the
15
- * respective converters
16
- * @param dataProps - Contains the runtime and fluidObjectMap to create and store DDSes
17
- * @param state - Current view state
18
- * @param setState - Callback to update view state
19
- * @param viewToFluid - A map of the view state values that need conversion to their Fluid state counterparts and the
20
- * respective converters
21
- * @param fluidToView - A map of the Fluid state values that need conversion to their view state counterparts and the
22
- * respective converters
23
- */
24
- async function initializeState(syncedStateId, syncedState, dataProps, state, setState, fluidToView, viewToFluid) {
25
- var _a;
26
- const schemaHandles = _1.getSchema(syncedStateId, syncedState);
27
- if ((schemaHandles === null || schemaHandles === void 0 ? void 0 : schemaHandles.storedHandleMapHandle.absolutePath) === undefined) {
28
- throw Error(`Schema not initialized prior to render for ${syncedStateId}`);
29
- }
30
- const storedHandleMap = (_a = dataProps.fluidObjectMap.get(schemaHandles === null || schemaHandles === void 0 ? void 0 : schemaHandles.storedHandleMapHandle.absolutePath)) === null || _a === void 0 ? void 0 : _a.fluidObject;
31
- if (storedHandleMap === undefined) {
32
- throw Error(`Stored handle map not initialized prior to render for ${syncedStateId}`);
33
- }
34
- const unlistenedHandles = [];
35
- for (const handle of storedHandleMap.values()) {
36
- unlistenedHandles.push(handle);
37
- }
38
- const currentFluidState = _1.getFluidState(syncedStateId, syncedState, dataProps.fluidObjectMap, fluidToView);
39
- if (currentFluidState === undefined) {
40
- throw Error("Synced state update triggered before Fluid state was initialized");
41
- }
42
- for (const fluidStateKey of fluidToView.keys()) {
43
- const value = fluidToView.get(fluidStateKey);
44
- if (value === undefined) {
45
- throw Error("Cannot find fluidToView value");
46
- }
47
- if (value.sharedObjectCreate !== undefined) {
48
- const fluidObject = currentFluidState[fluidStateKey];
49
- unlistenedHandles.push(fluidObject.handle);
50
- }
51
- }
52
- state.isInitialized = true;
53
- state.syncedStateId = syncedStateId;
54
- // Define the synced state callback listener that will be responsible for triggering state updates on synced state
55
- // value changes
56
- const syncedStateCallback = (change, local) => {
57
- const callback = _1.syncedStateCallbackListener(dataProps.fluidObjectMap, storedHandleMap, syncedStateId, syncedState, dataProps.runtime, state, setState, fluidToView, viewToFluid);
58
- return callback(change, local);
59
- };
60
- // Add the callback to the fluidObject's own synced state
61
- syncedState.addValueChangedListener(syncedStateCallback);
62
- storedHandleMap.on("valueChanged", (change, local) => {
63
- var _a, _b;
64
- const handle = storedHandleMap.get(change.key);
65
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
66
- if (handle !== undefined && !((_a = state.fluidObjectMap) === null || _a === void 0 ? void 0 : _a.has(handle.absolutePath))) {
67
- (_b = state.fluidObjectMap) === null || _b === void 0 ? void 0 : _b.set(handle.absolutePath, {
68
- isListened: false,
69
- });
70
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
71
- _1.updateStateAndFluidObjectMap([handle], dataProps.fluidObjectMap, storedHandleMap, true, syncedStateId, syncedState, dataProps.runtime, state, setState, syncedStateCallback, fluidToView, viewToFluid);
72
- }
73
- });
74
- return _1.updateStateAndFluidObjectMap(unlistenedHandles, dataProps.fluidObjectMap, storedHandleMap, true, syncedStateId, syncedState, dataProps.runtime, state, setState, syncedStateCallback, fluidToView, viewToFluid);
75
- }
76
- exports.initializeState = initializeState;
77
- //# sourceMappingURL=initializeState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initializeState.js","sourceRoot":"","sources":["../../src/helpers/initializeState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAeH,wBAKW;AAEX;;;;;;;;;;;;;;GAcG;AACI,KAAK,UAAU,eAAe,CAIjC,aAAqB,EACrB,WAAyB,EACzB,SAA0B,EAC1B,KAAS,EACT,QAIS,EACT,WAAmC,EACnC,WAAoC;;IAEpC,MAAM,aAAa,GAAG,YAAS,CAC3B,aAAa,EACb,WAAW,CACd,CAAC;IACF,IAAI,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,qBAAqB,CAAC,YAAY,MAAK,SAAS,EAAE;QACjE,MAAM,KAAK,CAAC,8CAA8C,aAAa,EAAE,CAAC,CAAC;KAC9E;IACD,MAAM,eAAe,GAAG,MAAA,SAAS,CAAC,cAAc,CAAC,GAAG,CAChD,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,qBAAqB,CAAC,YAAY,CACpD,0CAAE,WAAwB,CAAC;IAC5B,IAAI,eAAe,KAAK,SAAS,EAAE;QAC/B,MAAM,KAAK,CAAC,yDAAyD,aAAa,EAAE,CAAC,CAAC;KACzF;IACD,MAAM,iBAAiB,GAAmB,EAAE,CAAC;IAC7C,KAAK,MAAM,MAAM,IAAI,eAAe,CAAC,MAAM,EAAE,EAAE;QAC3C,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAClC;IAED,MAAM,iBAAiB,GAAG,gBAAa,CACnC,aAAa,EACb,WAAW,EACX,SAAS,CAAC,cAAc,EACxB,WAAW,CACd,CAAC;IACF,IAAI,iBAAiB,KAAK,SAAS,EAAE;QACjC,MAAM,KAAK,CAAC,kEAAkE,CAAC,CAAC;KACnF;IAED,KAAK,MAAM,aAAa,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE;QAC5C,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC7C,IAAI,KAAK,KAAK,SAAS,EAAE;YACrB,MAAM,KAAK,CAAC,+BAA+B,CAAC,CAAC;SAChD;QACD,IAAI,KAAK,CAAC,kBAAkB,KAAK,SAAS,EAAE;YACxC,MAAM,WAAW,GAAG,iBAAiB,CAAC,aAAa,CAAQ,CAAC;YAC5D,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;SAC9C;KACJ;IAED,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC;IACpC,kHAAkH;IAClH,gBAAgB;IAChB,MAAM,mBAAmB,GAAG,CACxB,MAAqB,EACrB,KAAc,EAChB,EAAE;QACA,MAAM,QAAQ,GAAG,8BAA2B,CACxC,SAAS,CAAC,cAAc,EACxB,eAAe,EACf,aAAa,EACb,WAAW,EACX,SAAS,CAAC,OAAO,EACjB,KAAK,EACL,QAAQ,EACR,WAAW,EACX,WAAW,CACd,CAAC;QACF,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,yDAAyD;IACzD,WAAW,CAAC,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;IACzD,eAAe,CAAC,EAAE,CAAC,cAAc,EAAE,CAC/B,MAAqB,EACrB,KAAc,EAChB,EAAE;;QACA,MAAM,MAAM,GAAG,eAAe,CAAC,GAAG,CAAe,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,yEAAyE;QACzE,IAAI,MAAM,KAAK,SAAS,IAAI,QAAC,KAAK,CAAC,cAAc,0CAAE,GAAG,CAAC,MAAM,CAAC,YAAY,EAAC,EAAE;YACzE,MAAA,KAAK,CAAC,cAAc,0CAAE,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE;gBAC3C,UAAU,EAAE,KAAK;aACpB,EAAE;YACH,mEAAmE;YACnE,+BAA4B,CACxB,CAAC,MAAM,CAAC,EACR,SAAS,CAAC,cAAc,EACxB,eAAe,EACf,IAAI,EACJ,aAAa,EACb,WAAW,EACX,SAAS,CAAC,OAAO,EACjB,KAAK,EACL,QAAQ,EACR,mBAAmB,EACnB,WAAW,EACX,WAAW,CACd,CAAC;SACL;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,+BAA4B,CAC/B,iBAAiB,EACjB,SAAS,CAAC,cAAc,EACxB,eAAe,EACf,IAAI,EACJ,aAAa,EACb,WAAW,EACX,SAAS,CAAC,OAAO,EACjB,KAAK,EACL,QAAQ,EACR,mBAAmB,EACnB,WAAW,EACX,WAAW,CACd,CAAC;AACN,CAAC;AAzHD,0CAyHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n IValueChanged,\n SharedMap,\n} from \"@fluidframework/map\";\nimport {\n IFluidDataProps,\n FluidToViewMap,\n ViewToFluidMap,\n IViewState,\n IFluidState,\n ISyncedState,\n} from \"../interface\";\nimport {\n syncedStateCallbackListener,\n updateStateAndFluidObjectMap,\n getSchema,\n getFluidState,\n} from \".\";\n\n/**\n * Fetch the synced state for this view from the SyncedDataObject sharedState and add\n * listeners for all state updates\n * @param syncedStateId - Unique ID for this synced data object's state\n * @param syncedState - The synced data object's shared state map\n * @param fluidToView - A map of the Fluid state values that need conversion to their view state counterparts and the\n * respective converters\n * @param dataProps - Contains the runtime and fluidObjectMap to create and store DDSes\n * @param state - Current view state\n * @param setState - Callback to update view state\n * @param viewToFluid - A map of the view state values that need conversion to their Fluid state counterparts and the\n * respective converters\n * @param fluidToView - A map of the Fluid state values that need conversion to their view state counterparts and the\n * respective converters\n */\nexport async function initializeState<\n SV extends IViewState,\n SF extends IFluidState\n>(\n syncedStateId: string,\n syncedState: ISyncedState,\n dataProps: IFluidDataProps,\n state: SV,\n setState: (\n newState: SV,\n fromRootUpdate?: boolean,\n isLocal?: boolean\n ) => void,\n fluidToView: FluidToViewMap<SV, SF>,\n viewToFluid?: ViewToFluidMap<SV, SF>,\n): Promise<void> {\n const schemaHandles = getSchema(\n syncedStateId,\n syncedState,\n );\n if (schemaHandles?.storedHandleMapHandle.absolutePath === undefined) {\n throw Error(`Schema not initialized prior to render for ${syncedStateId}`);\n }\n const storedHandleMap = dataProps.fluidObjectMap.get(\n schemaHandles?.storedHandleMapHandle.absolutePath,\n )?.fluidObject as SharedMap;\n if (storedHandleMap === undefined) {\n throw Error(`Stored handle map not initialized prior to render for ${syncedStateId}`);\n }\n const unlistenedHandles: IFluidHandle[] = [];\n for (const handle of storedHandleMap.values()) {\n unlistenedHandles.push(handle);\n }\n\n const currentFluidState = getFluidState(\n syncedStateId,\n syncedState,\n dataProps.fluidObjectMap,\n fluidToView,\n );\n if (currentFluidState === undefined) {\n throw Error(\"Synced state update triggered before Fluid state was initialized\");\n }\n\n for (const fluidStateKey of fluidToView.keys()) {\n const value = fluidToView.get(fluidStateKey);\n if (value === undefined) {\n throw Error(\"Cannot find fluidToView value\");\n }\n if (value.sharedObjectCreate !== undefined) {\n const fluidObject = currentFluidState[fluidStateKey] as any;\n unlistenedHandles.push(fluidObject.handle);\n }\n }\n\n state.isInitialized = true;\n state.syncedStateId = syncedStateId;\n // Define the synced state callback listener that will be responsible for triggering state updates on synced state\n // value changes\n const syncedStateCallback = (\n change: IValueChanged,\n local: boolean,\n ) => {\n const callback = syncedStateCallbackListener(\n dataProps.fluidObjectMap,\n storedHandleMap,\n syncedStateId,\n syncedState,\n dataProps.runtime,\n state,\n setState,\n fluidToView,\n viewToFluid,\n );\n return callback(change, local);\n };\n\n // Add the callback to the fluidObject's own synced state\n syncedState.addValueChangedListener(syncedStateCallback);\n storedHandleMap.on(\"valueChanged\", (\n change: IValueChanged,\n local: boolean,\n ) => {\n const handle = storedHandleMap.get<IFluidHandle>(change.key);\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (handle !== undefined && !state.fluidObjectMap?.has(handle.absolutePath)) {\n state.fluidObjectMap?.set(handle.absolutePath, {\n isListened: false,\n });\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n updateStateAndFluidObjectMap<SV, SF>(\n [handle],\n dataProps.fluidObjectMap,\n storedHandleMap,\n true,\n syncedStateId,\n syncedState,\n dataProps.runtime,\n state,\n setState,\n syncedStateCallback,\n fluidToView,\n viewToFluid,\n );\n }\n });\n\n return updateStateAndFluidObjectMap<SV, SF>(\n unlistenedHandles,\n dataProps.fluidObjectMap,\n storedHandleMap,\n true,\n syncedStateId,\n syncedState,\n dataProps.runtime,\n state,\n setState,\n syncedStateCallback,\n fluidToView,\n viewToFluid,\n );\n}\n"]}
@@ -1,15 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { IFluidHandle } from "@fluidframework/core-interfaces";
6
- import { ISharedMap } from "@fluidframework/map";
7
- /**
8
- * The respective handles for the Fluid schema params listed above
9
- */
10
- export interface IFluidSchemaHandles {
11
- viewMatchingMapHandle: IFluidHandle<ISharedMap>;
12
- fluidMatchingMapHandle: IFluidHandle<ISharedMap>;
13
- storedHandleMapHandle: IFluidHandle<ISharedMap>;
14
- }
15
- //# sourceMappingURL=internalInterface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internalInterface.d.ts","sourceRoot":"","sources":["../../src/helpers/internalInterface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,qBAAqB,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IAChD,sBAAsB,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IACjD,qBAAqB,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;CACnD"}
@@ -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=internalInterface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internalInterface.js","sourceRoot":"","sources":["../../src/helpers/internalInterface.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 { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { ISharedMap } from \"@fluidframework/map\";\n\n/**\n * The respective handles for the Fluid schema params listed above\n */\nexport interface IFluidSchemaHandles {\n viewMatchingMapHandle: IFluidHandle<ISharedMap>;\n fluidMatchingMapHandle: IFluidHandle<ISharedMap>;\n storedHandleMapHandle: IFluidHandle<ISharedMap>;\n}\n"]}
@@ -1,24 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { ISharedMap, IValueChanged } from "@fluidframework/map";
6
- import { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
7
- import { FluidObjectMap, ViewToFluidMap, FluidToViewMap, IViewState, IFluidState } from "../interface";
8
- import { ISyncedState } from "..";
9
- /**
10
- * The callback that is added to the "valueChanged" event on the Fluid object this
11
- * is passed in to. This will trigger state updates when the synced state value is updated
12
- * @param fluidObjectMap - A map of Fluid handle paths to their Fluid objects
13
- * @param syncedStateId - Unique ID for this synced Fluid object's state
14
- * @param syncedState - The shared map this Fluid object's synced state is stored on
15
- * @param runtime - The data store runtime
16
- * @param state - The current view state
17
- * @param setState - Callback to update the react view state
18
- * @param fluidToView - A map of the Fluid state values that need conversion to their view state counterparts and the
19
- * respective converters
20
- * @param viewToFluid - A map of the view state values that need conversion to their Fluid state counterparts and the
21
- * respective converters
22
- */
23
- export declare const syncedStateCallbackListener: <SV extends IViewState, SF extends IFluidState>(fluidObjectMap: FluidObjectMap, storedHandleMap: ISharedMap, syncedStateId: any, syncedState: ISyncedState, runtime: IFluidDataStoreRuntime, state: SV, setState: (newState: SV, fromRootUpdate?: boolean | undefined, isLocal?: boolean | undefined) => void, fluidToView: FluidToViewMap<SV, SF>, viewToFluid?: ViewToFluidMap<SV, SF> | undefined) => (change: IValueChanged, local: boolean) => void;
24
- //# sourceMappingURL=rootCallbackListener.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rootCallbackListener.d.ts","sourceRoot":"","sources":["../../src/helpers/rootCallbackListener.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EACH,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EACV,WAAW,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAMlC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,2BAA2B,mGAKnB,UAAU,mCAEd,YAAY,WAChB,sBAAsB,8GAM1B,IAAI,qGAGC,aAAa,SAAS,OAAO,SAoD1C,CAAC"}