@fluidframework/fluid-static 2.0.0-dev-rc.1.0.0.228517 → 2.0.0-dev-rc.1.0.0.232845
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 → .eslintrc.cjs} +1 -1
- package/api-report/fluid-static.api.md +10 -7
- package/dist/fluid-static-alpha.d.ts +11 -4
- package/dist/fluid-static-beta.d.ts +11 -4
- package/dist/fluid-static-public.d.ts +11 -4
- package/dist/fluid-static-untrimmed.d.ts +26 -7
- package/dist/fluidContainer.d.ts +9 -6
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js +3 -1
- package/dist/fluidContainer.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/rootDataObject.d.ts +5 -2
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +7 -3
- package/dist/rootDataObject.js.map +1 -1
- package/dist/serviceAudience.d.ts +13 -6
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/serviceAudience.js +12 -4
- package/dist/serviceAudience.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types.d.ts +8 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +6 -6
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +6 -3
- package/dist/utils.js.map +1 -1
- package/lib/fluid-static-alpha.d.mts +11 -4
- package/lib/fluid-static-beta.d.mts +11 -4
- package/lib/fluid-static-public.d.mts +11 -4
- package/lib/fluid-static-untrimmed.d.mts +26 -7
- package/lib/fluidContainer.d.mts +9 -6
- package/lib/fluidContainer.d.mts.map +1 -1
- package/lib/fluidContainer.mjs +3 -1
- package/lib/fluidContainer.mjs.map +1 -1
- package/lib/index.d.mts +2 -2
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/rootDataObject.d.mts +5 -2
- package/lib/rootDataObject.d.mts.map +1 -1
- package/lib/rootDataObject.mjs +7 -3
- package/lib/rootDataObject.mjs.map +1 -1
- package/lib/serviceAudience.d.mts +13 -6
- package/lib/serviceAudience.d.mts.map +1 -1
- package/lib/serviceAudience.mjs +12 -4
- package/lib/serviceAudience.mjs.map +1 -1
- package/lib/types.d.mts +8 -3
- package/lib/types.d.mts.map +1 -1
- package/lib/types.mjs.map +1 -1
- package/lib/utils.d.mts +6 -6
- package/lib/utils.d.mts.map +1 -1
- package/lib/utils.mjs +6 -3
- package/lib/utils.mjs.map +1 -1
- package/package.json +18 -18
- package/src/fluidContainer.ts +28 -16
- package/src/index.ts +19 -18
- package/src/rootDataObject.ts +45 -26
- package/src/serviceAudience.ts +35 -22
- package/src/types.ts +16 -3
- package/src/utils.ts +15 -12
package/src/types.ts
CHANGED
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
type IEvent,
|
|
8
|
+
type IEventProvider,
|
|
9
|
+
type IFluidLoadable,
|
|
10
|
+
} from "@fluidframework/core-interfaces";
|
|
11
|
+
import { type IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
|
|
@@ -14,9 +18,10 @@ export type LoadableObjectRecord = Record<string, IFluidLoadable>;
|
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
20
|
* A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
|
|
17
|
-
* or `SharedObject
|
|
21
|
+
* or `SharedObject`.
|
|
18
22
|
* @public
|
|
19
23
|
*/
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
25
|
export type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
|
|
21
26
|
|
|
22
27
|
/**
|
|
@@ -57,8 +62,15 @@ export type SharedObjectClass<T extends IFluidLoadable> = {
|
|
|
57
62
|
* @typeParam T - The class of the loadable object.
|
|
58
63
|
* @public
|
|
59
64
|
*/
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
66
|
export type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
|
|
61
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Represents properties that can be attached to a container.
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export type ContainerAttachProps<T = unknown> = T;
|
|
73
|
+
|
|
62
74
|
/**
|
|
63
75
|
* Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
|
|
64
76
|
*
|
|
@@ -99,6 +111,7 @@ export interface ContainerSchema {
|
|
|
99
111
|
* For best practice it's recommended to define all the dynamic types you create even if they are
|
|
100
112
|
* included via initialObjects.
|
|
101
113
|
*/
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
115
|
dynamicObjectTypes?: LoadableObjectClass<any>[];
|
|
103
116
|
}
|
|
104
117
|
|
package/src/utils.ts
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
|
+
import { type IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
7
7
|
import {
|
|
8
|
-
IFluidDataStoreFactory,
|
|
9
|
-
NamedFluidDataStoreRegistryEntry,
|
|
8
|
+
type IFluidDataStoreFactory,
|
|
9
|
+
type NamedFluidDataStoreRegistryEntry,
|
|
10
10
|
} from "@fluidframework/runtime-definitions";
|
|
11
|
-
import { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
12
|
-
import { ContainerSchema, DataObjectClass,
|
|
11
|
+
import { type IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
12
|
+
import { type ContainerSchema, type DataObjectClass, type SharedObjectClass } from "./types";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* An internal type used by the internal type guard isDataObjectClass to cast a
|
|
@@ -23,8 +23,8 @@ export type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<
|
|
|
23
23
|
/**
|
|
24
24
|
* Runtime check to determine if a class is a DataObject type
|
|
25
25
|
*/
|
|
26
|
-
export const isDataObjectClass = (obj:
|
|
27
|
-
const maybe
|
|
26
|
+
export const isDataObjectClass = (obj: unknown): obj is InternalDataObjectClass<IFluidLoadable> => {
|
|
27
|
+
const maybe = obj as Partial<InternalDataObjectClass<IFluidLoadable>> | undefined;
|
|
28
28
|
return (
|
|
29
29
|
maybe?.factory?.IFluidDataStoreFactory !== undefined &&
|
|
30
30
|
maybe?.factory?.IFluidDataStoreFactory === maybe?.factory
|
|
@@ -34,8 +34,9 @@ export const isDataObjectClass = (obj: any): obj is InternalDataObjectClass<IFlu
|
|
|
34
34
|
/**
|
|
35
35
|
* Runtime check to determine if a class is a SharedObject type
|
|
36
36
|
*/
|
|
37
|
-
export const isSharedObjectClass = (obj:
|
|
38
|
-
|
|
37
|
+
export const isSharedObjectClass = (obj: unknown): obj is SharedObjectClass<IFluidLoadable> => {
|
|
38
|
+
const maybe = obj as Partial<SharedObjectClass<IFluidLoadable>> | undefined;
|
|
39
|
+
return maybe?.getFactory !== undefined;
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
/**
|
|
@@ -49,7 +50,7 @@ export const parseDataObjectsFromSharedObjects = (
|
|
|
49
50
|
const registryEntries = new Set<NamedFluidDataStoreRegistryEntry>();
|
|
50
51
|
const sharedObjects = new Set<IChannelFactory>();
|
|
51
52
|
|
|
52
|
-
const tryAddObject = (obj:
|
|
53
|
+
const tryAddObject = (obj: unknown): void => {
|
|
53
54
|
if (isSharedObjectClass(obj)) {
|
|
54
55
|
sharedObjects.add(obj.getFactory());
|
|
55
56
|
} else if (isDataObjectClass(obj)) {
|
|
@@ -64,11 +65,13 @@ export const parseDataObjectsFromSharedObjects = (
|
|
|
64
65
|
...Object.values(schema.initialObjects),
|
|
65
66
|
...(schema.dynamicObjectTypes ?? []),
|
|
66
67
|
]);
|
|
67
|
-
dedupedObjects
|
|
68
|
+
for (const obj of dedupedObjects) {
|
|
69
|
+
tryAddObject(obj);
|
|
70
|
+
}
|
|
68
71
|
|
|
69
72
|
if (registryEntries.size === 0 && sharedObjects.size === 0) {
|
|
70
73
|
throw new Error("Container cannot be initialized without any DataTypes");
|
|
71
74
|
}
|
|
72
75
|
|
|
73
|
-
return [
|
|
76
|
+
return [[...registryEntries], [...sharedObjects]];
|
|
74
77
|
};
|