@fluidframework/fluid-static 1.1.0 → 1.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/README.md +0 -2
- package/api-extractor.json +1 -1
- package/dist/fluidContainer.d.ts +66 -33
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js +11 -2
- package/dist/fluidContainer.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/rootDataObject.d.ts +36 -1
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +29 -1
- package/dist/rootDataObject.js.map +1 -1
- package/dist/serviceAudience.d.ts +20 -1
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/serviceAudience.js +10 -1
- package/dist/serviceAudience.js.map +1 -1
- package/dist/types.d.ts +12 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/lib/fluidContainer.d.ts +66 -33
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.js +11 -2
- package/lib/fluidContainer.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -1
- package/lib/rootDataObject.d.ts +36 -1
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.js +29 -1
- package/lib/rootDataObject.js.map +1 -1
- package/lib/serviceAudience.d.ts +20 -1
- package/lib/serviceAudience.d.ts.map +1 -1
- package/lib/serviceAudience.js +10 -1
- package/lib/serviceAudience.js.map +1 -1
- package/lib/types.d.ts +12 -7
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +13 -13
- package/src/fluidContainer.ts +52 -19
- package/src/index.ts +6 -0
- package/src/rootDataObject.ts +41 -2
- package/src/serviceAudience.ts +16 -1
- package/src/types.ts +12 -7
|
@@ -1 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,EACf,OAAO,EACP,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IACjD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n BaseContainerRuntimeFactory,\n DataObject,\n DataObjectFactory,\n defaultRouteRequestHandler,\n} from \"@fluidframework/aqueduct\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { requestFluidObject } from \"@fluidframework/runtime-utils\";\nimport {\n ContainerSchema,\n DataObjectClass,\n LoadableObjectClass,\n LoadableObjectClassRecord,\n LoadableObjectRecord,\n SharedObjectClass,\n} from \"./types\";\nimport { isDataObjectClass, isSharedObjectClass, parseDataObjectsFromSharedObjects } from \"./utils\";\n\nexport interface RootDataObjectProps {\n initialObjects: LoadableObjectClassRecord;\n}\n\nexport class RootDataObject extends DataObject<{ InitialState: RootDataObjectProps; }> {\n private readonly initialObjectsDirKey = \"initial-objects-key\";\n private readonly _initialObjects: LoadableObjectRecord = {};\n\n private get initialObjectsDir() {\n const dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n if (dir === undefined) {\n throw new Error(\"InitialObjects sub-directory was not initialized\");\n }\n return dir;\n }\n\n protected async initializingFirstTime(props: RootDataObjectProps) {\n this.root.createSubDirectory(this.initialObjectsDirKey);\n\n // Create initial objects provided by the developer\n const initialObjectsP: Promise<void>[] = [];\n Object.entries(props.initialObjects).forEach(([id, objectClass]) => {\n const createObject = async () => {\n const obj = await this.create(objectClass);\n this.initialObjectsDir.set(id, obj.handle);\n };\n initialObjectsP.push(createObject());\n });\n\n await Promise.all(initialObjectsP);\n }\n\n protected async hasInitialized() {\n // We will always load the initial objects so they are available to the developer\n const loadInitialObjectsP: Promise<void>[] = [];\n for (const [key, value] of Array.from(this.initialObjectsDir.entries())) {\n const loadDir = async () => {\n const obj = await value.get();\n Object.assign(this._initialObjects, { [key]: obj });\n };\n loadInitialObjectsP.push(loadDir());\n }\n\n await Promise.all(loadInitialObjectsP);\n }\n\n public get initialObjects(): LoadableObjectRecord {\n if (Object.keys(this._initialObjects).length === 0) {\n throw new Error(\"Initial Objects were not correctly initialized\");\n }\n return this._initialObjects;\n }\n\n public async create<T extends IFluidLoadable>(\n objectClass: LoadableObjectClass<T>,\n ): Promise<T> {\n if (isDataObjectClass(objectClass)) {\n return this.createDataObject<T>(objectClass);\n } else if (isSharedObjectClass(objectClass)) {\n return this.createSharedObject<T>(objectClass);\n }\n throw new Error(\"Could not create new Fluid object because an unknown object was passed\");\n }\n\n private async createDataObject<T extends IFluidLoadable>(dataObjectClass: DataObjectClass<T>): Promise<T> {\n const factory = dataObjectClass.factory;\n const packagePath = [...this.context.packagePath, factory.type];\n const router = await this.context.containerRuntime.createDataStore(packagePath);\n return requestFluidObject<T>(router, \"/\");\n }\n\n private createSharedObject<T extends IFluidLoadable>(\n sharedObjectClass: SharedObjectClass<T>,\n ): T {\n const factory = sharedObjectClass.getFactory();\n const obj = this.runtime.createChannel(undefined, factory.type);\n return obj as unknown as T;\n }\n}\n\nconst rootDataStoreId = \"rootDOId\";\n\n/**\n * The DOProviderContainerRuntimeFactory is container code that provides a single RootDataObject. This data object is\n * dynamically customized (registry and initial objects) based on the schema provided to the container runtime factory.\n */\nexport class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n private readonly rootDataObjectFactory; // type is DataObjectFactory\n private readonly initialObjects: LoadableObjectClassRecord;\n constructor(schema: ContainerSchema) {\n const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n const rootDataObjectFactory =\n new DataObjectFactory(\n \"rootDO\",\n RootDataObject,\n sharedObjects,\n {},\n registryEntries,\n );\n super([rootDataObjectFactory.registryEntry], undefined, [defaultRouteRequestHandler(rootDataStoreId)]);\n this.rootDataObjectFactory = rootDataObjectFactory;\n this.initialObjects = schema.initialObjects;\n }\n\n protected async containerInitializingFirstTime(runtime: IContainerRuntime) {\n // The first time we create the container we create the RootDataObject\n await this.rootDataObjectFactory.createRootInstance(\n rootDataStoreId,\n runtime,\n { initialObjects: this.initialObjects });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACH,2BAA2B,EAC3B,UAAU,EACV,iBAAiB,EACjB,0BAA0B,GAC7B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AASnE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAapG;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAkD;IAAtF;;QACqB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IA4FhE,CAAC;IA1FG,IAAY,iBAAiB;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAA0B;QAC5D,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAExD,mDAAmD;QACnD,MAAM,eAAe,GAAoB,EAAE,CAAC;QAC5C,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,WAAW,CAAC,EAAE,EAAE;YAC/D,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE;gBAC5B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CA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CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAChD,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,8BAA8B,CAAC,OAA0B;QACrE,sEAAsE;QACtE,MAAM,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAC/C,eAAe,EACf,OAAO,EACP,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IACjD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n BaseContainerRuntimeFactory,\n DataObject,\n DataObjectFactory,\n defaultRouteRequestHandler,\n} from \"@fluidframework/aqueduct\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { requestFluidObject } from \"@fluidframework/runtime-utils\";\nimport {\n ContainerSchema,\n DataObjectClass,\n LoadableObjectClass,\n LoadableObjectClassRecord,\n LoadableObjectRecord,\n SharedObjectClass,\n} from \"./types\";\nimport { isDataObjectClass, isSharedObjectClass, parseDataObjectsFromSharedObjects } from \"./utils\";\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}\n */\nexport interface RootDataObjectProps {\n /**\n * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n * See {@link RootDataObject.initializingFirstTime}\n */\n initialObjects: LoadableObjectClassRecord;\n}\n\n/**\n * The entry-point/root collaborative object of the Fluid Container.\n * This class abstracts the dynamic code required to build a Fluid Container into a static representation\n * for end customers.\n */\nexport class RootDataObject extends DataObject<{ InitialState: RootDataObjectProps; }> {\n private readonly initialObjectsDirKey = \"initial-objects-key\";\n private readonly _initialObjects: LoadableObjectRecord = {};\n\n private get initialObjectsDir() {\n const dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n if (dir === undefined) {\n throw new Error(\"InitialObjects sub-directory was not initialized\");\n }\n return dir;\n }\n\n /**\n * The first time this object is initialized, creates each object identified in\n * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n *\n * See {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n */\n protected async initializingFirstTime(props: RootDataObjectProps) {\n this.root.createSubDirectory(this.initialObjectsDirKey);\n\n // Create initial objects provided by the developer\n const initialObjectsP: Promise<void>[] = [];\n Object.entries(props.initialObjects).forEach(([id, objectClass]) => {\n const createObject = async () => {\n const obj = await this.create(objectClass);\n this.initialObjectsDir.set(id, obj.handle);\n };\n initialObjectsP.push(createObject());\n });\n\n await Promise.all(initialObjectsP);\n }\n\n /**\n * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n * accessed immediately.\n *\n * See {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n */\n protected async hasInitialized() {\n // We will always load the initial objects so they are available to the developer\n const loadInitialObjectsP: Promise<void>[] = [];\n for (const [key, value] of Array.from(this.initialObjectsDir.entries())) {\n const loadDir = async () => {\n const obj = await value.get();\n Object.assign(this._initialObjects, { [key]: obj });\n };\n loadInitialObjectsP.push(loadDir());\n }\n\n await Promise.all(loadInitialObjectsP);\n }\n\n /**\n * Provides a record of the initial objects defined on creation.\n * See {@link RootDataObject.initializingFirstTime}\n */\n public get initialObjects(): LoadableObjectRecord {\n if (Object.keys(this._initialObjects).length === 0) {\n throw new Error(\"Initial Objects were not correctly initialized\");\n }\n return this._initialObjects;\n }\n\n /**\n * Dynamically creates a new detached collaborative object (DDS/DataObject).\n * @param objectClass - Type of the collaborative object to be created.\n */\n public async create<T extends IFluidLoadable>(\n objectClass: LoadableObjectClass<T>,\n ): Promise<T> {\n if (isDataObjectClass(objectClass)) {\n return this.createDataObject<T>(objectClass);\n } else if (isSharedObjectClass(objectClass)) {\n return this.createSharedObject<T>(objectClass);\n }\n throw new Error(\"Could not create new Fluid object because an unknown object was passed\");\n }\n\n private async createDataObject<T extends IFluidLoadable>(dataObjectClass: DataObjectClass<T>): Promise<T> {\n const factory = dataObjectClass.factory;\n const packagePath = [...this.context.packagePath, factory.type];\n const router = await this.context.containerRuntime.createDataStore(packagePath);\n return requestFluidObject<T>(router, \"/\");\n }\n\n private createSharedObject<T extends IFluidLoadable>(\n sharedObjectClass: SharedObjectClass<T>,\n ): T {\n const factory = sharedObjectClass.getFactory();\n const obj = this.runtime.createChannel(undefined, factory.type);\n return obj as unknown as T;\n }\n}\n\nconst rootDataStoreId = \"rootDOId\";\n\n/**\n * Container code that provides a single {@link RootDataObject}. This data object is\n * dynamically customized (registry and initial objects) based on the schema provided to the container runtime factory.\n */\nexport class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n private readonly rootDataObjectFactory: DataObjectFactory<RootDataObject, {\n InitialState: RootDataObjectProps;\n }>;\n\n private readonly initialObjects: LoadableObjectClassRecord;\n\n constructor(schema: ContainerSchema) {\n const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n const rootDataObjectFactory =\n new DataObjectFactory(\n \"rootDO\",\n RootDataObject,\n sharedObjects,\n {},\n registryEntries,\n );\n super([rootDataObjectFactory.registryEntry], undefined, [defaultRouteRequestHandler(rootDataStoreId)]);\n this.rootDataObjectFactory = rootDataObjectFactory;\n this.initialObjects = schema.initialObjects;\n }\n\n /**\n * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}\n */\n protected async containerInitializingFirstTime(runtime: IContainerRuntime) {\n // The first time we create the container we create the RootDataObject\n await this.rootDataObjectFactory.createRootInstance(\n rootDataStoreId,\n runtime,\n { initialObjects: this.initialObjects });\n }\n}\n"]}
|
package/lib/serviceAudience.d.ts
CHANGED
|
@@ -13,7 +13,13 @@ import { IServiceAudience, IServiceAudienceEvents, IMember } from "./types";
|
|
|
13
13
|
* @typeParam M - A service-specific member type.
|
|
14
14
|
*/
|
|
15
15
|
export declare abstract class ServiceAudience<M extends IMember = IMember> extends TypedEventEmitter<IServiceAudienceEvents<M>> implements IServiceAudience<M> {
|
|
16
|
+
/**
|
|
17
|
+
* Fluid Container to read the audience from.
|
|
18
|
+
*/
|
|
16
19
|
protected readonly container: IContainer;
|
|
20
|
+
/**
|
|
21
|
+
* Audience object which includes all the existing members of the container.
|
|
22
|
+
*/
|
|
17
23
|
protected readonly audience: IAudience;
|
|
18
24
|
/**
|
|
19
25
|
* Retain the most recent member list. This is so we have more information about a member
|
|
@@ -27,7 +33,15 @@ export declare abstract class ServiceAudience<M extends IMember = IMember> exten
|
|
|
27
33
|
* It is mapped clientId to M to be better work with what the IAudience event provides
|
|
28
34
|
*/
|
|
29
35
|
protected lastMembers: Map<string, M>;
|
|
30
|
-
constructor(
|
|
36
|
+
constructor(
|
|
37
|
+
/**
|
|
38
|
+
* Fluid Container to read the audience from.
|
|
39
|
+
*/
|
|
40
|
+
container: IContainer);
|
|
41
|
+
/**
|
|
42
|
+
* Provides ability for inheriting class to modify/extend the audience object.
|
|
43
|
+
* @param audienceMember - Record of a specific audience member.
|
|
44
|
+
*/
|
|
31
45
|
protected abstract createServiceMember(audienceMember: IClient): M;
|
|
32
46
|
/**
|
|
33
47
|
* {@inheritDoc IServiceAudience.getMembers}
|
|
@@ -38,6 +52,11 @@ export declare abstract class ServiceAudience<M extends IMember = IMember> exten
|
|
|
38
52
|
*/
|
|
39
53
|
getMyself(): M | undefined;
|
|
40
54
|
private getMember;
|
|
55
|
+
/**
|
|
56
|
+
* Provides ability for the inheriting class to include/omit specific members.
|
|
57
|
+
* An example use case is omitting the summarizer client.
|
|
58
|
+
* @param member - Member to be included/omitted.
|
|
59
|
+
*/
|
|
41
60
|
protected shouldIncludeAsMember(member: IClient): boolean;
|
|
42
61
|
}
|
|
43
62
|
//# sourceMappingURL=serviceAudience.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceAudience.d.ts","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,S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UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAuBnC;;OAEG;IACI,SAAS,IAAI,CAAC,GAAG,SAAS;IAQjC,OAAO,CAAC,SAAS;IAejB;;;;OAIG;IACH,SAAS,CAAC,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO;CAI1D"}
|
package/lib/serviceAudience.js
CHANGED
|
@@ -10,7 +10,11 @@ import { TypedEventEmitter } from "@fluidframework/common-utils";
|
|
|
10
10
|
* @typeParam M - A service-specific member type.
|
|
11
11
|
*/
|
|
12
12
|
export class ServiceAudience extends TypedEventEmitter {
|
|
13
|
-
constructor(
|
|
13
|
+
constructor(
|
|
14
|
+
/**
|
|
15
|
+
* Fluid Container to read the audience from.
|
|
16
|
+
*/
|
|
17
|
+
container) {
|
|
14
18
|
super();
|
|
15
19
|
this.container = container;
|
|
16
20
|
/**
|
|
@@ -92,6 +96,11 @@ export class ServiceAudience extends TypedEventEmitter {
|
|
|
92
96
|
}
|
|
93
97
|
return member;
|
|
94
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Provides ability for the inheriting class to include/omit specific members.
|
|
101
|
+
* An example use case is omitting the summarizer client.
|
|
102
|
+
* @param member - Member to be included/omitted.
|
|
103
|
+
*/
|
|
95
104
|
shouldIncludeAsMember(member) {
|
|
96
105
|
// Include only human members
|
|
97
106
|
return member.details.capabilities.interactive;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceAudience.js","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAKjE;;;;;GAKG;AACH,MAAM,OAAgB,eACpB,SAAQ,iBAA4C;
|
|
1
|
+
{"version":3,"file":"serviceAudience.js","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,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,IAAI,sBAAsB,KAAK,SAAS,EAAE;YACxC,OAAO,SAAS,CAAC;SAClB;QACD,2EAA2E;QAC3E,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/D,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,MAAM,KAAK,CAAC,6BAA6B,QAAQ,8CAA8C,CAAC,CAAC;SAClG;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACO,qBAAqB,CAAC,MAAe;QAC7C,6BAA6B;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC;IACjD,CAAC;CACF","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IAudience, IContainer } from \"@fluidframework/container-definitions\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport { IServiceAudience, IServiceAudienceEvents, IMember } from \"./types\";\n\n/**\n * Base class for providing audience information for sessions interacting with FluidContainer\n * This can be extended by different service-specific client packages to additional parameters to\n * the user and client details returned in IMember\n * @typeParam M - A service-specific member type.\n */\nexport abstract class ServiceAudience<M extends IMember = IMember>\n extends TypedEventEmitter<IServiceAudienceEvents<M>>\n implements IServiceAudience<M> {\n /**\n * Audience object which includes all the existing members of the container.\n */\n protected readonly audience: IAudience;\n\n /**\n * Retain the most recent member list. This is so we have more information about a member\n * leaving the audience in the removeMember event. It allows us to match the behavior of the\n * addMember event where it only fires on a change to the members this class exposes (and would\n * actually produce a change in what getMembers returns). It also allows us to provide the\n * client details in the event which makes it easier to find that client connection in a map\n * keyed on the userId and not clientId.\n * This map will always be up-to-date in a removeMember event because it is set once at\n * construction and in every addMember event.\n * It is mapped clientId to M to be better work with what the IAudience event provides\n */\n protected lastMembers: Map<string, M> = new Map();\n\n constructor(\n /**\n * Fluid Container to read the audience from.\n */\n protected readonly container: IContainer,\n ) {\n super();\n this.audience = container.audience;\n\n // getMembers will assign lastMembers so the removeMember event has what it needs\n // in case it would fire before getMembers otherwise gets called the first time\n this.getMembers();\n\n this.audience.on(\"addMember\", (clientId: string, details: IClient) => {\n if (this.shouldIncludeAsMember(details)) {\n const member = this.getMember(clientId);\n this.emit(\"memberAdded\", clientId, member);\n this.emit(\"membersChanged\");\n }\n });\n\n this.audience.on(\"removeMember\", (clientId: string) => {\n if (this.lastMembers.has(clientId)) {\n this.emit(\"memberRemoved\", clientId, this.lastMembers.get(clientId));\n this.emit(\"membersChanged\");\n }\n });\n\n this.container.on(\"connected\", () => this.emit(\"membersChanged\"));\n }\n\n /**\n * Provides ability for inheriting class to modify/extend the audience object.\n * @param audienceMember - Record of a specific audience member.\n */\n protected abstract createServiceMember(audienceMember: IClient): M;\n\n /**\n * {@inheritDoc IServiceAudience.getMembers}\n */\n public getMembers(): Map<string, M> {\n const users = new Map<string, M>();\n const clientMemberMap = new Map<string, M>();\n // Iterate through the members and get the user specifics.\n this.audience.getMembers().forEach((member: IClient, clientId: string) => {\n if (this.shouldIncludeAsMember(member)) {\n const userId = member.user.id;\n // Ensure we're tracking the user\n let user = users.get(userId);\n if (user === undefined) {\n user = this.createServiceMember(member);\n users.set(userId, user);\n }\n\n // Add this connection to their collection\n user.connections.push({ id: clientId, mode: member.mode });\n clientMemberMap.set(clientId, user);\n }\n });\n this.lastMembers = clientMemberMap;\n return users;\n }\n\n /**\n * {@inheritDoc IServiceAudience.getMyself}\n */\n public getMyself(): M | undefined {\n const clientId = this.container.clientId;\n if (clientId === undefined) {\n return undefined;\n }\n return this.getMember(clientId);\n }\n\n private getMember(clientId: string): M | undefined {\n // Fetch the user ID assoicated with this client ID from the runtime\n const internalAudienceMember = this.audience.getMember(clientId);\n if (internalAudienceMember === undefined) {\n return undefined;\n }\n // Return the member object with any other clients associated for this user\n const allMembers = this.getMembers();\n const member = allMembers.get(internalAudienceMember?.user.id);\n if (member === undefined) {\n throw Error(`Attempted to fetch client ${clientId} that is not part of the current member list`);\n }\n return member;\n }\n\n /**\n * Provides ability for the inheriting class to include/omit specific members.\n * An example use case is omitting the summarizer client.\n * @param member - Member to be included/omitted.\n */\n protected shouldIncludeAsMember(member: IClient): boolean {\n // Include only human members\n return member.details.capabilities.interactive;\n }\n}\n"]}
|
package/lib/types.d.ts
CHANGED
|
@@ -48,9 +48,10 @@ export declare type LoadableObjectCtor<T extends IFluidLoadable> = new (...args:
|
|
|
48
48
|
*/
|
|
49
49
|
export interface ContainerSchema {
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
* Defines loadable objects that will be created when the `Container` is first created.
|
|
52
|
+
* It uses the key as the id and the value as the loadable object to create.
|
|
53
53
|
*
|
|
54
|
+
* @example
|
|
54
55
|
* In the example below two objects will be created when the Container is first
|
|
55
56
|
* created. One with id "map1" that will return a `SharedMap` and the other with
|
|
56
57
|
* id "pair1" that will return a `KeyValueDataObject`.
|
|
@@ -75,12 +76,16 @@ export interface ContainerSchema {
|
|
|
75
76
|
}
|
|
76
77
|
/**
|
|
77
78
|
* Events that trigger when the roster of members in the Fluid session change.
|
|
78
|
-
* Only changes that would be reflected in the returned map of IServiceAudience's
|
|
79
|
-
* will emit events.
|
|
79
|
+
* Only changes that would be reflected in the returned map of {@link IServiceAudience}'s
|
|
80
|
+
* {@link IServiceAudience.getMembers} method will emit events.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
*
|
|
84
|
+
* The following is the list of events emitted.
|
|
80
85
|
*
|
|
81
86
|
* ### "membersChanged"
|
|
82
87
|
*
|
|
83
|
-
* The membersChanged event is emitted when a member is either added or removed.
|
|
88
|
+
* The "membersChanged" event is emitted when a member is either added or removed.
|
|
84
89
|
*
|
|
85
90
|
* #### Listener signature
|
|
86
91
|
*
|
|
@@ -90,7 +95,7 @@ export interface ContainerSchema {
|
|
|
90
95
|
*
|
|
91
96
|
* ### "memberAdded"
|
|
92
97
|
*
|
|
93
|
-
* The memberAdded event is emitted when a member joins the audience.
|
|
98
|
+
* The "memberAdded" event is emitted when a member joins the audience.
|
|
94
99
|
*
|
|
95
100
|
* #### Listener signature
|
|
96
101
|
*
|
|
@@ -103,7 +108,7 @@ export interface ContainerSchema {
|
|
|
103
108
|
*
|
|
104
109
|
* ### "memberRemoved"
|
|
105
110
|
*
|
|
106
|
-
* The memberRemoved event is emitted when a member leaves the audience.
|
|
111
|
+
* The "memberRemoved" event is emitted when a member leaves the audience.
|
|
107
112
|
*
|
|
108
113
|
* #### Listener signature
|
|
109
114
|
*
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E;;GAEG;AACH,oBAAY,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAElE;;;GAGG;AACH,oBAAY,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjF;;;GAGG;AACH,oBAAY,mBAAmB,CAAC,CAAC,SAAS,cAAc,IAAI,eAAe,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAEtG;;;;GAIG;AACH,oBAAY,eAAe,CAAC,CAAC,SAAS,cAAc,IAC9C;IAAE,QAAQ,CAAC,OAAO,EAAE,sBAA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,CAAC;IAEf;;OAEG;IACH,WAAW,EAAE,WAAW,EAAE,CAAC;CAC9B"}
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent, IEventProvider } from \"@fluidframework/common-definitions\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { IFluidDataStoreFactory } from \"@fluidframework/runtime-definitions\";\n\n/**\n * A mapping of string identifiers to instantiated DataObjects or SharedObjects.\n */\nexport type LoadableObjectRecord = Record<string, IFluidLoadable>;\n\n/**\n * A mapping of string identifiers to classes that will later be used to instantiate a corresponding DataObject\n * or SharedObject in a LoadableObjectRecord.\n */\nexport type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;\n\n/**\n * A LoadableObjectClass is an class object of DataObject or SharedObject\n * @typeParam T - The class of the DataObject or SharedObject\n */\nexport type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> | SharedObjectClass<T>;\n\n/**\n * A DataObjectClass is a class that has a factory that can create a DataObject and a\n * constructor that will return the type of the DataObject.\n * @typeParam T - The class of the DataObject\n */\nexport type DataObjectClass<T extends IFluidLoadable>\n = { readonly factory: IFluidDataStoreFactory; } & LoadableObjectCtor<T>;\n\n/**\n * A SharedObjectClass is a class that has a factory that can create a DDS (SharedObject) and a\n * constructor that will return the type of the DataObject.\n * @typeParam T - The class of the SharedObject\n */\nexport type SharedObjectClass<T extends IFluidLoadable>\n = { readonly getFactory: () => IChannelFactory; } & LoadableObjectCtor<T>;\n\n/**\n * An object with a constructor that will return an `IFluidLoadable`.\n * @typeParam T - The class of the loadable object\n */\nexport type LoadableObjectCtor<T extends IFluidLoadable> = new(...args: any[]) => T;\n\n/**\n * The ContainerSchema declares the Fluid objects that will be available in the container. It includes both the\n * instances of objects that are initially available upon container creation, as well as the types of objects that may\n * be dynamically created throughout the lifetime of the container.\n */\nexport interface ContainerSchema {\n /**\n *
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent, IEventProvider } from \"@fluidframework/common-definitions\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { IFluidDataStoreFactory } from \"@fluidframework/runtime-definitions\";\n\n/**\n * A mapping of string identifiers to instantiated DataObjects or SharedObjects.\n */\nexport type LoadableObjectRecord = Record<string, IFluidLoadable>;\n\n/**\n * A mapping of string identifiers to classes that will later be used to instantiate a corresponding DataObject\n * or SharedObject in a LoadableObjectRecord.\n */\nexport type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;\n\n/**\n * A LoadableObjectClass is an class object of DataObject or SharedObject\n * @typeParam T - The class of the DataObject or SharedObject\n */\nexport type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> | SharedObjectClass<T>;\n\n/**\n * A DataObjectClass is a class that has a factory that can create a DataObject and a\n * constructor that will return the type of the DataObject.\n * @typeParam T - The class of the DataObject\n */\nexport type DataObjectClass<T extends IFluidLoadable>\n = { readonly factory: IFluidDataStoreFactory; } & LoadableObjectCtor<T>;\n\n/**\n * A SharedObjectClass is a class that has a factory that can create a DDS (SharedObject) and a\n * constructor that will return the type of the DataObject.\n * @typeParam T - The class of the SharedObject\n */\nexport type SharedObjectClass<T extends IFluidLoadable>\n = { readonly getFactory: () => IChannelFactory; } & LoadableObjectCtor<T>;\n\n/**\n * An object with a constructor that will return an `IFluidLoadable`.\n * @typeParam T - The class of the loadable object\n */\nexport type LoadableObjectCtor<T extends IFluidLoadable> = new(...args: any[]) => T;\n\n/**\n * The ContainerSchema declares the Fluid objects that will be available in the container. It includes both the\n * instances of objects that are initially available upon container creation, as well as the types of objects that may\n * be dynamically created throughout the lifetime of the container.\n */\nexport interface ContainerSchema {\n /**\n * Defines loadable objects that will be created when the `Container` is first created.\n * It uses the key as the id and the value as the loadable object to create.\n *\n * @example\n * In the example below two objects will be created when the Container is first\n * created. One with id \"map1\" that will return a `SharedMap` and the other with\n * id \"pair1\" that will return a `KeyValueDataObject`.\n *\n * ```\n * {\n * map1: SharedMap,\n * pair1: KeyValueDataObject,\n * }\n * ```\n */\n initialObjects: LoadableObjectClassRecord;\n\n /**\n * Dynamic objects are Loadable objects that can be created after the initial Container creation.\n *\n * Types defined in `initialObjects` will always be available and are not required to be provided here.\n *\n * For best practice it's recommended to define all the dynamic types you create even if they are\n * included via initialObjects.\n */\n dynamicObjectTypes?: LoadableObjectClass<any>[];\n}\n\n/**\n * Events that trigger when the roster of members in the Fluid session change.\n * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s\n * {@link IServiceAudience.getMembers} method will emit events.\n *\n * @remarks\n *\n * The following is the list of events emitted.\n *\n * ### \"membersChanged\"\n *\n * The \"membersChanged\" event is emitted when a member is either added or removed.\n *\n * #### Listener signature\n *\n * ```typescript\n * () => void;\n * ```\n *\n * ### \"memberAdded\"\n *\n * The \"memberAdded\" event is emitted when a member joins the audience.\n *\n * #### Listener signature\n *\n * ```typescript\n * (clientId: string, member: M) => void;\n * ```\n * - `clientId` - A unique identifier for the client\n *\n * - `member` - The service-specific member object for the client\n *\n * ### \"memberRemoved\"\n *\n * The \"memberRemoved\" event is emitted when a member leaves the audience.\n *\n * #### Listener signature\n *\n * ```typescript\n * (clientId: string, member: M) => void;\n * ```\n * - `clientId` - A unique identifier for the client\n *\n * - `member` - The service-specific member object for the client\n * @typeParam M - A service-specific member type.\n */\nexport interface IServiceAudienceEvents<M extends IMember> extends IEvent {\n (event: \"membersChanged\", listener: () => void): void;\n (event: \"memberAdded\" | \"memberRemoved\", listener: (clientId: string, member: M) => void): void;\n}\n\n/**\n * Base interface to be implemented to fetch each service's audience. The generic M allows consumers to further\n * extend the client object with service-specific details about the connecting client, such as device information,\n * environment, or a username.\n * @typeParam M - A service-specific member type.\n */\nexport interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {\n /**\n * Returns an map of all users currently in the Fluid session where key is the userId and the value is the\n * member object. The implementation may choose to exclude certain connections from the returned map.\n * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.\n */\n getMembers(): Map<string, M>;\n\n /**\n * Returns the current active user on this client once they are connected. Otherwise, returns undefined.\n */\n getMyself(): M | undefined;\n}\n\n/**\n * Base interface for information for each connection made to the Fluid session. This interface can be extended\n * to provide additional information specific to each service.\n */\nexport interface IConnection {\n /**\n * A unique ID for the connection. A single user may have multiple connections, each with a different ID.\n */\n id: string;\n\n /**\n * Whether the connection is in read or read/write mode.\n */\n mode: \"write\" | \"read\";\n}\n\n/**\n * Base interface to be implemented to fetch each service's member. This interface can be extended by each service\n * to provide additional service-specific user metadata.\n */\nexport interface IMember {\n /**\n * An ID for the user, unique among each individual user connecting to the session.\n */\n userId: string;\n\n /**\n * The set of connections the user has made, e.g. from multiple tabs or devices.\n */\n connections: IConnection[];\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/fluid-static",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.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": {
|
|
@@ -35,25 +35,25 @@
|
|
|
35
35
|
"typetests:gen": "fluid-type-validator -g -d ."
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@fluidframework/aqueduct": "^1.
|
|
38
|
+
"@fluidframework/aqueduct": "^1.2.0",
|
|
39
39
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
40
40
|
"@fluidframework/common-utils": "^0.32.1",
|
|
41
|
-
"@fluidframework/container-definitions": "^1.
|
|
42
|
-
"@fluidframework/container-loader": "^1.
|
|
43
|
-
"@fluidframework/container-runtime-definitions": "^1.
|
|
44
|
-
"@fluidframework/core-interfaces": "^1.
|
|
45
|
-
"@fluidframework/datastore-definitions": "^1.
|
|
41
|
+
"@fluidframework/container-definitions": "^1.2.0",
|
|
42
|
+
"@fluidframework/container-loader": "^1.2.0",
|
|
43
|
+
"@fluidframework/container-runtime-definitions": "^1.2.0",
|
|
44
|
+
"@fluidframework/core-interfaces": "^1.2.0",
|
|
45
|
+
"@fluidframework/datastore-definitions": "^1.2.0",
|
|
46
46
|
"@fluidframework/protocol-definitions": "^0.1028.2000",
|
|
47
|
-
"@fluidframework/request-handler": "^1.
|
|
48
|
-
"@fluidframework/runtime-definitions": "^1.
|
|
49
|
-
"@fluidframework/runtime-utils": "^1.
|
|
47
|
+
"@fluidframework/request-handler": "^1.2.0",
|
|
48
|
+
"@fluidframework/runtime-definitions": "^1.2.0",
|
|
49
|
+
"@fluidframework/runtime-utils": "^1.2.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@fluid-experimental/get-container": "^1.
|
|
52
|
+
"@fluid-experimental/get-container": "^1.2.0",
|
|
53
53
|
"@fluidframework/build-common": "^0.24.0",
|
|
54
54
|
"@fluidframework/build-tools": "^0.2.74327",
|
|
55
55
|
"@fluidframework/eslint-config-fluid": "^0.28.2000",
|
|
56
|
-
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static
|
|
56
|
+
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@1.1.0",
|
|
57
57
|
"@microsoft/api-extractor": "^7.22.2",
|
|
58
58
|
"@rushstack/eslint-config": "^2.5.1",
|
|
59
59
|
"@types/node": "^14.18.0",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"typescript-formatter": "7.1.0"
|
|
67
67
|
},
|
|
68
68
|
"typeValidation": {
|
|
69
|
-
"version": "1.
|
|
69
|
+
"version": "1.2.0",
|
|
70
70
|
"broken": {}
|
|
71
71
|
}
|
|
72
72
|
}
|
package/src/fluidContainer.ts
CHANGED
|
@@ -10,11 +10,15 @@ import { LoadableObjectClass, LoadableObjectRecord } from "./types";
|
|
|
10
10
|
import { RootDataObject } from "./rootDataObject";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Events emitted from IFluidContainer.
|
|
13
|
+
* Events emitted from {@link IFluidContainer}.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
*
|
|
17
|
+
* The following is the list of events emitted.
|
|
14
18
|
*
|
|
15
19
|
* ### "connected"
|
|
16
20
|
*
|
|
17
|
-
* The connected event is emitted when the `IFluidContainer` completes connecting to the Fluid service.
|
|
21
|
+
* The "connected" event is emitted when the `IFluidContainer` completes connecting to the Fluid service.
|
|
18
22
|
*
|
|
19
23
|
* #### Listener signature
|
|
20
24
|
*
|
|
@@ -24,7 +28,7 @@ import { RootDataObject } from "./rootDataObject";
|
|
|
24
28
|
*
|
|
25
29
|
* ### "dispose"
|
|
26
30
|
*
|
|
27
|
-
* The dispose event is emitted when the `IFluidContainer` is disposed, which permanently disables it.
|
|
31
|
+
* The "dispose" event is emitted when the `IFluidContainer` is disposed, which permanently disables it.
|
|
28
32
|
*
|
|
29
33
|
* #### Listener signature
|
|
30
34
|
*
|
|
@@ -34,7 +38,7 @@ import { RootDataObject } from "./rootDataObject";
|
|
|
34
38
|
*
|
|
35
39
|
* ### "disconnected"
|
|
36
40
|
*
|
|
37
|
-
* The disconnected event is emitted when the `IFluidContainer` becomes disconnected from the Fluid service.
|
|
41
|
+
* The "disconnected" event is emitted when the `IFluidContainer` becomes disconnected from the Fluid service.
|
|
38
42
|
*
|
|
39
43
|
* #### Listener signature
|
|
40
44
|
*
|
|
@@ -44,7 +48,7 @@ import { RootDataObject } from "./rootDataObject";
|
|
|
44
48
|
*
|
|
45
49
|
* ### "saved"
|
|
46
50
|
*
|
|
47
|
-
* The saved event is emitted when the `IFluidContainer` has local changes acknowledged by the service.
|
|
51
|
+
* The "saved" event is emitted when the `IFluidContainer` has local changes acknowledged by the service.
|
|
48
52
|
*
|
|
49
53
|
* #### Listener signature
|
|
50
54
|
*
|
|
@@ -54,7 +58,7 @@ import { RootDataObject } from "./rootDataObject";
|
|
|
54
58
|
*
|
|
55
59
|
* ### "dirty"
|
|
56
60
|
*
|
|
57
|
-
* The dirty event is emitted when the `IFluidContainer` has local changes that have not yet
|
|
61
|
+
* The "dirty" event is emitted when the `IFluidContainer` has local changes that have not yet
|
|
58
62
|
* been acknowledged by the service.
|
|
59
63
|
*
|
|
60
64
|
* #### Listener signature
|
|
@@ -68,8 +72,8 @@ export interface IFluidContainerEvents extends IEvent {
|
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
/**
|
|
71
|
-
*
|
|
72
|
-
* to the data as well as status on the collaboration session.
|
|
75
|
+
* Provides an entrypoint into the client side of collaborative Fluid data.
|
|
76
|
+
* Provides access to the data as well as status on the collaboration session.
|
|
73
77
|
*/
|
|
74
78
|
export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
75
79
|
/**
|
|
@@ -77,7 +81,7 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
77
81
|
*/
|
|
78
82
|
readonly connectionState: ConnectionState;
|
|
79
83
|
|
|
80
|
-
|
|
84
|
+
/**
|
|
81
85
|
* A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.
|
|
82
86
|
* You should always check the `isDirty` flag before closing the container or navigating away from the page.
|
|
83
87
|
* Closing the container while `isDirty === true` may result in the loss of operations that have not yet been
|
|
@@ -94,7 +98,7 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
94
98
|
* service. In some cases this can be due to lack of network connection. If the network connection is down,
|
|
95
99
|
* it needs to be restored for the pending changes to be acknowledged.
|
|
96
100
|
*/
|
|
97
|
-
|
|
101
|
+
readonly isDirty: boolean;
|
|
98
102
|
|
|
99
103
|
/**
|
|
100
104
|
* Whether the container is disposed, which permanently disables it.
|
|
@@ -102,8 +106,8 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
102
106
|
readonly disposed: boolean;
|
|
103
107
|
|
|
104
108
|
/**
|
|
105
|
-
* The collection of data objects and DDSes that were specified by the schema.
|
|
106
|
-
* for the lifetime of the container.
|
|
109
|
+
* The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.
|
|
110
|
+
* These data objects and DDSes exist for the lifetime of the container.
|
|
107
111
|
*/
|
|
108
112
|
readonly initialObjects: LoadableObjectRecord;
|
|
109
113
|
|
|
@@ -114,26 +118,46 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
114
118
|
readonly attachState: AttachState;
|
|
115
119
|
|
|
116
120
|
/**
|
|
117
|
-
* A newly created container starts detached from the collaborative service.
|
|
118
|
-
* new container to the service and connects to the collaborative service.
|
|
121
|
+
* A newly created container starts detached from the collaborative service.
|
|
122
|
+
* Calling `attach()` uploads the new container to the service and connects to the collaborative service.
|
|
123
|
+
*
|
|
124
|
+
* @remarks This should only be called when the container is in the
|
|
125
|
+
* {@link @fluidframework/container-definitions#AttachState.Detatched} state.
|
|
126
|
+
*
|
|
127
|
+
* This can be determined by observing {@link IFluidContainer.attachState}.
|
|
128
|
+
*
|
|
119
129
|
* @returns A promise which resolves when the attach is complete, with the string identifier of the container.
|
|
120
130
|
*/
|
|
121
131
|
attach(): Promise<string>;
|
|
122
132
|
|
|
123
133
|
/**
|
|
124
|
-
* Attempts to connect the container to the delta stream and process
|
|
134
|
+
* Attempts to connect the container to the delta stream and process operations.
|
|
135
|
+
* Will throw an error if unsuccessful.
|
|
136
|
+
*
|
|
137
|
+
* @remarks This should only be called when the container is in the
|
|
138
|
+
* {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
|
|
139
|
+
*
|
|
140
|
+
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
125
141
|
*/
|
|
126
142
|
connect(): void;
|
|
127
143
|
|
|
128
144
|
/**
|
|
129
|
-
* Disconnects the container from the delta stream and stops processing
|
|
145
|
+
* Disconnects the container from the delta stream and stops processing operations.
|
|
146
|
+
*
|
|
147
|
+
* @remarks This should only be called when the container is in the
|
|
148
|
+
* {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
|
|
149
|
+
*
|
|
150
|
+
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
130
151
|
*/
|
|
131
152
|
disconnect(): void;
|
|
132
153
|
|
|
133
154
|
/**
|
|
134
|
-
* Create a new data object or DDS of the specified type.
|
|
155
|
+
* Create a new data object or Distributed Data Store (DDS) of the specified type.
|
|
156
|
+
*
|
|
157
|
+
* @remarks In order to share the data object or DDS with other
|
|
135
158
|
* collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your
|
|
136
159
|
* initialObjects.
|
|
160
|
+
*
|
|
137
161
|
* @param objectClass - The class of data object or DDS to create
|
|
138
162
|
*/
|
|
139
163
|
create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
|
|
@@ -145,7 +169,10 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
145
169
|
}
|
|
146
170
|
|
|
147
171
|
/**
|
|
148
|
-
*
|
|
172
|
+
* Base {@link IFluidContainer} implementation.
|
|
173
|
+
*
|
|
174
|
+
* @remarks Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}
|
|
175
|
+
* will need to utilize or provide a service-specific implementation of this type that implements that method.
|
|
149
176
|
*/
|
|
150
177
|
export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer {
|
|
151
178
|
private readonly connectedHandler = () => this.emit("connected");
|
|
@@ -202,7 +229,13 @@ export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> imp
|
|
|
202
229
|
}
|
|
203
230
|
|
|
204
231
|
/**
|
|
205
|
-
* {@
|
|
232
|
+
* Incomplete base implementation of {@link IFluidContainer.attach}.
|
|
233
|
+
* @remarks Note: this implementation will unconditionally throw.
|
|
234
|
+
* Consumers who rely on this will need to utilize or provide a service specific implementation of this base type
|
|
235
|
+
* that provides an implementation of this method.
|
|
236
|
+
*
|
|
237
|
+
* The reason is because externally we are presenting a separation between the service and the `FluidContainer`,
|
|
238
|
+
* but internally this separation is not there.
|
|
206
239
|
*/
|
|
207
240
|
public async attach(): Promise<string> {
|
|
208
241
|
throw new Error("Cannot attach container. Container is not in detached state");
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Provides a simple and powerful way to consume collaborative Fluid data.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
|
|
6
12
|
export * from "./fluidContainer";
|
|
7
13
|
export * from "./rootDataObject";
|
|
8
14
|
export * from "./serviceAudience";
|
package/src/rootDataObject.ts
CHANGED
|
@@ -21,10 +21,22 @@ import {
|
|
|
21
21
|
} from "./types";
|
|
22
22
|
import { isDataObjectClass, isSharedObjectClass, parseDataObjectsFromSharedObjects } from "./utils";
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Input props for {@link RootDataObject.initializingFirstTime}
|
|
26
|
+
*/
|
|
24
27
|
export interface RootDataObjectProps {
|
|
28
|
+
/**
|
|
29
|
+
* Initial object structure with which the {@link RootDataObject} will be first-time initialized.
|
|
30
|
+
* See {@link RootDataObject.initializingFirstTime}
|
|
31
|
+
*/
|
|
25
32
|
initialObjects: LoadableObjectClassRecord;
|
|
26
33
|
}
|
|
27
34
|
|
|
35
|
+
/**
|
|
36
|
+
* The entry-point/root collaborative object of the Fluid Container.
|
|
37
|
+
* This class abstracts the dynamic code required to build a Fluid Container into a static representation
|
|
38
|
+
* for end customers.
|
|
39
|
+
*/
|
|
28
40
|
export class RootDataObject extends DataObject<{ InitialState: RootDataObjectProps; }> {
|
|
29
41
|
private readonly initialObjectsDirKey = "initial-objects-key";
|
|
30
42
|
private readonly _initialObjects: LoadableObjectRecord = {};
|
|
@@ -37,6 +49,12 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
37
49
|
return dir;
|
|
38
50
|
}
|
|
39
51
|
|
|
52
|
+
/**
|
|
53
|
+
* The first time this object is initialized, creates each object identified in
|
|
54
|
+
* {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.
|
|
55
|
+
*
|
|
56
|
+
* See {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}
|
|
57
|
+
*/
|
|
40
58
|
protected async initializingFirstTime(props: RootDataObjectProps) {
|
|
41
59
|
this.root.createSubDirectory(this.initialObjectsDirKey);
|
|
42
60
|
|
|
@@ -53,6 +71,12 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
53
71
|
await Promise.all(initialObjectsP);
|
|
54
72
|
}
|
|
55
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Every time an instance is initialized, loads all of the initial objects in the root directory so they can be
|
|
76
|
+
* accessed immediately.
|
|
77
|
+
*
|
|
78
|
+
* See {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}
|
|
79
|
+
*/
|
|
56
80
|
protected async hasInitialized() {
|
|
57
81
|
// We will always load the initial objects so they are available to the developer
|
|
58
82
|
const loadInitialObjectsP: Promise<void>[] = [];
|
|
@@ -67,6 +91,10 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
67
91
|
await Promise.all(loadInitialObjectsP);
|
|
68
92
|
}
|
|
69
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Provides a record of the initial objects defined on creation.
|
|
96
|
+
* See {@link RootDataObject.initializingFirstTime}
|
|
97
|
+
*/
|
|
70
98
|
public get initialObjects(): LoadableObjectRecord {
|
|
71
99
|
if (Object.keys(this._initialObjects).length === 0) {
|
|
72
100
|
throw new Error("Initial Objects were not correctly initialized");
|
|
@@ -74,6 +102,10 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
74
102
|
return this._initialObjects;
|
|
75
103
|
}
|
|
76
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Dynamically creates a new detached collaborative object (DDS/DataObject).
|
|
107
|
+
* @param objectClass - Type of the collaborative object to be created.
|
|
108
|
+
*/
|
|
77
109
|
public async create<T extends IFluidLoadable>(
|
|
78
110
|
objectClass: LoadableObjectClass<T>,
|
|
79
111
|
): Promise<T> {
|
|
@@ -104,12 +136,16 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
104
136
|
const rootDataStoreId = "rootDOId";
|
|
105
137
|
|
|
106
138
|
/**
|
|
107
|
-
*
|
|
139
|
+
* Container code that provides a single {@link RootDataObject}. This data object is
|
|
108
140
|
* dynamically customized (registry and initial objects) based on the schema provided to the container runtime factory.
|
|
109
141
|
*/
|
|
110
142
|
export class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
111
|
-
private readonly rootDataObjectFactory
|
|
143
|
+
private readonly rootDataObjectFactory: DataObjectFactory<RootDataObject, {
|
|
144
|
+
InitialState: RootDataObjectProps;
|
|
145
|
+
}>;
|
|
146
|
+
|
|
112
147
|
private readonly initialObjects: LoadableObjectClassRecord;
|
|
148
|
+
|
|
113
149
|
constructor(schema: ContainerSchema) {
|
|
114
150
|
const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);
|
|
115
151
|
const rootDataObjectFactory =
|
|
@@ -125,6 +161,9 @@ export class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFacto
|
|
|
125
161
|
this.initialObjects = schema.initialObjects;
|
|
126
162
|
}
|
|
127
163
|
|
|
164
|
+
/**
|
|
165
|
+
* {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}
|
|
166
|
+
*/
|
|
128
167
|
protected async containerInitializingFirstTime(runtime: IContainerRuntime) {
|
|
129
168
|
// The first time we create the container we create the RootDataObject
|
|
130
169
|
await this.rootDataObjectFactory.createRootInstance(
|