@fluidframework/fluid-static 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.1
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 +8 -10
- package/.mocharc.js +2 -2
- package/CHANGELOG.md +48 -51
- package/api-extractor.json +2 -2
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +3 -1
- package/dist/rootDataObject.js.map +1 -1
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/serviceAudience.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -4
- package/dist/utils.js.map +1 -1
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.js +3 -1
- package/lib/rootDataObject.js.map +1 -1
- package/lib/serviceAudience.d.ts.map +1 -1
- package/lib/serviceAudience.js.map +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +1 -4
- package/lib/utils.js.map +1 -1
- package/package.json +105 -104
- package/prettier.config.cjs +1 -1
- package/src/fluidContainer.ts +264 -260
- package/src/index.ts +6 -2
- package/src/rootDataObject.ts +152 -148
- package/src/serviceAudience.ts +137 -134
- package/src/types.ts +105 -101
- package/src/utils.ts +30 -42
- package/tsconfig.esnext.json +5 -5
- package/tsconfig.json +10 -16
package/src/types.ts
CHANGED
|
@@ -24,7 +24,9 @@ export type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>
|
|
|
24
24
|
*
|
|
25
25
|
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
26
26
|
*/
|
|
27
|
-
export type LoadableObjectClass<T extends IFluidLoadable> =
|
|
27
|
+
export type LoadableObjectClass<T extends IFluidLoadable> =
|
|
28
|
+
| DataObjectClass<T>
|
|
29
|
+
| SharedObjectClass<T>;
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* A class that has a factory that can create a `DataObject` and a
|
|
@@ -32,8 +34,9 @@ export type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> |
|
|
|
32
34
|
*
|
|
33
35
|
* @typeParam T - The class of the `DataObject`.
|
|
34
36
|
*/
|
|
35
|
-
export type DataObjectClass<T extends IFluidLoadable>
|
|
36
|
-
|
|
37
|
+
export type DataObjectClass<T extends IFluidLoadable> = {
|
|
38
|
+
readonly factory: IFluidDataStoreFactory;
|
|
39
|
+
} & LoadableObjectCtor<T>;
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
42
|
* A class that has a factory that can create a DDSes (`SharedObject`s) and a
|
|
@@ -41,15 +44,16 @@ export type DataObjectClass<T extends IFluidLoadable>
|
|
|
41
44
|
*
|
|
42
45
|
* @typeParam T - The class of the `SharedObject`.
|
|
43
46
|
*/
|
|
44
|
-
export type SharedObjectClass<T extends IFluidLoadable>
|
|
45
|
-
|
|
47
|
+
export type SharedObjectClass<T extends IFluidLoadable> = {
|
|
48
|
+
readonly getFactory: () => IChannelFactory;
|
|
49
|
+
} & LoadableObjectCtor<T>;
|
|
46
50
|
|
|
47
51
|
/**
|
|
48
52
|
* An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
|
|
49
53
|
*
|
|
50
54
|
* @typeParam T - The class of the loadable object.
|
|
51
55
|
*/
|
|
52
|
-
export type LoadableObjectCtor<T extends IFluidLoadable> = new(...args: any[]) => T;
|
|
56
|
+
export type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
|
|
53
57
|
|
|
54
58
|
/**
|
|
55
59
|
* Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
|
|
@@ -60,37 +64,37 @@ export type LoadableObjectCtor<T extends IFluidLoadable> = new(...args: any[]) =
|
|
|
60
64
|
* as the types of objects that may be dynamically created throughout the lifetime of the `Container`.
|
|
61
65
|
*/
|
|
62
66
|
export interface ContainerSchema {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.
|
|
69
|
+
*
|
|
70
|
+
* @remarks It uses the key as the id and the value as the loadable object to create.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
*
|
|
74
|
+
* In the example below two objects will be created when the `Container` is first
|
|
75
|
+
* created. One with id "map1" that will return a `SharedMap` and the other with
|
|
76
|
+
* id "pair1" that will return a `KeyValueDataObject`.
|
|
77
|
+
*
|
|
78
|
+
* ```typescript
|
|
79
|
+
* {
|
|
80
|
+
* map1: SharedMap,
|
|
81
|
+
* pair1: KeyValueDataObject,
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
initialObjects: LoadableObjectClassRecord;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
*
|
|
92
|
+
* Types defined in `initialObjects` will always be available and are not required to be provided here.
|
|
93
|
+
*
|
|
94
|
+
* For best practice it's recommended to define all the dynamic types you create even if they are
|
|
95
|
+
* included via initialObjects.
|
|
96
|
+
*/
|
|
97
|
+
dynamicObjectTypes?: LoadableObjectClass<any>[];
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
/**
|
|
@@ -98,19 +102,19 @@ export interface ContainerSchema {
|
|
|
98
102
|
* to dynamically create further objects during usage.
|
|
99
103
|
*/
|
|
100
104
|
export interface IRootDataObject {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Provides a record of the initial objects defined on creation.
|
|
107
|
+
*/
|
|
108
|
+
readonly initialObjects: LoadableObjectRecord;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Dynamically creates a new detached collaborative object (DDS/DataObject).
|
|
112
|
+
*
|
|
113
|
+
* @param objectClass - Type of the collaborative object to be created.
|
|
114
|
+
*
|
|
115
|
+
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
116
|
+
*/
|
|
117
|
+
create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
/**
|
|
@@ -134,26 +138,26 @@ export type MemberChangedListener<M extends IMember> = (clientId: string, member
|
|
|
134
138
|
* @typeParam M - A service-specific {@link IMember} implementation.
|
|
135
139
|
*/
|
|
136
140
|
export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Emitted when a {@link IMember | member}(s) are either added or removed.
|
|
143
|
+
*
|
|
144
|
+
* @eventProperty
|
|
145
|
+
*/
|
|
146
|
+
(event: "membersChanged", listener: () => void): void;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Emitted when a {@link IMember | member} joins the audience.
|
|
150
|
+
*
|
|
151
|
+
* @eventProperty
|
|
152
|
+
*/
|
|
153
|
+
(event: "memberAdded", listener: MemberChangedListener<M>): void;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Emitted when a {@link IMember | member} leaves the audience.
|
|
157
|
+
*
|
|
158
|
+
* @eventProperty
|
|
159
|
+
*/
|
|
160
|
+
(event: "memberRemoved", listener: MemberChangedListener<M>): void;
|
|
157
161
|
}
|
|
158
162
|
|
|
159
163
|
/**
|
|
@@ -167,18 +171,18 @@ export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
|
|
|
167
171
|
* @typeParam M - A service-specific {@link IMember} type.
|
|
168
172
|
*/
|
|
169
173
|
export interface IServiceAudience<M extends IMember>
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
174
|
+
extends IEventProvider<IServiceAudienceEvents<M>> {
|
|
175
|
+
/**
|
|
176
|
+
* Returns an map of all users currently in the Fluid session where key is the userId and the value is the
|
|
177
|
+
* member object. The implementation may choose to exclude certain connections from the returned map.
|
|
178
|
+
* E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.
|
|
179
|
+
*/
|
|
180
|
+
getMembers(): Map<string, M>;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Returns the current active user on this client once they are connected. Otherwise, returns undefined.
|
|
184
|
+
*/
|
|
185
|
+
getMyself(): Myself<M> | undefined;
|
|
182
186
|
}
|
|
183
187
|
|
|
184
188
|
/**
|
|
@@ -187,15 +191,15 @@ export interface IServiceAudience<M extends IMember>
|
|
|
187
191
|
* @remarks This interface can be extended to provide additional information specific to each service.
|
|
188
192
|
*/
|
|
189
193
|
export interface IConnection {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
/**
|
|
195
|
+
* A unique ID for the connection. A single user may have multiple connections, each with a different ID.
|
|
196
|
+
*/
|
|
197
|
+
id: string;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Whether the connection is in read or read/write mode.
|
|
201
|
+
*/
|
|
202
|
+
mode: "write" | "read";
|
|
199
203
|
}
|
|
200
204
|
|
|
201
205
|
/**
|
|
@@ -204,18 +208,18 @@ export interface IConnection {
|
|
|
204
208
|
* @remarks This interface can be extended by each service to provide additional service-specific user metadata.
|
|
205
209
|
*/
|
|
206
210
|
export interface IMember {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
211
|
+
/**
|
|
212
|
+
* An ID for the user, unique among each individual user connecting to the session.
|
|
213
|
+
*/
|
|
214
|
+
userId: string;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The set of connections the user has made, e.g. from multiple tabs or devices.
|
|
218
|
+
*/
|
|
219
|
+
connections: IConnection[];
|
|
216
220
|
}
|
|
217
221
|
|
|
218
222
|
/**
|
|
219
223
|
* An extended member object that includes currentConnection
|
|
220
224
|
*/
|
|
221
|
-
export type Myself<M extends IMember = IMember> = M & { currentConnection: string
|
|
225
|
+
export type Myself<M extends IMember = IMember> = M & { currentConnection: string };
|
package/src/utils.ts
CHANGED
|
@@ -5,27 +5,20 @@
|
|
|
5
5
|
|
|
6
6
|
import { IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
7
7
|
import { NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions";
|
|
8
|
-
import {
|
|
9
|
-
ContainerSchema,
|
|
10
|
-
DataObjectClass,
|
|
11
|
-
LoadableObjectClass,
|
|
12
|
-
SharedObjectClass,
|
|
13
|
-
} from "./types";
|
|
8
|
+
import { ContainerSchema, DataObjectClass, LoadableObjectClass, SharedObjectClass } from "./types";
|
|
14
9
|
|
|
15
10
|
/**
|
|
16
11
|
* Runtime check to determine if a class is a DataObject type
|
|
17
12
|
*/
|
|
18
13
|
export const isDataObjectClass = (obj: any): obj is DataObjectClass<any> => {
|
|
19
|
-
|
|
14
|
+
return obj?.factory !== undefined;
|
|
20
15
|
};
|
|
21
16
|
|
|
22
17
|
/**
|
|
23
18
|
* Runtime check to determine if a class is a SharedObject type
|
|
24
19
|
*/
|
|
25
|
-
export const isSharedObjectClass = (
|
|
26
|
-
|
|
27
|
-
): obj is SharedObjectClass<any> => {
|
|
28
|
-
return obj?.getFactory !== undefined;
|
|
20
|
+
export const isSharedObjectClass = (obj: any): obj is SharedObjectClass<any> => {
|
|
21
|
+
return obj?.getFactory !== undefined;
|
|
29
22
|
};
|
|
30
23
|
|
|
31
24
|
/**
|
|
@@ -34,36 +27,31 @@ export const isSharedObjectClass = (
|
|
|
34
27
|
* of DataObject types and an array of SharedObjects.
|
|
35
28
|
*/
|
|
36
29
|
export const parseDataObjectsFromSharedObjects = (
|
|
37
|
-
|
|
30
|
+
schema: ContainerSchema,
|
|
38
31
|
): [NamedFluidDataStoreRegistryEntry[], IChannelFactory[]] => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"Container cannot be initialized without any DataTypes",
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return [Array.from(registryEntries), Array.from(sharedObjects)];
|
|
32
|
+
const registryEntries: Set<NamedFluidDataStoreRegistryEntry> = new Set();
|
|
33
|
+
const sharedObjects: Set<IChannelFactory> = new Set();
|
|
34
|
+
|
|
35
|
+
const tryAddObject = (obj: LoadableObjectClass<any>) => {
|
|
36
|
+
if (isSharedObjectClass(obj)) {
|
|
37
|
+
sharedObjects.add(obj.getFactory());
|
|
38
|
+
} else if (isDataObjectClass(obj)) {
|
|
39
|
+
registryEntries.add([obj.factory.type, Promise.resolve(obj.factory)]);
|
|
40
|
+
} else {
|
|
41
|
+
throw new Error(`Entry is neither a DataObject or a SharedObject`);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Add the object types that will be initialized
|
|
46
|
+
const dedupedObjects = new Set([
|
|
47
|
+
...Object.values(schema.initialObjects),
|
|
48
|
+
...(schema.dynamicObjectTypes ?? []),
|
|
49
|
+
]);
|
|
50
|
+
dedupedObjects.forEach(tryAddObject);
|
|
51
|
+
|
|
52
|
+
if (registryEntries.size === 0 && sharedObjects.size === 0) {
|
|
53
|
+
throw new Error("Container cannot be initialized without any DataTypes");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return [Array.from(registryEntries), Array.from(sharedObjects)];
|
|
69
57
|
};
|
package/tsconfig.esnext.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
]
|
|
13
|
-
},
|
|
14
|
-
"include": [
|
|
15
|
-
"src/**/*"
|
|
16
|
-
]
|
|
17
|
-
}
|
|
2
|
+
"extends": "@fluidframework/build-common/ts-common-config.json",
|
|
3
|
+
"exclude": ["src/test/**/*"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"composite": true,
|
|
8
|
+
"types": ["node"],
|
|
9
|
+
},
|
|
10
|
+
"include": ["src/**/*"],
|
|
11
|
+
}
|