@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.
- package/.eslintrc.cjs +11 -0
- package/.mocharc.cjs +15 -0
- package/CHANGELOG.md +282 -0
- package/README.md +122 -273
- package/api-extractor/api-extractor-lint-alpha.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-alpha.esm.json +5 -0
- package/api-extractor/api-extractor-lint-beta.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-beta.esm.json +5 -0
- package/api-extractor/api-extractor-lint-bundle.json +5 -0
- package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-public.esm.json +5 -0
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/react.alpha.api.md +114 -0
- package/api-report/react.beta.api.md +7 -0
- package/api-report/react.public.api.md +7 -0
- package/biome.jsonc +4 -0
- package/dist/alpha.d.ts +45 -0
- package/dist/beta.d.ts +15 -0
- package/dist/index.d.ts +11 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -17
- package/dist/index.js.map +1 -1
- package/dist/package.json +4 -0
- package/dist/propNode.d.ts +114 -0
- package/dist/propNode.d.ts.map +1 -0
- package/dist/propNode.js +43 -0
- package/dist/propNode.js.map +1 -0
- package/dist/public.d.ts +15 -0
- package/dist/reactSharedTreeView.d.ts +119 -0
- package/dist/reactSharedTreeView.d.ts.map +1 -0
- package/dist/reactSharedTreeView.js +206 -0
- package/dist/reactSharedTreeView.js.map +1 -0
- package/dist/simpleIdentifier.d.ts +19 -0
- package/dist/simpleIdentifier.d.ts.map +1 -0
- package/dist/simpleIdentifier.js +33 -0
- package/dist/simpleIdentifier.js.map +1 -0
- package/dist/useObservation.d.ts +83 -0
- package/dist/useObservation.d.ts.map +1 -0
- package/dist/useObservation.js +295 -0
- package/dist/useObservation.js.map +1 -0
- package/dist/useTree.d.ts +80 -0
- package/dist/useTree.d.ts.map +1 -0
- package/dist/useTree.js +137 -0
- package/dist/useTree.js.map +1 -0
- package/lib/alpha.d.ts +45 -0
- package/lib/beta.d.ts +15 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +4 -7
- package/lib/index.js.map +1 -1
- package/lib/package.json +4 -0
- package/lib/propNode.d.ts +114 -0
- package/lib/propNode.d.ts.map +1 -0
- package/lib/propNode.js +36 -0
- package/lib/propNode.js.map +1 -0
- package/lib/public.d.ts +15 -0
- package/lib/reactSharedTreeView.d.ts +119 -0
- package/lib/reactSharedTreeView.d.ts.map +1 -0
- package/lib/reactSharedTreeView.js +176 -0
- package/lib/reactSharedTreeView.js.map +1 -0
- package/lib/simpleIdentifier.d.ts +19 -0
- package/lib/simpleIdentifier.d.ts.map +1 -0
- package/lib/simpleIdentifier.js +29 -0
- package/lib/simpleIdentifier.js.map +1 -0
- package/lib/test/propNode.spec.js +120 -0
- package/lib/test/propNode.spec.js.map +1 -0
- package/lib/test/reactSharedTreeView.spec.js +71 -0
- package/lib/test/reactSharedTreeView.spec.js.map +1 -0
- package/lib/test/simpleIdentifier.spec.js +18 -0
- package/lib/test/simpleIdentifier.spec.js.map +1 -0
- package/lib/test/useObservation.spec.js +162 -0
- package/lib/test/useObservation.spec.js.map +1 -0
- package/lib/test/useTree.spec.js +165 -0
- package/lib/test/useTree.spec.js.map +1 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/lib/useObservation.d.ts +83 -0
- package/lib/useObservation.d.ts.map +1 -0
- package/lib/useObservation.js +266 -0
- package/lib/useObservation.js.map +1 -0
- package/lib/useTree.d.ts +80 -0
- package/lib/useTree.d.ts.map +1 -0
- package/lib/useTree.js +105 -0
- package/lib/useTree.js.map +1 -0
- package/package.json +150 -51
- package/react.test-files.tar +0 -0
- package/src/index.ts +42 -7
- package/src/propNode.ts +164 -0
- package/src/reactSharedTreeView.tsx +327 -0
- package/src/simpleIdentifier.ts +31 -0
- package/src/useObservation.ts +376 -0
- package/src/useTree.ts +147 -0
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +12 -15
- package/tsdoc.json +4 -0
- package/.eslintrc.js +0 -11
- package/dist/createContextFluid.d.ts +0 -7
- package/dist/createContextFluid.d.ts.map +0 -1
- package/dist/createContextFluid.js +0 -46
- package/dist/createContextFluid.js.map +0 -1
- package/dist/helpers/generateFluidObjectSchema.d.ts +0 -16
- package/dist/helpers/generateFluidObjectSchema.d.ts.map +0 -1
- package/dist/helpers/generateFluidObjectSchema.js +0 -75
- package/dist/helpers/generateFluidObjectSchema.js.map +0 -1
- package/dist/helpers/getFluidFromView.d.ts +0 -15
- package/dist/helpers/getFluidFromView.d.ts.map +0 -1
- package/dist/helpers/getFluidFromView.js +0 -30
- package/dist/helpers/getFluidFromView.js.map +0 -1
- package/dist/helpers/getFluidState.d.ts +0 -15
- package/dist/helpers/getFluidState.d.ts.map +0 -1
- package/dist/helpers/getFluidState.js +0 -47
- package/dist/helpers/getFluidState.js.map +0 -1
- package/dist/helpers/getSchema.d.ts +0 -13
- package/dist/helpers/getSchema.d.ts.map +0 -1
- package/dist/helpers/getSchema.js +0 -15
- package/dist/helpers/getSchema.js.map +0 -1
- package/dist/helpers/getViewFromFluid.d.ts +0 -18
- package/dist/helpers/getViewFromFluid.d.ts.map +0 -1
- package/dist/helpers/getViewFromFluid.js +0 -47
- package/dist/helpers/getViewFromFluid.js.map +0 -1
- package/dist/helpers/index.d.ts +0 -16
- package/dist/helpers/index.d.ts.map +0 -1
- package/dist/helpers/index.js +0 -28
- package/dist/helpers/index.js.map +0 -1
- package/dist/helpers/initializeState.d.ts +0 -22
- package/dist/helpers/initializeState.d.ts.map +0 -1
- package/dist/helpers/initializeState.js +0 -77
- package/dist/helpers/initializeState.js.map +0 -1
- package/dist/helpers/internalInterface.d.ts +0 -15
- package/dist/helpers/internalInterface.d.ts.map +0 -1
- package/dist/helpers/internalInterface.js +0 -7
- package/dist/helpers/internalInterface.js.map +0 -1
- package/dist/helpers/rootCallbackListener.d.ts +0 -24
- package/dist/helpers/rootCallbackListener.d.ts.map +0 -1
- package/dist/helpers/rootCallbackListener.js +0 -55
- package/dist/helpers/rootCallbackListener.js.map +0 -1
- package/dist/helpers/setComponentSchema.d.ts +0 -14
- package/dist/helpers/setComponentSchema.d.ts.map +0 -1
- package/dist/helpers/setComponentSchema.js +0 -18
- package/dist/helpers/setComponentSchema.js.map +0 -1
- package/dist/helpers/setFluidState.d.ts +0 -20
- package/dist/helpers/setFluidState.d.ts.map +0 -1
- package/dist/helpers/setFluidState.js +0 -94
- package/dist/helpers/setFluidState.js.map +0 -1
- package/dist/helpers/syncState.d.ts +0 -25
- package/dist/helpers/syncState.d.ts.map +0 -1
- package/dist/helpers/syncState.js +0 -98
- package/dist/helpers/syncState.js.map +0 -1
- package/dist/helpers/updateStateAndFluidObjectMap.d.ts +0 -29
- package/dist/helpers/updateStateAndFluidObjectMap.d.ts.map +0 -1
- package/dist/helpers/updateStateAndFluidObjectMap.js +0 -30
- package/dist/helpers/updateStateAndFluidObjectMap.js.map +0 -1
- package/dist/helpers/utils.d.ts +0 -12
- package/dist/helpers/utils.d.ts.map +0 -1
- package/dist/helpers/utils.js +0 -74
- package/dist/helpers/utils.js.map +0 -1
- package/dist/interface.d.ts +0 -444
- package/dist/interface.d.ts.map +0 -1
- package/dist/interface.js +0 -18
- package/dist/interface.js.map +0 -1
- package/dist/reactView.d.ts +0 -32
- package/dist/reactView.d.ts.map +0 -1
- package/dist/reactView.js +0 -79
- package/dist/reactView.js.map +0 -1
- package/dist/syncedDataObject.d.ts +0 -80
- package/dist/syncedDataObject.d.ts.map +0 -1
- package/dist/syncedDataObject.js +0 -249
- package/dist/syncedDataObject.js.map +0 -1
- package/dist/syncedObjects/array/fluidSyncedArray.d.ts +0 -11
- package/dist/syncedObjects/array/fluidSyncedArray.d.ts.map +0 -1
- package/dist/syncedObjects/array/fluidSyncedArray.js +0 -78
- package/dist/syncedObjects/array/fluidSyncedArray.js.map +0 -1
- package/dist/syncedObjects/array/index.d.ts +0 -7
- package/dist/syncedObjects/array/index.d.ts.map +0 -1
- package/dist/syncedObjects/array/index.js +0 -19
- package/dist/syncedObjects/array/index.js.map +0 -1
- package/dist/syncedObjects/array/interface.d.ts +0 -33
- package/dist/syncedObjects/array/interface.d.ts.map +0 -1
- package/dist/syncedObjects/array/interface.js +0 -3
- package/dist/syncedObjects/array/interface.js.map +0 -1
- package/dist/syncedObjects/array/syncedArray.d.ts +0 -30
- package/dist/syncedObjects/array/syncedArray.d.ts.map +0 -1
- package/dist/syncedObjects/array/syncedArray.js +0 -42
- package/dist/syncedObjects/array/syncedArray.js.map +0 -1
- package/dist/syncedObjects/counter/fluidSyncedCounter.d.ts +0 -11
- package/dist/syncedObjects/counter/fluidSyncedCounter.d.ts.map +0 -1
- package/dist/syncedObjects/counter/fluidSyncedCounter.js +0 -79
- package/dist/syncedObjects/counter/fluidSyncedCounter.js.map +0 -1
- package/dist/syncedObjects/counter/index.d.ts +0 -7
- package/dist/syncedObjects/counter/index.d.ts.map +0 -1
- package/dist/syncedObjects/counter/index.js +0 -19
- package/dist/syncedObjects/counter/index.js.map +0 -1
- package/dist/syncedObjects/counter/interface.d.ts +0 -32
- package/dist/syncedObjects/counter/interface.d.ts.map +0 -1
- package/dist/syncedObjects/counter/interface.js +0 -3
- package/dist/syncedObjects/counter/interface.js.map +0 -1
- package/dist/syncedObjects/counter/syncedCounter.d.ts +0 -29
- package/dist/syncedObjects/counter/syncedCounter.d.ts.map +0 -1
- package/dist/syncedObjects/counter/syncedCounter.js +0 -36
- package/dist/syncedObjects/counter/syncedCounter.js.map +0 -1
- package/dist/syncedObjects/index.d.ts +0 -9
- package/dist/syncedObjects/index.d.ts.map +0 -1
- package/dist/syncedObjects/index.js +0 -21
- package/dist/syncedObjects/index.js.map +0 -1
- package/dist/syncedObjects/object/index.d.ts +0 -7
- package/dist/syncedObjects/object/index.d.ts.map +0 -1
- package/dist/syncedObjects/object/index.js +0 -19
- package/dist/syncedObjects/object/index.js.map +0 -1
- package/dist/syncedObjects/object/interface.d.ts +0 -13
- package/dist/syncedObjects/object/interface.d.ts.map +0 -1
- package/dist/syncedObjects/object/interface.js +0 -7
- package/dist/syncedObjects/object/interface.js.map +0 -1
- package/dist/syncedObjects/object/syncedObject.d.ts +0 -22
- package/dist/syncedObjects/object/syncedObject.d.ts.map +0 -1
- package/dist/syncedObjects/object/syncedObject.js +0 -46
- package/dist/syncedObjects/object/syncedObject.js.map +0 -1
- package/dist/syncedObjects/string/index.d.ts +0 -7
- package/dist/syncedObjects/string/index.d.ts.map +0 -1
- package/dist/syncedObjects/string/index.js +0 -19
- package/dist/syncedObjects/string/index.js.map +0 -1
- package/dist/syncedObjects/string/interface.d.ts +0 -16
- package/dist/syncedObjects/string/interface.d.ts.map +0 -1
- package/dist/syncedObjects/string/interface.js +0 -7
- package/dist/syncedObjects/string/interface.js.map +0 -1
- package/dist/syncedObjects/string/syncedString.d.ts +0 -25
- package/dist/syncedObjects/string/syncedString.d.ts.map +0 -1
- package/dist/syncedObjects/string/syncedString.js +0 -53
- package/dist/syncedObjects/string/syncedString.js.map +0 -1
- package/dist/useReducerFluid.d.ts +0 -7
- package/dist/useReducerFluid.d.ts.map +0 -1
- package/dist/useReducerFluid.js +0 -219
- package/dist/useReducerFluid.js.map +0 -1
- package/dist/useStateFluid.d.ts +0 -10
- package/dist/useStateFluid.d.ts.map +0 -1
- package/dist/useStateFluid.js +0 -67
- package/dist/useStateFluid.js.map +0 -1
- package/lib/createContextFluid.js +0 -23
- package/lib/createContextFluid.js.map +0 -1
- package/lib/helpers/generateFluidObjectSchema.js +0 -71
- package/lib/helpers/generateFluidObjectSchema.js.map +0 -1
- package/lib/helpers/getFluidFromView.js +0 -26
- package/lib/helpers/getFluidFromView.js.map +0 -1
- package/lib/helpers/getFluidState.js +0 -43
- package/lib/helpers/getFluidState.js.map +0 -1
- package/lib/helpers/getSchema.js +0 -11
- package/lib/helpers/getSchema.js.map +0 -1
- package/lib/helpers/getViewFromFluid.js +0 -43
- package/lib/helpers/getViewFromFluid.js.map +0 -1
- package/lib/helpers/index.js +0 -16
- package/lib/helpers/index.js.map +0 -1
- package/lib/helpers/initializeState.js +0 -73
- package/lib/helpers/initializeState.js.map +0 -1
- package/lib/helpers/internalInterface.js +0 -6
- package/lib/helpers/internalInterface.js.map +0 -1
- package/lib/helpers/rootCallbackListener.js +0 -51
- package/lib/helpers/rootCallbackListener.js.map +0 -1
- package/lib/helpers/setComponentSchema.js +0 -14
- package/lib/helpers/setComponentSchema.js.map +0 -1
- package/lib/helpers/setFluidState.js +0 -90
- package/lib/helpers/setFluidState.js.map +0 -1
- package/lib/helpers/syncState.js +0 -94
- package/lib/helpers/syncState.js.map +0 -1
- package/lib/helpers/updateStateAndFluidObjectMap.js +0 -26
- package/lib/helpers/updateStateAndFluidObjectMap.js.map +0 -1
- package/lib/helpers/utils.js +0 -67
- package/lib/helpers/utils.js.map +0 -1
- package/lib/interface.js +0 -8
- package/lib/interface.js.map +0 -1
- package/lib/reactView.js +0 -56
- package/lib/reactView.js.map +0 -1
- package/lib/syncedDataObject.js +0 -245
- package/lib/syncedDataObject.js.map +0 -1
- package/lib/syncedObjects/array/fluidSyncedArray.js +0 -72
- package/lib/syncedObjects/array/fluidSyncedArray.js.map +0 -1
- package/lib/syncedObjects/array/index.js +0 -7
- package/lib/syncedObjects/array/index.js.map +0 -1
- package/lib/syncedObjects/array/interface.js +0 -2
- package/lib/syncedObjects/array/interface.js.map +0 -1
- package/lib/syncedObjects/array/syncedArray.js +0 -37
- package/lib/syncedObjects/array/syncedArray.js.map +0 -1
- package/lib/syncedObjects/counter/fluidSyncedCounter.js +0 -73
- package/lib/syncedObjects/counter/fluidSyncedCounter.js.map +0 -1
- package/lib/syncedObjects/counter/index.js +0 -7
- package/lib/syncedObjects/counter/index.js.map +0 -1
- package/lib/syncedObjects/counter/interface.js +0 -2
- package/lib/syncedObjects/counter/interface.js.map +0 -1
- package/lib/syncedObjects/counter/syncedCounter.js +0 -31
- package/lib/syncedObjects/counter/syncedCounter.js.map +0 -1
- package/lib/syncedObjects/index.js +0 -9
- package/lib/syncedObjects/index.js.map +0 -1
- package/lib/syncedObjects/object/index.js +0 -7
- package/lib/syncedObjects/object/index.js.map +0 -1
- package/lib/syncedObjects/object/interface.js +0 -6
- package/lib/syncedObjects/object/interface.js.map +0 -1
- package/lib/syncedObjects/object/syncedObject.js +0 -41
- package/lib/syncedObjects/object/syncedObject.js.map +0 -1
- package/lib/syncedObjects/string/index.js +0 -7
- package/lib/syncedObjects/string/index.js.map +0 -1
- package/lib/syncedObjects/string/interface.js +0 -6
- package/lib/syncedObjects/string/interface.js.map +0 -1
- package/lib/syncedObjects/string/syncedString.js +0 -48
- package/lib/syncedObjects/string/syncedString.js.map +0 -1
- package/lib/useReducerFluid.js +0 -196
- package/lib/useReducerFluid.js.map +0 -1
- package/lib/useStateFluid.js +0 -44
- package/lib/useStateFluid.js.map +0 -1
- package/src/createContextFluid.tsx +0 -33
- package/src/helpers/generateFluidObjectSchema.ts +0 -95
- package/src/helpers/getFluidFromView.ts +0 -38
- package/src/helpers/getFluidState.ts +0 -67
- package/src/helpers/getSchema.ts +0 -18
- package/src/helpers/getViewFromFluid.ts +0 -68
- package/src/helpers/index.tsx +0 -16
- package/src/helpers/initializeState.ts +0 -162
- package/src/helpers/internalInterface.ts +0 -16
- package/src/helpers/rootCallbackListener.ts +0 -104
- package/src/helpers/setComponentSchema.ts +0 -21
- package/src/helpers/setFluidState.ts +0 -116
- package/src/helpers/syncState.ts +0 -159
- package/src/helpers/updateStateAndFluidObjectMap.ts +0 -85
- package/src/helpers/utils.tsx +0 -109
- package/src/interface.ts +0 -617
- package/src/reactView.tsx +0 -108
- package/src/syncedDataObject.ts +0 -337
- package/src/syncedObjects/array/fluidSyncedArray.ts +0 -126
- package/src/syncedObjects/array/index.ts +0 -7
- package/src/syncedObjects/array/interface.ts +0 -45
- package/src/syncedObjects/array/syncedArray.ts +0 -65
- package/src/syncedObjects/counter/fluidSyncedCounter.ts +0 -122
- package/src/syncedObjects/counter/index.ts +0 -7
- package/src/syncedObjects/counter/interface.ts +0 -44
- package/src/syncedObjects/counter/syncedCounter.ts +0 -64
- package/src/syncedObjects/index.ts +0 -9
- package/src/syncedObjects/object/index.ts +0 -7
- package/src/syncedObjects/object/interface.ts +0 -14
- package/src/syncedObjects/object/syncedObject.ts +0 -55
- package/src/syncedObjects/string/index.ts +0 -7
- package/src/syncedObjects/string/interface.ts +0 -17
- package/src/syncedObjects/string/syncedString.ts +0 -61
- package/src/useReducerFluid.tsx +0 -436
- package/src/useStateFluid.tsx +0 -84
- package/tsconfig.esnext.json +0 -7
package/dist/interface.d.ts
DELETED
|
@@ -1,444 +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 { IFluidHandle, IFluidLoadable, IFluidObject } from "@fluidframework/core-interfaces";
|
|
8
|
-
import { SyncedDataObject } from "./syncedDataObject";
|
|
9
|
-
/**
|
|
10
|
-
* The combined state contains the Fluid and view states and the data props
|
|
11
|
-
* that are passed in to all reducers and selectors
|
|
12
|
-
*/
|
|
13
|
-
export interface ICombinedState<SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps> {
|
|
14
|
-
/**
|
|
15
|
-
* The react view state that will be used for all view renders
|
|
16
|
-
*/
|
|
17
|
-
viewState: SV;
|
|
18
|
-
/**
|
|
19
|
-
* The Fluid state that will be used to update the synced values in the state. This will be
|
|
20
|
-
* undefined until it is initialized, after which the state will update with the defined values
|
|
21
|
-
*/
|
|
22
|
-
fluidState?: SF;
|
|
23
|
-
/**
|
|
24
|
-
* Data props that are loaded in during the Fluid initialization step. This contains the runtime
|
|
25
|
-
* and the Fluid object map, along with any other properties the user wants to pass to reducers
|
|
26
|
-
* and selectors
|
|
27
|
-
*/
|
|
28
|
-
dataProps: C;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* The Fluid schema that is generated on load and will be stored in the synced state
|
|
32
|
-
*/
|
|
33
|
-
export interface IFluidSchema {
|
|
34
|
-
/**
|
|
35
|
-
* (k,v) = (viewKeys, needsFluidConverter)
|
|
36
|
-
*/
|
|
37
|
-
viewMatchingMap: ISharedMap;
|
|
38
|
-
/**
|
|
39
|
-
* (k,v) = (fluidKeys, needsViewConverter)
|
|
40
|
-
*/
|
|
41
|
-
fluidMatchingMap: ISharedMap;
|
|
42
|
-
/**
|
|
43
|
-
* (k,v) = (path, handle)
|
|
44
|
-
*/
|
|
45
|
-
storedHandleMap: ISharedMap;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* A map of the view state values that need conversion to their Fluid state counterparts and the
|
|
49
|
-
* respective converters
|
|
50
|
-
*/
|
|
51
|
-
export declare type ViewToFluidMap<SV, SF> = Map<keyof SV, IFluidConverter<SV, SF>>;
|
|
52
|
-
/**
|
|
53
|
-
* A map of the Fluid state values that need conversion to their view state counterparts and the
|
|
54
|
-
* respective converters
|
|
55
|
-
*/
|
|
56
|
-
export declare type FluidToViewMap<SV, SF> = Map<keyof SF, IViewConverter<SV, SF>>;
|
|
57
|
-
/**
|
|
58
|
-
* The Fluid reducer, containing an object that is keyed by function name and contains state update and
|
|
59
|
-
* effect functions. Each function will have the view state, fluid state, and data props passed into it
|
|
60
|
-
* as parameters in the combined state. State update functions are used to modify values on the state and return
|
|
61
|
-
* the updated state and any new Fluid object handles. Effect functions use values on the state to apply changes
|
|
62
|
-
* elsewhere. They do not return any new objects or state.
|
|
63
|
-
*/
|
|
64
|
-
export interface IFluidReducer<SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps> {
|
|
65
|
-
[key: string]: FluidAsyncStateUpdateFunction<SV, SF, C> | FluidStateUpdateFunction<SV, SF, C> | FluidEffectFunction<SV, SF, C> | FluidAsyncEffectFunction<SV, SF, C>;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* The Fluid selector, containing an object that is keyed by function name and contains selector
|
|
69
|
-
* functions. Each function will have the view state, fluid state, and data props passed into it
|
|
70
|
-
* as parameters in the combined state. Selector functions can also optionally pass in a
|
|
71
|
-
* handle to fetch from the Fluid object map.
|
|
72
|
-
* Selector functions are used to retrieve Fluid objects or parameters from other Fluid objects.
|
|
73
|
-
* It offers a way to fetch these values and return them to the view, with the
|
|
74
|
-
* Fluid object map being updated if the view requires a Fluid object that hasn't been locally loaded yet
|
|
75
|
-
*/
|
|
76
|
-
export interface IFluidSelector<SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps> {
|
|
77
|
-
[key: string]: FluidSelectorFunction<SV, SF, C> | FluidObjectSelectorFunction<SV, SF, C>;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Props passed in to create a FluidReactView or passed in to the useStateFluid hook
|
|
81
|
-
*/
|
|
82
|
-
export interface IFluidProps<SV extends IViewState, SF extends IFluidState> {
|
|
83
|
-
/**
|
|
84
|
-
* Unique ID to use for storing the synced state in the SyncedDataObject's syncedState SharedMap
|
|
85
|
-
*/
|
|
86
|
-
syncedStateId: string;
|
|
87
|
-
/**
|
|
88
|
-
* An instance of the SyncedDataObject that this view will be rendered in
|
|
89
|
-
*/
|
|
90
|
-
syncedDataObject: SyncedDataObject;
|
|
91
|
-
/**
|
|
92
|
-
* Data props containing the Fluid object map and the runtime
|
|
93
|
-
* Optional as the above two will be passed by default. This only need to be defined
|
|
94
|
-
* if there are additional values from the Fluid object lifecycle that need to be made
|
|
95
|
-
* available to the reducers
|
|
96
|
-
*/
|
|
97
|
-
dataProps?: IFluidDataProps;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* View converters to take the synced state Fluid value that they are keyed against in the FluidToView map
|
|
101
|
-
* and convert them into their view state counterparts
|
|
102
|
-
*/
|
|
103
|
-
export interface IViewConverter<SV extends IViewState, SF extends IFluidState> {
|
|
104
|
-
/**
|
|
105
|
-
* The type of object this key in the Fluid state holds
|
|
106
|
-
*/
|
|
107
|
-
type: string;
|
|
108
|
-
/**
|
|
109
|
-
* The corresponding value key within the view state type
|
|
110
|
-
*/
|
|
111
|
-
viewKey: keyof SV;
|
|
112
|
-
/**
|
|
113
|
-
* A callback that takes in the partial Fluid state containing the value that
|
|
114
|
-
* this converter maps to, and returns the corresponding partial view state
|
|
115
|
-
*/
|
|
116
|
-
viewConverter?: (viewState: SV, fluidState: Partial<SF>, fluidObjectMap: FluidObjectMap) => Partial<SV>;
|
|
117
|
-
/**
|
|
118
|
-
* If this is a fluid DDS SharedObject type (i.e. SharedCounter, SharedMap), supply its create function
|
|
119
|
-
* here and add any events that it will fire to the listenedEvents param below to trigger state updates
|
|
120
|
-
*/
|
|
121
|
-
sharedObjectCreate?: (runtime: IFluidDataStoreRuntime) => any;
|
|
122
|
-
/**
|
|
123
|
-
* List of events fired on this Fluid object that will trigger a state update
|
|
124
|
-
*/
|
|
125
|
-
listenedEvents?: string[];
|
|
126
|
-
/**
|
|
127
|
-
* If this Fluid object is stored on the Fluid DataObject root under a different key
|
|
128
|
-
* than the name of this Fluid state key within the synced state map,
|
|
129
|
-
* provide the key on the root for this object here. The changes will also
|
|
130
|
-
* reflect under that key if the data needs to be used elsewhere
|
|
131
|
-
*/
|
|
132
|
-
rootKey?: string;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Fluid converters to take the view state value that they are keyed against in the ViewToFluid map
|
|
136
|
-
* and convert them into their synced Fluid state counterparts
|
|
137
|
-
*/
|
|
138
|
-
export interface IFluidConverter<SV extends IViewState, SF extends IFluidState> {
|
|
139
|
-
/**
|
|
140
|
-
* The type of object this key in the view state holds
|
|
141
|
-
*/
|
|
142
|
-
type: string;
|
|
143
|
-
/**
|
|
144
|
-
* The corresponding value within the Fluid state
|
|
145
|
-
*/
|
|
146
|
-
fluidKey: keyof SF;
|
|
147
|
-
/**
|
|
148
|
-
* A callback that takes in the partial view state containing the value that
|
|
149
|
-
* this converter maps to, and optionally returns a value. This value will be automatically set on the synced state
|
|
150
|
-
* under the view key this converter maps to
|
|
151
|
-
*/
|
|
152
|
-
fluidConverter?: (viewState: SV, fluidState: Partial<SF>) => any;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Base interface to extend from for the Fluid state. These values can and should be left
|
|
156
|
-
* undefined when passing in the initial state as they will be used to establish the Fluid state
|
|
157
|
-
*/
|
|
158
|
-
export interface IFluidState {
|
|
159
|
-
/**
|
|
160
|
-
* The unique state ID for this React Fluid view
|
|
161
|
-
*/
|
|
162
|
-
syncedStateId?: string;
|
|
163
|
-
/**
|
|
164
|
-
* Boolean indicating if any DDSes or Fluid objects on this state are being listened on
|
|
165
|
-
* for synced state updates to trigger React state updates
|
|
166
|
-
*/
|
|
167
|
-
isInitialized?: boolean;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Base interface to extend from for the view state.
|
|
171
|
-
* This should be crafted based off of what the view will use from the Fluid state.
|
|
172
|
-
*/
|
|
173
|
-
export interface IViewState extends IFluidState {
|
|
174
|
-
/**
|
|
175
|
-
* The map containing the locally available Fluid objects that have been loaded. If there are
|
|
176
|
-
* any Fluid objects loaded during initialization that the view needs to use,
|
|
177
|
-
* they should be fetched and loaded in here.
|
|
178
|
-
* Any new Fluid objects added through reducers/selectors during the React lifecycle
|
|
179
|
-
* will be automatically added to this map and the state will re-update when they become asynchronously available
|
|
180
|
-
*/
|
|
181
|
-
fluidObjectMap?: FluidObjectMap;
|
|
182
|
-
}
|
|
183
|
-
export declare type IFluidReactState = IFluidState & IViewState;
|
|
184
|
-
export declare const instanceOfIFluidLoadable: (object: any) => object is IFluidLoadable;
|
|
185
|
-
/**
|
|
186
|
-
* The values stored in the Fluid object map
|
|
187
|
-
*/
|
|
188
|
-
export interface IFluidObjectMapItem {
|
|
189
|
-
/**
|
|
190
|
-
* The actual Fluid object that the path this value is keyed against leads to
|
|
191
|
-
*/
|
|
192
|
-
fluidObject?: IFluidObject & IFluidLoadable;
|
|
193
|
-
/**
|
|
194
|
-
* Boolean indicating if we are listening to changes on this Fluid object's synced state to trigger React
|
|
195
|
-
* state updates. Only set if you want custom behavior for adding listeners to your Fluid state
|
|
196
|
-
*/
|
|
197
|
-
isListened?: boolean;
|
|
198
|
-
/**
|
|
199
|
-
* List of events fired on this Fluid object that will trigger a state update
|
|
200
|
-
*/
|
|
201
|
-
listenedEvents?: string[];
|
|
202
|
-
/**
|
|
203
|
-
* INTERNAL
|
|
204
|
-
* Does not need to be set
|
|
205
|
-
* Is this a SharedMap that was added as a Fluid React requirement
|
|
206
|
-
*/
|
|
207
|
-
isRuntimeMap?: boolean;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* A map of the Fluid object handle absolute path to the Fluid object
|
|
211
|
-
*/
|
|
212
|
-
export declare type FluidObjectMap = Map<string, IFluidObjectMapItem>;
|
|
213
|
-
/**
|
|
214
|
-
* Base interface to extend from for the data props that will be passed in for reducers and
|
|
215
|
-
* selectors to use to offer inter-Fluid object operability
|
|
216
|
-
*/
|
|
217
|
-
export interface IFluidDataProps {
|
|
218
|
-
/**
|
|
219
|
-
* The Fluid data store runtime passed in from Fluid object initialization
|
|
220
|
-
*/
|
|
221
|
-
runtime: IFluidDataStoreRuntime;
|
|
222
|
-
/**
|
|
223
|
-
* The running map of all the Fluid objects being used to render the React view. This
|
|
224
|
-
* can be view/data Fluid objects, and they will be asynchronously loaded here so that they are,
|
|
225
|
-
* in turn, synchronously available for the view when the state updates after they are fetched
|
|
226
|
-
*/
|
|
227
|
-
fluidObjectMap: FluidObjectMap;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Definition for an effect function used in reducers
|
|
231
|
-
*/
|
|
232
|
-
export interface FluidEffectFunction<SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps> {
|
|
233
|
-
/**
|
|
234
|
-
* The function defined here will take the combined state and apply some
|
|
235
|
-
* logic that does not cause any state update changes
|
|
236
|
-
*/
|
|
237
|
-
function: (oldState?: ICombinedState<SV, SF, C>, ...args: any) => void;
|
|
238
|
-
}
|
|
239
|
-
export declare const instanceOfEffectFunction: <SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps>(object: any) => object is FluidEffectFunction<SV, SF, C>;
|
|
240
|
-
/**
|
|
241
|
-
* Definition for an async effect function used in reducers
|
|
242
|
-
*/
|
|
243
|
-
export interface FluidAsyncEffectFunction<SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps> {
|
|
244
|
-
/**
|
|
245
|
-
* The function defined here will take the combined state and apply some
|
|
246
|
-
* async logic that does not cause any state update changes
|
|
247
|
-
*/
|
|
248
|
-
asyncFunction: (oldState?: ICombinedState<SV, SF, C>, ...args: any) => Promise<void>;
|
|
249
|
-
}
|
|
250
|
-
export declare const instanceOfAsyncEffectFunction: <SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps>(object: any) => object is FluidAsyncEffectFunction<SV, SF, C>;
|
|
251
|
-
/**
|
|
252
|
-
* Definition for a state update function used in reducers
|
|
253
|
-
*/
|
|
254
|
-
export interface FluidStateUpdateFunction<SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps> {
|
|
255
|
-
/**
|
|
256
|
-
* The function defined here will take the combined state and update either
|
|
257
|
-
* the Fluid state, the view state, or both. The new combined state and any new Fluid object
|
|
258
|
-
* handles to load in are returned by the function.
|
|
259
|
-
*/
|
|
260
|
-
function: (oldState?: ICombinedState<SV, SF, C>, ...args: any) => IStateUpdateResult<SV, SF, C>;
|
|
261
|
-
}
|
|
262
|
-
export declare const instanceOfStateUpdateFunction: <SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps>(object: any) => object is FluidStateUpdateFunction<SV, SF, C>;
|
|
263
|
-
/**
|
|
264
|
-
* Definition for an async state update function used in reducers
|
|
265
|
-
*/
|
|
266
|
-
export interface FluidAsyncStateUpdateFunction<SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps> {
|
|
267
|
-
/**
|
|
268
|
-
* The function defined here will take the combined state and update either
|
|
269
|
-
* the Fluid state, the view state, or both in an async manner. The new combined state and any new
|
|
270
|
-
* Fluid object handles to load in will be returned by the function when it finishes.
|
|
271
|
-
*/
|
|
272
|
-
asyncFunction: (oldState?: ICombinedState<SV, SF, C>, ...args: any) => Promise<IStateUpdateResult<SV, SF, C>>;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* The value returned by state update functions.
|
|
276
|
-
*/
|
|
277
|
-
export interface IStateUpdateResult<SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps> {
|
|
278
|
-
/**
|
|
279
|
-
* The new view and Fluid states that were updated by the function
|
|
280
|
-
*/
|
|
281
|
-
state: ICombinedState<SV, SF, C>;
|
|
282
|
-
/**
|
|
283
|
-
* Any new Fluid objects that were added in due this function need to have
|
|
284
|
-
* their corresponding handles passed in so that the object can also be loaded for all other users
|
|
285
|
-
*/
|
|
286
|
-
newFluidHandles?: IFluidHandle[];
|
|
287
|
-
}
|
|
288
|
-
export declare const instanceOfAsyncStateUpdateFunction: <SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps>(object: any) => object is FluidAsyncStateUpdateFunction<SF, SV, C>;
|
|
289
|
-
/**
|
|
290
|
-
* Definition for a selector function used in selectors
|
|
291
|
-
*/
|
|
292
|
-
export interface FluidSelectorFunction<SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps> {
|
|
293
|
-
/**
|
|
294
|
-
* The function defined here will take the combined state and return
|
|
295
|
-
* to the view any values that it needs from other values/Fluid objects that were passed
|
|
296
|
-
* in to the data props on initializing.
|
|
297
|
-
* It will also return any new Fluid handles that will be needed for other users to render the view value
|
|
298
|
-
*/
|
|
299
|
-
function: (state?: ICombinedState<SV, SF, C>) => {
|
|
300
|
-
result: any | undefined;
|
|
301
|
-
newFluidHandles?: IFluidHandle[];
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Definition for a Fluid object selector function used in selectors
|
|
306
|
-
*/
|
|
307
|
-
export interface FluidObjectSelectorFunction<SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps> {
|
|
308
|
-
/**
|
|
309
|
-
* Similar to the FluidSelectorFunction's function but this also takes in a
|
|
310
|
-
* handle if we need to fetch a Fluid object from the fluidObjectMap
|
|
311
|
-
*/
|
|
312
|
-
function: (handle: IFluidHandle<any>, state?: ICombinedState<SV, SF, C>) => {
|
|
313
|
-
result: IFluidObject | undefined;
|
|
314
|
-
newFluidHandles?: IFluidHandle[];
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
export declare const instanceOfSelectorFunction: <SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps>(object: any) => object is FluidSelectorFunction<SV, SF, C>;
|
|
318
|
-
export declare const instanceOfFluidObjectSelectorFunction: <SV extends IViewState, SF extends IFluidState, C extends IFluidDataProps>(object: any) => object is FluidObjectSelectorFunction<SV, SF, C>;
|
|
319
|
-
/**
|
|
320
|
-
* Props passed in to the useReducerFluid hook
|
|
321
|
-
*/
|
|
322
|
-
export interface IFluidReducerProps<SV extends IViewState, SF extends IFluidState, A extends IFluidReducer<SV, SF, C>, B, C extends IFluidDataProps> {
|
|
323
|
-
/**
|
|
324
|
-
* Unique ID to use for storing the view's synced state in the SyncedDataObject's syncedState SharedMap
|
|
325
|
-
*/
|
|
326
|
-
syncedStateId: string;
|
|
327
|
-
/**
|
|
328
|
-
* An instance of the SyncedDataObject that this will be rendered in
|
|
329
|
-
*/
|
|
330
|
-
syncedDataObject: SyncedDataObject;
|
|
331
|
-
/**
|
|
332
|
-
* The Fluid reducer containing all the functions as defined by an extension of the IFluidReducer type.
|
|
333
|
-
* Any mutations to the state, or effects outside of the Fluid object involving the state should be done here.
|
|
334
|
-
*/
|
|
335
|
-
reducer: A;
|
|
336
|
-
/**
|
|
337
|
-
* The Fluid selector containing all the functions as defined by an extension of the IFluidSelector
|
|
338
|
-
* type. Any fetching of new Fluid objects or data from other Fluid objects should be done here.
|
|
339
|
-
*/
|
|
340
|
-
selector: B;
|
|
341
|
-
/**
|
|
342
|
-
* Data props that are loaded in during the Fluid initialization step. This contains the runtime
|
|
343
|
-
* and the Fluid object map
|
|
344
|
-
* TODO: Move data props out as it can be fetched from synced Fluid data object but
|
|
345
|
-
* still needs to be extensible for reducers
|
|
346
|
-
*/
|
|
347
|
-
dataProps?: C;
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Props containing the context that will be passed down through the Fluid context provider to the consumer
|
|
351
|
-
*/
|
|
352
|
-
export interface IFluidContextProps<SV, SF, C> extends IFluidProps<SV, SF> {
|
|
353
|
-
/**
|
|
354
|
-
* The additional data that will be passed through the Fluid context
|
|
355
|
-
*/
|
|
356
|
-
reactContext?: C;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* The state that is available through the react context
|
|
360
|
-
*/
|
|
361
|
-
export interface FluidContextState<SV extends IViewState, C> {
|
|
362
|
-
/**
|
|
363
|
-
* The view state
|
|
364
|
-
*/
|
|
365
|
-
state: SV;
|
|
366
|
-
/**
|
|
367
|
-
* Callback to update the state
|
|
368
|
-
*/
|
|
369
|
-
setState: (state: SV) => void;
|
|
370
|
-
/**
|
|
371
|
-
* The context passed in from the props
|
|
372
|
-
*/
|
|
373
|
-
reactContext: Partial<C>;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* The returned value of createFluidContext
|
|
377
|
-
*/
|
|
378
|
-
export interface FluidContext<SV extends IViewState, C> {
|
|
379
|
-
/**
|
|
380
|
-
* The context provider React component that will give the FluidContextState to
|
|
381
|
-
* its children
|
|
382
|
-
*/
|
|
383
|
-
Provider: React.ProviderExoticComponent<React.ProviderProps<FluidContextState<SV, C>>>;
|
|
384
|
-
/**
|
|
385
|
-
* The context consumer that allows children to use the FluidContextState
|
|
386
|
-
*/
|
|
387
|
-
Consumer: React.Consumer<FluidContextState<SV, C>>;
|
|
388
|
-
/**
|
|
389
|
-
* Callback to get the context
|
|
390
|
-
*/
|
|
391
|
-
usePrimedContext: () => FluidContextState<SV, C>;
|
|
392
|
-
/**
|
|
393
|
-
* The view state
|
|
394
|
-
*/
|
|
395
|
-
state: SV;
|
|
396
|
-
/**
|
|
397
|
-
* Callback to update the state
|
|
398
|
-
*/
|
|
399
|
-
setState: (newState: SV) => void;
|
|
400
|
-
}
|
|
401
|
-
export interface ISyncedStateConfig<SV, SF> {
|
|
402
|
-
/**
|
|
403
|
-
* Unique ID to use for storing the view's synced state in the SyncedDataObject's syncedState SharedMap
|
|
404
|
-
*/
|
|
405
|
-
syncedStateId: string;
|
|
406
|
-
/**
|
|
407
|
-
* The backup default view that any view with this ID will use prior to Fluid state initializing, this can be
|
|
408
|
-
* overridden by the view developer themselves
|
|
409
|
-
*/
|
|
410
|
-
defaultViewState: SV;
|
|
411
|
-
/**
|
|
412
|
-
* A map of the Fluid state values that need conversion to their view state counterparts and the
|
|
413
|
-
* respective converters
|
|
414
|
-
*/
|
|
415
|
-
fluidToView: FluidToViewMap<SV, SF>;
|
|
416
|
-
/**
|
|
417
|
-
* A map of the view state values that need conversion to their Fluid state counterparts and the
|
|
418
|
-
* respective converters
|
|
419
|
-
*/
|
|
420
|
-
viewToFluid?: ViewToFluidMap<SV, SF>;
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* The configurations that define the relationships between Fluid and view states for
|
|
424
|
-
* views that are rendered in a SyncedDataObject
|
|
425
|
-
*/
|
|
426
|
-
export declare type SyncedStateConfig = Map<string, ISyncedStateConfig<any, any>>;
|
|
427
|
-
/**
|
|
428
|
-
* The interface for interacting with the synced state that is stored on a SyncedDataObject
|
|
429
|
-
*/
|
|
430
|
-
export interface ISyncedState {
|
|
431
|
-
/**
|
|
432
|
-
* Set values on the synced state for a syncedStateId as key
|
|
433
|
-
*/
|
|
434
|
-
set: (key: string, value: any) => void;
|
|
435
|
-
/**
|
|
436
|
-
* Get values from the synced state for a syncedStateId as key
|
|
437
|
-
*/
|
|
438
|
-
get: <T>(key: string) => T | undefined;
|
|
439
|
-
/**
|
|
440
|
-
* Add a listener to the synced state using a provided callback
|
|
441
|
-
*/
|
|
442
|
-
addValueChangedListener: (callback: (changed: IValueChanged, local: boolean) => void) => void;
|
|
443
|
-
}
|
|
444
|
-
//# sourceMappingURL=interface.d.ts.map
|
package/dist/interface.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EACH,YAAY,EACZ,cAAc,EACd,YAAY,EACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,cAAc,CAC3B,EAAE,SAAS,UAAU,EACrB,EAAE,SAAS,WAAW,EACtB,CAAC,SAAS,eAAe;IAEzB;;OAEG;IACH,SAAS,EAAE,EAAE,CAAC;IACd;;;OAGG;IACH,UAAU,CAAC,EAAE,EAAE,CAAC;IAChB;;;;OAIG;IACH,SAAS,EAAE,CAAC,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,eAAe,EAAE,UAAU,CAAC;IAC5B;;OAEG;IACH,gBAAgB,EAAE,UAAU,CAAC;IAC7B;;OAEG;IACH,eAAe,EAAE,UAAU,CAAC;CAC/B;AAED;;;GAGG;AACH,oBAAY,cAAc,CAAC,EAAE,EAAE,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AAE5E;;;GAGG;AACH,oBAAY,cAAc,CAAC,EAAE,EAAE,EA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true });
|
|
3
|
-
exports.instanceOfFluidObjectSelectorFunction = exports.instanceOfSelectorFunction = exports.instanceOfAsyncStateUpdateFunction = exports.instanceOfStateUpdateFunction = exports.instanceOfAsyncEffectFunction = exports.instanceOfEffectFunction = exports.instanceOfIFluidLoadable = void 0;
|
|
4
|
-
const instanceOfIFluidLoadable = (object) => object === Object(object) && "IFluidLoadable" in object;
|
|
5
|
-
exports.instanceOfIFluidLoadable = instanceOfIFluidLoadable;
|
|
6
|
-
const instanceOfEffectFunction = (object) => object === Object(object) && "function" in object;
|
|
7
|
-
exports.instanceOfEffectFunction = instanceOfEffectFunction;
|
|
8
|
-
const instanceOfAsyncEffectFunction = (object) => object === Object(object) && "asyncFunction" in object;
|
|
9
|
-
exports.instanceOfAsyncEffectFunction = instanceOfAsyncEffectFunction;
|
|
10
|
-
const instanceOfStateUpdateFunction = (object) => object === Object(object) && "function" in object;
|
|
11
|
-
exports.instanceOfStateUpdateFunction = instanceOfStateUpdateFunction;
|
|
12
|
-
const instanceOfAsyncStateUpdateFunction = (object) => object === Object(object) && "asyncFunction" in object;
|
|
13
|
-
exports.instanceOfAsyncStateUpdateFunction = instanceOfAsyncStateUpdateFunction;
|
|
14
|
-
const instanceOfSelectorFunction = (object) => object === Object(object) && "function" in object;
|
|
15
|
-
exports.instanceOfSelectorFunction = instanceOfSelectorFunction;
|
|
16
|
-
const instanceOfFluidObjectSelectorFunction = (object) => object === Object(object) && "function" in object;
|
|
17
|
-
exports.instanceOfFluidObjectSelectorFunction = instanceOfFluidObjectSelectorFunction;
|
|
18
|
-
//# sourceMappingURL=interface.js.map
|
package/dist/interface.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":";;;AAwOO,MAAM,wBAAwB,GAAG,CACpC,MAAW,EACa,EAAE,CAC1B,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,gBAAgB,IAAI,MAAM,CAAC;AAH/C,QAAA,wBAAwB,4BAGuB;AAgErD,MAAM,wBAAwB,GAAG,CAKpC,MAAW,EAC6B,EAAE,CAC1C,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,IAAI,MAAM,CAAC;AAPzC,QAAA,wBAAwB,4BAOiB;AAoB/C,MAAM,6BAA6B,GAAG,CAKzC,MAAW,EACkC,EAAE,CAC/C,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,eAAe,IAAI,MAAM,CAAC;AAP9C,QAAA,6BAA6B,iCAOiB;AAqBpD,MAAM,6BAA6B,GAAG,CAKzC,MAAW,EACkC,EAAE,CAC/C,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,IAAI,MAAM,CAAC;AAPzC,QAAA,6BAA6B,iCAOY;AAwC/C,MAAM,kCAAkC,GAAG,CAK9C,MAAW,EACuC,EAAE,CACpD,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,eAAe,IAAI,MAAM,CAAC;AAP9C,QAAA,kCAAkC,sCAOY;AA6CpD,MAAM,0BAA0B,GAAG,CAKtC,MAAW,EAC+B,EAAE,CAC5C,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,IAAI,MAAM,CAAC;AAPzC,QAAA,0BAA0B,8BAOe;AAE/C,MAAM,qCAAqC,GAAG,CAKjD,MAAW,EACqC,EAAE,CAClD,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,IAAI,MAAM,CAAC;AAPzC,QAAA,qCAAqC,yCAOI","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { ISharedMap, IValueChanged } from \"@fluidframework/map\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport {\n IFluidHandle,\n IFluidLoadable,\n IFluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { SyncedDataObject } from \"./syncedDataObject\";\n\n/**\n * The combined state contains the Fluid and view states and the data props\n * that are passed in to all reducers and selectors\n */\nexport interface ICombinedState<\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n > {\n /**\n * The react view state that will be used for all view renders\n */\n viewState: SV;\n /**\n * The Fluid state that will be used to update the synced values in the state. This will be\n * undefined until it is initialized, after which the state will update with the defined values\n */\n fluidState?: SF;\n /**\n * Data props that are loaded in during the Fluid initialization step. This contains the runtime\n * and the Fluid object map, along with any other properties the user wants to pass to reducers\n * and selectors\n */\n dataProps: C;\n}\n\n/**\n * The Fluid schema that is generated on load and will be stored in the synced state\n */\nexport interface IFluidSchema {\n /**\n * (k,v) = (viewKeys, needsFluidConverter)\n */\n viewMatchingMap: ISharedMap;\n /**\n * (k,v) = (fluidKeys, needsViewConverter)\n */\n fluidMatchingMap: ISharedMap;\n /**\n * (k,v) = (path, handle)\n */\n storedHandleMap: ISharedMap;\n}\n\n/**\n * A map of the view state values that need conversion to their Fluid state counterparts and the\n * respective converters\n */\nexport type ViewToFluidMap<SV, SF> = Map<keyof SV, IFluidConverter<SV, SF>>;\n\n/**\n * A map of the Fluid state values that need conversion to their view state counterparts and the\n * respective converters\n */\nexport type FluidToViewMap<SV, SF> = Map<keyof SF, IViewConverter<SV, SF>>;\n\n/**\n * The Fluid reducer, containing an object that is keyed by function name and contains state update and\n * effect functions. Each function will have the view state, fluid state, and data props passed into it\n * as parameters in the combined state. State update functions are used to modify values on the state and return\n * the updated state and any new Fluid object handles. Effect functions use values on the state to apply changes\n * elsewhere. They do not return any new objects or state.\n */\nexport interface IFluidReducer<\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n > {\n [key: string]:\n | FluidAsyncStateUpdateFunction<SV, SF, C>\n | FluidStateUpdateFunction<SV, SF, C>\n | FluidEffectFunction<SV, SF, C>\n | FluidAsyncEffectFunction<SV, SF, C>;\n}\n\n/**\n * The Fluid selector, containing an object that is keyed by function name and contains selector\n * functions. Each function will have the view state, fluid state, and data props passed into it\n * as parameters in the combined state. Selector functions can also optionally pass in a\n * handle to fetch from the Fluid object map.\n * Selector functions are used to retrieve Fluid objects or parameters from other Fluid objects.\n * It offers a way to fetch these values and return them to the view, with the\n * Fluid object map being updated if the view requires a Fluid object that hasn't been locally loaded yet\n */\nexport interface IFluidSelector<\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n > {\n [key: string]:\n | FluidSelectorFunction<SV, SF, C>\n | FluidObjectSelectorFunction<SV, SF, C>;\n}\n\n/**\n * Props passed in to create a FluidReactView or passed in to the useStateFluid hook\n */\nexport interface IFluidProps<\n SV extends IViewState,\n SF extends IFluidState\n > {\n /**\n * Unique ID to use for storing the synced state in the SyncedDataObject's syncedState SharedMap\n */\n syncedStateId: string;\n /**\n * An instance of the SyncedDataObject that this view will be rendered in\n */\n syncedDataObject: SyncedDataObject;\n /**\n * Data props containing the Fluid object map and the runtime\n * Optional as the above two will be passed by default. This only need to be defined\n * if there are additional values from the Fluid object lifecycle that need to be made\n * available to the reducers\n */\n dataProps?: IFluidDataProps;\n}\n\n/**\n * View converters to take the synced state Fluid value that they are keyed against in the FluidToView map\n * and convert them into their view state counterparts\n */\nexport interface IViewConverter<\n SV extends IViewState,\n SF extends IFluidState\n > {\n /**\n * The type of object this key in the Fluid state holds\n */\n type: string;\n /**\n * The corresponding value key within the view state type\n */\n viewKey: keyof SV;\n /**\n * A callback that takes in the partial Fluid state containing the value that\n * this converter maps to, and returns the corresponding partial view state\n */\n viewConverter?: (\n viewState: SV,\n fluidState: Partial<SF>,\n fluidObjectMap: FluidObjectMap\n ) => Partial<SV>;\n /**\n * If this is a fluid DDS SharedObject type (i.e. SharedCounter, SharedMap), supply its create function\n * here and add any events that it will fire to the listenedEvents param below to trigger state updates\n */\n sharedObjectCreate?: (runtime: IFluidDataStoreRuntime) => any;\n /**\n * List of events fired on this Fluid object that will trigger a state update\n */\n listenedEvents?: string[];\n /**\n * If this Fluid object is stored on the Fluid DataObject root under a different key\n * than the name of this Fluid state key within the synced state map,\n * provide the key on the root for this object here. The changes will also\n * reflect under that key if the data needs to be used elsewhere\n */\n rootKey?: string;\n}\n\n/**\n * Fluid converters to take the view state value that they are keyed against in the ViewToFluid map\n * and convert them into their synced Fluid state counterparts\n */\nexport interface IFluidConverter<\n SV extends IViewState,\n SF extends IFluidState\n > {\n /**\n * The type of object this key in the view state holds\n */\n type: string;\n /**\n * The corresponding value within the Fluid state\n */\n fluidKey: keyof SF;\n /**\n * A callback that takes in the partial view state containing the value that\n * this converter maps to, and optionally returns a value. This value will be automatically set on the synced state\n * under the view key this converter maps to\n */\n fluidConverter?: (viewState: SV, fluidState: Partial<SF>) => any;\n}\n\n/**\n * Base interface to extend from for the Fluid state. These values can and should be left\n * undefined when passing in the initial state as they will be used to establish the Fluid state\n */\nexport interface IFluidState {\n /**\n * The unique state ID for this React Fluid view\n */\n syncedStateId?: string;\n /**\n * Boolean indicating if any DDSes or Fluid objects on this state are being listened on\n * for synced state updates to trigger React state updates\n */\n isInitialized?: boolean;\n}\n\n/**\n * Base interface to extend from for the view state.\n * This should be crafted based off of what the view will use from the Fluid state.\n */\nexport interface IViewState\n extends IFluidState {\n /**\n * The map containing the locally available Fluid objects that have been loaded. If there are\n * any Fluid objects loaded during initialization that the view needs to use,\n * they should be fetched and loaded in here.\n * Any new Fluid objects added through reducers/selectors during the React lifecycle\n * will be automatically added to this map and the state will re-update when they become asynchronously available\n */\n fluidObjectMap?: FluidObjectMap;\n}\n\nexport type IFluidReactState = IFluidState & IViewState;\n\nexport const instanceOfIFluidLoadable = (\n object: any,\n): object is IFluidLoadable =>\n object === Object(object) && \"IFluidLoadable\" in object;\n\n/**\n * The values stored in the Fluid object map\n */\nexport interface IFluidObjectMapItem {\n /**\n * The actual Fluid object that the path this value is keyed against leads to\n */\n fluidObject?: IFluidObject & IFluidLoadable;\n /**\n * Boolean indicating if we are listening to changes on this Fluid object's synced state to trigger React\n * state updates. Only set if you want custom behavior for adding listeners to your Fluid state\n */\n isListened?: boolean;\n /**\n * List of events fired on this Fluid object that will trigger a state update\n */\n listenedEvents?: string[];\n /**\n * INTERNAL\n * Does not need to be set\n * Is this a SharedMap that was added as a Fluid React requirement\n */\n isRuntimeMap?: boolean;\n}\n\n/**\n * A map of the Fluid object handle absolute path to the Fluid object\n */\nexport type FluidObjectMap = Map<string, IFluidObjectMapItem>;\n\n/**\n * Base interface to extend from for the data props that will be passed in for reducers and\n * selectors to use to offer inter-Fluid object operability\n */\nexport interface IFluidDataProps {\n /**\n * The Fluid data store runtime passed in from Fluid object initialization\n */\n runtime: IFluidDataStoreRuntime;\n /**\n * The running map of all the Fluid objects being used to render the React view. This\n * can be view/data Fluid objects, and they will be asynchronously loaded here so that they are,\n * in turn, synchronously available for the view when the state updates after they are fetched\n */\n fluidObjectMap: FluidObjectMap;\n}\n\n/**\n * Definition for an effect function used in reducers\n */\nexport interface FluidEffectFunction<\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n > {\n /**\n * The function defined here will take the combined state and apply some\n * logic that does not cause any state update changes\n */\n function: (oldState?: ICombinedState<SV, SF, C>, ...args: any) => void;\n}\n\nexport const instanceOfEffectFunction = <\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n>(\n object: any,\n): object is FluidEffectFunction<SV, SF, C> =>\n object === Object(object) && \"function\" in object;\n\n/**\n * Definition for an async effect function used in reducers\n */\nexport interface FluidAsyncEffectFunction<\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n > {\n /**\n * The function defined here will take the combined state and apply some\n * async logic that does not cause any state update changes\n */\n asyncFunction: (\n oldState?: ICombinedState<SV, SF, C>,\n ...args: any\n ) => Promise<void>;\n}\n\nexport const instanceOfAsyncEffectFunction = <\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n>(\n object: any,\n): object is FluidAsyncEffectFunction<SV, SF, C> =>\n object === Object(object) && \"asyncFunction\" in object;\n\n/**\n * Definition for a state update function used in reducers\n */\nexport interface FluidStateUpdateFunction<\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n > {\n /**\n * The function defined here will take the combined state and update either\n * the Fluid state, the view state, or both. The new combined state and any new Fluid object\n * handles to load in are returned by the function.\n */\n function: (\n oldState?: ICombinedState<SV, SF, C>,\n ...args: any\n ) => IStateUpdateResult<SV, SF, C>;\n}\n\nexport const instanceOfStateUpdateFunction = <\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n>(\n object: any,\n): object is FluidStateUpdateFunction<SV, SF, C> =>\n object === Object(object) && \"function\" in object;\n\n/**\n * Definition for an async state update function used in reducers\n */\nexport interface FluidAsyncStateUpdateFunction<\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n > {\n /**\n * The function defined here will take the combined state and update either\n * the Fluid state, the view state, or both in an async manner. The new combined state and any new\n * Fluid object handles to load in will be returned by the function when it finishes.\n */\n asyncFunction: (\n oldState?: ICombinedState<SV, SF, C>,\n ...args: any\n ) => Promise<IStateUpdateResult<SV, SF, C>>;\n}\n\n/**\n * The value returned by state update functions.\n */\nexport interface IStateUpdateResult<\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n > {\n /**\n * The new view and Fluid states that were updated by the function\n */\n state: ICombinedState<SV, SF, C>;\n /**\n * Any new Fluid objects that were added in due this function need to have\n * their corresponding handles passed in so that the object can also be loaded for all other users\n */\n newFluidHandles?: IFluidHandle[];\n}\n\nexport const instanceOfAsyncStateUpdateFunction = <\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n>(\n object: any,\n): object is FluidAsyncStateUpdateFunction<SF, SV, C> =>\n object === Object(object) && \"asyncFunction\" in object;\n\n/**\n * Definition for a selector function used in selectors\n */\nexport interface FluidSelectorFunction<\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n > {\n /**\n * The function defined here will take the combined state and return\n * to the view any values that it needs from other values/Fluid objects that were passed\n * in to the data props on initializing.\n * It will also return any new Fluid handles that will be needed for other users to render the view value\n */\n function: (\n state?: ICombinedState<SV, SF, C>\n ) => {\n result: any | undefined;\n newFluidHandles?: IFluidHandle[];\n };\n}\n\n/**\n * Definition for a Fluid object selector function used in selectors\n */\nexport interface FluidObjectSelectorFunction<\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n > {\n /**\n * Similar to the FluidSelectorFunction's function but this also takes in a\n * handle if we need to fetch a Fluid object from the fluidObjectMap\n */\n function: (\n handle: IFluidHandle<any>,\n state?: ICombinedState<SV, SF, C>,\n ) => {\n result: IFluidObject | undefined;\n newFluidHandles?: IFluidHandle[];\n };\n}\n\nexport const instanceOfSelectorFunction = <\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n>(\n object: any,\n): object is FluidSelectorFunction<SV, SF, C> =>\n object === Object(object) && \"function\" in object;\n\nexport const instanceOfFluidObjectSelectorFunction = <\n SV extends IViewState,\n SF extends IFluidState,\n C extends IFluidDataProps\n>(\n object: any,\n): object is FluidObjectSelectorFunction<SV, SF, C> =>\n object === Object(object) && \"function\" in object;\n\n/**\n * Props passed in to the useReducerFluid hook\n */\nexport interface IFluidReducerProps<\n SV extends IViewState,\n SF extends IFluidState,\n A extends IFluidReducer<SV, SF, C>,\n B,\n C extends IFluidDataProps\n > {\n /**\n * Unique ID to use for storing the view's synced state in the SyncedDataObject's syncedState SharedMap\n */\n syncedStateId: string;\n /**\n * An instance of the SyncedDataObject that this will be rendered in\n */\n syncedDataObject: SyncedDataObject;\n /**\n * The Fluid reducer containing all the functions as defined by an extension of the IFluidReducer type.\n * Any mutations to the state, or effects outside of the Fluid object involving the state should be done here.\n */\n reducer: A;\n /**\n * The Fluid selector containing all the functions as defined by an extension of the IFluidSelector\n * type. Any fetching of new Fluid objects or data from other Fluid objects should be done here.\n */\n selector: B;\n /**\n * Data props that are loaded in during the Fluid initialization step. This contains the runtime\n * and the Fluid object map\n * TODO: Move data props out as it can be fetched from synced Fluid data object but\n * still needs to be extensible for reducers\n */\n dataProps?: C;\n}\n\n/**\n * Props containing the context that will be passed down through the Fluid context provider to the consumer\n */\nexport interface IFluidContextProps<SV, SF, C> extends IFluidProps<SV, SF> {\n /**\n * The additional data that will be passed through the Fluid context\n */\n reactContext?: C;\n}\n\n/**\n * The state that is available through the react context\n */\nexport interface FluidContextState<\n SV extends IViewState,\n C\n > {\n /**\n * The view state\n */\n state: SV;\n /**\n * Callback to update the state\n */\n setState: (state: SV) => void;\n /**\n * The context passed in from the props\n */\n reactContext: Partial<C>;\n}\n\n/**\n * The returned value of createFluidContext\n */\nexport interface FluidContext<\n SV extends IViewState,\n C\n > {\n /**\n * The context provider React component that will give the FluidContextState to\n * its children\n */\n Provider: React.ProviderExoticComponent<\n React.ProviderProps<FluidContextState<SV, C>>\n >;\n /**\n * The context consumer that allows children to use the FluidContextState\n */\n Consumer: React.Consumer<FluidContextState<SV, C>>;\n /**\n * Callback to get the context\n */\n usePrimedContext: () => FluidContextState<SV, C>;\n /**\n * The view state\n */\n state: SV;\n /**\n * Callback to update the state\n */\n setState: (newState: SV) => void;\n}\n\nexport interface ISyncedStateConfig<SV, SF> {\n /**\n * Unique ID to use for storing the view's synced state in the SyncedDataObject's syncedState SharedMap\n */\n syncedStateId: string;\n /**\n * The backup default view that any view with this ID will use prior to Fluid state initializing, this can be\n * overridden by the view developer themselves\n */\n defaultViewState: SV;\n /**\n * A map of the Fluid state values that need conversion to their view state counterparts and the\n * respective converters\n */\n fluidToView: FluidToViewMap<SV, SF>;\n /**\n * A map of the view state values that need conversion to their Fluid state counterparts and the\n * respective converters\n */\n viewToFluid?: ViewToFluidMap<SV, SF>;\n}\n\n/**\n * The configurations that define the relationships between Fluid and view states for\n * views that are rendered in a SyncedDataObject\n */\nexport type SyncedStateConfig = Map<string, ISyncedStateConfig<any, any>>;\n\n/**\n * The interface for interacting with the synced state that is stored on a SyncedDataObject\n */\nexport interface ISyncedState {\n /**\n * Set values on the synced state for a syncedStateId as key\n */\n set: (key: string, value: any) => void;\n /**\n * Get values from the synced state for a syncedStateId as key\n */\n get: <T>(key: string) => T | undefined;\n /**\n * Add a listener to the synced state using a provided callback\n */\n addValueChangedListener: (\n callback: (changed: IValueChanged, local: boolean) => void) => void;\n}\n"]}
|
package/dist/reactView.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
import { IFluidProps, IFluidState, IViewState } from "./interface";
|
|
7
|
-
/**
|
|
8
|
-
* A React view with a synced state, initial props, and a Fluid-to-view state two-way mapping
|
|
9
|
-
*/
|
|
10
|
-
export declare abstract class FluidReactView<SV extends IViewState, SF extends IFluidState> extends React.Component<IFluidProps<SV, SF>, SV> {
|
|
11
|
-
private readonly _syncedStateId;
|
|
12
|
-
private readonly _syncedState;
|
|
13
|
-
private readonly _dataProps;
|
|
14
|
-
private readonly _viewToFluid;
|
|
15
|
-
private readonly _fluidToView;
|
|
16
|
-
constructor(props: IFluidProps<SV, SF>);
|
|
17
|
-
componentDidMount(): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Function to update the state from both synced state updates or local ones. Only updates the synced state
|
|
20
|
-
* on local updates
|
|
21
|
-
* @param newState - the new state to be set
|
|
22
|
-
* @param fromRootUpdate - is this update coming locally or from a synced state value change
|
|
23
|
-
* @param isLocal - should this update be applied only locally
|
|
24
|
-
*/
|
|
25
|
-
private _setState;
|
|
26
|
-
/**
|
|
27
|
-
* Function to update the current state. It overloads the React setState function
|
|
28
|
-
* @param newState - New state to be set both locally and on the synced state
|
|
29
|
-
*/
|
|
30
|
-
setState(newState: SV): void;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=reactView.d.ts.map
|
package/dist/reactView.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactView.d.ts","sourceRoot":"","sources":["../src/reactView.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACH,WAAW,EACX,WAAW,EACX,UAAU,EAKb,MAAM,aAAa,CAAC;AAGrB;;GAEG;AACH,8BAAsB,cAAc,CAAC,EAAE,SAAS,UAAU,EACtD,EAAE,SAAS,WAAW,CAAE,SAAQ,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;IACxE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAC7C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAyC;IACtE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwC;gBACzD,KAAK,EAAE,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC;IAkBzB,iBAAiB;IAY9B;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IA0BjB;;;OAGG;IACI,QAAQ,CAAC,QAAQ,EAAE,EAAE;CAa/B"}
|
package/dist/reactView.js
DELETED
|
@@ -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
|
-
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.FluidReactView = void 0;
|
|
27
|
-
const React = __importStar(require("react"));
|
|
28
|
-
const helpers_1 = require("./helpers");
|
|
29
|
-
/**
|
|
30
|
-
* A React view with a synced state, initial props, and a Fluid-to-view state two-way mapping
|
|
31
|
-
*/
|
|
32
|
-
class FluidReactView extends React.Component {
|
|
33
|
-
constructor(props) {
|
|
34
|
-
super(props);
|
|
35
|
-
const { syncedStateId, syncedDataObject, } = props;
|
|
36
|
-
const config = syncedDataObject.getConfig(syncedStateId);
|
|
37
|
-
if (config === undefined) {
|
|
38
|
-
throw Error(`Failed to find configuration for synced state ID: ${syncedStateId}`);
|
|
39
|
-
}
|
|
40
|
-
this._viewToFluid = config.viewToFluid;
|
|
41
|
-
this._fluidToView = config.fluidToView;
|
|
42
|
-
this._syncedStateId = syncedStateId;
|
|
43
|
-
this._syncedState = syncedDataObject.syncedState;
|
|
44
|
-
this._dataProps = syncedDataObject.dataProps;
|
|
45
|
-
this.state = config.defaultViewState;
|
|
46
|
-
}
|
|
47
|
-
async componentDidMount() {
|
|
48
|
-
await helpers_1.initializeState(this._syncedStateId, this._syncedState, this._dataProps, this.state, this._setState.bind(this), this._fluidToView, this._viewToFluid);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Function to update the state from both synced state updates or local ones. Only updates the synced state
|
|
52
|
-
* on local updates
|
|
53
|
-
* @param newState - the new state to be set
|
|
54
|
-
* @param fromRootUpdate - is this update coming locally or from a synced state value change
|
|
55
|
-
* @param isLocal - should this update be applied only locally
|
|
56
|
-
*/
|
|
57
|
-
_setState(newState, fromRootUpdate, isLocal) {
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
59
|
-
if (isLocal) {
|
|
60
|
-
super.setState(newState);
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
62
|
-
}
|
|
63
|
-
else if (fromRootUpdate) {
|
|
64
|
-
helpers_1.syncState(true, this._syncedStateId, this._syncedState, this._dataProps.runtime, newState, this._setState.bind(this), this._dataProps.fluidObjectMap, this._fluidToView, this._viewToFluid);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
this.setState(newState);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Function to update the current state. It overloads the React setState function
|
|
72
|
-
* @param newState - New state to be set both locally and on the synced state
|
|
73
|
-
*/
|
|
74
|
-
setState(newState) {
|
|
75
|
-
helpers_1.syncState(false, this._syncedStateId, this._syncedState, this._dataProps.runtime, newState, this._setState.bind(this), this._dataProps.fluidObjectMap, this._fluidToView, this._viewToFluid);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.FluidReactView = FluidReactView;
|
|
79
|
-
//# sourceMappingURL=reactView.js.map
|