@fluidframework/fluid-static 2.0.0-rc.1.0.3 → 2.0.0-rc.2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +1 -1
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +10 -0
  4. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
  5. package/api-extractor.json +1 -1
  6. package/api-report/fluid-static.api.md +17 -14
  7. package/dist/fluid-static-alpha.d.ts +29 -13
  8. package/dist/fluid-static-beta.d.ts +29 -13
  9. package/dist/fluid-static-public.d.ts +29 -13
  10. package/dist/fluid-static-untrimmed.d.ts +44 -16
  11. package/dist/fluidContainer.d.ts +9 -6
  12. package/dist/fluidContainer.d.ts.map +1 -1
  13. package/dist/fluidContainer.js +3 -1
  14. package/dist/fluidContainer.js.map +1 -1
  15. package/dist/index.d.ts +4 -4
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +6 -6
  18. package/dist/index.js.map +1 -1
  19. package/dist/package.json +3 -0
  20. package/dist/rootDataObject.d.ts +5 -2
  21. package/dist/rootDataObject.d.ts.map +1 -1
  22. package/dist/rootDataObject.js +12 -8
  23. package/dist/rootDataObject.js.map +1 -1
  24. package/dist/serviceAudience.d.ts +13 -6
  25. package/dist/serviceAudience.d.ts.map +1 -1
  26. package/dist/serviceAudience.js +12 -4
  27. package/dist/serviceAudience.js.map +1 -1
  28. package/dist/tsdoc-metadata.json +1 -1
  29. package/dist/types.d.ts +26 -12
  30. package/dist/types.d.ts.map +1 -1
  31. package/dist/types.js.map +1 -1
  32. package/dist/utils.d.ts +13 -9
  33. package/dist/utils.d.ts.map +1 -1
  34. package/dist/utils.js +11 -8
  35. package/dist/utils.js.map +1 -1
  36. package/lib/{fluid-static-alpha.d.mts → fluid-static-alpha.d.ts} +35 -13
  37. package/lib/{fluid-static-beta.d.mts → fluid-static-beta.d.ts} +35 -13
  38. package/lib/{fluid-static-public.d.mts → fluid-static-public.d.ts} +35 -13
  39. package/lib/{fluid-static-untrimmed.d.mts → fluid-static-untrimmed.d.ts} +50 -16
  40. package/lib/{fluidContainer.d.mts → fluidContainer.d.ts} +10 -7
  41. package/lib/fluidContainer.d.ts.map +1 -0
  42. package/lib/{fluidContainer.mjs → fluidContainer.js} +8 -2
  43. package/lib/fluidContainer.js.map +1 -0
  44. package/lib/index.d.ts +14 -0
  45. package/lib/index.d.ts.map +1 -0
  46. package/lib/index.js +13 -0
  47. package/lib/index.js.map +1 -0
  48. package/lib/{rootDataObject.d.mts → rootDataObject.d.ts} +6 -3
  49. package/lib/rootDataObject.d.ts.map +1 -0
  50. package/lib/{rootDataObject.mjs → rootDataObject.js} +14 -6
  51. package/lib/rootDataObject.js.map +1 -0
  52. package/lib/serviceAudience.d.ts +22 -0
  53. package/lib/serviceAudience.d.ts.map +1 -0
  54. package/lib/{serviceAudience.mjs → serviceAudience.js} +13 -5
  55. package/lib/serviceAudience.js.map +1 -0
  56. package/lib/test/fluidContainer.spec.js +21 -0
  57. package/lib/test/fluidContainer.spec.js.map +1 -0
  58. package/lib/test/types/validateFluidStaticPrevious.generated.js +46 -0
  59. package/lib/test/types/validateFluidStaticPrevious.generated.js.map +1 -0
  60. package/lib/test/utils.spec.js +86 -0
  61. package/lib/test/utils.spec.js.map +1 -0
  62. package/lib/{types.d.mts → types.d.ts} +27 -13
  63. package/lib/types.d.ts.map +1 -0
  64. package/lib/{types.mjs → types.js} +1 -1
  65. package/lib/types.js.map +1 -0
  66. package/lib/utils.d.ts +34 -0
  67. package/lib/utils.d.ts.map +1 -0
  68. package/lib/{utils.mjs → utils.js} +11 -8
  69. package/lib/utils.js.map +1 -0
  70. package/package.json +45 -58
  71. package/src/fluidContainer.ts +29 -17
  72. package/src/index.ts +23 -22
  73. package/src/rootDataObject.ts +48 -29
  74. package/src/serviceAudience.ts +35 -22
  75. package/src/types.ts +34 -14
  76. package/src/utils.ts +36 -16
  77. package/tsconfig.cjs.json +7 -0
  78. package/tsconfig.json +4 -8
  79. package/lib/fluidContainer.d.mts.map +0 -1
  80. package/lib/fluidContainer.mjs.map +0 -1
  81. package/lib/index.d.mts +0 -9
  82. package/lib/index.d.mts.map +0 -1
  83. package/lib/index.mjs +0 -8
  84. package/lib/index.mjs.map +0 -1
  85. package/lib/rootDataObject.d.mts.map +0 -1
  86. package/lib/rootDataObject.mjs.map +0 -1
  87. package/lib/serviceAudience.d.mts +0 -15
  88. package/lib/serviceAudience.d.mts.map +0 -1
  89. package/lib/serviceAudience.mjs.map +0 -1
  90. package/lib/types.d.mts.map +0 -1
  91. package/lib/types.mjs.map +0 -1
  92. package/lib/utils.d.mts +0 -30
  93. package/lib/utils.d.mts.map +0 -1
  94. package/lib/utils.mjs.map +0 -1
package/dist/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 { 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.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"]}
package/dist/utils.d.ts CHANGED
@@ -2,28 +2,32 @@
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";
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 LoadableObjectClass, type SharedObjectClass } from "./types.js";
9
9
  /**
10
10
  * An internal type used by the internal type guard isDataObjectClass to cast a
11
11
  * DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.
12
- * Unlike the external and exported type DataObjectClass which is
12
+ * Unlike the external and exported type DataObjectClass which is
13
13
  * weakly coupled to the IFluidDataStoreFactory to prevent leaking internals.
14
14
  */
15
15
  export type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<T> & Record<"factory", IFluidDataStoreFactory>;
16
16
  /**
17
- * Runtime check to determine if a class is a DataObject type
17
+ * Runtime check to determine if a class is a DataObject type.
18
18
  */
19
- export declare const isDataObjectClass: (obj: any) => obj is InternalDataObjectClass<IFluidLoadable>;
19
+ export declare function isDataObjectClass<T extends IFluidLoadable>(obj: LoadableObjectClass<T>): obj is InternalDataObjectClass<T>;
20
+ /**
21
+ * Runtime check to determine if a class is a DataObject type.
22
+ */
23
+ export declare function isDataObjectClass(obj: unknown): obj is InternalDataObjectClass<IFluidLoadable>;
20
24
  /**
21
25
  * Runtime check to determine if a class is a SharedObject type
22
26
  */
23
- export declare const isSharedObjectClass: (obj: any) => obj is SharedObjectClass<any>;
27
+ export declare const isSharedObjectClass: (obj: unknown) => obj is SharedObjectClass<IFluidLoadable>;
24
28
  /**
25
29
  * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
26
- * of both SharedObject or DataObject. This function seperates the two and returns a registery
30
+ * of both SharedObject or DataObject. This function separates the two and returns a registry
27
31
  * of DataObject types and an array of SharedObjects.
28
32
  */
29
33
  export declare const parseDataObjectsFromSharedObjects: (schema: ContainerSchema) => [NamedFluidDataStoreRegistryEntry[], IChannelFactory[]];
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EACN,sBAAsB,EACtB,gCAAgC,EAChC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAuB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEnG;;;;;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.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"}
package/dist/utils.js CHANGED
@@ -6,24 +6,25 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.parseDataObjectsFromSharedObjects = exports.isSharedObjectClass = exports.isDataObjectClass = void 0;
8
8
  /**
9
- * Runtime check to determine if a class is a DataObject type
9
+ * Runtime check to determine if a class is a DataObject type.
10
10
  */
11
- const isDataObjectClass = (obj) => {
11
+ function isDataObjectClass(obj) {
12
12
  const maybe = obj;
13
13
  return (maybe?.factory?.IFluidDataStoreFactory !== undefined &&
14
14
  maybe?.factory?.IFluidDataStoreFactory === maybe?.factory);
15
- };
15
+ }
16
16
  exports.isDataObjectClass = isDataObjectClass;
17
17
  /**
18
18
  * Runtime check to determine if a class is a SharedObject type
19
19
  */
20
20
  const isSharedObjectClass = (obj) => {
21
- return obj?.getFactory !== undefined;
21
+ const maybe = obj;
22
+ return maybe?.getFactory !== undefined;
22
23
  };
23
24
  exports.isSharedObjectClass = isSharedObjectClass;
24
25
  /**
25
26
  * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
26
- * of both SharedObject or DataObject. This function seperates the two and returns a registery
27
+ * of both SharedObject or DataObject. This function separates the two and returns a registry
27
28
  * of DataObject types and an array of SharedObjects.
28
29
  */
29
30
  const parseDataObjectsFromSharedObjects = (schema) => {
@@ -33,7 +34,7 @@ const parseDataObjectsFromSharedObjects = (schema) => {
33
34
  if ((0, exports.isSharedObjectClass)(obj)) {
34
35
  sharedObjects.add(obj.getFactory());
35
36
  }
36
- else if ((0, exports.isDataObjectClass)(obj)) {
37
+ else if (isDataObjectClass(obj)) {
37
38
  registryEntries.add([obj.factory.type, Promise.resolve(obj.factory)]);
38
39
  }
39
40
  else {
@@ -45,11 +46,13 @@ const parseDataObjectsFromSharedObjects = (schema) => {
45
46
  ...Object.values(schema.initialObjects),
46
47
  ...(schema.dynamicObjectTypes ?? []),
47
48
  ]);
48
- dedupedObjects.forEach(tryAddObject);
49
+ for (const obj of dedupedObjects) {
50
+ tryAddObject(obj);
51
+ }
49
52
  if (registryEntries.size === 0 && sharedObjects.size === 0) {
50
53
  throw new Error("Container cannot be initialized without any DataTypes");
51
54
  }
52
- return [Array.from(registryEntries), Array.from(sharedObjects)];
55
+ return [[...registryEntries], [...sharedObjects]];
53
56
  };
54
57
  exports.parseDataObjectsFromSharedObjects = parseDataObjectsFromSharedObjects;
55
58
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAmBH;;GAEG;AACI,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;AANW,QAAA,iBAAiB,qBAM5B;AAEF;;GAEG;AACI,MAAM,mBAAmB,GAAG,CAAC,GAAQ,EAAiC,EAAE;IAC9E,OAAO,GAAG,EAAE,UAAU,KAAK,SAAS,CAAC;AACtC,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B;AAEF;;;;GAIG;AACI,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,IAAA,2BAAmB,EAAC,GAAG,CAAC,EAAE;YAC7B,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;SACpC;aAAM,IAAI,IAAA,yBAAiB,EAAC,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;AA5BW,QAAA,iCAAiC,qCA4B5C","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.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAoCH;;GAEG;AACH,SAAgB,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;AAND,8CAMC;AAED;;GAEG;AACI,MAAM,mBAAmB,GAAG,CAAC,GAAY,EAA4C,EAAE;IAC7F,MAAM,KAAK,GAAG,GAA6D,CAAC;IAC5E,OAAO,KAAK,EAAE,UAAU,KAAK,SAAS,CAAC;AACxC,CAAC,CAAC;AAHW,QAAA,mBAAmB,uBAG9B;AAEF;;;;GAIG;AACI,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,IAAA,2BAAmB,EAAC,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;AA9BW,QAAA,iCAAiC,qCA8B5C","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,3 +1,9 @@
1
+ /**
2
+ * Provides a simple and powerful way to consume collaborative Fluid data.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
1
7
  import { AttachState } from '@fluidframework/container-definitions';
2
8
  import { ConnectionState } from '@fluidframework/container-definitions';
3
9
  import { IChannelFactory } from '@fluidframework/datastore-definitions';
@@ -9,6 +15,12 @@ import { IEventProvider } from '@fluidframework/core-interfaces';
9
15
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
10
16
  import { IRuntimeFactory } from '@fluidframework/container-definitions';
11
17
 
18
+ /**
19
+ * Represents properties that can be attached to a container.
20
+ * @public
21
+ */
22
+ export declare type ContainerAttachProps<T = unknown> = T;
23
+
12
24
  /**
13
25
  * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
14
26
  *
@@ -37,7 +49,7 @@ export declare interface ContainerSchema {
37
49
  * }
38
50
  * ```
39
51
  */
40
- initialObjects: LoadableObjectClassRecord;
52
+ readonly initialObjects: LoadableObjectClassRecord;
41
53
  /**
42
54
  * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
43
55
  *
@@ -48,7 +60,7 @@ export declare interface ContainerSchema {
48
60
  * For best practice it's recommended to define all the dynamic types you create even if they are
49
61
  * included via initialObjects.
50
62
  */
51
- dynamicObjectTypes?: LoadableObjectClass<any>[];
63
+ readonly dynamicObjectTypes?: readonly LoadableObjectClass[];
52
64
  }
53
65
 
54
66
  /* Excluded from this release type: createDOProviderContainerRuntimeFactory */
@@ -94,6 +106,7 @@ export declare interface IConnection {
94
106
  * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
95
107
  *
96
108
  * @remarks Note: external implementations of this interface are not supported.
109
+ *
97
110
  * @sealed
98
111
  * @public
99
112
  */
@@ -155,7 +168,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
155
168
  *
156
169
  * @returns A promise which resolves when the attach is complete, with the string identifier of the container.
157
170
  */
158
- attach(): Promise<string>;
171
+ attach(props?: ContainerAttachProps): Promise<string>;
159
172
  /**
160
173
  * Attempts to connect the container to the delta stream and process operations.
161
174
  *
@@ -164,7 +177,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
164
177
  * @remarks
165
178
  *
166
179
  * This should only be called when the container is in the
167
- * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
180
+ * {@link @fluidframework/container-definitions#(ConnectionState:namespace).Disconnected} state.
168
181
  *
169
182
  * This can be determined by observing {@link IFluidContainer.connectionState}.
170
183
  */
@@ -175,7 +188,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
175
188
  * @remarks
176
189
  *
177
190
  * This should only be called when the container is in the
178
- * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
191
+ * {@link @fluidframework/container-definitions#(ConnectionState:namespace).Connected} state.
179
192
  *
180
193
  * This can be determined by observing {@link IFluidContainer.connectionState}.
181
194
  */
@@ -349,15 +362,22 @@ export declare interface IServiceAudienceEvents<M extends IMember> extends IEven
349
362
  *
350
363
  * @typeParam T - The class of the `DataObject` or `SharedObject`.
351
364
  * @public
365
+ *
366
+ * @privateRemarks
367
+ * There are some edge cases in TypeScript where the order of the members in a union matter.
368
+ * Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.
369
+ * In this case, its better to have the desired match and/or the simpler type first.
370
+ * 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.
371
+ * This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].
352
372
  */
353
- export declare type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> | SharedObjectClass<T>;
373
+ export declare type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> = SharedObjectClass<T> | DataObjectClass<T>;
354
374
 
355
375
  /**
356
376
  * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
357
- * or `SharedObject` in a {@link LoadableObjectRecord}.
377
+ * or `SharedObject`.
358
378
  * @public
359
379
  */
360
- export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
380
+ export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;
361
381
 
362
382
  /**
363
383
  * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
@@ -389,14 +409,16 @@ export declare type Myself<M extends IMember = IMember> = M & {
389
409
  };
390
410
 
391
411
  /**
392
- * A class that has a factory that can create a DDSes (`SharedObject`s) and a
393
- * constructor that will return the type of the `DataObject`.
412
+ * A factory that produces a factory that can create a DDSes (`SharedObject`s).
394
413
  *
395
414
  * @typeParam T - The class of the `SharedObject`.
396
415
  * @public
397
416
  */
398
- export declare type SharedObjectClass<T extends IFluidLoadable> = {
399
- readonly getFactory: () => IChannelFactory;
400
- } & LoadableObjectCtor<T>;
417
+ export declare interface SharedObjectClass<T extends IFluidLoadable> {
418
+ /**
419
+ * Gets the factory this factory is a wrapper for.
420
+ */
421
+ readonly getFactory: () => IChannelFactory<T>;
422
+ }
401
423
 
402
424
  export { }
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Provides a simple and powerful way to consume collaborative Fluid data.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
1
7
  import { AttachState } from '@fluidframework/container-definitions';
2
8
  import { ConnectionState } from '@fluidframework/container-definitions';
3
9
  import { IChannelFactory } from '@fluidframework/datastore-definitions';
@@ -9,6 +15,12 @@ import { IEventProvider } from '@fluidframework/core-interfaces';
9
15
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
10
16
  import { IRuntimeFactory } from '@fluidframework/container-definitions';
11
17
 
18
+ /**
19
+ * Represents properties that can be attached to a container.
20
+ * @public
21
+ */
22
+ export declare type ContainerAttachProps<T = unknown> = T;
23
+
12
24
  /**
13
25
  * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
14
26
  *
@@ -37,7 +49,7 @@ export declare interface ContainerSchema {
37
49
  * }
38
50
  * ```
39
51
  */
40
- initialObjects: LoadableObjectClassRecord;
52
+ readonly initialObjects: LoadableObjectClassRecord;
41
53
  /**
42
54
  * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
43
55
  *
@@ -48,7 +60,7 @@ export declare interface ContainerSchema {
48
60
  * For best practice it's recommended to define all the dynamic types you create even if they are
49
61
  * included via initialObjects.
50
62
  */
51
- dynamicObjectTypes?: LoadableObjectClass<any>[];
63
+ readonly dynamicObjectTypes?: readonly LoadableObjectClass[];
52
64
  }
53
65
 
54
66
  /* Excluded from this release type: createDOProviderContainerRuntimeFactory */
@@ -96,6 +108,7 @@ export declare interface IConnection {
96
108
  * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
97
109
  *
98
110
  * @remarks Note: external implementations of this interface are not supported.
111
+ *
99
112
  * @sealed
100
113
  * @public
101
114
  */
@@ -157,7 +170,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
157
170
  *
158
171
  * @returns A promise which resolves when the attach is complete, with the string identifier of the container.
159
172
  */
160
- attach(): Promise<string>;
173
+ attach(props?: ContainerAttachProps): Promise<string>;
161
174
  /**
162
175
  * Attempts to connect the container to the delta stream and process operations.
163
176
  *
@@ -166,7 +179,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
166
179
  * @remarks
167
180
  *
168
181
  * This should only be called when the container is in the
169
- * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
182
+ * {@link @fluidframework/container-definitions#(ConnectionState:namespace).Disconnected} state.
170
183
  *
171
184
  * This can be determined by observing {@link IFluidContainer.connectionState}.
172
185
  */
@@ -177,7 +190,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
177
190
  * @remarks
178
191
  *
179
192
  * This should only be called when the container is in the
180
- * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
193
+ * {@link @fluidframework/container-definitions#(ConnectionState:namespace).Connected} state.
181
194
  *
182
195
  * This can be determined by observing {@link IFluidContainer.connectionState}.
183
196
  */
@@ -353,15 +366,22 @@ export declare interface IServiceAudienceEvents<M extends IMember> extends IEven
353
366
  *
354
367
  * @typeParam T - The class of the `DataObject` or `SharedObject`.
355
368
  * @public
369
+ *
370
+ * @privateRemarks
371
+ * There are some edge cases in TypeScript where the order of the members in a union matter.
372
+ * Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.
373
+ * In this case, its better to have the desired match and/or the simpler type first.
374
+ * 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.
375
+ * This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].
356
376
  */
357
- export declare type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> | SharedObjectClass<T>;
377
+ export declare type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> = SharedObjectClass<T> | DataObjectClass<T>;
358
378
 
359
379
  /**
360
380
  * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
361
- * or `SharedObject` in a {@link LoadableObjectRecord}.
381
+ * or `SharedObject`.
362
382
  * @public
363
383
  */
364
- export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
384
+ export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;
365
385
 
366
386
  /**
367
387
  * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
@@ -393,14 +413,16 @@ export declare type Myself<M extends IMember = IMember> = M & {
393
413
  };
394
414
 
395
415
  /**
396
- * A class that has a factory that can create a DDSes (`SharedObject`s) and a
397
- * constructor that will return the type of the `DataObject`.
416
+ * A factory that produces a factory that can create a DDSes (`SharedObject`s).
398
417
  *
399
418
  * @typeParam T - The class of the `SharedObject`.
400
419
  * @public
401
420
  */
402
- export declare type SharedObjectClass<T extends IFluidLoadable> = {
403
- readonly getFactory: () => IChannelFactory;
404
- } & LoadableObjectCtor<T>;
421
+ export declare interface SharedObjectClass<T extends IFluidLoadable> {
422
+ /**
423
+ * Gets the factory this factory is a wrapper for.
424
+ */
425
+ readonly getFactory: () => IChannelFactory<T>;
426
+ }
405
427
 
406
428
  export { }
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Provides a simple and powerful way to consume collaborative Fluid data.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
1
7
  import { AttachState } from '@fluidframework/container-definitions';
2
8
  import { ConnectionState } from '@fluidframework/container-definitions';
3
9
  import { IChannelFactory } from '@fluidframework/datastore-definitions';
@@ -9,6 +15,12 @@ import { IEventProvider } from '@fluidframework/core-interfaces';
9
15
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
10
16
  import { IRuntimeFactory } from '@fluidframework/container-definitions';
11
17
 
18
+ /**
19
+ * Represents properties that can be attached to a container.
20
+ * @public
21
+ */
22
+ export declare type ContainerAttachProps<T = unknown> = T;
23
+
12
24
  /**
13
25
  * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
14
26
  *
@@ -37,7 +49,7 @@ export declare interface ContainerSchema {
37
49
  * }
38
50
  * ```
39
51
  */
40
- initialObjects: LoadableObjectClassRecord;
52
+ readonly initialObjects: LoadableObjectClassRecord;
41
53
  /**
42
54
  * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
43
55
  *
@@ -48,7 +60,7 @@ export declare interface ContainerSchema {
48
60
  * For best practice it's recommended to define all the dynamic types you create even if they are
49
61
  * included via initialObjects.
50
62
  */
51
- dynamicObjectTypes?: LoadableObjectClass<any>[];
63
+ readonly dynamicObjectTypes?: readonly LoadableObjectClass[];
52
64
  }
53
65
 
54
66
  /* Excluded from this release type: createDOProviderContainerRuntimeFactory */
@@ -96,6 +108,7 @@ export declare interface IConnection {
96
108
  * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
97
109
  *
98
110
  * @remarks Note: external implementations of this interface are not supported.
111
+ *
99
112
  * @sealed
100
113
  * @public
101
114
  */
@@ -157,7 +170,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
157
170
  *
158
171
  * @returns A promise which resolves when the attach is complete, with the string identifier of the container.
159
172
  */
160
- attach(): Promise<string>;
173
+ attach(props?: ContainerAttachProps): Promise<string>;
161
174
  /**
162
175
  * Attempts to connect the container to the delta stream and process operations.
163
176
  *
@@ -166,7 +179,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
166
179
  * @remarks
167
180
  *
168
181
  * This should only be called when the container is in the
169
- * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
182
+ * {@link @fluidframework/container-definitions#(ConnectionState:namespace).Disconnected} state.
170
183
  *
171
184
  * This can be determined by observing {@link IFluidContainer.connectionState}.
172
185
  */
@@ -177,7 +190,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
177
190
  * @remarks
178
191
  *
179
192
  * This should only be called when the container is in the
180
- * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
193
+ * {@link @fluidframework/container-definitions#(ConnectionState:namespace).Connected} state.
181
194
  *
182
195
  * This can be determined by observing {@link IFluidContainer.connectionState}.
183
196
  */
@@ -353,15 +366,22 @@ export declare interface IServiceAudienceEvents<M extends IMember> extends IEven
353
366
  *
354
367
  * @typeParam T - The class of the `DataObject` or `SharedObject`.
355
368
  * @public
369
+ *
370
+ * @privateRemarks
371
+ * There are some edge cases in TypeScript where the order of the members in a union matter.
372
+ * Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.
373
+ * In this case, its better to have the desired match and/or the simpler type first.
374
+ * 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.
375
+ * This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].
356
376
  */
357
- export declare type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> | SharedObjectClass<T>;
377
+ export declare type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> = SharedObjectClass<T> | DataObjectClass<T>;
358
378
 
359
379
  /**
360
380
  * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
361
- * or `SharedObject` in a {@link LoadableObjectRecord}.
381
+ * or `SharedObject`.
362
382
  * @public
363
383
  */
364
- export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
384
+ export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;
365
385
 
366
386
  /**
367
387
  * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
@@ -393,14 +413,16 @@ export declare type Myself<M extends IMember = IMember> = M & {
393
413
  };
394
414
 
395
415
  /**
396
- * A class that has a factory that can create a DDSes (`SharedObject`s) and a
397
- * constructor that will return the type of the `DataObject`.
416
+ * A factory that produces a factory that can create a DDSes (`SharedObject`s).
398
417
  *
399
418
  * @typeParam T - The class of the `SharedObject`.
400
419
  * @public
401
420
  */
402
- export declare type SharedObjectClass<T extends IFluidLoadable> = {
403
- readonly getFactory: () => IChannelFactory;
404
- } & LoadableObjectCtor<T>;
421
+ export declare interface SharedObjectClass<T extends IFluidLoadable> {
422
+ /**
423
+ * Gets the factory this factory is a wrapper for.
424
+ */
425
+ readonly getFactory: () => IChannelFactory<T>;
426
+ }
405
427
 
406
428
  export { }