@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/README.md
CHANGED
|
@@ -1,300 +1,149 @@
|
|
|
1
1
|
# @fluidframework/react
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Examples on how to use all of the different tools in this package can be found in the [clicker-react](../../../examples/data-objects/clicker-react) and [`likes-and-comments`](../../../examples/data-objects/likes-and-comments) folders under `./examples/data-object/` from the Fluid Framework repo root.
|
|
6
|
-
|
|
7
|
-
A good general order of operations to follow when writing a `SyncedDataObject` implementation is the following:
|
|
8
|
-
1. Define the DDSes needed in the `SyncedDataObject`constructor. This can be done using the `set*Config` functions.
|
|
9
|
-
2. Fill in the `render(element: HTMLElement)` function with a call to `ReactDOM.render` and pass in a React view.
|
|
10
|
-
3. Build out the React view either using the `FluidReactView` class or as a functional view using the various hooks that are available.
|
|
11
|
-
|
|
12
|
-
## SyncedDataObject
|
|
13
|
-
|
|
14
|
-
The ['SyncedDataObject'](./src/syncedDataObject.ts) is an extension of the Fluid `DataObject` class provided by the `@fluidframework/aqueduct` package. This will be the base class that users developing Fluid objects with React views will want to extend.
|
|
15
|
-
|
|
16
|
-
The `SyncedDataObject` essentially acts as the data store for the React app that is rendered within it. It provides a configuration where we can set up the schema for our data store, and also guarantees that all the values defined in the configuration will be automatically initialized prior to the view rendering. It also ensures that all updates that were made in the data store for that session will be automatically restored when the app is loaded fresh again by another client for that session. Finally, and most importantly, it guarantees that all updates that are made in the data store are synced live with all other clients that are currently viewing this React app in the current session, without requiring event listeners or component lifecycle methods.
|
|
17
|
-
|
|
18
|
-
`SyncedDataObject` uses the same factory as `DataObject`. However, in addition, it also provides the following functionality:
|
|
19
|
-
|
|
20
|
-
- A `syncedStateConfig` where users can define the different types of values that they would like to see prepared for their view to consume. Values defined here are guaranteed to be initialized and available prior to `render` being called. Here, users can assign the DDSes that their React views will need by using the pre-built helper functions available to them from the `syncedObjects` folder, i.e. `setSyncedStringConfig`, `setSyncedArrayConfig`, etc. or they can manually define their own unique configuration with `this.setConfig`. Each value set on the config will have its own `syncedStateId` which we will use to refer to the prepared value from the view.
|
|
21
|
-
|
|
22
|
-
- An implementation of `IFluidHTMLView` where users fill in the `render` function and the `IFluidHTMLView` interface is already fulfilled without any further code. The React view used in the `render` function should pass in the synced data object for the view to use.
|
|
23
|
-
|
|
24
|
-
- A `fluidObjectMap` that guarantees that all Fluid DDSes/objects used by this `SyncedDataObject` will be automatically created and loaded without the need for component lifecycle methods such as `initializeStateFirstTime` and `initializeStateFromExisting`
|
|
25
|
-
|
|
26
|
-
#### SyncedDataObject Example
|
|
27
|
-
|
|
28
|
-
```jsx
|
|
29
|
-
export class LikesAndComments extends SyncedDataObject {
|
|
30
|
-
constructor(props) {
|
|
31
|
-
super(props);
|
|
32
|
-
// Adds a synced counter to config under ID 'likes'
|
|
33
|
-
setSyncedCounterConfig(
|
|
34
|
-
this,
|
|
35
|
-
"likes",
|
|
36
|
-
);
|
|
37
|
-
// Adds a synced array to config under ID 'comments'
|
|
38
|
-
setSyncedArrayConfig<IComment>(
|
|
39
|
-
this,
|
|
40
|
-
"comments",
|
|
41
|
-
);
|
|
42
|
-
// Adds a synced string to config under ID 'imgUrl'
|
|
43
|
-
setSyncedStringConfig(
|
|
44
|
-
this,
|
|
45
|
-
"imgUrl",
|
|
46
|
-
defaultImgUrl,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Renders the React view
|
|
51
|
-
public render(div: HTMLElement) {
|
|
52
|
-
ReactDOM.render(
|
|
53
|
-
<div>
|
|
54
|
-
<LikesAndCommentsView
|
|
55
|
-
syncedDataObject={this}
|
|
56
|
-
/>
|
|
57
|
-
</div>,
|
|
58
|
-
div,
|
|
59
|
-
);
|
|
60
|
-
return div;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
```
|
|
3
|
+
Utilities for integrating content powered by the Fluid Framework into [React](https://react.dev/) applications.
|
|
64
4
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
The [synced Objects folder](./src/syncedObjects) contains a collection of setSynced\*Config helper function and useSynced\* hook pairings. These functions allow you to easily start using the DDSes that were prepared in the `syncedDataObject`. Since these are all wrappers around the `React.useState` hook, with added syncing functionality, simply calling these functions using regular React hook rules will automatically convert the function into a React functional view.
|
|
68
|
-
|
|
69
|
-
Each of these helper & hook pairings take a Fluid DDS and binds them to the `syncedDataObject` under the unique `syncedStateId`. This ensures that any changes that happen on these DDSes see synced updates show up live on all connected React views.
|
|
70
|
-
|
|
71
|
-
A single `syncedDataObject` can hold multiple different types of DDSes and other `DataObjects` under different `syncedStateIds`. However, each unique ID is exclusive to the type of value that is set there when using the helper & hook pairs.
|
|
72
|
-
|
|
73
|
-
The current roster of available helper & hook pairs for different DDSes are:
|
|
74
|
-
- For just setting type T objects on a `SharedMap` -> `useSyncedObject<T>` & `setSyncedObjectConfig<T>`
|
|
75
|
-
- `SharedCounter` -> `useSyncedCounter` & `setSyncedCounterConfig`
|
|
76
|
-
- `SharedObjectSequence` -> `useSyncedArray<T>` & `setSyncedArrayConfig`
|
|
77
|
-
- `SharedString` -> `useSyncedString` & `setSyncedStringConfig`
|
|
78
|
-
|
|
79
|
-
NOTE: IT IS IMPORTANT TO PICK THE RIGHT DDS.
|
|
80
|
-
|
|
81
|
-
While it may be tempting to use `useSyncedObject` for any type T object, a SharedMap has different syncing logic from a SharedString, SharedObjectSequence, etc. Therefore, passing a string to be set on a SharedMap is not the same as using a SharedString. The latter contains additional logic that allows people to, for example, type on the same word together without overwriting one another's characters. Please use `useSyncedString` for these scenarios. The SharedMap, on the other hand, is useful for having a distributed dictionary of items that are always in sync based on the values being set on the map.
|
|
82
|
-
|
|
83
|
-
### syncedObject Hooks Example
|
|
84
|
-
|
|
85
|
-
This example provides the view for the `syncedDataObject` in the example above.
|
|
86
|
-
|
|
87
|
-
```jsx
|
|
88
|
-
function LikesAndCommentsView(
|
|
89
|
-
props: ILikesAndCommentsViewProps,
|
|
90
|
-
) {
|
|
91
|
-
// Use the synced states that were prepared on our syncedDataObject above using the setSynced*Config helper functions. Note that the useSynced* function and the ID passed in correspond to the how the config was set above. These values are guaranteed to be available in the view
|
|
92
|
-
const [likes, likesReducer] = useSyncedCounter(props.syncedDataObject, "likes");
|
|
93
|
-
const [comments, commentReducer] = useSyncedArray<IComment>(props.syncedDataObject, "comments");
|
|
94
|
-
const [imgUrl, setImgUrl] = useSyncedString(props.syncedDataObject,"imgUrl");
|
|
95
|
-
|
|
96
|
-
// Use local state for the comment as we don't want it to be synced until it is submitted
|
|
97
|
-
const [currentComment, setCurrentComment] = React.useState("");
|
|
98
|
-
|
|
99
|
-
// The remaining code is for rendering the React view elements themselves
|
|
100
|
-
|
|
101
|
-
// Convert data to JSX for comments state
|
|
102
|
-
const commentListItems = comments.map((item, key) => (
|
|
103
|
-
<li key={key}>
|
|
104
|
-
{`${item.author}: ${item.message}`}
|
|
105
|
-
</li>
|
|
106
|
-
));
|
|
107
|
-
|
|
108
|
-
// Render
|
|
109
|
-
return (
|
|
110
|
-
<div>
|
|
111
|
-
<div>
|
|
112
|
-
<img width='100%' src={imgUrl?.getText()}/>
|
|
113
|
-
{imgUrl !== undefined
|
|
114
|
-
? <CollaborativeInput
|
|
115
|
-
style={{ width: "90%" }}
|
|
116
|
-
sharedString={imgUrl}
|
|
117
|
-
onInput={(value: SharedString) => setImgUrl({ value })}
|
|
118
|
-
/>
|
|
119
|
-
: undefined}
|
|
120
|
-
</div>
|
|
121
|
-
<span>
|
|
122
|
-
{`Likes: ${likes}`}
|
|
123
|
-
</span>
|
|
124
|
-
<button onClick={() => likesReducer.increment(1)}>
|
|
125
|
-
{"+"}
|
|
126
|
-
</button>
|
|
127
|
-
<div>
|
|
128
|
-
<div>
|
|
129
|
-
<input
|
|
130
|
-
type="text"
|
|
131
|
-
value={currentComment}
|
|
132
|
-
onChange={(e) => setCurrentComment(e.target.value)}
|
|
133
|
-
placeholder="Add Comment"
|
|
134
|
-
/>
|
|
135
|
-
<button
|
|
136
|
-
onClick={() => {
|
|
137
|
-
commentReducer.add({
|
|
138
|
-
message: currentComment,
|
|
139
|
-
author: getAuthorName(props.syncedDataObject),
|
|
140
|
-
});
|
|
141
|
-
setCurrentComment("");
|
|
142
|
-
}}
|
|
143
|
-
>{"Submit"}</button>
|
|
144
|
-
</div>
|
|
145
|
-
<ul>{commentListItems}</ul>
|
|
146
|
-
</div>
|
|
147
|
-
</div>
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
```
|
|
5
|
+
This package currently has some experimental APIs focused on integrating SharedTree content into React.
|
|
151
6
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
I.e. for the example above,
|
|
155
|
-
```jsx
|
|
156
|
-
// ----- FACTORY SETUP -----
|
|
157
|
-
export const LikesAndCommentsInstantiationFactory = new DataObjectFactory(
|
|
158
|
-
"likes-and-comments",
|
|
159
|
-
LikesAndComments,
|
|
160
|
-
[
|
|
161
|
-
SharedCounter.getFactory(),
|
|
162
|
-
SharedObjectSequence.getFactory(),
|
|
163
|
-
SharedString.getFactory(),
|
|
164
|
-
],
|
|
165
|
-
{},
|
|
166
|
-
);
|
|
167
|
-
export const fluidExport = LikesAndCommentsInstantiationFactory;
|
|
168
|
-
```
|
|
7
|
+
## Known Issues and Limitations
|
|
169
8
|
|
|
170
|
-
These
|
|
171
|
-
|
|
172
|
-
## FluidReactView
|
|
173
|
-
|
|
174
|
-
This is the base level `FluidReactView` that offers a synced view state and a mapping between the view and synced state stored in the root. It allows users to set up their own unique relationships between the Fluid state, which is the data state that is being synced, and the view state, which extracts the synced data from the Fluid state in a format that is ready for consumption in the view. In many cases, these the Fluid and view state can be identical but, in more complex scenarios, it may be beneficial to have a cleaner view state that picks out the relevant values needed for the view from the Fluid state.
|
|
175
|
-
|
|
176
|
-
To see an example of this, please take a look at the `@fluid-example/clicker-react` example. If we take a look at this example in parts, we can see how the `SyncedDataObject` that houses the view aligns with the `FluidReactView` that is rendered.
|
|
177
|
-
|
|
178
|
-
Looking at the constructor, we see that a configuration is created under ID `clicker` containing a SharedCounter:
|
|
179
|
-
```jsx
|
|
180
|
-
constructor(props) {
|
|
181
|
-
super(props);
|
|
182
|
-
// Mark the counter value in the state as a SharedCounter type and pass in its create function
|
|
183
|
-
// so that it will be created on the first run and be available on our React state
|
|
184
|
-
// We also mark the "incremented" event as we want to update the React state when the counter
|
|
185
|
-
// is incremented to display the new value
|
|
186
|
-
this.setConfig<ICounterState>(
|
|
187
|
-
"clicker",
|
|
188
|
-
{
|
|
189
|
-
syncedStateId: "clicker",
|
|
190
|
-
fluidToView: new Map([
|
|
191
|
-
[
|
|
192
|
-
"counter", {
|
|
193
|
-
type: SharedCounter.name,
|
|
194
|
-
viewKey: "counter",
|
|
195
|
-
sharedObjectCreate: SharedCounter.create,
|
|
196
|
-
listenedEvents: ["incremented"],
|
|
197
|
-
},
|
|
198
|
-
],
|
|
199
|
-
]),
|
|
200
|
-
defaultViewState: {},
|
|
201
|
-
},
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
```
|
|
9
|
+
These are a mix of issues that were encountered when authoring this package, as well as limitations of this package.
|
|
205
10
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
```jsx
|
|
209
|
-
this.setConfig<ICounterState>(
|
|
210
|
-
"clicker",
|
|
211
|
-
{
|
|
212
|
-
syncedStateId: "clicker",
|
|
213
|
-
fluidToView: new Map([
|
|
214
|
-
[
|
|
215
|
-
"counter", {
|
|
216
|
-
type: SharedCounter.name,
|
|
217
|
-
viewKey: "counter",
|
|
218
|
-
sharedObjectCreate: SharedCounter.create,
|
|
219
|
-
listenedEvents: ["incremented"],
|
|
220
|
-
},
|
|
221
|
-
"counter2", {
|
|
222
|
-
type: SharedCounter.name,
|
|
223
|
-
viewKey: "counter2",
|
|
224
|
-
sharedObjectCreate: SharedCounter.create,
|
|
225
|
-
listenedEvents: ["incremented"],
|
|
226
|
-
},
|
|
227
|
-
],
|
|
228
|
-
]),
|
|
229
|
-
defaultViewState: {},
|
|
230
|
-
},
|
|
231
|
-
);
|
|
232
|
-
```
|
|
11
|
+
Some of this logic would be useful for non-react applications: to avoid creating even more septate packages, that logic is not split into its own package.
|
|
12
|
+
If there is clear demand for this to be done, it might be done in the future.
|
|
233
13
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return element;
|
|
245
|
-
}
|
|
246
|
-
```
|
|
14
|
+
There is no service implementation agnostic client abstraction that can be referred to here (ex: shared by TinyliciousClient, AzureClient and OdspClient).
|
|
15
|
+
This makes documenting compatibility with that implicit common API difficult.
|
|
16
|
+
It also makes writing service agnostic code at that abstraction level harder.
|
|
17
|
+
|
|
18
|
+
There does not appear to be a local service implementation of the above mentioned abstraction, which makes testing the code in the package harder.
|
|
19
|
+
|
|
20
|
+
The commonly used boilerplate for setting up a ContainerSchema based application configures the dev-tools,
|
|
21
|
+
but currently can't be included in this package due to dependency layering issues.
|
|
22
|
+
|
|
23
|
+
<!-- AUTO-GENERATED-CONTENT:START (LIBRARY_README_HEADER) -->
|
|
247
24
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
25
|
+
<!-- prettier-ignore-start -->
|
|
26
|
+
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
27
|
+
|
|
28
|
+
## Using Fluid Framework libraries
|
|
29
|
+
|
|
30
|
+
When taking a dependency on a Fluid Framework library's public APIs, we recommend using a `^` (caret) version range, such as `^1.3.4`.
|
|
31
|
+
While Fluid Framework libraries may use different ranges with interdependencies between other Fluid Framework libraries,
|
|
32
|
+
library consumers should always prefer `^`.
|
|
33
|
+
|
|
34
|
+
If using any of Fluid Framework's unstable APIs (for example, its `beta` APIs), we recommend using a more constrained version range, such as `~`.
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
To get started, install the package by running the following command:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm i @fluidframework/react
|
|
268
42
|
```
|
|
269
43
|
|
|
270
|
-
|
|
44
|
+
## Importing from this package
|
|
45
|
+
|
|
46
|
+
This package leverages [package.json exports](https://nodejs.org/api/packages.html#exports) to separate its APIs by support level.
|
|
47
|
+
For more information on the related support guarantees, see [API Support Levels](https://fluidframework.com/docs/build/releases-and-apitags/#api-support-levels).
|
|
48
|
+
|
|
49
|
+
To access the `public` ([SemVer](https://semver.org/)) APIs, import via `@fluidframework/react` like normal.
|
|
50
|
+
|
|
51
|
+
To access the `beta` APIs, import via `@fluidframework/react/beta`.
|
|
52
|
+
|
|
53
|
+
To access the `alpha` APIs, import via `@fluidframework/react/alpha`.
|
|
54
|
+
|
|
55
|
+
## API Documentation
|
|
56
|
+
|
|
57
|
+
API documentation for **@fluidframework/react** is available at <https://fluidframework.com/docs/apis/react>.
|
|
58
|
+
|
|
59
|
+
<!-- prettier-ignore-end -->
|
|
60
|
+
|
|
61
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
62
|
+
|
|
63
|
+
<!-- AUTO-GENERATED-CONTENT:START (README_FOOTER) -->
|
|
64
|
+
|
|
65
|
+
<!-- prettier-ignore-start -->
|
|
66
|
+
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
67
|
+
|
|
68
|
+
## Minimum Client Requirements
|
|
69
|
+
|
|
70
|
+
These are the platform requirements for the current version of Fluid Framework Client Packages.
|
|
71
|
+
These requirements err on the side of being too strict since within a major version they can be relaxed over time, but not made stricter.
|
|
72
|
+
For Long Term Support (LTS) versions this can require supporting these platforms for several years.
|
|
73
|
+
|
|
74
|
+
It is likely that other configurations will work, but they are not supported: if they stop working, we do not consider that a bug.
|
|
75
|
+
If you would benefit from support for something not listed here, file an issue and the product team will evaluate your request.
|
|
76
|
+
When making such a request please include if the configuration already works (and thus the request is just that it becomes officially supported), or if changes are required to get it working.
|
|
77
|
+
|
|
78
|
+
### Supported Runtimes
|
|
79
|
+
|
|
80
|
+
- NodeJs ^20.10.0 except that we will drop support for it [when NodeJs 20 loses its upstream support on 2026-04-30](https://github.com/nodejs/release#release-schedule), and will support a newer LTS version of NodeJS (22) at least 1 year before 20 is end-of-life. This same policy applies to NodeJS 22 when it is end of life (2027-04-30).
|
|
81
|
+
- Running Fluid in a Node.js environment with the `--no-experimental-fetch` flag is not supported.
|
|
82
|
+
- Modern browsers supporting the es2022 standard library: in response to asks we can add explicit support for using babel to polyfill to target specific standards or runtimes (meaning we can avoid/remove use of things that don't polyfill robustly, but otherwise target modern standards).
|
|
83
|
+
|
|
84
|
+
### Supported Tools
|
|
85
|
+
|
|
86
|
+
- TypeScript 5.4:
|
|
87
|
+
- All [`strict`](https://www.typescriptlang.org/tsconfig) options are supported.
|
|
88
|
+
- [`strictNullChecks`](https://www.typescriptlang.org/tsconfig) is required.
|
|
89
|
+
- [Configuration options deprecated in 5.0](https://github.com/microsoft/TypeScript/issues/51909) are not supported.
|
|
90
|
+
- `exactOptionalPropertyTypes` is currently not fully supported.
|
|
91
|
+
If used, narrowing members of Fluid Framework types types using `in`, `Reflect.has`, `Object.hasOwn` or `Object.prototype.hasOwnProperty` should be avoided as they may incorrectly exclude `undefined` from the possible values in some cases.
|
|
92
|
+
- [webpack](https://webpack.js.org/) 5
|
|
93
|
+
- We are not intending to be prescriptive about what bundler to use.
|
|
94
|
+
Other bundlers which can handle ES Modules should work, but webpack is the only one we actively test.
|
|
95
|
+
|
|
96
|
+
### Module Resolution
|
|
97
|
+
|
|
98
|
+
[`Node16`, `NodeNext`, or `Bundler`](https://www.typescriptlang.org/tsconfig#moduleResolution) resolution should be used with TypeScript compilerOptions to follow the [Node.js v12+ ESM Resolution and Loading algorithm](https://nodejs.github.io/nodejs.dev/en/api/v20/esm/#resolution-and-loading-algorithm).
|
|
99
|
+
Node10 resolution is not supported as it does not support Fluid Framework's API structuring pattern that is used to distinguish stable APIs from those that are in development.
|
|
100
|
+
|
|
101
|
+
### Module Formats
|
|
102
|
+
|
|
103
|
+
- ES Modules:
|
|
104
|
+
ES Modules are the preferred way to consume our client packages (including in NodeJs) and consuming our client packages from ES Modules is fully supported.
|
|
105
|
+
- CommonJs:
|
|
106
|
+
Consuming our client packages as CommonJs is supported only in NodeJS and only for the cases listed below.
|
|
107
|
+
This is done to accommodate some workflows without good ES Module support.
|
|
108
|
+
If you have a workflow you would like included in this list, file an issue.
|
|
109
|
+
Once this list of workflows motivating CommonJS support is empty, we may drop support for CommonJS one year after notice of the change is posted here.
|
|
271
110
|
|
|
272
|
-
|
|
111
|
+
- Testing with Jest (which lacks [stable ESM support](https://jestjs.io/docs/ecmascript-modules) due to [unstable APIs in NodeJs](https://github.com/nodejs/node/issues/37648))
|
|
273
112
|
|
|
274
|
-
##
|
|
113
|
+
## Contribution Guidelines
|
|
275
114
|
|
|
276
|
-
|
|
115
|
+
There are many ways to [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid.
|
|
277
116
|
|
|
278
|
-
|
|
117
|
+
- Participate in Q&A in our [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
|
|
118
|
+
- [Submit bugs](https://github.com/microsoft/FluidFramework/issues) and help us verify fixes as they are checked in.
|
|
119
|
+
- Review the [source code changes](https://github.com/microsoft/FluidFramework/pulls).
|
|
120
|
+
- [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
|
|
279
121
|
|
|
280
|
-
|
|
122
|
+
Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/wiki).
|
|
281
123
|
|
|
282
|
-
This
|
|
124
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
125
|
+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
283
126
|
|
|
127
|
+
This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
|
|
128
|
+
Use of these trademarks or logos must follow Microsoft’s [Trademark & Brand Guidelines](https://www.microsoft.com/trademarks).
|
|
129
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
284
130
|
|
|
285
|
-
|
|
131
|
+
## Help
|
|
286
132
|
|
|
133
|
+
Not finding what you're looking for in this README? Check out [fluidframework.com](https://fluidframework.com/docs/).
|
|
287
134
|
|
|
288
|
-
|
|
135
|
+
Still not finding what you're looking for? Please [file an issue](https://github.com/microsoft/FluidFramework/wiki/Submitting-Bugs-and-Feature-Requests).
|
|
289
136
|
|
|
290
|
-
|
|
137
|
+
Thank you!
|
|
291
138
|
|
|
292
|
-
##
|
|
139
|
+
## Trademark
|
|
293
140
|
|
|
294
|
-
This
|
|
141
|
+
This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
|
|
295
142
|
|
|
143
|
+
Use of these trademarks or logos must follow Microsoft's [Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
|
296
144
|
|
|
297
|
-
|
|
145
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
298
146
|
|
|
147
|
+
<!-- prettier-ignore-end -->
|
|
299
148
|
|
|
300
|
-
|
|
149
|
+
<!-- AUTO-GENERATED-CONTENT:END -->
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
|
|
4
|
+
"mainEntryPointFilePath": "<projectFolder>/dist/alpha.d.ts"
|
|
5
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
|
|
4
|
+
"mainEntryPointFilePath": "<projectFolder>/lib/alpha.d.ts"
|
|
5
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
|
|
4
|
+
"mainEntryPointFilePath": "<projectFolder>/dist/beta.d.ts"
|
|
5
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
|
|
4
|
+
"mainEntryPointFilePath": "<projectFolder>/dist/public.d.ts"
|
|
5
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
|
|
4
|
+
"mainEntryPointFilePath": "<projectFolder>/lib/public.d.ts"
|
|
5
|
+
}
|
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "../../../common/build/build-common/api-extractor-base.esm.no-legacy.json"
|
|
4
4
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
## Alpha API Report File for "@fluidframework/react"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
// @alpha @sealed
|
|
8
|
+
export interface IReactTreeDataObject<TSchema extends ImplicitFieldSchema> {
|
|
9
|
+
readonly config: TreeViewConfiguration<TSchema>;
|
|
10
|
+
readonly treeView: TreeView<TSchema>;
|
|
11
|
+
readonly TreeViewComponent: (props: TreeViewProps<TSchema>) => React_2.JSX.Element;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// @alpha @system
|
|
15
|
+
export type IsMappableObjectType<T, True = true, False = false, Mapped = {
|
|
16
|
+
[P in keyof T]: T[P];
|
|
17
|
+
}> = [Mapped] extends [T] ? ([T] extends [Mapped] ? True : False) : False;
|
|
18
|
+
|
|
19
|
+
// @alpha
|
|
20
|
+
export type NodeRecord = Record<string, TreeNode | TreeLeafValue>;
|
|
21
|
+
|
|
22
|
+
// @alpha
|
|
23
|
+
export function objectIdNumber(object: object): number;
|
|
24
|
+
|
|
25
|
+
// @alpha @input
|
|
26
|
+
export interface ObservationOptions {
|
|
27
|
+
onInvalidation?: () => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// @alpha
|
|
31
|
+
export interface PropTreeNode<T extends TreeNode> extends ErasedType<[T, "PropTreeNode"]> {
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// @alpha
|
|
35
|
+
export type PropTreeNodeRecord = Record<string, TreeLeafValue | PropTreeNode<TreeNode> | undefined>;
|
|
36
|
+
|
|
37
|
+
// @alpha
|
|
38
|
+
export type PropTreeValue<T extends TreeNode | TreeLeafValue | undefined> = T extends TreeNode ? PropTreeNode<T> : T;
|
|
39
|
+
|
|
40
|
+
// @alpha
|
|
41
|
+
export interface SchemaIncompatibleProps {
|
|
42
|
+
readonly compatibility: SchemaCompatibilityStatus;
|
|
43
|
+
readonly upgradeSchema: () => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// @alpha
|
|
47
|
+
export function toPropTreeNode<T extends TreeNode | TreeLeafValue>(node: T): PropTreeValue<T>;
|
|
48
|
+
|
|
49
|
+
// @alpha
|
|
50
|
+
export function toPropTreeRecord<T extends NodeRecord>(node: T): WrapPropTreeNodeRecord<T>;
|
|
51
|
+
|
|
52
|
+
// @alpha
|
|
53
|
+
export function treeDataObject<TSchema extends ImplicitFieldSchema>(treeConfiguration: TreeViewConfiguration<TSchema>, createInitialTree: () => InsertableTreeFieldFromImplicitField<TSchema>): SharedObjectKind<IReactTreeDataObject<TSchema> & IFluidLoadable>;
|
|
54
|
+
|
|
55
|
+
// @alpha
|
|
56
|
+
export function TreeViewComponent<TSchema extends ImplicitFieldSchema>({ tree, viewComponent: ViewComponent, errorComponent, }: TreeViewProps<TSchema> & {
|
|
57
|
+
tree: Pick<IReactTreeDataObject<TSchema>, "treeView">;
|
|
58
|
+
}): React_2.JSX.Element;
|
|
59
|
+
|
|
60
|
+
// @alpha @input
|
|
61
|
+
export interface TreeViewProps<TSchema extends ImplicitFieldSchema> {
|
|
62
|
+
readonly errorComponent?: React_2.FC<SchemaIncompatibleProps>;
|
|
63
|
+
readonly viewComponent: React_2.FC<{
|
|
64
|
+
root: PropTreeValue<TreeFieldFromImplicitField<TSchema>>;
|
|
65
|
+
}>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// @alpha
|
|
69
|
+
export type UnwrapPropTreeNode<T extends TreeLeafValue | PropTreeNode<TreeNode> | undefined> = T extends PropTreeNode<infer Node> ? Node : T;
|
|
70
|
+
|
|
71
|
+
// @alpha
|
|
72
|
+
export function unwrapPropTreeNode<T extends TreeNode | TreeLeafValue>(propNode: PropTreeValue<T> | T): T;
|
|
73
|
+
|
|
74
|
+
// @alpha
|
|
75
|
+
export type UnwrapPropTreeNodeRecord<T extends PropTreeNodeRecord> = {
|
|
76
|
+
readonly [P in keyof T]: UnwrapPropTreeNode<T[P]>;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// @alpha
|
|
80
|
+
export function unwrapPropTreeRecord<T extends PropTreeNodeRecord>(props: T): UnwrapPropTreeNodeRecord<T>;
|
|
81
|
+
|
|
82
|
+
// @alpha
|
|
83
|
+
export function usePropTreeNode<T extends TreeNode | TreeLeafValue, TResult>(propNode: PropTreeValue<T> | T, trackDuring: (node: T) => TResult): WrapNodes<TResult>;
|
|
84
|
+
|
|
85
|
+
// @alpha
|
|
86
|
+
export function usePropTreeRecord<const T extends PropTreeNodeRecord, TResult>(props: T, f: (node: UnwrapPropTreeNodeRecord<T>) => TResult): WrapNodes<TResult>;
|
|
87
|
+
|
|
88
|
+
// @alpha
|
|
89
|
+
export function useTree(subtreeRoot: TreeNode): number;
|
|
90
|
+
|
|
91
|
+
// @alpha
|
|
92
|
+
export function useTreeObservations<TResult>(trackDuring: () => TResult, options?: ObservationOptions): TResult;
|
|
93
|
+
|
|
94
|
+
// @alpha
|
|
95
|
+
export function withMemoizedTreeObservations<TIn>(component: React_2.FC<TIn>, options?: ObservationOptions & {
|
|
96
|
+
readonly propsAreEqual?: Parameters<typeof React_2.memo>[1];
|
|
97
|
+
}): React_2.MemoExoticComponent<ReturnType<typeof withTreeObservations<TIn>>>;
|
|
98
|
+
|
|
99
|
+
// @alpha
|
|
100
|
+
export function withTreeObservations<TIn>(component: React_2.FC<TIn>, options?: ObservationOptions): React_2.FC<TIn> & React_2.FC<WrapNodes<TIn>> & React_2.FC<TIn | WrapNodes<TIn>>;
|
|
101
|
+
|
|
102
|
+
// @alpha
|
|
103
|
+
export type WrapNodes<T> = T extends TreeNode ? PropTreeNode<T> : T extends readonly (infer U)[] ? readonly WrapNodes<U>[] : T extends infer U ? IsMappableObjectType<U, {
|
|
104
|
+
[P in keyof U]: WrapNodes<U[P]>;
|
|
105
|
+
} extends U ? U : {
|
|
106
|
+
[P in keyof U]: WrapNodes<U[P]>;
|
|
107
|
+
}, T> : T;
|
|
108
|
+
|
|
109
|
+
// @alpha
|
|
110
|
+
export type WrapPropTreeNodeRecord<T extends NodeRecord> = {
|
|
111
|
+
readonly [P in keyof T]: PropTreeValue<T[P]>;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
```
|
package/biome.jsonc
ADDED