@fluidframework/fluid-static 2.0.0-dev-rc.2.0.0.245554 → 2.0.0-dev-rc.3.0.0.250606

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 (61) hide show
  1. package/api-report/fluid-static.api.md +4 -12
  2. package/dist/fluid-static-alpha.d.ts +5 -26
  3. package/dist/fluid-static-beta.d.ts +5 -26
  4. package/dist/fluid-static-public.d.ts +5 -26
  5. package/dist/fluid-static-untrimmed.d.ts +5 -26
  6. package/dist/fluidContainer.d.ts +6 -2
  7. package/dist/fluidContainer.d.ts.map +1 -1
  8. package/dist/fluidContainer.js +2 -2
  9. package/dist/fluidContainer.js.map +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/rootDataObject.d.ts +4 -0
  14. package/dist/rootDataObject.d.ts.map +1 -1
  15. package/dist/rootDataObject.js +5 -3
  16. package/dist/rootDataObject.js.map +1 -1
  17. package/dist/serviceAudience.d.ts +1 -1
  18. package/dist/serviceAudience.d.ts.map +1 -1
  19. package/dist/serviceAudience.js.map +1 -1
  20. package/dist/types.d.ts +5 -24
  21. package/dist/types.d.ts.map +1 -1
  22. package/dist/types.js.map +1 -1
  23. package/dist/utils.d.ts +5 -4
  24. package/dist/utils.d.ts.map +1 -1
  25. package/dist/utils.js +16 -9
  26. package/dist/utils.js.map +1 -1
  27. package/lib/fluid-static-alpha.d.ts +5 -26
  28. package/lib/fluid-static-beta.d.ts +5 -26
  29. package/lib/fluid-static-public.d.ts +5 -26
  30. package/lib/fluid-static-untrimmed.d.ts +5 -26
  31. package/lib/fluidContainer.d.ts +6 -2
  32. package/lib/fluidContainer.d.ts.map +1 -1
  33. package/lib/fluidContainer.js.map +1 -1
  34. package/lib/index.d.ts +1 -1
  35. package/lib/index.d.ts.map +1 -1
  36. package/lib/index.js.map +1 -1
  37. package/lib/rootDataObject.d.ts +4 -0
  38. package/lib/rootDataObject.d.ts.map +1 -1
  39. package/lib/rootDataObject.js +4 -2
  40. package/lib/rootDataObject.js.map +1 -1
  41. package/lib/serviceAudience.d.ts +1 -1
  42. package/lib/serviceAudience.d.ts.map +1 -1
  43. package/lib/serviceAudience.js.map +1 -1
  44. package/lib/test/fluidContainer.spec.js.map +1 -1
  45. package/lib/test/types/validateFluidStaticPrevious.generated.js +0 -4
  46. package/lib/test/types/validateFluidStaticPrevious.generated.js.map +1 -1
  47. package/lib/test/utils.spec.js.map +1 -1
  48. package/lib/types.d.ts +5 -24
  49. package/lib/types.d.ts.map +1 -1
  50. package/lib/types.js.map +1 -1
  51. package/lib/utils.d.ts +5 -4
  52. package/lib/utils.d.ts.map +1 -1
  53. package/lib/utils.js +14 -7
  54. package/lib/utils.js.map +1 -1
  55. package/package.json +33 -20
  56. package/src/fluidContainer.ts +8 -7
  57. package/src/index.ts +0 -2
  58. package/src/rootDataObject.ts +12 -9
  59. package/src/serviceAudience.ts +1 -1
  60. package/src/types.ts +6 -27
  61. package/src/utils.ts +30 -18
package/lib/types.js.map CHANGED
@@ -1 +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"]}
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 ISharedObjectKind } from \"@fluidframework/shared-object-base\";\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 ISharedObjectKind fixed one usage and didn't break anything, and generally seems more likely to work than the reverse, so this is the order being used.\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| ISharedObjectKind<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 = IFluidLoadable> = {\n\treadonly factory: { IFluidDataStoreFactory: DataObjectClass<T>[\"factory\"] };\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n} & (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"]}
package/lib/utils.d.ts CHANGED
@@ -2,10 +2,11 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { type IFluidLoadable } from "@fluidframework/core-interfaces";
5
6
  import { type IChannelFactory } from "@fluidframework/datastore-definitions";
6
7
  import { type IFluidDataStoreFactory, type NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions";
7
- import { type IFluidLoadable } from "@fluidframework/core-interfaces";
8
- import { type ContainerSchema, type DataObjectClass, type LoadableObjectClass, type SharedObjectClass } from "./types.js";
8
+ import type { ISharedObjectKind } from "@fluidframework/shared-object-base";
9
+ import { type ContainerSchema, type DataObjectClass, type LoadableObjectClass } from "./types.js";
9
10
  /**
10
11
  * An internal type used by the internal type guard isDataObjectClass to cast a
11
12
  * DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.
@@ -20,11 +21,11 @@ export declare function isDataObjectClass<T extends IFluidLoadable>(obj: Loadabl
20
21
  /**
21
22
  * Runtime check to determine if a class is a DataObject type.
22
23
  */
23
- export declare function isDataObjectClass(obj: unknown): obj is InternalDataObjectClass<IFluidLoadable>;
24
+ export declare function isDataObjectClass(obj: LoadableObjectClass): obj is InternalDataObjectClass<IFluidLoadable>;
24
25
  /**
25
26
  * Runtime check to determine if a class is a SharedObject type
26
27
  */
27
- export declare const isSharedObjectClass: (obj: unknown) => obj is SharedObjectClass<IFluidLoadable>;
28
+ export declare function isSharedObjectKind(obj: LoadableObjectClass): obj is ISharedObjectKind<IFluidLoadable>;
28
29
  /**
29
30
  * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
30
31
  * of both SharedObject or DataObject. This function separates the two and returns a registry
@@ -1 +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"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,gCAAgC,EACrC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAElG;;;;;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,CAChC,GAAG,EAAE,mBAAmB,GACtB,GAAG,IAAI,uBAAuB,CAAC,cAAc,CAAC,CAAC;AAyBlD;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,mBAAmB,GACtB,GAAG,IAAI,iBAAiB,CAAC,cAAc,CAAC,CAE1C;AAED;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,WACrC,eAAe,KACrB,CAAC,gCAAgC,EAAE,EAAE,eAAe,EAAE,CA4BxD,CAAC"}
package/lib/utils.js CHANGED
@@ -2,21 +2,28 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { UsageError } from "@fluidframework/telemetry-utils";
5
6
  /**
6
7
  * Runtime check to determine if a class is a DataObject type.
7
8
  */
8
9
  export function isDataObjectClass(obj) {
9
10
  const maybe = obj;
10
- return (maybe?.factory?.IFluidDataStoreFactory !== undefined &&
11
- maybe?.factory?.IFluidDataStoreFactory === maybe?.factory);
11
+ const isDataObject = maybe?.factory?.IFluidDataStoreFactory !== undefined &&
12
+ maybe.factory.IFluidDataStoreFactory === maybe.factory;
13
+ if (isDataObject ===
14
+ (obj.getFactory !== undefined)) {
15
+ // TODO: Currently nothing in the types or docs requires an actual DataObjectClass to not have a member called "getFactory" so there is a risk of this being a false positive.
16
+ // Refactoring the use of LoadableObjectClass such that explicit down casting is not required (for example by having a single factory API shared by both cases) could avoid problems like this.
17
+ throw new UsageError("Invalid LoadableObjectClass");
18
+ }
19
+ return isDataObject;
12
20
  }
13
21
  /**
14
22
  * Runtime check to determine if a class is a SharedObject type
15
23
  */
16
- export const isSharedObjectClass = (obj) => {
17
- const maybe = obj;
18
- return maybe?.getFactory !== undefined;
19
- };
24
+ export function isSharedObjectKind(obj) {
25
+ return !isDataObjectClass(obj);
26
+ }
20
27
  /**
21
28
  * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
22
29
  * of both SharedObject or DataObject. This function separates the two and returns a registry
@@ -26,7 +33,7 @@ export const parseDataObjectsFromSharedObjects = (schema) => {
26
33
  const registryEntries = new Set();
27
34
  const sharedObjects = new Set();
28
35
  const tryAddObject = (obj) => {
29
- if (isSharedObjectClass(obj)) {
36
+ if (isSharedObjectKind(obj)) {
30
37
  sharedObjects.add(obj.getFactory());
31
38
  }
32
39
  else if (isDataObjectClass(obj)) {
package/lib/utils.js.map CHANGED
@@ -1 +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;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 {\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"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AA0B7D;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAChC,GAAwB;IAExB,MAAM,KAAK,GAAG,GAAmE,CAAC;IAClF,MAAM,YAAY,GACjB,KAAK,EAAE,OAAO,EAAE,sBAAsB,KAAK,SAAS;QACpD,KAAK,CAAC,OAAO,CAAC,sBAAsB,KAAK,KAAK,CAAC,OAAO,CAAC;IAExD,IACC,YAAY;QACZ,CAAE,GAAkD,CAAC,UAAU,KAAK,SAAS,CAAC,EAC7E;QACD,8KAA8K;QAC9K,+LAA+L;QAC/L,MAAM,IAAI,UAAU,CAAC,6BAA6B,CAAC,CAAC;KACpD;IAED,OAAO,YAAY,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CACjC,GAAwB;IAExB,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC;AAED;;;;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,GAAwB,EAAQ,EAAE;QACvD,IAAI,kBAAkB,CAAC,GAAG,CAAC,EAAE;YAC5B,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 IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { type IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n\ttype IFluidDataStoreFactory,\n\ttype NamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport { UsageError } from \"@fluidframework/telemetry-utils\";\nimport { type ContainerSchema, type DataObjectClass, type LoadableObjectClass } 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(\n\tobj: LoadableObjectClass,\n): obj is InternalDataObjectClass<IFluidLoadable>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass(\n\tobj: LoadableObjectClass,\n): obj is InternalDataObjectClass<IFluidLoadable> {\n\tconst maybe = obj as Partial<InternalDataObjectClass<IFluidLoadable>> | undefined;\n\tconst isDataObject =\n\t\tmaybe?.factory?.IFluidDataStoreFactory !== undefined &&\n\t\tmaybe.factory.IFluidDataStoreFactory === maybe.factory;\n\n\tif (\n\t\tisDataObject ===\n\t\t((obj as Partial<ISharedObjectKind<IFluidLoadable>>).getFactory !== undefined)\n\t) {\n\t\t// TODO: Currently nothing in the types or docs requires an actual DataObjectClass to not have a member called \"getFactory\" so there is a risk of this being a false positive.\n\t\t// Refactoring the use of LoadableObjectClass such that explicit down casting is not required (for example by having a single factory API shared by both cases) could avoid problems like this.\n\t\tthrow new UsageError(\"Invalid LoadableObjectClass\");\n\t}\n\n\treturn isDataObject;\n}\n\n/**\n * Runtime check to determine if a class is a SharedObject type\n */\nexport function isSharedObjectKind(\n\tobj: LoadableObjectClass,\n): obj is ISharedObjectKind<IFluidLoadable> {\n\treturn !isDataObjectClass(obj);\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: LoadableObjectClass): void => {\n\t\tif (isSharedObjectKind(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.2.0.0.245554",
3
+ "version": "2.0.0-dev-rc.3.0.0.250606",
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": {
@@ -67,29 +67,32 @@
67
67
  "temp-directory": "nyc/.nyc_output"
68
68
  },
69
69
  "dependencies": {
70
- "@fluid-internal/client-utils": "2.0.0-dev-rc.2.0.0.245554",
71
- "@fluidframework/aqueduct": "2.0.0-dev-rc.2.0.0.245554",
72
- "@fluidframework/container-definitions": "2.0.0-dev-rc.2.0.0.245554",
73
- "@fluidframework/container-loader": "2.0.0-dev-rc.2.0.0.245554",
74
- "@fluidframework/container-runtime": "2.0.0-dev-rc.2.0.0.245554",
75
- "@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.2.0.0.245554",
76
- "@fluidframework/core-interfaces": "2.0.0-dev-rc.2.0.0.245554",
77
- "@fluidframework/datastore-definitions": "2.0.0-dev-rc.2.0.0.245554",
70
+ "@fluid-internal/client-utils": "2.0.0-dev-rc.3.0.0.250606",
71
+ "@fluidframework/aqueduct": "2.0.0-dev-rc.3.0.0.250606",
72
+ "@fluidframework/container-definitions": "2.0.0-dev-rc.3.0.0.250606",
73
+ "@fluidframework/container-loader": "2.0.0-dev-rc.3.0.0.250606",
74
+ "@fluidframework/container-runtime": "2.0.0-dev-rc.3.0.0.250606",
75
+ "@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.3.0.0.250606",
76
+ "@fluidframework/core-interfaces": "2.0.0-dev-rc.3.0.0.250606",
77
+ "@fluidframework/datastore-definitions": "2.0.0-dev-rc.3.0.0.250606",
78
78
  "@fluidframework/protocol-definitions": "^3.2.0",
79
- "@fluidframework/request-handler": "2.0.0-dev-rc.2.0.0.245554",
80
- "@fluidframework/runtime-definitions": "2.0.0-dev-rc.2.0.0.245554",
81
- "@fluidframework/runtime-utils": "2.0.0-dev-rc.2.0.0.245554"
79
+ "@fluidframework/request-handler": "2.0.0-dev-rc.3.0.0.250606",
80
+ "@fluidframework/runtime-definitions": "2.0.0-dev-rc.3.0.0.250606",
81
+ "@fluidframework/runtime-utils": "2.0.0-dev-rc.3.0.0.250606",
82
+ "@fluidframework/shared-object-base": "2.0.0-dev-rc.3.0.0.250606",
83
+ "@fluidframework/telemetry-utils": "2.0.0-dev-rc.3.0.0.250606"
82
84
  },
83
85
  "devDependencies": {
84
86
  "@arethetypeswrong/cli": "^0.13.3",
85
- "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.2.0.0.245554",
87
+ "@biomejs/biome": "^1.6.2",
88
+ "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.3.0.0.250606",
86
89
  "@fluid-tools/build-cli": "^0.34.0",
87
90
  "@fluidframework/build-common": "^2.0.3",
88
91
  "@fluidframework/build-tools": "^0.34.0",
89
92
  "@fluidframework/eslint-config-fluid": "^5.1.0",
90
93
  "@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-internal.8.0.0",
91
- "@fluidframework/map": "2.0.0-dev-rc.2.0.0.245554",
92
- "@fluidframework/sequence": "2.0.0-dev-rc.2.0.0.245554",
94
+ "@fluidframework/map": "2.0.0-dev-rc.3.0.0.250606",
95
+ "@fluidframework/sequence": "2.0.0-dev-rc.3.0.0.250606",
93
96
  "@microsoft/api-extractor": "^7.42.3",
94
97
  "@types/mocha": "^9.1.1",
95
98
  "@types/node": "^18.19.0",
@@ -121,6 +124,14 @@
121
124
  "broken": {
122
125
  "InterfaceDeclaration_ContainerSchema": {
123
126
  "backCompat": false
127
+ },
128
+ "RemovedTypeAliasDeclaration_LoadableObjectCtor": {
129
+ "backCompat": false,
130
+ "forwardCompat": false
131
+ },
132
+ "RemovedTypeAliasDeclaration_SharedObjectClass": {
133
+ "forwardCompat": false,
134
+ "backCompat": false
124
135
  }
125
136
  }
126
137
  },
@@ -137,16 +148,18 @@
137
148
  "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
138
149
  "build:test:esm": "tsc --project ./src/test/tsconfig.json",
139
150
  "check:are-the-types-wrong": "attw --pack . --entrypoints .",
151
+ "check:biome": "biome check .",
152
+ "check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
140
153
  "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
141
154
  "ci:build:docs": "api-extractor run",
142
155
  "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
143
156
  "eslint": "eslint --format stylish src",
144
157
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
145
- "format": "npm run prettier:fix",
146
- "lint": "npm run prettier && npm run check:release-tags && npm run eslint",
147
- "lint:fix": "npm run prettier:fix && npm run eslint:fix",
148
- "prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
149
- "prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
158
+ "format": "fluid-build --task format .",
159
+ "format:biome": "biome check --apply .",
160
+ "format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
161
+ "lint": "fluid-build . --task lint",
162
+ "lint:fix": "fluid-build . --task eslint:fix --task format",
150
163
  "test": "npm run test:mocha",
151
164
  "test:coverage": "c8 npm test",
152
165
  "test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
@@ -2,21 +2,22 @@
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
- import {
7
- type IEvent,
8
- type IEventProvider,
9
- type IFluidLoadable,
10
- } from "@fluidframework/core-interfaces";
11
7
  import {
12
8
  AttachState,
9
+ type ConnectionState,
13
10
  type IContainer,
14
11
  type ICriticalContainerError,
15
- type ConnectionState,
16
12
  } from "@fluidframework/container-definitions";
13
+ import {
14
+ type IEvent,
15
+ type IEventProvider,
16
+ type IFluidLoadable,
17
+ } from "@fluidframework/core-interfaces";
17
18
  import type {
18
- ContainerSchema,
19
19
  ContainerAttachProps,
20
+ ContainerSchema,
20
21
  IRootDataObject,
21
22
  LoadableObjectClass,
22
23
  } from "./types.js";
package/src/index.ts CHANGED
@@ -28,10 +28,8 @@ export {
28
28
  type IServiceAudienceEvents,
29
29
  type LoadableObjectClass,
30
30
  type LoadableObjectClassRecord,
31
- type LoadableObjectCtor,
32
31
  type LoadableObjectRecord,
33
32
  type MemberChangedListener,
34
33
  type Myself,
35
- type SharedObjectClass,
36
34
  type IProvideRootDataObject,
37
35
  } from "./types.js";
@@ -2,11 +2,14 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+
5
6
  import {
6
7
  BaseContainerRuntimeFactory,
7
8
  DataObject,
8
9
  DataObjectFactory,
9
10
  } from "@fluidframework/aqueduct";
11
+ import { type IRuntimeFactory } from "@fluidframework/container-definitions";
12
+ import { type ContainerRuntime } from "@fluidframework/container-runtime";
10
13
  import { type IContainerRuntime } from "@fluidframework/container-runtime-definitions";
11
14
  import {
12
15
  type FluidObject,
@@ -14,24 +17,22 @@ import {
14
17
  type IRequest,
15
18
  type IResponse,
16
19
  } from "@fluidframework/core-interfaces";
20
+ import { type IDirectory } from "@fluidframework/map";
17
21
  import { FlushMode } from "@fluidframework/runtime-definitions";
18
- import { type IRuntimeFactory } from "@fluidframework/container-definitions";
19
22
  import { RequestParser } from "@fluidframework/runtime-utils";
20
- import { type ContainerRuntime } from "@fluidframework/container-runtime";
21
- import { type IDirectory } from "@fluidframework/map";
22
23
 
24
+ import type { ISharedObjectKind } from "@fluidframework/shared-object-base";
23
25
  import {
24
26
  type ContainerSchema,
25
27
  type IRootDataObject,
26
28
  type LoadableObjectClass,
27
29
  type LoadableObjectClassRecord,
28
30
  type LoadableObjectRecord,
29
- type SharedObjectClass,
30
31
  } from "./types.js";
31
32
  import {
32
33
  type InternalDataObjectClass,
33
34
  isDataObjectClass,
34
- isSharedObjectClass,
35
+ isSharedObjectKind,
35
36
  parseDataObjectsFromSharedObjects,
36
37
  } from "./utils.js";
37
38
 
@@ -128,9 +129,9 @@ class RootDataObject
128
129
  */
129
130
  public async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {
130
131
  if (isDataObjectClass(objectClass)) {
131
- return this.createDataObject<T>(objectClass);
132
- } else if (isSharedObjectClass(objectClass)) {
133
- return this.createSharedObject<T>(objectClass);
132
+ return this.createDataObject(objectClass);
133
+ } else if (isSharedObjectKind(objectClass)) {
134
+ return this.createSharedObject(objectClass);
134
135
  }
135
136
  throw new Error("Could not create new Fluid object because an unknown object was passed");
136
137
  }
@@ -146,7 +147,7 @@ class RootDataObject
146
147
  }
147
148
 
148
149
  private createSharedObject<T extends IFluidLoadable>(
149
- sharedObjectClass: SharedObjectClass<T>,
150
+ sharedObjectClass: ISharedObjectKind<T>,
150
151
  ): T {
151
152
  const factory = sharedObjectClass.getFactory();
152
153
  const obj = this.runtime.createChannel(undefined, factory.type);
@@ -226,12 +227,14 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
226
227
  super({
227
228
  registryEntries: [rootDataObjectFactory.registryEntry],
228
229
  requestHandlers: [getDefaultObject],
230
+ // WARNING: These settigs are not compatible with FF 1.3 clients!
229
231
  runtimeOptions: {
230
232
  // temporary workaround to disable message batching until the message batch size issue is resolved
231
233
  // resolution progress is tracked by the Feature 465 work item in AzDO
232
234
  flushMode: FlushMode.Immediate,
233
235
  // The runtime compressor is required to be on to use @fluidframework/tree.
234
236
  enableRuntimeIdCompressor: "on",
237
+ explicitSchemaControl: true,
235
238
  },
236
239
  provideEntryPoint,
237
240
  });
@@ -7,9 +7,9 @@ import { TypedEventEmitter } from "@fluid-internal/client-utils";
7
7
  import { type IAudience, type IContainer } from "@fluidframework/container-definitions";
8
8
  import { type IClient } from "@fluidframework/protocol-definitions";
9
9
  import {
10
+ type IMember,
10
11
  type IServiceAudience,
11
12
  type IServiceAudienceEvents,
12
- type IMember,
13
13
  type Myself,
14
14
  } from "./types.js";
15
15
 
package/src/types.ts CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  type IEventProvider,
9
9
  type IFluidLoadable,
10
10
  } from "@fluidframework/core-interfaces";
11
- import { type IChannelFactory } from "@fluidframework/datastore-definitions";
11
+ import { type ISharedObjectKind } from "@fluidframework/shared-object-base";
12
12
 
13
13
  /**
14
14
  * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
@@ -33,11 +33,11 @@ export type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;
33
33
  * There are some edge cases in TypeScript where the order of the members in a union matter.
34
34
  * Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.
35
35
  * In this case, its better to have the desired match and/or the simpler type first.
36
- * In this case placing 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.
36
+ * In this case placing ISharedObjectKind fixed one usage and didn't break anything, and generally seems more likely to work than the reverse, so this is the order being used.
37
37
  * This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].
38
38
  */
39
39
  export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> =
40
- | SharedObjectClass<T>
40
+ | ISharedObjectKind<T>
41
41
  | DataObjectClass<T>;
42
42
 
43
43
  /**
@@ -47,31 +47,10 @@ export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> =
47
47
  * @typeParam T - The class of the `DataObject`.
48
48
  * @public
49
49
  */
50
- export type DataObjectClass<T extends IFluidLoadable> = {
50
+ export type DataObjectClass<T extends IFluidLoadable = IFluidLoadable> = {
51
51
  readonly factory: { IFluidDataStoreFactory: DataObjectClass<T>["factory"] };
52
- } & LoadableObjectCtor<T>;
53
-
54
- /**
55
- * A factory that produces a factory that can create a DDSes (`SharedObject`s).
56
- *
57
- * @typeParam T - The class of the `SharedObject`.
58
- * @public
59
- */
60
- export interface SharedObjectClass<T extends IFluidLoadable> {
61
- /**
62
- * Gets the factory this factory is a wrapper for.
63
- */
64
- readonly getFactory: () => IChannelFactory<T>;
65
- }
66
-
67
- /**
68
- * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
69
- *
70
- * @typeParam T - The class of the loadable object.
71
- * @public
72
- */
73
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
- export type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ } & (new (...args: any[]) => T);
75
54
 
76
55
  /**
77
56
  * Represents properties that can be attached to a container.
package/src/utils.ts CHANGED
@@ -3,18 +3,15 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { type IFluidLoadable } from "@fluidframework/core-interfaces";
6
7
  import { type IChannelFactory } from "@fluidframework/datastore-definitions";
7
8
  import {
8
9
  type IFluidDataStoreFactory,
9
10
  type NamedFluidDataStoreRegistryEntry,
10
11
  } from "@fluidframework/runtime-definitions";
11
- import { type IFluidLoadable } from "@fluidframework/core-interfaces";
12
- import {
13
- type ContainerSchema,
14
- type DataObjectClass,
15
- type LoadableObjectClass,
16
- type SharedObjectClass,
17
- } from "./types.js";
12
+ import type { ISharedObjectKind } from "@fluidframework/shared-object-base";
13
+ import { UsageError } from "@fluidframework/telemetry-utils";
14
+ import { type ContainerSchema, type DataObjectClass, type LoadableObjectClass } from "./types.js";
18
15
 
19
16
  /**
20
17
  * An internal type used by the internal type guard isDataObjectClass to cast a
@@ -35,26 +32,41 @@ export function isDataObjectClass<T extends IFluidLoadable>(
35
32
  /**
36
33
  * Runtime check to determine if a class is a DataObject type.
37
34
  */
38
- export function isDataObjectClass(obj: unknown): obj is InternalDataObjectClass<IFluidLoadable>;
35
+ export function isDataObjectClass(
36
+ obj: LoadableObjectClass,
37
+ ): obj is InternalDataObjectClass<IFluidLoadable>;
39
38
 
40
39
  /**
41
40
  * Runtime check to determine if a class is a DataObject type.
42
41
  */
43
- export function isDataObjectClass(obj: unknown): obj is InternalDataObjectClass<IFluidLoadable> {
42
+ export function isDataObjectClass(
43
+ obj: LoadableObjectClass,
44
+ ): obj is InternalDataObjectClass<IFluidLoadable> {
44
45
  const maybe = obj as Partial<InternalDataObjectClass<IFluidLoadable>> | undefined;
45
- return (
46
+ const isDataObject =
46
47
  maybe?.factory?.IFluidDataStoreFactory !== undefined &&
47
- maybe?.factory?.IFluidDataStoreFactory === maybe?.factory
48
- );
48
+ maybe.factory.IFluidDataStoreFactory === maybe.factory;
49
+
50
+ if (
51
+ isDataObject ===
52
+ ((obj as Partial<ISharedObjectKind<IFluidLoadable>>).getFactory !== undefined)
53
+ ) {
54
+ // TODO: Currently nothing in the types or docs requires an actual DataObjectClass to not have a member called "getFactory" so there is a risk of this being a false positive.
55
+ // Refactoring the use of LoadableObjectClass such that explicit down casting is not required (for example by having a single factory API shared by both cases) could avoid problems like this.
56
+ throw new UsageError("Invalid LoadableObjectClass");
57
+ }
58
+
59
+ return isDataObject;
49
60
  }
50
61
 
51
62
  /**
52
63
  * Runtime check to determine if a class is a SharedObject type
53
64
  */
54
- export const isSharedObjectClass = (obj: unknown): obj is SharedObjectClass<IFluidLoadable> => {
55
- const maybe = obj as Partial<SharedObjectClass<IFluidLoadable>> | undefined;
56
- return maybe?.getFactory !== undefined;
57
- };
65
+ export function isSharedObjectKind(
66
+ obj: LoadableObjectClass,
67
+ ): obj is ISharedObjectKind<IFluidLoadable> {
68
+ return !isDataObjectClass(obj);
69
+ }
58
70
 
59
71
  /**
60
72
  * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
@@ -67,8 +79,8 @@ export const parseDataObjectsFromSharedObjects = (
67
79
  const registryEntries = new Set<NamedFluidDataStoreRegistryEntry>();
68
80
  const sharedObjects = new Set<IChannelFactory>();
69
81
 
70
- const tryAddObject = (obj: unknown): void => {
71
- if (isSharedObjectClass(obj)) {
82
+ const tryAddObject = (obj: LoadableObjectClass): void => {
83
+ if (isSharedObjectKind(obj)) {
72
84
  sharedObjects.add(obj.getFactory());
73
85
  } else if (isDataObjectClass(obj)) {
74
86
  registryEntries.add([obj.factory.type, Promise.resolve(obj.factory)]);