@fluidframework/fluid-static 2.41.0-338401 → 2.42.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/CHANGELOG.md +8 -0
- package/dist/fluidContainer.d.ts +14 -5
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js +10 -3
- package/dist/fluidContainer.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/rootDataObject.d.ts +16 -2
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +37 -25
- package/dist/rootDataObject.js.map +1 -1
- package/dist/serviceAudience.js +0 -2
- package/dist/serviceAudience.js.map +1 -1
- package/dist/types.d.ts +23 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/lib/fluidContainer.d.ts +14 -5
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.js +10 -3
- package/lib/fluidContainer.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/rootDataObject.d.ts +16 -2
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.js +37 -25
- package/lib/rootDataObject.js.map +1 -1
- package/lib/serviceAudience.js +0 -2
- package/lib/serviceAudience.js.map +1 -1
- package/lib/types.d.ts +23 -10
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +21 -20
- package/src/fluidContainer.ts +45 -7
- package/src/index.ts +0 -3
- package/src/rootDataObject.ts +81 -29
- package/src/serviceAudience.ts +0 -2
- package/src/types.ts +30 -11
package/CHANGELOG.md
CHANGED
package/dist/fluidContainer.d.ts
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { AttachState, type ConnectionState, type ICriticalContainerError } from "@fluidframework/container-definitions";
|
|
6
6
|
import type { IContainer } from "@fluidframework/container-definitions/internal";
|
|
7
|
-
import type {
|
|
7
|
+
import type { ContainerExtensionStore } from "@fluidframework/container-runtime-definitions/internal";
|
|
8
|
+
import type { IEvent, IEventProvider, IFluidHandle, IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
8
9
|
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
9
|
-
import type { ContainerAttachProps, ContainerSchema
|
|
10
|
+
import type { ContainerAttachProps, ContainerSchema } from "./types.js";
|
|
10
11
|
/**
|
|
11
12
|
* Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
|
|
12
13
|
* @public
|
|
@@ -201,13 +202,22 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
201
202
|
*
|
|
202
203
|
* @internal
|
|
203
204
|
*/
|
|
204
|
-
export interface IFluidContainerInternal {
|
|
205
|
+
export interface IFluidContainerInternal extends ContainerExtensionStore {
|
|
205
206
|
/**
|
|
206
207
|
* The underlying {@link @fluidframework/container-definitions#IContainer}.
|
|
207
208
|
*
|
|
208
209
|
* @remarks Used to power debug tooling and experimental features.
|
|
209
210
|
*/
|
|
210
211
|
readonly container: IContainer;
|
|
212
|
+
/**
|
|
213
|
+
* Upload a blob of data.
|
|
214
|
+
* Although it is marked as internal, there is external usage of this function for experimental purposes.
|
|
215
|
+
* Please contact yunho-microsoft or vladsud if you need to change it.
|
|
216
|
+
* @param blob - blob to be uploaded.
|
|
217
|
+
*
|
|
218
|
+
* @remarks This method is used to expose uploadBlob to the IFluidContainer level. UploadBlob will upload data to server side (as of now, ODSP only). There is no downloadBlob provided as it is not needed(blob lifetime managed by server).
|
|
219
|
+
*/
|
|
220
|
+
uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;
|
|
211
221
|
}
|
|
212
222
|
/**
|
|
213
223
|
* Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.
|
|
@@ -216,8 +226,7 @@ export interface IFluidContainerInternal {
|
|
|
216
226
|
*/
|
|
217
227
|
export declare function createFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>(props: {
|
|
218
228
|
container: IContainer;
|
|
219
|
-
|
|
220
|
-
}): IFluidContainer<TContainerSchema>;
|
|
229
|
+
}): Promise<IFluidContainer<TContainerSchema>>;
|
|
221
230
|
/**
|
|
222
231
|
* Check that the provided `container` is an internal {@link IFluidContainerInternal}.
|
|
223
232
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidContainer.d.ts","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"fluidContainer.d.ts","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AACtG,OAAO,KAAK,EAEX,MAAM,EACN,cAAc,EACd,YAAY,EACZ,cAAc,EACd,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,KAAK,EACX,oBAAoB,EACpB,eAAe,EAGf,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,eAAe,IAAI;KAMtD,CAAC,IAAI,MAAM,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC,C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;;;;;;;;;;;OAWG;IACH,OAAO,IAAI,IAAI,CAAC;IAEhB;;;;;;;;;OASG;IACH,UAAU,IAAI,IAAI,CAAC;IAEnB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE/E;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACvE;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAE/B;;;;;;;OAOG;IACH,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC;CAC1E;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACzC,gBAAgB,SAAS,eAAe,GAAG,eAAe,EACzD,KAAK,EAAE;IACR,SAAS,EAAE,UAAU,CAAC;CACtB,GAAG,OAAO,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC,CAW7C;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,SAAS,eAAe,EAChF,SAAS,EAAE,eAAe,CAAC,gBAAgB,CAAC,GAAG,uBAAuB,GACpE,SAAS,IAAI,uBAAuB,CAKtC"}
|
package/dist/fluidContainer.js
CHANGED
|
@@ -7,13 +7,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.isInternalFluidContainer = exports.createFluidContainer = void 0;
|
|
8
8
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
9
|
const container_definitions_1 = require("@fluidframework/container-definitions");
|
|
10
|
+
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
10
11
|
/**
|
|
11
12
|
* Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.
|
|
12
13
|
*
|
|
13
14
|
* @internal
|
|
14
15
|
*/
|
|
15
|
-
function createFluidContainer(props) {
|
|
16
|
-
|
|
16
|
+
async function createFluidContainer(props) {
|
|
17
|
+
const entryPoint = await props.container.getEntryPoint();
|
|
18
|
+
(0, internal_1.assert)(entryPoint.IStaticEntryPoint !== undefined, 0xb9e /* entryPoint must be of type IStaticEntryPoint */);
|
|
19
|
+
return new FluidContainer(props.container, entryPoint.IStaticEntryPoint.rootDataObject, entryPoint.IStaticEntryPoint.extensionStore);
|
|
17
20
|
}
|
|
18
21
|
exports.createFluidContainer = createFluidContainer;
|
|
19
22
|
/**
|
|
@@ -38,7 +41,7 @@ exports.isInternalFluidContainer = isInternalFluidContainer;
|
|
|
38
41
|
* will need to utilize or provide a service-specific implementation of this type that implements that method.
|
|
39
42
|
*/
|
|
40
43
|
class FluidContainer extends client_utils_1.TypedEventEmitter {
|
|
41
|
-
constructor(container, rootDataObject) {
|
|
44
|
+
constructor(container, rootDataObject, extensionStore) {
|
|
42
45
|
super();
|
|
43
46
|
this.container = container;
|
|
44
47
|
this.rootDataObject = rootDataObject;
|
|
@@ -47,6 +50,7 @@ class FluidContainer extends client_utils_1.TypedEventEmitter {
|
|
|
47
50
|
this.disposedHandler = (error) => this.emit("disposed", error);
|
|
48
51
|
this.savedHandler = () => this.emit("saved");
|
|
49
52
|
this.dirtyHandler = () => this.emit("dirty");
|
|
53
|
+
this.acquireExtension = extensionStore.acquireExtension.bind(extensionStore);
|
|
50
54
|
container.on("connected", this.connectedHandler);
|
|
51
55
|
container.on("closed", this.disposedHandler);
|
|
52
56
|
container.on("disconnected", this.disconnectedHandler);
|
|
@@ -103,5 +107,8 @@ class FluidContainer extends client_utils_1.TypedEventEmitter {
|
|
|
103
107
|
this.container.off("saved", this.savedHandler);
|
|
104
108
|
this.container.off("dirty", this.dirtyHandler);
|
|
105
109
|
}
|
|
110
|
+
async uploadBlob(blob) {
|
|
111
|
+
return this.rootDataObject.uploadBlob(blob);
|
|
112
|
+
}
|
|
106
113
|
}
|
|
107
114
|
//# sourceMappingURL=fluidContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidContainer.js","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,iFAI+C;AA4O/C;;;;GAIG;AACH,SAAgB,oBAAoB,CAElC,KAGD;IACA,OAAO,IAAI,cAAc,CAAmB,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;AACpF,CAAC;AAPD,oDAOC;AAED;;;;GAIG;AACH,SAAgB,wBAAwB,CACvC,SAAsE;IAEtE,+EAA+E;IAC/E,4EAA4E;IAC5E,kCAAkC;IAClC,OAAO,SAAS,YAAY,cAAc,CAAC;AAC5C,CAAC;AAPD,4DAOC;AAED;;;;;;;;GAQG;AACH,MAAM,cACL,SAAQ,gCAAwC;IAUhD,YACiB,SAAqB,EACpB,cAA+B;QAEhD,KAAK,EAAE,CAAC;QAHQ,cAAS,GAAT,SAAS,CAAY;QACpB,mBAAc,GAAd,cAAc,CAAiB;QAThC,qBAAgB,GAAG,GAAY,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzD,wBAAmB,GAAG,GAAY,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/D,oBAAe,GAAG,CAAC,KAA+B,EAAW,EAAE,CAC/E,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACb,iBAAY,GAAG,GAAY,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,iBAAY,GAAG,GAAY,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAOjE,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACjD,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,e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AC,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;IAChD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype ConnectionState,\n\ttype ICriticalContainerError,\n} from \"@fluidframework/container-definitions\";\nimport type { IContainer } from \"@fluidframework/container-definitions/internal\";\nimport type { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\n\nimport type { ContainerAttachProps, ContainerSchema, IRootDataObject } from \"./types.js\";\n\n/**\n * Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.\n * @public\n */\nexport type InitialObjects<T extends ContainerSchema> = {\n\t// Construct a LoadableObjectRecord type by enumerating the keys of\n\t// 'ContainerSchema.initialObjects' and inferring the value type of each key.\n\t//\n\t// The '? TChannel : never' is required because infer can only be used in\n\t// a conditional 'extends' expression.\n\t[K in keyof T[\"initialObjects\"]]: T[\"initialObjects\"][K] extends SharedObjectKind<\n\t\tinfer TChannel\n\t>\n\t\t? TChannel\n\t\t: never;\n};\n\n/**\n * Events emitted from {@link IFluidContainer}.\n *\n * @remarks Note: external implementations of this interface are not supported.\n * @sealed\n * @public\n */\nexport interface IFluidContainerEvents extends IEvent {\n\t/**\n\t * Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.\n\t *\n\t * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n\t *\n\t * @see\n\t *\n\t * - {@link IFluidContainer.connectionState}\n\t *\n\t * - {@link IFluidContainer.connect}\n\t */\n\t(event: \"connected\", listener: () => void): void;\n\n\t/**\n\t * Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.\n\t *\n\t * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n\t *\n\t * @see\n\t *\n\t * - {@link IFluidContainer.connectionState}\n\t *\n\t * - {@link IFluidContainer.disconnect}\n\t */\n\t(event: \"disconnected\", listener: () => void): void;\n\n\t/**\n\t * Emitted when all local changes/edits have been acknowledged by the service.\n\t *\n\t * @remarks \"dirty\" event will be emitted when the next local change has been made.\n\t *\n\t * @see {@link IFluidContainer.isDirty}\n\t */\n\t(event: \"saved\", listener: () => void): void;\n\n\t/**\n\t * Emitted when the first local change has been made, following a \"saved\" event.\n\t *\n\t * @remarks \"saved\" event will be emitted once all local changes have been acknowledged by the service.\n\t *\n\t * @see {@link IFluidContainer.isDirty}\n\t */\n\t(event: \"dirty\", listener: () => void): void;\n\n\t/**\n\t * Emitted when the {@link IFluidContainer} is closed, which permanently disables it.\n\t *\n\t * @remarks Listener parameters:\n\t *\n\t * - `error`: If the container was closed due to error (as opposed to an explicit call to\n\t * {@link IFluidContainer.dispose}), this will contain details about the error that caused it.\n\t */\n\t(event: \"disposed\", listener: (error?: ICriticalContainerError) => void);\n}\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 *\n * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.\n *\n * @remarks Note: external implementations of this interface are not supported.\n *\n * @sealed\n * @public\n */\nexport interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>\n\textends IEventProvider<IFluidContainerEvents> {\n\t/**\n\t * Provides the current connected state of the container\n\t */\n\treadonly connectionState: ConnectionState;\n\n\t/**\n\t * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.\n\t *\n\t * @remarks\n\t *\n\t * You should always check the `isDirty` flag before closing the container or navigating away from the page.\n\t * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been\n\t * acknowledged by the service.\n\t *\n\t * A container is considered dirty in the following cases:\n\t *\n\t * 1. The container has been created in the detached state, and either it has not been attached yet or it is\n\t * in the process of being attached (container is in `attaching` state). If container is closed prior to being\n\t * attached, host may never know if the file was created or not.\n\t *\n\t * 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.\n\t * This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the\n\t * service. In some cases this can be due to lack of network connection. If the network connection is down,\n\t * it needs to be restored for the pending changes to be acknowledged.\n\t */\n\treadonly isDirty: boolean;\n\n\t/**\n\t * Whether or not the container is disposed, which permanently disables it.\n\t */\n\treadonly disposed: boolean;\n\n\t/**\n\t * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.\n\t *\n\t * @remarks These data objects and DDSes exist for the lifetime of the container.\n\t */\n\treadonly initialObjects: InitialObjects<TContainerSchema>;\n\n\t/**\n\t * The current attachment state of the container.\n\t *\n\t * @remarks\n\t *\n\t * Once a container has been attached, it remains attached.\n\t * When loading an existing container, it will already be attached.\n\t */\n\treadonly attachState: AttachState;\n\n\t/**\n\t * A newly created container starts detached from the collaborative service.\n\t * Calling `attach()` uploads the new container to the service and connects to the collaborative service.\n\t *\n\t * @remarks\n\t *\n\t * This should only be called when the container is in the\n\t * {@link @fluidframework/container-definitions#AttachState.Detached} state.\n\t *\n\t * This can be determined by observing {@link IFluidContainer.attachState}.\n\t *\n\t * @returns A promise which resolves when the attach is complete, with the string identifier of the container.\n\t */\n\tattach(props?: ContainerAttachProps): Promise<string>;\n\n\t/**\n\t * Attempts to connect the container to the delta stream and process operations.\n\t *\n\t * @throws Will throw an error if connection is unsuccessful.\n\t *\n\t * @remarks\n\t *\n\t * This should only be called when the container is in the\n\t * {@link @fluidframework/container-definitions#(ConnectionState:namespace).Disconnected} state.\n\t *\n\t * This can be determined by observing {@link IFluidContainer.connectionState}.\n\t */\n\tconnect(): void;\n\n\t/**\n\t * Disconnects the container from the delta stream and stops processing operations.\n\t *\n\t * @remarks\n\t *\n\t * This should only be called when the container is in the\n\t * {@link @fluidframework/container-definitions#(ConnectionState:namespace).Connected} state.\n\t *\n\t * This can be determined by observing {@link IFluidContainer.connectionState}.\n\t */\n\tdisconnect(): void;\n\n\t/**\n\t * Create a new data object or Distributed Data Store (DDS) of the specified type.\n\t *\n\t * @param objectClass - The class of the `DataObject` or `SharedObject` to create.\n\t *\n\t * @typeParam T - The class of the `DataObject` or `SharedObject`.\n\t *\n\t * @remarks\n\t *\n\t * In order to share the data object or DDS with other collaborators and retrieve it later,\n\t * store its handle in a collection like a SharedDirectory from your initialObjects.\n\t * It's typically a good idea to set any initial state on the object before doing so,\n\t * as it is both more efficient and helpful to maintain domain model invariants\n\t * (e.g. this approach easily allows state to only be set once).\n\t *\n\t * @example\n\t *\n\t * ```typescript\n\t * const existingDirectory = container.initialObjects.myDirectory;\n\t * const map = await container.create(SharedMap);\n\t * map.set(\"initialState\", \"someValue\");\n\t * existingDirectory.set(\"myMap\", map.handle);\n\t * ```\n\t */\n\tcreate<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T>;\n\n\t/**\n\t * Dispose of the container instance, permanently disabling it.\n\t */\n\tdispose(): void;\n}\n\n/**\n * Internal interface for {@link IFluidContainer}.\n *\n * @internal\n */\nexport interface IFluidContainerInternal {\n\t/**\n\t * The underlying {@link @fluidframework/container-definitions#IContainer}.\n\t *\n\t * @remarks Used to power debug tooling and experimental features.\n\t */\n\treadonly container: IContainer;\n}\n\n/**\n * Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.\n *\n * @internal\n */\nexport function createFluidContainer<\n\tTContainerSchema extends ContainerSchema = ContainerSchema,\n>(props: {\n\tcontainer: IContainer;\n\trootDataObject: IRootDataObject;\n}): IFluidContainer<TContainerSchema> {\n\treturn new FluidContainer<TContainerSchema>(props.container, props.rootDataObject);\n}\n\n/**\n * Check that the provided `container` is an internal {@link IFluidContainerInternal}.\n *\n * @internal\n */\nexport function isInternalFluidContainer<TContainerSchema extends ContainerSchema>(\n\tcontainer: IFluidContainer<TContainerSchema> | IFluidContainerInternal,\n): container is IFluidContainerInternal {\n\t// IFluidContainer is sealed; so we never expect an `IFluidContainer` not to be\n\t// `IFluidContainerInternal` implemented by `FluidContainer`. To be caution,\n\t// we use `instanceof` to confirm.\n\treturn container instanceof FluidContainer;\n}\n\n/**\n * {@link IFluidContainer} implementation.\n *\n * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.\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 */\nclass FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>\n\textends TypedEventEmitter<IFluidContainerEvents>\n\timplements IFluidContainer<TContainerSchema>, IFluidContainerInternal\n{\n\tprivate readonly connectedHandler = (): boolean => this.emit(\"connected\");\n\tprivate readonly disconnectedHandler = (): boolean => this.emit(\"disconnected\");\n\tprivate readonly disposedHandler = (error?: ICriticalContainerError): boolean =>\n\t\tthis.emit(\"disposed\", error);\n\tprivate readonly savedHandler = (): boolean => this.emit(\"saved\");\n\tprivate readonly dirtyHandler = (): boolean => this.emit(\"dirty\");\n\n\tpublic constructor(\n\t\tpublic readonly container: IContainer,\n\t\tprivate readonly rootDataObject: IRootDataObject,\n\t) {\n\t\tsuper();\n\t\tcontainer.on(\"connected\", this.connectedHandler);\n\t\tcontainer.on(\"closed\", this.disposedHandler);\n\t\tcontainer.on(\"disconnected\", this.disconnectedHandler);\n\t\tcontainer.on(\"saved\", this.savedHandler);\n\t\tcontainer.on(\"dirty\", this.dirtyHandler);\n\t}\n\n\tpublic get isDirty(): boolean {\n\t\treturn this.container.isDirty;\n\t}\n\n\tpublic get attachState(): AttachState {\n\t\treturn this.container.attachState;\n\t}\n\n\tpublic get disposed(): boolean {\n\t\treturn this.container.closed;\n\t}\n\n\tpublic get connectionState(): ConnectionState {\n\t\treturn this.container.connectionState;\n\t}\n\n\tpublic get initialObjects(): InitialObjects<TContainerSchema> {\n\t\treturn this.rootDataObject.initialObjects as InitialObjects<TContainerSchema>;\n\t}\n\n\t/**\n\t * Incomplete base implementation of {@link IFluidContainer.attach}.\n\t *\n\t * @remarks\n\t *\n\t * Note: this implementation will unconditionally throw.\n\t * Consumers who rely on this will need to utilize or provide a service specific implementation of this base type\n\t * that provides an implementation of this method.\n\t *\n\t * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,\n\t * but internally this separation is not there.\n\t */\n\tpublic async attach(props?: ContainerAttachProps): Promise<string> {\n\t\tif (this.container.attachState !== AttachState.Detached) {\n\t\t\tthrow new Error(\"Cannot attach container. Container is not in detached state.\");\n\t\t}\n\t\tthrow new Error(\"Cannot attach container. Attach method not provided.\");\n\t}\n\n\tpublic async connect(): Promise<void> {\n\t\tthis.container.connect?.();\n\t}\n\n\tpublic async disconnect(): Promise<void> {\n\t\tthis.container.disconnect?.();\n\t}\n\n\tpublic async create<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T> {\n\t\treturn this.rootDataObject.create(objectClass);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.container.close();\n\t\tthis.container.off(\"connected\", this.connectedHandler);\n\t\tthis.container.off(\"closed\", this.disposedHandler);\n\t\tthis.container.off(\"disconnected\", this.disconnectedHandler);\n\t\tthis.container.off(\"saved\", this.savedHandler);\n\t\tthis.container.off(\"dirty\", this.dirtyHandler);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fluidContainer.js","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,iFAI+C;AAU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IAC/B,CAAC;IAEM,KAAK,CAAC,MAAM,CAA2B,WAAgC;QAC7E,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;IAEM,OAAO;QACb,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;IAChD,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QAC5C,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype ConnectionState,\n\ttype ICriticalContainerError,\n} from \"@fluidframework/container-definitions\";\nimport type { IContainer } from \"@fluidframework/container-definitions/internal\";\nimport type { ContainerExtensionStore } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tFluidObject,\n\tIEvent,\n\tIEventProvider,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\n\nimport type {\n\tContainerAttachProps,\n\tContainerSchema,\n\tIRootDataObject,\n\tIStaticEntryPoint,\n} from \"./types.js\";\n\n/**\n * Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.\n * @public\n */\nexport type InitialObjects<T extends ContainerSchema> = {\n\t// Construct a LoadableObjectRecord type by enumerating the keys of\n\t// 'ContainerSchema.initialObjects' and inferring the value type of each key.\n\t//\n\t// The '? TChannel : never' is required because infer can only be used in\n\t// a conditional 'extends' expression.\n\t[K in keyof T[\"initialObjects\"]]: T[\"initialObjects\"][K] extends SharedObjectKind<\n\t\tinfer TChannel\n\t>\n\t\t? TChannel\n\t\t: never;\n};\n\n/**\n * Events emitted from {@link IFluidContainer}.\n *\n * @remarks Note: external implementations of this interface are not supported.\n * @sealed\n * @public\n */\nexport interface IFluidContainerEvents extends IEvent {\n\t/**\n\t * Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.\n\t *\n\t * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n\t *\n\t * @see\n\t *\n\t * - {@link IFluidContainer.connectionState}\n\t *\n\t * - {@link IFluidContainer.connect}\n\t */\n\t(event: \"connected\", listener: () => void): void;\n\n\t/**\n\t * Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.\n\t *\n\t * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n\t *\n\t * @see\n\t *\n\t * - {@link IFluidContainer.connectionState}\n\t *\n\t * - {@link IFluidContainer.disconnect}\n\t */\n\t(event: \"disconnected\", listener: () => void): void;\n\n\t/**\n\t * Emitted when all local changes/edits have been acknowledged by the service.\n\t *\n\t * @remarks \"dirty\" event will be emitted when the next local change has been made.\n\t *\n\t * @see {@link IFluidContainer.isDirty}\n\t */\n\t(event: \"saved\", listener: () => void): void;\n\n\t/**\n\t * Emitted when the first local change has been made, following a \"saved\" event.\n\t *\n\t * @remarks \"saved\" event will be emitted once all local changes have been acknowledged by the service.\n\t *\n\t * @see {@link IFluidContainer.isDirty}\n\t */\n\t(event: \"dirty\", listener: () => void): void;\n\n\t/**\n\t * Emitted when the {@link IFluidContainer} is closed, which permanently disables it.\n\t *\n\t * @remarks Listener parameters:\n\t *\n\t * - `error`: If the container was closed due to error (as opposed to an explicit call to\n\t * {@link IFluidContainer.dispose}), this will contain details about the error that caused it.\n\t */\n\t(event: \"disposed\", listener: (error?: ICriticalContainerError) => void);\n}\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 *\n * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.\n *\n * @remarks Note: external implementations of this interface are not supported.\n *\n * @sealed\n * @public\n */\nexport interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>\n\textends IEventProvider<IFluidContainerEvents> {\n\t/**\n\t * Provides the current connected state of the container\n\t */\n\treadonly connectionState: ConnectionState;\n\n\t/**\n\t * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.\n\t *\n\t * @remarks\n\t *\n\t * You should always check the `isDirty` flag before closing the container or navigating away from the page.\n\t * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been\n\t * acknowledged by the service.\n\t *\n\t * A container is considered dirty in the following cases:\n\t *\n\t * 1. The container has been created in the detached state, and either it has not been attached yet or it is\n\t * in the process of being attached (container is in `attaching` state). If container is closed prior to being\n\t * attached, host may never know if the file was created or not.\n\t *\n\t * 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.\n\t * This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the\n\t * service. In some cases this can be due to lack of network connection. If the network connection is down,\n\t * it needs to be restored for the pending changes to be acknowledged.\n\t */\n\treadonly isDirty: boolean;\n\n\t/**\n\t * Whether or not the container is disposed, which permanently disables it.\n\t */\n\treadonly disposed: boolean;\n\n\t/**\n\t * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.\n\t *\n\t * @remarks These data objects and DDSes exist for the lifetime of the container.\n\t */\n\treadonly initialObjects: InitialObjects<TContainerSchema>;\n\n\t/**\n\t * The current attachment state of the container.\n\t *\n\t * @remarks\n\t *\n\t * Once a container has been attached, it remains attached.\n\t * When loading an existing container, it will already be attached.\n\t */\n\treadonly attachState: AttachState;\n\n\t/**\n\t * A newly created container starts detached from the collaborative service.\n\t * Calling `attach()` uploads the new container to the service and connects to the collaborative service.\n\t *\n\t * @remarks\n\t *\n\t * This should only be called when the container is in the\n\t * {@link @fluidframework/container-definitions#AttachState.Detached} state.\n\t *\n\t * This can be determined by observing {@link IFluidContainer.attachState}.\n\t *\n\t * @returns A promise which resolves when the attach is complete, with the string identifier of the container.\n\t */\n\tattach(props?: ContainerAttachProps): Promise<string>;\n\n\t/**\n\t * Attempts to connect the container to the delta stream and process operations.\n\t *\n\t * @throws Will throw an error if connection is unsuccessful.\n\t *\n\t * @remarks\n\t *\n\t * This should only be called when the container is in the\n\t * {@link @fluidframework/container-definitions#(ConnectionState:namespace).Disconnected} state.\n\t *\n\t * This can be determined by observing {@link IFluidContainer.connectionState}.\n\t */\n\tconnect(): void;\n\n\t/**\n\t * Disconnects the container from the delta stream and stops processing operations.\n\t *\n\t * @remarks\n\t *\n\t * This should only be called when the container is in the\n\t * {@link @fluidframework/container-definitions#(ConnectionState:namespace).Connected} state.\n\t *\n\t * This can be determined by observing {@link IFluidContainer.connectionState}.\n\t */\n\tdisconnect(): void;\n\n\t/**\n\t * Create a new data object or Distributed Data Store (DDS) of the specified type.\n\t *\n\t * @param objectClass - The class of the `DataObject` or `SharedObject` to create.\n\t *\n\t * @typeParam T - The class of the `DataObject` or `SharedObject`.\n\t *\n\t * @remarks\n\t *\n\t * In order to share the data object or DDS with other collaborators and retrieve it later,\n\t * store its handle in a collection like a SharedDirectory from your initialObjects.\n\t * It's typically a good idea to set any initial state on the object before doing so,\n\t * as it is both more efficient and helpful to maintain domain model invariants\n\t * (e.g. this approach easily allows state to only be set once).\n\t *\n\t * @example\n\t *\n\t * ```typescript\n\t * const existingDirectory = container.initialObjects.myDirectory;\n\t * const map = await container.create(SharedMap);\n\t * map.set(\"initialState\", \"someValue\");\n\t * existingDirectory.set(\"myMap\", map.handle);\n\t * ```\n\t */\n\tcreate<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T>;\n\n\t/**\n\t * Dispose of the container instance, permanently disabling it.\n\t */\n\tdispose(): void;\n}\n\n/**\n * Internal interface for {@link IFluidContainer}.\n *\n * @internal\n */\nexport interface IFluidContainerInternal extends ContainerExtensionStore {\n\t/**\n\t * The underlying {@link @fluidframework/container-definitions#IContainer}.\n\t *\n\t * @remarks Used to power debug tooling and experimental features.\n\t */\n\treadonly container: IContainer;\n\n\t/**\n\t * Upload a blob of data.\n\t * Although it is marked as internal, there is external usage of this function for experimental purposes.\n\t * Please contact yunho-microsoft or vladsud if you need to change it.\n\t * @param blob - blob to be uploaded.\n\t *\n\t * @remarks This method is used to expose uploadBlob to the IFluidContainer level. UploadBlob will upload data to server side (as of now, ODSP only). There is no downloadBlob provided as it is not needed(blob lifetime managed by server).\n\t */\n\tuploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;\n}\n\n/**\n * Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.\n *\n * @internal\n */\nexport async function createFluidContainer<\n\tTContainerSchema extends ContainerSchema = ContainerSchema,\n>(props: {\n\tcontainer: IContainer;\n}): Promise<IFluidContainer<TContainerSchema>> {\n\tconst entryPoint: FluidObject<IStaticEntryPoint> = await props.container.getEntryPoint();\n\tassert(\n\t\tentryPoint.IStaticEntryPoint !== undefined,\n\t\t0xb9e /* entryPoint must be of type IStaticEntryPoint */,\n\t);\n\treturn new FluidContainer<TContainerSchema>(\n\t\tprops.container,\n\t\tentryPoint.IStaticEntryPoint.rootDataObject,\n\t\tentryPoint.IStaticEntryPoint.extensionStore,\n\t);\n}\n\n/**\n * Check that the provided `container` is an internal {@link IFluidContainerInternal}.\n *\n * @internal\n */\nexport function isInternalFluidContainer<TContainerSchema extends ContainerSchema>(\n\tcontainer: IFluidContainer<TContainerSchema> | IFluidContainerInternal,\n): container is IFluidContainerInternal {\n\t// IFluidContainer is sealed; so we never expect an `IFluidContainer` not to be\n\t// `IFluidContainerInternal` implemented by `FluidContainer`. To be caution,\n\t// we use `instanceof` to confirm.\n\treturn container instanceof FluidContainer;\n}\n\n/**\n * {@link IFluidContainer} implementation.\n *\n * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.\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 */\nclass FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>\n\textends TypedEventEmitter<IFluidContainerEvents>\n\timplements IFluidContainer<TContainerSchema>, IFluidContainerInternal\n{\n\tprivate readonly connectedHandler = (): boolean => this.emit(\"connected\");\n\tprivate readonly disconnectedHandler = (): boolean => this.emit(\"disconnected\");\n\tprivate readonly disposedHandler = (error?: ICriticalContainerError): boolean =>\n\t\tthis.emit(\"disposed\", error);\n\tprivate readonly savedHandler = (): boolean => this.emit(\"saved\");\n\tprivate readonly dirtyHandler = (): boolean => this.emit(\"dirty\");\n\tpublic readonly acquireExtension: ContainerExtensionStore[\"acquireExtension\"];\n\n\tpublic constructor(\n\t\tpublic readonly container: IContainer,\n\t\tprivate readonly rootDataObject: IRootDataObject,\n\t\textensionStore: ContainerExtensionStore,\n\t) {\n\t\tsuper();\n\t\tthis.acquireExtension = extensionStore.acquireExtension.bind(extensionStore);\n\t\tcontainer.on(\"connected\", this.connectedHandler);\n\t\tcontainer.on(\"closed\", this.disposedHandler);\n\t\tcontainer.on(\"disconnected\", this.disconnectedHandler);\n\t\tcontainer.on(\"saved\", this.savedHandler);\n\t\tcontainer.on(\"dirty\", this.dirtyHandler);\n\t}\n\n\tpublic get isDirty(): boolean {\n\t\treturn this.container.isDirty;\n\t}\n\n\tpublic get attachState(): AttachState {\n\t\treturn this.container.attachState;\n\t}\n\n\tpublic get disposed(): boolean {\n\t\treturn this.container.closed;\n\t}\n\n\tpublic get connectionState(): ConnectionState {\n\t\treturn this.container.connectionState;\n\t}\n\n\tpublic get initialObjects(): InitialObjects<TContainerSchema> {\n\t\treturn this.rootDataObject.initialObjects as InitialObjects<TContainerSchema>;\n\t}\n\n\t/**\n\t * Incomplete base implementation of {@link IFluidContainer.attach}.\n\t *\n\t * @remarks\n\t *\n\t * Note: this implementation will unconditionally throw.\n\t * Consumers who rely on this will need to utilize or provide a service specific implementation of this base type\n\t * that provides an implementation of this method.\n\t *\n\t * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,\n\t * but internally this separation is not there.\n\t */\n\tpublic async attach(props?: ContainerAttachProps): Promise<string> {\n\t\tif (this.container.attachState !== AttachState.Detached) {\n\t\t\tthrow new Error(\"Cannot attach container. Container is not in detached state.\");\n\t\t}\n\t\tthrow new Error(\"Cannot attach container. Attach method not provided.\");\n\t}\n\n\tpublic async connect(): Promise<void> {\n\t\tthis.container.connect?.();\n\t}\n\n\tpublic async disconnect(): Promise<void> {\n\t\tthis.container.disconnect?.();\n\t}\n\n\tpublic async create<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T> {\n\t\treturn this.rootDataObject.create(objectClass);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.container.close();\n\t\tthis.container.off(\"connected\", this.connectedHandler);\n\t\tthis.container.off(\"closed\", this.disposedHandler);\n\t\tthis.container.off(\"disconnected\", this.disconnectedHandler);\n\t\tthis.container.off(\"saved\", this.savedHandler);\n\t\tthis.container.off(\"dirty\", this.dirtyHandler);\n\t}\n\n\tpublic async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {\n\t\treturn this.rootDataObject.uploadBlob(blob);\n\t}\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
export { createFluidContainer, isInternalFluidContainer, type IFluidContainer, type IFluidContainerEvents, type IFluidContainerInternal, type InitialObjects, } from "./fluidContainer.js";
|
|
11
11
|
export { createDOProviderContainerRuntimeFactory } from "./rootDataObject.js";
|
|
12
12
|
export { createServiceAudience } from "./serviceAudience.js";
|
|
13
|
-
export type { CompatibilityMode, ContainerSchema, ContainerAttachProps, IConnection, IMember,
|
|
13
|
+
export type { CompatibilityMode, ContainerSchema, ContainerAttachProps, IConnection, IMember, IServiceAudience, IServiceAudienceEvents, MemberChangedListener, Myself, } from "./types.js";
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,YAAY,EACX,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,OAAO,EACP,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,YAAY,EACX,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,MAAM,GACN,MAAM,YAAY,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;GAIG;AAEH,yDAO6B;AAN5B,yHAAA,oBAAoB,OAAA;AACpB,6HAAA,wBAAwB,OAAA;AAMzB,yDAA8E;AAArE,4IAAA,uCAAuC,OAAA;AAChD,2DAA6D;AAApD,2HAAA,qBAAqB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Provides a simple and powerful way to consume collaborative Fluid data.\n *\n * @packageDocumentation\n */\n\nexport {\n\tcreateFluidContainer,\n\tisInternalFluidContainer,\n\ttype IFluidContainer,\n\ttype IFluidContainerEvents,\n\ttype IFluidContainerInternal,\n\ttype InitialObjects,\n} from \"./fluidContainer.js\";\nexport { createDOProviderContainerRuntimeFactory } from \"./rootDataObject.js\";\nexport { createServiceAudience } from \"./serviceAudience.js\";\nexport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tContainerAttachProps,\n\tIConnection,\n\tIMember,\n\
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;GAIG;AAEH,yDAO6B;AAN5B,yHAAA,oBAAoB,OAAA;AACpB,6HAAA,wBAAwB,OAAA;AAMzB,yDAA8E;AAArE,4IAAA,uCAAuC,OAAA;AAChD,2DAA6D;AAApD,2HAAA,qBAAqB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Provides a simple and powerful way to consume collaborative Fluid data.\n *\n * @packageDocumentation\n */\n\nexport {\n\tcreateFluidContainer,\n\tisInternalFluidContainer,\n\ttype IFluidContainer,\n\ttype IFluidContainerEvents,\n\ttype IFluidContainerInternal,\n\ttype InitialObjects,\n} from \"./fluidContainer.js\";\nexport { createDOProviderContainerRuntimeFactory } from \"./rootDataObject.js\";\nexport { createServiceAudience } from \"./serviceAudience.js\";\nexport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tContainerAttachProps,\n\tIConnection,\n\tIMember,\n\tIServiceAudience,\n\tIServiceAudienceEvents,\n\tMemberChangedListener,\n\tMyself,\n} from \"./types.js\";\n"]}
|
package/dist/rootDataObject.d.ts
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
|
|
6
|
+
import { type IContainerRuntimeOptions, type MinimumVersionForCollab } from "@fluidframework/container-runtime/internal";
|
|
6
7
|
import type { IFluidDataStoreRegistry } from "@fluidframework/runtime-definitions/internal";
|
|
7
8
|
import type { CompatibilityMode, ContainerSchema } from "./types.js";
|
|
8
9
|
/**
|
|
9
10
|
* Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers
|
|
10
|
-
* with
|
|
11
|
-
* and initial objects are configured based on the provided
|
|
11
|
+
* with an entry point containing single IRootDataObject (entry point is opaque to caller),
|
|
12
|
+
* where the root data object's registry and initial objects are configured based on the provided
|
|
13
|
+
* schema (and optionally, data store registry).
|
|
12
14
|
*
|
|
13
15
|
* @internal
|
|
14
16
|
*/
|
|
@@ -26,5 +28,17 @@ export declare function createDOProviderContainerRuntimeFactory(props: {
|
|
|
26
28
|
* If not provided, one will be created based on the schema.
|
|
27
29
|
*/
|
|
28
30
|
rootDataStoreRegistry?: IFluidDataStoreRegistry;
|
|
31
|
+
/**
|
|
32
|
+
* Optional overrides for the container runtime options.
|
|
33
|
+
* If not provided, only the default options for the given compatibilityMode will be used.
|
|
34
|
+
*/
|
|
35
|
+
runtimeOptionOverrides?: Partial<IContainerRuntimeOptions>;
|
|
36
|
+
/**
|
|
37
|
+
* Optional override for minimum version for collab.
|
|
38
|
+
* If not provided, the default for the given compatibilityMode will be used.
|
|
39
|
+
* @remarks
|
|
40
|
+
* This is useful when runtime options are overridden and change the minimum version for collab.
|
|
41
|
+
*/
|
|
42
|
+
minVersionForCollabOverride?: MinimumVersionForCollab;
|
|
29
43
|
}): IRuntimeFactory;
|
|
30
44
|
//# sourceMappingURL=rootDataObject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,MAAM,4CAA4C,CAAC;AAcpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAO5F,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EAMf,MAAM,YAAY,CAAC;AA6IpB;;;;;;;GAOG;AACH,wBAAgB,uCAAuC,CAAC,KAAK,EAAE;IAC9D;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IACxB;;OAEG;IACH,iBAAiB,EAAE,iBAAiB,CAAC;IACrC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,uBAAuB,CAAC;IAChD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC3D;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,uBAAuB,CAAC;CACtD,GAAG,eAAe,CAalB"}
|
package/dist/rootDataObject.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.createDOProviderContainerRuntimeFactory = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/aqueduct/internal");
|
|
9
9
|
const internal_2 = require("@fluidframework/container-runtime/internal");
|
|
10
|
+
const internal_3 = require("@fluidframework/core-utils/internal");
|
|
10
11
|
const compatibilityConfiguration_js_1 = require("./compatibilityConfiguration.js");
|
|
11
12
|
const utils_js_1 = require("./utils.js");
|
|
12
13
|
/**
|
|
@@ -26,7 +27,7 @@ class RootDataObject extends internal_1.DataObject {
|
|
|
26
27
|
this.initialObjectsDirKey = "initial-objects-key";
|
|
27
28
|
this._initialObjects = {};
|
|
28
29
|
}
|
|
29
|
-
get
|
|
30
|
+
get RootDataObject() {
|
|
30
31
|
return this;
|
|
31
32
|
}
|
|
32
33
|
get initialObjectsDir() {
|
|
@@ -74,18 +75,12 @@ class RootDataObject extends internal_1.DataObject {
|
|
|
74
75
|
}
|
|
75
76
|
await Promise.all(loadInitialObjectsP);
|
|
76
77
|
}
|
|
77
|
-
/**
|
|
78
|
-
* {@inheritDoc IRootDataObject.initialObjects}
|
|
79
|
-
*/
|
|
80
78
|
get initialObjects() {
|
|
81
79
|
if (Object.keys(this._initialObjects).length === 0) {
|
|
82
80
|
throw new Error("Initial Objects were not correctly initialized");
|
|
83
81
|
}
|
|
84
82
|
return this._initialObjects;
|
|
85
83
|
}
|
|
86
|
-
/**
|
|
87
|
-
* {@inheritDoc IRootDataObject.create}
|
|
88
|
-
*/
|
|
89
84
|
async create(objectClass) {
|
|
90
85
|
const internal = objectClass;
|
|
91
86
|
if ((0, utils_js_1.isDataObjectKind)(internal)) {
|
|
@@ -96,6 +91,9 @@ class RootDataObject extends internal_1.DataObject {
|
|
|
96
91
|
}
|
|
97
92
|
throw new Error("Could not create new Fluid object because an unknown object was passed");
|
|
98
93
|
}
|
|
94
|
+
async uploadBlob(blob) {
|
|
95
|
+
return this.runtime.uploadBlob(blob);
|
|
96
|
+
}
|
|
99
97
|
async createDataObject(dataObjectClass) {
|
|
100
98
|
const factory = dataObjectClass.factory;
|
|
101
99
|
const packagePath = [...this.context.packagePath, factory.type];
|
|
@@ -112,20 +110,40 @@ class RootDataObject extends internal_1.DataObject {
|
|
|
112
110
|
const rootDataStoreId = "rootDOId";
|
|
113
111
|
/**
|
|
114
112
|
* Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers
|
|
115
|
-
* with
|
|
116
|
-
* and initial objects are configured based on the provided
|
|
113
|
+
* with an entry point containing single IRootDataObject (entry point is opaque to caller),
|
|
114
|
+
* where the root data object's registry and initial objects are configured based on the provided
|
|
115
|
+
* schema (and optionally, data store registry).
|
|
117
116
|
*
|
|
118
117
|
* @internal
|
|
119
118
|
*/
|
|
120
119
|
function createDOProviderContainerRuntimeFactory(props) {
|
|
121
120
|
const [registryEntries, sharedObjects] = (0, utils_js_1.parseDataObjectsFromSharedObjects)(props.schema);
|
|
122
121
|
const registry = props.rootDataStoreRegistry ?? new internal_2.FluidDataStoreRegistry(registryEntries);
|
|
123
|
-
return new DOProviderContainerRuntimeFactory(props.schema, props.compatibilityMode, new RootDataObjectFactory(sharedObjects, registry)
|
|
122
|
+
return new DOProviderContainerRuntimeFactory(props.schema, props.compatibilityMode, new RootDataObjectFactory(sharedObjects, registry), {
|
|
123
|
+
runtimeOptions: props.runtimeOptionOverrides,
|
|
124
|
+
minVersionForCollab: props.minVersionForCollabOverride,
|
|
125
|
+
});
|
|
124
126
|
}
|
|
125
127
|
exports.createDOProviderContainerRuntimeFactory = createDOProviderContainerRuntimeFactory;
|
|
128
|
+
function makeFluidObject(object, providerKey) {
|
|
129
|
+
return Object.defineProperty(object, providerKey, { value: object });
|
|
130
|
+
}
|
|
131
|
+
async function provideEntryPoint(containerRuntime) {
|
|
132
|
+
const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
|
|
133
|
+
if (entryPoint === undefined) {
|
|
134
|
+
throw new Error(`default dataStore [${rootDataStoreId}] must exist`);
|
|
135
|
+
}
|
|
136
|
+
const rootDataObject = (await entryPoint.get())
|
|
137
|
+
.RootDataObject;
|
|
138
|
+
(0, internal_3.assert)(rootDataObject !== undefined, 0xb9f /* entryPoint must be of type RootDataObject */);
|
|
139
|
+
return makeFluidObject({
|
|
140
|
+
rootDataObject,
|
|
141
|
+
extensionStore: containerRuntime,
|
|
142
|
+
}, "IStaticEntryPoint");
|
|
143
|
+
}
|
|
126
144
|
/**
|
|
127
|
-
* Factory for Container Runtime instances that provide a
|
|
128
|
-
* as their entry point.
|
|
145
|
+
* Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}
|
|
146
|
+
* (containing single {@link IRootDataObject}) as their entry point.
|
|
129
147
|
*/
|
|
130
148
|
class DOProviderContainerRuntimeFactory extends internal_1.BaseContainerRuntimeFactory {
|
|
131
149
|
/**
|
|
@@ -142,26 +160,20 @@ class DOProviderContainerRuntimeFactory extends internal_1.BaseContainerRuntimeF
|
|
|
142
160
|
* @param compatibilityMode - Compatibility mode
|
|
143
161
|
* @param rootDataObjectFactory - A factory that can construct the root data object.
|
|
144
162
|
*/
|
|
145
|
-
constructor(schema, compatibilityMode, rootDataObjectFactory) {
|
|
146
|
-
const provideEntryPoint = async (containerRuntime) => {
|
|
147
|
-
const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
|
|
148
|
-
if (entryPoint === undefined) {
|
|
149
|
-
throw new Error(`default dataStore [${rootDataStoreId}] must exist`);
|
|
150
|
-
}
|
|
151
|
-
return entryPoint.get();
|
|
152
|
-
};
|
|
163
|
+
constructor(schema, compatibilityMode, rootDataObjectFactory, overrides) {
|
|
153
164
|
super({
|
|
154
165
|
registryEntries: [rootDataObjectFactory.registryEntry],
|
|
155
|
-
runtimeOptions:
|
|
166
|
+
runtimeOptions: {
|
|
167
|
+
...compatibilityConfiguration_js_1.compatibilityModeRuntimeOptions[compatibilityMode],
|
|
168
|
+
...overrides?.runtimeOptions,
|
|
169
|
+
},
|
|
156
170
|
provideEntryPoint,
|
|
157
|
-
minVersionForCollab:
|
|
171
|
+
minVersionForCollab: overrides?.minVersionForCollab ??
|
|
172
|
+
compatibilityModeToMinVersionForCollab[compatibilityMode],
|
|
158
173
|
});
|
|
159
174
|
this.rootDataObjectFactory = rootDataObjectFactory;
|
|
160
175
|
this.initialObjects = schema.initialObjects;
|
|
161
176
|
}
|
|
162
|
-
/**
|
|
163
|
-
* {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}
|
|
164
|
-
*/
|
|
165
177
|
async containerInitializingFirstTime(runtime) {
|
|
166
178
|
// The first time we create the container we create the RootDataObject
|
|
167
179
|
await this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAK2C;AAE3C,yEAGoD;AAWpD,mFAAkF;AASlF,yCAIoB;AAEpB;;GAEG;AACH,MAAM,sCAAsC,GAAG;IAC9C,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,OAAO;CAC0D,CAAC;AAcxE;;;GAGG;AACH,MAAM,cACL,SAAQ,qBAAiD;IAD1D;;QAIkB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IAmG7D,CAAC;IAjGA,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAY,iBAAiB;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAA0B;QAC/D,IAAI,CAAC,IAAI,CA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,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,eAAe,EAAE,OAAO,EAAE;YAC7E,cAAc,EAAE,IAAI,CAAC,cAAc;SACnC,CAAC,CAAC;IACJ,CAAC;CACD;AAED;;GAEG;AACH,MAAM,qBAAsB,SAAQ,4BAGnC;IACA,YACC,gBAA4C,EAAE,EAC7B,iBAA0C;QAE3D,2GAA2G;QAC3G,+GAA+G;QAC/G,KAAK,CAAC;YACL,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,cAAc;YACpB,aAAa;SACb,CAAC,CAAC;QARc,sBAAiB,GAAjB,iBAAiB,CAAyB;IAS5D,CAAC;IAED,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAC/B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tBaseContainerRuntimeFactory,\n\tDataObject,\n\ttype DataObjectKind,\n\tDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tFluidDataStoreRegistry,\n\ttype MinimumVersionForCollab,\n} from \"@fluidframework/container-runtime/internal\";\nimport type { IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { FluidObject, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IDirectory } from \"@fluidframework/map/internal\";\nimport type { IFluidDataStoreRegistry } from \"@fluidframework/runtime-definitions/internal\";\nimport type {\n\tISharedObjectKind,\n\tSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport { compatibilityModeRuntimeOptions } from \"./compatibilityConfiguration.js\";\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tIRootDataObject,\n\tLoadableObjectKind,\n\tLoadableObjectKindRecord,\n\tLoadableObjectRecord,\n} from \"./types.js\";\nimport {\n\tisDataObjectKind,\n\tisSharedObjectKind,\n\tparseDataObjectsFromSharedObjects,\n} from \"./utils.js\";\n\n/**\n * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.\n */\nconst compatibilityModeToMinVersionForCollab = {\n\t\"1\": \"1.0.0\",\n\t\"2\": \"2.0.0\",\n} as const satisfies Record<CompatibilityMode, MinimumVersionForCollab>;\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}.\n */\ninterface RootDataObjectProps {\n\t/**\n\t * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n\t *\n\t * @see {@link RootDataObject.initializingFirstTime}\n\t */\n\treadonly initialObjects: LoadableObjectKindRecord;\n}\n\n/**\n * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.\n * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.\n */\nclass RootDataObject\n\textends DataObject<{ InitialState: RootDataObjectProps }>\n\timplements IRootDataObject\n{\n\tprivate readonly initialObjectsDirKey = \"initial-objects-key\";\n\tprivate readonly _initialObjects: LoadableObjectRecord = {};\n\n\tpublic get IRootDataObject(): IRootDataObject {\n\t\treturn this;\n\t}\n\n\tprivate get initialObjectsDir(): IDirectory {\n\t\tconst dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n\t\tif (dir === undefined) {\n\t\t\tthrow new Error(\"InitialObjects sub-directory was not initialized\");\n\t\t}\n\t\treturn dir;\n\t}\n\n\t/**\n\t * The first time this object is initialized, creates each object identified in\n\t * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n\t */\n\tprotected async initializingFirstTime(props: RootDataObjectProps): Promise<void> {\n\t\tthis.root.createSubDirectory(this.initialObjectsDirKey);\n\n\t\t// Create initial objects provided by the developer\n\t\tconst initialObjectsP: Promise<void>[] = [];\n\t\tfor (const [id, objectClass] of Object.entries(props.initialObjects)) {\n\t\t\tconst createObject = async (): Promise<void> => {\n\t\t\t\tconst obj = await this.create<IFluidLoadable>(\n\t\t\t\t\tobjectClass as SharedObjectKind<IFluidLoadable>,\n\t\t\t\t);\n\t\t\t\tthis.initialObjectsDir.set(id, obj.handle);\n\t\t\t};\n\t\t\tinitialObjectsP.push(createObject());\n\t\t}\n\n\t\tawait Promise.all(initialObjectsP);\n\t}\n\n\t/**\n\t * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n\t * accessed immediately.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n\t */\n\tprotected async hasInitialized(): Promise<void> {\n\t\t// We will always load the initial objects so they are available to the developer\n\t\tconst loadInitialObjectsP: Promise<void>[] = [];\n\t\tfor (const [key, value] of this.initialObjectsDir.entries()) {\n\t\t\tconst loadDir = async (): Promise<void> => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\tconst obj: unknown = await value.get();\n\t\t\t\tObject.assign(this._initialObjects, { [key]: obj });\n\t\t\t};\n\t\t\tloadInitialObjectsP.push(loadDir());\n\t\t}\n\n\t\tawait Promise.all(loadInitialObjectsP);\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.initialObjects}\n\t */\n\tpublic get initialObjects(): LoadableObjectRecord {\n\t\tif (Object.keys(this._initialObjects).length === 0) {\n\t\t\tthrow new Error(\"Initial Objects were not correctly initialized\");\n\t\t}\n\t\treturn this._initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.create}\n\t */\n\tpublic async create<T>(objectClass: SharedObjectKind<T>): Promise<T> {\n\t\tconst internal = objectClass as unknown as LoadableObjectKind<T & IFluidLoadable>;\n\t\tif (isDataObjectKind(internal)) {\n\t\t\treturn this.createDataObject(internal);\n\t\t} else if (isSharedObjectKind(internal)) {\n\t\t\treturn this.createSharedObject(internal);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tprivate async createDataObject<T extends IFluidLoadable>(\n\t\tdataObjectClass: DataObjectKind<T>,\n\t): Promise<T> {\n\t\tconst factory = dataObjectClass.factory;\n\t\tconst packagePath = [...this.context.packagePath, factory.type];\n\t\tconst dataStore = await this.context.containerRuntime.createDataStore(packagePath);\n\t\tconst entryPoint = await dataStore.entryPoint.get();\n\t\treturn entryPoint as T;\n\t}\n\n\tprivate createSharedObject<T extends IFluidLoadable>(\n\t\tsharedObjectClass: ISharedObjectKind<T>,\n\t): T {\n\t\tconst factory = sharedObjectClass.getFactory();\n\t\tconst obj = this.runtime.createChannel(undefined, factory.type);\n\t\treturn obj as unknown as T;\n\t}\n}\n\nconst rootDataStoreId = \"rootDOId\";\n\n/**\n * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers\n * with a single {@link IRootDataObject} as their entry point, where the root data object's registry\n * and initial objects are configured based on the provided schema (and optionally, data store registry).\n *\n * @internal\n */\nexport function createDOProviderContainerRuntimeFactory(props: {\n\t/**\n\t * The schema for the container.\n\t */\n\tschema: ContainerSchema;\n\t/**\n\t * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.\n\t */\n\tcompatibilityMode: CompatibilityMode;\n\t/**\n\t * Optional registry of data stores to pass to the DataObject factory.\n\t * If not provided, one will be created based on the schema.\n\t */\n\trootDataStoreRegistry?: IFluidDataStoreRegistry;\n}): IRuntimeFactory {\n\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(props.schema);\n\tconst registry = props.rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);\n\n\treturn new DOProviderContainerRuntimeFactory(\n\t\tprops.schema,\n\t\tprops.compatibilityMode,\n\t\tnew RootDataObjectFactory(sharedObjects, registry),\n\t);\n}\n\n/**\n * Factory for Container Runtime instances that provide a single {@link IRootDataObject}\n * as their entry point.\n */\nclass DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n\tprivate readonly rootDataObjectFactory: DataObjectFactory<\n\t\tRootDataObject,\n\t\t{\n\t\t\tInitialState: RootDataObjectProps;\n\t\t}\n\t>;\n\n\tprivate readonly initialObjects: LoadableObjectKindRecord;\n\n\t/**\n\t * Create a new instance of a container runtime factory.\n\t * @remarks\n\t * The caller is responsible for making sure that the provided root data object factory is configured\n\t * appropriately based on the schema of the container (e.g. its registry entries contain all the\n\t * DataStore/DDS types that the schema says can be constructed).\n\t *\n\t * Most scenarios probably want to use {@link createDOProviderContainerRuntimeFactory} instead,\n\t * since it can take care of constructing the root data object factory based on the schema.\n\t *\n\t * @param schema - The schema for the container\n\t * @param compatibilityMode - Compatibility mode\n\t * @param rootDataObjectFactory - A factory that can construct the root data object.\n\t */\n\tpublic constructor(\n\t\tschema: ContainerSchema,\n\t\tcompatibilityMode: CompatibilityMode,\n\t\trootDataObjectFactory: DataObjectFactory<\n\t\t\tRootDataObject,\n\t\t\t{ InitialState: RootDataObjectProps }\n\t\t>,\n\t) {\n\t\tconst provideEntryPoint = async (\n\t\t\tcontainerRuntime: IContainerRuntime,\n\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\t): Promise<FluidObject> => {\n\t\t\tconst entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\tif (entryPoint === undefined) {\n\t\t\t\tthrow new Error(`default dataStore [${rootDataStoreId}] must exist`);\n\t\t\t}\n\t\t\treturn entryPoint.get();\n\t\t};\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\truntimeOptions: compatibilityModeRuntimeOptions[compatibilityMode],\n\t\t\tprovideEntryPoint,\n\t\t\tminVersionForCollab: compatibilityModeToMinVersionForCollab[compatibilityMode],\n\t\t});\n\t\tthis.rootDataObjectFactory = rootDataObjectFactory;\n\t\tthis.initialObjects = schema.initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}\n\t */\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\t// The first time we create the container we create the RootDataObject\n\t\tawait this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {\n\t\t\tinitialObjects: this.initialObjects,\n\t\t});\n\t}\n}\n\n/**\n * Factory that creates instances of a root data object.\n */\nclass RootDataObjectFactory extends DataObjectFactory<\n\tRootDataObject,\n\t{ InitialState: RootDataObjectProps }\n> {\n\tpublic constructor(\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\tprivate readonly dataStoreRegistry: IFluidDataStoreRegistry,\n\t) {\n\t\t// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,\n\t\t// and instead we override the necessary methods in this class to use the registry received in the constructor.\n\t\tsuper({\n\t\t\ttype: \"rootDO\",\n\t\t\tctor: RootDataObject,\n\t\t\tsharedObjects,\n\t\t});\n\t}\n\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.dataStoreRegistry;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAK2C;AAE3C,yEAIoD;AAWpD,kEAA6D;AAS7D,mFAAkF;AAUlF,yCAIoB;AAEpB;;GAEG;AACH,MAAM,sCAAsC,GAAG;IAC9C,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,OAAO;CAC0D,CAAC;AAkBxE;;;GAGG;AACH,MAAM,cACL,SAAQ,qBAAiD;IAD1D;;QAIkB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IAiG7D,CAAC;IA/FA,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAY,iBAAiB;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,I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B,CAAC;IAC/B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tBaseContainerRuntimeFactory,\n\tDataObject,\n\ttype DataObjectKind,\n\tDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tFluidDataStoreRegistry,\n\ttype IContainerRuntimeOptions,\n\ttype MinimumVersionForCollab,\n} from \"@fluidframework/container-runtime/internal\";\nimport type {\n\tIContainerRuntime,\n\tIContainerRuntimeInternal,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tFluidObject,\n\tFluidObjectKeys,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IDirectory } from \"@fluidframework/map/internal\";\nimport type { IFluidDataStoreRegistry } from \"@fluidframework/runtime-definitions/internal\";\nimport type {\n\tISharedObjectKind,\n\tSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport { compatibilityModeRuntimeOptions } from \"./compatibilityConfiguration.js\";\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tIRootDataObject,\n\tIStaticEntryPoint,\n\tLoadableObjectKind,\n\tLoadableObjectKindRecord,\n\tLoadableObjectRecord,\n} from \"./types.js\";\nimport {\n\tisDataObjectKind,\n\tisSharedObjectKind,\n\tparseDataObjectsFromSharedObjects,\n} from \"./utils.js\";\n\n/**\n * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.\n */\nconst compatibilityModeToMinVersionForCollab = {\n\t\"1\": \"1.0.0\",\n\t\"2\": \"2.0.0\",\n} as const satisfies Record<CompatibilityMode, MinimumVersionForCollab>;\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}.\n */\ninterface RootDataObjectProps {\n\t/**\n\t * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n\t *\n\t * @see {@link RootDataObject.initializingFirstTime}\n\t */\n\treadonly initialObjects: LoadableObjectKindRecord;\n}\n\ninterface IProvideRootDataObject {\n\treadonly RootDataObject: RootDataObject;\n}\n\n/**\n * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.\n * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.\n */\nclass RootDataObject\n\textends DataObject<{ InitialState: RootDataObjectProps }>\n\timplements IRootDataObject, IProvideRootDataObject\n{\n\tprivate readonly initialObjectsDirKey = \"initial-objects-key\";\n\tprivate readonly _initialObjects: LoadableObjectRecord = {};\n\n\tpublic get RootDataObject(): RootDataObject {\n\t\treturn this;\n\t}\n\n\tprivate get initialObjectsDir(): IDirectory {\n\t\tconst dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n\t\tif (dir === undefined) {\n\t\t\tthrow new Error(\"InitialObjects sub-directory was not initialized\");\n\t\t}\n\t\treturn dir;\n\t}\n\n\t/**\n\t * The first time this object is initialized, creates each object identified in\n\t * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n\t */\n\tprotected async initializingFirstTime(props: RootDataObjectProps): Promise<void> {\n\t\tthis.root.createSubDirectory(this.initialObjectsDirKey);\n\n\t\t// Create initial objects provided by the developer\n\t\tconst initialObjectsP: Promise<void>[] = [];\n\t\tfor (const [id, objectClass] of Object.entries(props.initialObjects)) {\n\t\t\tconst createObject = async (): Promise<void> => {\n\t\t\t\tconst obj = await this.create<IFluidLoadable>(\n\t\t\t\t\tobjectClass as SharedObjectKind<IFluidLoadable>,\n\t\t\t\t);\n\t\t\t\tthis.initialObjectsDir.set(id, obj.handle);\n\t\t\t};\n\t\t\tinitialObjectsP.push(createObject());\n\t\t}\n\n\t\tawait Promise.all(initialObjectsP);\n\t}\n\n\t/**\n\t * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n\t * accessed immediately.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n\t */\n\tprotected async hasInitialized(): Promise<void> {\n\t\t// We will always load the initial objects so they are available to the developer\n\t\tconst loadInitialObjectsP: Promise<void>[] = [];\n\t\tfor (const [key, value] of this.initialObjectsDir.entries()) {\n\t\t\tconst loadDir = async (): Promise<void> => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\tconst obj: unknown = await value.get();\n\t\t\t\tObject.assign(this._initialObjects, { [key]: obj });\n\t\t\t};\n\t\t\tloadInitialObjectsP.push(loadDir());\n\t\t}\n\n\t\tawait Promise.all(loadInitialObjectsP);\n\t}\n\n\tpublic get initialObjects(): LoadableObjectRecord {\n\t\tif (Object.keys(this._initialObjects).length === 0) {\n\t\t\tthrow new Error(\"Initial Objects were not correctly initialized\");\n\t\t}\n\t\treturn this._initialObjects;\n\t}\n\n\tpublic async create<T>(objectClass: SharedObjectKind<T>): Promise<T> {\n\t\tconst internal = objectClass as unknown as LoadableObjectKind<T & IFluidLoadable>;\n\t\tif (isDataObjectKind(internal)) {\n\t\t\treturn this.createDataObject(internal);\n\t\t} else if (isSharedObjectKind(internal)) {\n\t\t\treturn this.createSharedObject(internal);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tpublic async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {\n\t\treturn this.runtime.uploadBlob(blob);\n\t}\n\n\tprivate async createDataObject<T extends IFluidLoadable>(\n\t\tdataObjectClass: DataObjectKind<T>,\n\t): Promise<T> {\n\t\tconst factory = dataObjectClass.factory;\n\t\tconst packagePath = [...this.context.packagePath, factory.type];\n\t\tconst dataStore = await this.context.containerRuntime.createDataStore(packagePath);\n\t\tconst entryPoint = await dataStore.entryPoint.get();\n\t\treturn entryPoint as T;\n\t}\n\n\tprivate createSharedObject<T extends IFluidLoadable>(\n\t\tsharedObjectClass: ISharedObjectKind<T>,\n\t): T {\n\t\tconst factory = sharedObjectClass.getFactory();\n\t\tconst obj = this.runtime.createChannel(undefined, factory.type);\n\t\treturn obj as unknown as T;\n\t}\n}\n\nconst rootDataStoreId = \"rootDOId\";\n\n/**\n * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers\n * with an entry point containing single IRootDataObject (entry point is opaque to caller),\n * where the root data object's registry and initial objects are configured based on the provided\n * schema (and optionally, data store registry).\n *\n * @internal\n */\nexport function createDOProviderContainerRuntimeFactory(props: {\n\t/**\n\t * The schema for the container.\n\t */\n\tschema: ContainerSchema;\n\t/**\n\t * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.\n\t */\n\tcompatibilityMode: CompatibilityMode;\n\t/**\n\t * Optional registry of data stores to pass to the DataObject factory.\n\t * If not provided, one will be created based on the schema.\n\t */\n\trootDataStoreRegistry?: IFluidDataStoreRegistry;\n\t/**\n\t * Optional overrides for the container runtime options.\n\t * If not provided, only the default options for the given compatibilityMode will be used.\n\t */\n\truntimeOptionOverrides?: Partial<IContainerRuntimeOptions>;\n\t/**\n\t * Optional override for minimum version for collab.\n\t * If not provided, the default for the given compatibilityMode will be used.\n\t * @remarks\n\t * This is useful when runtime options are overridden and change the minimum version for collab.\n\t */\n\tminVersionForCollabOverride?: MinimumVersionForCollab;\n}): IRuntimeFactory {\n\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(props.schema);\n\tconst registry = props.rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);\n\n\treturn new DOProviderContainerRuntimeFactory(\n\t\tprops.schema,\n\t\tprops.compatibilityMode,\n\t\tnew RootDataObjectFactory(sharedObjects, registry),\n\t\t{\n\t\t\truntimeOptions: props.runtimeOptionOverrides,\n\t\t\tminVersionForCollab: props.minVersionForCollabOverride,\n\t\t},\n\t);\n}\n\nfunction makeFluidObject<T extends object, K extends FluidObjectKeys<T> = FluidObjectKeys<T>>(\n\tobject: Omit<T, K>,\n\tproviderKey: K,\n): T {\n\treturn Object.defineProperty(object, providerKey, { value: object }) as T;\n}\n\nasync function provideEntryPoint(\n\tcontainerRuntime: IContainerRuntime,\n): Promise<IStaticEntryPoint> {\n\tconst entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\tif (entryPoint === undefined) {\n\t\tthrow new Error(`default dataStore [${rootDataStoreId}] must exist`);\n\t}\n\tconst rootDataObject = ((await entryPoint.get()) as FluidObject<RootDataObject>)\n\t\t.RootDataObject;\n\tassert(rootDataObject !== undefined, 0xb9f /* entryPoint must be of type RootDataObject */);\n\treturn makeFluidObject<IStaticEntryPoint>(\n\t\t{\n\t\t\trootDataObject,\n\t\t\textensionStore: containerRuntime as IContainerRuntimeInternal,\n\t\t},\n\t\t\"IStaticEntryPoint\",\n\t);\n}\n\n/**\n * Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}\n * (containing single {@link IRootDataObject}) as their entry point.\n */\nclass DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n\tprivate readonly rootDataObjectFactory: DataObjectFactory<\n\t\tRootDataObject,\n\t\t{\n\t\t\tInitialState: RootDataObjectProps;\n\t\t}\n\t>;\n\n\tprivate readonly initialObjects: LoadableObjectKindRecord;\n\n\t/**\n\t * Create a new instance of a container runtime factory.\n\t * @remarks\n\t * The caller is responsible for making sure that the provided root data object factory is configured\n\t * appropriately based on the schema of the container (e.g. its registry entries contain all the\n\t * DataStore/DDS types that the schema says can be constructed).\n\t *\n\t * Most scenarios probably want to use {@link createDOProviderContainerRuntimeFactory} instead,\n\t * since it can take care of constructing the root data object factory based on the schema.\n\t *\n\t * @param schema - The schema for the container\n\t * @param compatibilityMode - Compatibility mode\n\t * @param rootDataObjectFactory - A factory that can construct the root data object.\n\t */\n\tpublic constructor(\n\t\tschema: ContainerSchema,\n\t\tcompatibilityMode: CompatibilityMode,\n\t\trootDataObjectFactory: DataObjectFactory<\n\t\t\tRootDataObject,\n\t\t\t{ InitialState: RootDataObjectProps }\n\t\t>,\n\t\toverrides?: Partial<{\n\t\t\truntimeOptions: Partial<IContainerRuntimeOptions>;\n\t\t\tminVersionForCollab: MinimumVersionForCollab;\n\t\t}>,\n\t) {\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\truntimeOptions: {\n\t\t\t\t...compatibilityModeRuntimeOptions[compatibilityMode],\n\t\t\t\t...overrides?.runtimeOptions,\n\t\t\t},\n\t\t\tprovideEntryPoint,\n\t\t\tminVersionForCollab:\n\t\t\t\toverrides?.minVersionForCollab ??\n\t\t\t\tcompatibilityModeToMinVersionForCollab[compatibilityMode],\n\t\t});\n\t\tthis.rootDataObjectFactory = rootDataObjectFactory;\n\t\tthis.initialObjects = schema.initialObjects;\n\t}\n\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\t// The first time we create the container we create the RootDataObject\n\t\tawait this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {\n\t\t\tinitialObjects: this.initialObjects,\n\t\t});\n\t}\n}\n\n/**\n * Factory that creates instances of a root data object.\n */\nclass RootDataObjectFactory extends DataObjectFactory<\n\tRootDataObject,\n\t{ InitialState: RootDataObjectProps }\n> {\n\tpublic constructor(\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\tprivate readonly dataStoreRegistry: IFluidDataStoreRegistry,\n\t) {\n\t\t// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,\n\t\t// and instead we override the necessary methods in this class to use the registry received in the constructor.\n\t\tsuper({\n\t\t\ttype: \"rootDO\",\n\t\t\tctor: RootDataObject,\n\t\t\tsharedObjects,\n\t\t});\n\t}\n\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.dataStoreRegistry;\n\t}\n}\n"]}
|
package/dist/serviceAudience.js
CHANGED
|
@@ -29,8 +29,6 @@ exports.createServiceAudience = createServiceAudience;
|
|
|
29
29
|
* the user and client details returned in {@link IMember}.
|
|
30
30
|
*
|
|
31
31
|
* @typeParam TMember - A service-specific {@link IMember} implementation.
|
|
32
|
-
*
|
|
33
|
-
* @internal
|
|
34
32
|
*/
|
|
35
33
|
class ServiceAudience extends client_utils_1.TypedEventEmitter {
|
|
36
34
|
constructor(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceAudience.js","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAOjE;;;;;;;;;GASG;AACH,SAAgB,qBAAqB,CAAoC,KAGxE;IACA,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;AACxE,CAAC;AALD,sDAKC;AAED
|
|
1
|
+
{"version":3,"file":"serviceAudience.js","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAOjE;;;;;;;;;GASG;AACH,SAAgB,qBAAqB,CAAoC,KAGxE;IACA,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;AACxE,CAAC;AALD,sDAKC;AAED;;;;;;;;;GASG;AACH,MAAM,eACL,SAAQ,gCAAkD;IA2B1D;IACC;;OAEG;IACc,SAAqB,EACrB,mBAAyD;QAE1E,KAAK,EAAE,CAAC;QAHS,cAAS,GAAT,SAAS,CAAY;QACrB,wBAAmB,GAAnB,mBAAmB,CAAsC;QAxB3E;;;;;;;;;;;;;;;;WAgBG;QACK,gBAAW,GAAG,IAAI,GAAG,EAAmB,CAAC;QAUhD,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;QAEnC,iFAAiF;QACjF,+EAA+E;QAC/E,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC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,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACd,6BAA6B,QAAQ,8CAA8C,CACnF,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACK,qBAAqB,CAAC,MAAe;QAC5C,6BAA6B;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC;IAChD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IAudience } from \"@fluidframework/container-definitions\";\nimport type { IContainer } from \"@fluidframework/container-definitions/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\n\nimport type { IMember, IServiceAudience, IServiceAudienceEvents, Myself } from \"./types.js\";\n\n/**\n * Creates a service audience for the provided container.\n *\n * @param container - The container with which the audience is associated.\n * @param createServiceMember - A function for creating audience members.\n *\n * @typeParam TMember - The {@link IMember} representation used by the audience.\n *\n * @internal\n */\nexport function createServiceAudience<TMember extends IMember = IMember>(props: {\n\tcontainer: IContainer;\n\tcreateServiceMember: (audienceMember: IClient) => TMember;\n}): IServiceAudience<TMember> {\n\treturn new ServiceAudience(props.container, props.createServiceMember);\n}\n\n/**\n * Base class for providing audience information for sessions interacting with {@link IFluidContainer}\n *\n * @remarks\n *\n * This can be extended by different service-specific client packages to additional parameters to\n * the user and client details returned in {@link IMember}.\n *\n * @typeParam TMember - A service-specific {@link IMember} implementation.\n */\nclass ServiceAudience<TMember extends IMember = IMember>\n\textends TypedEventEmitter<IServiceAudienceEvents<TMember>>\n\timplements IServiceAudience<TMember>\n{\n\t/**\n\t * Audience object which includes all the existing members of the {@link IFluidContainer | container}.\n\t */\n\tprivate readonly audience: IAudience;\n\n\t/**\n\t * Retain the most recent member list.\n\t *\n\t * @remarks\n\t *\n\t * This is so we have more information about a member leaving the audience in the `removeMember` event.\n\t *\n\t * It allows us to match the behavior of the `addMember` event where it only fires on a change to the members this\n\t * class exposes (and would actually produce a change in what `getMembers` returns).\n\t *\n\t * It also allows us to provide the client details in the event which makes it easier to find that client connection\n\t * in a map keyed on the `userId` and not `clientId`.\n\t *\n\t * This map will always be up-to-date in a `removeMember` event because it is set once at construction and in\n\t * every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}\n\t * events provide.\n\t */\n\tprivate lastMembers = new Map<string, TMember>();\n\n\tpublic constructor(\n\t\t/**\n\t\t * Fluid Container to read the audience from.\n\t\t */\n\t\tprivate readonly container: IContainer,\n\t\tprivate readonly createServiceMember: (audienceMember: IClient) => TMember,\n\t) {\n\t\tsuper();\n\t\tthis.audience = container.audience;\n\n\t\t// getMembers will assign lastMembers so the removeMember event has what it needs\n\t\t// in case it would fire before getMembers otherwise gets called the first time\n\t\tthis.getMembers();\n\n\t\tthis.audience.on(\"addMember\", (clientId: string, details: IClient) => {\n\t\t\tif (this.shouldIncludeAsMember(details)) {\n\t\t\t\tconst member = this.getMember(clientId);\n\t\t\t\tthis.emit(\"memberAdded\", clientId, member);\n\t\t\t\tthis.emit(\"membersChanged\");\n\t\t\t}\n\t\t});\n\n\t\tthis.audience.on(\"removeMember\", (clientId: string) => {\n\t\t\tif (this.lastMembers.has(clientId)) {\n\t\t\t\tthis.emit(\"memberRemoved\", clientId, this.lastMembers.get(clientId));\n\t\t\t\tthis.emit(\"membersChanged\");\n\t\t\t}\n\t\t});\n\n\t\tthis.container.on(\"connected\", () => this.emit(\"membersChanged\"));\n\t}\n\n\t/**\n\t * {@inheritDoc IServiceAudience.getMembers}\n\t */\n\tpublic getMembers(): Map<string, TMember> {\n\t\tconst users = new Map<string, TMember>();\n\t\tconst clientMemberMap = new Map<string, TMember>();\n\t\t// Iterate through the members and get the user specifics.\n\t\tfor (const [clientId, member] of this.audience.getMembers()) {\n\t\t\tif (this.shouldIncludeAsMember(member)) {\n\t\t\t\tconst userId = member.user.id;\n\t\t\t\t// Ensure we're tracking the user\n\t\t\t\tlet user = users.get(userId);\n\t\t\t\tif (user === undefined) {\n\t\t\t\t\tuser = this.createServiceMember(member);\n\t\t\t\t\tusers.set(userId, user);\n\t\t\t\t}\n\n\t\t\t\t// Add this connection to their collection\n\t\t\t\tuser.connections.push({ id: clientId, mode: member.mode });\n\t\t\t\tclientMemberMap.set(clientId, user);\n\t\t\t}\n\t\t}\n\t\tthis.lastMembers = clientMemberMap;\n\t\treturn users;\n\t}\n\n\t/**\n\t * {@inheritDoc IServiceAudience.getMyself}\n\t */\n\tpublic getMyself(): Myself<TMember> | undefined {\n\t\tconst clientId = this.container.clientId;\n\t\tif (clientId === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst member = this.getMember(clientId);\n\t\tif (member === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst myself: Myself<TMember> = { ...member, currentConnection: clientId };\n\n\t\treturn myself;\n\t}\n\n\tprivate getMember(clientId: string): TMember | undefined {\n\t\t// Fetch the user ID assoicated with this client ID from the runtime\n\t\tconst internalAudienceMember = this.audience.getMember(clientId);\n\t\tif (internalAudienceMember === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\t// Return the member object with any other clients associated for this user\n\t\tconst allMembers = this.getMembers();\n\t\tconst member = allMembers.get(internalAudienceMember?.user.id);\n\t\tif (member === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`Attempted to fetch client ${clientId} that is not part of the current member list`,\n\t\t\t);\n\t\t}\n\t\treturn member;\n\t}\n\n\t/**\n\t * Provides ability for the inheriting class to include/omit specific members.\n\t * An example use case is omitting the summarizer client.\n\t *\n\t * @param member - Member to be included/omitted.\n\t */\n\tprivate shouldIncludeAsMember(member: IClient): boolean {\n\t\t// Include only human members\n\t\treturn member.details.capabilities.interactive;\n\t}\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { DataObjectKind } from "@fluidframework/aqueduct/internal";
|
|
6
|
-
import type {
|
|
6
|
+
import type { ContainerExtensionStore } from "@fluidframework/container-runtime-definitions/internal";
|
|
7
|
+
import type { IEvent, IEventProvider, IFluidHandle, IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
7
8
|
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
8
9
|
import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
|
|
9
10
|
/**
|
|
@@ -16,7 +17,6 @@ import type { ISharedObjectKind } from "@fluidframework/shared-object-base/inter
|
|
|
16
17
|
export type CompatibilityMode = "1" | "2";
|
|
17
18
|
/**
|
|
18
19
|
* A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
|
|
19
|
-
* @internal
|
|
20
20
|
*/
|
|
21
21
|
export type LoadableObjectRecord = Record<string, IFluidLoadable>;
|
|
22
22
|
/**
|
|
@@ -83,18 +83,11 @@ export interface ContainerSchema {
|
|
|
83
83
|
*/
|
|
84
84
|
readonly dynamicObjectTypes?: readonly SharedObjectKind[];
|
|
85
85
|
}
|
|
86
|
-
/**
|
|
87
|
-
* @internal
|
|
88
|
-
*/
|
|
89
|
-
export interface IProvideRootDataObject {
|
|
90
|
-
readonly IRootDataObject: IRootDataObject;
|
|
91
|
-
}
|
|
92
86
|
/**
|
|
93
87
|
* Holds the collection of objects that the container was initially created with, as well as provides the ability
|
|
94
88
|
* to dynamically create further objects during usage.
|
|
95
|
-
* @internal
|
|
96
89
|
*/
|
|
97
|
-
export interface IRootDataObject
|
|
90
|
+
export interface IRootDataObject {
|
|
98
91
|
/**
|
|
99
92
|
* Provides a record of the initial objects defined on creation.
|
|
100
93
|
*/
|
|
@@ -107,6 +100,25 @@ export interface IRootDataObject extends IProvideRootDataObject {
|
|
|
107
100
|
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
108
101
|
*/
|
|
109
102
|
create<T>(objectClass: SharedObjectKind<T>): Promise<T>;
|
|
103
|
+
/**
|
|
104
|
+
* Upload a blob of data.
|
|
105
|
+
* Although it is marked as internal, there is external usage of this function for experimental purposes.
|
|
106
|
+
* Please contact yunho-microsoft or vladsud if you need to change it.
|
|
107
|
+
* @param blob - blob to be uploaded.
|
|
108
|
+
*
|
|
109
|
+
* @remarks This method is used to expose uploadBlob to the IFluidContainer level. UploadBlob will upload data to server side (as of now, ODSP only). There is no downloadBlob provided as it is not needed(blob lifetime managed by server).
|
|
110
|
+
*/
|
|
111
|
+
uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;
|
|
112
|
+
}
|
|
113
|
+
interface IProvideStaticEntryPoint {
|
|
114
|
+
readonly IStaticEntryPoint: IStaticEntryPoint;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* This is the internal entry point fluid-static creates.
|
|
118
|
+
*/
|
|
119
|
+
export interface IStaticEntryPoint extends IProvideStaticEntryPoint {
|
|
120
|
+
readonly rootDataObject: IRootDataObject;
|
|
121
|
+
readonly extensionStore: ContainerExtensionStore;
|
|
110
122
|
}
|
|
111
123
|
/**
|
|
112
124
|
* Signature for {@link IMember} change events.
|
|
@@ -211,4 +223,5 @@ export interface IMember {
|
|
|
211
223
|
export type Myself<M extends IMember = IMember> = M & {
|
|
212
224
|
readonly currentConnection: string;
|
|
213
225
|
};
|
|
226
|
+
export {};
|
|
214
227
|
//# sourceMappingURL=types.d.ts.map
|