@fluidframework/fluid-static 1.2.7 → 2.0.0-dev.1.3.0.96595

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.
@@ -23,20 +23,20 @@ import {
23
23
  import { isDataObjectClass, isSharedObjectClass, parseDataObjectsFromSharedObjects } from "./utils";
24
24
 
25
25
  /**
26
- * Input props for {@link RootDataObject.initializingFirstTime}
26
+ * Input props for {@link RootDataObject.initializingFirstTime}.
27
27
  */
28
28
  export interface RootDataObjectProps {
29
29
  /**
30
30
  * Initial object structure with which the {@link RootDataObject} will be first-time initialized.
31
- * See {@link RootDataObject.initializingFirstTime}
31
+ *
32
+ * @see {@link RootDataObject.initializingFirstTime}
32
33
  */
33
34
  initialObjects: LoadableObjectClassRecord;
34
35
  }
35
36
 
36
37
  /**
37
- * The entry-point/root collaborative object of the Fluid Container.
38
- * This class abstracts the dynamic code required to build a Fluid Container into a static representation
39
- * for end customers.
38
+ * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
39
+ * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
40
40
  */
41
41
  export class RootDataObject extends DataObject<{ InitialState: RootDataObjectProps; }> {
42
42
  private readonly initialObjectsDirKey = "initial-objects-key";
@@ -54,7 +54,7 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
54
54
  * The first time this object is initialized, creates each object identified in
55
55
  * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.
56
56
  *
57
- * See {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}
57
+ * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}
58
58
  */
59
59
  protected async initializingFirstTime(props: RootDataObjectProps) {
60
60
  this.root.createSubDirectory(this.initialObjectsDirKey);
@@ -76,7 +76,7 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
76
76
  * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be
77
77
  * accessed immediately.
78
78
  *
79
- * See {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}
79
+ * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}
80
80
  */
81
81
  protected async hasInitialized() {
82
82
  // We will always load the initial objects so they are available to the developer
@@ -94,7 +94,8 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
94
94
 
95
95
  /**
96
96
  * Provides a record of the initial objects defined on creation.
97
- * See {@link RootDataObject.initializingFirstTime}
97
+ *
98
+ * @see {@link RootDataObject.initializingFirstTime}
98
99
  */
99
100
  public get initialObjects(): LoadableObjectRecord {
100
101
  if (Object.keys(this._initialObjects).length === 0) {
@@ -105,7 +106,10 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
105
106
 
106
107
  /**
107
108
  * Dynamically creates a new detached collaborative object (DDS/DataObject).
109
+ *
108
110
  * @param objectClass - Type of the collaborative object to be created.
111
+ *
112
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
109
113
  */
110
114
  public async create<T extends IFluidLoadable>(
111
115
  objectClass: LoadableObjectClass<T>,
@@ -137,8 +141,12 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
137
141
  const rootDataStoreId = "rootDOId";
138
142
 
139
143
  /**
140
- * Container code that provides a single {@link RootDataObject}. This data object is
141
- * dynamically customized (registry and initial objects) based on the schema provided to the container runtime factory.
144
+ * Container code that provides a single {@link RootDataObject}.
145
+ *
146
+ * @remarks
147
+ *
148
+ * This data object is dynamically customized (registry and initial objects) based on the schema provided.
149
+ * to the container runtime factory.
142
150
  */
143
151
  export class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
144
152
  private readonly rootDataObjectFactory: DataObjectFactory<RootDataObject, {
@@ -9,29 +9,39 @@ import { IClient } from "@fluidframework/protocol-definitions";
9
9
  import { IServiceAudience, IServiceAudienceEvents, IMember } from "./types";
10
10
 
11
11
  /**
12
- * Base class for providing audience information for sessions interacting with FluidContainer
12
+ * Base class for providing audience information for sessions interacting with {@link IFluidContainer}
13
+ *
14
+ * @remarks
15
+ *
13
16
  * This can be extended by different service-specific client packages to additional parameters to
14
- * the user and client details returned in IMember
15
- * @typeParam M - A service-specific member type.
17
+ * the user and client details returned in {@link IMember}.
18
+ *
19
+ * @typeParam M - A service-specific {@link IMember} implementation.
16
20
  */
17
21
  export abstract class ServiceAudience<M extends IMember = IMember>
18
22
  extends TypedEventEmitter<IServiceAudienceEvents<M>>
19
23
  implements IServiceAudience<M> {
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
29
  /**
26
- * Retain the most recent member list. This is so we have more information about a member
27
- * leaving the audience in the removeMember event. It allows us to match the behavior of the
28
- * addMember event where it only fires on a change to the members this class exposes (and would
29
- * actually produce a change in what getMembers returns). It also allows us to provide the
30
- * client details in the event which makes it easier to find that client connection in a map
31
- * keyed on the userId and not clientId.
32
- * This map will always be up-to-date in a removeMember event because it is set once at
33
- * construction and in every addMember event.
34
- * It is mapped clientId to M to be better work with what the IAudience event provides
30
+ * Retain the most recent member list.
31
+ *
32
+ * @remarks
33
+ *
34
+ * This is so we have more information about a member leaving the audience in the `removeMember` event.
35
+ *
36
+ * It allows us to match the behavior of the `addMember` event where it only fires on a change to the members this
37
+ * class exposes (and would actually produce a change in what `getMembers` returns).
38
+ *
39
+ * It also allows us to provide the client details in the event which makes it easier to find that client connection
40
+ * in a map keyed on the `userId` and not `clientId`.
41
+ *
42
+ * This map will always be up-to-date in a `removeMember` event because it is set once at construction and in
43
+ * every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}
44
+ * events provide.
35
45
  */
36
46
  protected lastMembers: Map<string, M> = new Map();
37
47
 
@@ -68,6 +78,7 @@ export abstract class ServiceAudience<M extends IMember = IMember>
68
78
 
69
79
  /**
70
80
  * Provides ability for inheriting class to modify/extend the audience object.
81
+ *
71
82
  * @param audienceMember - Record of a specific audience member.
72
83
  */
73
84
  protected abstract createServiceMember(audienceMember: IClient): M;
@@ -127,6 +138,7 @@ export abstract class ServiceAudience<M extends IMember = IMember>
127
138
  /**
128
139
  * Provides ability for the inheriting class to include/omit specific members.
129
140
  * An example use case is omitting the summarizer client.
141
+ *
130
142
  * @param member - Member to be included/omitted.
131
143
  */
132
144
  protected shouldIncludeAsMember(member: IClient): boolean {
package/src/types.ts CHANGED
@@ -9,60 +9,69 @@ import { IChannelFactory } from "@fluidframework/datastore-definitions";
9
9
  import { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions";
10
10
 
11
11
  /**
12
- * A mapping of string identifiers to instantiated DataObjects or SharedObjects.
12
+ * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
13
13
  */
14
14
  export type LoadableObjectRecord = Record<string, IFluidLoadable>;
15
15
 
16
16
  /**
17
- * A mapping of string identifiers to classes that will later be used to instantiate a corresponding DataObject
18
- * or SharedObject in a LoadableObjectRecord.
17
+ * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
18
+ * or `SharedObject` in a {@link LoadableObjectRecord}.
19
19
  */
20
20
  export type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
21
21
 
22
22
  /**
23
- * A LoadableObjectClass is an class object of DataObject or SharedObject
24
- * @typeParam T - The class of the DataObject or SharedObject
23
+ * A class object of `DataObject` or `SharedObject`.
24
+ *
25
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
25
26
  */
26
27
  export type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> | SharedObjectClass<T>;
27
28
 
28
29
  /**
29
- * A DataObjectClass is a class that has a factory that can create a DataObject and a
30
- * constructor that will return the type of the DataObject.
31
- * @typeParam T - The class of the DataObject
30
+ * A class that has a factory that can create a `DataObject` and a
31
+ * constructor that will return the type of the `DataObject`.
32
+ *
33
+ * @typeParam T - The class of the `DataObject`.
32
34
  */
33
35
  export type DataObjectClass<T extends IFluidLoadable>
34
36
  = { readonly factory: IFluidDataStoreFactory; } & LoadableObjectCtor<T>;
35
37
 
36
38
  /**
37
- * A SharedObjectClass is a class that has a factory that can create a DDS (SharedObject) and a
38
- * constructor that will return the type of the DataObject.
39
- * @typeParam T - The class of the SharedObject
39
+ * A class that has a factory that can create a DDSes (`SharedObject`s) and a
40
+ * constructor that will return the type of the `DataObject`.
41
+ *
42
+ * @typeParam T - The class of the `SharedObject`.
40
43
  */
41
44
  export type SharedObjectClass<T extends IFluidLoadable>
42
45
  = { readonly getFactory: () => IChannelFactory; } & LoadableObjectCtor<T>;
43
46
 
44
47
  /**
45
- * An object with a constructor that will return an `IFluidLoadable`.
46
- * @typeParam T - The class of the loadable object
48
+ * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
49
+ *
50
+ * @typeParam T - The class of the loadable object.
47
51
  */
48
52
  export type LoadableObjectCtor<T extends IFluidLoadable> = new(...args: any[]) => T;
49
53
 
50
54
  /**
51
- * The ContainerSchema declares the Fluid objects that will be available in the container. It includes both the
52
- * instances of objects that are initially available upon container creation, as well as the types of objects that may
53
- * be dynamically created throughout the lifetime of the container.
55
+ * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
56
+ *
57
+ * @remarks
58
+ *
59
+ * It includes both the instances of objects that are initially available upon `Container` creation, as well
60
+ * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.
54
61
  */
55
62
  export interface ContainerSchema {
56
63
  /**
57
- * Defines loadable objects that will be created when the `Container` is first created.
58
- * It uses the key as the id and the value as the loadable object to create.
64
+ * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.
65
+ *
66
+ * @remarks It uses the key as the id and the value as the loadable object to create.
59
67
  *
60
68
  * @example
61
- * In the example below two objects will be created when the Container is first
69
+ *
70
+ * In the example below two objects will be created when the `Container` is first
62
71
  * created. One with id "map1" that will return a `SharedMap` and the other with
63
72
  * id "pair1" that will return a `KeyValueDataObject`.
64
73
  *
65
- * ```
74
+ * ```typescript
66
75
  * {
67
76
  * map1: SharedMap,
68
77
  * pair1: KeyValueDataObject,
@@ -72,7 +81,9 @@ export interface ContainerSchema {
72
81
  initialObjects: LoadableObjectClassRecord;
73
82
 
74
83
  /**
75
- * Dynamic objects are Loadable objects that can be created after the initial Container creation.
84
+ * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
85
+ *
86
+ * @remarks
76
87
  *
77
88
  * Types defined in `initialObjects` will always be available and are not required to be provided here.
78
89
  *
@@ -83,61 +94,59 @@ export interface ContainerSchema {
83
94
  }
84
95
 
85
96
  /**
86
- * Events that trigger when the roster of members in the Fluid session change.
87
- * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s
88
- * {@link IServiceAudience.getMembers} method will emit events.
89
- *
90
- * @remarks
91
- *
92
- * The following is the list of events emitted.
93
- *
94
- * ### "membersChanged"
95
- *
96
- * The "membersChanged" event is emitted when a member is either added or removed.
97
- *
98
- * #### Listener signature
99
- *
100
- * ```typescript
101
- * () => void;
102
- * ```
103
- *
104
- * ### "memberAdded"
105
- *
106
- * The "memberAdded" event is emitted when a member joins the audience.
107
- *
108
- * #### Listener signature
109
- *
110
- * ```typescript
111
- * (clientId: string, member: M) => void;
112
- * ```
113
- * - `clientId` - A unique identifier for the client
97
+ * Signature for {@link IMember} change events.
114
98
  *
115
- * - `member` - The service-specific member object for the client
99
+ * @param clientId - A unique identifier for the client.
100
+ * @param member - The service-specific member object for the client.
116
101
  *
117
- * ### "memberRemoved"
118
- *
119
- * The "memberRemoved" event is emitted when a member leaves the audience.
102
+ * @see See {@link IServiceAudienceEvents} for usage details.
103
+ */
104
+ export type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;
105
+
106
+ /**
107
+ * Events that trigger when the roster of members in the Fluid session change.
120
108
  *
121
- * #### Listener signature
109
+ * @remarks
122
110
  *
123
- * ```typescript
124
- * (clientId: string, member: M) => void;
125
- * ```
126
- * - `clientId` - A unique identifier for the client
111
+ * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s
112
+ * {@link IServiceAudience.getMembers} method will emit events.
127
113
  *
128
- * - `member` - The service-specific member object for the client
129
- * @typeParam M - A service-specific member type.
114
+ * @typeParam M - A service-specific {@link IMember} implementation.
130
115
  */
131
116
  export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
117
+ /* eslint-disable @typescript-eslint/unified-signatures */
118
+ /**
119
+ * Emitted when a {@link IMember | member}(s) are either added or removed.
120
+ *
121
+ * @eventProperty
122
+ */
132
123
  (event: "membersChanged", listener: () => void): void;
133
- (event: "memberAdded" | "memberRemoved", listener: (clientId: string, member: M) => void): void;
124
+
125
+ /**
126
+ * Emitted when a {@link IMember | member} joins the audience.
127
+ *
128
+ * @eventProperty
129
+ */
130
+ (event: "memberAdded", listener: MemberChangedListener<M>): void;
131
+
132
+ /**
133
+ * Emitted when a {@link IMember | member} leaves the audience.
134
+ *
135
+ * @eventProperty
136
+ */
137
+ (event: "memberRemoved", listener: MemberChangedListener<M>): void;
138
+ /* eslint-enable @typescript-eslint/unified-signatures */
134
139
  }
135
140
 
136
141
  /**
137
- * Base interface to be implemented to fetch each service's audience. The generic M allows consumers to further
138
- * extend the client object with service-specific details about the connecting client, such as device information,
139
- * environment, or a username.
140
- * @typeParam M - A service-specific member type.
142
+ * Base interface to be implemented to fetch each service's audience.
143
+ *
144
+ * @remarks
145
+ *
146
+ * The type parameter `M` allows consumers to further extend the client object with service-specific
147
+ * details about the connecting client, such as device information, environment, or a username.
148
+ *
149
+ * @typeParam M - A service-specific {@link IMember} type.
141
150
  */
142
151
  export interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
143
152
  /**
@@ -154,8 +163,9 @@ export interface IServiceAudience<M extends IMember> extends IEventProvider<ISer
154
163
  }
155
164
 
156
165
  /**
157
- * Base interface for information for each connection made to the Fluid session. This interface can be extended
158
- * to provide additional information specific to each service.
166
+ * Base interface for information for each connection made to the Fluid session.
167
+ *
168
+ * @remarks This interface can be extended to provide additional information specific to each service.
159
169
  */
160
170
  export interface IConnection {
161
171
  /**
@@ -170,8 +180,9 @@ export interface IConnection {
170
180
  }
171
181
 
172
182
  /**
173
- * Base interface to be implemented to fetch each service's member. This interface can be extended by each service
174
- * 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.
175
186
  */
176
187
  export interface IMember {
177
188
  /**