@fluidframework/fluid-static 1.2.6 → 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.
- package/.mocharc.js +12 -0
- package/dist/fluidContainer.d.ts +63 -66
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js +7 -2
- package/dist/fluidContainer.js.map +1 -1
- package/dist/rootDataObject.d.ts +18 -10
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +15 -8
- package/dist/rootDataObject.js.map +1 -1
- package/dist/serviceAudience.d.ts +25 -13
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/serviceAudience.js +23 -12
- package/dist/serviceAudience.js.map +1 -1
- package/dist/types.d.ts +75 -69
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/lib/fluidContainer.d.ts +63 -66
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.js +7 -2
- package/lib/fluidContainer.js.map +1 -1
- package/lib/rootDataObject.d.ts +18 -10
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.js +15 -8
- package/lib/rootDataObject.js.map +1 -1
- package/lib/serviceAudience.d.ts +25 -13
- package/lib/serviceAudience.d.ts.map +1 -1
- package/lib/serviceAudience.js +23 -12
- package/lib/serviceAudience.js.map +1 -1
- package/lib/types.d.ts +75 -69
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +43 -22
- package/src/fluidContainer.ts +70 -66
- package/src/rootDataObject.ts +18 -10
- package/src/serviceAudience.ts +25 -13
- package/src/types.ts +80 -69
package/src/rootDataObject.ts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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}.
|
|
141
|
-
*
|
|
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, {
|
package/src/serviceAudience.ts
CHANGED
|
@@ -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
|
|
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
|
-
*
|
|
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.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
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
|
|
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,61 +94,59 @@ export interface ContainerSchema {
|
|
|
83
94
|
}
|
|
84
95
|
|
|
85
96
|
/**
|
|
86
|
-
*
|
|
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
|
-
*
|
|
99
|
+
* @param clientId - A unique identifier for the client.
|
|
100
|
+
* @param member - The service-specific member object for the client.
|
|
116
101
|
*
|
|
117
|
-
*
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
*
|
|
109
|
+
* @remarks
|
|
122
110
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
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.
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
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.
|
|
158
|
-
*
|
|
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.
|
|
174
|
-
*
|
|
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
|
/**
|