@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.
Files changed (62) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +1 -1
  2. package/api-report/fluid-static.api.md +10 -7
  3. package/dist/fluid-static-alpha.d.ts +11 -4
  4. package/dist/fluid-static-beta.d.ts +11 -4
  5. package/dist/fluid-static-public.d.ts +11 -4
  6. package/dist/fluid-static-untrimmed.d.ts +26 -7
  7. package/dist/fluidContainer.d.ts +9 -6
  8. package/dist/fluidContainer.d.ts.map +1 -1
  9. package/dist/fluidContainer.js +3 -1
  10. package/dist/fluidContainer.js.map +1 -1
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/rootDataObject.d.ts +5 -2
  15. package/dist/rootDataObject.d.ts.map +1 -1
  16. package/dist/rootDataObject.js +7 -3
  17. package/dist/rootDataObject.js.map +1 -1
  18. package/dist/serviceAudience.d.ts +13 -6
  19. package/dist/serviceAudience.d.ts.map +1 -1
  20. package/dist/serviceAudience.js +12 -4
  21. package/dist/serviceAudience.js.map +1 -1
  22. package/dist/tsdoc-metadata.json +1 -1
  23. package/dist/types.d.ts +8 -3
  24. package/dist/types.d.ts.map +1 -1
  25. package/dist/types.js.map +1 -1
  26. package/dist/utils.d.ts +6 -6
  27. package/dist/utils.d.ts.map +1 -1
  28. package/dist/utils.js +6 -3
  29. package/dist/utils.js.map +1 -1
  30. package/lib/fluid-static-alpha.d.mts +11 -4
  31. package/lib/fluid-static-beta.d.mts +11 -4
  32. package/lib/fluid-static-public.d.mts +11 -4
  33. package/lib/fluid-static-untrimmed.d.mts +26 -7
  34. package/lib/fluidContainer.d.mts +9 -6
  35. package/lib/fluidContainer.d.mts.map +1 -1
  36. package/lib/fluidContainer.mjs +3 -1
  37. package/lib/fluidContainer.mjs.map +1 -1
  38. package/lib/index.d.mts +2 -2
  39. package/lib/index.d.mts.map +1 -1
  40. package/lib/index.mjs.map +1 -1
  41. package/lib/rootDataObject.d.mts +5 -2
  42. package/lib/rootDataObject.d.mts.map +1 -1
  43. package/lib/rootDataObject.mjs +7 -3
  44. package/lib/rootDataObject.mjs.map +1 -1
  45. package/lib/serviceAudience.d.mts +13 -6
  46. package/lib/serviceAudience.d.mts.map +1 -1
  47. package/lib/serviceAudience.mjs +12 -4
  48. package/lib/serviceAudience.mjs.map +1 -1
  49. package/lib/types.d.mts +8 -3
  50. package/lib/types.d.mts.map +1 -1
  51. package/lib/types.mjs.map +1 -1
  52. package/lib/utils.d.mts +6 -6
  53. package/lib/utils.d.mts.map +1 -1
  54. package/lib/utils.mjs +6 -3
  55. package/lib/utils.mjs.map +1 -1
  56. package/package.json +18 -18
  57. package/src/fluidContainer.ts +28 -16
  58. package/src/index.ts +19 -18
  59. package/src/rootDataObject.ts +45 -26
  60. package/src/serviceAudience.ts +35 -22
  61. package/src/types.ts +16 -3
  62. package/src/utils.ts +15 -12
package/lib/types.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","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 { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { 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` in a {@link LoadableObjectRecord}.\n * @public\n */\nexport type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;\n\n/**\n * A class object of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n * @public\n */\nexport type LoadableObjectClass<T extends IFluidLoadable> =\n\t| DataObjectClass<T>\n\t| SharedObjectClass<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 class that has a factory that can create a DDSes (`SharedObject`s) and a\n * constructor that will return the type of the `DataObject`.\n *\n * @typeParam T - The class of the `SharedObject`.\n * @public\n */\nexport type SharedObjectClass<T extends IFluidLoadable> = {\n\treadonly getFactory: () => IChannelFactory;\n} & LoadableObjectCtor<T>;\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 */\nexport type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => 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\tinitialObjects: 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\tdynamicObjectTypes?: LoadableObjectClass<any>[];\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"]}
1
+ {"version":3,"file":"types.mjs","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 */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;\n\n/**\n * A class object of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n * @public\n */\nexport type LoadableObjectClass<T extends IFluidLoadable> =\n\t| DataObjectClass<T>\n\t| SharedObjectClass<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 class that has a factory that can create a DDSes (`SharedObject`s) and a\n * constructor that will return the type of the `DataObject`.\n *\n * @typeParam T - The class of the `SharedObject`.\n * @public\n */\nexport type SharedObjectClass<T extends IFluidLoadable> = {\n\treadonly getFactory: () => IChannelFactory;\n} & LoadableObjectCtor<T>;\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\tinitialObjects: 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\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdynamicObjectTypes?: LoadableObjectClass<any>[];\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"]}
package/lib/utils.d.mts CHANGED
@@ -2,10 +2,10 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IChannelFactory } from "@fluidframework/datastore-definitions";
6
- import { IFluidDataStoreFactory, NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions";
7
- import { IFluidLoadable } from "@fluidframework/core-interfaces";
8
- import { ContainerSchema, DataObjectClass, SharedObjectClass } from "./types.mjs";
5
+ import { type IChannelFactory } from "@fluidframework/datastore-definitions";
6
+ import { type IFluidDataStoreFactory, type NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions";
7
+ import { type IFluidLoadable } from "@fluidframework/core-interfaces";
8
+ import { type ContainerSchema, type DataObjectClass, type SharedObjectClass } from "./types.mjs";
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.
@@ -16,11 +16,11 @@ export type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<
16
16
  /**
17
17
  * Runtime check to determine if a class is a DataObject type
18
18
  */
19
- export declare const isDataObjectClass: (obj: any) => obj is InternalDataObjectClass<IFluidLoadable>;
19
+ export declare const isDataObjectClass: (obj: unknown) => obj is InternalDataObjectClass<IFluidLoadable>;
20
20
  /**
21
21
  * Runtime check to determine if a class is a SharedObject type
22
22
  */
23
- export declare const isSharedObjectClass: (obj: any) => obj is SharedObjectClass<any>;
23
+ export declare const isSharedObjectClass: (obj: unknown) => obj is SharedObjectClass<IFluidLoadable>;
24
24
  /**
25
25
  * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
26
26
  * of both SharedObject or DataObject. This function seperates the two and returns a registery
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,eAAe,EAAE,MAAM,uCAAuC;OAChE,EACN,sBAAsB,EACtB,gCAAgC,EAChC,MAAM,qCAAqC;OACrC,EAAE,cAAc,EAAE,MAAM,iCAAiC;OACzD,EAAE,eAAe,EAAE,eAAe,EAAuB,iBAAiB,EAAE;AAEnF;;;;;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,eAAO,MAAM,iBAAiB,QAAS,GAAG,mDAMzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAAS,GAAG,kCAE3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,WACrC,eAAe,KACrB,CAAC,gCAAgC,EAAE,EAAE,eAAe,EAAE,CA0BxD,CAAC"}
1
+ {"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC;OACrE,EACN,KAAK,sBAAsB,EAC3B,KAAK,gCAAgC,EACrC,MAAM,qCAAqC;OACrC,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC;OAC9D,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE;AAE7E;;;;;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,eAAO,MAAM,iBAAiB,QAAS,OAAO,mDAM7C,CAAC;AAEF;;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"}
package/lib/utils.mjs CHANGED
@@ -14,7 +14,8 @@ export const isDataObjectClass = (obj) => {
14
14
  * Runtime check to determine if a class is a SharedObject type
15
15
  */
16
16
  export const isSharedObjectClass = (obj) => {
17
- return obj?.getFactory !== undefined;
17
+ const maybe = obj;
18
+ return maybe?.getFactory !== undefined;
18
19
  };
19
20
  /**
20
21
  * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
@@ -40,10 +41,12 @@ export const parseDataObjectsFromSharedObjects = (schema) => {
40
41
  ...Object.values(schema.initialObjects),
41
42
  ...(schema.dynamicObjectTypes ?? []),
42
43
  ]);
43
- dedupedObjects.forEach(tryAddObject);
44
+ for (const obj of dedupedObjects) {
45
+ tryAddObject(obj);
46
+ }
44
47
  if (registryEntries.size === 0 && sharedObjects.size === 0) {
45
48
  throw new Error("Container cannot be initialized without any DataTypes");
46
49
  }
47
- return [Array.from(registryEntries), Array.from(sharedObjects)];
50
+ return [[...registryEntries], [...sharedObjects]];
48
51
  };
49
52
  //# sourceMappingURL=utils.mjs.map
package/lib/utils.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAQ,EAAkD,EAAE;IAC7F,MAAM,KAAK,GAAiE,GAAG,CAAC;IAChF,OAAO,CACN,KAAK,EAAE,OAAO,EAAE,sBAAsB,KAAK,SAAS;QACpD,KAAK,EAAE,OAAO,EAAE,sBAAsB,KAAK,KAAK,EAAE,OAAO,CACzD,CAAC;AACH,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAQ,EAAiC,EAAE;IAC9E,OAAO,GAAG,EAAE,UAAU,KAAK,SAAS,CAAC;AACtC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAChD,MAAuB,EACmC,EAAE;IAC5D,MAAM,eAAe,GAAG,IAAI,GAAG,EAAoC,CAAC;IACpE,MAAM,aAAa,GAAG,IAAI,GAAG,EAAmB,CAAC;IAEjD,MAAM,YAAY,GAAG,CAAC,GAA6B,EAAE,EAAE;QACtD,IAAI,mBAAmB,CAAC,GAAG,CAAC,EAAE;YAC7B,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;SACpC;aAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,EAAE;YAClC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;SACtE;aAAM;YACN,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;SACnE;IACF,CAAC,CAAC;IAEF,gDAAgD;IAChD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;QAC9B,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;QACvC,GAAG,CAAC,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAC;KACpC,CAAC,CAAC;IACH,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAErC,IAAI,eAAe,CAAC,IAAI,KAAK,CAAC,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE;QAC3D,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KACzE;IAED,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { ContainerSchema, DataObjectClass, LoadableObjectClass, SharedObjectClass } from \"./types\";\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 const isDataObjectClass = (obj: any): obj is InternalDataObjectClass<IFluidLoadable> => {\n\tconst maybe: Partial<InternalDataObjectClass<IFluidLoadable>> | undefined = obj;\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: any): obj is SharedObjectClass<any> => {\n\treturn obj?.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 seperates the two and returns a registery\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: LoadableObjectClass<any>) => {\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\tdedupedObjects.forEach(tryAddObject);\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 [Array.from(registryEntries), Array.from(sharedObjects)];\n};\n"]}
1
+ {"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAY,EAAkD,EAAE;IACjG,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,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAY,EAA4C,EAAE;IAC7F,MAAM,KAAK,GAAG,GAA6D,CAAC;IAC5E,OAAO,KAAK,EAAE,UAAU,KAAK,SAAS,CAAC;AACxC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAChD,MAAuB,EACmC,EAAE;IAC5D,MAAM,eAAe,GAAG,IAAI,GAAG,EAAoC,CAAC;IACpE,MAAM,aAAa,GAAG,IAAI,GAAG,EAAmB,CAAC;IAEjD,MAAM,YAAY,GAAG,CAAC,GAAY,EAAQ,EAAE;QAC3C,IAAI,mBAAmB,CAAC,GAAG,CAAC,EAAE;YAC7B,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;SACpC;aAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,EAAE;YAClC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;SACtE;aAAM;YACN,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;SACnE;IACF,CAAC,CAAC;IAEF,gDAAgD;IAChD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;QAC9B,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;QACvC,GAAG,CAAC,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAC;KACpC,CAAC,CAAC;IACH,KAAK,MAAM,GAAG,IAAI,cAAc,EAAE;QACjC,YAAY,CAAC,GAAG,CAAC,CAAC;KAClB;IAED,IAAI,eAAe,CAAC,IAAI,KAAK,CAAC,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE;QAC3D,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KACzE;IAED,OAAO,CAAC,CAAC,GAAG,eAAe,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 { type ContainerSchema, type DataObjectClass, type SharedObjectClass } from \"./types\";\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 const 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 seperates the two and returns a registery\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.1.0.0.228517",
3
+ "version": "2.0.0-dev-rc.1.0.0.232845",
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": {
@@ -87,30 +87,30 @@
87
87
  "temp-directory": "nyc/.nyc_output"
88
88
  },
89
89
  "dependencies": {
90
- "@fluid-internal/client-utils": "2.0.0-dev-rc.1.0.0.228517",
91
- "@fluidframework/aqueduct": "2.0.0-dev-rc.1.0.0.228517",
92
- "@fluidframework/container-definitions": "2.0.0-dev-rc.1.0.0.228517",
93
- "@fluidframework/container-loader": "2.0.0-dev-rc.1.0.0.228517",
94
- "@fluidframework/container-runtime": "2.0.0-dev-rc.1.0.0.228517",
95
- "@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.1.0.0.228517",
96
- "@fluidframework/core-interfaces": "2.0.0-dev-rc.1.0.0.228517",
97
- "@fluidframework/datastore-definitions": "2.0.0-dev-rc.1.0.0.228517",
98
- "@fluidframework/protocol-definitions": "^3.1.0",
99
- "@fluidframework/request-handler": "2.0.0-dev-rc.1.0.0.228517",
100
- "@fluidframework/runtime-definitions": "2.0.0-dev-rc.1.0.0.228517",
101
- "@fluidframework/runtime-utils": "2.0.0-dev-rc.1.0.0.228517"
90
+ "@fluid-internal/client-utils": "2.0.0-dev-rc.1.0.0.232845",
91
+ "@fluidframework/aqueduct": "2.0.0-dev-rc.1.0.0.232845",
92
+ "@fluidframework/container-definitions": "2.0.0-dev-rc.1.0.0.232845",
93
+ "@fluidframework/container-loader": "2.0.0-dev-rc.1.0.0.232845",
94
+ "@fluidframework/container-runtime": "2.0.0-dev-rc.1.0.0.232845",
95
+ "@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.1.0.0.232845",
96
+ "@fluidframework/core-interfaces": "2.0.0-dev-rc.1.0.0.232845",
97
+ "@fluidframework/datastore-definitions": "2.0.0-dev-rc.1.0.0.232845",
98
+ "@fluidframework/protocol-definitions": "^3.2.0-231454",
99
+ "@fluidframework/request-handler": "2.0.0-dev-rc.1.0.0.232845",
100
+ "@fluidframework/runtime-definitions": "2.0.0-dev-rc.1.0.0.232845",
101
+ "@fluidframework/runtime-utils": "2.0.0-dev-rc.1.0.0.232845"
102
102
  },
103
103
  "devDependencies": {
104
104
  "@arethetypeswrong/cli": "^0.13.3",
105
105
  "@fluid-tools/build-cli": "^0.29.0",
106
106
  "@fluidframework/build-common": "^2.0.3",
107
107
  "@fluidframework/build-tools": "^0.29.0",
108
- "@fluidframework/eslint-config-fluid": "^3.2.0",
108
+ "@fluidframework/eslint-config-fluid": "^3.3.0",
109
109
  "@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-internal.8.0.0",
110
- "@fluidframework/map": "2.0.0-dev-rc.1.0.0.228517",
111
- "@fluidframework/mocha-test-setup": "2.0.0-dev-rc.1.0.0.228517",
112
- "@fluidframework/sequence": "2.0.0-dev-rc.1.0.0.228517",
113
- "@microsoft/api-extractor": "^7.38.3",
110
+ "@fluidframework/map": "2.0.0-dev-rc.1.0.0.232845",
111
+ "@fluidframework/mocha-test-setup": "2.0.0-dev-rc.1.0.0.232845",
112
+ "@fluidframework/sequence": "2.0.0-dev-rc.1.0.0.232845",
113
+ "@microsoft/api-extractor": "^7.39.1",
114
114
  "@types/mocha": "^9.1.1",
115
115
  "@types/node": "^18.19.0",
116
116
  "c8": "^8.0.1",
@@ -3,14 +3,23 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { TypedEventEmitter } from "@fluid-internal/client-utils";
6
- import { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
6
+ import {
7
+ type IEvent,
8
+ type IEventProvider,
9
+ type IFluidLoadable,
10
+ } from "@fluidframework/core-interfaces";
7
11
  import {
8
12
  AttachState,
9
- IContainer,
10
- ICriticalContainerError,
11
- ConnectionState,
13
+ type IContainer,
14
+ type ICriticalContainerError,
15
+ type ConnectionState,
12
16
  } from "@fluidframework/container-definitions";
13
- import type { ContainerSchema, IRootDataObject, LoadableObjectClass } from "./types";
17
+ import type {
18
+ ContainerSchema,
19
+ ContainerAttachProps,
20
+ IRootDataObject,
21
+ LoadableObjectClass,
22
+ } from "./types";
14
23
 
15
24
  /**
16
25
  * Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
@@ -99,6 +108,7 @@ export interface IFluidContainerEvents extends IEvent {
99
108
  * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
100
109
  *
101
110
  * @remarks Note: external implementations of this interface are not supported.
111
+ *
102
112
  * @sealed
103
113
  * @public
104
114
  */
@@ -166,7 +176,7 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
166
176
  *
167
177
  * @returns A promise which resolves when the attach is complete, with the string identifier of the container.
168
178
  */
169
- attach(): Promise<string>;
179
+ attach(props?: ContainerAttachProps): Promise<string>;
170
180
 
171
181
  /**
172
182
  * Attempts to connect the container to the delta stream and process operations.
@@ -176,7 +186,7 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
176
186
  * @remarks
177
187
  *
178
188
  * This should only be called when the container is in the
179
- * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
189
+ * {@link @fluidframework/container-definitions#(ConnectionState:namespace).Disconnected} state.
180
190
  *
181
191
  * This can be determined by observing {@link IFluidContainer.connectionState}.
182
192
  */
@@ -188,7 +198,7 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
188
198
  * @remarks
189
199
  *
190
200
  * This should only be called when the container is in the
191
- * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
201
+ * {@link @fluidframework/container-definitions#(ConnectionState:namespace).Connected} state.
192
202
  *
193
203
  * This can be determined by observing {@link IFluidContainer.connectionState}.
194
204
  */
@@ -216,6 +226,8 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
216
226
  }
217
227
 
218
228
  /**
229
+ * Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.
230
+ *
219
231
  * @internal
220
232
  */
221
233
  export function createFluidContainer<
@@ -242,12 +254,12 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
242
254
  extends TypedEventEmitter<IFluidContainerEvents>
243
255
  implements IFluidContainer<TContainerSchema>
244
256
  {
245
- private readonly connectedHandler = () => this.emit("connected");
246
- private readonly disconnectedHandler = () => this.emit("disconnected");
247
- private readonly disposedHandler = (error?: ICriticalContainerError) =>
257
+ private readonly connectedHandler = (): boolean => this.emit("connected");
258
+ private readonly disconnectedHandler = (): boolean => this.emit("disconnected");
259
+ private readonly disposedHandler = (error?: ICriticalContainerError): boolean =>
248
260
  this.emit("disposed", error);
249
- private readonly savedHandler = () => this.emit("saved");
250
- private readonly dirtyHandler = () => this.emit("dirty");
261
+ private readonly savedHandler = (): boolean => this.emit("saved");
262
+ private readonly dirtyHandler = (): boolean => this.emit("dirty");
251
263
 
252
264
  public constructor(
253
265
  private readonly container: IContainer,
@@ -278,7 +290,7 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
278
290
  /**
279
291
  * {@inheritDoc IFluidContainer.disposed}
280
292
  */
281
- public get disposed() {
293
+ public get disposed(): boolean {
282
294
  return this.container.closed;
283
295
  }
284
296
 
@@ -308,7 +320,7 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
308
320
  * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,
309
321
  * but internally this separation is not there.
310
322
  */
311
- public async attach(): Promise<string> {
323
+ public async attach(props?: ContainerAttachProps): Promise<string> {
312
324
  if (this.container.attachState !== AttachState.Detached) {
313
325
  throw new Error("Cannot attach container. Container is not in detached state.");
314
326
  }
@@ -339,7 +351,7 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
339
351
  /**
340
352
  * {@inheritDoc IFluidContainer.dispose}
341
353
  */
342
- public dispose() {
354
+ public dispose(): void {
343
355
  this.container.close();
344
356
  this.container.off("connected", this.connectedHandler);
345
357
  this.container.off("closed", this.disposedHandler);
package/src/index.ts CHANGED
@@ -11,26 +11,27 @@
11
11
 
12
12
  export {
13
13
  createFluidContainer,
14
- IFluidContainer,
15
- IFluidContainerEvents,
16
- InitialObjects,
14
+ type IFluidContainer,
15
+ type IFluidContainerEvents,
16
+ type InitialObjects,
17
17
  } from "./fluidContainer";
18
18
  export { createDOProviderContainerRuntimeFactory } from "./rootDataObject";
19
19
  export { createServiceAudience } from "./serviceAudience";
20
20
  export {
21
- ContainerSchema,
22
- DataObjectClass,
23
- IConnection,
24
- IMember,
25
- IRootDataObject,
26
- IServiceAudience,
27
- IServiceAudienceEvents,
28
- LoadableObjectClass,
29
- LoadableObjectClassRecord,
30
- LoadableObjectCtor,
31
- LoadableObjectRecord,
32
- MemberChangedListener,
33
- Myself,
34
- SharedObjectClass,
35
- IProvideRootDataObject,
21
+ type ContainerSchema,
22
+ type ContainerAttachProps,
23
+ type DataObjectClass,
24
+ type IConnection,
25
+ type IMember,
26
+ type IRootDataObject,
27
+ type IServiceAudience,
28
+ type IServiceAudienceEvents,
29
+ type LoadableObjectClass,
30
+ type LoadableObjectClassRecord,
31
+ type LoadableObjectCtor,
32
+ type LoadableObjectRecord,
33
+ type MemberChangedListener,
34
+ type Myself,
35
+ type SharedObjectClass,
36
+ type IProvideRootDataObject,
36
37
  } from "./types";
@@ -7,22 +7,29 @@ import {
7
7
  DataObject,
8
8
  DataObjectFactory,
9
9
  } from "@fluidframework/aqueduct";
10
- import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
11
- import { IFluidLoadable, IRequest } from "@fluidframework/core-interfaces";
10
+ import { type IContainerRuntime } from "@fluidframework/container-runtime-definitions";
11
+ import {
12
+ type FluidObject,
13
+ type IFluidLoadable,
14
+ type IRequest,
15
+ type IResponse,
16
+ } from "@fluidframework/core-interfaces";
12
17
  import { FlushMode } from "@fluidframework/runtime-definitions";
13
- import { IRuntimeFactory } from "@fluidframework/container-definitions";
18
+ import { type IRuntimeFactory } from "@fluidframework/container-definitions";
14
19
  import { RequestParser } from "@fluidframework/runtime-utils";
15
- import { ContainerRuntime } from "@fluidframework/container-runtime";
20
+ import { type ContainerRuntime } from "@fluidframework/container-runtime";
21
+ import { type IDirectory } from "@fluidframework/map";
22
+
16
23
  import {
17
- ContainerSchema,
18
- IRootDataObject,
19
- LoadableObjectClass,
20
- LoadableObjectClassRecord,
21
- LoadableObjectRecord,
22
- SharedObjectClass,
24
+ type ContainerSchema,
25
+ type IRootDataObject,
26
+ type LoadableObjectClass,
27
+ type LoadableObjectClassRecord,
28
+ type LoadableObjectRecord,
29
+ type SharedObjectClass,
23
30
  } from "./types";
24
31
  import {
25
- InternalDataObjectClass,
32
+ type InternalDataObjectClass,
26
33
  isDataObjectClass,
27
34
  isSharedObjectClass,
28
35
  parseDataObjectsFromSharedObjects,
@@ -50,11 +57,12 @@ class RootDataObject
50
57
  {
51
58
  private readonly initialObjectsDirKey = "initial-objects-key";
52
59
  private readonly _initialObjects: LoadableObjectRecord = {};
53
- public get IRootDataObject() {
60
+
61
+ public get IRootDataObject(): IRootDataObject {
54
62
  return this;
55
63
  }
56
64
 
57
- private get initialObjectsDir() {
65
+ private get initialObjectsDir(): IDirectory {
58
66
  const dir = this.root.getSubDirectory(this.initialObjectsDirKey);
59
67
  if (dir === undefined) {
60
68
  throw new Error("InitialObjects sub-directory was not initialized");
@@ -68,18 +76,18 @@ class RootDataObject
68
76
  *
69
77
  * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}
70
78
  */
71
- protected async initializingFirstTime(props: RootDataObjectProps) {
79
+ protected async initializingFirstTime(props: RootDataObjectProps): Promise<void> {
72
80
  this.root.createSubDirectory(this.initialObjectsDirKey);
73
81
 
74
82
  // Create initial objects provided by the developer
75
83
  const initialObjectsP: Promise<void>[] = [];
76
- Object.entries(props.initialObjects).forEach(([id, objectClass]) => {
77
- const createObject = async () => {
78
- const obj = await this.create(objectClass);
84
+ for (const [id, objectClass] of Object.entries(props.initialObjects)) {
85
+ const createObject = async (): Promise<void> => {
86
+ const obj = await this.create<IFluidLoadable>(objectClass);
79
87
  this.initialObjectsDir.set(id, obj.handle);
80
88
  };
81
89
  initialObjectsP.push(createObject());
82
- });
90
+ }
83
91
 
84
92
  await Promise.all(initialObjectsP);
85
93
  }
@@ -90,12 +98,13 @@ class RootDataObject
90
98
  *
91
99
  * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}
92
100
  */
93
- protected async hasInitialized() {
101
+ protected async hasInitialized(): Promise<void> {
94
102
  // We will always load the initial objects so they are available to the developer
95
103
  const loadInitialObjectsP: Promise<void>[] = [];
96
- for (const [key, value] of Array.from(this.initialObjectsDir.entries())) {
97
- const loadDir = async () => {
98
- const obj = await value.get();
104
+ for (const [key, value] of this.initialObjectsDir.entries()) {
105
+ const loadDir = async (): Promise<void> => {
106
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
107
+ const obj: unknown = await value.get();
99
108
  Object.assign(this._initialObjects, { [key]: obj });
100
109
  };
101
110
  loadInitialObjectsP.push(loadDir());
@@ -148,6 +157,9 @@ class RootDataObject
148
157
  const rootDataStoreId = "rootDOId";
149
158
 
150
159
  /**
160
+ * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} for a container with a single
161
+ * {@link IRootDataObject}, which is constructed from the provided schema.
162
+ *
151
163
  * @internal
152
164
  */
153
165
  export function createDOProviderContainerRuntimeFactory(props: {
@@ -176,7 +188,7 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
176
188
 
177
189
  private readonly initialObjects: LoadableObjectClassRecord;
178
190
 
179
- constructor(schema: ContainerSchema) {
191
+ public constructor(schema: ContainerSchema) {
180
192
  const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);
181
193
  const rootDataObjectFactory = new DataObjectFactory(
182
194
  "rootDO",
@@ -185,7 +197,10 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
185
197
  {},
186
198
  registryEntries,
187
199
  );
188
- const provideEntryPoint = async (containerRuntime: IContainerRuntime) => {
200
+ const provideEntryPoint = async (
201
+ containerRuntime: IContainerRuntime,
202
+ // eslint-disable-next-line unicorn/consistent-function-scoping
203
+ ): Promise<FluidObject> => {
189
204
  const entryPoint =
190
205
  await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
191
206
  if (entryPoint === undefined) {
@@ -193,7 +208,11 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
193
208
  }
194
209
  return entryPoint.get();
195
210
  };
196
- const getDefaultObject = async (request: IRequest, runtime: IContainerRuntime) => {
211
+ const getDefaultObject = async (
212
+ request: IRequest,
213
+ runtime: IContainerRuntime,
214
+ // eslint-disable-next-line unicorn/consistent-function-scoping
215
+ ): Promise<IResponse | undefined> => {
197
216
  const parser = RequestParser.create(request);
198
217
  if (parser.pathParts.length === 0) {
199
218
  // This cast is safe as ContainerRuntime.loadRuntime is called in the base class
@@ -223,7 +242,7 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
223
242
  /**
224
243
  * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}
225
244
  */
226
- protected async containerInitializingFirstTime(runtime: IContainerRuntime) {
245
+ protected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {
227
246
  // The first time we create the container we create the RootDataObject
228
247
  await this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {
229
248
  initialObjects: this.initialObjects,
@@ -4,17 +4,29 @@
4
4
  */
5
5
 
6
6
  import { TypedEventEmitter } from "@fluid-internal/client-utils";
7
- import { IAudience, IContainer } from "@fluidframework/container-definitions";
8
- import { IClient } from "@fluidframework/protocol-definitions";
9
- import { IServiceAudience, IServiceAudienceEvents, IMember, Myself } from "./types";
7
+ import { type IAudience, type IContainer } from "@fluidframework/container-definitions";
8
+ import { type IClient } from "@fluidframework/protocol-definitions";
9
+ import {
10
+ type IServiceAudience,
11
+ type IServiceAudienceEvents,
12
+ type IMember,
13
+ type Myself,
14
+ } from "./types";
10
15
 
11
16
  /**
17
+ * Creates a service audience for the provided container.
18
+ *
19
+ * @param container - The container with which the audience is associated.
20
+ * @param createServiceMember - A function for creating audience members.
21
+ *
22
+ * @typeParam TMember - The {@link IMember} representation used by the audience.
23
+ *
12
24
  * @internal
13
25
  */
14
- export function createServiceAudience<M extends IMember = IMember>(props: {
26
+ export function createServiceAudience<TMember extends IMember = IMember>(props: {
15
27
  container: IContainer;
16
- createServiceMember: (audienceMember: IClient) => M;
17
- }): IServiceAudience<M> {
28
+ createServiceMember: (audienceMember: IClient) => TMember;
29
+ }): IServiceAudience<TMember> {
18
30
  return new ServiceAudience(props.container, props.createServiceMember);
19
31
  }
20
32
 
@@ -26,12 +38,13 @@ export function createServiceAudience<M extends IMember = IMember>(props: {
26
38
  * This can be extended by different service-specific client packages to additional parameters to
27
39
  * the user and client details returned in {@link IMember}.
28
40
  *
29
- * @typeParam M - A service-specific {@link IMember} implementation.
41
+ * @typeParam TMember - A service-specific {@link IMember} implementation.
42
+ *
30
43
  * @internal
31
44
  */
32
- class ServiceAudience<M extends IMember = IMember>
33
- extends TypedEventEmitter<IServiceAudienceEvents<M>>
34
- implements IServiceAudience<M>
45
+ class ServiceAudience<TMember extends IMember = IMember>
46
+ extends TypedEventEmitter<IServiceAudienceEvents<TMember>>
47
+ implements IServiceAudience<TMember>
35
48
  {
36
49
  /**
37
50
  * Audience object which includes all the existing members of the {@link IFluidContainer | container}.
@@ -55,14 +68,14 @@ class ServiceAudience<M extends IMember = IMember>
55
68
  * every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}
56
69
  * events provide.
57
70
  */
58
- private lastMembers = new Map<string, M>();
71
+ private lastMembers = new Map<string, TMember>();
59
72
 
60
- constructor(
73
+ public constructor(
61
74
  /**
62
75
  * Fluid Container to read the audience from.
63
76
  */
64
77
  private readonly container: IContainer,
65
- private readonly createServiceMember: (audienceMember: IClient) => M,
78
+ private readonly createServiceMember: (audienceMember: IClient) => TMember,
66
79
  ) {
67
80
  super();
68
81
  this.audience = container.audience;
@@ -92,11 +105,11 @@ class ServiceAudience<M extends IMember = IMember>
92
105
  /**
93
106
  * {@inheritDoc IServiceAudience.getMembers}
94
107
  */
95
- public getMembers(): Map<string, M> {
96
- const users = new Map<string, M>();
97
- const clientMemberMap = new Map<string, M>();
108
+ public getMembers(): Map<string, TMember> {
109
+ const users = new Map<string, TMember>();
110
+ const clientMemberMap = new Map<string, TMember>();
98
111
  // Iterate through the members and get the user specifics.
99
- this.audience.getMembers().forEach((member: IClient, clientId: string) => {
112
+ for (const [clientId, member] of this.audience.getMembers()) {
100
113
  if (this.shouldIncludeAsMember(member)) {
101
114
  const userId = member.user.id;
102
115
  // Ensure we're tracking the user
@@ -110,7 +123,7 @@ class ServiceAudience<M extends IMember = IMember>
110
123
  user.connections.push({ id: clientId, mode: member.mode });
111
124
  clientMemberMap.set(clientId, user);
112
125
  }
113
- });
126
+ }
114
127
  this.lastMembers = clientMemberMap;
115
128
  return users;
116
129
  }
@@ -118,7 +131,7 @@ class ServiceAudience<M extends IMember = IMember>
118
131
  /**
119
132
  * {@inheritDoc IServiceAudience.getMyself}
120
133
  */
121
- public getMyself(): Myself<M> | undefined {
134
+ public getMyself(): Myself<TMember> | undefined {
122
135
  const clientId = this.container.clientId;
123
136
  if (clientId === undefined) {
124
137
  return undefined;
@@ -129,12 +142,12 @@ class ServiceAudience<M extends IMember = IMember>
129
142
  return undefined;
130
143
  }
131
144
 
132
- const myself: Myself<M> = { ...member, currentConnection: clientId };
145
+ const myself: Myself<TMember> = { ...member, currentConnection: clientId };
133
146
 
134
147
  return myself;
135
148
  }
136
149
 
137
- private getMember(clientId: string): M | undefined {
150
+ private getMember(clientId: string): TMember | undefined {
138
151
  // Fetch the user ID assoicated with this client ID from the runtime
139
152
  const internalAudienceMember = this.audience.getMember(clientId);
140
153
  if (internalAudienceMember === undefined) {
@@ -144,7 +157,7 @@ class ServiceAudience<M extends IMember = IMember>
144
157
  const allMembers = this.getMembers();
145
158
  const member = allMembers.get(internalAudienceMember?.user.id);
146
159
  if (member === undefined) {
147
- throw Error(
160
+ throw new Error(
148
161
  `Attempted to fetch client ${clientId} that is not part of the current member list`,
149
162
  );
150
163
  }