@fluidframework/fluid-static 2.101.1 → 2.102.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 (59) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/api-report/fluid-static.alpha.api.md +1 -1
  3. package/api-report/fluid-static.beta.api.md +1 -1
  4. package/api-report/fluid-static.legacy.beta.api.md +9 -1
  5. package/api-report/fluid-static.legacy.public.api.md +1 -1
  6. package/api-report/fluid-static.public.api.md +1 -1
  7. package/dist/compatibilityConfiguration.d.ts +8 -7
  8. package/dist/compatibilityConfiguration.d.ts.map +1 -1
  9. package/dist/compatibilityConfiguration.js +22 -7
  10. package/dist/compatibilityConfiguration.js.map +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +2 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/rootDataObject.d.ts +5 -11
  16. package/dist/rootDataObject.d.ts.map +1 -1
  17. package/dist/rootDataObject.js +9 -9
  18. package/dist/rootDataObject.js.map +1 -1
  19. package/dist/treeRootDataObject.d.ts +38 -4
  20. package/dist/treeRootDataObject.d.ts.map +1 -1
  21. package/dist/treeRootDataObject.js +20 -19
  22. package/dist/treeRootDataObject.js.map +1 -1
  23. package/dist/types.d.ts +6 -0
  24. package/dist/types.d.ts.map +1 -1
  25. package/dist/types.js.map +1 -1
  26. package/dist/utils.d.ts +10 -7
  27. package/dist/utils.d.ts.map +1 -1
  28. package/dist/utils.js +18 -6
  29. package/dist/utils.js.map +1 -1
  30. package/lib/compatibilityConfiguration.d.ts +8 -7
  31. package/lib/compatibilityConfiguration.d.ts.map +1 -1
  32. package/lib/compatibilityConfiguration.js +20 -6
  33. package/lib/compatibilityConfiguration.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 +1 -1
  37. package/lib/index.js.map +1 -1
  38. package/lib/rootDataObject.d.ts +5 -11
  39. package/lib/rootDataObject.d.ts.map +1 -1
  40. package/lib/rootDataObject.js +11 -11
  41. package/lib/rootDataObject.js.map +1 -1
  42. package/lib/treeRootDataObject.d.ts +38 -4
  43. package/lib/treeRootDataObject.d.ts.map +1 -1
  44. package/lib/treeRootDataObject.js +22 -21
  45. package/lib/treeRootDataObject.js.map +1 -1
  46. package/lib/types.d.ts +6 -0
  47. package/lib/types.d.ts.map +1 -1
  48. package/lib/types.js.map +1 -1
  49. package/lib/utils.d.ts +10 -7
  50. package/lib/utils.d.ts.map +1 -1
  51. package/lib/utils.js +16 -5
  52. package/lib/utils.js.map +1 -1
  53. package/package.json +24 -23
  54. package/src/compatibilityConfiguration.ts +27 -9
  55. package/src/index.ts +4 -1
  56. package/src/rootDataObject.ts +15 -32
  57. package/src/treeRootDataObject.ts +76 -17
  58. package/src/types.ts +6 -0
  59. package/src/utils.ts +18 -5
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 type { DataObjectKind } from \"@fluidframework/aqueduct/internal\";\nimport type { ContainerExtensionStore } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tIEvent,\n\tIEventProvider,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport type {\n\tISharedObjectKind,\n\tSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\nimport type { ITree } from \"@fluidframework/tree\";\n\n/**\n * Determines the set of runtime options that Fluid Framework will use when running.\n * In \"1\" mode we support full interop between 2.x clients and 1.x clients,\n * while in \"2\" mode we only support interop between 2.x clients.\n *\n * @public\n */\nexport type CompatibilityMode = \"1\" | \"2\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\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 */\nexport type LoadableObjectKindRecord = Record<string, SharedObjectKind>;\n\n/**\n * A kind of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The kind of `DataObject` or `SharedObject`.\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 LoadableObjectKind<T extends IFluidLoadable = IFluidLoadable> =\n\t| ISharedObjectKind<T>\n\t| DataObjectKind<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: Record<string, SharedObjectKind>;\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 SharedObjectKind[];\n}\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 kind of `SharedTree` that will be 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 *\n * @legacy @beta\n */\nexport interface TreeContainerSchema extends ContainerSchema {\n\t// TODO: longer term, it would be better to not have to fit into the `initialObjects` model for tree-based containers.\n\t// But in the short term, fitting into this model makes migration easier.\n\treadonly initialObjects: {\n\t\treadonly tree: SharedObjectKind<ITree>;\n\t};\n}\n\n/**\n * Holds the collection of objects that the container was initially created with.\n * Additionally provides the ability to dynamically create further objects during usage.\n */\nexport interface IRootDataObject {\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>(objectClass: SharedObjectKind<T>): Promise<T>;\n\n\t/**\n\t * Upload a blob of data.\n\t * Although it is marked as internal, there is external usage of this function for experimental purposes.\n\t * Please contact yunho-microsoft or vladsud if you need to change it.\n\t * @param blob - blob to be uploaded.\n\t *\n\t * @remarks This method is used to expose uploadBlob to the IFluidContainer level. UploadBlob will upload data to server side (as of now, ODSP only). There is no downloadBlob provided as it is not needed(blob lifetime managed by server).\n\t */\n\tuploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;\n\n\t/**\n\t * Provides a record of the initial objects defined on creation.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n}\n\ninterface IProvideStaticEntryPoint {\n\treadonly IStaticEntryPoint: IStaticEntryPoint;\n}\n\n/**\n * This is the internal entry point fluid-static creates.\n */\nexport interface IStaticEntryPoint extends IProvideStaticEntryPoint {\n\treadonly rootDataObject: IRootDataObject;\n\treadonly extensionStore: ContainerExtensionStore;\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(): ReadonlyMap<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\treadonly id: string;\n\n\t/**\n\t * Whether the connection is in read or read/write mode.\n\t */\n\treadonly mode: \"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\treadonly id: string;\n\n\t/**\n\t * The set of connections the user has made, e.g. from multiple tabs or devices.\n\t */\n\treadonly connections: IConnection[];\n}\n\n/**\n * An extended member object that includes currentConnection\n * @public\n */\nexport type Myself<M extends IMember = IMember> = M & { readonly 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 type { DataObjectKind } from \"@fluidframework/aqueduct/internal\";\nimport type { ContainerExtensionStore } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tIEvent,\n\tIEventProvider,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport type {\n\tISharedObjectKind,\n\tSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\nimport type { ITree } from \"@fluidframework/tree\";\n\n/**\n * Determines the set of runtime options that Fluid Framework will use when running.\n * In \"1\" mode we support full interop between 2.x clients and 1.x clients,\n * while in \"2\" mode we only support interop between 2.x clients.\n *\n * @deprecated Specify the minimum Fluid Framework version directly via the\n * `minVersionForCollab` parameter, which accepts a\n * {@link @fluidframework/runtime-definitions#MinimumVersionForCollab} SemVer string. The\n * legacy mode \"1\" is equivalent to `minVersionForCollab: \"1.0.0\"`; mode \"2\" is\n * equivalent to `\"2.0.0\"`.\n *\n * @public\n */\nexport type CompatibilityMode = \"1\" | \"2\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\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 */\nexport type LoadableObjectKindRecord = Record<string, SharedObjectKind>;\n\n/**\n * A kind of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The kind of `DataObject` or `SharedObject`.\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 LoadableObjectKind<T extends IFluidLoadable = IFluidLoadable> =\n\t| ISharedObjectKind<T>\n\t| DataObjectKind<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: Record<string, SharedObjectKind>;\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 SharedObjectKind[];\n}\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 kind of `SharedTree` that will be 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 *\n * @legacy @beta\n */\nexport interface TreeContainerSchema extends ContainerSchema {\n\t// TODO: longer term, it would be better to not have to fit into the `initialObjects` model for tree-based containers.\n\t// But in the short term, fitting into this model makes migration easier.\n\treadonly initialObjects: {\n\t\treadonly tree: SharedObjectKind<ITree>;\n\t};\n}\n\n/**\n * Holds the collection of objects that the container was initially created with.\n * Additionally provides the ability to dynamically create further objects during usage.\n */\nexport interface IRootDataObject {\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>(objectClass: SharedObjectKind<T>): Promise<T>;\n\n\t/**\n\t * Upload a blob of data.\n\t * Although it is marked as internal, there is external usage of this function for experimental purposes.\n\t * Please contact yunho-microsoft or vladsud if you need to change it.\n\t * @param blob - blob to be uploaded.\n\t *\n\t * @remarks This method is used to expose uploadBlob to the IFluidContainer level. UploadBlob will upload data to server side (as of now, ODSP only). There is no downloadBlob provided as it is not needed(blob lifetime managed by server).\n\t */\n\tuploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;\n\n\t/**\n\t * Provides a record of the initial objects defined on creation.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n}\n\ninterface IProvideStaticEntryPoint {\n\treadonly IStaticEntryPoint: IStaticEntryPoint;\n}\n\n/**\n * This is the internal entry point fluid-static creates.\n */\nexport interface IStaticEntryPoint extends IProvideStaticEntryPoint {\n\treadonly rootDataObject: IRootDataObject;\n\treadonly extensionStore: ContainerExtensionStore;\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(): ReadonlyMap<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\treadonly id: string;\n\n\t/**\n\t * Whether the connection is in read or read/write mode.\n\t */\n\treadonly mode: \"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\treadonly id: string;\n\n\t/**\n\t * The set of connections the user has made, e.g. from multiple tabs or devices.\n\t */\n\treadonly connections: IConnection[];\n}\n\n/**\n * An extended member object that includes currentConnection\n * @public\n */\nexport type Myself<M extends IMember = IMember> = M & { readonly currentConnection: string };\n"]}
package/dist/utils.d.ts CHANGED
@@ -5,9 +5,9 @@
5
5
  import type { DataObjectKind } from "@fluidframework/aqueduct/internal";
6
6
  import type { FluidObjectKeys, IFluidLoadable } from "@fluidframework/core-interfaces";
7
7
  import type { IChannelFactory, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
8
- import type { IFluidDataStoreContext, NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions/internal";
8
+ import type { IFluidDataStoreContext, MinimumVersionForCollab, NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions/internal";
9
9
  import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
10
- import type { ContainerSchema, LoadableObjectKind, TreeContainerSchema } from "./types.js";
10
+ import type { CompatibilityMode, ContainerSchema, LoadableObjectKind, TreeContainerSchema } from "./types.js";
11
11
  /**
12
12
  * Runtime check to determine if an object is a {@link DataObjectKind}.
13
13
  */
@@ -40,12 +40,15 @@ export declare function createSharedObject<T extends IFluidLoadable>(sharedObjec
40
40
  */
41
41
  export declare function makeFluidObject<T extends object, K extends FluidObjectKeys<T> = FluidObjectKeys<T>>(object: Omit<T, K>, providerKey: K): T;
42
42
  /**
43
- * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.
43
+ * Resolves the `compatibilityMode` input either a `MinimumVersionForCollab`
44
+ * SemVer string or a legacy `CompatibilityMode` value — into a precise
45
+ * `MinimumVersionForCollab`.
46
+ *
47
+ * TODO: AB#73679: This can be removed when the deprecated CompatibilityMode is removed
48
+ *
49
+ * @internal
44
50
  */
45
- export declare const compatibilityModeToMinVersionForCollab: {
46
- readonly "1": "1.0.0";
47
- readonly "2": "2.0.0";
48
- };
51
+ export declare function resolveCompatibilityModeToMinVersionForCollab(compatibilityMode: MinimumVersionForCollab | CompatibilityMode): MinimumVersionForCollab;
49
52
  /**
50
53
  * Determines if the provided schema is a valid tree-based container schema.
51
54
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEvF,OAAO,KAAK,EACX,eAAe,EACf,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EACX,sBAAsB,EAEtB,gCAAgC,EAChC,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAIrF,OAAO,KAAK,EAEX,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,cAAc,EACxD,GAAG,EAAE,kBAAkB,CAAC,CAAC,CAAC,GACxB,GAAG,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;AAE5B;;GAEG;AACH,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,kBAAkB,GACrB,GAAG,IAAI,cAAc,CAAC,cAAc,CAAC,CAAC;AAyBzC;;GAEG;AACH,wBA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;;;;GAQG;AACH,wBAAgB,6CAA6C,CAE5D,iBAAiB,EAAE,uBAAuB,GAAG,iBAAiB,GAC5D,uBAAuB,CAMzB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,IAAI,mBAAmB,CAqB5F"}
package/dist/utils.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.isTreeContainerSchema = exports.compatibilityModeToMinVersionForCollab = exports.makeFluidObject = exports.createSharedObject = exports.createDataObject = exports.parseDataObjectsFromSharedObjects = exports.isSharedObjectKind = exports.isDataObjectKind = void 0;
7
+ exports.isTreeContainerSchema = exports.resolveCompatibilityModeToMinVersionForCollab = exports.makeFluidObject = exports.createSharedObject = exports.createDataObject = exports.parseDataObjectsFromSharedObjects = exports.isSharedObjectKind = exports.isDataObjectKind = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const internal_2 = require("@fluidframework/telemetry-utils/internal");
10
10
  const internal_3 = require("@fluidframework/tree/internal");
@@ -93,12 +93,24 @@ function makeFluidObject(object, providerKey) {
93
93
  }
94
94
  exports.makeFluidObject = makeFluidObject;
95
95
  /**
96
- * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.
96
+ * Resolves the `compatibilityMode` input either a `MinimumVersionForCollab`
97
+ * SemVer string or a legacy `CompatibilityMode` value — into a precise
98
+ * `MinimumVersionForCollab`.
99
+ *
100
+ * TODO: AB#73679: This can be removed when the deprecated CompatibilityMode is removed
101
+ *
102
+ * @internal
97
103
  */
98
- exports.compatibilityModeToMinVersionForCollab = {
99
- "1": "1.0.0",
100
- "2": "2.0.0",
101
- };
104
+ function resolveCompatibilityModeToMinVersionForCollab(
105
+ // eslint-disable-next-line import-x/no-deprecated
106
+ compatibilityMode) {
107
+ return compatibilityMode === "1"
108
+ ? "1.0.0"
109
+ : compatibilityMode === "2"
110
+ ? "2.0.0"
111
+ : compatibilityMode;
112
+ }
113
+ exports.resolveCompatibilityModeToMinVersionForCollab = resolveCompatibilityModeToMinVersionForCollab;
102
114
  /**
103
115
  * Determines if the provided schema is a valid tree-based container schema.
104
116
  * @internal
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kEAA0D;AAW1D,uEAAsE;AACtE,4DAAsE;AAuBtE;;GAEG;AACH,SAAgB,gBAAgB,CAC/B,GAAuB;IAEvB,MAAM,KAAK,GAAG,GAA0D,CAAC;IACzE,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,CAAC;QACF,8KAA8K;QAC9K,+LAA+L;QAC/L,MAAM,IAAI,qBAAU,CAAC,6BAA6B,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,YAAY,CAAC;AACrB,CAAC;AAlBD,4CAkBC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CACjC,GAAuB;IAEvB,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC;AAJD,gDAIC;AAED;;;;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,GAAuB,EAAQ,EAAE;QACtD,IAAI,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QACrC,CAAC;a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AAC;AACd,CAAC;AArBD,sDAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { DataObjectKind } from \"@fluidframework/aqueduct/internal\";\nimport type { FluidObjectKeys, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIFluidDataStoreContext,\n\tMinimumVersionForCollab,\n\tNamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { SharedTreeFactoryType } from \"@fluidframework/tree/internal\";\n\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tLoadableObjectKind,\n\tTreeContainerSchema,\n} from \"./types.js\";\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind<T extends IFluidLoadable>(\n\tobj: LoadableObjectKind<T>,\n): obj is DataObjectKind<T>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable> {\n\tconst maybe = obj as Partial<DataObjectKind<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: LoadableObjectKind,\n): obj is ISharedObjectKind<IFluidLoadable> {\n\treturn !isDataObjectKind(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: LoadableObjectKind): void => {\n\t\tif (isSharedObjectKind(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectKind(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 as unknown as LoadableObjectKind);\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\n/**\n * Creates a new data object of the specified type.\n */\nexport async function createDataObject<T extends IFluidLoadable>(\n\tdataObjectClass: DataObjectKind<T>,\n\tcontext: IFluidDataStoreContext,\n): Promise<T> {\n\tconst factory = dataObjectClass.factory;\n\tconst packagePath = [...context.packagePath, factory.type];\n\tconst dataStore = await context.containerRuntime.createDataStore(packagePath);\n\tconst entryPoint = await dataStore.entryPoint.get();\n\treturn entryPoint as T;\n}\n\n/**\n * Creates a new shared object of the specified type.\n */\nexport function createSharedObject<T extends IFluidLoadable>(\n\tsharedObjectClass: ISharedObjectKind<T>,\n\truntime: IFluidDataStoreRuntime,\n): T {\n\tconst factory = sharedObjectClass.getFactory();\n\tconst obj = runtime.createChannel(undefined, factory.type);\n\treturn obj as unknown as T;\n}\n\n/**\n * Creates a Fluid object that has a property with the key `providerKey` that points to itself.\n * @remarks This is useful for creating objects that need to reference themselves, such as DataObjects.\n */\nexport function makeFluidObject<\n\tT extends object,\n\tK extends FluidObjectKeys<T> = FluidObjectKeys<T>,\n>(object: Omit<T, K>, providerKey: K): T {\n\treturn Object.defineProperty(object, providerKey, { value: object }) as T;\n}\n\n/**\n * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.\n */\nexport const compatibilityModeToMinVersionForCollab = {\n\t\"1\": \"1.0.0\",\n\t\"2\": \"2.0.0\",\n} as const satisfies Record<CompatibilityMode, MinimumVersionForCollab>;\n\n/**\n * Determines if the provided schema is a valid tree-based container schema.\n * @internal\n */\nexport function isTreeContainerSchema(schema: ContainerSchema): schema is TreeContainerSchema {\n\tconst schemaEntries = Object.entries(schema.initialObjects);\n\tif (schemaEntries.length !== 1) {\n\t\treturn false;\n\t}\n\n\tconst entry = schemaEntries[0] ?? oob();\n\tconst key = entry[0];\n\tif (key !== \"tree\") {\n\t\treturn false;\n\t}\n\n\tconst objectKind = entry[1] as unknown as LoadableObjectKind;\n\tif (\n\t\tisSharedObjectKind(objectKind) &&\n\t\tobjectKind.getFactory().type === SharedTreeFactoryType\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;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IAC3D,OAAO,GAAmB,CAAC;AAC5B,CAAC;AAPD,gDAOC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAG7B,MAAkB,EAAE,WAAc;IACnC,OAAO,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAM,CAAC;AAC3E,CAAC;AALD,0CAKC;AAED;;;;;;;;GAQG;AACH,SAAgB,6CAA6C;AAC5D,kDAAkD;AAClD,iBAA8D;IAE9D,OAAO,iBAAiB,KAAK,GAAG;QAC/B,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,iBAAiB,KAAK,GAAG;YAC1B,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,iBAAiB,CAAC;AACvB,CAAC;AATD,sGASC;AAED;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,MAAuB;IAC5D,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAC5D,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,IAAA,cAAG,GAAE,CAAC;IACxC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACrB,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAkC,CAAC;IAC7D,IACC,kBAAkB,CAAC,UAAU,CAAC;QAC9B,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI,KAAK,gCAAqB,EACrD,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AArBD,sDAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { DataObjectKind } from \"@fluidframework/aqueduct/internal\";\nimport type { FluidObjectKeys, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIFluidDataStoreContext,\n\tMinimumVersionForCollab,\n\tNamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { SharedTreeFactoryType } from \"@fluidframework/tree/internal\";\n\nimport type {\n\t// eslint-disable-next-line import-x/no-deprecated\n\tCompatibilityMode,\n\tContainerSchema,\n\tLoadableObjectKind,\n\tTreeContainerSchema,\n} from \"./types.js\";\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind<T extends IFluidLoadable>(\n\tobj: LoadableObjectKind<T>,\n): obj is DataObjectKind<T>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable> {\n\tconst maybe = obj as Partial<DataObjectKind<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: LoadableObjectKind,\n): obj is ISharedObjectKind<IFluidLoadable> {\n\treturn !isDataObjectKind(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: LoadableObjectKind): void => {\n\t\tif (isSharedObjectKind(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectKind(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 as unknown as LoadableObjectKind);\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\n/**\n * Creates a new data object of the specified type.\n */\nexport async function createDataObject<T extends IFluidLoadable>(\n\tdataObjectClass: DataObjectKind<T>,\n\tcontext: IFluidDataStoreContext,\n): Promise<T> {\n\tconst factory = dataObjectClass.factory;\n\tconst packagePath = [...context.packagePath, factory.type];\n\tconst dataStore = await context.containerRuntime.createDataStore(packagePath);\n\tconst entryPoint = await dataStore.entryPoint.get();\n\treturn entryPoint as T;\n}\n\n/**\n * Creates a new shared object of the specified type.\n */\nexport function createSharedObject<T extends IFluidLoadable>(\n\tsharedObjectClass: ISharedObjectKind<T>,\n\truntime: IFluidDataStoreRuntime,\n): T {\n\tconst factory = sharedObjectClass.getFactory();\n\tconst obj = runtime.createChannel(undefined, factory.type);\n\treturn obj as unknown as T;\n}\n\n/**\n * Creates a Fluid object that has a property with the key `providerKey` that points to itself.\n * @remarks This is useful for creating objects that need to reference themselves, such as DataObjects.\n */\nexport function makeFluidObject<\n\tT extends object,\n\tK extends FluidObjectKeys<T> = FluidObjectKeys<T>,\n>(object: Omit<T, K>, providerKey: K): T {\n\treturn Object.defineProperty(object, providerKey, { value: object }) as T;\n}\n\n/**\n * Resolves the `compatibilityMode` input — either a `MinimumVersionForCollab`\n * SemVer string or a legacy `CompatibilityMode` value — into a precise\n * `MinimumVersionForCollab`.\n *\n * TODO: AB#73679: This can be removed when the deprecated CompatibilityMode is removed\n *\n * @internal\n */\nexport function resolveCompatibilityModeToMinVersionForCollab(\n\t// eslint-disable-next-line import-x/no-deprecated\n\tcompatibilityMode: MinimumVersionForCollab | CompatibilityMode,\n): MinimumVersionForCollab {\n\treturn compatibilityMode === \"1\"\n\t\t? \"1.0.0\"\n\t\t: compatibilityMode === \"2\"\n\t\t\t? \"2.0.0\"\n\t\t\t: compatibilityMode;\n}\n\n/**\n * Determines if the provided schema is a valid tree-based container schema.\n * @internal\n */\nexport function isTreeContainerSchema(schema: ContainerSchema): schema is TreeContainerSchema {\n\tconst schemaEntries = Object.entries(schema.initialObjects);\n\tif (schemaEntries.length !== 1) {\n\t\treturn false;\n\t}\n\n\tconst entry = schemaEntries[0] ?? oob();\n\tconst key = entry[0];\n\tif (key !== \"tree\") {\n\t\treturn false;\n\t}\n\n\tconst objectKind = entry[1] as unknown as LoadableObjectKind;\n\tif (\n\t\tisSharedObjectKind(objectKind) &&\n\t\tobjectKind.getFactory().type === SharedTreeFactoryType\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n"]}
@@ -3,14 +3,15 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { IContainerRuntimeOptionsInternal } from "@fluidframework/container-runtime/internal";
6
- import type { CompatibilityMode } from "./types.js";
6
+ import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
7
7
  /**
8
- * The CompatibilityMode selected determines the set of runtime options to use. In "1" mode we support
9
- * full interop with true 1.x clients, while in "2" mode we only support interop with 2.x clients.
8
+ * Returns the fluid-static-specific runtime option overrides for the given `minVersionForCollab`.
10
9
  *
11
- * @privateRemarks In general, we can use the `compatibilityMode` property of `LoadContainerRuntimeParams` to apply
12
- * the proper configurations. However, there are some options that we need to explicity set that differ
13
- * from the default values (i.e. `enableRuntimeIdCompressor` below).
10
+ * @remarks
11
+ * The bulk of runtime defaults for a given `minVersionForCollab` are selected by container-runtime
12
+ * (via `getMinVersionForCollabDefaults`). This function only contributes the additional overrides
13
+ * that fluid-static needs to layer on top of those defaults.
14
+ * @internal
14
15
  */
15
- export declare const compatibilityModeRuntimeOptions: Record<CompatibilityMode, IContainerRuntimeOptionsInternal>;
16
+ export declare function defaultRuntimeOptionsForMinVersion(minVersionForCollab: MinimumVersionForCollab): IContainerRuntimeOptionsInternal;
16
17
  //# sourceMappingURL=compatibilityConfiguration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compatibilityConfiguration.d.ts","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,4CAA4C,CAAC;AAEnG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CACnD,iBAAiB,EACjB,gCAAgC,CAShC,CAAC"}
1
+ {"version":3,"file":"compatibilityConfiguration.d.ts","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,4CAA4C,CAAC;AACnG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAyB5F;;;;;;;;GAQG;AACH,wBAAgB,kCAAkC,CACjD,mBAAmB,EAAE,uBAAuB,GAC1C,gCAAgC,CAIlC"}
@@ -2,15 +2,17 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { gte } from "semver-ts";
5
6
  /**
6
- * The CompatibilityMode selected determines the set of runtime options to use. In "1" mode we support
7
- * full interop with true 1.x clients, while in "2" mode we only support interop with 2.x clients.
7
+ * Fluid-static-specific runtime option overrides keyed by `minVersionForCollab`.
8
8
  *
9
- * @privateRemarks In general, we can use the `compatibilityMode` property of `LoadContainerRuntimeParams` to apply
10
- * the proper configurations. However, there are some options that we need to explicity set that differ
11
- * from the default values (i.e. `enableRuntimeIdCompressor` below).
9
+ * @remarks
10
+ * These are layered on top of the runtime defaults that container-runtime selects from
11
+ * `minVersionForCollab` (via `getMinVersionForCollabDefaults`). Only options that
12
+ * fluid-static needs to set differently from those defaults belong here
13
+ * (e.g. enableRuntimeIdCompressor to support SharedTree).
12
14
  */
13
- export const compatibilityModeRuntimeOptions = {
15
+ const minVersionForCollabToDefaultRuntimeOptions = {
14
16
  "1": {},
15
17
  "2": {
16
18
  // The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.
@@ -19,4 +21,16 @@ export const compatibilityModeRuntimeOptions = {
19
21
  enableRuntimeIdCompressor: "on",
20
22
  },
21
23
  };
24
+ /**
25
+ * Returns the fluid-static-specific runtime option overrides for the given `minVersionForCollab`.
26
+ *
27
+ * @remarks
28
+ * The bulk of runtime defaults for a given `minVersionForCollab` are selected by container-runtime
29
+ * (via `getMinVersionForCollabDefaults`). This function only contributes the additional overrides
30
+ * that fluid-static needs to layer on top of those defaults.
31
+ * @internal
32
+ */
33
+ export function defaultRuntimeOptionsForMinVersion(minVersionForCollab) {
34
+ return minVersionForCollabToDefaultRuntimeOptions[gte(minVersionForCollab, "2.0.0") ? "2" : "1"];
35
+ }
22
36
  //# sourceMappingURL=compatibilityConfiguration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAGxC;IACH,GAAG,EAAE,EAAE;IACP,GAAG,EAAE;QACJ,sHAAsH;QACtH,oHAAoH;QACpH,gGAAgG;QAChG,yBAAyB,EAAE,IAAI;KAC/B;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IContainerRuntimeOptionsInternal } from \"@fluidframework/container-runtime/internal\";\n\nimport type { CompatibilityMode } from \"./types.js\";\n\n/**\n * The CompatibilityMode selected determines the set of runtime options to use. In \"1\" mode we support\n * full interop with true 1.x clients, while in \"2\" mode we only support interop with 2.x clients.\n *\n * @privateRemarks In general, we can use the `compatibilityMode` property of `LoadContainerRuntimeParams` to apply\n * the proper configurations. However, there are some options that we need to explicity set that differ\n * from the default values (i.e. `enableRuntimeIdCompressor` below).\n */\nexport const compatibilityModeRuntimeOptions: Record<\n\tCompatibilityMode,\n\tIContainerRuntimeOptionsInternal\n> = {\n\t\"1\": {},\n\t\"2\": {\n\t\t// The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.\n\t\t// In general, we don't want to enable this by default since it increases the bundle size. However, since SharedTree\n\t\t// is bundled with the fluid-framework package, we need to enable it here to support SharedTree.\n\t\tenableRuntimeIdCompressor: \"on\",\n\t},\n};\n"]}
1
+ {"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC;;;;;;;;GAQG;AACH,MAAM,0CAA0C,GAG5C;IACH,GAAG,EAAE,EAAE;IACP,GAAG,EAAE;QACJ,sHAAsH;QACtH,oHAAoH;QACpH,gGAAgG;QAChG,yBAAyB,EAAE,IAAI;KAC/B;CACD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,kCAAkC,CACjD,mBAA4C;IAE5C,OAAO,0CAA0C,CAChD,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAC7C,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IContainerRuntimeOptionsInternal } from \"@fluidframework/container-runtime/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport { gte } from \"semver-ts\";\n\n/**\n * Fluid-static-specific runtime option overrides keyed by `minVersionForCollab`.\n *\n * @remarks\n * These are layered on top of the runtime defaults that container-runtime selects from\n * `minVersionForCollab` (via `getMinVersionForCollabDefaults`). Only options that\n * fluid-static needs to set differently from those defaults belong here\n * (e.g. enableRuntimeIdCompressor to support SharedTree).\n */\nconst minVersionForCollabToDefaultRuntimeOptions: Record<\n\t\"1\" | \"2\",\n\tIContainerRuntimeOptionsInternal\n> = {\n\t\"1\": {},\n\t\"2\": {\n\t\t// The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.\n\t\t// In general, we don't want to enable this by default since it increases the bundle size. However, since SharedTree\n\t\t// is bundled with the fluid-framework package, we need to enable it here to support SharedTree.\n\t\tenableRuntimeIdCompressor: \"on\",\n\t},\n};\n\n/**\n * Returns the fluid-static-specific runtime option overrides for the given `minVersionForCollab`.\n *\n * @remarks\n * The bulk of runtime defaults for a given `minVersionForCollab` are selected by container-runtime\n * (via `getMinVersionForCollabDefaults`). This function only contributes the additional overrides\n * that fluid-static needs to layer on top of those defaults.\n * @internal\n */\nexport function defaultRuntimeOptionsForMinVersion(\n\tminVersionForCollab: MinimumVersionForCollab,\n): IContainerRuntimeOptionsInternal {\n\treturn minVersionForCollabToDefaultRuntimeOptions[\n\t\tgte(minVersionForCollab, \"2.0.0\") ? \"2\" : \"1\"\n\t];\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -13,5 +13,5 @@ export { createDOProviderContainerRuntimeFactory } from "./rootDataObject.js";
13
13
  export { createServiceAudience } from "./serviceAudience.js";
14
14
  export { createTreeContainerRuntimeFactory } from "./treeRootDataObject.js";
15
15
  export type { CompatibilityMode, ContainerSchema, ContainerAttachProps, IConnection, IMember, IServiceAudience, IServiceAudienceEvents, MemberChangedListener, Myself, TreeContainerSchema, } from "./types.js";
16
- export { isTreeContainerSchema } from "./utils.js";
16
+ export { isTreeContainerSchema, resolveCompatibilityModeToMinVersionForCollab, } from "./utils.js";
17
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAC5E,YAAY,EACX,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,MAAM,EACN,mBAAmB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAC5E,YAAY,EACX,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,MAAM,EACN,mBAAmB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,qBAAqB,EACrB,6CAA6C,GAC7C,MAAM,YAAY,CAAC"}
package/lib/index.js CHANGED
@@ -12,5 +12,5 @@ export { getPresence, getPresenceAlpha } from "./getPresence.js";
12
12
  export { createDOProviderContainerRuntimeFactory } from "./rootDataObject.js";
13
13
  export { createServiceAudience } from "./serviceAudience.js";
14
14
  export { createTreeContainerRuntimeFactory } from "./treeRootDataObject.js";
15
- export { isTreeContainerSchema } from "./utils.js";
15
+ export { isTreeContainerSchema, resolveCompatibilityModeToMinVersionForCollab, } from "./utils.js";
16
16
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,GAKxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAa5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Provides a simple and powerful way to consume collaborative Fluid data.\n *\n * @packageDocumentation\n */\n\nexport {\n\tcreateFluidContainer,\n\tisInternalFluidContainer,\n\ttype IFluidContainer,\n\ttype IFluidContainerEvents,\n\ttype IFluidContainerInternal,\n\ttype InitialObjects,\n} from \"./fluidContainer.js\";\nexport { getPresence, getPresenceAlpha } from \"./getPresence.js\";\nexport { createDOProviderContainerRuntimeFactory } from \"./rootDataObject.js\";\nexport { createServiceAudience } from \"./serviceAudience.js\";\nexport { createTreeContainerRuntimeFactory } from \"./treeRootDataObject.js\";\nexport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tContainerAttachProps,\n\tIConnection,\n\tIMember,\n\tIServiceAudience,\n\tIServiceAudienceEvents,\n\tMemberChangedListener,\n\tMyself,\n\tTreeContainerSchema,\n} from \"./types.js\";\nexport { isTreeContainerSchema } from \"./utils.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,GAKxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAa5E,OAAO,EACN,qBAAqB,EACrB,6CAA6C,GAC7C,MAAM,YAAY,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Provides a simple and powerful way to consume collaborative Fluid data.\n *\n * @packageDocumentation\n */\n\nexport {\n\tcreateFluidContainer,\n\tisInternalFluidContainer,\n\ttype IFluidContainer,\n\ttype IFluidContainerEvents,\n\ttype IFluidContainerInternal,\n\ttype InitialObjects,\n} from \"./fluidContainer.js\";\nexport { getPresence, getPresenceAlpha } from \"./getPresence.js\";\nexport { createDOProviderContainerRuntimeFactory } from \"./rootDataObject.js\";\nexport { createServiceAudience } from \"./serviceAudience.js\";\nexport { createTreeContainerRuntimeFactory } from \"./treeRootDataObject.js\";\nexport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tContainerAttachProps,\n\tIConnection,\n\tIMember,\n\tIServiceAudience,\n\tIServiceAudienceEvents,\n\tMemberChangedListener,\n\tMyself,\n\tTreeContainerSchema,\n} from \"./types.js\";\nexport {\n\tisTreeContainerSchema,\n\tresolveCompatibilityModeToMinVersionForCollab,\n} from \"./utils.js\";\n"]}
@@ -5,7 +5,7 @@
5
5
  import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
6
6
  import { type IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
7
7
  import type { IFluidDataStoreRegistry, MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
8
- import type { CompatibilityMode, ContainerSchema } from "./types.js";
8
+ import type { ContainerSchema } from "./types.js";
9
9
  /**
10
10
  * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
11
11
  * with an entry point containing single directory-based root data object.
@@ -23,9 +23,10 @@ export declare function createDOProviderContainerRuntimeFactory(props: {
23
23
  */
24
24
  schema: ContainerSchema;
25
25
  /**
26
- * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.
26
+ * Minimum Fluid Framework version required for collaboration as a
27
+ * {@link @fluidframework/runtime-definitions#MinimumVersionForCollab} SemVer string.
27
28
  */
28
- compatibilityMode: CompatibilityMode;
29
+ minVersionForCollaboration: MinimumVersionForCollab;
29
30
  /**
30
31
  * Optional registry of data stores to pass to the DataObject factory.
31
32
  * If not provided, one will be created based on the schema.
@@ -33,15 +34,8 @@ export declare function createDOProviderContainerRuntimeFactory(props: {
33
34
  rootDataStoreRegistry?: IFluidDataStoreRegistry;
34
35
  /**
35
36
  * Optional overrides for the container runtime options.
36
- * If not provided, only the default options for the given compatibilityMode will be used.
37
+ * If not provided, only the default options for the given minVersionForCollaboration will be used.
37
38
  */
38
39
  runtimeOptionOverrides?: Partial<IContainerRuntimeOptions>;
39
- /**
40
- * Optional override for minimum version for collab.
41
- * If not provided, the default for the given compatibilityMode will be used.
42
- * @remarks
43
- * This is useful when runtime options are overridden and change the minimum version for collab.
44
- */
45
- minVersionForCollabOverride?: MinimumVersionForCollab;
46
40
  }): IRuntimeFactory;
47
41
  //# sourceMappingURL=rootDataObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAEN,KAAK,wBAAwB,EAC7B,MAAM,4CAA4C,CAAC;AAapD,OAAO,KAAK,EACX,uBAAuB,EACvB,uBAAuB,EACvB,MAAM,8CAA8C,CAAC;AAItD,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EAMf,MAAM,YAAY,CAAC;AA2IpB;;;;;;;;;;GAUG;AACH,wBAAgB,uCAAuC,CAAC,KAAK,EAAE;IAC9D;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IACxB;;OAEG;IACH,iBAAiB,EAAE,iBAAiB,CAAC;IACrC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,uBAAuB,CAAC;IAChD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC3D;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,uBAAuB,CAAC;CACtD,GAAG,eAAe,CAoBlB"}
1
+ {"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAEN,KAAK,wBAAwB,EAC7B,MAAM,4CAA4C,CAAC;AAapD,OAAO,KAAK,EACX,uBAAuB,EACvB,uBAAuB,EACvB,MAAM,8CAA8C,CAAC;AAItD,OAAO,KAAK,EACX,eAAe,EAMf,MAAM,YAAY,CAAC;AA0IpB;;;;;;;;;;GAUG;AACH,wBAAgB,uCAAuC,CAAC,KAAK,EAAE;IAC9D;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IACxB;;;OAGG;IACH,0BAA0B,EAAE,uBAAuB,CAAC;IACpD;;;OAGG;IACH,qBAAqB,CAAC,EAAE,uBAAuB,CAAC;IAChD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;CAC3D,GAAG,eAAe,CAclB"}
@@ -5,8 +5,8 @@
5
5
  import { BaseContainerRuntimeFactory, DataObject, DataObjectFactory, } from "@fluidframework/aqueduct/internal";
6
6
  import { FluidDataStoreRegistry, } from "@fluidframework/container-runtime/internal";
7
7
  import { assert } from "@fluidframework/core-utils/internal";
8
- import { compatibilityModeRuntimeOptions } from "./compatibilityConfiguration.js";
9
- import { compatibilityModeToMinVersionForCollab, createDataObject, createSharedObject, isDataObjectKind, isSharedObjectKind, makeFluidObject, parseDataObjectsFromSharedObjects, } from "./utils.js";
8
+ import { defaultRuntimeOptionsForMinVersion } from "./compatibilityConfiguration.js";
9
+ import { createDataObject, createSharedObject, isDataObjectKind, isSharedObjectKind, makeFluidObject, parseDataObjectsFromSharedObjects, } from "./utils.js";
10
10
  /**
11
11
  * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
12
12
  * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
@@ -112,12 +112,13 @@ async function provideEntryPoint(containerRuntime) {
112
112
  * @internal
113
113
  */
114
114
  export function createDOProviderContainerRuntimeFactory(props) {
115
- const { compatibilityMode, minVersionForCollabOverride, rootDataStoreRegistry, runtimeOptionOverrides, schema, } = props;
115
+ const { rootDataStoreRegistry, runtimeOptionOverrides, schema } = props;
116
+ const minVersionForCollab = props.minVersionForCollaboration;
116
117
  const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);
117
118
  const registry = rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);
118
- return new DOProviderContainerRuntimeFactory(schema, compatibilityMode, new RootDataObjectFactory(sharedObjects, registry), {
119
+ return new DOProviderContainerRuntimeFactory(schema, new RootDataObjectFactory(sharedObjects, registry), {
119
120
  runtimeOptions: runtimeOptionOverrides,
120
- minVersionForCollab: minVersionForCollabOverride,
121
+ minVersionForCollab,
121
122
  });
122
123
  }
123
124
  /**
@@ -136,19 +137,18 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
136
137
  * since it can take care of constructing the root data object factory based on the schema.
137
138
  *
138
139
  * @param schema - The schema for the container
139
- * @param compatibilityMode - Compatibility mode
140
140
  * @param rootDataObjectFactory - A factory that can construct the root data object.
141
+ * @param config - Resolved minimum version for collaboration (required) and optional runtime option overrides.
141
142
  */
142
- constructor(schema, compatibilityMode, rootDataObjectFactory, overrides) {
143
+ constructor(schema, rootDataObjectFactory, config) {
143
144
  super({
144
145
  registryEntries: [rootDataObjectFactory.registryEntry],
145
146
  runtimeOptions: {
146
- ...compatibilityModeRuntimeOptions[compatibilityMode],
147
- ...overrides?.runtimeOptions,
147
+ ...defaultRuntimeOptionsForMinVersion(config.minVersionForCollab),
148
+ ...config.runtimeOptions,
148
149
  },
149
150
  provideEntryPoint,
150
- minVersionForCollab: overrides?.minVersionForCollab ??
151
- compatibilityModeToMinVersionForCollab[compatibilityMode],
151
+ minVersionForCollab: config.minVersionForCollab,
152
152
  });
153
153
  this.rootDataObjectFactory = rootDataObjectFactory;
154
154
  this.initialObjects = schema.initialObjects;
@@ -1 +1 @@
1
- {"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,2BAA2B,EAC3B,UAAU,EACV,iBAAiB,GACjB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACN,sBAAsB,GAEtB,MAAM,4CAA4C,CAAC;AAUpD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAS7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AAUlF,OAAO,EACN,sCAAsC,EACtC,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,iCAAiC,GACjC,MAAM,YAAY,CAAC;AAkBpB;;;GAGG;AACH,MAAM,cACL,SAAQ,UAAiD;IAD1D;;QAIkB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IA+E7D,CAAC;IA7EA,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAY,iBAAiB;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,kDA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AC,OAA0B;QACxE,sEAAsE;QACtE,MAAM,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,eAAe,EAAE,OAAO,EAAE;YAC7E,cAAc,EAAE,IAAI,CAAC,cAAc;SACnC,CAAC,CAAC;IACJ,CAAC;CACD;AAED;;GAEG;AACH,MAAM,qBAAsB,SAAQ,iBAGnC;IACA,YACC,gBAA4C,EAAE,EAC7B,iBAA0C;QAE3D,2GAA2G;QAC3G,+GAA+G;QAC/G,KAAK,CAAC;YACL,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,cAAc;YACpB,aAAa;SACb,CAAC,CAAC;QARc,sBAAiB,GAAjB,iBAAiB,CAAyB;IAS5D,CAAC;IAED,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAC/B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tBaseContainerRuntimeFactory,\n\tDataObject,\n\tDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tFluidDataStoreRegistry,\n\ttype IContainerRuntimeOptions,\n} from \"@fluidframework/container-runtime/internal\";\nimport type {\n\tIContainerRuntime,\n\tIContainerRuntimeInternal,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tFluidObject,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IDirectory } from \"@fluidframework/map/internal\";\nimport type {\n\tIFluidDataStoreRegistry,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport { compatibilityModeRuntimeOptions } from \"./compatibilityConfiguration.js\";\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tIRootDataObject,\n\tIStaticEntryPoint,\n\tLoadableObjectKind,\n\tLoadableObjectKindRecord,\n\tLoadableObjectRecord,\n} from \"./types.js\";\nimport {\n\tcompatibilityModeToMinVersionForCollab,\n\tcreateDataObject,\n\tcreateSharedObject,\n\tisDataObjectKind,\n\tisSharedObjectKind,\n\tmakeFluidObject,\n\tparseDataObjectsFromSharedObjects,\n} from \"./utils.js\";\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}.\n */\ninterface RootDataObjectProps {\n\t/**\n\t * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n\t *\n\t * @see {@link RootDataObject.initializingFirstTime}\n\t */\n\treadonly initialObjects: LoadableObjectKindRecord;\n}\n\ninterface IProvideRootDataObject {\n\treadonly RootDataObject: RootDataObject;\n}\n\n/**\n * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.\n * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.\n */\nclass RootDataObject\n\textends DataObject<{ InitialState: RootDataObjectProps }>\n\timplements IRootDataObject, IProvideRootDataObject\n{\n\tprivate readonly initialObjectsDirKey = \"initial-objects-key\";\n\tprivate readonly _initialObjects: LoadableObjectRecord = {};\n\n\tpublic get RootDataObject(): RootDataObject {\n\t\treturn this;\n\t}\n\n\tprivate get initialObjectsDir(): IDirectory {\n\t\tconst dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n\t\tif (dir === undefined) {\n\t\t\tthrow new Error(\"InitialObjects sub-directory was not initialized\");\n\t\t}\n\t\treturn dir;\n\t}\n\n\t/**\n\t * The first time this object is initialized, creates each object identified in\n\t * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n\t */\n\tprotected async initializingFirstTime(props: RootDataObjectProps): Promise<void> {\n\t\tthis.root.createSubDirectory(this.initialObjectsDirKey);\n\n\t\t// Create initial objects provided by the developer\n\t\tconst initialObjectsP: Promise<void>[] = [];\n\t\tfor (const [id, objectClass] of Object.entries(props.initialObjects)) {\n\t\t\tconst createObject = async (): Promise<void> => {\n\t\t\t\tconst obj = await this.create<IFluidLoadable>(\n\t\t\t\t\tobjectClass as SharedObjectKind<IFluidLoadable>,\n\t\t\t\t);\n\t\t\t\tthis.initialObjectsDir.set(id, obj.handle);\n\t\t\t};\n\t\t\tinitialObjectsP.push(createObject());\n\t\t}\n\n\t\tawait Promise.all(initialObjectsP);\n\t}\n\n\t/**\n\t * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n\t * accessed immediately.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n\t */\n\tprotected async hasInitialized(): Promise<void> {\n\t\t// We will always load the initial objects so they are available to the developer\n\t\tconst loadInitialObjectsP: Promise<void>[] = [];\n\t\tfor (const [key, value] of this.initialObjectsDir.entries()) {\n\t\t\tconst loadDir = async (): Promise<void> => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\tconst obj: unknown = await value.get();\n\t\t\t\tObject.assign(this._initialObjects, { [key]: obj });\n\t\t\t};\n\t\t\tloadInitialObjectsP.push(loadDir());\n\t\t}\n\n\t\tawait Promise.all(loadInitialObjectsP);\n\t}\n\n\tpublic get initialObjects(): LoadableObjectRecord {\n\t\tif (Object.keys(this._initialObjects).length === 0) {\n\t\t\tthrow new Error(\"Initial Objects were not correctly initialized\");\n\t\t}\n\t\treturn this._initialObjects;\n\t}\n\n\tpublic async create<T>(objectClass: SharedObjectKind<T>): Promise<T> {\n\t\tconst internal = objectClass as unknown as LoadableObjectKind<T & IFluidLoadable>;\n\t\tif (isDataObjectKind(internal)) {\n\t\t\treturn createDataObject(internal, this.context);\n\t\t} else if (isSharedObjectKind(internal)) {\n\t\t\treturn createSharedObject(internal, this.runtime);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tpublic async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {\n\t\treturn this.runtime.uploadBlob(blob);\n\t}\n}\n\nconst rootDataStoreId = \"rootDOId\";\nconst rootDataObjectType = \"rootDO\";\n\nasync function provideEntryPoint(\n\tcontainerRuntime: IContainerRuntime,\n): Promise<IStaticEntryPoint> {\n\tconst entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\tif (entryPoint === undefined) {\n\t\tthrow new Error(`default dataStore [${rootDataStoreId}] must exist`);\n\t}\n\tconst rootDataObject = ((await entryPoint.get()) as FluidObject<RootDataObject>)\n\t\t.RootDataObject;\n\tassert(rootDataObject !== undefined, 0xb9f /* entryPoint must be of type RootDataObject */);\n\treturn makeFluidObject<IStaticEntryPoint>(\n\t\t{\n\t\t\trootDataObject,\n\t\t\textensionStore: containerRuntime as IContainerRuntimeInternal,\n\t\t},\n\t\t\"IStaticEntryPoint\",\n\t);\n}\n\n/**\n * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers\n * with an entry point containing single directory-based root data object.\n *\n * @remarks\n * The entry point is opaque to caller.\n * The root data object's registry and initial objects are configured based on the provided\n * schema (and optionally, data store registry).\n *\n * @internal\n */\nexport function createDOProviderContainerRuntimeFactory(props: {\n\t/**\n\t * The schema for the container.\n\t */\n\tschema: ContainerSchema;\n\t/**\n\t * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.\n\t */\n\tcompatibilityMode: CompatibilityMode;\n\t/**\n\t * Optional registry of data stores to pass to the DataObject factory.\n\t * If not provided, one will be created based on the schema.\n\t */\n\trootDataStoreRegistry?: IFluidDataStoreRegistry;\n\t/**\n\t * Optional overrides for the container runtime options.\n\t * If not provided, only the default options for the given compatibilityMode will be used.\n\t */\n\truntimeOptionOverrides?: Partial<IContainerRuntimeOptions>;\n\t/**\n\t * Optional override for minimum version for collab.\n\t * If not provided, the default for the given compatibilityMode will be used.\n\t * @remarks\n\t * This is useful when runtime options are overridden and change the minimum version for collab.\n\t */\n\tminVersionForCollabOverride?: MinimumVersionForCollab;\n}): IRuntimeFactory {\n\tconst {\n\t\tcompatibilityMode,\n\t\tminVersionForCollabOverride,\n\t\trootDataStoreRegistry,\n\t\truntimeOptionOverrides,\n\t\tschema,\n\t} = props;\n\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n\tconst registry = rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);\n\n\treturn new DOProviderContainerRuntimeFactory(\n\t\tschema,\n\t\tcompatibilityMode,\n\t\tnew RootDataObjectFactory(sharedObjects, registry),\n\t\t{\n\t\t\truntimeOptions: runtimeOptionOverrides,\n\t\t\tminVersionForCollab: minVersionForCollabOverride,\n\t\t},\n\t);\n}\n\n/**\n * Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}\n * (containing single {@link IRootDataObject}) as their entry point.\n */\nclass DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n\tprivate readonly rootDataObjectFactory: DataObjectFactory<\n\t\tRootDataObject,\n\t\t{\n\t\t\tInitialState: RootDataObjectProps;\n\t\t}\n\t>;\n\n\tprivate readonly initialObjects: LoadableObjectKindRecord;\n\n\t/**\n\t * Create a new instance of a container runtime factory.\n\t * @remarks\n\t * The caller is responsible for making sure that the provided root data object factory is configured\n\t * appropriately based on the schema of the container (e.g. its registry entries contain all the\n\t * DataStore/DDS types that the schema says can be constructed).\n\t *\n\t * Most scenarios probably want to use {@link createDOProviderContainerRuntimeFactory} instead,\n\t * since it can take care of constructing the root data object factory based on the schema.\n\t *\n\t * @param schema - The schema for the container\n\t * @param compatibilityMode - Compatibility mode\n\t * @param rootDataObjectFactory - A factory that can construct the root data object.\n\t */\n\tpublic constructor(\n\t\tschema: ContainerSchema,\n\t\tcompatibilityMode: CompatibilityMode,\n\t\trootDataObjectFactory: DataObjectFactory<\n\t\t\tRootDataObject,\n\t\t\t{ InitialState: RootDataObjectProps }\n\t\t>,\n\t\toverrides?: Partial<{\n\t\t\truntimeOptions: Partial<IContainerRuntimeOptions>;\n\t\t\tminVersionForCollab: MinimumVersionForCollab;\n\t\t}>,\n\t) {\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\truntimeOptions: {\n\t\t\t\t...compatibilityModeRuntimeOptions[compatibilityMode],\n\t\t\t\t...overrides?.runtimeOptions,\n\t\t\t},\n\t\t\tprovideEntryPoint,\n\t\t\tminVersionForCollab:\n\t\t\t\toverrides?.minVersionForCollab ??\n\t\t\t\tcompatibilityModeToMinVersionForCollab[compatibilityMode],\n\t\t});\n\t\tthis.rootDataObjectFactory = rootDataObjectFactory;\n\t\tthis.initialObjects = schema.initialObjects;\n\t}\n\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\t// The first time we create the container we create the RootDataObject\n\t\tawait this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {\n\t\t\tinitialObjects: this.initialObjects,\n\t\t});\n\t}\n}\n\n/**\n * Factory that creates instances of a root data object.\n */\nclass RootDataObjectFactory extends DataObjectFactory<\n\tRootDataObject,\n\t{ InitialState: RootDataObjectProps }\n> {\n\tpublic constructor(\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\tprivate readonly dataStoreRegistry: IFluidDataStoreRegistry,\n\t) {\n\t\t// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,\n\t\t// and instead we override the necessary methods in this class to use the registry received in the constructor.\n\t\tsuper({\n\t\t\ttype: rootDataObjectType,\n\t\t\tctor: RootDataObject,\n\t\t\tsharedObjects,\n\t\t});\n\t}\n\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.dataStoreRegistry;\n\t}\n}\n"]}
1
+ {"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,2BAA2B,EAC3B,UAAU,EACV,iB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CAAiC,CAC3C,MAAM,EACN,IAAI,qBAAqB,CAAC,aAAa,EAAE,QAAQ,CAAC,EAClD;QACC,cAAc,EAAE,sBAAsB;QACtC,mBAAmB;KACnB,CACD,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,iCAAkC,SAAQ,2BAA2B;IAU1E;;;;;;;;;;;;;OAaG;IACH,YACC,MAAuB,EACvB,qBAGC,EACD,MAGC;QAED,KAAK,CAAC;YACL,eAAe,EAAE,CAAC,qBAAqB,CAAC,aAAa,CAAC;YACtD,cAAc,EAAE;gBACf,GAAG,kCAAkC,CAAC,MAAM,CAAC,mBAAmB,CAAC;gBACjE,GAAG,MAAM,CAAC,cAAc;aACxB;YACD,iBAAiB;YACjB,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;SAC/C,CAAC,CAAC;QACH,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAC7C,CAAC;IAES,KAAK,CAAC,8BAA8B,CAAC,OAA0B;QACxE,sEAAsE;QACtE,MAAM,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,eAAe,EAAE,OAAO,EAAE;YAC7E,cAAc,EAAE,IAAI,CAAC,cAAc;SACnC,CAAC,CAAC;IACJ,CAAC;CACD;AAED;;GAEG;AACH,MAAM,qBAAsB,SAAQ,iBAGnC;IACA,YACC,gBAA4C,EAAE,EAC7B,iBAA0C;QAE3D,2GAA2G;QAC3G,+GAA+G;QAC/G,KAAK,CAAC;YACL,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,cAAc;YACpB,aAAa;SACb,CAAC,CAAC;QARc,sBAAiB,GAAjB,iBAAiB,CAAyB;IAS5D,CAAC;IAED,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAC/B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tBaseContainerRuntimeFactory,\n\tDataObject,\n\tDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tFluidDataStoreRegistry,\n\ttype IContainerRuntimeOptions,\n} from \"@fluidframework/container-runtime/internal\";\nimport type {\n\tIContainerRuntime,\n\tIContainerRuntimeInternal,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tFluidObject,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IDirectory } from \"@fluidframework/map/internal\";\nimport type {\n\tIFluidDataStoreRegistry,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport { defaultRuntimeOptionsForMinVersion } from \"./compatibilityConfiguration.js\";\nimport type {\n\tContainerSchema,\n\tIRootDataObject,\n\tIStaticEntryPoint,\n\tLoadableObjectKind,\n\tLoadableObjectKindRecord,\n\tLoadableObjectRecord,\n} from \"./types.js\";\nimport {\n\tcreateDataObject,\n\tcreateSharedObject,\n\tisDataObjectKind,\n\tisSharedObjectKind,\n\tmakeFluidObject,\n\tparseDataObjectsFromSharedObjects,\n} from \"./utils.js\";\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}.\n */\ninterface RootDataObjectProps {\n\t/**\n\t * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n\t *\n\t * @see {@link RootDataObject.initializingFirstTime}\n\t */\n\treadonly initialObjects: LoadableObjectKindRecord;\n}\n\ninterface IProvideRootDataObject {\n\treadonly RootDataObject: RootDataObject;\n}\n\n/**\n * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.\n * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.\n */\nclass RootDataObject\n\textends DataObject<{ InitialState: RootDataObjectProps }>\n\timplements IRootDataObject, IProvideRootDataObject\n{\n\tprivate readonly initialObjectsDirKey = \"initial-objects-key\";\n\tprivate readonly _initialObjects: LoadableObjectRecord = {};\n\n\tpublic get RootDataObject(): RootDataObject {\n\t\treturn this;\n\t}\n\n\tprivate get initialObjectsDir(): IDirectory {\n\t\tconst dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n\t\tif (dir === undefined) {\n\t\t\tthrow new Error(\"InitialObjects sub-directory was not initialized\");\n\t\t}\n\t\treturn dir;\n\t}\n\n\t/**\n\t * The first time this object is initialized, creates each object identified in\n\t * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n\t */\n\tprotected async initializingFirstTime(props: RootDataObjectProps): Promise<void> {\n\t\tthis.root.createSubDirectory(this.initialObjectsDirKey);\n\n\t\t// Create initial objects provided by the developer\n\t\tconst initialObjectsP: Promise<void>[] = [];\n\t\tfor (const [id, objectClass] of Object.entries(props.initialObjects)) {\n\t\t\tconst createObject = async (): Promise<void> => {\n\t\t\t\tconst obj = await this.create<IFluidLoadable>(\n\t\t\t\t\tobjectClass as SharedObjectKind<IFluidLoadable>,\n\t\t\t\t);\n\t\t\t\tthis.initialObjectsDir.set(id, obj.handle);\n\t\t\t};\n\t\t\tinitialObjectsP.push(createObject());\n\t\t}\n\n\t\tawait Promise.all(initialObjectsP);\n\t}\n\n\t/**\n\t * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n\t * accessed immediately.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n\t */\n\tprotected async hasInitialized(): Promise<void> {\n\t\t// We will always load the initial objects so they are available to the developer\n\t\tconst loadInitialObjectsP: Promise<void>[] = [];\n\t\tfor (const [key, value] of this.initialObjectsDir.entries()) {\n\t\t\tconst loadDir = async (): Promise<void> => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\tconst obj: unknown = await value.get();\n\t\t\t\tObject.assign(this._initialObjects, { [key]: obj });\n\t\t\t};\n\t\t\tloadInitialObjectsP.push(loadDir());\n\t\t}\n\n\t\tawait Promise.all(loadInitialObjectsP);\n\t}\n\n\tpublic get initialObjects(): LoadableObjectRecord {\n\t\tif (Object.keys(this._initialObjects).length === 0) {\n\t\t\tthrow new Error(\"Initial Objects were not correctly initialized\");\n\t\t}\n\t\treturn this._initialObjects;\n\t}\n\n\tpublic async create<T>(objectClass: SharedObjectKind<T>): Promise<T> {\n\t\tconst internal = objectClass as unknown as LoadableObjectKind<T & IFluidLoadable>;\n\t\tif (isDataObjectKind(internal)) {\n\t\t\treturn createDataObject(internal, this.context);\n\t\t} else if (isSharedObjectKind(internal)) {\n\t\t\treturn createSharedObject(internal, this.runtime);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tpublic async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {\n\t\treturn this.runtime.uploadBlob(blob);\n\t}\n}\n\nconst rootDataStoreId = \"rootDOId\";\nconst rootDataObjectType = \"rootDO\";\n\nasync function provideEntryPoint(\n\tcontainerRuntime: IContainerRuntime,\n): Promise<IStaticEntryPoint> {\n\tconst entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\tif (entryPoint === undefined) {\n\t\tthrow new Error(`default dataStore [${rootDataStoreId}] must exist`);\n\t}\n\tconst rootDataObject = ((await entryPoint.get()) as FluidObject<RootDataObject>)\n\t\t.RootDataObject;\n\tassert(rootDataObject !== undefined, 0xb9f /* entryPoint must be of type RootDataObject */);\n\treturn makeFluidObject<IStaticEntryPoint>(\n\t\t{\n\t\t\trootDataObject,\n\t\t\textensionStore: containerRuntime as IContainerRuntimeInternal,\n\t\t},\n\t\t\"IStaticEntryPoint\",\n\t);\n}\n\n/**\n * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers\n * with an entry point containing single directory-based root data object.\n *\n * @remarks\n * The entry point is opaque to caller.\n * The root data object's registry and initial objects are configured based on the provided\n * schema (and optionally, data store registry).\n *\n * @internal\n */\nexport function createDOProviderContainerRuntimeFactory(props: {\n\t/**\n\t * The schema for the container.\n\t */\n\tschema: ContainerSchema;\n\t/**\n\t * Minimum Fluid Framework version required for collaboration as a\n\t * {@link @fluidframework/runtime-definitions#MinimumVersionForCollab} SemVer string.\n\t */\n\tminVersionForCollaboration: MinimumVersionForCollab;\n\t/**\n\t * Optional registry of data stores to pass to the DataObject factory.\n\t * If not provided, one will be created based on the schema.\n\t */\n\trootDataStoreRegistry?: IFluidDataStoreRegistry;\n\t/**\n\t * Optional overrides for the container runtime options.\n\t * If not provided, only the default options for the given minVersionForCollaboration will be used.\n\t */\n\truntimeOptionOverrides?: Partial<IContainerRuntimeOptions>;\n}): IRuntimeFactory {\n\tconst { rootDataStoreRegistry, runtimeOptionOverrides, schema } = props;\n\tconst minVersionForCollab = props.minVersionForCollaboration;\n\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n\tconst registry = rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);\n\n\treturn new DOProviderContainerRuntimeFactory(\n\t\tschema,\n\t\tnew RootDataObjectFactory(sharedObjects, registry),\n\t\t{\n\t\t\truntimeOptions: runtimeOptionOverrides,\n\t\t\tminVersionForCollab,\n\t\t},\n\t);\n}\n\n/**\n * Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}\n * (containing single {@link IRootDataObject}) as their entry point.\n */\nclass DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n\tprivate readonly rootDataObjectFactory: DataObjectFactory<\n\t\tRootDataObject,\n\t\t{\n\t\t\tInitialState: RootDataObjectProps;\n\t\t}\n\t>;\n\n\tprivate readonly initialObjects: LoadableObjectKindRecord;\n\n\t/**\n\t * Create a new instance of a container runtime factory.\n\t * @remarks\n\t * The caller is responsible for making sure that the provided root data object factory is configured\n\t * appropriately based on the schema of the container (e.g. its registry entries contain all the\n\t * DataStore/DDS types that the schema says can be constructed).\n\t *\n\t * Most scenarios probably want to use {@link createDOProviderContainerRuntimeFactory} instead,\n\t * since it can take care of constructing the root data object factory based on the schema.\n\t *\n\t * @param schema - The schema for the container\n\t * @param rootDataObjectFactory - A factory that can construct the root data object.\n\t * @param config - Resolved minimum version for collaboration (required) and optional runtime option overrides.\n\t */\n\tpublic constructor(\n\t\tschema: ContainerSchema,\n\t\trootDataObjectFactory: DataObjectFactory<\n\t\t\tRootDataObject,\n\t\t\t{ InitialState: RootDataObjectProps }\n\t\t>,\n\t\tconfig: {\n\t\t\tminVersionForCollab: MinimumVersionForCollab;\n\t\t\truntimeOptions?: Partial<IContainerRuntimeOptions>;\n\t\t},\n\t) {\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\truntimeOptions: {\n\t\t\t\t...defaultRuntimeOptionsForMinVersion(config.minVersionForCollab),\n\t\t\t\t...config.runtimeOptions,\n\t\t\t},\n\t\t\tprovideEntryPoint,\n\t\t\tminVersionForCollab: config.minVersionForCollab,\n\t\t});\n\t\tthis.rootDataObjectFactory = rootDataObjectFactory;\n\t\tthis.initialObjects = schema.initialObjects;\n\t}\n\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\t// The first time we create the container we create the RootDataObject\n\t\tawait this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {\n\t\t\tinitialObjects: this.initialObjects,\n\t\t});\n\t}\n}\n\n/**\n * Factory that creates instances of a root data object.\n */\nclass RootDataObjectFactory extends DataObjectFactory<\n\tRootDataObject,\n\t{ InitialState: RootDataObjectProps }\n> {\n\tpublic constructor(\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\tprivate readonly dataStoreRegistry: IFluidDataStoreRegistry,\n\t) {\n\t\t// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,\n\t\t// and instead we override the necessary methods in this class to use the registry received in the constructor.\n\t\tsuper({\n\t\t\ttype: rootDataObjectType,\n\t\t\tctor: RootDataObject,\n\t\t\tsharedObjects,\n\t\t});\n\t}\n\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.dataStoreRegistry;\n\t}\n}\n"]}
@@ -23,7 +23,41 @@ export declare function createTreeContainerRuntimeFactory(props: {
23
23
  */
24
24
  readonly schema: TreeContainerSchema;
25
25
  /**
26
- * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.
26
+ * Minimum Fluid Framework version required for collaboration as a
27
+ * {@link @fluidframework/runtime-definitions#MinimumVersionForCollab} SemVer string.
28
+ */
29
+ readonly minVersionForCollaboration: MinimumVersionForCollab;
30
+ /**
31
+ * Optional registry of data stores to pass to the DataObject factory.
32
+ * If not provided, one will be created based on the schema.
33
+ */
34
+ readonly rootDataStoreRegistry?: IFluidDataStoreRegistry;
35
+ /**
36
+ * Optional overrides for the container runtime options.
37
+ * If not provided, only the default options for the given minVersionForCollaboration will be used.
38
+ */
39
+ readonly runtimeOptionOverrides?: Partial<IContainerRuntimeOptions>;
40
+ }): IRuntimeFactory;
41
+ /**
42
+ * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
43
+ * with an entry point containing single tree-based root data object.
44
+ *
45
+ * @remarks
46
+ * The entry point is opaque to caller.
47
+ * The root data object's registry and shared objects are configured based on the provided
48
+ * SharedTree and optional data store registry.
49
+ *
50
+ * @deprecated Pass `minVersionForCollaboration` directly instead of using `compatibilityMode`.
51
+ *
52
+ * @legacy @beta
53
+ */
54
+ export declare function createTreeContainerRuntimeFactory(props: {
55
+ /**
56
+ * The schema for the container.
57
+ */
58
+ readonly schema: TreeContainerSchema;
59
+ /**
60
+ * Legacy compatibility mode for the container.
27
61
  */
28
62
  readonly compatibilityMode: CompatibilityMode;
29
63
  /**
@@ -37,10 +71,10 @@ export declare function createTreeContainerRuntimeFactory(props: {
37
71
  */
38
72
  readonly runtimeOptionOverrides?: Partial<IContainerRuntimeOptions>;
39
73
  /**
40
- * Optional override for minimum version for collab.
41
- * If not provided, the default for the given compatibilityMode will be used.
74
+ * Optional override for minimum version for collaboration.
42
75
  * @remarks
43
- * This is useful when runtime options are overridden and change the minimum version for collab.
76
+ * If not provided, the default for the given compatibilityMode will be used.
77
+ * Rather than defining this, omit `compatibilityMode` and pass `minVersionForCollaboration` directly.
44
78
  */
45
79
  readonly minVersionForCollabOverride?: MinimumVersionForCollab;
46
80
  }): IRuntimeFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"treeRootDataObject.d.ts","sourceRoot":"","sources":["../src/treeRootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAEN,KAAK,wBAAwB,EAC7B,MAAM,4CAA4C,CAAC;AAYpD,OAAO,KAAK,EACX,uBAAuB,EACvB,uBAAuB,EACvB,MAAM,8CAA8C,CAAC;AAItD,OAAO,KAAK,EACX,iBAAiB,EAKjB,mBAAmB,EACnB,MAAM,YAAY,CAAC;AA0JpB;;;;;;;;;;GAUG;AACH,wBAAgB,iCAAiC,CAAC,KAAK,EAAE;IACxD;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,uBAAuB,CAAC;IACzD;;;OAGG;IACH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACpE;;;;;OAKG;IACH,QAAQ,CAAC,2BAA2B,CAAC,EAAE,uBAAuB,CAAC;CAC/D,GAAG,eAAe,CAoBlB"}
1
+ {"version":3,"file":"treeRootDataObject.d.ts","sourceRoot":"","sources":["../src/treeRootDataObject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