@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.
- package/.eslintrc.js +1 -1
- package/dist/fluidContainer.d.ts +100 -71
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js +26 -4
- package/dist/fluidContainer.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -14
- package/dist/index.js.map +1 -1
- package/dist/rootDataObject.d.ts +17 -15
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +16 -14
- package/dist/rootDataObject.js.map +1 -1
- package/dist/serviceAudience.d.ts +27 -15
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/serviceAudience.js +29 -13
- package/dist/serviceAudience.js.map +1 -1
- package/dist/types.d.ts +100 -70
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/lib/fluidContainer.d.ts +100 -71
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.js +26 -4
- package/lib/fluidContainer.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -4
- package/lib/index.js.map +1 -1
- package/lib/rootDataObject.d.ts +17 -15
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.js +16 -14
- package/lib/rootDataObject.js.map +1 -1
- package/lib/serviceAudience.d.ts +27 -15
- package/lib/serviceAudience.d.ts.map +1 -1
- package/lib/serviceAudience.js +29 -13
- package/lib/serviceAudience.js.map +1 -1
- package/lib/types.d.ts +100 -70
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +49 -25
- package/prettier.config.cjs +8 -0
- package/src/fluidContainer.ts +121 -75
- package/src/index.ts +19 -4
- package/src/rootDataObject.ts +20 -17
- package/src/serviceAudience.ts +36 -16
- 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
|
|
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
|
|
24
|
-
*
|
|
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
|
|
30
|
-
* constructor that will return the type of the DataObject
|
|
31
|
-
*
|
|
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
|
|
38
|
-
* constructor that will return the type of the DataObject
|
|
39
|
-
*
|
|
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
|
|
46
|
-
*
|
|
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
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
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
|
|
58
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
87
|
-
*
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
*
|
|
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
|
-
*
|
|
119
|
+
* @param clientId - A unique identifier for the client.
|
|
120
|
+
* @param member - The service-specific member object for the client.
|
|
118
121
|
*
|
|
119
|
-
*
|
|
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
|
-
*
|
|
129
|
+
* @remarks
|
|
122
130
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
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.
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
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>
|
|
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.
|
|
158
|
-
*
|
|
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.
|
|
174
|
-
*
|
|
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; };
|