@fluidframework/fluid-static 2.0.0-dev.1.4.6.106135 → 2.0.0-dev.2.3.0.115467

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.
Files changed (46) hide show
  1. package/.eslintrc.js +1 -1
  2. package/dist/fluidContainer.d.ts +100 -71
  3. package/dist/fluidContainer.d.ts.map +1 -1
  4. package/dist/fluidContainer.js +26 -4
  5. package/dist/fluidContainer.js.map +1 -1
  6. package/dist/index.d.ts +4 -4
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +8 -14
  9. package/dist/index.js.map +1 -1
  10. package/dist/rootDataObject.d.ts +17 -15
  11. package/dist/rootDataObject.d.ts.map +1 -1
  12. package/dist/rootDataObject.js +16 -14
  13. package/dist/rootDataObject.js.map +1 -1
  14. package/dist/serviceAudience.d.ts +27 -15
  15. package/dist/serviceAudience.d.ts.map +1 -1
  16. package/dist/serviceAudience.js +29 -13
  17. package/dist/serviceAudience.js.map +1 -1
  18. package/dist/types.d.ts +100 -70
  19. package/dist/types.d.ts.map +1 -1
  20. package/dist/types.js.map +1 -1
  21. package/lib/fluidContainer.d.ts +100 -71
  22. package/lib/fluidContainer.d.ts.map +1 -1
  23. package/lib/fluidContainer.js +26 -4
  24. package/lib/fluidContainer.js.map +1 -1
  25. package/lib/index.d.ts +4 -4
  26. package/lib/index.d.ts.map +1 -1
  27. package/lib/index.js +3 -4
  28. package/lib/index.js.map +1 -1
  29. package/lib/rootDataObject.d.ts +17 -15
  30. package/lib/rootDataObject.d.ts.map +1 -1
  31. package/lib/rootDataObject.js +16 -14
  32. package/lib/rootDataObject.js.map +1 -1
  33. package/lib/serviceAudience.d.ts +27 -15
  34. package/lib/serviceAudience.d.ts.map +1 -1
  35. package/lib/serviceAudience.js +29 -13
  36. package/lib/serviceAudience.js.map +1 -1
  37. package/lib/types.d.ts +100 -70
  38. package/lib/types.d.ts.map +1 -1
  39. package/lib/types.js.map +1 -1
  40. package/package.json +49 -25
  41. package/prettier.config.cjs +8 -0
  42. package/src/fluidContainer.ts +121 -75
  43. package/src/index.ts +19 -4
  44. package/src/rootDataObject.ts +20 -17
  45. package/src/serviceAudience.ts +36 -16
  46. package/src/types.ts +108 -71
@@ -1 +1 @@
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,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,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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A0B,CAAC,eAAe,CAAC,CAAC;QAC7C,kGAAkG;QAClG,sEAAsE;QACtE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CACrC,CAAC;QACF,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,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 { FlushMode } from \"@fluidframework/runtime-definitions\";\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(\n [rootDataObjectFactory.registryEntry],\n undefined,\n [defaultRouteRequestHandler(rootDataStoreId)],\n // temporary workaround to disable message batching until the message batch size issue is resolved\n // resolution progress is tracked by the Feature 465 work item in AzDO\n { flushMode: FlushMode.Immediate },\n );\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 { initialOb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AI,CAAC,qBAAqB,GAAG,qBAAqB,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 { FlushMode } from \"@fluidframework/runtime-definitions\";\nimport {\n ContainerSchema,\n DataObjectClass,\n IRootDataObject,\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 *\n * @see {@link RootDataObject.initializingFirstTime}\n */\n initialObjects: LoadableObjectClassRecord;\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 */\nexport class RootDataObject extends DataObject<{ InitialState: RootDataObjectProps; }> implements IRootDataObject {\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 * {@inheritDoc IRootDataObject.initialObjects}\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 * {@inheritDoc IRootDataObject.create}\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 dataStore = await this.context.containerRuntime.createDataStore(packagePath);\n const entryPoint = await dataStore.entryPoint?.get();\n return entryPoint as unknown as T;\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}.\n *\n * @remarks\n *\n * This data object is dynamically customized (registry and initial objects) based on the schema provided.\n * 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(\n [rootDataObjectFactory.registryEntry],\n undefined,\n [defaultRouteRequestHandler(rootDataStoreId)],\n // temporary workaround to disable message batching until the message batch size issue is resolved\n // resolution progress is tracked by the Feature 465 work item in AzDO\n { flushMode: FlushMode.Immediate },\n );\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"]}
@@ -5,12 +5,16 @@
5
5
  import { TypedEventEmitter } from "@fluidframework/common-utils";
6
6
  import { IAudience, IContainer } from "@fluidframework/container-definitions";
7
7
  import { IClient } from "@fluidframework/protocol-definitions";
8
- import { IServiceAudience, IServiceAudienceEvents, IMember } from "./types";
8
+ import { IServiceAudience, IServiceAudienceEvents, IMember, Myself } from "./types";
9
9
  /**
10
- * Base class for providing audience information for sessions interacting with FluidContainer
10
+ * Base class for providing audience information for sessions interacting with {@link IFluidContainer}
11
+ *
12
+ * @remarks
13
+ *
11
14
  * This can be extended by different service-specific client packages to additional parameters to
12
- * the user and client details returned in IMember
13
- * @typeParam M - A service-specific member type.
15
+ * the user and client details returned in {@link IMember}.
16
+ *
17
+ * @typeParam M - A service-specific {@link IMember} implementation.
14
18
  */
15
19
  export declare abstract class ServiceAudience<M extends IMember = IMember> extends TypedEventEmitter<IServiceAudienceEvents<M>> implements IServiceAudience<M> {
16
20
  /**
@@ -18,19 +22,25 @@ export declare abstract class ServiceAudience<M extends IMember = IMember> exten
18
22
  */
19
23
  protected readonly container: IContainer;
20
24
  /**
21
- * Audience object which includes all the existing members of the container.
25
+ * Audience object which includes all the existing members of the {@link IFluidContainer | container}.
22
26
  */
23
27
  protected readonly audience: IAudience;
24
28
  /**
25
- * Retain the most recent member list. This is so we have more information about a member
26
- * leaving the audience in the removeMember event. It allows us to match the behavior of the
27
- * addMember event where it only fires on a change to the members this class exposes (and would
28
- * actually produce a change in what getMembers returns). It also allows us to provide the
29
- * client details in the event which makes it easier to find that client connection in a map
30
- * keyed on the userId and not clientId.
31
- * This map will always be up-to-date in a removeMember event because it is set once at
32
- * construction and in every addMember event.
33
- * It is mapped clientId to M to be better work with what the IAudience event provides
29
+ * Retain the most recent member list.
30
+ *
31
+ * @remarks
32
+ *
33
+ * This is so we have more information about a member leaving the audience in the `removeMember` event.
34
+ *
35
+ * It allows us to match the behavior of the `addMember` event where it only fires on a change to the members this
36
+ * class exposes (and would actually produce a change in what `getMembers` returns).
37
+ *
38
+ * It also allows us to provide the client details in the event which makes it easier to find that client connection
39
+ * in a map keyed on the `userId` and not `clientId`.
40
+ *
41
+ * This map will always be up-to-date in a `removeMember` event because it is set once at construction and in
42
+ * every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}
43
+ * events provide.
34
44
  */
35
45
  protected lastMembers: Map<string, M>;
36
46
  constructor(
@@ -40,6 +50,7 @@ export declare abstract class ServiceAudience<M extends IMember = IMember> exten
40
50
  container: IContainer);
41
51
  /**
42
52
  * Provides ability for inheriting class to modify/extend the audience object.
53
+ *
43
54
  * @param audienceMember - Record of a specific audience member.
44
55
  */
45
56
  protected abstract createServiceMember(audienceMember: IClient): M;
@@ -50,11 +61,12 @@ export declare abstract class ServiceAudience<M extends IMember = IMember> exten
50
61
  /**
51
62
  * {@inheritDoc IServiceAudience.getMyself}
52
63
  */
53
- getMyself(): M | undefined;
64
+ getMyself(): Myself<M> | undefined;
54
65
  private getMember;
55
66
  /**
56
67
  * Provides ability for the inheriting class to include/omit specific members.
57
68
  * An example use case is omitting the summarizer client.
69
+ *
58
70
  * @param member - Member to be included/omitted.
59
71
  */
60
72
  protected shouldIncludeAsMember(member: IClient): boolean;
@@ -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,SAAS,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE5E;;;;;GAKG;AACH,8BAAsB,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,CAC/D,SAAQ,iBAAiB,CAAC,sBAAsB,CAAC,CAAC,CAAC,CACnD,YAAW,gBAAgB,CAAC,CAAC,CAAC;IAoB5B;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,UAAU;IAtB1C;;OAE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G,CAAC,MAAM,EAAE,CAAC,CAAC,CAAa;;IAGhD;;OAEG;IACgB,SAAS,EAAE,UAAU;IA2B1C;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,mBAAmB,CAAC,cAAc,EAAE,OAAO,GAAG,CAAC;IAElE;;OAEG;IACI,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAuBnC;;OAEG;IACI,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS;IAgBzC,OAAO,CAAC,SAAS;IAejB;;;;;OAKG;IACH,SAAS,CAAC,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO;CAI1D"}
@@ -4,10 +4,14 @@
4
4
  */
5
5
  import { TypedEventEmitter } from "@fluidframework/common-utils";
6
6
  /**
7
- * Base class for providing audience information for sessions interacting with FluidContainer
7
+ * Base class for providing audience information for sessions interacting with {@link IFluidContainer}
8
+ *
9
+ * @remarks
10
+ *
8
11
  * This can be extended by different service-specific client packages to additional parameters to
9
- * the user and client details returned in IMember
10
- * @typeParam M - A service-specific member type.
12
+ * the user and client details returned in {@link IMember}.
13
+ *
14
+ * @typeParam M - A service-specific {@link IMember} implementation.
11
15
  */
12
16
  export class ServiceAudience extends TypedEventEmitter {
13
17
  constructor(
@@ -18,15 +22,21 @@ export class ServiceAudience extends TypedEventEmitter {
18
22
  super();
19
23
  this.container = container;
20
24
  /**
21
- * Retain the most recent member list. This is so we have more information about a member
22
- * leaving the audience in the removeMember event. It allows us to match the behavior of the
23
- * addMember event where it only fires on a change to the members this class exposes (and would
24
- * actually produce a change in what getMembers returns). It also allows us to provide the
25
- * client details in the event which makes it easier to find that client connection in a map
26
- * keyed on the userId and not clientId.
27
- * This map will always be up-to-date in a removeMember event because it is set once at
28
- * construction and in every addMember event.
29
- * It is mapped clientId to M to be better work with what the IAudience event provides
25
+ * Retain the most recent member list.
26
+ *
27
+ * @remarks
28
+ *
29
+ * This is so we have more information about a member leaving the audience in the `removeMember` event.
30
+ *
31
+ * It allows us to match the behavior of the `addMember` event where it only fires on a change to the members this
32
+ * class exposes (and would actually produce a change in what `getMembers` returns).
33
+ *
34
+ * It also allows us to provide the client details in the event which makes it easier to find that client connection
35
+ * in a map keyed on the `userId` and not `clientId`.
36
+ *
37
+ * This map will always be up-to-date in a `removeMember` event because it is set once at construction and in
38
+ * every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}
39
+ * events provide.
30
40
  */
31
41
  this.lastMembers = new Map();
32
42
  this.audience = container.audience;
@@ -80,7 +90,12 @@ export class ServiceAudience extends TypedEventEmitter {
80
90
  if (clientId === undefined) {
81
91
  return undefined;
82
92
  }
83
- return this.getMember(clientId);
93
+ const member = this.getMember(clientId);
94
+ if (member === undefined) {
95
+ return undefined;
96
+ }
97
+ const myself = Object.assign(Object.assign({}, member), { currentConnection: clientId });
98
+ return myself;
84
99
  }
85
100
  getMember(clientId) {
86
101
  // Fetch the user ID assoicated with this client ID from the runtime
@@ -99,6 +114,7 @@ export class ServiceAudience extends TypedEventEmitter {
99
114
  /**
100
115
  * Provides ability for the inheriting class to include/omit specific members.
101
116
  * An example use case is omitting the summarizer client.
117
+ *
102
118
  * @param member - Member to be included/omitted.
103
119
  */
104
120
  shouldIncludeAsMember(member) {
@@ -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;IAoBpD;IACE;;OAEG;IACgB,SAAqB;QAExC,KAAK,EAAE,CAAC;QAFW,cAAS,GAAT,SAAS,CAAY;QAjB1C;;;;;;;;;;WAUG;QACO,gBAAW,GAAmB,IAAI,GAAG,EAAE,CAAC;QAShD,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;QAEnC,iFAAiF;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E;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;\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SAAS,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,MAAM,KAAK,SAAS,EAAE;YACtB,OAAO,SAAS,CAAC;SAClB;QAEH,MAAM,MAAM,mCAAmB,MAAM,KAAE,iBAAiB,EAAE,QAAQ,GAAE,CAAC;QAErE,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,SAAS,CAAC,QAAgB;QAChC,oEAAoE;QACpE,MAAM,sBAAsB,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACjE,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;;;;;OAKG;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, Myself } from \"./types\";\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 M - A service-specific {@link IMember} implementation.\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 {@link IFluidContainer | container}.\n */\n protected readonly audience: IAudience;\n\n /**\n * Retain the most recent member list.\n *\n * @remarks\n *\n * This is so we have more information about a member leaving the audience in the `removeMember` event.\n *\n * It allows us to match the behavior of the `addMember` event where it only fires on a change to the members this\n * class exposes (and would actually produce a change in what `getMembers` returns).\n *\n * It also allows us to provide the client details in the event which makes it easier to find that client connection\n * in a map keyed on the `userId` and not `clientId`.\n *\n * This map will always be up-to-date in a `removeMember` event because it is set once at construction and in\n * every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}\n * events provide.\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 *\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(): Myself<M> | undefined {\n const clientId = this.container.clientId;\n if (clientId === undefined) {\n return undefined;\n }\n\n const member = this.getMember(clientId);\n if (member === undefined) {\n return undefined;\n }\n\n const myself: Myself<M> = { ...member, currentConnection: clientId };\n\n return myself;\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 *\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
@@ -7,56 +7,65 @@ import { IFluidLoadable } from "@fluidframework/core-interfaces";
7
7
  import { IChannelFactory } from "@fluidframework/datastore-definitions";
8
8
  import { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions";
9
9
  /**
10
- * A mapping of string identifiers to instantiated DataObjects or SharedObjects.
10
+ * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
11
11
  */
12
12
  export declare type LoadableObjectRecord = Record<string, IFluidLoadable>;
13
13
  /**
14
- * A mapping of string identifiers to classes that will later be used to instantiate a corresponding DataObject
15
- * or SharedObject in a LoadableObjectRecord.
14
+ * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
15
+ * or `SharedObject` in a {@link LoadableObjectRecord}.
16
16
  */
17
17
  export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
18
18
  /**
19
- * A LoadableObjectClass is an class object of DataObject or SharedObject
20
- * @typeParam T - The class of the DataObject or SharedObject
19
+ * A class object of `DataObject` or `SharedObject`.
20
+ *
21
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
21
22
  */
22
23
  export declare type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> | SharedObjectClass<T>;
23
24
  /**
24
- * A DataObjectClass is a class that has a factory that can create a DataObject and a
25
- * constructor that will return the type of the DataObject.
26
- * @typeParam T - The class of the DataObject
25
+ * A class that has a factory that can create a `DataObject` and a
26
+ * constructor that will return the type of the `DataObject`.
27
+ *
28
+ * @typeParam T - The class of the `DataObject`.
27
29
  */
28
30
  export declare type DataObjectClass<T extends IFluidLoadable> = {
29
31
  readonly factory: IFluidDataStoreFactory;
30
32
  } & LoadableObjectCtor<T>;
31
33
  /**
32
- * A SharedObjectClass is a class that has a factory that can create a DDS (SharedObject) and a
33
- * constructor that will return the type of the DataObject.
34
- * @typeParam T - The class of the SharedObject
34
+ * A class that has a factory that can create a DDSes (`SharedObject`s) and a
35
+ * constructor that will return the type of the `DataObject`.
36
+ *
37
+ * @typeParam T - The class of the `SharedObject`.
35
38
  */
36
39
  export declare type SharedObjectClass<T extends IFluidLoadable> = {
37
40
  readonly getFactory: () => IChannelFactory;
38
41
  } & LoadableObjectCtor<T>;
39
42
  /**
40
- * An object with a constructor that will return an `IFluidLoadable`.
41
- * @typeParam T - The class of the loadable object
43
+ * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
44
+ *
45
+ * @typeParam T - The class of the loadable object.
42
46
  */
43
47
  export declare type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
44
48
  /**
45
- * The ContainerSchema declares the Fluid objects that will be available in the container. It includes both the
46
- * instances of objects that are initially available upon container creation, as well as the types of objects that may
47
- * be dynamically created throughout the lifetime of the container.
49
+ * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
50
+ *
51
+ * @remarks
52
+ *
53
+ * It includes both the instances of objects that are initially available upon `Container` creation, as well
54
+ * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.
48
55
  */
49
56
  export interface ContainerSchema {
50
57
  /**
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.
58
+ * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.
59
+ *
60
+ * @remarks It uses the key as the id and the value as the loadable object to create.
53
61
  *
54
62
  * @example
55
- * In the example below two objects will be created when the Container is first
63
+ *
64
+ * In the example below two objects will be created when the `Container` is first
56
65
  * created. One with id "map1" that will return a `SharedMap` and the other with
57
66
  * id "pair1" that will return a `KeyValueDataObject`.
58
67
  *
59
- * ```
68
+ * ```typescript
60
69
  * {
61
70
  * map1: SharedMap,
62
71
  * pair1: KeyValueDataObject,
@@ -65,7 +74,9 @@ export interface ContainerSchema {
65
74
  */
66
75
  initialObjects: LoadableObjectClassRecord;
67
76
  /**
68
- * Dynamic objects are Loadable objects that can be created after the initial Container creation.
77
+ * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
78
+ *
79
+ * @remarks
69
80
  *
70
81
  * Types defined in `initialObjects` will always be available and are not required to be provided here.
71
82
  *
@@ -75,60 +86,71 @@ export interface ContainerSchema {
75
86
  dynamicObjectTypes?: LoadableObjectClass<any>[];
76
87
  }
77
88
  /**
78
- * Events that trigger when the roster of members in the Fluid session change.
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.
85
- *
86
- * ### "membersChanged"
87
- *
88
- * The "membersChanged" event is emitted when a member is either added or removed.
89
- *
90
- * #### Listener signature
91
- *
92
- * ```typescript
93
- * () => void;
94
- * ```
95
- *
96
- * ### "memberAdded"
97
- *
98
- * The "memberAdded" event is emitted when a member joins the audience.
99
- *
100
- * #### Listener signature
101
- *
102
- * ```typescript
103
- * (clientId: string, member: M) => void;
104
- * ```
105
- * - `clientId` - A unique identifier for the client
106
- *
107
- * - `member` - The service-specific member object for the client
89
+ * Holds the collection of objects that the container was initially created with, as well as provides the ability
90
+ * to dynamically create further objects during usage.
91
+ */
92
+ export interface IRootDataObject {
93
+ /**
94
+ * Provides a record of the initial objects defined on creation.
95
+ */
96
+ readonly initialObjects: LoadableObjectRecord;
97
+ /**
98
+ * Dynamically creates a new detached collaborative object (DDS/DataObject).
99
+ *
100
+ * @param objectClass - Type of the collaborative object to be created.
101
+ *
102
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
103
+ */
104
+ create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
105
+ }
106
+ /**
107
+ * Signature for {@link IMember} change events.
108
108
  *
109
- * ### "memberRemoved"
109
+ * @param clientId - A unique identifier for the client.
110
+ * @param member - The service-specific member object for the client.
110
111
  *
111
- * The "memberRemoved" event is emitted when a member leaves the audience.
112
+ * @see See {@link IServiceAudienceEvents} for usage details.
113
+ */
114
+ export declare type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;
115
+ /**
116
+ * Events that trigger when the roster of members in the Fluid session change.
112
117
  *
113
- * #### Listener signature
118
+ * @remarks
114
119
  *
115
- * ```typescript
116
- * (clientId: string, member: M) => void;
117
- * ```
118
- * - `clientId` - A unique identifier for the client
120
+ * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s
121
+ * {@link IServiceAudience.getMembers} method will emit events.
119
122
  *
120
- * - `member` - The service-specific member object for the client
121
- * @typeParam M - A service-specific member type.
123
+ * @typeParam M - A service-specific {@link IMember} implementation.
122
124
  */
123
125
  export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
126
+ /**
127
+ * Emitted when a {@link IMember | member}(s) are either added or removed.
128
+ *
129
+ * @eventProperty
130
+ */
124
131
  (event: "membersChanged", listener: () => void): void;
125
- (event: "memberAdded" | "memberRemoved", listener: (clientId: string, member: M) => void): void;
132
+ /**
133
+ * Emitted when a {@link IMember | member} joins the audience.
134
+ *
135
+ * @eventProperty
136
+ */
137
+ (event: "memberAdded", listener: MemberChangedListener<M>): void;
138
+ /**
139
+ * Emitted when a {@link IMember | member} leaves the audience.
140
+ *
141
+ * @eventProperty
142
+ */
143
+ (event: "memberRemoved", listener: MemberChangedListener<M>): void;
126
144
  }
127
145
  /**
128
- * Base interface to be implemented to fetch each service's audience. The generic M allows consumers to further
129
- * extend the client object with service-specific details about the connecting client, such as device information,
130
- * environment, or a username.
131
- * @typeParam M - A service-specific member type.
146
+ * Base interface to be implemented to fetch each service's audience.
147
+ *
148
+ * @remarks
149
+ *
150
+ * The type parameter `M` allows consumers to further extend the client object with service-specific
151
+ * details about the connecting client, such as device information, environment, or a username.
152
+ *
153
+ * @typeParam M - A service-specific {@link IMember} type.
132
154
  */
133
155
  export interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
134
156
  /**
@@ -140,11 +162,12 @@ export interface IServiceAudience<M extends IMember> extends IEventProvider<ISer
140
162
  /**
141
163
  * Returns the current active user on this client once they are connected. Otherwise, returns undefined.
142
164
  */
143
- getMyself(): M | undefined;
165
+ getMyself(): Myself<M> | undefined;
144
166
  }
145
167
  /**
146
- * Base interface for information for each connection made to the Fluid session. This interface can be extended
147
- * to provide additional information specific to each service.
168
+ * Base interface for information for each connection made to the Fluid session.
169
+ *
170
+ * @remarks This interface can be extended to provide additional information specific to each service.
148
171
  */
149
172
  export interface IConnection {
150
173
  /**
@@ -157,8 +180,9 @@ export interface IConnection {
157
180
  mode: "write" | "read";
158
181
  }
159
182
  /**
160
- * Base interface to be implemented to fetch each service's member. This interface can be extended by each service
161
- * to provide additional service-specific user metadata.
183
+ * Base interface to be implemented to fetch each service's member.
184
+ *
185
+ * @remarks This interface can be extended by each service to provide additional service-specific user metadata.
162
186
  */
163
187
  export interface IMember {
164
188
  /**
@@ -170,4 +194,10 @@ export interface IMember {
170
194
  */
171
195
  connections: IConnection[];
172
196
  }
197
+ /**
198
+ * An extended member object that includes currentConnection
199
+ */
200
+ export declare type Myself<M extends IMember = IMember> = M & {
201
+ currentConnection: string;
202
+ };
173
203
  //# sourceMappingURL=types.d.ts.map
@@ -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,sBAAsB,CAAC;CAAE,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAE5E;;;;GAIG;AACH,oBAAY,iBAAiB,CAAC,CAAC,SAAS,cAAc,IAChD;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,eAAe,CAAC;CAAE,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAE9E;;;GAGG;AACH,oBAAY,kBAAkB,CAA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E,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,EAAE,WAAW,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,oBAAY,MAAM,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG;IAAE,iBAAiB,EAAE,MAAM,CAAC;CAAE,CAAC"}
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 * 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"]}
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 `DataObject`s or `SharedObject`s.\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 {@link LoadableObjectRecord}.\n */\nexport type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;\n\n/**\n * A class object of `DataObject` or `SharedObject`.\n *\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 class that has a factory that can create a `DataObject` and a\n * constructor that will return the type of the `DataObject`.\n *\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 class that has a factory that can create a DDSes (`SharedObject`s) and a\n * constructor that will return the type of the `DataObject`.\n *\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 {@link @fluidframework/core-interfaces#IFluidLoadable}.\n *\n * @typeParam T - The class of the loadable object.\n */\nexport type LoadableObjectCtor<T extends IFluidLoadable> = new(...args: any[]) => T;\n\n/**\n * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.\n *\n * @remarks\n *\n * It includes both the instances of objects that are initially available upon `Container` creation, as well\n * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.\n */\nexport interface ContainerSchema {\n /**\n * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.\n *\n * @remarks It uses the key as the id and the value as the loadable object to create.\n *\n * @example\n *\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 * ```typescript\n * {\n * map1: SharedMap,\n * pair1: KeyValueDataObject,\n * }\n * ```\n */\n initialObjects: LoadableObjectClassRecord;\n\n /**\n * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.\n *\n * @remarks\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 * Holds the collection of objects that the container was initially created with, as well as provides the ability\n * to dynamically create further objects during usage.\n */\nexport interface IRootDataObject {\n /**\n * Provides a record of the initial objects defined on creation.\n */\n readonly initialObjects: LoadableObjectRecord;\n\n /**\n * Dynamically creates a new detached collaborative object (DDS/DataObject).\n *\n * @param objectClass - Type of the collaborative object to be created.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n */\n create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;\n}\n\n/**\n * Signature for {@link IMember} change events.\n *\n * @param clientId - A unique identifier for the client.\n * @param member - The service-specific member object for the client.\n *\n * @see See {@link IServiceAudienceEvents} for usage details.\n */\nexport type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;\n\n/**\n * Events that trigger when the roster of members in the Fluid session change.\n *\n * @remarks\n *\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 * @typeParam M - A service-specific {@link IMember} implementation.\n */\nexport interface IServiceAudienceEvents<M extends IMember> extends IEvent {\n /* eslint-disable @typescript-eslint/unified-signatures */\n /**\n * Emitted when a {@link IMember | member}(s) are either added or removed.\n *\n * @eventProperty\n */\n (event: \"membersChanged\", listener: () => void): void;\n\n /**\n * Emitted when a {@link IMember | member} joins the audience.\n *\n * @eventProperty\n */\n (event: \"memberAdded\", listener: MemberChangedListener<M>): void;\n\n /**\n * Emitted when a {@link IMember | member} leaves the audience.\n *\n * @eventProperty\n */\n (event: \"memberRemoved\", listener: MemberChangedListener<M>): void;\n /* eslint-enable @typescript-eslint/unified-signatures */\n}\n\n/**\n * Base interface to be implemented to fetch each service's audience.\n *\n * @remarks\n *\n * The type parameter `M` allows consumers to further extend the client object with service-specific\n * details about the connecting client, such as device information, environment, or a username.\n *\n * @typeParam M - A service-specific {@link IMember} type.\n */\nexport interface IServiceAudience<M extends IMember>\n 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(): Myself<M> | undefined;\n}\n\n/**\n * Base interface for information for each connection made to the Fluid session.\n *\n * @remarks This interface can be extended 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.\n *\n * @remarks This interface can be extended by each service 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\n/**\n * An extended member object that includes currentConnection\n */\nexport type Myself<M extends IMember = IMember> = M & { currentConnection: string; };\n"]}