@fluidframework/fluid-static 2.0.0-internal.2.1.1 → 2.0.0-internal.2.2.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.js +1 -1
- package/dist/fluidContainer.d.ts +6 -5
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js.map +1 -1
- package/lib/fluidContainer.d.ts +6 -5
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.js.map +1 -1
- package/package.json +26 -19
- package/prettier.config.cjs +8 -0
- package/src/fluidContainer.ts +6 -5
package/.eslintrc.js
CHANGED
package/dist/fluidContainer.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface IFluidContainerEvents extends IEvent {
|
|
|
20
20
|
*
|
|
21
21
|
* - {@link IFluidContainer.connectionState}
|
|
22
22
|
*
|
|
23
|
-
* - {@link IFluidContainer.
|
|
23
|
+
* - {@link IFluidContainer.connect}
|
|
24
24
|
*/
|
|
25
25
|
(event: "connected", listener: () => void): void;
|
|
26
26
|
/**
|
|
@@ -54,10 +54,10 @@ export interface IFluidContainerEvents extends IEvent {
|
|
|
54
54
|
/**
|
|
55
55
|
* Emitted when the {@link IFluidContainer} is closed, which permanently disables it.
|
|
56
56
|
*
|
|
57
|
-
* @remarks
|
|
57
|
+
* @remarks Listener parameters:
|
|
58
58
|
*
|
|
59
|
-
* If container was closed due to error (as opposed to an explicit call to
|
|
60
|
-
* {@link IFluidContainer.dispose}),
|
|
59
|
+
* - `error`: If the container was closed due to error (as opposed to an explicit call to
|
|
60
|
+
* {@link IFluidContainer.dispose}), this will contain details about the error that caused it.
|
|
61
61
|
*/
|
|
62
62
|
(event: "disposed", listener: (error?: ICriticalContainerError) => void): any;
|
|
63
63
|
}
|
|
@@ -126,7 +126,8 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
126
126
|
attach(): Promise<string>;
|
|
127
127
|
/**
|
|
128
128
|
* Attempts to connect the container to the delta stream and process operations.
|
|
129
|
-
*
|
|
129
|
+
*
|
|
130
|
+
* @throws Will throw an error if connection is unsuccessful.
|
|
130
131
|
*
|
|
131
132
|
* @remarks
|
|
132
133
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidContainer.d.ts","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EACH,WAAW,EACX,UAAU,EACV,uBAAuB,EACvB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE1F;;GAEG;AAEH,MAAM,WAAW,qBAAsB,SAAQ,MAAM;IACjD;;;;;;;;;;OAUG;IACH,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAEjD;;;;;;;;;;OAUG;IACH,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAEpD;;;;;;OAMG;IACH,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAE7C;;;;;;OAMG;IACH,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAE7C;;;;;;;OAOG;IACH,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,uBAAuB,KAAK,IAAI,OAAE;CAC5E;AAGD;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC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D,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO;;QAChB,MAAA,MAAA,IAAI,CAAC,SAAS,EAAC,OAAO,kDAAI,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,UAAU;;QACnB,MAAA,MAAA,IAAI,CAAC,SAAS,EAAC,UAAU,kDAAI,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAA2B,WAAmC;QAC7E,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC;CACJ;AAzGD,wCAyGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { IEvent, IEventProvider } from \"@fluidframework/common-definitions\";\nimport {\n AttachState,\n IContainer,\n ICriticalContainerError,\n ConnectionState,\n} from \"@fluidframework/container-definitions\";\nimport type { IRootDataObject, LoadableObjectClass, LoadableObjectRecord } from \"./types\";\n\n/**\n * Events emitted from {@link IFluidContainer}.\n */\n/* eslint-disable @typescript-eslint/unified-signatures */\nexport interface IFluidContainerEvents extends IEvent {\n /**\n * Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.\n *\n * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n *\n * @see\n *\n * - {@link IFluidContainer.connectionState}\n *\n * - {@link IFluidContainer.disconnect}\n */\n (event: \"connected\", listener: () => void): void;\n\n /**\n * Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.\n *\n * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n *\n * @see\n *\n * - {@link IFluidContainer.connectionState}\n *\n * - {@link IFluidContainer.disconnect}\n */\n (event: \"disconnected\", listener: () => void): void;\n\n /**\n * Emitted when all local changes/edits have been acknowledged by the service.\n *\n * @remarks \"dirty\" event will be emitted when the next local change has been made.\n *\n * @see {@link IFluidContainer.isDirty}\n */\n (event: \"saved\", listener: () => void): void;\n\n /**\n * Emitted when the first local change has been made, following a \"saved\" event.\n *\n * @remarks \"saved\" event will be emitted once all local changes have been acknowledged by the service.\n *\n * @see {@link IFluidContainer.isDirty}\n */\n (event: \"dirty\", listener: () => void): void;\n\n /**\n * Emitted when the {@link IFluidContainer} is closed, which permanently disables it.\n *\n * @remarks\n *\n * If container was closed due to error (as opposed to an explicit call to\n * {@link IFluidContainer.dispose}), optional argument contains further details about the error.\n */\n (event: \"disposed\", listener: (error?: ICriticalContainerError) => void);\n}\n/* eslint-enable @typescript-eslint/unified-signatures */\n\n/**\n * Provides an entrypoint into the client side of collaborative Fluid data.\n * Provides access to the data as well as status on the collaboration session.\n */\nexport interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {\n /**\n * Provides the current connected state of the container\n */\n readonly connectionState: ConnectionState;\n\n /**\n * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.\n *\n * @remarks\n *\n * You should always check the `isDirty` flag before closing the container or navigating away from the page.\n * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been\n * acknowledged by the service.\n *\n * A container is considered dirty in the following cases:\n *\n * 1. The container has been created in the detached state, and either it has not been attached yet or it is\n * in the process of being attached (container is in `attaching` state). If container is closed prior to being\n * attached, host may never know if the file was created or not.\n *\n * 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.\n * This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the\n * service. In some cases this can be due to lack of network connection. If the network connection is down,\n * it needs to be restored for the pending changes to be acknowledged.\n */\n readonly isDirty: boolean;\n\n /**\n * Whether or not the container is disposed, which permanently disables it.\n */\n readonly disposed: boolean;\n\n /**\n * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.\n *\n * @remarks These data objects and DDSes exist for the lifetime of the container.\n */\n readonly initialObjects: LoadableObjectRecord;\n\n /**\n * The current attachment state of the container.\n *\n * @remarks\n *\n * Once a container has been attached, it remains attached.\n * When loading an existing container, it will already be attached.\n */\n readonly attachState: AttachState;\n\n /**\n * A newly created container starts detached from the collaborative service.\n * Calling `attach()` uploads the new container to the service and connects to the collaborative service.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#AttachState.Detatched} state.\n *\n * This can be determined by observing {@link IFluidContainer.attachState}.\n *\n * @returns A promise which resolves when the attach is complete, with the string identifier of the container.\n */\n attach(): Promise<string>;\n\n /**\n * Attempts to connect the container to the delta stream and process operations.\n * Will throw an error if unsuccessful.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.\n *\n * This can be determined by observing {@link IFluidContainer.connectionState}.\n */\n connect(): void;\n\n /**\n * Disconnects the container from the delta stream and stops processing operations.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.\n *\n * This can be determined by observing {@link IFluidContainer.connectionState}.\n */\n disconnect(): void;\n\n /**\n * Create a new data object or Distributed Data Store (DDS) of the specified type.\n *\n * @remarks\n *\n * In order to share the data object or DDS with other\n * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your\n * initialObjects.\n *\n * @param objectClass - The class of the `DataObject` or `SharedObject` to create.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n */\n create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;\n\n /**\n * Dispose of the container instance, permanently disabling it.\n */\n dispose(): void;\n}\n\n/**\n * Base {@link IFluidContainer} implementation.\n *\n * @remarks\n *\n * Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}\n * will need to utilize or provide a service-specific implementation of this type that implements that method.\n */\nexport class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer {\n private readonly connectedHandler = () => this.emit(\"connected\");\n private readonly disconnectedHandler = () => this.emit(\"disconnected\");\n private readonly disposedHandler = (error?: ICriticalContainerError) => this.emit(\"disposed\", error);\n private readonly savedHandler = () => this.emit(\"saved\");\n private readonly dirtyHandler = () => this.emit(\"dirty\");\n\n public constructor(\n private readonly container: IContainer,\n private readonly rootDataObject: IRootDataObject,\n ) {\n super();\n container.on(\"connected\", this.connectedHandler);\n container.on(\"closed\", this.disposedHandler);\n container.on(\"disconnected\", this.disconnectedHandler);\n container.on(\"saved\", this.savedHandler);\n container.on(\"dirty\", this.dirtyHandler);\n }\n\n /**\n * {@inheritDoc IFluidContainer.isDirty}\n */\n public get isDirty(): boolean {\n return this.container.isDirty;\n }\n\n /**\n * {@inheritDoc IFluidContainer.attachState}\n */\n public get attachState(): AttachState {\n return this.container.attachState;\n }\n\n /**\n * {@inheritDoc IFluidContainer.disposed}\n */\n public get disposed() {\n return this.container.closed;\n }\n\n /**\n * {@inheritDoc IFluidContainer.connectionState}\n */\n public get connectionState(): ConnectionState {\n return this.container.connectionState;\n }\n\n /**\n * {@inheritDoc IFluidContainer.initialObjects}\n */\n public get initialObjects() {\n return this.rootDataObject.initialObjects;\n }\n\n /**\n * Incomplete base implementation of {@link IFluidContainer.attach}.\n *\n * @remarks\n *\n * Note: this implementation will unconditionally throw.\n * Consumers who rely on this will need to utilize or provide a service specific implementation of this base type\n * that provides an implementation of this method.\n *\n * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,\n * but internally this separation is not there.\n */\n public async attach(): Promise<string> {\n if (this.container.attachState !== AttachState.Detached) {\n throw new Error(\"Cannot attach container. Container is not in detached state.\");\n }\n throw new Error(\"Cannot attach container. Attach method not provided.\");\n }\n\n /**\n * {@inheritDoc IFluidContainer.connect}\n */\n public async connect(): Promise<void> {\n this.container.connect?.();\n }\n\n /**\n * {@inheritDoc IFluidContainer.connect}\n */\n public async disconnect(): Promise<void> {\n this.container.disconnect?.();\n }\n\n /**\n * {@inheritDoc IFluidContainer.create}\n */\n public async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {\n return this.rootDataObject.create(objectClass);\n }\n\n /**\n * {@inheritDoc IFluidContainer.dispose}\n */\n public dispose() {\n this.container.close();\n this.container.off(\"connected\", this.connectedHandler);\n this.container.off(\"closed\", this.disposedHandler);\n this.container.off(\"disconnected\", this.disconnectedHandler);\n this.container.off(\"saved\", this.savedHandler);\n this.container.off(\"dirty\", this.dirtyHandler);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fluidContainer.js","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+DAAiE;AAGjE,iFAK+C;AAoL/C;;;;;;;GAOG;AACH,MAAa,cAAe,SAAQ,gCAAwC;IAOxE,YACqB,SAAqB,EACrB,cAA+B;QAEhD,KAAK,EAAE,CAAC;QAHS,cAAS,GAAT,SAAS,CAAY;QACrB,mBAAc,GAAd,cAAc,CAAiB;QARnC,qBAAgB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAChD,wBAAmB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACtD,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AC,8DAA8D,CAAC,CAAC;SACnF;QACD,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO;;QAChB,MAAA,MAAA,IAAI,CAAC,SAAS,EAAC,OAAO,kDAAI,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,UAAU;;QACnB,MAAA,MAAA,IAAI,CAAC,SAAS,EAAC,UAAU,kDAAI,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAA2B,WAAmC;QAC7E,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC;CACJ;AAzGD,wCAyGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { IEvent, IEventProvider } from \"@fluidframework/common-definitions\";\nimport {\n AttachState,\n IContainer,\n ICriticalContainerError,\n ConnectionState,\n} from \"@fluidframework/container-definitions\";\nimport type { IRootDataObject, LoadableObjectClass, LoadableObjectRecord } from \"./types\";\n\n/**\n * Events emitted from {@link IFluidContainer}.\n */\n/* eslint-disable @typescript-eslint/unified-signatures */\nexport interface IFluidContainerEvents extends IEvent {\n /**\n * Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.\n *\n * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n *\n * @see\n *\n * - {@link IFluidContainer.connectionState}\n *\n * - {@link IFluidContainer.connect}\n */\n (event: \"connected\", listener: () => void): void;\n\n /**\n * Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.\n *\n * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n *\n * @see\n *\n * - {@link IFluidContainer.connectionState}\n *\n * - {@link IFluidContainer.disconnect}\n */\n (event: \"disconnected\", listener: () => void): void;\n\n /**\n * Emitted when all local changes/edits have been acknowledged by the service.\n *\n * @remarks \"dirty\" event will be emitted when the next local change has been made.\n *\n * @see {@link IFluidContainer.isDirty}\n */\n (event: \"saved\", listener: () => void): void;\n\n /**\n * Emitted when the first local change has been made, following a \"saved\" event.\n *\n * @remarks \"saved\" event will be emitted once all local changes have been acknowledged by the service.\n *\n * @see {@link IFluidContainer.isDirty}\n */\n (event: \"dirty\", listener: () => void): void;\n\n /**\n * Emitted when the {@link IFluidContainer} is closed, which permanently disables it.\n *\n * @remarks Listener parameters:\n *\n * - `error`: If the container was closed due to error (as opposed to an explicit call to\n * {@link IFluidContainer.dispose}), this will contain details about the error that caused it.\n */\n (event: \"disposed\", listener: (error?: ICriticalContainerError) => void);\n}\n/* eslint-enable @typescript-eslint/unified-signatures */\n\n/**\n * Provides an entrypoint into the client side of collaborative Fluid data.\n * Provides access to the data as well as status on the collaboration session.\n */\nexport interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {\n /**\n * Provides the current connected state of the container\n */\n readonly connectionState: ConnectionState;\n\n /**\n * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.\n *\n * @remarks\n *\n * You should always check the `isDirty` flag before closing the container or navigating away from the page.\n * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been\n * acknowledged by the service.\n *\n * A container is considered dirty in the following cases:\n *\n * 1. The container has been created in the detached state, and either it has not been attached yet or it is\n * in the process of being attached (container is in `attaching` state). If container is closed prior to being\n * attached, host may never know if the file was created or not.\n *\n * 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.\n * This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the\n * service. In some cases this can be due to lack of network connection. If the network connection is down,\n * it needs to be restored for the pending changes to be acknowledged.\n */\n readonly isDirty: boolean;\n\n /**\n * Whether or not the container is disposed, which permanently disables it.\n */\n readonly disposed: boolean;\n\n /**\n * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.\n *\n * @remarks These data objects and DDSes exist for the lifetime of the container.\n */\n readonly initialObjects: LoadableObjectRecord;\n\n /**\n * The current attachment state of the container.\n *\n * @remarks\n *\n * Once a container has been attached, it remains attached.\n * When loading an existing container, it will already be attached.\n */\n readonly attachState: AttachState;\n\n /**\n * A newly created container starts detached from the collaborative service.\n * Calling `attach()` uploads the new container to the service and connects to the collaborative service.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#AttachState.Detatched} state.\n *\n * This can be determined by observing {@link IFluidContainer.attachState}.\n *\n * @returns A promise which resolves when the attach is complete, with the string identifier of the container.\n */\n attach(): Promise<string>;\n\n /**\n * Attempts to connect the container to the delta stream and process operations.\n *\n * @throws Will throw an error if connection is unsuccessful.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.\n *\n * This can be determined by observing {@link IFluidContainer.connectionState}.\n */\n connect(): void;\n\n /**\n * Disconnects the container from the delta stream and stops processing operations.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.\n *\n * This can be determined by observing {@link IFluidContainer.connectionState}.\n */\n disconnect(): void;\n\n /**\n * Create a new data object or Distributed Data Store (DDS) of the specified type.\n *\n * @remarks\n *\n * In order to share the data object or DDS with other\n * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your\n * initialObjects.\n *\n * @param objectClass - The class of the `DataObject` or `SharedObject` to create.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n */\n create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;\n\n /**\n * Dispose of the container instance, permanently disabling it.\n */\n dispose(): void;\n}\n\n/**\n * Base {@link IFluidContainer} implementation.\n *\n * @remarks\n *\n * Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}\n * will need to utilize or provide a service-specific implementation of this type that implements that method.\n */\nexport class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer {\n private readonly connectedHandler = () => this.emit(\"connected\");\n private readonly disconnectedHandler = () => this.emit(\"disconnected\");\n private readonly disposedHandler = (error?: ICriticalContainerError) => this.emit(\"disposed\", error);\n private readonly savedHandler = () => this.emit(\"saved\");\n private readonly dirtyHandler = () => this.emit(\"dirty\");\n\n public constructor(\n private readonly container: IContainer,\n private readonly rootDataObject: IRootDataObject,\n ) {\n super();\n container.on(\"connected\", this.connectedHandler);\n container.on(\"closed\", this.disposedHandler);\n container.on(\"disconnected\", this.disconnectedHandler);\n container.on(\"saved\", this.savedHandler);\n container.on(\"dirty\", this.dirtyHandler);\n }\n\n /**\n * {@inheritDoc IFluidContainer.isDirty}\n */\n public get isDirty(): boolean {\n return this.container.isDirty;\n }\n\n /**\n * {@inheritDoc IFluidContainer.attachState}\n */\n public get attachState(): AttachState {\n return this.container.attachState;\n }\n\n /**\n * {@inheritDoc IFluidContainer.disposed}\n */\n public get disposed() {\n return this.container.closed;\n }\n\n /**\n * {@inheritDoc IFluidContainer.connectionState}\n */\n public get connectionState(): ConnectionState {\n return this.container.connectionState;\n }\n\n /**\n * {@inheritDoc IFluidContainer.initialObjects}\n */\n public get initialObjects() {\n return this.rootDataObject.initialObjects;\n }\n\n /**\n * Incomplete base implementation of {@link IFluidContainer.attach}.\n *\n * @remarks\n *\n * Note: this implementation will unconditionally throw.\n * Consumers who rely on this will need to utilize or provide a service specific implementation of this base type\n * that provides an implementation of this method.\n *\n * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,\n * but internally this separation is not there.\n */\n public async attach(): Promise<string> {\n if (this.container.attachState !== AttachState.Detached) {\n throw new Error(\"Cannot attach container. Container is not in detached state.\");\n }\n throw new Error(\"Cannot attach container. Attach method not provided.\");\n }\n\n /**\n * {@inheritDoc IFluidContainer.connect}\n */\n public async connect(): Promise<void> {\n this.container.connect?.();\n }\n\n /**\n * {@inheritDoc IFluidContainer.connect}\n */\n public async disconnect(): Promise<void> {\n this.container.disconnect?.();\n }\n\n /**\n * {@inheritDoc IFluidContainer.create}\n */\n public async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {\n return this.rootDataObject.create(objectClass);\n }\n\n /**\n * {@inheritDoc IFluidContainer.dispose}\n */\n public dispose() {\n this.container.close();\n this.container.off(\"connected\", this.connectedHandler);\n this.container.off(\"closed\", this.disposedHandler);\n this.container.off(\"disconnected\", this.disconnectedHandler);\n this.container.off(\"saved\", this.savedHandler);\n this.container.off(\"dirty\", this.dirtyHandler);\n }\n}\n"]}
|
package/lib/fluidContainer.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface IFluidContainerEvents extends IEvent {
|
|
|
20
20
|
*
|
|
21
21
|
* - {@link IFluidContainer.connectionState}
|
|
22
22
|
*
|
|
23
|
-
* - {@link IFluidContainer.
|
|
23
|
+
* - {@link IFluidContainer.connect}
|
|
24
24
|
*/
|
|
25
25
|
(event: "connected", listener: () => void): void;
|
|
26
26
|
/**
|
|
@@ -54,10 +54,10 @@ export interface IFluidContainerEvents extends IEvent {
|
|
|
54
54
|
/**
|
|
55
55
|
* Emitted when the {@link IFluidContainer} is closed, which permanently disables it.
|
|
56
56
|
*
|
|
57
|
-
* @remarks
|
|
57
|
+
* @remarks Listener parameters:
|
|
58
58
|
*
|
|
59
|
-
* If container was closed due to error (as opposed to an explicit call to
|
|
60
|
-
* {@link IFluidContainer.dispose}),
|
|
59
|
+
* - `error`: If the container was closed due to error (as opposed to an explicit call to
|
|
60
|
+
* {@link IFluidContainer.dispose}), this will contain details about the error that caused it.
|
|
61
61
|
*/
|
|
62
62
|
(event: "disposed", listener: (error?: ICriticalContainerError) => void): any;
|
|
63
63
|
}
|
|
@@ -126,7 +126,8 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
126
126
|
attach(): Promise<string>;
|
|
127
127
|
/**
|
|
128
128
|
* Attempts to connect the container to the delta stream and process operations.
|
|
129
|
-
*
|
|
129
|
+
*
|
|
130
|
+
* @throws Will throw an error if connection is unsuccessful.
|
|
130
131
|
*
|
|
131
132
|
* @remarks
|
|
132
133
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidContainer.d.ts","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EACH,WAAW,EACX,UAAU,EACV,uBAAuB,EACvB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE1F;;GAEG;AAEH,MAAM,WAAW,qBAAsB,SAAQ,MAAM;IACjD;;;;;;;;;;OAUG;IACH,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAEjD;;;;;;;;;;OAUG;IACH,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ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7D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { IEvent, IEventProvider } from \"@fluidframework/common-definitions\";\nimport {\n AttachState,\n IContainer,\n ICriticalContainerError,\n ConnectionState,\n} from \"@fluidframework/container-definitions\";\nimport type { IRootDataObject, LoadableObjectClass, LoadableObjectRecord } from \"./types\";\n\n/**\n * Events emitted from {@link IFluidContainer}.\n */\n/* eslint-disable @typescript-eslint/unified-signatures */\nexport interface IFluidContainerEvents extends IEvent {\n /**\n * Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.\n *\n * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n *\n * @see\n *\n * - {@link IFluidContainer.connectionState}\n *\n * - {@link IFluidContainer.disconnect}\n */\n (event: \"connected\", listener: () => void): void;\n\n /**\n * Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.\n *\n * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n *\n * @see\n *\n * - {@link IFluidContainer.connectionState}\n *\n * - {@link IFluidContainer.disconnect}\n */\n (event: \"disconnected\", listener: () => void): void;\n\n /**\n * Emitted when all local changes/edits have been acknowledged by the service.\n *\n * @remarks \"dirty\" event will be emitted when the next local change has been made.\n *\n * @see {@link IFluidContainer.isDirty}\n */\n (event: \"saved\", listener: () => void): void;\n\n /**\n * Emitted when the first local change has been made, following a \"saved\" event.\n *\n * @remarks \"saved\" event will be emitted once all local changes have been acknowledged by the service.\n *\n * @see {@link IFluidContainer.isDirty}\n */\n (event: \"dirty\", listener: () => void): void;\n\n /**\n * Emitted when the {@link IFluidContainer} is closed, which permanently disables it.\n *\n * @remarks\n *\n * If container was closed due to error (as opposed to an explicit call to\n * {@link IFluidContainer.dispose}), optional argument contains further details about the error.\n */\n (event: \"disposed\", listener: (error?: ICriticalContainerError) => void);\n}\n/* eslint-enable @typescript-eslint/unified-signatures */\n\n/**\n * Provides an entrypoint into the client side of collaborative Fluid data.\n * Provides access to the data as well as status on the collaboration session.\n */\nexport interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {\n /**\n * Provides the current connected state of the container\n */\n readonly connectionState: ConnectionState;\n\n /**\n * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.\n *\n * @remarks\n *\n * You should always check the `isDirty` flag before closing the container or navigating away from the page.\n * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been\n * acknowledged by the service.\n *\n * A container is considered dirty in the following cases:\n *\n * 1. The container has been created in the detached state, and either it has not been attached yet or it is\n * in the process of being attached (container is in `attaching` state). If container is closed prior to being\n * attached, host may never know if the file was created or not.\n *\n * 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.\n * This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the\n * service. In some cases this can be due to lack of network connection. If the network connection is down,\n * it needs to be restored for the pending changes to be acknowledged.\n */\n readonly isDirty: boolean;\n\n /**\n * Whether or not the container is disposed, which permanently disables it.\n */\n readonly disposed: boolean;\n\n /**\n * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.\n *\n * @remarks These data objects and DDSes exist for the lifetime of the container.\n */\n readonly initialObjects: LoadableObjectRecord;\n\n /**\n * The current attachment state of the container.\n *\n * @remarks\n *\n * Once a container has been attached, it remains attached.\n * When loading an existing container, it will already be attached.\n */\n readonly attachState: AttachState;\n\n /**\n * A newly created container starts detached from the collaborative service.\n * Calling `attach()` uploads the new container to the service and connects to the collaborative service.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#AttachState.Detatched} state.\n *\n * This can be determined by observing {@link IFluidContainer.attachState}.\n *\n * @returns A promise which resolves when the attach is complete, with the string identifier of the container.\n */\n attach(): Promise<string>;\n\n /**\n * Attempts to connect the container to the delta stream and process operations.\n * Will throw an error if unsuccessful.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.\n *\n * This can be determined by observing {@link IFluidContainer.connectionState}.\n */\n connect(): void;\n\n /**\n * Disconnects the container from the delta stream and stops processing operations.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.\n *\n * This can be determined by observing {@link IFluidContainer.connectionState}.\n */\n disconnect(): void;\n\n /**\n * Create a new data object or Distributed Data Store (DDS) of the specified type.\n *\n * @remarks\n *\n * In order to share the data object or DDS with other\n * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your\n * initialObjects.\n *\n * @param objectClass - The class of the `DataObject` or `SharedObject` to create.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n */\n create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;\n\n /**\n * Dispose of the container instance, permanently disabling it.\n */\n dispose(): void;\n}\n\n/**\n * Base {@link IFluidContainer} implementation.\n *\n * @remarks\n *\n * Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}\n * will need to utilize or provide a service-specific implementation of this type that implements that method.\n */\nexport class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer {\n private readonly connectedHandler = () => this.emit(\"connected\");\n private readonly disconnectedHandler = () => this.emit(\"disconnected\");\n private readonly disposedHandler = (error?: ICriticalContainerError) => this.emit(\"disposed\", error);\n private readonly savedHandler = () => this.emit(\"saved\");\n private readonly dirtyHandler = () => this.emit(\"dirty\");\n\n public constructor(\n private readonly container: IContainer,\n private readonly rootDataObject: IRootDataObject,\n ) {\n super();\n container.on(\"connected\", this.connectedHandler);\n container.on(\"closed\", this.disposedHandler);\n container.on(\"disconnected\", this.disconnectedHandler);\n container.on(\"saved\", this.savedHandler);\n container.on(\"dirty\", this.dirtyHandler);\n }\n\n /**\n * {@inheritDoc IFluidContainer.isDirty}\n */\n public get isDirty(): boolean {\n return this.container.isDirty;\n }\n\n /**\n * {@inheritDoc IFluidContainer.attachState}\n */\n public get attachState(): AttachState {\n return this.container.attachState;\n }\n\n /**\n * {@inheritDoc IFluidContainer.disposed}\n */\n public get disposed() {\n return this.container.closed;\n }\n\n /**\n * {@inheritDoc IFluidContainer.connectionState}\n */\n public get connectionState(): ConnectionState {\n return this.container.connectionState;\n }\n\n /**\n * {@inheritDoc IFluidContainer.initialObjects}\n */\n public get initialObjects() {\n return this.rootDataObject.initialObjects;\n }\n\n /**\n * Incomplete base implementation of {@link IFluidContainer.attach}.\n *\n * @remarks\n *\n * Note: this implementation will unconditionally throw.\n * Consumers who rely on this will need to utilize or provide a service specific implementation of this base type\n * that provides an implementation of this method.\n *\n * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,\n * but internally this separation is not there.\n */\n public async attach(): Promise<string> {\n if (this.container.attachState !== AttachState.Detached) {\n throw new Error(\"Cannot attach container. Container is not in detached state.\");\n }\n throw new Error(\"Cannot attach container. Attach method not provided.\");\n }\n\n /**\n * {@inheritDoc IFluidContainer.connect}\n */\n public async connect(): Promise<void> {\n this.container.connect?.();\n }\n\n /**\n * {@inheritDoc IFluidContainer.connect}\n */\n public async disconnect(): Promise<void> {\n this.container.disconnect?.();\n }\n\n /**\n * {@inheritDoc IFluidContainer.create}\n */\n public async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {\n return this.rootDataObject.create(objectClass);\n }\n\n /**\n * {@inheritDoc IFluidContainer.dispose}\n */\n public dispose() {\n this.container.close();\n this.container.off(\"connected\", this.connectedHandler);\n this.container.off(\"closed\", this.disposedHandler);\n this.container.off(\"disconnected\", this.disconnectedHandler);\n this.container.off(\"saved\", this.savedHandler);\n this.container.off(\"dirty\", this.dirtyHandler);\n }\n}\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;QACnD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { IEvent, IEventProvider } from \"@fluidframework/common-definitions\";\nimport {\n AttachState,\n IContainer,\n ICriticalContainerError,\n ConnectionState,\n} from \"@fluidframework/container-definitions\";\nimport type { IRootDataObject, LoadableObjectClass, LoadableObjectRecord } from \"./types\";\n\n/**\n * Events emitted from {@link IFluidContainer}.\n */\n/* eslint-disable @typescript-eslint/unified-signatures */\nexport interface IFluidContainerEvents extends IEvent {\n /**\n * Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.\n *\n * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n *\n * @see\n *\n * - {@link IFluidContainer.connectionState}\n *\n * - {@link IFluidContainer.connect}\n */\n (event: \"connected\", listener: () => void): void;\n\n /**\n * Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.\n *\n * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n *\n * @see\n *\n * - {@link IFluidContainer.connectionState}\n *\n * - {@link IFluidContainer.disconnect}\n */\n (event: \"disconnected\", listener: () => void): void;\n\n /**\n * Emitted when all local changes/edits have been acknowledged by the service.\n *\n * @remarks \"dirty\" event will be emitted when the next local change has been made.\n *\n * @see {@link IFluidContainer.isDirty}\n */\n (event: \"saved\", listener: () => void): void;\n\n /**\n * Emitted when the first local change has been made, following a \"saved\" event.\n *\n * @remarks \"saved\" event will be emitted once all local changes have been acknowledged by the service.\n *\n * @see {@link IFluidContainer.isDirty}\n */\n (event: \"dirty\", listener: () => void): void;\n\n /**\n * Emitted when the {@link IFluidContainer} is closed, which permanently disables it.\n *\n * @remarks Listener parameters:\n *\n * - `error`: If the container was closed due to error (as opposed to an explicit call to\n * {@link IFluidContainer.dispose}), this will contain details about the error that caused it.\n */\n (event: \"disposed\", listener: (error?: ICriticalContainerError) => void);\n}\n/* eslint-enable @typescript-eslint/unified-signatures */\n\n/**\n * Provides an entrypoint into the client side of collaborative Fluid data.\n * Provides access to the data as well as status on the collaboration session.\n */\nexport interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {\n /**\n * Provides the current connected state of the container\n */\n readonly connectionState: ConnectionState;\n\n /**\n * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.\n *\n * @remarks\n *\n * You should always check the `isDirty` flag before closing the container or navigating away from the page.\n * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been\n * acknowledged by the service.\n *\n * A container is considered dirty in the following cases:\n *\n * 1. The container has been created in the detached state, and either it has not been attached yet or it is\n * in the process of being attached (container is in `attaching` state). If container is closed prior to being\n * attached, host may never know if the file was created or not.\n *\n * 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.\n * This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the\n * service. In some cases this can be due to lack of network connection. If the network connection is down,\n * it needs to be restored for the pending changes to be acknowledged.\n */\n readonly isDirty: boolean;\n\n /**\n * Whether or not the container is disposed, which permanently disables it.\n */\n readonly disposed: boolean;\n\n /**\n * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.\n *\n * @remarks These data objects and DDSes exist for the lifetime of the container.\n */\n readonly initialObjects: LoadableObjectRecord;\n\n /**\n * The current attachment state of the container.\n *\n * @remarks\n *\n * Once a container has been attached, it remains attached.\n * When loading an existing container, it will already be attached.\n */\n readonly attachState: AttachState;\n\n /**\n * A newly created container starts detached from the collaborative service.\n * Calling `attach()` uploads the new container to the service and connects to the collaborative service.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#AttachState.Detatched} state.\n *\n * This can be determined by observing {@link IFluidContainer.attachState}.\n *\n * @returns A promise which resolves when the attach is complete, with the string identifier of the container.\n */\n attach(): Promise<string>;\n\n /**\n * Attempts to connect the container to the delta stream and process operations.\n *\n * @throws Will throw an error if connection is unsuccessful.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.\n *\n * This can be determined by observing {@link IFluidContainer.connectionState}.\n */\n connect(): void;\n\n /**\n * Disconnects the container from the delta stream and stops processing operations.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.\n *\n * This can be determined by observing {@link IFluidContainer.connectionState}.\n */\n disconnect(): void;\n\n /**\n * Create a new data object or Distributed Data Store (DDS) of the specified type.\n *\n * @remarks\n *\n * In order to share the data object or DDS with other\n * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your\n * initialObjects.\n *\n * @param objectClass - The class of the `DataObject` or `SharedObject` to create.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n */\n create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;\n\n /**\n * Dispose of the container instance, permanently disabling it.\n */\n dispose(): void;\n}\n\n/**\n * Base {@link IFluidContainer} implementation.\n *\n * @remarks\n *\n * Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}\n * will need to utilize or provide a service-specific implementation of this type that implements that method.\n */\nexport class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer {\n private readonly connectedHandler = () => this.emit(\"connected\");\n private readonly disconnectedHandler = () => this.emit(\"disconnected\");\n private readonly disposedHandler = (error?: ICriticalContainerError) => this.emit(\"disposed\", error);\n private readonly savedHandler = () => this.emit(\"saved\");\n private readonly dirtyHandler = () => this.emit(\"dirty\");\n\n public constructor(\n private readonly container: IContainer,\n private readonly rootDataObject: IRootDataObject,\n ) {\n super();\n container.on(\"connected\", this.connectedHandler);\n container.on(\"closed\", this.disposedHandler);\n container.on(\"disconnected\", this.disconnectedHandler);\n container.on(\"saved\", this.savedHandler);\n container.on(\"dirty\", this.dirtyHandler);\n }\n\n /**\n * {@inheritDoc IFluidContainer.isDirty}\n */\n public get isDirty(): boolean {\n return this.container.isDirty;\n }\n\n /**\n * {@inheritDoc IFluidContainer.attachState}\n */\n public get attachState(): AttachState {\n return this.container.attachState;\n }\n\n /**\n * {@inheritDoc IFluidContainer.disposed}\n */\n public get disposed() {\n return this.container.closed;\n }\n\n /**\n * {@inheritDoc IFluidContainer.connectionState}\n */\n public get connectionState(): ConnectionState {\n return this.container.connectionState;\n }\n\n /**\n * {@inheritDoc IFluidContainer.initialObjects}\n */\n public get initialObjects() {\n return this.rootDataObject.initialObjects;\n }\n\n /**\n * Incomplete base implementation of {@link IFluidContainer.attach}.\n *\n * @remarks\n *\n * Note: this implementation will unconditionally throw.\n * Consumers who rely on this will need to utilize or provide a service specific implementation of this base type\n * that provides an implementation of this method.\n *\n * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,\n * but internally this separation is not there.\n */\n public async attach(): Promise<string> {\n if (this.container.attachState !== AttachState.Detached) {\n throw new Error(\"Cannot attach container. Container is not in detached state.\");\n }\n throw new Error(\"Cannot attach container. Attach method not provided.\");\n }\n\n /**\n * {@inheritDoc IFluidContainer.connect}\n */\n public async connect(): Promise<void> {\n this.container.connect?.();\n }\n\n /**\n * {@inheritDoc IFluidContainer.connect}\n */\n public async disconnect(): Promise<void> {\n this.container.disconnect?.();\n }\n\n /**\n * {@inheritDoc IFluidContainer.create}\n */\n public async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {\n return this.rootDataObject.create(objectClass);\n }\n\n /**\n * {@inheritDoc IFluidContainer.dispose}\n */\n public dispose() {\n this.container.close();\n this.container.off(\"connected\", this.connectedHandler);\n this.container.off(\"closed\", this.disposedHandler);\n this.container.off(\"disconnected\", this.disconnectedHandler);\n this.container.off(\"saved\", this.savedHandler);\n this.container.off(\"dirty\", this.dirtyHandler);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/fluid-static",
|
|
3
|
-
"version": "2.0.0-internal.2.
|
|
3
|
+
"version": "2.0.0-internal.2.2.0",
|
|
4
4
|
"description": "A tool to enable consumption of Fluid Data Objects without requiring custom container code.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -27,14 +27,18 @@
|
|
|
27
27
|
"clean": "rimraf dist *.tsbuildinfo *.build.log",
|
|
28
28
|
"eslint": "eslint --format stylish src",
|
|
29
29
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
30
|
+
"format": "npm run prettier:fix",
|
|
30
31
|
"lint": "npm run eslint",
|
|
31
32
|
"lint:fix": "npm run eslint:fix",
|
|
33
|
+
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
34
|
+
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
32
35
|
"test": "npm run test:mocha",
|
|
33
36
|
"test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
|
|
34
37
|
"test:mocha": "mocha --recursive dist/test/**/*.spec.js -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
|
|
35
38
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
36
39
|
"tsc": "tsc",
|
|
37
|
-
"typetests:gen": "
|
|
40
|
+
"typetests:gen": "flub generate typetests --generate --dir .",
|
|
41
|
+
"typetests:prepare": "flub generate typetests --prepare --dir . --pin"
|
|
38
42
|
},
|
|
39
43
|
"nyc": {
|
|
40
44
|
"all": true,
|
|
@@ -57,28 +61,28 @@
|
|
|
57
61
|
"temp-directory": "nyc/.nyc_output"
|
|
58
62
|
},
|
|
59
63
|
"dependencies": {
|
|
60
|
-
"@fluidframework/aqueduct": ">=2.0.0-internal.2.
|
|
64
|
+
"@fluidframework/aqueduct": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
|
|
61
65
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
62
66
|
"@fluidframework/common-utils": "^1.0.0",
|
|
63
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.2.
|
|
64
|
-
"@fluidframework/container-loader": ">=2.0.0-internal.2.
|
|
65
|
-
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.2.
|
|
66
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.2.
|
|
67
|
-
"@fluidframework/datastore-definitions": ">=2.0.0-internal.2.
|
|
67
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
|
|
68
|
+
"@fluidframework/container-loader": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
|
|
69
|
+
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
|
|
70
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
|
|
71
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
|
|
68
72
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
69
|
-
"@fluidframework/request-handler": ">=2.0.0-internal.2.
|
|
70
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-internal.2.
|
|
71
|
-
"@fluidframework/runtime-utils": ">=2.0.0-internal.2.
|
|
73
|
+
"@fluidframework/request-handler": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
|
|
74
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
|
|
75
|
+
"@fluidframework/runtime-utils": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0"
|
|
72
76
|
},
|
|
73
77
|
"devDependencies": {
|
|
74
|
-
"@fluid-tools/build-cli": "^0.
|
|
78
|
+
"@fluid-tools/build-cli": "^0.7.0",
|
|
75
79
|
"@fluidframework/build-common": "^1.1.0",
|
|
76
|
-
"@fluidframework/build-tools": "^0.
|
|
77
|
-
"@fluidframework/eslint-config-fluid": "^1.
|
|
78
|
-
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-internal.2.
|
|
79
|
-
"@fluidframework/map": ">=2.0.0-internal.2.
|
|
80
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.
|
|
81
|
-
"@fluidframework/sequence": ">=2.0.0-internal.2.
|
|
80
|
+
"@fluidframework/build-tools": "^0.7.0",
|
|
81
|
+
"@fluidframework/eslint-config-fluid": "^1.2.0",
|
|
82
|
+
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-internal.2.1.0",
|
|
83
|
+
"@fluidframework/map": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
|
|
84
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
|
|
85
|
+
"@fluidframework/sequence": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
|
|
82
86
|
"@microsoft/api-extractor": "^7.22.2",
|
|
83
87
|
"@rushstack/eslint-config": "^2.5.1",
|
|
84
88
|
"@types/mocha": "^9.1.1",
|
|
@@ -89,11 +93,14 @@
|
|
|
89
93
|
"eslint": "~8.6.0",
|
|
90
94
|
"mocha": "^10.0.0",
|
|
91
95
|
"nyc": "^15.0.0",
|
|
96
|
+
"prettier": "~2.6.2",
|
|
92
97
|
"rimraf": "^2.6.2",
|
|
93
98
|
"typescript": "~4.5.5"
|
|
94
99
|
},
|
|
95
100
|
"typeValidation": {
|
|
96
|
-
"version": "2.0.0-internal.2.
|
|
101
|
+
"version": "2.0.0-internal.2.2.0",
|
|
102
|
+
"baselineRange": ">=2.0.0-internal.2.1.0 <2.0.0-internal.2.2.0",
|
|
103
|
+
"baselineVersion": "2.0.0-internal.2.1.0",
|
|
97
104
|
"broken": {}
|
|
98
105
|
}
|
|
99
106
|
}
|
package/src/fluidContainer.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface IFluidContainerEvents extends IEvent {
|
|
|
27
27
|
*
|
|
28
28
|
* - {@link IFluidContainer.connectionState}
|
|
29
29
|
*
|
|
30
|
-
* - {@link IFluidContainer.
|
|
30
|
+
* - {@link IFluidContainer.connect}
|
|
31
31
|
*/
|
|
32
32
|
(event: "connected", listener: () => void): void;
|
|
33
33
|
|
|
@@ -65,10 +65,10 @@ export interface IFluidContainerEvents extends IEvent {
|
|
|
65
65
|
/**
|
|
66
66
|
* Emitted when the {@link IFluidContainer} is closed, which permanently disables it.
|
|
67
67
|
*
|
|
68
|
-
* @remarks
|
|
68
|
+
* @remarks Listener parameters:
|
|
69
69
|
*
|
|
70
|
-
* If container was closed due to error (as opposed to an explicit call to
|
|
71
|
-
* {@link IFluidContainer.dispose}),
|
|
70
|
+
* - `error`: If the container was closed due to error (as opposed to an explicit call to
|
|
71
|
+
* {@link IFluidContainer.dispose}), this will contain details about the error that caused it.
|
|
72
72
|
*/
|
|
73
73
|
(event: "disposed", listener: (error?: ICriticalContainerError) => void);
|
|
74
74
|
}
|
|
@@ -145,7 +145,8 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
147
|
* Attempts to connect the container to the delta stream and process operations.
|
|
148
|
-
*
|
|
148
|
+
*
|
|
149
|
+
* @throws Will throw an error if connection is unsuccessful.
|
|
149
150
|
*
|
|
150
151
|
* @remarks
|
|
151
152
|
*
|