/*! * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Microsoft Live Share SDK License. */ import { IFluidContainer, LoadableObjectClassRecord } from "fluid-framework"; import React from "react"; import { AzureClientProps, AzureContainerServices } from "@fluidframework/azure-client"; import { IAzureContainerResults } from "../types"; import { ISharedStateRegistryResponse } from "../shared-hooks"; import { IFluidTurboClient } from "@microsoft/live-share-turbo"; /** * React Context provider values for `` and ``. * * @remarks * To get the latest values, use the {@link useFluidObjectsContext} hook. */ export interface IFluidContext extends ISharedStateRegistryResponse { /** * The Fluid Turbo client used for connecting to the Fluid container. */ clientRef: React.MutableRefObject; /** * Stateful Fluid container. */ container: IFluidContainer | undefined; /** * The Azure container services (e.g., audience). */ services: AzureContainerServices | undefined; /** * A stateful error object that is set if there was an error connecting to the Fluid container. */ joinError: Error | undefined; /** * React callback function to connect to an existing Fluid container. * * @remarks * The results will also be set to their stateful counterparts for `container` and `services`. * * @param containerId the containerId to connect to. * @param initialObjects Optional. initial object schema, which should match that passed to `createContainer()`. * @returns promise that returns a results object once complete (e.g., container, services, etc.) */ getContainer: (containerId: string, initialObjects?: LoadableObjectClassRecord) => Promise; /** * React callback function to create and connect to a new Fluid container. * * @remarks * The results will also be set to their stateful counterparts for `container` and `services`. * * @param initialObjects Optional. The initial object schema to apply to the container. * @param onInitializeContainer Optional. A callback for when the container is first initialized, which is useful for setting default values to objects in `initialObjects`. * @returns promise that returns a results object once complete (e.g., container, services, etc.) */ createContainer: (initialObjects?: LoadableObjectClassRecord, onInitializeContainer?: (container: IFluidContainer) => void) => Promise; } /** * @hidden */ export declare const FluidContext: React.Context; /** * Hook to get the latest React context state for `FluidContext`. * * @remarks * This hook can only be used in a child component of `` or ``. * * @returns current state of `LiveShareContext` */ export declare const useFluidObjectsContext: () => IFluidContext; /** * Prop types for {@link AzureProvider} component. */ export interface IAzureProviderProps { /** * Optional. React children node for the React Context Provider. */ children?: React.ReactNode; /** * Props for initializing a new `AzureClient` instance. */ clientOptions: AzureClientProps; /** * The `containerId` to connect to when {@link joinOnLoad} is true. * * @remarks * If you pass in an `undefined` value when {@link createOnLoad} is true, a new container will be created. */ containerId?: string; /** * Flag to control whether or not a new container should be created on first mount. * * @remarks * If no {@link containerId} is set when the component first mounts, setting this to `true` will automatically create a new container. * This prop does not do anything if you are using `` instead of ``. */ createOnLoad?: boolean; /** * The initial object schema to use when {@link joinOnLoad} or {@link createOnLoad} is true. */ initialObjects?: LoadableObjectClassRecord; /** * Flag to control whether or not to connect to an existing container on first mount. * * @remarks * Setting this to true will connect to the container if {@link containerId} is provided as a prop. */ joinOnLoad?: boolean; } /** * React Context provider component for using Fluid data objects & joining/creating a Fluid document `AzureClient`. */ export declare const AzureProvider: React.FC; //# sourceMappingURL=AzureProvider.d.ts.map