@fluidframework/aqueduct 2.20.0 → 2.22.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @fluidframework/aqueduct
2
2
 
3
+ ## 2.22.0
4
+
5
+ Dependency updates only.
6
+
7
+ ## 2.21.0
8
+
9
+ Dependency updates only.
10
+
3
11
  ## 2.20.0
4
12
 
5
13
  ### Minor Changes
package/README.md CHANGED
@@ -252,6 +252,7 @@ When making such a request please include if the configuration already works (an
252
252
  ### Supported Runtimes
253
253
 
254
254
  - NodeJs ^20.10.0 except that we will drop support for it [when NodeJs 20 loses its upstream support on 2026-04-30](https://github.com/nodejs/release#release-schedule), and will support a newer LTS version of NodeJS (22) at least 1 year before 20 is end-of-life. This same policy applies to NodeJS 22 when it is end of life (2027-04-30).
255
+ - Running Fluid in a Node.js environment with the `--no-experimental-fetch` flag is not supported.
255
256
  - Modern browsers supporting the es2022 standard library: in response to asks we can add explicit support for using babel to polyfill to target specific standards or runtimes (meaning we can avoid/remove use of things that don't polyfill robustly, but otherwise target modern standards).
256
257
 
257
258
  ### Supported Tools
@@ -94,7 +94,6 @@ export abstract class PureDataObject<I extends DataObjectTypes = DataObjectTypes
94
94
  get IFluidHandle(): IFluidHandleInternal<this>;
95
95
  get IFluidLoadable(): this;
96
96
  initializeInternal(existing: boolean): Promise<void>;
97
- // (undocumented)
98
97
  protected initializeP: Promise<void> | undefined;
99
98
  protected initializingFirstTime(props?: I["InitialState"]): Promise<void>;
100
99
  protected initializingFromExisting(): Promise<void>;
@@ -39,6 +39,7 @@ export declare abstract class DataObject<I extends DataObjectTypes = DataObjectT
39
39
  }
40
40
  /**
41
41
  * Utility for creating SharedObjectKind instances for data objects.
42
+ * @typeParam T - The kind of data object.
42
43
  * @internal
43
44
  */
44
45
  export declare function createDataObjectKind<T extends new (...any: any[]) => DataObject>(factory: T): T & SharedObjectKind<InstanceType<T>>;
@@ -1 +1 @@
1
- {"version":3,"file":"dataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,gBAAgB,EAGrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;;;;;;GAWG;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;IA4BjE;;;OAGG;IACH,SAAS,CAAC,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAG3D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,KAAK,GAAG,GAAG,OAAA,KAAK,UAAU,EACxE,OAAO,EAAE,CAAC,GACR,CAAC,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAEvC"}
1
+ {"version":3,"file":"dataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,gBAAgB,EAGrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;;;;;;GAWG;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;IACmB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B1E;;;OAGG;IACH,SAAS,CAAC,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAG3D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,KAAK,GAAG,GAAG,OAAA,KAAK,UAAU,EACxE,OAAO,EAAE,CAAC,GACR,CAAC,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAEvC"}
@@ -5,7 +5,6 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.createDataObjectKind = exports.DataObject = void 0;
8
- // eslint-disable-next-line import/no-deprecated
9
8
  const internal_1 = require("@fluidframework/map/internal");
10
9
  const pureDataObject_js_1 = require("./pureDataObject.js");
11
10
  /**
@@ -56,7 +55,6 @@ class DataObject extends pureDataObject_js_1.PureDataObject {
56
55
  }
57
56
  else {
58
57
  // Create a root directory and register it before calling initializingFirstTime
59
- // eslint-disable-next-line import/no-deprecated
60
58
  this.internalRoot = internal_1.SharedDirectory.create(this.runtime, this.rootDirectoryId);
61
59
  this.internalRoot.bindToContext();
62
60
  }
@@ -73,6 +71,7 @@ class DataObject extends pureDataObject_js_1.PureDataObject {
73
71
  exports.DataObject = DataObject;
74
72
  /**
75
73
  * Utility for creating SharedObjectKind instances for data objects.
74
+ * @typeParam T - The kind of data object.
76
75
  * @internal
77
76
  */
78
77
  function createDataOb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,CAAC;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;AAzDD,gCAyDC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CACnC,OAAU;IAEV,OAAO,OAAgD,CAAC;AACzD,CAAC;AAJD,oDAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-deprecated\nimport {\n\ttype ISharedDirectory,\n\tMapFactory,\n\tSharedDirectory,\n} from \"@fluidframework/map/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\n\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 * @legacy\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\t// eslint-disable-next-line import/no-deprecated\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\n/**\n * Utility for creating SharedObjectKind instances for data objects.\n * @internal\n */\nexport function createDataObjectKind<T extends new (...any) => DataObject>(\n\tfactory: T,\n): T & SharedObjectKind<InstanceType<T>> {\n\treturn factory as T & SharedObjectKind<InstanceType<T>>;\n}\n"]}
1
+ {"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAIsC;AAGtC,2DAAqD;AAGrD;;;;;;;;;;;GAWG;AACH,MAAsB,UAEpB,SAAQ,kCAAiB;IAF3B;;QAIkB,oBAAe,GAAG,MAAM,CAAC;IAoD3C,CAAC;IAlDA;;;OAGG;IACH,IAAc,IAAI;QACjB,IAAI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\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype ISharedDirectory,\n\tMapFactory,\n\tSharedDirectory,\n} from \"@fluidframework/map/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\n\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 * @legacy\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 override 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\n/**\n * Utility for creating SharedObjectKind instances for data objects.\n * @typeParam T - The kind of data object.\n * @internal\n */\nexport function createDataObjectKind<T extends new (...any) => DataObject>(\n\tfactory: T,\n): T & SharedObjectKind<InstanceType<T>> {\n\treturn factory as T & SharedObjectKind<InstanceType<T>>;\n}\n"]}
@@ -11,8 +11,10 @@ import type { AsyncFluidObjectProvider } from "@fluidframework/synthesize/intern
11
11
  import type { DataObjectTypes, IDataObjectProps } from "./types.js";
12
12
  /**
13
13
  * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.
14
+ *
15
+ * @remarks
14
16
  * You probably don't want to inherit from this data store directly unless
15
- * you are creating another base data store class
17
+ * you are creating another base data store class.
16
18
  *
17
19
  * @typeParam I - The optional input types used to strongly type the data object
18
20
  * @legacy
@@ -36,6 +38,13 @@ export declare abstract class PureDataObject<I extends DataObjectTypes = DataObj
36
38
  */
37
39
  protected readonly providers: AsyncFluidObjectProvider<I["OptionalProviders"]>;
38
40
  protected initProps?: I["InitialState"];
41
+ /**
42
+ * Internal implementation detail.
43
+ * Subclasses should not use this.
44
+ * @privateRemarks
45
+ * For unknown reasons this API was exposed as a protected member with no documented behavior nor any external usage or clear use-case.
46
+ * Ideally a breaking change would be made to replace this with a better named private property like `#initializationPromise` when permitted.
47
+ */
39
48
  protected initializeP: Promise<void> | undefined;
40
49
  get id(): string;
41
50
  /**
@@ -62,11 +71,11 @@ export declare abstract class PureDataObject<I extends DataObjectTypes = DataObj
62
71
  */
63
72
  request(req: IRequest): Promise<IResponse>;
64
73
  /**
65
- * Call this API to ensure PureDataObject is fully initialized.
74
+ * Await this API to ensure PureDataObject is fully initialized.
66
75
  * Initialization happens on demand, only on as-needed bases.
67
76
  * In most cases you should allow factory/object to decide when to finish initialization.
68
77
  * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods
69
- * and need a fully initialized object, then you can call this API to ensure object is fully initialized.
78
+ * and need a fully initialized object, then you can await this API to ensure object is fully initialized.
70
79
  */
71
80
  finishInitialization(existing: boolean): Promise<void>;
72
81
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"pureDataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EACX,MAAM,EACN,cAAc,EACd,QAAQ,EACR,SAAS,EACT,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACX,oBAAoB,EAEpB,mBAAmB,EACnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AAE3F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAEpF,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEpE;;;;;;;;GAQG;AACH,8BAAsB,cAAc,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe,CAC/E,SAAQ,iBAAiB,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,CAE9C,YAAW,cAAc,EAAE,mBAAmB;IAE9C;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,sB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,CAEhC;IAED;;OAEG;IACH,IAAW,YAAY,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAEpD;IAED;;OAEG;IACH,IAAW,MAAM,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAM9C;WAEmB,aAAa,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,cAAc,CAAC;gBAKxE,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAQ7C;;;;;;;OAOG;IACU,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAMvD;;;;;;OAMG;IACU,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnE;;;;;;OAMG;IACU,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBjE;;;OAGG;cACa,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9C;;;;;OAKG;cACa,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAE/E;;;OAGG;cACa,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAEzD;;OAEG;cACa,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;CAC/C"}
@@ -10,8 +10,10 @@ const internal_1 = require("@fluidframework/core-utils/internal");
10
10
  const internal_2 = require("@fluidframework/runtime-utils/internal");
11
11
  /**
12
12
  * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.
13
+ *
14
+ * @remarks
13
15
  * You probably don't want to inherit from this data store directly unless
14
- * you are creating another base data store class
16
+ * you are creating another base data store class.
15
17
  *
16
18
  * @typeParam I - The optional input types used to strongly type the data object
17
19
  * @legacy
@@ -68,17 +70,14 @@ class PureDataObject extends client_utils_1.TypedEventEmitter {
68
70
  : (0, internal_2.create404Response)(req);
69
71
  }
70
72
  /**
71
- * Call this API to ensure PureDataObject is fully initialized.
73
+ * Await this API to ensure PureDataObject is fully initialized.
72
74
  * Initialization happens on demand, only on as-needed bases.
73
75
  * In most cases you should allow factory/object to decide when to finish initialization.
74
76
  * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods
75
- * and need a fully initialized object, then you can call this API to ensure object is fully initialized.
77
+ * and need a fully initialized object, then you can await this API to ensure object is fully initialized.
76
78
  */
77
79
  async finishInitialization(existing) {
78
- if (this.initializeP !== undefined) {
79
- return this.initializeP;
80
- }
81
- this.initializeP = this.initializeInternal(existing);
80
+ this.initializeP ??= this.initializeInternal(existing);
82
81
  return this.initializeP;
83
82
  }
84
83
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAYjE,kEAA6D;AAG7D,qEAA2E;AAK3E;;;;;;;;GAQG;AACH,MAAsB,cACrB,SAAQ,gCAAuC;IA2B/C,IAAW,EAAE;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QAChB,0GAA0G;QAC1G,yGAAyG;QACzG,wDAAwD;QACxD,IAAA,iBAAM,EAAC,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC,OAAO,CAAC,UAAwC,CAAC;IAC9D,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,OAA+B;QAChE,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;QAC3C,OAAO,GAAqB,CAAC;IAC9B,CAAC;IAED,YA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I,CAAC,OAAO,CAAC,WAAiC,IAAI,IAAI,CAAC,SAAS,CACjE,CAAC;QACH,CAAC;QACD,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,KAAmB,CAAC;IAEjD;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAAyB,IAAkB,CAAC;IAElF;;;OAGG;IACO,KAAK,CAAC,wBAAwB,KAAmB,CAAC;IAE5D;;OAEG;IACO,KAAK,CAAC,cAAc,KAAmB,CAAC;CAClD;AAlJD,wCAkJC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tIEvent,\n\tIFluidLoadable,\n\tIRequest,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\nimport type {\n\tIFluidHandleInternal,\n\t// eslint-disable-next-line import/no-deprecated\n\tIProvideFluidHandle,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\nimport { create404Response } from \"@fluidframework/runtime-utils/internal\";\nimport type { AsyncFluidObjectProvider } from \"@fluidframework/synthesize/internal\";\n\nimport type { DataObjectTypes, IDataObjectProps } from \"./types.js\";\n\n/**\n * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.\n * You probably don't want to inherit from this data store directly unless\n * you are creating another base data store class\n *\n * @typeParam I - The optional input types used to strongly type the data object\n * @legacy\n * @alpha\n */\nexport abstract class PureDataObject<I extends DataObjectTypes = DataObjectTypes>\n\textends TypedEventEmitter<I[\"Events\"] & IEvent>\n\t// eslint-disable-next-line import/no-deprecated\n\timplements IFluidLoadable, IProvideFluidHandle\n{\n\t/**\n\t * This is your FluidDataStoreRuntime object\n\t */\n\tprotected readonly runtime: IFluidDataStoreRuntime;\n\n\t/**\n\t * This context is used to talk up to the IContainerRuntime\n\t */\n\tprotected readonly context: IFluidDataStoreContext;\n\n\t/**\n\t * Providers are FluidObject keyed objects that provide back\n\t * a promise to the corresponding FluidObject or undefined.\n\t * Providers injected/provided by the Container and/or HostingApplication\n\t *\n\t * To define providers set FluidObject interfaces in the OptionalProviders generic type for your data store\n\t */\n\tprotected readonly providers: AsyncFluidObjectProvider<I[\"OptionalProviders\"]>;\n\n\tprotected initProps?: I[\"InitialState\"];\n\n\tprotected initializeP: Promise<void> | undefined;\n\n\tpublic get id(): string {\n\t\treturn this.runtime.id;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IProvideFluidLoadable.IFluidLoadable}\n\t */\n\tpublic get IFluidLoadable(): this {\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IProvideFluidHandle.IFluidHandle}\n\t */\n\tpublic get IFluidHandle(): IFluidHandleInternal<this> {\n\t\treturn this.handle;\n\t}\n\n\t/**\n\t * Handle to a data store\n\t */\n\tpublic get handle(): IFluidHandleInternal<this> {\n\t\t// PureDataObjectFactory already provides an entryPoint initialization function to the data store runtime,\n\t\t// so this object should always have access to a non-null entryPoint. Need to cast because PureDataObject\n\t\t// tried to be too smart with its typing for handles :).\n\t\tassert(this.runtime.entryPoint !== undefined, 0x46b /* EntryPoint was undefined */);\n\t\treturn this.runtime.entryPoint as IFluidHandleInternal<this>;\n\t}\n\n\tpublic static async getDataObject(runtime: IFluidDataStoreRuntime): Promise<PureDataObject> {\n\t\tconst obj = await runtime.entryPoint.get();\n\t\treturn obj as PureDataObject;\n\t}\n\n\tpublic constructor(props: IDataObjectProps<I>) {\n\t\tsuper();\n\t\tthis.runtime = props.runtime;\n\t\tthis.context = props.context;\n\t\tthis.providers = props.providers;\n\t\tthis.initProps = props.initProps;\n\t}\n\n\t/**\n\t * Return this object if someone requests it directly\n\t * We will return this object in two scenarios:\n\t *\n\t * 1. the request url is a \"/\"\n\t *\n\t * 2. the request url is empty\n\t */\n\tpublic async request(req: IRequest): Promise<IResponse> {\n\t\treturn req.url === \"\" || req.url === \"/\" || req.url.startsWith(\"/?\")\n\t\t\t? { mimeType: \"fluid/object\", status: 200, value: this }\n\t\t\t: create404Response(req);\n\t}\n\n\t/**\n\t * Call this API to ensure PureDataObject is fully initialized.\n\t * Initialization happens on demand, only on as-needed bases.\n\t * In most cases you should allow factory/object to decide when to finish initialization.\n\t * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods\n\t * and need a fully initialized object, then you can call this API to ensure object is fully initialized.\n\t */\n\tpublic async finishInitialization(existing: boolean): Promise<void> {\n\t\tif (this.initializeP !== undefined) {\n\t\t\treturn this.initializeP;\n\t\t}\n\t\tthis.initializeP = this.initializeInternal(existing);\n\t\treturn this.initializeP;\n\t}\n\n\t/**\n\t * Internal initialize implementation. Overwriting this will change the flow of the PureDataObject and should\n\t * generally not be done.\n\t *\n\t * Calls initializingFirstTime, initializingFromExisting, and hasInitialized. Caller is\n\t * responsible for ensuring this is only invoked once.\n\t */\n\tpublic async initializeInternal(existing: boolean): Promise<void> {\n\t\tawait this.preInitialize();\n\t\tif (existing) {\n\t\t\tassert(\n\t\t\t\tthis.initProps === undefined,\n\t\t\t\t0x0be /* \"Trying to initialize from existing while initProps is set!\" */,\n\t\t\t);\n\t\t\tawait this.initializingFromExisting();\n\t\t} else {\n\t\t\tawait this.initializingFirstTime(\n\t\t\t\t(this.context.createProps as I[\"InitialState\"]) ?? this.initProps,\n\t\t\t);\n\t\t}\n\t\tawait this.hasInitialized();\n\t}\n\n\t/**\n\t * Called every time the data store is initialized, before initializingFirstTime or\n\t * initializingFromExisting is called.\n\t */\n\tprotected async preInitialize(): Promise<void> {}\n\n\t/**\n\t * Called the first time the data store is initialized (new creations with a new\n\t * data store runtime)\n\t *\n\t * @param props - Optional props to be passed in on create\n\t */\n\tprotected async initializingFirstTime(props?: I[\"InitialState\"]): Promise<void> {}\n\n\t/**\n\t * Called every time but the first time the data store is initialized (creations\n\t * with an existing data store runtime)\n\t */\n\tprotected async initializingFromExisting(): Promise<void> {}\n\n\t/**\n\t * Called every time the data store is initialized after create or existing.\n\t */\n\tprotected async hasInitialized(): Promise<void> {}\n}\n"]}
1
+ {"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAYjE,kEAA6D;AAG7D,qEAA2E;AAK3E;;;;;;;;;;GAUG;AACH,MAAsB,cACrB,SAAQ,gCAAuC;IAkC/C,IAAW,EAAE;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QAChB,0GAA0G;QAC1G,yGAAyG;QACzG,wDAAwD;QACxD,IAAA,iBAAM,EAAC,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC,OAAO,CAAC,UAAwC,CAAC;IAC9D,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,OAA+B;QAChE,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;QAC3C,OAAO,GAAqB,CAAC;IAC9B,CAAC;IAED,YAAmB,KAA0B;QAC5C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;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AE5D;;OAEG;IACO,KAAK,CAAC,cAAc,KAAmB,CAAC;CAClD;AAtJD,wCAsJC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tIEvent,\n\tIFluidLoadable,\n\tIRequest,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\nimport type {\n\tIFluidHandleInternal,\n\t// eslint-disable-next-line import/no-deprecated\n\tIProvideFluidHandle,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\nimport { create404Response } from \"@fluidframework/runtime-utils/internal\";\nimport type { AsyncFluidObjectProvider } from \"@fluidframework/synthesize/internal\";\n\nimport type { DataObjectTypes, IDataObjectProps } from \"./types.js\";\n\n/**\n * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.\n *\n * @remarks\n * You probably don't want to inherit from this data store directly unless\n * you are creating another base data store class.\n *\n * @typeParam I - The optional input types used to strongly type the data object\n * @legacy\n * @alpha\n */\nexport abstract class PureDataObject<I extends DataObjectTypes = DataObjectTypes>\n\textends TypedEventEmitter<I[\"Events\"] & IEvent>\n\t// eslint-disable-next-line import/no-deprecated\n\timplements IFluidLoadable, IProvideFluidHandle\n{\n\t/**\n\t * This is your FluidDataStoreRuntime object\n\t */\n\tprotected readonly runtime: IFluidDataStoreRuntime;\n\n\t/**\n\t * This context is used to talk up to the IContainerRuntime\n\t */\n\tprotected readonly context: IFluidDataStoreContext;\n\n\t/**\n\t * Providers are FluidObject keyed objects that provide back\n\t * a promise to the corresponding FluidObject or undefined.\n\t * Providers injected/provided by the Container and/or HostingApplication\n\t *\n\t * To define providers set FluidObject interfaces in the OptionalProviders generic type for your data store\n\t */\n\tprotected readonly providers: AsyncFluidObjectProvider<I[\"OptionalProviders\"]>;\n\n\tprotected initProps?: I[\"InitialState\"];\n\n\t/**\n\t * Internal implementation detail.\n\t * Subclasses should not use this.\n\t * @privateRemarks\n\t * For unknown reasons this API was exposed as a protected member with no documented behavior nor any external usage or clear use-case.\n\t * Ideally a breaking change would be made to replace this with a better named private property like `#initializationPromise` when permitted.\n\t */\n\tprotected initializeP: Promise<void> | undefined;\n\n\tpublic get id(): string {\n\t\treturn this.runtime.id;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IProvideFluidLoadable.IFluidLoadable}\n\t */\n\tpublic get IFluidLoadable(): this {\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IProvideFluidHandle.IFluidHandle}\n\t */\n\tpublic get IFluidHandle(): IFluidHandleInternal<this> {\n\t\treturn this.handle;\n\t}\n\n\t/**\n\t * Handle to a data store\n\t */\n\tpublic get handle(): IFluidHandleInternal<this> {\n\t\t// PureDataObjectFactory already provides an entryPoint initialization function to the data store runtime,\n\t\t// so this object should always have access to a non-null entryPoint. Need to cast because PureDataObject\n\t\t// tried to be too smart with its typing for handles :).\n\t\tassert(this.runtime.entryPoint !== undefined, 0x46b /* EntryPoint was undefined */);\n\t\treturn this.runtime.entryPoint as IFluidHandleInternal<this>;\n\t}\n\n\tpublic static async getDataObject(runtime: IFluidDataStoreRuntime): Promise<PureDataObject> {\n\t\tconst obj = await runtime.entryPoint.get();\n\t\treturn obj as PureDataObject;\n\t}\n\n\tpublic constructor(props: IDataObjectProps<I>) {\n\t\tsuper();\n\t\tthis.runtime = props.runtime;\n\t\tthis.context = props.context;\n\t\tthis.providers = props.providers;\n\t\tthis.initProps = props.initProps;\n\t}\n\n\t/**\n\t * Return this object if someone requests it directly\n\t * We will return this object in two scenarios:\n\t *\n\t * 1. the request url is a \"/\"\n\t *\n\t * 2. the request url is empty\n\t */\n\tpublic async request(req: IRequest): Promise<IResponse> {\n\t\treturn req.url === \"\" || req.url === \"/\" || req.url.startsWith(\"/?\")\n\t\t\t? { mimeType: \"fluid/object\", status: 200, value: this }\n\t\t\t: create404Response(req);\n\t}\n\n\t/**\n\t * Await this API to ensure PureDataObject is fully initialized.\n\t * Initialization happens on demand, only on as-needed bases.\n\t * In most cases you should allow factory/object to decide when to finish initialization.\n\t * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods\n\t * and need a fully initialized object, then you can await this API to ensure object is fully initialized.\n\t */\n\tpublic async finishInitialization(existing: boolean): Promise<void> {\n\t\tthis.initializeP ??= this.initializeInternal(existing);\n\t\treturn this.initializeP;\n\t}\n\n\t/**\n\t * Internal initialize implementation. Overwriting this will change the flow of the PureDataObject and should\n\t * generally not be done.\n\t *\n\t * Calls initializingFirstTime, initializingFromExisting, and hasInitialized. Caller is\n\t * responsible for ensuring this is only invoked once.\n\t */\n\tpublic async initializeInternal(existing: boolean): Promise<void> {\n\t\tawait this.preInitialize();\n\t\tif (existing) {\n\t\t\tassert(\n\t\t\t\tthis.initProps === undefined,\n\t\t\t\t0x0be /* \"Trying to initialize from existing while initProps is set!\" */,\n\t\t\t);\n\t\t\tawait this.initializingFromExisting();\n\t\t} else {\n\t\t\tawait this.initializingFirstTime(\n\t\t\t\t(this.context.createProps as I[\"InitialState\"]) ?? this.initProps,\n\t\t\t);\n\t\t}\n\t\tawait this.hasInitialized();\n\t}\n\n\t/**\n\t * Called every time the data store is initialized, before initializingFirstTime or\n\t * initializingFromExisting is called.\n\t */\n\tprotected async preInitialize(): Promise<void> {}\n\n\t/**\n\t * Called the first time the data store is initialized (new creations with a new\n\t * data store runtime)\n\t *\n\t * @param props - Optional props to be passed in on create\n\t */\n\tprotected async initializingFirstTime(props?: I[\"InitialState\"]): Promise<void> {}\n\n\t/**\n\t * Called every time but the first time the data store is initialized (creations\n\t * with an existing data store runtime)\n\t */\n\tprotected async initializingFromExisting(): Promise<void> {}\n\n\t/**\n\t * Called every time the data store is initialized after create or existing.\n\t */\n\tprotected async hasInitialized(): Promise<void> {}\n}\n"]}
@@ -39,6 +39,7 @@ export declare abstract class DataObject<I extends DataObjectTypes = DataObjectT
39
39
  }
40
40
  /**
41
41
  * Utility for creating SharedObjectKind instances for data objects.
42
+ * @typeParam T - The kind of data object.
42
43
  * @internal
43
44
  */
44
45
  export declare function createDataObjectKind<T extends new (...any: any[]) => DataObject>(factory: T): T & SharedObjectKind<InstanceType<T>>;
@@ -1 +1 @@
1
- {"version":3,"file":"dataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,gBAAgB,EAGrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;;;;;;GAWG;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;IA4BjE;;;OAGG;IACH,SAAS,CAAC,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAG3D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,KAAK,GAAG,GAAG,OAAA,KAAK,UAAU,EACxE,OAAO,EAAE,CAAC,GACR,CAAC,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAEvC"}
1
+ {"version":3,"file":"dataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,gBAAgB,EAGrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;;;;;;GAWG;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;IACmB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B1E;;;OAGG;IACH,SAAS,CAAC,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAG3D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,KAAK,GAAG,GAAG,OAAA,KAAK,UAAU,EACxE,OAAO,EAAE,CAAC,GACR,CAAC,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAEvC"}
@@ -2,7 +2,6 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- // eslint-disable-next-line import/no-deprecated
6
5
  import { MapFactory, SharedDirectory, } from "@fluidframework/map/internal";
7
6
  import { PureDataObject } from "./pureDataObject.js";
8
7
  /**
@@ -53,7 +52,6 @@ export class DataObject extends PureDataObject {
53
52
  }
54
53
  else {
55
54
  // Create a root directory and register it before calling initializingFirstTime
56
- // eslint-disable-next-line import/no-deprecated
57
55
  this.internalRoot = SharedDirectory.create(this.runtime, this.rootDirectoryId);
58
56
  this.internalRoot.bindToContext();
59
57
  }
@@ -69,6 +67,7 @@ export class DataObject extends PureDataObject {
69
67
  }
70
68
  /**
71
69
  * Utility for creating SharedObjectKind instances for data objects.
70
+ * @typeParam T - The kind of data object.
72
71
  * @internal
73
72
  */
74
73
  export function createDataObjectKind(factory) {
@@ -1 +1 @@
1
- {"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,gDAAgD;AAChD,OAAO,EAEN,UAAU,EACV,eAAe,GACf,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;;;;;;;;;GAWG;AACH,MAAM,OAAgB,UAEpB,SAAQ,cAAiB;IAF3B;;QAIkB,oBAAe,GAAG,MAAM,CAAC;IAqD3C,CAAC;IAnDA;;;OAGG;IACH,IAAc,IAAI;QACjB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,kBAAkB,CAAC,QAAiB;QAChD,IAAI,QAAQ,EAAE,CAAC;YACd,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,UAAU,CAAC,IAAI,EAAE,CAAC;gBAC3D,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;oBACxB,QAAQ,EAAE,SAAS;oBACnB,SAAS,EAAE,eAAe;oBAC1B,OAAO,EACN,6EAA6E;iBAC9E,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;aAAM,CAAC;YACP,+EAA+E;YAC/E,gDAAgD;YAChD,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;YAC/E,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,CAAC;QACnC,CAAC;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;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CACnC,OAAU;IAEV,OAAO,OAAgD,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-deprecated\nimport {\n\ttype ISharedDirectory,\n\tMapFactory,\n\tSharedDirectory,\n} from \"@fluidframework/map/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\n\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 * @legacy\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\t// eslint-disable-next-line import/no-deprecated\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\n/**\n * Utility for creating SharedObjectKind instances for data objects.\n * @internal\n */\nexport function createDataObjectKind<T extends new (...any) => DataObject>(\n\tfactory: T,\n): T & SharedObjectKind<InstanceType<T>> {\n\treturn factory as T & SharedObjectKind<InstanceType<T>>;\n}\n"]}
1
+ {"version":3,"file":"data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AC;QACnC,CAAC;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;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CACnC,OAAU;IAEV,OAAO,OAAgD,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype ISharedDirectory,\n\tMapFactory,\n\tSharedDirectory,\n} from \"@fluidframework/map/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\n\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 * @legacy\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 override 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\n/**\n * Utility for creating SharedObjectKind instances for data objects.\n * @typeParam T - The kind of data object.\n * @internal\n */\nexport function createDataObjectKind<T extends new (...any) => DataObject>(\n\tfactory: T,\n): T & SharedObjectKind<InstanceType<T>> {\n\treturn factory as T & SharedObjectKind<InstanceType<T>>;\n}\n"]}
@@ -11,8 +11,10 @@ import type { AsyncFluidObjectProvider } from "@fluidframework/synthesize/intern
11
11
  import type { DataObjectTypes, IDataObjectProps } from "./types.js";
12
12
  /**
13
13
  * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.
14
+ *
15
+ * @remarks
14
16
  * You probably don't want to inherit from this data store directly unless
15
- * you are creating another base data store class
17
+ * you are creating another base data store class.
16
18
  *
17
19
  * @typeParam I - The optional input types used to strongly type the data object
18
20
  * @legacy
@@ -36,6 +38,13 @@ export declare abstract class PureDataObject<I extends DataObjectTypes = DataObj
36
38
  */
37
39
  protected readonly providers: AsyncFluidObjectProvider<I["OptionalProviders"]>;
38
40
  protected initProps?: I["InitialState"];
41
+ /**
42
+ * Internal implementation detail.
43
+ * Subclasses should not use this.
44
+ * @privateRemarks
45
+ * For unknown reasons this API was exposed as a protected member with no documented behavior nor any external usage or clear use-case.
46
+ * Ideally a breaking change would be made to replace this with a better named private property like `#initializationPromise` when permitted.
47
+ */
39
48
  protected initializeP: Promise<void> | undefined;
40
49
  get id(): string;
41
50
  /**
@@ -62,11 +71,11 @@ export declare abstract class PureDataObject<I extends DataObjectTypes = DataObj
62
71
  */
63
72
  request(req: IRequest): Promise<IResponse>;
64
73
  /**
65
- * Call this API to ensure PureDataObject is fully initialized.
74
+ * Await this API to ensure PureDataObject is fully initialized.
66
75
  * Initialization happens on demand, only on as-needed bases.
67
76
  * In most cases you should allow factory/object to decide when to finish initialization.
68
77
  * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods
69
- * and need a fully initialized object, then you can call this API to ensure object is fully initialized.
78
+ * and need a fully initialized object, then you can await this API to ensure object is fully initialized.
70
79
  */
71
80
  finishInitialization(existing: boolean): Promise<void>;
72
81
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"pureDataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EACX,MAAM,EACN,cAAc,EACd,QAAQ,EACR,SAAS,EACT,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACX,oBAAoB,EAEpB,mBAAmB,EACnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AAE3F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,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9
9
  * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.
10
+ *
11
+ * @remarks
10
12
  * You probably don't want to inherit from this data store directly unless
11
- * you are creating another base data store class
13
+ * you are creating another base data store class.
12
14
  *
13
15
  * @typeParam I - The optional input types used to strongly type the data object
14
16
  * @legacy
@@ -65,17 +67,14 @@ export class PureDataObject extends TypedEventEmitter {
65
67
  : create404Response(req);
66
68
  }
67
69
  /**
68
- * Call this API to ensure PureDataObject is fully initialized.
70
+ * Await this API to ensure PureDataObject is fully initialized.
69
71
  * Initialization happens on demand, only on as-needed bases.
70
72
  * In most cases you should allow factory/object to decide when to finish initialization.
71
73
  * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods
72
- * and need a fully initialized object, then you can call this API to ensure object is fully initialized.
74
+ * and need a fully initialized object, then you can await this API to ensure object is fully initialized.
73
75
  */
74
76
  async finishInitialization(existing) {
75
- if (this.initializeP !== undefined) {
76
- return this.initializeP;
77
- }
78
- this.initializeP = this.initializeInternal(existing);
77
+ this.initializeP ??= this.initializeInternal(existing);
79
78
  return this.initializeP;
80
79
  }
81
80
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAYjE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAK3E;;;;;;;;GAQG;AACH,MAAM,OAAgB,cACrB,SAAQ,iBAAuC;IA2B/C,IAAW,EAAE;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,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AC,QAAQ,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,kBAAkB,CAAC,QAAiB;QAChD,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAC3B,IAAI,QAAQ,EAAE,CAAC;YACd,MAAM,CACL,IAAI,CAAC,SAAS,KAAK,SAAS,EAC5B,KAAK,CAAC,kEAAkE,CACxE,CAAC;YACF,MAAM,IAAI,CAAC,wBAAwB,EAAE,CAAC;QACvC,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,CAAC,qBAAqB,CAC9B,IAAI,CAAC,OAAO,CAAC,WAAiC,IAAI,IAAI,CAAC,SAAS,CACjE,CAAC;QACH,CAAC;QACD,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,KAAmB,CAAC;IAEjD;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAAyB,IAAkB,CAAC;IAElF;;;OAGG;IACO,KAAK,CAAC,wBAAwB,KAAmB,CAAC;IAE5D;;OAEG;IACO,KAAK,CAAC,cAAc,KAAmB,CAAC;CAClD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tIEvent,\n\tIFluidLoadable,\n\tIRequest,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\nimport type {\n\tIFluidHandleInternal,\n\t// eslint-disable-next-line import/no-deprecated\n\tIProvideFluidHandle,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\nimport { create404Response } from \"@fluidframework/runtime-utils/internal\";\nimport type { AsyncFluidObjectProvider } from \"@fluidframework/synthesize/internal\";\n\nimport type { DataObjectTypes, IDataObjectProps } from \"./types.js\";\n\n/**\n * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.\n * You probably don't want to inherit from this data store directly unless\n * you are creating another base data store class\n *\n * @typeParam I - The optional input types used to strongly type the data object\n * @legacy\n * @alpha\n */\nexport abstract class PureDataObject<I extends DataObjectTypes = DataObjectTypes>\n\textends TypedEventEmitter<I[\"Events\"] & IEvent>\n\t// eslint-disable-next-line import/no-deprecated\n\timplements IFluidLoadable, IProvideFluidHandle\n{\n\t/**\n\t * This is your FluidDataStoreRuntime object\n\t */\n\tprotected readonly runtime: IFluidDataStoreRuntime;\n\n\t/**\n\t * This context is used to talk up to the IContainerRuntime\n\t */\n\tprotected readonly context: IFluidDataStoreContext;\n\n\t/**\n\t * Providers are FluidObject keyed objects that provide back\n\t * a promise to the corresponding FluidObject or undefined.\n\t * Providers injected/provided by the Container and/or HostingApplication\n\t *\n\t * To define providers set FluidObject interfaces in the OptionalProviders generic type for your data store\n\t */\n\tprotected readonly providers: AsyncFluidObjectProvider<I[\"OptionalProviders\"]>;\n\n\tprotected initProps?: I[\"InitialState\"];\n\n\tprotected initializeP: Promise<void> | undefined;\n\n\tpublic get id(): string {\n\t\treturn this.runtime.id;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IProvideFluidLoadable.IFluidLoadable}\n\t */\n\tpublic get IFluidLoadable(): this {\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IProvideFluidHandle.IFluidHandle}\n\t */\n\tpublic get IFluidHandle(): IFluidHandleInternal<this> {\n\t\treturn this.handle;\n\t}\n\n\t/**\n\t * Handle to a data store\n\t */\n\tpublic get handle(): IFluidHandleInternal<this> {\n\t\t// PureDataObjectFactory already provides an entryPoint initialization function to the data store runtime,\n\t\t// so this object should always have access to a non-null entryPoint. Need to cast because PureDataObject\n\t\t// tried to be too smart with its typing for handles :).\n\t\tassert(this.runtime.entryPoint !== undefined, 0x46b /* EntryPoint was undefined */);\n\t\treturn this.runtime.entryPoint as IFluidHandleInternal<this>;\n\t}\n\n\tpublic static async getDataObject(runtime: IFluidDataStoreRuntime): Promise<PureDataObject> {\n\t\tconst obj = await runtime.entryPoint.get();\n\t\treturn obj as PureDataObject;\n\t}\n\n\tpublic constructor(props: IDataObjectProps<I>) {\n\t\tsuper();\n\t\tthis.runtime = props.runtime;\n\t\tthis.context = props.context;\n\t\tthis.providers = props.providers;\n\t\tthis.initProps = props.initProps;\n\t}\n\n\t/**\n\t * Return this object if someone requests it directly\n\t * We will return this object in two scenarios:\n\t *\n\t * 1. the request url is a \"/\"\n\t *\n\t * 2. the request url is empty\n\t */\n\tpublic async request(req: IRequest): Promise<IResponse> {\n\t\treturn req.url === \"\" || req.url === \"/\" || req.url.startsWith(\"/?\")\n\t\t\t? { mimeType: \"fluid/object\", status: 200, value: this }\n\t\t\t: create404Response(req);\n\t}\n\n\t/**\n\t * Call this API to ensure PureDataObject is fully initialized.\n\t * Initialization happens on demand, only on as-needed bases.\n\t * In most cases you should allow factory/object to decide when to finish initialization.\n\t * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods\n\t * and need a fully initialized object, then you can call this API to ensure object is fully initialized.\n\t */\n\tpublic async finishInitialization(existing: boolean): Promise<void> {\n\t\tif (this.initializeP !== undefined) {\n\t\t\treturn this.initializeP;\n\t\t}\n\t\tthis.initializeP = this.initializeInternal(existing);\n\t\treturn this.initializeP;\n\t}\n\n\t/**\n\t * Internal initialize implementation. Overwriting this will change the flow of the PureDataObject and should\n\t * generally not be done.\n\t *\n\t * Calls initializingFirstTime, initializingFromExisting, and hasInitialized. Caller is\n\t * responsible for ensuring this is only invoked once.\n\t */\n\tpublic async initializeInternal(existing: boolean): Promise<void> {\n\t\tawait this.preInitialize();\n\t\tif (existing) {\n\t\t\tassert(\n\t\t\t\tthis.initProps === undefined,\n\t\t\t\t0x0be /* \"Trying to initialize from existing while initProps is set!\" */,\n\t\t\t);\n\t\t\tawait this.initializingFromExisting();\n\t\t} else {\n\t\t\tawait this.initializingFirstTime(\n\t\t\t\t(this.context.createProps as I[\"InitialState\"]) ?? this.initProps,\n\t\t\t);\n\t\t}\n\t\tawait this.hasInitialized();\n\t}\n\n\t/**\n\t * Called every time the data store is initialized, before initializingFirstTime or\n\t * initializingFromExisting is called.\n\t */\n\tprotected async preInitialize(): Promise<void> {}\n\n\t/**\n\t * Called the first time the data store is initialized (new creations with a new\n\t * data store runtime)\n\t *\n\t * @param props - Optional props to be passed in on create\n\t */\n\tprotected async initializingFirstTime(props?: I[\"InitialState\"]): Promise<void> {}\n\n\t/**\n\t * Called every time but the first time the data store is initialized (creations\n\t * with an existing data store runtime)\n\t */\n\tprotected async initializingFromExisting(): Promise<void> {}\n\n\t/**\n\t * Called every time the data store is initialized after create or existing.\n\t */\n\tprotected async hasInitialized(): Promise<void> {}\n}\n"]}
1
+ {"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAYjE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAK3E;;;;;;;;;;GAUG;AACH,MAAM,OAAgB,cACrB,SAAQ,iBAAuC;IAkC/C,IAAW,EAAE;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QAChB,0GAA0G;QAC1G,yGAAyG;QACzG,wDAAwD;QACxD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC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,CAAC,SAAS,KAAK,SAAS,EAC5B,KAAK,CAAC,kEAAkE,CACxE,CAAC;YACF,MAAM,IAAI,CAAC,wBAAwB,EAAE,CAAC;QACvC,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,CAAC,qBAAqB,CAC9B,IAAI,CAAC,OAAO,CAAC,WAAiC,IAAI,IAAI,CAAC,SAAS,CACjE,CAAC;QACH,CAAC;QACD,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,KAAmB,CAAC;IAEjD;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAAyB,IAAkB,CAAC;IAElF;;;OAGG;IACO,KAAK,CAAC,wBAAwB,KAAmB,CAAC;IAE5D;;OAEG;IACO,KAAK,CAAC,cAAc,KAAmB,CAAC;CAClD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tIEvent,\n\tIFluidLoadable,\n\tIRequest,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\nimport type {\n\tIFluidHandleInternal,\n\t// eslint-disable-next-line import/no-deprecated\n\tIProvideFluidHandle,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions/internal\";\nimport { create404Response } from \"@fluidframework/runtime-utils/internal\";\nimport type { AsyncFluidObjectProvider } from \"@fluidframework/synthesize/internal\";\n\nimport type { DataObjectTypes, IDataObjectProps } from \"./types.js\";\n\n/**\n * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.\n *\n * @remarks\n * You probably don't want to inherit from this data store directly unless\n * you are creating another base data store class.\n *\n * @typeParam I - The optional input types used to strongly type the data object\n * @legacy\n * @alpha\n */\nexport abstract class PureDataObject<I extends DataObjectTypes = DataObjectTypes>\n\textends TypedEventEmitter<I[\"Events\"] & IEvent>\n\t// eslint-disable-next-line import/no-deprecated\n\timplements IFluidLoadable, IProvideFluidHandle\n{\n\t/**\n\t * This is your FluidDataStoreRuntime object\n\t */\n\tprotected readonly runtime: IFluidDataStoreRuntime;\n\n\t/**\n\t * This context is used to talk up to the IContainerRuntime\n\t */\n\tprotected readonly context: IFluidDataStoreContext;\n\n\t/**\n\t * Providers are FluidObject keyed objects that provide back\n\t * a promise to the corresponding FluidObject or undefined.\n\t * Providers injected/provided by the Container and/or HostingApplication\n\t *\n\t * To define providers set FluidObject interfaces in the OptionalProviders generic type for your data store\n\t */\n\tprotected readonly providers: AsyncFluidObjectProvider<I[\"OptionalProviders\"]>;\n\n\tprotected initProps?: I[\"InitialState\"];\n\n\t/**\n\t * Internal implementation detail.\n\t * Subclasses should not use this.\n\t * @privateRemarks\n\t * For unknown reasons this API was exposed as a protected member with no documented behavior nor any external usage or clear use-case.\n\t * Ideally a breaking change would be made to replace this with a better named private property like `#initializationPromise` when permitted.\n\t */\n\tprotected initializeP: Promise<void> | undefined;\n\n\tpublic get id(): string {\n\t\treturn this.runtime.id;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IProvideFluidLoadable.IFluidLoadable}\n\t */\n\tpublic get IFluidLoadable(): this {\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#IProvideFluidHandle.IFluidHandle}\n\t */\n\tpublic get IFluidHandle(): IFluidHandleInternal<this> {\n\t\treturn this.handle;\n\t}\n\n\t/**\n\t * Handle to a data store\n\t */\n\tpublic get handle(): IFluidHandleInternal<this> {\n\t\t// PureDataObjectFactory already provides an entryPoint initialization function to the data store runtime,\n\t\t// so this object should always have access to a non-null entryPoint. Need to cast because PureDataObject\n\t\t// tried to be too smart with its typing for handles :).\n\t\tassert(this.runtime.entryPoint !== undefined, 0x46b /* EntryPoint was undefined */);\n\t\treturn this.runtime.entryPoint as IFluidHandleInternal<this>;\n\t}\n\n\tpublic static async getDataObject(runtime: IFluidDataStoreRuntime): Promise<PureDataObject> {\n\t\tconst obj = await runtime.entryPoint.get();\n\t\treturn obj as PureDataObject;\n\t}\n\n\tpublic constructor(props: IDataObjectProps<I>) {\n\t\tsuper();\n\t\tthis.runtime = props.runtime;\n\t\tthis.context = props.context;\n\t\tthis.providers = props.providers;\n\t\tthis.initProps = props.initProps;\n\t}\n\n\t/**\n\t * Return this object if someone requests it directly\n\t * We will return this object in two scenarios:\n\t *\n\t * 1. the request url is a \"/\"\n\t *\n\t * 2. the request url is empty\n\t */\n\tpublic async request(req: IRequest): Promise<IResponse> {\n\t\treturn req.url === \"\" || req.url === \"/\" || req.url.startsWith(\"/?\")\n\t\t\t? { mimeType: \"fluid/object\", status: 200, value: this }\n\t\t\t: create404Response(req);\n\t}\n\n\t/**\n\t * Await this API to ensure PureDataObject is fully initialized.\n\t * Initialization happens on demand, only on as-needed bases.\n\t * In most cases you should allow factory/object to decide when to finish initialization.\n\t * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods\n\t * and need a fully initialized object, then you can await this API to ensure object is fully initialized.\n\t */\n\tpublic async finishInitialization(existing: boolean): Promise<void> {\n\t\tthis.initializeP ??= this.initializeInternal(existing);\n\t\treturn this.initializeP;\n\t}\n\n\t/**\n\t * Internal initialize implementation. Overwriting this will change the flow of the PureDataObject and should\n\t * generally not be done.\n\t *\n\t * Calls initializingFirstTime, initializingFromExisting, and hasInitialized. Caller is\n\t * responsible for ensuring this is only invoked once.\n\t */\n\tpublic async initializeInternal(existing: boolean): Promise<void> {\n\t\tawait this.preInitialize();\n\t\tif (existing) {\n\t\t\tassert(\n\t\t\t\tthis.initProps === undefined,\n\t\t\t\t0x0be /* \"Trying to initialize from existing while initProps is set!\" */,\n\t\t\t);\n\t\t\tawait this.initializingFromExisting();\n\t\t} else {\n\t\t\tawait this.initializingFirstTime(\n\t\t\t\t(this.context.createProps as I[\"InitialState\"]) ?? this.initProps,\n\t\t\t);\n\t\t}\n\t\tawait this.hasInitialized();\n\t}\n\n\t/**\n\t * Called every time the data store is initialized, before initializingFirstTime or\n\t * initializingFromExisting is called.\n\t */\n\tprotected async preInitialize(): Promise<void> {}\n\n\t/**\n\t * Called the first time the data store is initialized (new creations with a new\n\t * data store runtime)\n\t *\n\t * @param props - Optional props to be passed in on create\n\t */\n\tprotected async initializingFirstTime(props?: I[\"InitialState\"]): Promise<void> {}\n\n\t/**\n\t * Called every time but the first time the data store is initialized (creations\n\t * with an existing data store runtime)\n\t */\n\tprotected async initializingFromExisting(): Promise<void> {}\n\n\t/**\n\t * Called every time the data store is initialized after create or existing.\n\t */\n\tprotected async hasInitialized(): Promise<void> {}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/aqueduct",
3
- "version": "2.20.0",
3
+ "version": "2.22.0",
4
4
  "description": "A set of implementations for Fluid Framework interfaces.",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -69,30 +69,30 @@
69
69
  "temp-directory": "nyc/.nyc_output"
70
70
  },
71
71
  "dependencies": {
72
- "@fluid-internal/client-utils": "~2.20.0",
73
- "@fluidframework/container-definitions": "~2.20.0",
74
- "@fluidframework/container-runtime": "~2.20.0",
75
- "@fluidframework/container-runtime-definitions": "~2.20.0",
76
- "@fluidframework/core-interfaces": "~2.20.0",
77
- "@fluidframework/core-utils": "~2.20.0",
78
- "@fluidframework/datastore": "~2.20.0",
79
- "@fluidframework/datastore-definitions": "~2.20.0",
80
- "@fluidframework/map": "~2.20.0",
81
- "@fluidframework/request-handler": "~2.20.0",
82
- "@fluidframework/runtime-definitions": "~2.20.0",
83
- "@fluidframework/runtime-utils": "~2.20.0",
84
- "@fluidframework/shared-object-base": "~2.20.0",
85
- "@fluidframework/synthesize": "~2.20.0"
72
+ "@fluid-internal/client-utils": "~2.22.0",
73
+ "@fluidframework/container-definitions": "~2.22.0",
74
+ "@fluidframework/container-runtime": "~2.22.0",
75
+ "@fluidframework/container-runtime-definitions": "~2.22.0",
76
+ "@fluidframework/core-interfaces": "~2.22.0",
77
+ "@fluidframework/core-utils": "~2.22.0",
78
+ "@fluidframework/datastore": "~2.22.0",
79
+ "@fluidframework/datastore-definitions": "~2.22.0",
80
+ "@fluidframework/map": "~2.22.0",
81
+ "@fluidframework/request-handler": "~2.22.0",
82
+ "@fluidframework/runtime-definitions": "~2.22.0",
83
+ "@fluidframework/runtime-utils": "~2.22.0",
84
+ "@fluidframework/shared-object-base": "~2.22.0",
85
+ "@fluidframework/synthesize": "~2.22.0"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@arethetypeswrong/cli": "^0.17.1",
89
89
  "@biomejs/biome": "~1.9.3",
90
- "@fluid-internal/mocha-test-setup": "~2.20.0",
90
+ "@fluid-internal/mocha-test-setup": "~2.22.0",
91
91
  "@fluid-tools/build-cli": "^0.51.0",
92
- "@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@2.13.0",
92
+ "@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@2.21.0",
93
93
  "@fluidframework/build-common": "^2.0.3",
94
94
  "@fluidframework/build-tools": "^0.51.0",
95
- "@fluidframework/eslint-config-fluid": "^5.6.0",
95
+ "@fluidframework/eslint-config-fluid": "^5.7.3",
96
96
  "@microsoft/api-extractor": "7.47.8",
97
97
  "@types/mocha": "^10.0.10",
98
98
  "@types/node": "^18.19.0",
@@ -109,11 +109,7 @@
109
109
  "typescript": "~5.4.5"
110
110
  },
111
111
  "typeValidation": {
112
- "broken": {
113
- "Interface_IDataObjectProps": {
114
- "backCompat": false
115
- }
116
- },
112
+ "broken": {},
117
113
  "entrypoint": "legacy"
118
114
  },
119
115
  "scripts": {
@@ -145,7 +141,7 @@
145
141
  "ci:build:api-reports:current": "api-extractor run --config api-extractor/api-extractor.current.json",
146
142
  "ci:build:api-reports:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
147
143
  "ci:build:docs": "api-extractor run",
148
- "clean": "rimraf --glob dist lib \"*.d.ts\" \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
144
+ "clean": "rimraf --glob dist lib {alpha,beta,internal,legacy}.d.ts \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
149
145
  "eslint": "eslint --format stylish src",
150
146
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
151
147
  "format": "npm run format:biome",
@@ -156,8 +152,8 @@
156
152
  "test": "npm run test:mocha",
157
153
  "test:coverage": "c8 npm test",
158
154
  "test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
159
- "test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\" --exit",
160
- "test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit",
155
+ "test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\"",
156
+ "test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\"",
161
157
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
162
158
  "tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
163
159
  "typetests:gen": "flub generate typetests --dir . -v",
@@ -3,7 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- // eslint-disable-next-line import/no-deprecated
7
6
  import {
8
7
  type ISharedDirectory,
9
8
  MapFactory,
@@ -48,7 +47,7 @@ export abstract class DataObject<
48
47
  * Initializes internal objects and calls initialization overrides.
49
48
  * Caller is responsible for ensuring this is only invoked once.
50
49
  */
51
- public async initializeInternal(existing: boolean): Promise<void> {
50
+ public override async initializeInternal(existing: boolean): Promise<void> {
52
51
  if (existing) {
53
52
  // data store has a root directory so we just need to set it before calling initializingFromExisting
54
53
  this.internalRoot = (await this.runtime.getChannel(
@@ -68,7 +67,6 @@ export abstract class DataObject<
68
67
  }
69
68
  } else {
70
69
  // Create a root directory and register it before calling initializingFirstTime
71
- // eslint-disable-next-line import/no-deprecated
72
70
  this.internalRoot = SharedDirectory.create(this.runtime, this.rootDirectoryId);
73
71
  this.internalRoot.bindToContext();
74
72
  }
@@ -87,6 +85,7 @@ export abstract class DataObject<
87
85
 
88
86
  /**
89
87
  * Utility for creating SharedObjectKind instances for data objects.
88
+ * @typeParam T - The kind of data object.
90
89
  * @internal
91
90
  */
92
91
  export function createDataObjectKind<T extends new (...any) => DataObject>(
@@ -25,8 +25,10 @@ import type { DataObjectTypes, IDataObjectProps } from "./types.js";
25
25
 
26
26
  /**
27
27
  * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.
28
+ *
29
+ * @remarks
28
30
  * You probably don't want to inherit from this data store directly unless
29
- * you are creating another base data store class
31
+ * you are creating another base data store class.
30
32
  *
31
33
  * @typeParam I - The optional input types used to strongly type the data object
32
34
  * @legacy
@@ -58,6 +60,13 @@ export abstract class PureDataObject<I extends DataObjectTypes = DataObjectTypes
58
60
 
59
61
  protected initProps?: I["InitialState"];
60
62
 
63
+ /**
64
+ * Internal implementation detail.
65
+ * Subclasses should not use this.
66
+ * @privateRemarks
67
+ * For unknown reasons this API was exposed as a protected member with no documented behavior nor any external usage or clear use-case.
68
+ * Ideally a breaking change would be made to replace this with a better named private property like `#initializationPromise` when permitted.
69
+ */
61
70
  protected initializeP: Promise<void> | undefined;
62
71
 
63
72
  public get id(): string {
@@ -117,17 +126,14 @@ export abstract class PureDataObject<I extends DataObjectTypes = DataObjectTypes
117
126
  }
118
127
 
119
128
  /**
120
- * Call this API to ensure PureDataObject is fully initialized.
129
+ * Await this API to ensure PureDataObject is fully initialized.
121
130
  * Initialization happens on demand, only on as-needed bases.
122
131
  * In most cases you should allow factory/object to decide when to finish initialization.
123
132
  * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods
124
- * and need a fully initialized object, then you can call this API to ensure object is fully initialized.
133
+ * and need a fully initialized object, then you can await this API to ensure object is fully initialized.
125
134
  */
126
135
  public async finishInitialization(existing: boolean): Promise<void> {
127
- if (this.initializeP !== undefined) {
128
- return this.initializeP;
129
- }
130
- this.initializeP = this.initializeInternal(existing);
136
+ this.initializeP ??= this.initializeInternal(existing);
131
137
  return this.initializeP;
132
138
  }
133
139