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

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 +85 -70
  3. package/dist/fluidContainer.d.ts.map +1 -1
  4. package/dist/fluidContainer.js +13 -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 +85 -70
  22. package/lib/fluidContainer.d.ts.map +1 -1
  23. package/lib/fluidContainer.js +13 -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 +103 -74
  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
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,63 +94,82 @@ 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
114
- *
115
- * - `member` - The service-specific member object for the client
97
+ * Holds the collection of objects that the container was initially created with, as well as provides the ability
98
+ * to dynamically create further objects during usage.
99
+ */
100
+ export interface IRootDataObject {
101
+ /**
102
+ * Provides a record of the initial objects defined on creation.
103
+ */
104
+ readonly initialObjects: LoadableObjectRecord;
105
+
106
+ /**
107
+ * Dynamically creates a new detached collaborative object (DDS/DataObject).
108
+ *
109
+ * @param objectClass - Type of the collaborative object to be created.
110
+ *
111
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
112
+ */
113
+ create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
114
+ }
115
+
116
+ /**
117
+ * Signature for {@link IMember} change events.
116
118
  *
117
- * ### "memberRemoved"
119
+ * @param clientId - A unique identifier for the client.
120
+ * @param member - The service-specific member object for the client.
118
121
  *
119
- * The "memberRemoved" event is emitted when a member leaves the audience.
122
+ * @see See {@link IServiceAudienceEvents} for usage details.
123
+ */
124
+ export type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;
125
+
126
+ /**
127
+ * Events that trigger when the roster of members in the Fluid session change.
120
128
  *
121
- * #### Listener signature
129
+ * @remarks
122
130
  *
123
- * ```typescript
124
- * (clientId: string, member: M) => void;
125
- * ```
126
- * - `clientId` - A unique identifier for the client
131
+ * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s
132
+ * {@link IServiceAudience.getMembers} method will emit events.
127
133
  *
128
- * - `member` - The service-specific member object for the client
129
- * @typeParam M - A service-specific member type.
134
+ * @typeParam M - A service-specific {@link IMember} implementation.
130
135
  */
131
136
  export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
137
+ /* eslint-disable @typescript-eslint/unified-signatures */
138
+ /**
139
+ * Emitted when a {@link IMember | member}(s) are either added or removed.
140
+ *
141
+ * @eventProperty
142
+ */
132
143
  (event: "membersChanged", listener: () => void): void;
133
- (event: "memberAdded" | "memberRemoved", listener: (clientId: string, member: M) => void): void;
144
+
145
+ /**
146
+ * Emitted when a {@link IMember | member} joins the audience.
147
+ *
148
+ * @eventProperty
149
+ */
150
+ (event: "memberAdded", listener: MemberChangedListener<M>): void;
151
+
152
+ /**
153
+ * Emitted when a {@link IMember | member} leaves the audience.
154
+ *
155
+ * @eventProperty
156
+ */
157
+ (event: "memberRemoved", listener: MemberChangedListener<M>): void;
158
+ /* eslint-enable @typescript-eslint/unified-signatures */
134
159
  }
135
160
 
136
161
  /**
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.
162
+ * Base interface to be implemented to fetch each service's audience.
163
+ *
164
+ * @remarks
165
+ *
166
+ * The type parameter `M` allows consumers to further extend the client object with service-specific
167
+ * details about the connecting client, such as device information, environment, or a username.
168
+ *
169
+ * @typeParam M - A service-specific {@link IMember} type.
141
170
  */
142
- export interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
171
+ export interface IServiceAudience<M extends IMember>
172
+ extends IEventProvider<IServiceAudienceEvents<M>> {
143
173
  /**
144
174
  * Returns an map of all users currently in the Fluid session where key is the userId and the value is the
145
175
  * member object. The implementation may choose to exclude certain connections from the returned map.
@@ -150,12 +180,13 @@ export interface IServiceAudience<M extends IMember> extends IEventProvider<ISer
150
180
  /**
151
181
  * Returns the current active user on this client once they are connected. Otherwise, returns undefined.
152
182
  */
153
- getMyself(): M | undefined;
183
+ getMyself(): Myself<M> | undefined;
154
184
  }
155
185
 
156
186
  /**
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.
187
+ * Base interface for information for each connection made to the Fluid session.
188
+ *
189
+ * @remarks This interface can be extended to provide additional information specific to each service.
159
190
  */
160
191
  export interface IConnection {
161
192
  /**
@@ -170,8 +201,9 @@ export interface IConnection {
170
201
  }
171
202
 
172
203
  /**
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.
204
+ * Base interface to be implemented to fetch each service's member.
205
+ *
206
+ * @remarks This interface can be extended by each service to provide additional service-specific user metadata.
175
207
  */
176
208
  export interface IMember {
177
209
  /**
@@ -184,3 +216,8 @@ export interface IMember {
184
216
  */
185
217
  connections: IConnection[];
186
218
  }
219
+
220
+ /**
221
+ * An extended member object that includes currentConnection
222
+ */
223
+ export type Myself<M extends IMember = IMember> = M & { currentConnection: string; };