@fluidframework/fluid-static 2.0.0-rc.2.0.1 → 2.0.0-rc.3.0.0
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/CHANGELOG.md +35 -0
- package/api-report/fluid-static.api.md +13 -21
- package/dist/fluidContainer.d.ts +7 -2
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js +3 -2
- 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/public.d.ts +27 -0
- package/dist/rootDataObject.d.ts +5 -1
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +13 -11
- package/dist/rootDataObject.js.map +1 -1
- package/dist/serviceAudience.d.ts +2 -2
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/serviceAudience.js.map +1 -1
- package/dist/types.d.ts +15 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +6 -5
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +16 -9
- package/dist/utils.js.map +1 -1
- package/internal.d.ts +11 -0
- package/lib/fluidContainer.d.ts +7 -2
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.js +1 -0
- 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.map +1 -1
- package/lib/public.d.ts +27 -0
- package/lib/rootDataObject.d.ts +5 -1
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.js +7 -5
- package/lib/rootDataObject.js.map +1 -1
- package/lib/serviceAudience.d.ts +2 -2
- package/lib/serviceAudience.d.ts.map +1 -1
- package/lib/serviceAudience.js.map +1 -1
- package/lib/types.d.ts +15 -31
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils.d.ts +6 -5
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +14 -7
- package/lib/utils.js.map +1 -1
- package/package.json +44 -55
- package/src/fluidContainer.ts +10 -7
- package/src/index.ts +0 -2
- package/src/rootDataObject.ts +16 -13
- package/src/serviceAudience.ts +4 -2
- package/src/types.ts +16 -34
- package/src/utils.ts +32 -19
- package/api-extractor-cjs.json +0 -8
- package/dist/fluid-static-alpha.d.ts +0 -424
- package/dist/fluid-static-beta.d.ts +0 -428
- package/dist/fluid-static-public.d.ts +0 -428
- package/dist/fluid-static-untrimmed.d.ts +0 -480
- package/lib/fluid-static-alpha.d.ts +0 -424
- package/lib/fluid-static-beta.d.ts +0 -428
- package/lib/fluid-static-public.d.ts +0 -428
- package/lib/fluid-static-untrimmed.d.ts +0 -480
- package/lib/test/fluidContainer.spec.js +0 -21
- package/lib/test/fluidContainer.spec.js.map +0 -1
- package/lib/test/types/validateFluidStaticPrevious.generated.js +0 -46
- package/lib/test/types/validateFluidStaticPrevious.generated.js.map +0 -1
- package/lib/test/utils.spec.js +0 -86
- package/lib/test/utils.spec.js.map +0 -1
- /package/{dist → lib}/tsdoc-metadata.json +0 -0
package/src/rootDataObject.ts
CHANGED
|
@@ -2,23 +2,25 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
|
|
5
6
|
import {
|
|
6
7
|
BaseContainerRuntimeFactory,
|
|
7
8
|
DataObject,
|
|
8
9
|
DataObjectFactory,
|
|
9
|
-
} from "@fluidframework/aqueduct";
|
|
10
|
-
import { type
|
|
10
|
+
} from "@fluidframework/aqueduct/internal";
|
|
11
|
+
import { type IRuntimeFactory } from "@fluidframework/container-definitions/internal";
|
|
12
|
+
import { type ContainerRuntime } from "@fluidframework/container-runtime/internal";
|
|
13
|
+
import { type IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
|
|
11
14
|
import {
|
|
12
15
|
type FluidObject,
|
|
13
16
|
type IFluidLoadable,
|
|
14
17
|
type IRequest,
|
|
15
18
|
type IResponse,
|
|
16
19
|
} from "@fluidframework/core-interfaces";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { RequestParser } from "@fluidframework/runtime-utils";
|
|
20
|
-
import {
|
|
21
|
-
import { type IDirectory } from "@fluidframework/map";
|
|
20
|
+
import { type IDirectory } from "@fluidframework/map/internal";
|
|
21
|
+
import { FlushMode } from "@fluidframework/runtime-definitions/internal";
|
|
22
|
+
import { RequestParser } from "@fluidframework/runtime-utils/internal";
|
|
23
|
+
import type { ISharedObjectKind } from "@fluidframework/shared-object-base";
|
|
22
24
|
|
|
23
25
|
import {
|
|
24
26
|
type ContainerSchema,
|
|
@@ -26,12 +28,11 @@ import {
|
|
|
26
28
|
type LoadableObjectClass,
|
|
27
29
|
type LoadableObjectClassRecord,
|
|
28
30
|
type LoadableObjectRecord,
|
|
29
|
-
type SharedObjectClass,
|
|
30
31
|
} from "./types.js";
|
|
31
32
|
import {
|
|
32
33
|
type InternalDataObjectClass,
|
|
33
34
|
isDataObjectClass,
|
|
34
|
-
|
|
35
|
+
isSharedObjectKind,
|
|
35
36
|
parseDataObjectsFromSharedObjects,
|
|
36
37
|
} from "./utils.js";
|
|
37
38
|
|
|
@@ -128,9 +129,9 @@ class RootDataObject
|
|
|
128
129
|
*/
|
|
129
130
|
public async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {
|
|
130
131
|
if (isDataObjectClass(objectClass)) {
|
|
131
|
-
return this.createDataObject
|
|
132
|
-
} else if (
|
|
133
|
-
return this.createSharedObject
|
|
132
|
+
return this.createDataObject(objectClass);
|
|
133
|
+
} else if (isSharedObjectKind(objectClass)) {
|
|
134
|
+
return this.createSharedObject(objectClass);
|
|
134
135
|
}
|
|
135
136
|
throw new Error("Could not create new Fluid object because an unknown object was passed");
|
|
136
137
|
}
|
|
@@ -146,7 +147,7 @@ class RootDataObject
|
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
private createSharedObject<T extends IFluidLoadable>(
|
|
149
|
-
sharedObjectClass:
|
|
150
|
+
sharedObjectClass: ISharedObjectKind<T>,
|
|
150
151
|
): T {
|
|
151
152
|
const factory = sharedObjectClass.getFactory();
|
|
152
153
|
const obj = this.runtime.createChannel(undefined, factory.type);
|
|
@@ -226,12 +227,14 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
|
226
227
|
super({
|
|
227
228
|
registryEntries: [rootDataObjectFactory.registryEntry],
|
|
228
229
|
requestHandlers: [getDefaultObject],
|
|
230
|
+
// WARNING: These settigs are not compatible with FF 1.3 clients!
|
|
229
231
|
runtimeOptions: {
|
|
230
232
|
// temporary workaround to disable message batching until the message batch size issue is resolved
|
|
231
233
|
// resolution progress is tracked by the Feature 465 work item in AzDO
|
|
232
234
|
flushMode: FlushMode.Immediate,
|
|
233
235
|
// The runtime compressor is required to be on to use @fluidframework/tree.
|
|
234
236
|
enableRuntimeIdCompressor: "on",
|
|
237
|
+
explicitSchemaControl: true,
|
|
235
238
|
},
|
|
236
239
|
provideEntryPoint,
|
|
237
240
|
});
|
package/src/serviceAudience.ts
CHANGED
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
7
|
-
import { type IAudience
|
|
7
|
+
import { type IAudience } from "@fluidframework/container-definitions";
|
|
8
|
+
import { type IContainer } from "@fluidframework/container-definitions/internal";
|
|
8
9
|
import { type IClient } from "@fluidframework/protocol-definitions";
|
|
10
|
+
|
|
9
11
|
import {
|
|
12
|
+
type IMember,
|
|
10
13
|
type IServiceAudience,
|
|
11
14
|
type IServiceAudienceEvents,
|
|
12
|
-
type IMember,
|
|
13
15
|
type Myself,
|
|
14
16
|
} from "./types.js";
|
|
15
17
|
|
package/src/types.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
type IEventProvider,
|
|
9
9
|
type IFluidLoadable,
|
|
10
10
|
} from "@fluidframework/core-interfaces";
|
|
11
|
-
import { type
|
|
11
|
+
import { type ISharedObjectKind } from "@fluidframework/shared-object-base";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
|
|
@@ -33,11 +33,11 @@ export type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;
|
|
|
33
33
|
* There are some edge cases in TypeScript where the order of the members in a union matter.
|
|
34
34
|
* Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.
|
|
35
35
|
* In this case, its better to have the desired match and/or the simpler type first.
|
|
36
|
-
* In this case placing
|
|
36
|
+
* In this case placing ISharedObjectKind fixed one usage and didn't break anything, and generally seems more likely to work than the reverse, so this is the order being used.
|
|
37
37
|
* This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].
|
|
38
38
|
*/
|
|
39
39
|
export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> =
|
|
40
|
-
|
|
|
40
|
+
| ISharedObjectKind<T>
|
|
41
41
|
| DataObjectClass<T>;
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -45,33 +45,15 @@ export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> =
|
|
|
45
45
|
* constructor that will return the type of the `DataObject`.
|
|
46
46
|
*
|
|
47
47
|
* @typeParam T - The class of the `DataObject`.
|
|
48
|
+
* @privateRemarks
|
|
49
|
+
* Having both `factory` and `LoadableObjectCtor` is redundant, and having `factory` not actually work as a factory is also strange.
|
|
50
|
+
* This may need some refinement.
|
|
48
51
|
* @public
|
|
49
52
|
*/
|
|
50
|
-
export type DataObjectClass<T extends IFluidLoadable> = {
|
|
51
|
-
readonly factory: { IFluidDataStoreFactory: DataObjectClass<T>["factory"] };
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* A factory that produces a factory that can create a DDSes (`SharedObject`s).
|
|
56
|
-
*
|
|
57
|
-
* @typeParam T - The class of the `SharedObject`.
|
|
58
|
-
* @public
|
|
59
|
-
*/
|
|
60
|
-
export interface SharedObjectClass<T extends IFluidLoadable> {
|
|
61
|
-
/**
|
|
62
|
-
* Gets the factory this factory is a wrapper for.
|
|
63
|
-
*/
|
|
64
|
-
readonly getFactory: () => IChannelFactory<T>;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
|
|
69
|
-
*
|
|
70
|
-
* @typeParam T - The class of the loadable object.
|
|
71
|
-
* @public
|
|
72
|
-
*/
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
-
export type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
|
|
53
|
+
export type DataObjectClass<T extends IFluidLoadable = IFluidLoadable> = {
|
|
54
|
+
readonly factory: { readonly IFluidDataStoreFactory: DataObjectClass<T>["factory"] };
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
} & (new (...args: any[]) => T);
|
|
75
57
|
|
|
76
58
|
/**
|
|
77
59
|
* Represents properties that can be attached to a container.
|
|
@@ -213,7 +195,7 @@ export interface IServiceAudience<M extends IMember>
|
|
|
213
195
|
* member object. The implementation may choose to exclude certain connections from the returned map.
|
|
214
196
|
* E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.
|
|
215
197
|
*/
|
|
216
|
-
getMembers():
|
|
198
|
+
getMembers(): ReadonlyMap<string, M>;
|
|
217
199
|
|
|
218
200
|
/**
|
|
219
201
|
* Returns the current active user on this client once they are connected. Otherwise, returns undefined.
|
|
@@ -231,12 +213,12 @@ export interface IConnection {
|
|
|
231
213
|
/**
|
|
232
214
|
* A unique ID for the connection. A single user may have multiple connections, each with a different ID.
|
|
233
215
|
*/
|
|
234
|
-
id: string;
|
|
216
|
+
readonly id: string;
|
|
235
217
|
|
|
236
218
|
/**
|
|
237
219
|
* Whether the connection is in read or read/write mode.
|
|
238
220
|
*/
|
|
239
|
-
mode: "write" | "read";
|
|
221
|
+
readonly mode: "write" | "read";
|
|
240
222
|
}
|
|
241
223
|
|
|
242
224
|
/**
|
|
@@ -249,16 +231,16 @@ export interface IMember {
|
|
|
249
231
|
/**
|
|
250
232
|
* An ID for the user, unique among each individual user connecting to the session.
|
|
251
233
|
*/
|
|
252
|
-
userId: string;
|
|
234
|
+
readonly userId: string;
|
|
253
235
|
|
|
254
236
|
/**
|
|
255
237
|
* The set of connections the user has made, e.g. from multiple tabs or devices.
|
|
256
238
|
*/
|
|
257
|
-
connections: IConnection[];
|
|
239
|
+
readonly connections: IConnection[];
|
|
258
240
|
}
|
|
259
241
|
|
|
260
242
|
/**
|
|
261
243
|
* An extended member object that includes currentConnection
|
|
262
244
|
* @public
|
|
263
245
|
*/
|
|
264
|
-
export type Myself<M extends IMember = IMember> = M & { currentConnection: string };
|
|
246
|
+
export type Myself<M extends IMember = IMember> = M & { readonly currentConnection: string };
|
package/src/utils.ts
CHANGED
|
@@ -3,18 +3,16 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { type IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
6
7
|
import { type IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
7
8
|
import {
|
|
8
9
|
type IFluidDataStoreFactory,
|
|
9
10
|
type NamedFluidDataStoreRegistryEntry,
|
|
10
|
-
} from "@fluidframework/runtime-definitions";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type LoadableObjectClass,
|
|
16
|
-
type SharedObjectClass,
|
|
17
|
-
} from "./types.js";
|
|
11
|
+
} from "@fluidframework/runtime-definitions/internal";
|
|
12
|
+
import type { ISharedObjectKind } from "@fluidframework/shared-object-base";
|
|
13
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
14
|
+
|
|
15
|
+
import { type ContainerSchema, type DataObjectClass, type LoadableObjectClass } from "./types.js";
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
18
|
* An internal type used by the internal type guard isDataObjectClass to cast a
|
|
@@ -35,26 +33,41 @@ export function isDataObjectClass<T extends IFluidLoadable>(
|
|
|
35
33
|
/**
|
|
36
34
|
* Runtime check to determine if a class is a DataObject type.
|
|
37
35
|
*/
|
|
38
|
-
export function isDataObjectClass(
|
|
36
|
+
export function isDataObjectClass(
|
|
37
|
+
obj: LoadableObjectClass,
|
|
38
|
+
): obj is InternalDataObjectClass<IFluidLoadable>;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Runtime check to determine if a class is a DataObject type.
|
|
42
42
|
*/
|
|
43
|
-
export function isDataObjectClass(
|
|
43
|
+
export function isDataObjectClass(
|
|
44
|
+
obj: LoadableObjectClass,
|
|
45
|
+
): obj is InternalDataObjectClass<IFluidLoadable> {
|
|
44
46
|
const maybe = obj as Partial<InternalDataObjectClass<IFluidLoadable>> | undefined;
|
|
45
|
-
|
|
47
|
+
const isDataObject =
|
|
46
48
|
maybe?.factory?.IFluidDataStoreFactory !== undefined &&
|
|
47
|
-
maybe
|
|
48
|
-
|
|
49
|
+
maybe.factory.IFluidDataStoreFactory === maybe.factory;
|
|
50
|
+
|
|
51
|
+
if (
|
|
52
|
+
isDataObject ===
|
|
53
|
+
((obj as Partial<ISharedObjectKind<IFluidLoadable>>).getFactory !== undefined)
|
|
54
|
+
) {
|
|
55
|
+
// TODO: Currently nothing in the types or docs requires an actual DataObjectClass to not have a member called "getFactory" so there is a risk of this being a false positive.
|
|
56
|
+
// Refactoring the use of LoadableObjectClass such that explicit down casting is not required (for example by having a single factory API shared by both cases) could avoid problems like this.
|
|
57
|
+
throw new UsageError("Invalid LoadableObjectClass");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return isDataObject;
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
/**
|
|
52
64
|
* Runtime check to determine if a class is a SharedObject type
|
|
53
65
|
*/
|
|
54
|
-
export
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
export function isSharedObjectKind(
|
|
67
|
+
obj: LoadableObjectClass,
|
|
68
|
+
): obj is ISharedObjectKind<IFluidLoadable> {
|
|
69
|
+
return !isDataObjectClass(obj);
|
|
70
|
+
}
|
|
58
71
|
|
|
59
72
|
/**
|
|
60
73
|
* The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
|
|
@@ -67,8 +80,8 @@ export const parseDataObjectsFromSharedObjects = (
|
|
|
67
80
|
const registryEntries = new Set<NamedFluidDataStoreRegistryEntry>();
|
|
68
81
|
const sharedObjects = new Set<IChannelFactory>();
|
|
69
82
|
|
|
70
|
-
const tryAddObject = (obj:
|
|
71
|
-
if (
|
|
83
|
+
const tryAddObject = (obj: LoadableObjectClass): void => {
|
|
84
|
+
if (isSharedObjectKind(obj)) {
|
|
72
85
|
sharedObjects.add(obj.getFactory());
|
|
73
86
|
} else if (isDataObjectClass(obj)) {
|
|
74
87
|
registryEntries.add([obj.factory.type, Promise.resolve(obj.factory)]);
|
package/api-extractor-cjs.json
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"extends": "../../../common/build/build-common/api-extractor-base.cjs.primary.json",
|
|
4
|
-
// CJS is actually secondary; so, no report.
|
|
5
|
-
"apiReport": {
|
|
6
|
-
"enabled": false
|
|
7
|
-
}
|
|
8
|
-
}
|