@fluidframework/aqueduct 2.0.0-rc.1.0.3 → 2.0.0-rc.2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/aqueduct-alpha.d.ts +116 -48
  2. package/dist/aqueduct-beta.d.ts +10 -0
  3. package/dist/aqueduct-public.d.ts +10 -0
  4. package/dist/aqueduct-untrimmed.d.ts +116 -48
  5. package/dist/container-runtime-factories/baseContainerRuntimeFactory.d.ts +39 -23
  6. package/dist/container-runtime-factories/baseContainerRuntimeFactory.d.ts.map +1 -1
  7. package/dist/container-runtime-factories/baseContainerRuntimeFactory.js +3 -8
  8. package/dist/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
  9. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.ts +37 -25
  10. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
  11. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js +4 -13
  12. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
  13. package/dist/container-runtime-factories/index.d.ts +2 -2
  14. package/dist/container-runtime-factories/index.d.ts.map +1 -1
  15. package/dist/container-runtime-factories/index.js +4 -4
  16. package/dist/container-runtime-factories/index.js.map +1 -1
  17. package/dist/data-object-factories/dataObjectFactory.d.ts +6 -6
  18. package/dist/data-object-factories/dataObjectFactory.d.ts.map +1 -1
  19. package/dist/data-object-factories/dataObjectFactory.js +4 -4
  20. package/dist/data-object-factories/dataObjectFactory.js.map +1 -1
  21. package/dist/data-object-factories/index.d.ts +2 -2
  22. package/dist/data-object-factories/index.d.ts.map +1 -1
  23. package/dist/data-object-factories/index.js +4 -4
  24. package/dist/data-object-factories/index.js.map +1 -1
  25. package/dist/data-object-factories/pureDataObjectFactory.d.ts +44 -14
  26. package/dist/data-object-factories/pureDataObjectFactory.d.ts.map +1 -1
  27. package/dist/data-object-factories/pureDataObjectFactory.js +56 -14
  28. package/dist/data-object-factories/pureDataObjectFactory.js.map +1 -1
  29. package/dist/data-objects/dataObject.d.ts +3 -3
  30. package/dist/data-objects/dataObject.d.ts.map +1 -1
  31. package/dist/data-objects/dataObject.js +8 -8
  32. package/dist/data-objects/dataObject.js.map +1 -1
  33. package/dist/data-objects/index.d.ts +3 -3
  34. package/dist/data-objects/index.d.ts.map +1 -1
  35. package/dist/data-objects/index.js +4 -4
  36. package/dist/data-objects/index.js.map +1 -1
  37. package/dist/data-objects/pureDataObject.d.ts +12 -6
  38. package/dist/data-objects/pureDataObject.d.ts.map +1 -1
  39. package/dist/data-objects/pureDataObject.js +10 -0
  40. package/dist/data-objects/pureDataObject.js.map +1 -1
  41. package/dist/data-objects/types.d.ts +7 -7
  42. package/dist/data-objects/types.d.ts.map +1 -1
  43. package/dist/data-objects/types.js.map +1 -1
  44. package/dist/index.d.ts +3 -3
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +9 -9
  47. package/dist/index.js.map +1 -1
  48. package/dist/package.json +3 -0
  49. package/dist/tsdoc-metadata.json +1 -1
  50. package/lib/{aqueduct-alpha.d.mts → aqueduct-alpha.d.ts} +131 -48
  51. package/lib/{aqueduct-beta.d.mts → aqueduct-beta.d.ts} +25 -0
  52. package/lib/{aqueduct-public.d.mts → aqueduct-public.d.ts} +25 -0
  53. package/lib/{aqueduct-untrimmed.d.mts → aqueduct-untrimmed.d.ts} +131 -48
  54. package/lib/container-runtime-factories/{baseContainerRuntimeFactory.d.mts → baseContainerRuntimeFactory.d.ts} +40 -24
  55. package/lib/container-runtime-factories/baseContainerRuntimeFactory.d.ts.map +1 -0
  56. package/lib/container-runtime-factories/{baseContainerRuntimeFactory.mjs → baseContainerRuntimeFactory.js} +6 -10
  57. package/lib/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -0
  58. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.ts +57 -0
  59. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -0
  60. package/lib/container-runtime-factories/{containerRuntimeFactoryWithDefaultDataStore.mjs → containerRuntimeFactoryWithDefaultDataStore.js} +4 -13
  61. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js.map +1 -0
  62. package/lib/container-runtime-factories/index.d.ts +7 -0
  63. package/lib/container-runtime-factories/index.d.ts.map +1 -0
  64. package/lib/container-runtime-factories/index.js +7 -0
  65. package/lib/container-runtime-factories/index.js.map +1 -0
  66. package/lib/data-object-factories/dataObjectFactory.d.ts +23 -0
  67. package/lib/data-object-factories/dataObjectFactory.d.ts.map +1 -0
  68. package/lib/data-object-factories/{dataObjectFactory.mjs → dataObjectFactory.js} +4 -4
  69. package/lib/data-object-factories/dataObjectFactory.js.map +1 -0
  70. package/lib/data-object-factories/index.d.ts +7 -0
  71. package/lib/data-object-factories/index.d.ts.map +1 -0
  72. package/lib/data-object-factories/index.js +7 -0
  73. package/lib/data-object-factories/index.js.map +1 -0
  74. package/lib/data-object-factories/{pureDataObjectFactory.d.mts → pureDataObjectFactory.d.ts} +45 -15
  75. package/lib/data-object-factories/pureDataObjectFactory.d.ts.map +1 -0
  76. package/lib/data-object-factories/{pureDataObjectFactory.mjs → pureDataObjectFactory.js} +57 -15
  77. package/lib/data-object-factories/pureDataObjectFactory.js.map +1 -0
  78. package/lib/data-objects/{dataObject.d.mts → dataObject.d.ts} +4 -4
  79. package/lib/data-objects/dataObject.d.ts.map +1 -0
  80. package/lib/data-objects/{dataObject.mjs → dataObject.js} +8 -8
  81. package/lib/data-objects/dataObject.js.map +1 -0
  82. package/lib/data-objects/index.d.ts +8 -0
  83. package/lib/data-objects/index.d.ts.map +1 -0
  84. package/lib/data-objects/index.js +7 -0
  85. package/lib/data-objects/index.js.map +1 -0
  86. package/lib/data-objects/{pureDataObject.d.mts → pureDataObject.d.ts} +13 -7
  87. package/lib/data-objects/pureDataObject.d.ts.map +1 -0
  88. package/lib/data-objects/{pureDataObject.mjs → pureDataObject.js} +11 -1
  89. package/lib/data-objects/pureDataObject.js.map +1 -0
  90. package/lib/data-objects/{types.d.mts → types.d.ts} +8 -8
  91. package/lib/data-objects/types.d.ts.map +1 -0
  92. package/lib/data-objects/{types.mjs → types.js} +1 -1
  93. package/lib/data-objects/types.js.map +1 -0
  94. package/lib/index.d.ts +22 -0
  95. package/lib/index.d.ts.map +1 -0
  96. package/lib/index.js +22 -0
  97. package/lib/index.js.map +1 -0
  98. package/lib/test/aqueduct.spec.js +8 -0
  99. package/lib/test/aqueduct.spec.js.map +1 -0
  100. package/lib/test/tsconfig.tsbuildinfo +1 -0
  101. package/lib/test/types/validateAqueductPrevious.generated.js +24 -0
  102. package/lib/test/types/validateAqueductPrevious.generated.js.map +1 -0
  103. package/package.json +54 -54
  104. package/lib/container-runtime-factories/baseContainerRuntimeFactory.d.mts.map +0 -1
  105. package/lib/container-runtime-factories/baseContainerRuntimeFactory.mjs.map +0 -1
  106. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.mts +0 -45
  107. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.mts.map +0 -1
  108. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.mjs.map +0 -1
  109. package/lib/container-runtime-factories/index.d.mts +0 -7
  110. package/lib/container-runtime-factories/index.d.mts.map +0 -1
  111. package/lib/container-runtime-factories/index.mjs +0 -7
  112. package/lib/container-runtime-factories/index.mjs.map +0 -1
  113. package/lib/data-object-factories/dataObjectFactory.d.mts +0 -23
  114. package/lib/data-object-factories/dataObjectFactory.d.mts.map +0 -1
  115. package/lib/data-object-factories/dataObjectFactory.mjs.map +0 -1
  116. package/lib/data-object-factories/index.d.mts +0 -7
  117. package/lib/data-object-factories/index.d.mts.map +0 -1
  118. package/lib/data-object-factories/index.mjs +0 -7
  119. package/lib/data-object-factories/index.mjs.map +0 -1
  120. package/lib/data-object-factories/pureDataObjectFactory.d.mts.map +0 -1
  121. package/lib/data-object-factories/pureDataObjectFactory.mjs.map +0 -1
  122. package/lib/data-objects/dataObject.d.mts.map +0 -1
  123. package/lib/data-objects/dataObject.mjs.map +0 -1
  124. package/lib/data-objects/index.d.mts +0 -8
  125. package/lib/data-objects/index.d.mts.map +0 -1
  126. package/lib/data-objects/index.mjs +0 -7
  127. package/lib/data-objects/index.mjs.map +0 -1
  128. package/lib/data-objects/pureDataObject.d.mts.map +0 -1
  129. package/lib/data-objects/pureDataObject.mjs.map +0 -1
  130. package/lib/data-objects/types.d.mts.map +0 -1
  131. package/lib/data-objects/types.mjs.map +0 -1
  132. package/lib/index.d.mts +0 -8
  133. package/lib/index.d.mts.map +0 -1
  134. package/lib/index.mjs +0 -8
  135. package/lib/index.mjs.map +0 -1
@@ -5,8 +5,8 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ContainerRuntimeFactoryWithDefaultDataStore = exports.BaseContainerRuntimeFactory = void 0;
8
- var baseContainerRuntimeFactory_1 = require("./baseContainerRuntimeFactory");
9
- Object.defineProperty(exports, "BaseContainerRuntimeFactory", { enumerable: true, get: function () { return baseContainerRuntimeFactory_1.BaseContainerRuntimeFactory; } });
10
- var containerRuntimeFactoryWithDefaultDataStore_1 = require("./containerRuntimeFactoryWithDefaultDataStore");
11
- Object.defineProperty(exports, "ContainerRuntimeFactoryWithDefaultDataStore", { enumerable: true, get: function () { return containerRuntimeFactoryWithDefaultDataStore_1.ContainerRuntimeFactoryWithDefaultDataStore; } });
8
+ var baseContainerRuntimeFactory_js_1 = require("./baseContainerRuntimeFactory.js");
9
+ Object.defineProperty(exports, "BaseContainerRuntimeFactory", { enumerable: true, get: function () { return baseContainerRuntimeFactory_js_1.BaseContainerRuntimeFactory; } });
10
+ var containerRuntimeFactoryWithDefaultDataStore_js_1 = require("./containerRuntimeFactoryWithDefaultDataStore.js");
11
+ Object.defineProperty(exports, "ContainerRuntimeFactoryWithDefaultDataStore", { enumerable: true, get: function () { return containerRuntimeFactoryWithDefaultDataStore_js_1.ContainerRuntimeFactoryWithDefaultDataStore; } });
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/container-runtime-factories/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6EAA4E;AAAnE,0IAAA,2BAA2B,OAAA;AACpC,6GAA4G;AAAnG,0KAAA,2CAA2C,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { BaseContainerRuntimeFactory } from \"./baseContainerRuntimeFactory\";\nexport { ContainerRuntimeFactoryWithDefaultDataStore } from \"./containerRuntimeFactoryWithDefaultDataStore\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/container-runtime-factories/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mFAG0C;AAFzC,6IAAA,2BAA2B,OAAA;AAG5B,mHAG0D;AAFzD,6KAAA,2CAA2C,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tBaseContainerRuntimeFactory,\n\ttype BaseContainerRuntimeFactoryProps,\n} from \"./baseContainerRuntimeFactory.js\";\nexport {\n\tContainerRuntimeFactoryWithDefaultDataStore,\n\ttype ContainerRuntimeFactoryWithDefaultDataStoreProps,\n} from \"./containerRuntimeFactoryWithDefaultDataStore.js\";\n"]}
@@ -2,12 +2,12 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { NamedFluidDataStoreRegistryEntries } from "@fluidframework/runtime-definitions";
6
- import { IChannelFactory } from "@fluidframework/datastore-definitions";
7
- import { FluidObjectSymbolProvider } from "@fluidframework/synthesize";
5
+ import { type NamedFluidDataStoreRegistryEntries } from "@fluidframework/runtime-definitions";
6
+ import { type IChannelFactory } from "@fluidframework/datastore-definitions";
7
+ import { type FluidObjectSymbolProvider } from "@fluidframework/synthesize";
8
8
  import { FluidDataStoreRuntime } from "@fluidframework/datastore";
9
- import { DataObject, DataObjectTypes, IDataObjectProps } from "../data-objects";
10
- import { PureDataObjectFactory } from "./pureDataObjectFactory";
9
+ import { type DataObject, type DataObjectTypes, type IDataObjectProps } from "../data-objects/index.js";
10
+ import { PureDataObjectFactory } from "./pureDataObjectFactory.js";
11
11
  /**
12
12
  * DataObjectFactory is the IFluidDataStoreFactory for use with DataObjects.
13
13
  * It facilitates DataObject's features (such as its shared directory) by
@@ -18,6 +18,6 @@ import { PureDataObjectFactory } from "./pureDataObjectFactory";
18
18
  * @alpha
19
19
  */
20
20
  export declare class DataObjectFactory<TObj extends DataObject<I>, I extends DataObjectTypes = DataObjectTypes> extends PureDataObjectFactory<TObj, I> {
21
- constructor(type: string, ctor: new (props: IDataObjectProps<I>) => TObj, sharedObjects: readonly IChannelFactory[] | undefined, optionalProviders: FluidObjectSymbolProvider<I["OptionalProviders"]>, registryEntries?: NamedFluidDataStoreRegistryEntries, runtimeFactory?: typeof FluidDataStoreRuntime);
21
+ constructor(type: string, ctor: new (props: IDataObjectProps<I>) => TObj, sharedObjects: readonly IChannelFactory<import("@fluidframework/core-interfaces").IFluidLoadable>[] | undefined, optionalProviders: FluidObjectSymbolProvider<I["OptionalProviders"]>, registryEntries?: NamedFluidDataStoreRegistryEntries, runtimeFactory?: typeof FluidDataStoreRuntime);
22
22
  }
23
23
  //# sourceMappingURL=dataObjectFactory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dataObjectFactory.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/dataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,kCAAkC,EAAE,MAAM,qCAAqC,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B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eAAe,CAC1C,SAAQ,qBAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;gBAEtC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,KAAK,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,EAC9C,aAAa,kGAAiC,EAC9C,iBAAiB,EAAE,yBAAyB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,EACpE,eAAe,CAAC,EAAE,kCAAkC,EACpD,cAAc,GAAE,OAAO,qBAA6C;CAiBrE"}
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.DataObjectFactory = void 0;
8
8
  const map_1 = require("@fluidframework/map");
9
9
  const datastore_1 = require("@fluidframework/datastore");
10
- const pureDataObjectFactory_1 = require("./pureDataObjectFactory");
10
+ const pureDataObjectFactory_js_1 = require("./pureDataObjectFactory.js");
11
11
  /**
12
12
  * DataObjectFactory is the IFluidDataStoreFactory for use with DataObjects.
13
13
  * It facilitates DataObject's features (such as its shared directory) by
@@ -17,15 +17,15 @@ const pureDataObjectFactory_1 = require("./pureDataObjectFactory");
17
17
  * @typeParam I - The input types for the DataObject
18
18
  * @alpha
19
19
  */
20
- class DataObjectFactory extends pureDataObjectFactory_1.PureDataObjectFactory {
20
+ class DataObjectFactory extends pureDataObjectFactory_js_1.PureDataObjectFactory {
21
21
  constructor(type, ctor, sharedObjects = [], optionalProviders, registryEntries, runtimeFactory = datastore_1.FluidDataStoreRuntime) {
22
22
  const mergedObjects = [...sharedObjects];
23
- if (!sharedObjects.find((factory) => factory.type === map_1.DirectoryFactory.Type)) {
23
+ if (!sharedObjects.some((factory) => factory.type === map_1.DirectoryFactory.Type)) {
24
24
  // User did not register for directory
25
25
  mergedObjects.push(map_1.SharedDirectory.getFactory());
26
26
  }
27
27
  // TODO: Remove SharedMap factory when compatibility with SharedMap DataObject is no longer needed in 0.10
28
- if (!sharedObjects.find((factory) => factory.type === map_1.MapFactory.Type)) {
28
+ if (!sharedObjects.some((factory) => factory.type === map_1.MapFactory.Type)) {
29
29
  // User did not register for map
30
30
  mergedObjects.push(map_1.SharedMap.getFactory());
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/dataObjectFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAA+F;AAI/F,yDAAkE;AAGlE,mEAAgE;AAEhE;;;;;;;;GAQG;AACH,MAAa,iBAGX,SAAQ,6CAA8B;IACvC,YACC,IAAY,EACZ,IAA8C,EAC9C,gBAA4C,EAAE,EAC9C,iBAAoE,EACpE,eAAoD,EACpD,iBAA+C,iCAAqB;QAEpE,MAAM,aAAa,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC;QAEzC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,sBAAgB,CAAC,IAAI,CAAC,EAAE;YAC7E,sCAAsC;YACtC,aAAa,CAAC,IAAI,CAAC,qBAAe,CAAC,UAAU,EAAE,CAAC,CAAC;SACjD;QAED,0GAA0G;QAC1G,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,gBAAU,CAAC,IAAI,CAAC,EAAE;YACvE,gCAAgC;YAChC,aAAa,CAAC,IAAI,CAAC,eAAS,CAAC,UAAU,EAAE,CAAC,CAAC;SAC3C;QAED,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;IACtF,CAAC;CACD;AA3BD,8CA2BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DirectoryFactory, MapFactory, SharedDirectory, SharedMap } from \"@fluidframework/map\";\nimport { NamedFluidDataStoreRegistryEntries } from \"@fluidframework/runtime-definitions\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { FluidObjectSymbolProvider } from \"@fluidframework/synthesize\";\nimport { FluidDataStoreRuntime } from \"@fluidframework/datastore\";\n\nimport { DataObject, DataObjectTypes, IDataObjectProps } from \"../data-objects\";\nimport { PureDataObjectFactory } from \"./pureDataObjectFactory\";\n\n/**\n * DataObjectFactory is the IFluidDataStoreFactory for use with DataObjects.\n * It facilitates DataObject's features (such as its shared directory) by\n * ensuring relevant shared objects etc are available to the factory.\n *\n * @typeParam TObj - DataObject (concrete type)\n * @typeParam I - The input types for the DataObject\n * @alpha\n */\nexport class DataObjectFactory<\n\tTObj extends DataObject<I>,\n\tI extends DataObjectTypes = DataObjectTypes,\n> extends PureDataObjectFactory<TObj, I> {\n\tconstructor(\n\t\ttype: string,\n\t\tctor: new (props: IDataObjectProps<I>) => TObj,\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\toptionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n\t\tregistryEntries?: NamedFluidDataStoreRegistryEntries,\n\t\truntimeFactory: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n\t) {\n\t\tconst mergedObjects = [...sharedObjects];\n\n\t\tif (!sharedObjects.find((factory) => factory.type === DirectoryFactory.Type)) {\n\t\t\t// User did not register for directory\n\t\t\tmergedObjects.push(SharedDirectory.getFactory());\n\t\t}\n\n\t\t// TODO: Remove SharedMap factory when compatibility with SharedMap DataObject is no longer needed in 0.10\n\t\tif (!sharedObjects.find((factory) => factory.type === MapFactory.Type)) {\n\t\t\t// User did not register for map\n\t\t\tmergedObjects.push(SharedMap.getFactory());\n\t\t}\n\n\t\tsuper(type, ctor, mergedObjects, optionalProviders, registryEntries, runtimeFactory);\n\t}\n}\n"]}
1
+ {"version":3,"file":"dataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/dataObjectFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAA+F;AAI/F,yDAAkE;AAOlE,yEAAmE;AAEnE;;;;;;;;GAQG;AACH,MAAa,iBAGX,SAAQ,gDAA8B;IACvC,YACC,IAAY,EACZ,IAA8C,EAC9C,gBAA4C,EAAE,EAC9C,iBAAoE,EACpE,eAAoD,EACpD,iBAA+C,iCAAqB;QAEpE,MAAM,aAAa,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC;QAEzC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,sBAAgB,CAAC,IAAI,CAAC,EAAE;YAC7E,sCAAsC;YACtC,aAAa,CAAC,IAAI,CAAC,qBAAe,CAAC,UAAU,EAAE,CAAC,CAAC;SACjD;QAED,0GAA0G;QAC1G,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,gBAAU,CAAC,IAAI,CAAC,EAAE;YACvE,gCAAgC;YAChC,aAAa,CAAC,IAAI,CAAC,eAAS,CAAC,UAAU,EAAE,CAAC,CAAC;SAC3C;QAED,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;IACtF,CAAC;CACD;AA3BD,8CA2BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DirectoryFactory, MapFactory, SharedDirectory, SharedMap } from \"@fluidframework/map\";\nimport { type NamedFluidDataStoreRegistryEntries } from \"@fluidframework/runtime-definitions\";\nimport { type IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { type FluidObjectSymbolProvider } from \"@fluidframework/synthesize\";\nimport { FluidDataStoreRuntime } from \"@fluidframework/datastore\";\n\nimport {\n\ttype DataObject,\n\ttype DataObjectTypes,\n\ttype IDataObjectProps,\n} from \"../data-objects/index.js\";\nimport { PureDataObjectFactory } from \"./pureDataObjectFactory.js\";\n\n/**\n * DataObjectFactory is the IFluidDataStoreFactory for use with DataObjects.\n * It facilitates DataObject's features (such as its shared directory) by\n * ensuring relevant shared objects etc are available to the factory.\n *\n * @typeParam TObj - DataObject (concrete type)\n * @typeParam I - The input types for the DataObject\n * @alpha\n */\nexport class DataObjectFactory<\n\tTObj extends DataObject<I>,\n\tI extends DataObjectTypes = DataObjectTypes,\n> extends PureDataObjectFactory<TObj, I> {\n\tpublic constructor(\n\t\ttype: string,\n\t\tctor: new (props: IDataObjectProps<I>) => TObj,\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\toptionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n\t\tregistryEntries?: NamedFluidDataStoreRegistryEntries,\n\t\truntimeFactory: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n\t) {\n\t\tconst mergedObjects = [...sharedObjects];\n\n\t\tif (!sharedObjects.some((factory) => factory.type === DirectoryFactory.Type)) {\n\t\t\t// User did not register for directory\n\t\t\tmergedObjects.push(SharedDirectory.getFactory());\n\t\t}\n\n\t\t// TODO: Remove SharedMap factory when compatibility with SharedMap DataObject is no longer needed in 0.10\n\t\tif (!sharedObjects.some((factory) => factory.type === MapFactory.Type)) {\n\t\t\t// User did not register for map\n\t\t\tmergedObjects.push(SharedMap.getFactory());\n\t\t}\n\n\t\tsuper(type, ctor, mergedObjects, optionalProviders, registryEntries, runtimeFactory);\n\t}\n}\n"]}
@@ -2,6 +2,6 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { DataObjectFactory } from "./dataObjectFactory";
6
- export { PureDataObjectFactory } from "./pureDataObjectFactory";
5
+ export { DataObjectFactory } from "./dataObjectFactory.js";
6
+ export { PureDataObjectFactory } from "./pureDataObjectFactory.js";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -5,8 +5,8 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.PureDataObjectFactory = exports.DataObjectFactory = void 0;
8
- var dataObjectFactory_1 = require("./dataObjectFactory");
9
- Object.defineProperty(exports, "DataObjectFactory", { enumerable: true, get: function () { return dataObjectFactory_1.DataObjectFactory; } });
10
- var pureDataObjectFactory_1 = require("./pureDataObjectFactory");
11
- Object.defineProperty(exports, "PureDataObjectFactory", { enumerable: true, get: function () { return pureDataObjectFactory_1.PureDataObjectFactory; } });
8
+ var dataObjectFactory_js_1 = require("./dataObjectFactory.js");
9
+ Object.defineProperty(exports, "DataObjectFactory", { enumerable: true, get: function () { return dataObjectFactory_js_1.DataObjectFactory; } });
10
+ var pureDataObjectFactory_js_1 = require("./pureDataObjectFactory.js");
11
+ Object.defineProperty(exports, "PureDataObjectFactory", { enumerable: true, get: function () { return pureDataObjectFactory_js_1.PureDataObjectFactory; } });
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { DataObjectFactory } from \"./dataObjectFactory\";\nexport { PureDataObjectFactory } from \"./pureDataObjectFactory\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { DataObjectFactory } from \"./dataObjectFactory.js\";\nexport { PureDataObjectFactory } from \"./pureDataObjectFactory.js\";\n"]}
@@ -3,11 +3,11 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { FluidDataStoreRuntime } from "@fluidframework/datastore";
6
- import { IFluidDataStoreContext, IContainerRuntimeBase, IFluidDataStoreFactory, IFluidDataStoreRegistry, IProvideFluidDataStoreRegistry, NamedFluidDataStoreRegistryEntries, NamedFluidDataStoreRegistryEntry, IFluidDataStoreContextDetached } from "@fluidframework/runtime-definitions";
7
- import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
8
- import { IChannelFactory } from "@fluidframework/datastore-definitions";
9
- import { FluidObjectSymbolProvider } from "@fluidframework/synthesize";
10
- import { IDataObjectProps, PureDataObject, DataObjectTypes } from "../data-objects";
6
+ import { type IContainerRuntimeBase, type IDataStore, type IFluidDataStoreChannel, type IFluidDataStoreContext, type IFluidDataStoreContextDetached, type IFluidDataStoreFactory, type IFluidDataStoreRegistry, type NamedFluidDataStoreRegistryEntries, type NamedFluidDataStoreRegistryEntry, type IProvideFluidDataStoreRegistry } from "@fluidframework/runtime-definitions";
7
+ import { type IContainerRuntime } from "@fluidframework/container-runtime-definitions";
8
+ import { type IChannelFactory } from "@fluidframework/datastore-definitions";
9
+ import { type FluidObjectSymbolProvider } from "@fluidframework/synthesize";
10
+ import { type IDataObjectProps, type PureDataObject, type DataObjectTypes } from "../data-objects/index.js";
11
11
  /**
12
12
  * PureDataObjectFactory is a barebones IFluidDataStoreFactory for use with PureDataObject.
13
13
  * Consumers should typically use DataObjectFactory instead unless creating
@@ -18,14 +18,27 @@ import { IDataObjectProps, PureDataObject, DataObjectTypes } from "../data-objec
18
18
  * @alpha
19
19
  */
20
20
  export declare class PureDataObjectFactory<TObj extends PureDataObject<I>, I extends DataObjectTypes = DataObjectTypes> implements IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry> {
21
+ /**
22
+ * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory."type"}
23
+ */
21
24
  readonly type: string;
22
25
  private readonly ctor;
23
26
  private readonly optionalProviders;
24
27
  private readonly runtimeClass;
25
28
  private readonly sharedObjectRegistry;
26
29
  private readonly registry;
27
- constructor(type: string, ctor: new (props: IDataObjectProps<I>) => TObj, sharedObjects: readonly IChannelFactory[], optionalProviders: FluidObjectSymbolProvider<I["OptionalProviders"]>, registryEntries?: NamedFluidDataStoreRegistryEntries, runtimeClass?: typeof FluidDataStoreRuntime);
30
+ constructor(
31
+ /**
32
+ * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory."type"}
33
+ */
34
+ type: string, ctor: new (props: IDataObjectProps<I>) => TObj, sharedObjects: readonly IChannelFactory[], optionalProviders: FluidObjectSymbolProvider<I["OptionalProviders"]>, registryEntries?: NamedFluidDataStoreRegistryEntries, runtimeClass?: typeof FluidDataStoreRuntime);
35
+ /**
36
+ * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreFactory.IFluidDataStoreFactory}
37
+ */
28
38
  get IFluidDataStoreFactory(): this;
39
+ /**
40
+ * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreRegistry.IFluidDataStoreRegistry}
41
+ */
29
42
  get IFluidDataStoreRegistry(): IFluidDataStoreRegistry | undefined;
30
43
  /**
31
44
  * Convenience helper to get the data store's/factory's data store registry entry.
@@ -35,11 +48,9 @@ export declare class PureDataObjectFactory<TObj extends PureDataObject<I>, I ext
35
48
  */
36
49
  get registryEntry(): NamedFluidDataStoreRegistryEntry;
37
50
  /**
38
- * This is where we do data store setup.
39
- *
40
- * @param context - data store context used to load a data store runtime
51
+ * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory.instantiateDataStore}
41
52
  */
42
- instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<FluidDataStoreRuntime>;
53
+ instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<IFluidDataStoreChannel>;
43
54
  /**
44
55
  * Creates a new instance of the object. Uses parent context's registry to build package path to this factory.
45
56
  * In other words, registry of context passed in has to contain this factory, with the name that matches
@@ -48,10 +59,11 @@ export declare class PureDataObjectFactory<TObj extends PureDataObject<I>, I ext
48
59
  * @param context - The context being used to create the runtime
49
60
  * (the created object will have its own new context created as well)
50
61
  * @param initialState - The initial state to provide to the created data store.
62
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
51
63
  * @returns an object created by this factory. Data store and objects created are not attached to container.
52
64
  * They get attached only when a handle to one of them is attached to already attached objects.
53
65
  */
54
- createChildInstance(parentContext: IFluidDataStoreContext, initialState?: I["InitialState"]): Promise<TObj>;
66
+ createChildInstance(parentContext: IFluidDataStoreContext, initialState?: I["InitialState"], loadingGroupId?: string): Promise<TObj>;
55
67
  /**
56
68
  * Creates a new instance of the object. Uses peer context's registry and its package path to identify this factory.
57
69
  * In other words, registry of context passed in has to have this factory.
@@ -59,10 +71,11 @@ export declare class PureDataObjectFactory<TObj extends PureDataObject<I>, I ext
59
71
  * @param context - The component context being used to create the object
60
72
  * (the created object will have its own new context created as well)
61
73
  * @param initialState - The initial state to provide to the created component.
74
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
62
75
  * @returns an object created by this factory. Data store and objects created are not attached to container.
63
76
  * They get attached only when a handle to one of them is attached to already attached objects.
64
77
  */
65
- createPeerInstance(peerContext: IFluidDataStoreContext, initialState?: I["InitialState"]): Promise<TObj>;
78
+ createPeerInstance(peerContext: IFluidDataStoreContext, initialState?: I["InitialState"], loadingGroupId?: string): Promise<TObj>;
66
79
  /**
67
80
  * Creates a new instance of the object. Uses container's registry to find this factory.
68
81
  * It's expected that only container owners would use this functionality, as only such developers
@@ -70,10 +83,24 @@ export declare class PureDataObjectFactory<TObj extends PureDataObject<I>, I ext
70
83
  * The name in this registry for such record should match type of this factory.
71
84
  * @param runtime - container runtime. It's registry is used to create an object.
72
85
  * @param initialState - The initial state to provide to the created component.
86
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
73
87
  * @returns an object created by this factory. Data store and objects created are not attached to container.
74
88
  * They get attached only when a handle to one of them is attached to already attached objects.
75
89
  */
76
- createInstance(runtime: IContainerRuntimeBase, initialState?: I["InitialState"]): Promise<TObj>;
90
+ createInstance(runtime: IContainerRuntimeBase, initialState?: I["InitialState"], loadingGroupId?: string): Promise<TObj>;
91
+ /**
92
+ * Creates a new instance of the object with a datastore which exposes the aliasing api.
93
+ * @param runtime - container runtime. It is the runtime that will be used to create the object. It will produce
94
+ * the underlying infrastructure to get the data object to operate.
95
+ * @param initialState - The initial state to provide to the created component.
96
+ * @param packagePath - The path to the data store factory to use to create the data object.
97
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
98
+ * @returns an array containing the object created by this factory and an IDataStore object that enables users to
99
+ * alias the data object.
100
+ * The data object is attached only when it is attached to the handle graph that connects to an aliased object or
101
+ * when the data object is aliased.
102
+ */
103
+ createInstanceWithDataStore(containerRuntime: IContainerRuntimeBase, initialState?: I["InitialState"], packagePath?: Readonly<string[]>, loadingGroupId?: string): Promise<[TObj, IDataStore]>;
77
104
  /**
78
105
  * Creates a new root instance of the object. Uses container's registry to find this factory.
79
106
  * It's expected that only container owners would use this functionality, as only such developers
@@ -83,9 +110,12 @@ export declare class PureDataObjectFactory<TObj extends PureDataObject<I>, I ext
83
110
  * @param initialState - The initial state to provide to the created component.
84
111
  * @returns an object created by this factory. Data store and objects created are not attached to container.
85
112
  * They get attached only when a handle to one of them is attached to already attached objects.
113
+ *
114
+ * @deprecated - the issue is that it does not allow the customer to decide the conflict resolution policy when an
115
+ * aliasing conflict occurs. Use {@link PureDataObjectFactory.createInstanceWithDataStore} instead.
86
116
  */
87
117
  createRootInstance(rootDataStoreId: string, runtime: IContainerRuntime, initialState?: I["InitialState"]): Promise<TObj>;
88
- protected createNonRootInstanceCore(containerRuntime: IContainerRuntimeBase, packagePath: Readonly<string[]>, initialState?: I["InitialState"]): Promise<TObj>;
118
+ protected createNonRootInstanceCore(containerRuntime: IContainerRuntimeBase, packagePath: Readonly<string[]>, initialState?: I["InitialState"], loadingGroupId?: string): Promise<TObj>;
89
119
  protected createInstanceCore(context: IFluidDataStoreContextDetached, initialState?: I["InitialState"]): Promise<TObj>;
90
120
  }
91
121
  //# sourceMappingURL=pureDataObjectFactory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pureDataObjectFactory.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,qBAAqB,EAGrB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,kCAAkC,EAClC,gCAAgC,EAChC,8BAA8B,EAC9B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,eAAe,E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68
68
  * @alpha
69
69
  */
70
70
  class PureDataObjectFactory {
71
- constructor(type, ctor, sharedObjects, optionalProviders, registryEntries, runtimeClass = datastore_1.FluidDataStoreRuntime) {
71
+ constructor(
72
+ /**
73
+ * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory."type"}
74
+ */
75
+ type, ctor, sharedObjects, optionalProviders, registryEntries, runtimeClass = datastore_1.FluidDataStoreRuntime) {
72
76
  this.type = type;
73
77
  this.ctor = ctor;
74
78
  this.optionalProviders = optionalProviders;
@@ -81,9 +85,15 @@ class PureDataObjectFactory {
81
85
  }
82
86
  this.sharedObjectRegistry = new Map(sharedObjects.map((ext) => [ext.type, ext]));
83
87
  }
88
+ /**
89
+ * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreFactory.IFluidDataStoreFactory}
90
+ */
84
91
  get IFluidDataStoreFactory() {
85
92
  return this;
86
93
  }
94
+ /**
95
+ * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreRegistry.IFluidDataStoreRegistry}
96
+ */
87
97
  get IFluidDataStoreRegistry() {
88
98
  return this.registry;
89
99
  }
@@ -97,9 +107,7 @@ class PureDataObjectFactory {
97
107
  return [this.type, Promise.resolve(this)];
98
108
  }
99
109
  /**
100
- * This is where we do data store setup.
101
- *
102
- * @param context - data store context used to load a data store runtime
110
+ * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory.instantiateDataStore}
103
111
  */
104
112
  async instantiateDataStore(context, existing) {
105
113
  const { runtime } = await createDataObject(this.ctor, context, this.sharedObjectRegistry, this.optionalProviders, this.runtimeClass, existing);
@@ -113,11 +121,12 @@ class PureDataObjectFactory {
113
121
  * @param context - The context being used to create the runtime
114
122
  * (the created object will have its own new context created as well)
115
123
  * @param initialState - The initial state to provide to the created data store.
124
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
116
125
  * @returns an object created by this factory. Data store and objects created are not attached to container.
117
126
  * They get attached only when a handle to one of them is attached to already attached objects.
118
127
  */
119
- async createChildInstance(parentContext, initialState) {
120
- return this.createNonRootInstanceCore(parentContext.containerRuntime, [...parentContext.packagePath, this.type], initialState);
128
+ async createChildInstance(parentContext, initialState, loadingGroupId) {
129
+ return this.createNonRootInstanceCore(parentContext.containerRuntime, [...parentContext.packagePath, this.type], initialState, loadingGroupId);
121
130
  }
122
131
  /**
123
132
  * Creates a new instance of the object. Uses peer context's registry and its package path to identify this factory.
@@ -126,11 +135,12 @@ class PureDataObjectFactory {
126
135
  * @param context - The component context being used to create the object
127
136
  * (the created object will have its own new context created as well)
128
137
  * @param initialState - The initial state to provide to the created component.
138
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
129
139
  * @returns an object created by this factory. Data store and objects created are not attached to container.
130
140
  * They get attached only when a handle to one of them is attached to already attached objects.
131
141
  */
132
- async createPeerInstance(peerContext, initialState) {
133
- return this.createNonRootInstanceCore(peerContext.containerRuntime, peerContext.packagePath, initialState);
142
+ async createPeerInstance(peerContext, initialState, loadingGroupId) {
143
+ return this.createNonRootInstanceCore(peerContext.containerRuntime, peerContext.packagePath, initialState, loadingGroupId);
134
144
  }
135
145
  /**
136
146
  * Creates a new instance of the object. Uses container's registry to find this factory.
@@ -139,11 +149,31 @@ class PureDataObjectFactory {
139
149
  * The name in this registry for such record should match type of this factory.
140
150
  * @param runtime - container runtime. It's registry is used to create an object.
141
151
  * @param initialState - The initial state to provide to the created component.
152
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
142
153
  * @returns an object created by this factory. Data store and objects created are not attached to container.
143
154
  * They get attached only when a handle to one of them is attached to already attached objects.
144
155
  */
145
- async createInstance(runtime, initialState) {
146
- return this.createNonRootInstanceCore(runtime, [this.type], initialState);
156
+ async createInstance(runtime, initialState, loadingGroupId) {
157
+ return this.createNonRootInstanceCore(runtime, [this.type], initialState, loadingGroupId);
158
+ }
159
+ /**
160
+ * Creates a new instance of the object with a datastore which exposes the aliasing api.
161
+ * @param runtime - container runtime. It is the runtime that will be used to create the object. It will produce
162
+ * the underlying infrastructure to get the data object to operate.
163
+ * @param initialState - The initial state to provide to the created component.
164
+ * @param packagePath - The path to the data store factory to use to create the data object.
165
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
166
+ * @returns an array containing the object created by this factory and an IDataStore object that enables users to
167
+ * alias the data object.
168
+ * The data object is attached only when it is attached to the handle graph that connects to an aliased object or
169
+ * when the data object is aliased.
170
+ */
171
+ async createInstanceWithDataStore(containerRuntime, initialState, packagePath, loadingGroupId) {
172
+ const context = containerRuntime.createDetachedDataStore(packagePath ?? [this.type], loadingGroupId);
173
+ const { instance, runtime } = await createDataObject(this.ctor, context, this.sharedObjectRegistry, this.optionalProviders, this.runtimeClass, false, // existing
174
+ initialState);
175
+ const dataStore = await context.attachRuntime(this, runtime);
176
+ return [instance, dataStore];
147
177
  }
148
178
  /**
149
179
  * Creates a new root instance of the object. Uses container's registry to find this factory.
@@ -154,13 +184,25 @@ class PureDataObjectFactory {
154
184
  * @param initialState - The initial state to provide to the created component.
155
185
  * @returns an object created by this factory. Data store and objects created are not attached to container.
156
186
  * They get attached only when a handle to one of them is attached to already attached objects.
187
+ *
188
+ * @deprecated - the issue is that it does not allow the customer to decide the conflict resolution policy when an
189
+ * aliasing conflict occurs. Use {@link PureDataObjectFactory.createInstanceWithDataStore} instead.
157
190
  */
158
191
  async createRootInstance(rootDataStoreId, runtime, initialState) {
159
- const context = runtime.createDetachedRootDataStore([this.type], rootDataStoreId);
160
- return this.createInstanceCore(context, initialState);
192
+ const context = runtime.createDetachedDataStore([this.type]);
193
+ const { instance, runtime: dataStoreRuntime } = await createDataObject(this.ctor, context, this.sharedObjectRegistry, this.optionalProviders, this.runtimeClass, false, // existing
194
+ initialState);
195
+ const dataStore = await context.attachRuntime(this, dataStoreRuntime);
196
+ const result = await dataStore.trySetAlias(rootDataStoreId);
197
+ if (result !== "Success") {
198
+ const handle = await runtime.getAliasedDataStoreEntryPoint(rootDataStoreId);
199
+ (0, core_utils_1.assert)(handle !== undefined, 0x8e1 /* Should have retrieved aliased handle */);
200
+ return (await handle.get());
201
+ }
202
+ return instance;
161
203
  }
162
- async createNonRootInstanceCore(containerRuntime, packagePath, initialState) {
163
- const context = containerRuntime.createDetachedDataStore(packagePath);
204
+ async createNonRootInstanceCore(containerRuntime, packagePath, initialState, loadingGroupId) {
205
+ const context = containerRuntime.createDetachedDataStore(packagePath, loadingGroupId);
164
206
  return this.createInstanceCore(context, initialState);
165
207
  }
166
208
  async createInstanceCore(context, initialState) {
@@ -1 +1 @@
1
- {"version":3,"file":"pureDataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yDAImC;AACnC,yEAA2E;AAmB3E,2DAAoD;AAGpD;;;GAGG;AACH,KAAK,UAAU,gBAAgB,CAI9B,IAA8C,EAC9C,OAA+B,EAC/B,oBAA2C,EAC3C,iBAAoE,EACpE,eAA6C,EAC7C,QAAiB,EACjB,SAA6B;IAE7B,OAAO;IACP,IAAI,YAAY,GAAG,eAAe,CAAC;IAEnC,mBAAmB;IACnB,YAAY,GAAG,IAAA,+BAAmB,EACjC,KAAK,EAAE,OAAiB,EAAE,UAAiC,EAAE,EAAE;QAC9D,iFAAiF;QACjF,MAAM,UAAU,GAAG,CAAC,MAAM,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,CAAS,CAAC;QAC/D,IAAA,mBAAM,EACL,UAAU,CAAC,OAAO,KAAK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AAoB,EACzB,IAAI,CAAC,iBAAiB,EACtB,IAAI,CAAC,YAAY,EACjB,KAAK,EAAE,WAAW;QAClB,YAAY,CACZ,CAAC;QAEF,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE3C,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD;AAxKD,sDAwKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest, FluidObject } from \"@fluidframework/core-interfaces\";\nimport {\n\tFluidDataStoreRuntime,\n\tISharedObjectRegistry,\n\tmixinRequestHandler,\n} from \"@fluidframework/datastore\";\nimport { FluidDataStoreRegistry } from \"@fluidframework/container-runtime\";\nimport {\n\tIFluidDataStoreContext,\n\tIContainerRuntimeBase,\n\tIFluidDataStoreFactory,\n\tIFluidDataStoreRegistry,\n\tIProvideFluidDataStoreRegistry,\n\tNamedFluidDataStoreRegistryEntries,\n\tNamedFluidDataStoreRegistryEntry,\n\tIFluidDataStoreContextDetached,\n} from \"@fluidframework/runtime-definitions\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IChannelFactory, IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport {\n\tAsyncFluidObjectProvider,\n\tFluidObjectSymbolProvider,\n\tIFluidDependencySynthesizer,\n} from \"@fluidframework/synthesize\";\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IDataObjectProps, PureDataObject, DataObjectTypes } from \"../data-objects\";\n\n/**\n * Proxy over PureDataObject\n * Does delayed creation & initialization of PureDataObject\n */\nasync function createDataObject<\n\tTObj extends PureDataObject,\n\tI extends DataObjectTypes = DataObjectTypes,\n>(\n\tctor: new (props: IDataObjectProps<I>) => TObj,\n\tcontext: IFluidDataStoreContext,\n\tsharedObjectRegistry: ISharedObjectRegistry,\n\toptionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n\truntimeClassArg: typeof FluidDataStoreRuntime,\n\texisting: boolean,\n\tinitProps?: I[\"InitialState\"],\n) {\n\t// base\n\tlet runtimeClass = runtimeClassArg;\n\n\t// request mixin in\n\truntimeClass = mixinRequestHandler(\n\t\tasync (request: IRequest, runtimeArg: FluidDataStoreRuntime) => {\n\t\t\t// The provideEntryPoint callback below always returns TObj, so this cast is safe\n\t\t\tconst dataObject = (await runtimeArg.entryPoint.get()) as TObj;\n\t\t\tassert(\n\t\t\t\tdataObject.request !== undefined,\n\t\t\t\t0x795 /* Data store runtime entryPoint does not have request */,\n\t\t\t);\n\t\t\treturn dataObject.request(request);\n\t\t},\n\t\truntimeClass,\n\t);\n\n\t// Create a new runtime for our data store, as if via new FluidDataStoreRuntime,\n\t// but using the runtimeClass that's been augmented with mixins\n\t// The runtime is what Fluid uses to create DDS' and route to your data store\n\tconst runtime: FluidDataStoreRuntime = new runtimeClass( // calls new FluidDataStoreRuntime(...)\n\t\tcontext,\n\t\tsharedObjectRegistry,\n\t\texisting,\n\t\tasync (rt: IFluidDataStoreRuntime) => {\n\t\t\tassert(instance !== undefined, 0x46a /* entryPoint is undefined */);\n\t\t\t// Calling finishInitialization here like PureDataObject.getDataObject did, to keep the same behavior,\n\t\t\t// since accessing the runtime's entryPoint is how we want the data object to be retrieved going forward.\n\t\t\t// Without this I ran into issues with the load-existing flow not working correctly.\n\t\t\tawait instance.finishInitialization(true);\n\t\t\treturn instance;\n\t\t} /* provideEntryPoint */,\n\t);\n\n\t// Create object right away.\n\t// This allows object to register various callbacks with runtime before runtime\n\t// becomes globally available. But it's not full initialization - constructor can't\n\t// access DDSes or other services of runtime as objects are not fully initialized.\n\t// In order to use object, we need to go through full initialization by calling finishInitialization().\n\tconst scope: FluidObject<IFluidDependencySynthesizer> = context.scope;\n\tconst providers =\n\t\tscope.IFluidDependencySynthesizer?.synthesize<I[\"OptionalProviders\"]>(\n\t\t\toptionalProviders,\n\t\t\t{},\n\t\t) ??\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t({} as AsyncFluidObjectProvider<never>);\n\n\tconst instance = new ctor({ runtime, context, providers, initProps });\n\n\t// if it's a newly created object, we need to wait for it to finish initialization\n\t// as that results in creation of DDSes, before it gets attached, providing atomic\n\t// guarantee of creation.\n\t// WARNING: we can't do the same (yet) for already existing PureDataObject!\n\t// This will result in deadlock, as it tries to resolve internal handles, but any\n\t// handle resolution goes through root (container runtime), which can't route it back\n\t// to this data store, as it's still not initialized and not known to container runtime yet.\n\t// In the future, we should address it by using relative paths for handles and be able to resolve\n\t// local DDSes while data store is not fully initialized.\n\tif (!existing) {\n\t\tawait instance.finishInitialization(existing);\n\t}\n\n\treturn { instance, runtime };\n}\n\n/**\n * PureDataObjectFactory is a barebones IFluidDataStoreFactory for use with PureDataObject.\n * Consumers should typically use DataObjectFactory instead unless creating\n * another base data store factory.\n *\n * @typeParam TObj - DataObject (concrete type)\n * @typeParam I - The input types for the DataObject\n * @alpha\n */\nexport class PureDataObjectFactory<\n\t\tTObj extends PureDataObject<I>,\n\t\tI extends DataObjectTypes = DataObjectTypes,\n\t>\n\timplements IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry>\n{\n\tprivate readonly sharedObjectRegistry: ISharedObjectRegistry;\n\tprivate readonly registry: IFluidDataStoreRegistry | undefined;\n\n\tconstructor(\n\t\tpublic readonly type: string,\n\t\tprivate readonly ctor: new (props: IDataObjectProps<I>) => TObj,\n\t\tsharedObjects: readonly IChannelFactory[],\n\t\tprivate readonly optionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n\t\tregistryEntries?: NamedFluidDataStoreRegistryEntries,\n\t\tprivate readonly runtimeClass: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n\t) {\n\t\tif (this.type === \"\") {\n\t\t\tthrow new Error(\"undefined type member\");\n\t\t}\n\t\tif (registryEntries !== undefined) {\n\t\t\tthis.registry = new FluidDataStoreRegistry(registryEntries);\n\t\t}\n\t\tthis.sharedObjectRegistry = new Map(sharedObjects.map((ext) => [ext.type, ext]));\n\t}\n\n\tpublic get IFluidDataStoreFactory() {\n\t\treturn this;\n\t}\n\n\tpublic get IFluidDataStoreRegistry() {\n\t\treturn this.registry;\n\t}\n\n\t/**\n\t * Convenience helper to get the data store's/factory's data store registry entry.\n\t * The return type hides the factory's generics, easing grouping of registry\n\t * entries that differ only in this way into the same array.\n\t * @returns The NamedFluidDataStoreRegistryEntry\n\t */\n\tpublic get registryEntry(): NamedFluidDataStoreRegistryEntry {\n\t\treturn [this.type, Promise.resolve(this)];\n\t}\n\n\t/**\n\t * This is where we do data store setup.\n\t *\n\t * @param context - data store context used to load a data store runtime\n\t */\n\tpublic async instantiateDataStore(context: IFluidDataStoreContext, existing: boolean) {\n\t\tconst { runtime } = await createDataObject(\n\t\t\tthis.ctor,\n\t\t\tcontext,\n\t\t\tthis.sharedObjectRegistry,\n\t\t\tthis.optionalProviders,\n\t\t\tthis.runtimeClass,\n\t\t\texisting,\n\t\t);\n\n\t\treturn runtime;\n\t}\n\n\t/**\n\t * Creates a new instance of the object. Uses parent context's registry to build package path to this factory.\n\t * In other words, registry of context passed in has to contain this factory, with the name that matches\n\t * this factory's type.\n\t * It is intended to be used by data store objects that create sub-objects.\n\t * @param context - The context being used to create the runtime\n\t * (the created object will have its own new context created as well)\n\t * @param initialState - The initial state to provide to the created data store.\n\t * @returns an object created by this factory. Data store and objects created are not attached to container.\n\t * They get attached only when a handle to one of them is attached to already attached objects.\n\t */\n\tpublic async createChildInstance(\n\t\tparentContext: IFluidDataStoreContext,\n\t\tinitialState?: I[\"InitialState\"],\n\t): Promise<TObj> {\n\t\treturn this.createNonRootInstanceCore(\n\t\t\tparentContext.containerRuntime,\n\t\t\t[...parentContext.packagePath, this.type],\n\t\t\tinitialState,\n\t\t);\n\t}\n\n\t/**\n\t * Creates a new instance of the object. Uses peer context's registry and its package path to identify this factory.\n\t * In other words, registry of context passed in has to have this factory.\n\t * Intended to be used by data store objects that need to create peers (similar) instances of existing objects.\n\t * @param context - The component context being used to create the object\n\t * (the created object will have its own new context created as well)\n\t * @param initialState - The initial state to provide to the created component.\n\t * @returns an object created by this factory. Data store and objects created are not attached to container.\n\t * They get attached only when a handle to one of them is attached to already attached objects.\n\t */\n\tpublic async createPeerInstance(\n\t\tpeerContext: IFluidDataStoreContext,\n\t\tinitialState?: I[\"InitialState\"],\n\t): Promise<TObj> {\n\t\treturn this.createNonRootInstanceCore(\n\t\t\tpeerContext.containerRuntime,\n\t\t\tpeerContext.packagePath,\n\t\t\tinitialState,\n\t\t);\n\t}\n\n\t/**\n\t * Creates a new instance of the object. Uses container's registry to find this factory.\n\t * It's expected that only container owners would use this functionality, as only such developers\n\t * have knowledge of entries in container registry.\n\t * The name in this registry for such record should match type of this factory.\n\t * @param runtime - container runtime. It's registry is used to create an object.\n\t * @param initialState - The initial state to provide to the created component.\n\t * @returns an object created by this factory. Data store and objects created are not attached to container.\n\t * They get attached only when a handle to one of them is attached to already attached objects.\n\t */\n\tpublic async createInstance(\n\t\truntime: IContainerRuntimeBase,\n\t\tinitialState?: I[\"InitialState\"],\n\t): Promise<TObj> {\n\t\treturn this.createNonRootInstanceCore(runtime, [this.type], initialState);\n\t}\n\n\t/**\n\t * Creates a new root instance of the object. Uses container's registry to find this factory.\n\t * It's expected that only container owners would use this functionality, as only such developers\n\t * have knowledge of entries in container registry.\n\t * The name in this registry for such record should match type of this factory.\n\t * @param runtime - container runtime. It's registry is used to create an object.\n\t * @param initialState - The initial state to provide to the created component.\n\t * @returns an object created by this factory. Data store and objects created are not attached to container.\n\t * They get attached only when a handle to one of them is attached to already attached objects.\n\t */\n\tpublic async createRootInstance(\n\t\trootDataStoreId: string,\n\t\truntime: IContainerRuntime,\n\t\tinitialState?: I[\"InitialState\"],\n\t): Promise<TObj> {\n\t\tconst context = runtime.createDetachedRootDataStore([this.type], rootDataStoreId);\n\t\treturn this.createInstanceCore(context, initialState);\n\t}\n\n\tprotected async createNonRootInstanceCore(\n\t\tcontainerRuntime: IContainerRuntimeBase,\n\t\tpackagePath: Readonly<string[]>,\n\t\tinitialState?: I[\"InitialState\"],\n\t): Promise<TObj> {\n\t\tconst context = containerRuntime.createDetachedDataStore(packagePath);\n\t\treturn this.createInstanceCore(context, initialState);\n\t}\n\n\tprotected async createInstanceCore(\n\t\tcontext: IFluidDataStoreContextDetached,\n\t\tinitialState?: I[\"InitialState\"],\n\t): Promise<TObj> {\n\t\tconst { instance, runtime } = await createDataObject(\n\t\t\tthis.ctor,\n\t\t\tcontext,\n\t\t\tthis.sharedObjectRegistry,\n\t\t\tthis.optionalProviders,\n\t\t\tthis.runtimeClass,\n\t\t\tfalse, // existing\n\t\t\tinitialState,\n\t\t);\n\n\t\tawait context.attachRuntime(this, runtime);\n\n\t\treturn instance;\n\t}\n}\n"]}
1
+ {"version":3,"file":"pureDataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yDAImC;AACnC,yEAA2E;AAwB3E,2DAAoD;AAOpD;;;GAGG;AACH,KAAK,UAAU,gBAAgB,CAI9B,IAA8C,EAC9C,OAA+B,EAC/B,oBAA2C,EAC3C,iBAAoE,EACpE,eAA6C,EAC7C,QAAiB,EACjB,SAA6B;IAK7B,OAAO;IACP,IAAI,YAAY,GAAG,eAAe,CAAC;IAEnC,mBAAmB;IACnB,YAAY,GAAG,IAAA,+BAAmB,EACjC,KAAK,EAAE,OAAiB,EAAE,UAAiC,EAAE,EAAE;QAC9D,iFAAiF;QACjF,MAAM,UAAU,GAAG,CAAC,MAAM,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,CAAS,CAAC;QAC/D,IAAA,mBAAM,EACL,UAAU,CAAC,OAAO,KAAK,SAAS,EAChC,KAAK,CAAC,yDAAyD,CAC/D,CAAC;QACF,OAAO,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC,EACD,YAAY,CACZ,CAAC;IAEF,gFAAgF;IAChF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,YAAY,EACjB,KAAK,EAAE,WAAW;QAClB,YAAY,CACZ,CAAC;QAEF,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE3C,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD;AAlPD,sDAkPC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IRequest, type FluidObject } from \"@fluidframework/core-interfaces\";\nimport {\n\tFluidDataStoreRuntime,\n\ttype ISharedObjectRegistry,\n\tmixinRequestHandler,\n} from \"@fluidframework/datastore\";\nimport { FluidDataStoreRegistry } from \"@fluidframework/container-runtime\";\nimport {\n\ttype IContainerRuntimeBase,\n\ttype IDataStore,\n\ttype IFluidDataStoreChannel,\n\ttype IFluidDataStoreContext,\n\ttype IFluidDataStoreContextDetached,\n\ttype IFluidDataStoreFactory,\n\ttype IFluidDataStoreRegistry,\n\ttype NamedFluidDataStoreRegistryEntries,\n\ttype NamedFluidDataStoreRegistryEntry,\n\ttype IProvideFluidDataStoreRegistry,\n} from \"@fluidframework/runtime-definitions\";\nimport { type IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport {\n\ttype IChannelFactory,\n\ttype IFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n\ttype AsyncFluidObjectProvider,\n\ttype FluidObjectSymbolProvider,\n\ttype IFluidDependencySynthesizer,\n} from \"@fluidframework/synthesize\";\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\ttype IDataObjectProps,\n\ttype PureDataObject,\n\ttype DataObjectTypes,\n} from \"../data-objects/index.js\";\n\n/**\n * Proxy over PureDataObject\n * Does delayed creation & initialization of PureDataObject\n */\nasync function createDataObject<\n\tTObj extends PureDataObject,\n\tI extends DataObjectTypes = DataObjectTypes,\n>(\n\tctor: new (props: IDataObjectProps<I>) => TObj,\n\tcontext: IFluidDataStoreContext,\n\tsharedObjectRegistry: ISharedObjectRegistry,\n\toptionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n\truntimeClassArg: typeof FluidDataStoreRuntime,\n\texisting: boolean,\n\tinitProps?: I[\"InitialState\"],\n): Promise<{\n\tinstance: TObj;\n\truntime: FluidDataStoreRuntime;\n}> {\n\t// base\n\tlet runtimeClass = runtimeClassArg;\n\n\t// request mixin in\n\truntimeClass = mixinRequestHandler(\n\t\tasync (request: IRequest, runtimeArg: FluidDataStoreRuntime) => {\n\t\t\t// The provideEntryPoint callback below always returns TObj, so this cast is safe\n\t\t\tconst dataObject = (await runtimeArg.entryPoint.get()) as TObj;\n\t\t\tassert(\n\t\t\t\tdataObject.request !== undefined,\n\t\t\t\t0x795 /* Data store runtime entryPoint does not have request */,\n\t\t\t);\n\t\t\treturn dataObject.request(request);\n\t\t},\n\t\truntimeClass,\n\t);\n\n\t// Create a new runtime for our data store, as if via new FluidDataStoreRuntime,\n\t// but using the runtimeClass that's been augmented with mixins\n\t// The runtime is what Fluid uses to create DDS' and route to your data store\n\tconst runtime: FluidDataStoreRuntime = new runtimeClass( // calls new FluidDataStoreRuntime(...)\n\t\tcontext,\n\t\tsharedObjectRegistry,\n\t\texisting,\n\t\tasync (rt: IFluidDataStoreRuntime) => {\n\t\t\tassert(instance !== undefined, 0x46a /* entryPoint is undefined */);\n\t\t\t// Calling finishInitialization here like PureDataObject.getDataObject did, to keep the same behavior,\n\t\t\t// since accessing the runtime's entryPoint is how we want the data object to be retrieved going forward.\n\t\t\t// Without this I ran into issues with the load-existing flow not working correctly.\n\t\t\tawait instance.finishInitialization(true);\n\t\t\treturn instance;\n\t\t} /* provideEntryPoint */,\n\t);\n\n\t// Create object right away.\n\t// This allows object to register various callbacks with runtime before runtime\n\t// becomes globally available. But it's not full initialization - constructor can't\n\t// access DDSes or other services of runtime as objects are not fully initialized.\n\t// In order to use object, we need to go through full initialization by calling finishInitialization().\n\tconst scope: FluidObject<IFluidDependencySynthesizer> = context.scope;\n\tconst providers =\n\t\tscope.IFluidDependencySynthesizer?.synthesize<I[\"OptionalProviders\"]>(\n\t\t\toptionalProviders,\n\t\t\t{},\n\t\t) ??\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t({} as AsyncFluidObjectProvider<never>);\n\n\tconst instance = new ctor({ runtime, context, providers, initProps });\n\n\t// if it's a newly created object, we need to wait for it to finish initialization\n\t// as that results in creation of DDSes, before it gets attached, providing atomic\n\t// guarantee of creation.\n\t// WARNING: we can't do the same (yet) for already existing PureDataObject!\n\t// This will result in deadlock, as it tries to resolve internal handles, but any\n\t// handle resolution goes through root (container runtime), which can't route it back\n\t// to this data store, as it's still not initialized and not known to container runtime yet.\n\t// In the future, we should address it by using relative paths for handles and be able to resolve\n\t// local DDSes while data store is not fully initialized.\n\tif (!existing) {\n\t\tawait instance.finishInitialization(existing);\n\t}\n\n\treturn { instance, runtime };\n}\n\n/**\n * PureDataObjectFactory is a barebones IFluidDataStoreFactory for use with PureDataObject.\n * Consumers should typically use DataObjectFactory instead unless creating\n * another base data store factory.\n *\n * @typeParam TObj - DataObject (concrete type)\n * @typeParam I - The input types for the DataObject\n * @alpha\n */\nexport class PureDataObjectFactory<\n\t\tTObj extends PureDataObject<I>,\n\t\tI extends DataObjectTypes = DataObjectTypes,\n\t>\n\timplements IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry>\n{\n\tprivate readonly sharedObjectRegistry: ISharedObjectRegistry;\n\tprivate readonly registry: IFluidDataStoreRegistry | undefined;\n\n\tpublic constructor(\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory.\"type\"}\n\t\t */\n\t\tpublic readonly type: string,\n\t\tprivate readonly ctor: new (props: IDataObjectProps<I>) => TObj,\n\t\tsharedObjects: readonly IChannelFactory[],\n\t\tprivate readonly optionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n\t\tregistryEntries?: NamedFluidDataStoreRegistryEntries,\n\t\tprivate readonly runtimeClass: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n\t) {\n\t\tif (this.type === \"\") {\n\t\t\tthrow new Error(\"undefined type member\");\n\t\t}\n\t\tif (registryEntries !== undefined) {\n\t\t\tthis.registry = new FluidDataStoreRegistry(registryEntries);\n\t\t}\n\t\tthis.sharedObjectRegistry = new Map(sharedObjects.map((ext) => [ext.type, ext]));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreFactory.IFluidDataStoreFactory}\n\t */\n\tpublic get IFluidDataStoreFactory(): this {\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreRegistry.IFluidDataStoreRegistry}\n\t */\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry | undefined {\n\t\treturn this.registry;\n\t}\n\n\t/**\n\t * Convenience helper to get the data store's/factory's data store registry entry.\n\t * The return type hides the factory's generics, easing grouping of registry\n\t * entries that differ only in this way into the same array.\n\t * @returns The NamedFluidDataStoreRegistryEntry\n\t */\n\tpublic get registryEntry(): NamedFluidDataStoreRegistryEntry {\n\t\treturn [this.type, Promise.resolve(this)];\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory.instantiateDataStore}\n\t */\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<IFluidDataStoreChannel> {\n\t\tconst { runtime } = await createDataObject(\n\t\t\tthis.ctor,\n\t\t\tcontext,\n\t\t\tthis.sharedObjectRegistry,\n\t\t\tthis.optionalProviders,\n\t\t\tthis.runtimeClass,\n\t\t\texisting,\n\t\t);\n\n\t\treturn runtime;\n\t}\n\n\t/**\n\t * Creates a new instance of the object. Uses parent context's registry to build package path to this factory.\n\t * In other words, registry of context passed in has to contain this factory, with the name that matches\n\t * this factory's type.\n\t * It is intended to be used by data store objects that create sub-objects.\n\t * @param context - The context being used to create the runtime\n\t * (the created object will have its own new context created as well)\n\t * @param initialState - The initial state to provide to the created data store.\n\t * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services\n\t * @returns an object created by this factory. Data store and objects created are not attached to container.\n\t * They get attached only when a handle to one of them is attached to already attached objects.\n\t */\n\tpublic async createChildInstance(\n\t\tparentContext: IFluidDataStoreContext,\n\t\tinitialState?: I[\"InitialState\"],\n\t\tloadingGroupId?: string,\n\t): Promise<TObj> {\n\t\treturn this.createNonRootInstanceCore(\n\t\t\tparentContext.containerRuntime,\n\t\t\t[...parentContext.packagePath, this.type],\n\t\t\tinitialState,\n\t\t\tloadingGroupId,\n\t\t);\n\t}\n\n\t/**\n\t * Creates a new instance of the object. Uses peer context's registry and its package path to identify this factory.\n\t * In other words, registry of context passed in has to have this factory.\n\t * Intended to be used by data store objects that need to create peers (similar) instances of existing objects.\n\t * @param context - The component context being used to create the object\n\t * (the created object will have its own new context created as well)\n\t * @param initialState - The initial state to provide to the created component.\n\t * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services\n\t * @returns an object created by this factory. Data store and objects created are not attached to container.\n\t * They get attached only when a handle to one of them is attached to already attached objects.\n\t */\n\tpublic async createPeerInstance(\n\t\tpeerContext: IFluidDataStoreContext,\n\t\tinitialState?: I[\"InitialState\"],\n\t\tloadingGroupId?: string, // DO NOT USE, this is an experimental feature\n\t): Promise<TObj> {\n\t\treturn this.createNonRootInstanceCore(\n\t\t\tpeerContext.containerRuntime,\n\t\t\tpeerContext.packagePath,\n\t\t\tinitialState,\n\t\t\tloadingGroupId,\n\t\t);\n\t}\n\n\t/**\n\t * Creates a new instance of the object. Uses container's registry to find this factory.\n\t * It's expected that only container owners would use this functionality, as only such developers\n\t * have knowledge of entries in container registry.\n\t * The name in this registry for such record should match type of this factory.\n\t * @param runtime - container runtime. It's registry is used to create an object.\n\t * @param initialState - The initial state to provide to the created component.\n\t * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services\n\t * @returns an object created by this factory. Data store and objects created are not attached to container.\n\t * They get attached only when a handle to one of them is attached to already attached objects.\n\t */\n\tpublic async createInstance(\n\t\truntime: IContainerRuntimeBase,\n\t\tinitialState?: I[\"InitialState\"],\n\t\tloadingGroupId?: string,\n\t): Promise<TObj> {\n\t\treturn this.createNonRootInstanceCore(runtime, [this.type], initialState, loadingGroupId);\n\t}\n\n\t/**\n\t * Creates a new instance of the object with a datastore which exposes the aliasing api.\n\t * @param runtime - container runtime. It is the runtime that will be used to create the object. It will produce\n\t * the underlying infrastructure to get the data object to operate.\n\t * @param initialState - The initial state to provide to the created component.\n\t * @param packagePath - The path to the data store factory to use to create the data object.\n\t * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services\n\t * @returns an array containing the object created by this factory and an IDataStore object that enables users to\n\t * alias the data object.\n\t * The data object is attached only when it is attached to the handle graph that connects to an aliased object or\n\t * when the data object is aliased.\n\t */\n\tpublic async createInstanceWithDataStore(\n\t\tcontainerRuntime: IContainerRuntimeBase,\n\t\tinitialState?: I[\"InitialState\"],\n\t\tpackagePath?: Readonly<string[]>,\n\t\tloadingGroupId?: string,\n\t): Promise<[TObj, IDataStore]> {\n\t\tconst context = containerRuntime.createDetachedDataStore(\n\t\t\tpackagePath ?? [this.type],\n\t\t\tloadingGroupId,\n\t\t);\n\t\tconst { instance, runtime } = await createDataObject(\n\t\t\tthis.ctor,\n\t\t\tcontext,\n\t\t\tthis.sharedObjectRegistry,\n\t\t\tthis.optionalProviders,\n\t\t\tthis.runtimeClass,\n\t\t\tfalse, // existing\n\t\t\tinitialState,\n\t\t);\n\t\tconst dataStore = await context.attachRuntime(this, runtime);\n\n\t\treturn [instance, dataStore];\n\t}\n\n\t/**\n\t * Creates a new root instance of the object. Uses container's registry to find this factory.\n\t * It's expected that only container owners would use this functionality, as only such developers\n\t * have knowledge of entries in container registry.\n\t * The name in this registry for such record should match type of this factory.\n\t * @param runtime - container runtime. It's registry is used to create an object.\n\t * @param initialState - The initial state to provide to the created component.\n\t * @returns an object created by this factory. Data store and objects created are not attached to container.\n\t * They get attached only when a handle to one of them is attached to already attached objects.\n\t *\n\t * @deprecated - the issue is that it does not allow the customer to decide the conflict resolution policy when an\n\t * aliasing conflict occurs. Use {@link PureDataObjectFactory.createInstanceWithDataStore} instead.\n\t */\n\tpublic async createRootInstance(\n\t\trootDataStoreId: string,\n\t\truntime: IContainerRuntime,\n\t\tinitialState?: I[\"InitialState\"],\n\t): Promise<TObj> {\n\t\tconst context = runtime.createDetachedDataStore([this.type]);\n\t\tconst { instance, runtime: dataStoreRuntime } = await createDataObject(\n\t\t\tthis.ctor,\n\t\t\tcontext,\n\t\t\tthis.sharedObjectRegistry,\n\t\t\tthis.optionalProviders,\n\t\t\tthis.runtimeClass,\n\t\t\tfalse, // existing\n\t\t\tinitialState,\n\t\t);\n\t\tconst dataStore = await context.attachRuntime(this, dataStoreRuntime);\n\t\tconst result = await dataStore.trySetAlias(rootDataStoreId);\n\t\tif (result !== \"Success\") {\n\t\t\tconst handle = await runtime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\tassert(handle !== undefined, 0x8e1 /* Should have retrieved aliased handle */);\n\t\t\treturn (await handle.get()) as TObj;\n\t\t}\n\t\treturn instance;\n\t}\n\n\tprotected async createNonRootInstanceCore(\n\t\tcontainerRuntime: IContainerRuntimeBase,\n\t\tpackagePath: Readonly<string[]>,\n\t\tinitialState?: I[\"InitialState\"],\n\t\tloadingGroupId?: string,\n\t): Promise<TObj> {\n\t\tconst context = containerRuntime.createDetachedDataStore(packagePath, loadingGroupId);\n\t\treturn this.createInstanceCore(context, initialState);\n\t}\n\n\tprotected async createInstanceCore(\n\t\tcontext: IFluidDataStoreContextDetached,\n\t\tinitialState?: I[\"InitialState\"],\n\t): Promise<TObj> {\n\t\tconst { instance, runtime } = await createDataObject(\n\t\t\tthis.ctor,\n\t\t\tcontext,\n\t\t\tthis.sharedObjectRegistry,\n\t\t\tthis.optionalProviders,\n\t\t\tthis.runtimeClass,\n\t\t\tfalse, // existing\n\t\t\tinitialState,\n\t\t);\n\n\t\tawait context.attachRuntime(this, runtime);\n\n\t\treturn instance;\n\t}\n}\n"]}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ISharedDirectory } from "@fluidframework/map";
6
- import { PureDataObject } from "./pureDataObject";
7
- import { DataObjectTypes } from "./types";
5
+ import { type ISharedDirectory } from "@fluidframework/map";
6
+ import { PureDataObject } from "./pureDataObject.js";
7
+ import { type DataObjectTypes } from "./types.js";
8
8
  /**
9
9
  * DataObject is a base data store that is primed with a root directory. It
10
10
  * ensures that it is created and ready before you can access it.
@@ -1 +1 @@
1
- {"version":3,"file":"dataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAA+B,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;;GAUG;AACH,8BAAsB,UAAU,CAC/B,CAAC,SAAS,eAAe,GAAG,eAAe,CAC1C,SAAQ,cAAc,CAAC,CAAC,CAAC;IAC1B,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;IAE1C;;;OAGG;IACH,SAAS,KAAK,IAAI,IAAI,gBAAgB,CAMrC;IAED;;;OAGG;IACU,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BjE;;;OAGG;IACH,SAAS,CAAC,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAG3D"}
1
+ {"version":3,"file":"dataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,gBAAgB,EAA+B,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;;;;;GAUG;AACH,8BAAsB,UAAU,CAC/B,CAAC,SAAS,eAAe,GAAG,eAAe,CAC1C,SAAQ,cAAc,CAAC,CAAC,CAAC;IAC1B,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;IAE1C;;;OAGG;IACH,SAAS,KAAK,IAAI,IAAI,gBAAgB,CAMrC;IAED;;;OAGG;IACU,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BjE;;;OAGG;IACH,SAAS,CAAC,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAG3D"}
@@ -6,7 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.DataObject = void 0;
8
8
  const map_1 = require("@fluidframework/map");
9
- const pureDataObject_1 = require("./pureDataObject");
9
+ const pureDataObject_js_1 = require("./pureDataObject.js");
10
10
  /**
11
11
  * DataObject is a base data store that is primed with a root directory. It
12
12
  * ensures that it is created and ready before you can access it.
@@ -18,7 +18,7 @@ const pureDataObject_1 = require("./pureDataObject");
18
18
  * @typeParam I - The optional input types used to strongly type the data object
19
19
  * @alpha
20
20
  */
21
- class DataObject extends pureDataObject_1.PureDataObject {
21
+ class DataObject extends pureDataObject_js_1.PureDataObject {
22
22
  constructor() {
23
23
  super(...arguments);
24
24
  this.rootDirectoryId = "root";
@@ -38,12 +38,7 @@ class DataObject extends pureDataObject_1.PureDataObject {
38
38
  * Caller is responsible for ensuring this is only invoked once.
39
39
  */
40
40
  async initializeInternal(existing) {
41
- if (!existing) {
42
- // Create a root directory and register it before calling initializingFirstTime
43
- this.internalRoot = map_1.SharedDirectory.create(this.runtime, this.rootDirectoryId);
44
- this.internalRoot.bindToContext();
45
- }
46
- else {
41
+ if (existing) {
47
42
  // data store has a root directory so we just need to set it before calling initializingFromExisting
48
43
  this.internalRoot = (await this.runtime.getChannel(this.rootDirectoryId));
49
44
  // This will actually be an ISharedMap if the channel was previously created by the older version of
@@ -57,6 +52,11 @@ class DataObject extends pureDataObject_1.PureDataObject {
57
52
  });
58
53
  }
59
54
  }
55
+ else {
56
+ // Create a root directory and register it before calling initializingFirstTime
57
+ this.internalRoot = map_1.SharedDirectory.create(this.runtime, this.rootDirectoryId);
58
+ this.internalRoot.bindToContext();
59
+ }
60
60
  await super.initializeInternal(existing);
61
61
  }
62
62
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAAoF;AACpF,qDAAkD;AAGlD;;;;;;;;;;GAUG;AACH,MAAsB,UAEpB,SAAQ,+BAAiB;IAF3B;;QAIkB,oBAAe,GAAG,MAAM,CAAC;IAoD3C,CAAC;IAlDA;;;OAGG;IACH,IAAc,IAAI;QACjB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC;SAC1D;QAED,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,kBAAkB,CAAC,QAAiB;QAChD,IAAI,CAAC,QAAQ,EAAE;YACd,+EAA+E;YAC/E,IAAI,CAAC,YAAY,GAAG,qBAAe,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;YAC/E,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,CAAC;SAClC;aAAM;YACN,oGAAoG;YACpG,IAAI,CAAC,YAAY,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CACjD,IAAI,CAAC,eAAe,CACpB,CAAqB,CAAC;YAEvB,oGAAoG;YACpG,gGAAgG;YAChG,qGAAqG;YACrG,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,KAAK,gBAAU,CAAC,IAAI,EAAE;gBAC1D,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;oBACxB,QAAQ,EAAE,SAAS;oBACnB,SAAS,EAAE,eAAe;oBAC1B,OAAO,EACN,6EAA6E;iBAC9E,CAAC,CAAC;aACH;SACD;QAED,MAAM,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACO,2BAA2B,CAAC,IAAY;QACjD,OAAO,GAAG,IAAI,6CAA6C,CAAC;IAC7D,CAAC;CACD;AAxDD,gCAwDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISharedDirectory, MapFactory, SharedDirectory } from \"@fluidframework/map\";\nimport { PureDataObject } from \"./pureDataObject\";\nimport { DataObjectTypes } from \"./types\";\n\n/**\n * DataObject is a base data store that is primed with a root directory. It\n * ensures that it is created and ready before you can access it.\n *\n * Having a single root directory allows for easier development. Instead of creating\n * and registering channels with the runtime any new DDS that is set on the root\n * will automatically be registered.\n *\n * @typeParam I - The optional input types used to strongly type the data object\n * @alpha\n */\nexport abstract class DataObject<\n\tI extends DataObjectTypes = DataObjectTypes,\n> extends PureDataObject<I> {\n\tprivate internalRoot: ISharedDirectory | undefined;\n\tprivate readonly rootDirectoryId = \"root\";\n\n\t/**\n\t * The root directory will either be ready or will return an error. If an error is thrown\n\t * the root has not been correctly created/set.\n\t */\n\tprotected get root(): ISharedDirectory {\n\t\tif (!this.internalRoot) {\n\t\t\tthrow new Error(this.getUninitializedErrorString(`root`));\n\t\t}\n\n\t\treturn this.internalRoot;\n\t}\n\n\t/**\n\t * Initializes internal objects and calls initialization overrides.\n\t * Caller is responsible for ensuring this is only invoked once.\n\t */\n\tpublic async initializeInternal(existing: boolean): Promise<void> {\n\t\tif (!existing) {\n\t\t\t// Create a root directory and register it before calling initializingFirstTime\n\t\t\tthis.internalRoot = SharedDirectory.create(this.runtime, this.rootDirectoryId);\n\t\t\tthis.internalRoot.bindToContext();\n\t\t} else {\n\t\t\t// data store has a root directory so we just need to set it before calling initializingFromExisting\n\t\t\tthis.internalRoot = (await this.runtime.getChannel(\n\t\t\t\tthis.rootDirectoryId,\n\t\t\t)) as ISharedDirectory;\n\n\t\t\t// This will actually be an ISharedMap if the channel was previously created by the older version of\n\t\t\t// DataObject which used a SharedMap. Since SharedMap and SharedDirectory are compatible unless\n\t\t\t// SharedDirectory-only commands are used on SharedMap, this will mostly just work for compatibility.\n\t\t\tif (this.internalRoot.attributes.type === MapFactory.Type) {\n\t\t\t\tthis.runtime.logger.send({\n\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\teventName: \"MapDataObject\",\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"Legacy document, SharedMap is masquerading as SharedDirectory in DataObject\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tawait super.initializeInternal(existing);\n\t}\n\n\t/**\n\t * Generates an error string indicating an item is uninitialized.\n\t * @param item - The name of the item that was uninitialized.\n\t */\n\tprotected getUninitializedErrorString(item: string): string {\n\t\treturn `${item} must be initialized before being accessed.`;\n\t}\n}\n"]}
1
+ {"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings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gCAwDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type ISharedDirectory, MapFactory, SharedDirectory } from \"@fluidframework/map\";\nimport { PureDataObject } from \"./pureDataObject.js\";\nimport { type DataObjectTypes } from \"./types.js\";\n\n/**\n * DataObject is a base data store that is primed with a root directory. It\n * ensures that it is created and ready before you can access it.\n *\n * Having a single root directory allows for easier development. Instead of creating\n * and registering channels with the runtime any new DDS that is set on the root\n * will automatically be registered.\n *\n * @typeParam I - The optional input types used to strongly type the data object\n * @alpha\n */\nexport abstract class DataObject<\n\tI extends DataObjectTypes = DataObjectTypes,\n> extends PureDataObject<I> {\n\tprivate internalRoot: ISharedDirectory | undefined;\n\tprivate readonly rootDirectoryId = \"root\";\n\n\t/**\n\t * The root directory will either be ready or will return an error. If an error is thrown\n\t * the root has not been correctly created/set.\n\t */\n\tprotected get root(): ISharedDirectory {\n\t\tif (!this.internalRoot) {\n\t\t\tthrow new Error(this.getUninitializedErrorString(`root`));\n\t\t}\n\n\t\treturn this.internalRoot;\n\t}\n\n\t/**\n\t * Initializes internal objects and calls initialization overrides.\n\t * Caller is responsible for ensuring this is only invoked once.\n\t */\n\tpublic async initializeInternal(existing: boolean): Promise<void> {\n\t\tif (existing) {\n\t\t\t// data store has a root directory so we just need to set it before calling initializingFromExisting\n\t\t\tthis.internalRoot = (await this.runtime.getChannel(\n\t\t\t\tthis.rootDirectoryId,\n\t\t\t)) as ISharedDirectory;\n\n\t\t\t// This will actually be an ISharedMap if the channel was previously created by the older version of\n\t\t\t// DataObject which used a SharedMap. Since SharedMap and SharedDirectory are compatible unless\n\t\t\t// SharedDirectory-only commands are used on SharedMap, this will mostly just work for compatibility.\n\t\t\tif (this.internalRoot.attributes.type === MapFactory.Type) {\n\t\t\t\tthis.runtime.logger.send({\n\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\teventName: \"MapDataObject\",\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"Legacy document, SharedMap is masquerading as SharedDirectory in DataObject\",\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\t// Create a root directory and register it before calling initializingFirstTime\n\t\t\tthis.internalRoot = SharedDirectory.create(this.runtime, this.rootDirectoryId);\n\t\t\tthis.internalRoot.bindToContext();\n\t\t}\n\n\t\tawait super.initializeInternal(existing);\n\t}\n\n\t/**\n\t * Generates an error string indicating an item is uninitialized.\n\t * @param item - The name of the item that was uninitialized.\n\t */\n\tprotected getUninitializedErrorString(item: string): string {\n\t\treturn `${item} must be initialized before being accessed.`;\n\t}\n}\n"]}