@fluidframework/fluid-static 2.0.0-dev-rc.1.0.0.232845 → 2.0.0-dev-rc.2.0.0.246488
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 → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +10 -0
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
- package/api-extractor.json +1 -1
- package/api-report/fluid-static.api.md +7 -7
- package/dist/fluid-static-alpha.d.ts +18 -9
- package/dist/fluid-static-beta.d.ts +18 -9
- package/dist/fluid-static-public.d.ts +18 -9
- package/dist/fluid-static-untrimmed.d.ts +18 -9
- package/dist/fluidContainer.d.ts +5 -1
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js +2 -2
- 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 +6 -6
- package/dist/index.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/rootDataObject.d.ts +5 -1
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +7 -7
- package/dist/rootDataObject.js.map +1 -1
- package/dist/serviceAudience.d.ts +1 -1
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/serviceAudience.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types.d.ts +18 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +9 -5
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +5 -5
- package/dist/utils.js.map +1 -1
- package/lib/{fluid-static-alpha.d.mts → fluid-static-alpha.d.ts} +24 -9
- package/lib/{fluid-static-public.d.mts → fluid-static-beta.d.ts} +24 -9
- package/lib/{fluid-static-beta.d.mts → fluid-static-public.d.ts} +24 -9
- package/lib/{fluid-static-untrimmed.d.mts → fluid-static-untrimmed.d.ts} +24 -9
- package/lib/{fluidContainer.d.mts → fluidContainer.d.ts} +6 -2
- package/lib/fluidContainer.d.ts.map +1 -0
- package/lib/{fluidContainer.mjs → fluidContainer.js} +5 -1
- package/lib/fluidContainer.js.map +1 -0
- package/lib/{index.d.mts → index.d.ts} +10 -5
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +13 -0
- package/lib/index.js.map +1 -0
- package/lib/{rootDataObject.d.mts → rootDataObject.d.ts} +6 -2
- package/lib/rootDataObject.d.ts.map +1 -0
- package/lib/{rootDataObject.mjs → rootDataObject.js} +7 -3
- package/lib/rootDataObject.js.map +1 -0
- package/lib/{serviceAudience.d.mts → serviceAudience.d.ts} +2 -2
- package/lib/serviceAudience.d.ts.map +1 -0
- package/lib/{serviceAudience.mjs → serviceAudience.js} +1 -1
- package/lib/serviceAudience.js.map +1 -0
- package/lib/test/fluidContainer.spec.js +21 -0
- package/lib/test/fluidContainer.spec.js.map +1 -0
- package/lib/test/types/validateFluidStaticPrevious.generated.js +46 -0
- package/lib/test/types/validateFluidStaticPrevious.generated.js.map +1 -0
- package/lib/test/utils.spec.js +86 -0
- package/lib/test/utils.spec.js.map +1 -0
- package/lib/{types.d.mts → types.d.ts} +19 -10
- package/lib/types.d.ts.map +1 -0
- package/lib/{types.mjs → types.js} +1 -1
- package/lib/types.js.map +1 -0
- package/lib/{utils.d.mts → utils.d.ts} +10 -6
- package/lib/utils.d.ts.map +1 -0
- package/lib/{utils.mjs → utils.js} +5 -5
- package/lib/utils.js.map +1 -0
- package/package.json +45 -58
- package/src/fluidContainer.ts +3 -2
- package/src/index.ts +4 -4
- package/src/rootDataObject.ts +4 -3
- package/src/serviceAudience.ts +1 -1
- package/src/types.ts +20 -13
- package/src/utils.ts +23 -6
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +4 -8
- package/lib/fluidContainer.d.mts.map +0 -1
- package/lib/fluidContainer.mjs.map +0 -1
- package/lib/index.d.mts.map +0 -1
- package/lib/index.mjs +0 -8
- package/lib/index.mjs.map +0 -1
- package/lib/rootDataObject.d.mts.map +0 -1
- package/lib/rootDataObject.mjs.map +0 -1
- package/lib/serviceAudience.d.mts.map +0 -1
- package/lib/serviceAudience.mjs.map +0 -1
- package/lib/types.d.mts.map +0 -1
- package/lib/types.mjs.map +0 -1
- package/lib/utils.d.mts.map +0 -1
- package/lib/utils.mjs.map +0 -1
|
@@ -14,14 +14,21 @@ export type LoadableObjectRecord = Record<string, IFluidLoadable>;
|
|
|
14
14
|
* or `SharedObject`.
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
|
-
export type LoadableObjectClassRecord = Record<string, LoadableObjectClass
|
|
17
|
+
export type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;
|
|
18
18
|
/**
|
|
19
19
|
* A class object of `DataObject` or `SharedObject`.
|
|
20
20
|
*
|
|
21
21
|
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
22
22
|
* @public
|
|
23
|
+
*
|
|
24
|
+
* @privateRemarks
|
|
25
|
+
* There are some edge cases in TypeScript where the order of the members in a union matter.
|
|
26
|
+
* Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.
|
|
27
|
+
* In this case, its better to have the desired match and/or the simpler type first.
|
|
28
|
+
* In this case placing SharedObjectClass 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.
|
|
29
|
+
* This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].
|
|
23
30
|
*/
|
|
24
|
-
export type LoadableObjectClass<T extends IFluidLoadable> =
|
|
31
|
+
export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> = SharedObjectClass<T> | DataObjectClass<T>;
|
|
25
32
|
/**
|
|
26
33
|
* A class that has a factory that can create a `DataObject` and a
|
|
27
34
|
* constructor that will return the type of the `DataObject`.
|
|
@@ -35,15 +42,17 @@ export type DataObjectClass<T extends IFluidLoadable> = {
|
|
|
35
42
|
};
|
|
36
43
|
} & LoadableObjectCtor<T>;
|
|
37
44
|
/**
|
|
38
|
-
* A
|
|
39
|
-
* constructor that will return the type of the `DataObject`.
|
|
45
|
+
* A factory that produces a factory that can create a DDSes (`SharedObject`s).
|
|
40
46
|
*
|
|
41
47
|
* @typeParam T - The class of the `SharedObject`.
|
|
42
48
|
* @public
|
|
43
49
|
*/
|
|
44
|
-
export
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
export interface SharedObjectClass<T extends IFluidLoadable> {
|
|
51
|
+
/**
|
|
52
|
+
* Gets the factory this factory is a wrapper for.
|
|
53
|
+
*/
|
|
54
|
+
readonly getFactory: () => IChannelFactory<T>;
|
|
55
|
+
}
|
|
47
56
|
/**
|
|
48
57
|
* An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
|
|
49
58
|
*
|
|
@@ -84,7 +93,7 @@ export interface ContainerSchema {
|
|
|
84
93
|
* }
|
|
85
94
|
* ```
|
|
86
95
|
*/
|
|
87
|
-
initialObjects: LoadableObjectClassRecord;
|
|
96
|
+
readonly initialObjects: LoadableObjectClassRecord;
|
|
88
97
|
/**
|
|
89
98
|
* Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
|
|
90
99
|
*
|
|
@@ -95,7 +104,7 @@ export interface ContainerSchema {
|
|
|
95
104
|
* For best practice it's recommended to define all the dynamic types you create even if they are
|
|
96
105
|
* included via initialObjects.
|
|
97
106
|
*/
|
|
98
|
-
dynamicObjectTypes?: LoadableObjectClass
|
|
107
|
+
readonly dynamicObjectTypes?: readonly LoadableObjectClass[];
|
|
99
108
|
}
|
|
100
109
|
/**
|
|
101
110
|
* @internal
|
|
@@ -225,4 +234,4 @@ export interface IMember {
|
|
|
225
234
|
export type Myself<M extends IMember = IMember> = M & {
|
|
226
235
|
currentConnection: string;
|
|
227
236
|
};
|
|
228
|
-
//# sourceMappingURL=types.d.
|
|
237
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAA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,SAAS,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACvB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,EAAE,WAAW,EAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG;IAAE,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype IEvent,\n\ttype IEventProvider,\n\ttype IFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { type IChannelFactory } from \"@fluidframework/datastore-definitions\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\n * @internal\n */\nexport type LoadableObjectRecord = Record<string, IFluidLoadable>;\n\n/**\n * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`\n * or `SharedObject`.\n * @public\n */\nexport type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;\n\n/**\n * A class object of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n * @public\n *\n * @privateRemarks\n * There are some edge cases in TypeScript where the order of the members in a union matter.\n * Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.\n * In this case, its better to have the desired match and/or the simpler type first.\n * In this case placing SharedObjectClass 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.\n * This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].\n */\nexport type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> =\n\t| SharedObjectClass<T>\n\t| DataObjectClass<T>;\n\n/**\n * A class that has a factory that can create a `DataObject` and a\n * constructor that will return the type of the `DataObject`.\n *\n * @typeParam T - The class of the `DataObject`.\n * @public\n */\nexport type DataObjectClass<T extends IFluidLoadable> = {\n\treadonly factory: { IFluidDataStoreFactory: DataObjectClass<T>[\"factory\"] };\n} & LoadableObjectCtor<T>;\n\n/**\n * A factory that produces a factory that can create a DDSes (`SharedObject`s).\n *\n * @typeParam T - The class of the `SharedObject`.\n * @public\n */\nexport interface SharedObjectClass<T extends IFluidLoadable> {\n\t/**\n\t * Gets the factory this factory is a wrapper for.\n\t */\n\treadonly getFactory: () => IChannelFactory<T>;\n}\n\n/**\n * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.\n *\n * @typeParam T - The class of the loadable object.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;\n\n/**\n * Represents properties that can be attached to a container.\n * @public\n */\nexport type ContainerAttachProps<T = unknown> = T;\n\n/**\n * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.\n *\n * @remarks\n *\n * It includes both the instances of objects that are initially available upon `Container` creation, as well\n * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.\n * @public\n */\nexport interface ContainerSchema {\n\t/**\n\t * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.\n\t *\n\t * @remarks It uses the key as the id and the value as the loadable object to create.\n\t *\n\t * @example\n\t *\n\t * In the example below two objects will be created when the `Container` is first\n\t * created. One with id \"map1\" that will return a `SharedMap` and the other with\n\t * id \"pair1\" that will return a `KeyValueDataObject`.\n\t *\n\t * ```typescript\n\t * {\n\t * map1: SharedMap,\n\t * pair1: KeyValueDataObject,\n\t * }\n\t * ```\n\t */\n\treadonly initialObjects: LoadableObjectClassRecord;\n\n\t/**\n\t * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.\n\t *\n\t * @remarks\n\t *\n\t * Types defined in `initialObjects` will always be available and are not required to be provided here.\n\t *\n\t * For best practice it's recommended to define all the dynamic types you create even if they are\n\t * included via initialObjects.\n\t */\n\treadonly dynamicObjectTypes?: readonly LoadableObjectClass[];\n}\n\n/**\n * @internal\n */\nexport interface IProvideRootDataObject {\n\treadonly IRootDataObject: IRootDataObject;\n}\n\n/**\n * Holds the collection of objects that the container was initially created with, as well as provides the ability\n * to dynamically create further objects during usage.\n * @internal\n */\nexport interface IRootDataObject extends IProvideRootDataObject {\n\t/**\n\t * Provides a record of the initial objects defined on creation.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n\n\t/**\n\t * Dynamically creates a new detached collaborative object (DDS/DataObject).\n\t *\n\t * @param objectClass - Type of the collaborative object to be created.\n\t *\n\t * @typeParam T - The class of the `DataObject` or `SharedObject`.\n\t */\n\tcreate<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;\n}\n\n/**\n * Signature for {@link IMember} change events.\n *\n * @param clientId - A unique identifier for the client.\n * @param member - The service-specific member object for the client.\n *\n * @see See {@link IServiceAudienceEvents} for usage details.\n * @public\n */\nexport type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;\n\n/**\n * Events that trigger when the roster of members in the Fluid session change.\n *\n * @remarks\n *\n * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s\n * {@link IServiceAudience.getMembers} method will emit events.\n *\n * @typeParam M - A service-specific {@link IMember} implementation.\n * @public\n */\nexport interface IServiceAudienceEvents<M extends IMember> extends IEvent {\n\t/**\n\t * Emitted when a {@link IMember | member}(s) are either added or removed.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"membersChanged\", listener: () => void): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} joins the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberAdded\", listener: MemberChangedListener<M>): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} leaves the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberRemoved\", listener: MemberChangedListener<M>): void;\n}\n\n/**\n * Base interface to be implemented to fetch each service's audience.\n *\n * @remarks\n *\n * The type parameter `M` allows consumers to further extend the client object with service-specific\n * details about the connecting client, such as device information, environment, or a username.\n *\n * @typeParam M - A service-specific {@link IMember} type.\n * @public\n */\nexport interface IServiceAudience<M extends IMember>\n\textends IEventProvider<IServiceAudienceEvents<M>> {\n\t/**\n\t * Returns an map of all users currently in the Fluid session where key is the userId and the value is the\n\t * member object. The implementation may choose to exclude certain connections from the returned map.\n\t * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.\n\t */\n\tgetMembers(): Map<string, M>;\n\n\t/**\n\t * Returns the current active user on this client once they are connected. Otherwise, returns undefined.\n\t */\n\tgetMyself(): Myself<M> | undefined;\n}\n\n/**\n * Base interface for information for each connection made to the Fluid session.\n *\n * @remarks This interface can be extended to provide additional information specific to each service.\n * @public\n */\nexport interface IConnection {\n\t/**\n\t * A unique ID for the connection. A single user may have multiple connections, each with a different ID.\n\t */\n\tid: string;\n\n\t/**\n\t * Whether the connection is in read or read/write mode.\n\t */\n\tmode: \"write\" | \"read\";\n}\n\n/**\n * Base interface to be implemented to fetch each service's member.\n *\n * @remarks This interface can be extended by each service to provide additional service-specific user metadata.\n * @public\n */\nexport interface IMember {\n\t/**\n\t * An ID for the user, unique among each individual user connecting to the session.\n\t */\n\tuserId: string;\n\n\t/**\n\t * The set of connections the user has made, e.g. from multiple tabs or devices.\n\t */\n\tconnections: IConnection[];\n}\n\n/**\n * An extended member object that includes currentConnection\n * @public\n */\nexport type Myself<M extends IMember = IMember> = M & { currentConnection: string };\n"]}
|
|
@@ -5,26 +5,30 @@
|
|
|
5
5
|
import { type IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
6
|
import { type IFluidDataStoreFactory, type NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions";
|
|
7
7
|
import { type IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
8
|
-
import { type ContainerSchema, type DataObjectClass, type SharedObjectClass } from "./types.
|
|
8
|
+
import { type ContainerSchema, type DataObjectClass, type LoadableObjectClass, type SharedObjectClass } from "./types.js";
|
|
9
9
|
/**
|
|
10
10
|
* An internal type used by the internal type guard isDataObjectClass to cast a
|
|
11
11
|
* DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.
|
|
12
|
-
* Unlike the external and exported type DataObjectClass
|
|
12
|
+
* Unlike the external and exported type DataObjectClass which is
|
|
13
13
|
* weakly coupled to the IFluidDataStoreFactory to prevent leaking internals.
|
|
14
14
|
*/
|
|
15
15
|
export type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<T> & Record<"factory", IFluidDataStoreFactory>;
|
|
16
16
|
/**
|
|
17
|
-
* Runtime check to determine if a class is a DataObject type
|
|
17
|
+
* Runtime check to determine if a class is a DataObject type.
|
|
18
18
|
*/
|
|
19
|
-
export declare
|
|
19
|
+
export declare function isDataObjectClass<T extends IFluidLoadable>(obj: LoadableObjectClass<T>): obj is InternalDataObjectClass<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Runtime check to determine if a class is a DataObject type.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isDataObjectClass(obj: unknown): obj is InternalDataObjectClass<IFluidLoadable>;
|
|
20
24
|
/**
|
|
21
25
|
* Runtime check to determine if a class is a SharedObject type
|
|
22
26
|
*/
|
|
23
27
|
export declare const isSharedObjectClass: (obj: unknown) => obj is SharedObjectClass<IFluidLoadable>;
|
|
24
28
|
/**
|
|
25
29
|
* The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
|
|
26
|
-
* of both SharedObject or DataObject. This function
|
|
30
|
+
* of both SharedObject or DataObject. This function separates the two and returns a registry
|
|
27
31
|
* of DataObject types and an array of SharedObjects.
|
|
28
32
|
*/
|
|
29
33
|
export declare const parseDataObjectsFromSharedObjects: (schema: ContainerSchema) => [NamedFluidDataStoreRegistryEntry[], IChannelFactory[]];
|
|
30
|
-
//# sourceMappingURL=utils.d.
|
|
34
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,gCAAgC,EACrC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,cAAc,IAAI,eAAe,CAAC,CAAC,CAAC,GACjF,MAAM,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;AAE3C;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,cAAc,EACzD,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,GACzB,GAAG,IAAI,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAErC;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,uBAAuB,CAAC,cAAc,CAAC,CAAC;AAahG;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAAS,OAAO,6CAG/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,WACrC,eAAe,KACrB,CAAC,gCAAgC,EAAE,EAAE,eAAe,EAAE,CA4BxD,CAAC"}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Runtime check to determine if a class is a DataObject type
|
|
6
|
+
* Runtime check to determine if a class is a DataObject type.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export function isDataObjectClass(obj) {
|
|
9
9
|
const maybe = obj;
|
|
10
10
|
return (maybe?.factory?.IFluidDataStoreFactory !== undefined &&
|
|
11
11
|
maybe?.factory?.IFluidDataStoreFactory === maybe?.factory);
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
/**
|
|
14
14
|
* Runtime check to determine if a class is a SharedObject type
|
|
15
15
|
*/
|
|
@@ -19,7 +19,7 @@ export const isSharedObjectClass = (obj) => {
|
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
|
|
22
|
-
* of both SharedObject or DataObject. This function
|
|
22
|
+
* of both SharedObject or DataObject. This function separates the two and returns a registry
|
|
23
23
|
* of DataObject types and an array of SharedObjects.
|
|
24
24
|
*/
|
|
25
25
|
export const parseDataObjectsFromSharedObjects = (schema) => {
|
|
@@ -49,4 +49,4 @@ export const parseDataObjectsFromSharedObjects = (schema) => {
|
|
|
49
49
|
}
|
|
50
50
|
return [[...registryEntries], [...sharedObjects]];
|
|
51
51
|
};
|
|
52
|
-
//# sourceMappingURL=utils.
|
|
52
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoCH;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC7C,MAAM,KAAK,GAAG,GAAmE,CAAC;IAClF,OAAO,CACN,KAAK,EAAE,OAAO,EAAE,sBAAsB,KAAK,SAAS;QACpD,KAAK,EAAE,OAAO,EAAE,sBAAsB,KAAK,KAAK,EAAE,OAAO,CACzD,CAAC;AACH,CAAC;AAED;;GAEG;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e,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n\ttype IFluidDataStoreFactory,\n\ttype NamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions\";\nimport { type IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport {\n\ttype ContainerSchema,\n\ttype DataObjectClass,\n\ttype LoadableObjectClass,\n\ttype SharedObjectClass,\n} from \"./types.js\";\n\n/**\n * An internal type used by the internal type guard isDataObjectClass to cast a\n * DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.\n * Unlike the external and exported type DataObjectClass which is\n * weakly coupled to the IFluidDataStoreFactory to prevent leaking internals.\n */\nexport type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<T> &\n\tRecord<\"factory\", IFluidDataStoreFactory>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass<T extends IFluidLoadable>(\n\tobj: LoadableObjectClass<T>,\n): obj is InternalDataObjectClass<T>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass(obj: unknown): obj is InternalDataObjectClass<IFluidLoadable>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass(obj: unknown): obj is InternalDataObjectClass<IFluidLoadable> {\n\tconst maybe = obj as Partial<InternalDataObjectClass<IFluidLoadable>> | undefined;\n\treturn (\n\t\tmaybe?.factory?.IFluidDataStoreFactory !== undefined &&\n\t\tmaybe?.factory?.IFluidDataStoreFactory === maybe?.factory\n\t);\n}\n\n/**\n * Runtime check to determine if a class is a SharedObject type\n */\nexport const isSharedObjectClass = (obj: unknown): obj is SharedObjectClass<IFluidLoadable> => {\n\tconst maybe = obj as Partial<SharedObjectClass<IFluidLoadable>> | undefined;\n\treturn maybe?.getFactory !== undefined;\n};\n\n/**\n * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be\n * of both SharedObject or DataObject. This function separates the two and returns a registry\n * of DataObject types and an array of SharedObjects.\n */\nexport const parseDataObjectsFromSharedObjects = (\n\tschema: ContainerSchema,\n): [NamedFluidDataStoreRegistryEntry[], IChannelFactory[]] => {\n\tconst registryEntries = new Set<NamedFluidDataStoreRegistryEntry>();\n\tconst sharedObjects = new Set<IChannelFactory>();\n\n\tconst tryAddObject = (obj: unknown): void => {\n\t\tif (isSharedObjectClass(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectClass(obj)) {\n\t\t\tregistryEntries.add([obj.factory.type, Promise.resolve(obj.factory)]);\n\t\t} else {\n\t\t\tthrow new Error(`Entry is neither a DataObject or a SharedObject`);\n\t\t}\n\t};\n\n\t// Add the object types that will be initialized\n\tconst dedupedObjects = new Set([\n\t\t...Object.values(schema.initialObjects),\n\t\t...(schema.dynamicObjectTypes ?? []),\n\t]);\n\tfor (const obj of dedupedObjects) {\n\t\ttryAddObject(obj);\n\t}\n\n\tif (registryEntries.size === 0 && sharedObjects.size === 0) {\n\t\tthrow new Error(\"Container cannot be initialized without any DataTypes\");\n\t}\n\n\treturn [[...registryEntries], [...sharedObjects]];\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/fluid-static",
|
|
3
|
-
"version": "2.0.0-dev-rc.
|
|
3
|
+
"version": "2.0.0-dev-rc.2.0.0.246488",
|
|
4
4
|
"description": "A tool to enable consumption of Fluid Data Objects without requiring custom container code.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -11,60 +11,40 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Microsoft and contributors",
|
|
13
13
|
"sideEffects": false,
|
|
14
|
+
"type": "module",
|
|
14
15
|
"exports": {
|
|
15
16
|
".": {
|
|
16
17
|
"import": {
|
|
17
|
-
"types": "./lib/index.d.
|
|
18
|
-
"default": "./lib/index.
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
19
20
|
},
|
|
20
21
|
"require": {
|
|
21
22
|
"types": "./dist/index.d.ts",
|
|
22
23
|
"default": "./dist/index.js"
|
|
23
24
|
}
|
|
24
25
|
},
|
|
25
|
-
"./
|
|
26
|
-
"import": {
|
|
27
|
-
"types": "./lib/fluid-static-alpha.d.mts",
|
|
28
|
-
"default": "./lib/index.mjs"
|
|
29
|
-
},
|
|
30
|
-
"require": {
|
|
31
|
-
"types": "./dist/fluid-static-alpha.d.ts",
|
|
32
|
-
"default": "./dist/index.js"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"./beta": {
|
|
26
|
+
"./public": {
|
|
36
27
|
"import": {
|
|
37
|
-
"types": "./lib/fluid-static-
|
|
38
|
-
"default": "./lib/index.
|
|
28
|
+
"types": "./lib/fluid-static-public.d.ts",
|
|
29
|
+
"default": "./lib/index.js"
|
|
39
30
|
},
|
|
40
31
|
"require": {
|
|
41
|
-
"types": "./dist/fluid-static-
|
|
32
|
+
"types": "./dist/fluid-static-public.d.ts",
|
|
42
33
|
"default": "./dist/index.js"
|
|
43
34
|
}
|
|
44
35
|
},
|
|
45
36
|
"./internal": {
|
|
46
37
|
"import": {
|
|
47
|
-
"types": "./lib/index.d.
|
|
48
|
-
"default": "./lib/index.
|
|
38
|
+
"types": "./lib/index.d.ts",
|
|
39
|
+
"default": "./lib/index.js"
|
|
49
40
|
},
|
|
50
41
|
"require": {
|
|
51
42
|
"types": "./dist/index.d.ts",
|
|
52
43
|
"default": "./dist/index.js"
|
|
53
44
|
}
|
|
54
|
-
},
|
|
55
|
-
"./public": {
|
|
56
|
-
"import": {
|
|
57
|
-
"types": "./lib/fluid-static-public.d.mts",
|
|
58
|
-
"default": "./lib/index.mjs"
|
|
59
|
-
},
|
|
60
|
-
"require": {
|
|
61
|
-
"types": "./dist/fluid-static-public.d.ts",
|
|
62
|
-
"default": "./dist/index.js"
|
|
63
|
-
}
|
|
64
45
|
}
|
|
65
46
|
},
|
|
66
47
|
"main": "dist/index.js",
|
|
67
|
-
"module": "lib/index.mjs",
|
|
68
48
|
"types": "dist/index.d.ts",
|
|
69
49
|
"c8": {
|
|
70
50
|
"all": true,
|
|
@@ -87,43 +67,42 @@
|
|
|
87
67
|
"temp-directory": "nyc/.nyc_output"
|
|
88
68
|
},
|
|
89
69
|
"dependencies": {
|
|
90
|
-
"@fluid-internal/client-utils": "2.0.0-dev-rc.
|
|
91
|
-
"@fluidframework/aqueduct": "2.0.0-dev-rc.
|
|
92
|
-
"@fluidframework/container-definitions": "2.0.0-dev-rc.
|
|
93
|
-
"@fluidframework/container-loader": "2.0.0-dev-rc.
|
|
94
|
-
"@fluidframework/container-runtime": "2.0.0-dev-rc.
|
|
95
|
-
"@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.
|
|
96
|
-
"@fluidframework/core-interfaces": "2.0.0-dev-rc.
|
|
97
|
-
"@fluidframework/datastore-definitions": "2.0.0-dev-rc.
|
|
98
|
-
"@fluidframework/protocol-definitions": "^3.2.0
|
|
99
|
-
"@fluidframework/request-handler": "2.0.0-dev-rc.
|
|
100
|
-
"@fluidframework/runtime-definitions": "2.0.0-dev-rc.
|
|
101
|
-
"@fluidframework/runtime-utils": "2.0.0-dev-rc.
|
|
70
|
+
"@fluid-internal/client-utils": "2.0.0-dev-rc.2.0.0.246488",
|
|
71
|
+
"@fluidframework/aqueduct": "2.0.0-dev-rc.2.0.0.246488",
|
|
72
|
+
"@fluidframework/container-definitions": "2.0.0-dev-rc.2.0.0.246488",
|
|
73
|
+
"@fluidframework/container-loader": "2.0.0-dev-rc.2.0.0.246488",
|
|
74
|
+
"@fluidframework/container-runtime": "2.0.0-dev-rc.2.0.0.246488",
|
|
75
|
+
"@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.2.0.0.246488",
|
|
76
|
+
"@fluidframework/core-interfaces": "2.0.0-dev-rc.2.0.0.246488",
|
|
77
|
+
"@fluidframework/datastore-definitions": "2.0.0-dev-rc.2.0.0.246488",
|
|
78
|
+
"@fluidframework/protocol-definitions": "^3.2.0",
|
|
79
|
+
"@fluidframework/request-handler": "2.0.0-dev-rc.2.0.0.246488",
|
|
80
|
+
"@fluidframework/runtime-definitions": "2.0.0-dev-rc.2.0.0.246488",
|
|
81
|
+
"@fluidframework/runtime-utils": "2.0.0-dev-rc.2.0.0.246488"
|
|
102
82
|
},
|
|
103
83
|
"devDependencies": {
|
|
104
84
|
"@arethetypeswrong/cli": "^0.13.3",
|
|
105
|
-
"@fluid-
|
|
85
|
+
"@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.2.0.0.246488",
|
|
86
|
+
"@fluid-tools/build-cli": "^0.34.0",
|
|
106
87
|
"@fluidframework/build-common": "^2.0.3",
|
|
107
|
-
"@fluidframework/build-tools": "^0.
|
|
108
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
88
|
+
"@fluidframework/build-tools": "^0.34.0",
|
|
89
|
+
"@fluidframework/eslint-config-fluid": "^5.1.0",
|
|
109
90
|
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-internal.8.0.0",
|
|
110
|
-
"@fluidframework/map": "2.0.0-dev-rc.
|
|
111
|
-
"@fluidframework/
|
|
112
|
-
"@
|
|
113
|
-
"@microsoft/api-extractor": "^7.39.1",
|
|
91
|
+
"@fluidframework/map": "2.0.0-dev-rc.2.0.0.246488",
|
|
92
|
+
"@fluidframework/sequence": "2.0.0-dev-rc.2.0.0.246488",
|
|
93
|
+
"@microsoft/api-extractor": "^7.42.3",
|
|
114
94
|
"@types/mocha": "^9.1.1",
|
|
115
95
|
"@types/node": "^18.19.0",
|
|
116
96
|
"c8": "^8.0.1",
|
|
117
97
|
"copyfiles": "^2.4.1",
|
|
118
98
|
"cross-env": "^7.0.3",
|
|
119
|
-
"eslint": "~8.
|
|
99
|
+
"eslint": "~8.55.0",
|
|
120
100
|
"mocha": "^10.2.0",
|
|
121
101
|
"mocha-json-output-reporter": "^2.0.1",
|
|
122
102
|
"mocha-multi-reporters": "^1.5.1",
|
|
123
103
|
"moment": "^2.21.0",
|
|
124
104
|
"prettier": "~3.0.3",
|
|
125
105
|
"rimraf": "^4.4.0",
|
|
126
|
-
"tsc-multi": "^1.1.0",
|
|
127
106
|
"typescript": "~5.1.6"
|
|
128
107
|
},
|
|
129
108
|
"fluidBuild": {
|
|
@@ -139,18 +118,24 @@
|
|
|
139
118
|
}
|
|
140
119
|
},
|
|
141
120
|
"typeValidation": {
|
|
142
|
-
"broken": {
|
|
121
|
+
"broken": {
|
|
122
|
+
"InterfaceDeclaration_ContainerSchema": {
|
|
123
|
+
"backCompat": false
|
|
124
|
+
}
|
|
125
|
+
}
|
|
143
126
|
},
|
|
144
127
|
"scripts": {
|
|
145
128
|
"api": "fluid-build . --task api",
|
|
146
|
-
"api-extractor:commonjs": "api-extractor run --
|
|
147
|
-
"api-extractor:esnext": "api-extractor run --
|
|
129
|
+
"api-extractor:commonjs": "api-extractor run --config ./api-extractor-cjs.json",
|
|
130
|
+
"api-extractor:esnext": "api-extractor run --local",
|
|
148
131
|
"build": "fluid-build . --task build",
|
|
149
132
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
150
133
|
"build:compile": "fluid-build . --task compile",
|
|
151
134
|
"build:docs": "fluid-build . --task api",
|
|
152
|
-
"build:esnext": "tsc
|
|
153
|
-
"build:test": "
|
|
135
|
+
"build:esnext": "tsc --project ./tsconfig.json",
|
|
136
|
+
"build:test": "npm run build:test:esm && npm run build:test:cjs",
|
|
137
|
+
"build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
|
|
138
|
+
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
|
|
154
139
|
"check:are-the-types-wrong": "attw --pack . --entrypoints .",
|
|
155
140
|
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
156
141
|
"ci:build:docs": "api-extractor run",
|
|
@@ -164,9 +149,11 @@
|
|
|
164
149
|
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
165
150
|
"test": "npm run test:mocha",
|
|
166
151
|
"test:coverage": "c8 npm test",
|
|
167
|
-
"test:mocha": "
|
|
152
|
+
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
|
|
153
|
+
"test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\" --exit -r node_modules/@fluid-internal/mocha-test-setup",
|
|
154
|
+
"test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit -r node_modules/@fluid-internal/mocha-test-setup",
|
|
168
155
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
169
|
-
"tsc": "tsc",
|
|
156
|
+
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
|
|
170
157
|
"typetests:gen": "fluid-type-test-generator",
|
|
171
158
|
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
172
159
|
}
|
package/src/fluidContainer.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
|
|
5
6
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
6
7
|
import {
|
|
7
8
|
type IEvent,
|
|
@@ -19,7 +20,7 @@ import type {
|
|
|
19
20
|
ContainerAttachProps,
|
|
20
21
|
IRootDataObject,
|
|
21
22
|
LoadableObjectClass,
|
|
22
|
-
} from "./types";
|
|
23
|
+
} from "./types.js";
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
|
|
@@ -27,7 +28,7 @@ import type {
|
|
|
27
28
|
*/
|
|
28
29
|
export type InitialObjects<T extends ContainerSchema> = {
|
|
29
30
|
// Construct a LoadableObjectRecord type by enumerating the keys of
|
|
30
|
-
// 'ContainerSchema.initialObjects' and
|
|
31
|
+
// 'ContainerSchema.initialObjects' and inferring the value type of each key.
|
|
31
32
|
//
|
|
32
33
|
// The '? TChannel : never' is required because infer can only be used in
|
|
33
34
|
// a conditional 'extends' expression.
|
package/src/index.ts
CHANGED
|
@@ -14,9 +14,9 @@ export {
|
|
|
14
14
|
type IFluidContainer,
|
|
15
15
|
type IFluidContainerEvents,
|
|
16
16
|
type InitialObjects,
|
|
17
|
-
} from "./fluidContainer";
|
|
18
|
-
export { createDOProviderContainerRuntimeFactory } from "./rootDataObject";
|
|
19
|
-
export { createServiceAudience } from "./serviceAudience";
|
|
17
|
+
} from "./fluidContainer.js";
|
|
18
|
+
export { createDOProviderContainerRuntimeFactory } from "./rootDataObject.js";
|
|
19
|
+
export { createServiceAudience } from "./serviceAudience.js";
|
|
20
20
|
export {
|
|
21
21
|
type ContainerSchema,
|
|
22
22
|
type ContainerAttachProps,
|
|
@@ -34,4 +34,4 @@ export {
|
|
|
34
34
|
type Myself,
|
|
35
35
|
type SharedObjectClass,
|
|
36
36
|
type IProvideRootDataObject,
|
|
37
|
-
} from "./types";
|
|
37
|
+
} from "./types.js";
|
package/src/rootDataObject.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
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,
|
|
@@ -27,13 +28,13 @@ import {
|
|
|
27
28
|
type LoadableObjectClassRecord,
|
|
28
29
|
type LoadableObjectRecord,
|
|
29
30
|
type SharedObjectClass,
|
|
30
|
-
} from "./types";
|
|
31
|
+
} from "./types.js";
|
|
31
32
|
import {
|
|
32
33
|
type InternalDataObjectClass,
|
|
33
34
|
isDataObjectClass,
|
|
34
35
|
isSharedObjectClass,
|
|
35
36
|
parseDataObjectsFromSharedObjects,
|
|
36
|
-
} from "./utils";
|
|
37
|
+
} from "./utils.js";
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Input props for {@link RootDataObject.initializingFirstTime}.
|
|
@@ -231,7 +232,7 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
|
231
232
|
// resolution progress is tracked by the Feature 465 work item in AzDO
|
|
232
233
|
flushMode: FlushMode.Immediate,
|
|
233
234
|
// The runtime compressor is required to be on to use @fluidframework/tree.
|
|
234
|
-
enableRuntimeIdCompressor:
|
|
235
|
+
enableRuntimeIdCompressor: "on",
|
|
235
236
|
},
|
|
236
237
|
provideEntryPoint,
|
|
237
238
|
});
|
package/src/serviceAudience.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -21,18 +21,24 @@ export type LoadableObjectRecord = Record<string, IFluidLoadable>;
|
|
|
21
21
|
* or `SharedObject`.
|
|
22
22
|
* @public
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
export type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
|
|
24
|
+
export type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
27
|
* A class object of `DataObject` or `SharedObject`.
|
|
29
28
|
*
|
|
30
29
|
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
31
30
|
* @public
|
|
31
|
+
*
|
|
32
|
+
* @privateRemarks
|
|
33
|
+
* There are some edge cases in TypeScript where the order of the members in a union matter.
|
|
34
|
+
* Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.
|
|
35
|
+
* In this case, its better to have the desired match and/or the simpler type first.
|
|
36
|
+
* In this case placing SharedObjectClass 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
|
+
* This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].
|
|
32
38
|
*/
|
|
33
|
-
export type LoadableObjectClass<T extends IFluidLoadable> =
|
|
34
|
-
|
|
|
35
|
-
|
|
|
39
|
+
export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> =
|
|
40
|
+
| SharedObjectClass<T>
|
|
41
|
+
| DataObjectClass<T>;
|
|
36
42
|
|
|
37
43
|
/**
|
|
38
44
|
* A class that has a factory that can create a `DataObject` and a
|
|
@@ -46,15 +52,17 @@ export type DataObjectClass<T extends IFluidLoadable> = {
|
|
|
46
52
|
} & LoadableObjectCtor<T>;
|
|
47
53
|
|
|
48
54
|
/**
|
|
49
|
-
* A
|
|
50
|
-
* constructor that will return the type of the `DataObject`.
|
|
55
|
+
* A factory that produces a factory that can create a DDSes (`SharedObject`s).
|
|
51
56
|
*
|
|
52
57
|
* @typeParam T - The class of the `SharedObject`.
|
|
53
58
|
* @public
|
|
54
59
|
*/
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
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
|
+
}
|
|
58
66
|
|
|
59
67
|
/**
|
|
60
68
|
* An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
|
|
@@ -99,7 +107,7 @@ export interface ContainerSchema {
|
|
|
99
107
|
* }
|
|
100
108
|
* ```
|
|
101
109
|
*/
|
|
102
|
-
initialObjects: LoadableObjectClassRecord;
|
|
110
|
+
readonly initialObjects: LoadableObjectClassRecord;
|
|
103
111
|
|
|
104
112
|
/**
|
|
105
113
|
* Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
|
|
@@ -111,8 +119,7 @@ export interface ContainerSchema {
|
|
|
111
119
|
* For best practice it's recommended to define all the dynamic types you create even if they are
|
|
112
120
|
* included via initialObjects.
|
|
113
121
|
*/
|
|
114
|
-
|
|
115
|
-
dynamicObjectTypes?: LoadableObjectClass<any>[];
|
|
122
|
+
readonly dynamicObjectTypes?: readonly LoadableObjectClass[];
|
|
116
123
|
}
|
|
117
124
|
|
|
118
125
|
/**
|
package/src/utils.ts
CHANGED
|
@@ -9,27 +9,44 @@ import {
|
|
|
9
9
|
type NamedFluidDataStoreRegistryEntry,
|
|
10
10
|
} from "@fluidframework/runtime-definitions";
|
|
11
11
|
import { type IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
type ContainerSchema,
|
|
14
|
+
type DataObjectClass,
|
|
15
|
+
type LoadableObjectClass,
|
|
16
|
+
type SharedObjectClass,
|
|
17
|
+
} from "./types.js";
|
|
13
18
|
|
|
14
19
|
/**
|
|
15
20
|
* An internal type used by the internal type guard isDataObjectClass to cast a
|
|
16
21
|
* DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.
|
|
17
|
-
* Unlike the external and exported type DataObjectClass
|
|
22
|
+
* Unlike the external and exported type DataObjectClass which is
|
|
18
23
|
* weakly coupled to the IFluidDataStoreFactory to prevent leaking internals.
|
|
19
24
|
*/
|
|
20
25
|
export type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<T> &
|
|
21
26
|
Record<"factory", IFluidDataStoreFactory>;
|
|
22
27
|
|
|
23
28
|
/**
|
|
24
|
-
* Runtime check to determine if a class is a DataObject type
|
|
29
|
+
* Runtime check to determine if a class is a DataObject type.
|
|
30
|
+
*/
|
|
31
|
+
export function isDataObjectClass<T extends IFluidLoadable>(
|
|
32
|
+
obj: LoadableObjectClass<T>,
|
|
33
|
+
): obj is InternalDataObjectClass<T>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Runtime check to determine if a class is a DataObject type.
|
|
25
37
|
*/
|
|
26
|
-
export
|
|
38
|
+
export function isDataObjectClass(obj: unknown): obj is InternalDataObjectClass<IFluidLoadable>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Runtime check to determine if a class is a DataObject type.
|
|
42
|
+
*/
|
|
43
|
+
export function isDataObjectClass(obj: unknown): obj is InternalDataObjectClass<IFluidLoadable> {
|
|
27
44
|
const maybe = obj as Partial<InternalDataObjectClass<IFluidLoadable>> | undefined;
|
|
28
45
|
return (
|
|
29
46
|
maybe?.factory?.IFluidDataStoreFactory !== undefined &&
|
|
30
47
|
maybe?.factory?.IFluidDataStoreFactory === maybe?.factory
|
|
31
48
|
);
|
|
32
|
-
}
|
|
49
|
+
}
|
|
33
50
|
|
|
34
51
|
/**
|
|
35
52
|
* Runtime check to determine if a class is a SharedObject type
|
|
@@ -41,7 +58,7 @@ export const isSharedObjectClass = (obj: unknown): obj is SharedObjectClass<IFlu
|
|
|
41
58
|
|
|
42
59
|
/**
|
|
43
60
|
* The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
|
|
44
|
-
* of both SharedObject or DataObject. This function
|
|
61
|
+
* of both SharedObject or DataObject. This function separates the two and returns a registry
|
|
45
62
|
* of DataObject types and an array of SharedObjects.
|
|
46
63
|
*/
|
|
47
64
|
export const parseDataObjectsFromSharedObjects = (
|
package/tsconfig.json
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends":
|
|
3
|
-
"../../../common/build/build-common/tsconfig.base.json",
|
|
4
|
-
"../../../common/build/build-common/tsconfig.cjs.json",
|
|
5
|
-
],
|
|
6
|
-
"include": ["src/**/*"],
|
|
7
|
-
"exclude": ["src/test/**/*"],
|
|
2
|
+
"extends": "../../../common/build/build-common/tsconfig.node16.json",
|
|
8
3
|
"compilerOptions": {
|
|
9
4
|
"rootDir": "./src",
|
|
10
|
-
"outDir": "./
|
|
11
|
-
"types": ["node"],
|
|
5
|
+
"outDir": "./lib",
|
|
12
6
|
},
|
|
7
|
+
"include": ["src/**/*"],
|
|
8
|
+
"exclude": ["src/test/**/*"],
|
|
13
9
|
}
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