@fluidframework/aqueduct 2.40.0 → 2.41.0-338186

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.
@@ -37,6 +37,10 @@ export declare abstract class TreeDataObject<TTreeView> extends PureDataObject {
37
37
  * @remarks Called once during initialization.
38
38
  */
39
39
  protected abstract generateView(tree: ITree): TTreeView;
40
+ /**
41
+ * Gets the underlying {@link @fluidframework/tree#ITree | tree}.
42
+ */
43
+ get sharedTree(): ITree;
40
44
  /**
41
45
  * Gets the derived view of the underlying tree.
42
46
  *
@@ -1 +1 @@
1
- {"version":3,"file":"treeDataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,KAAK,EAAc,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUrD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,8BAAsB,cAAc,CAAC,SAAS,CAAE,SAAQ,cAAc;;IACrE;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS;IAQvD;;;;;OAKG;IACH,IAAW,QAAQ,IAAI,SAAS,CAK/B;IAEqB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CA0B1E"}
1
+ {"version":3,"file":"treeDataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,KAAK,EAAc,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUrD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,8BAAsB,cAAc,CAAC,SAAS,CAAE,SAAQ,cAAc;;IACrE;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS;IAQvD;;OAEG;IACH,IAAW,UAAU,IAAI,KAAK,CAK7B;IAQD;;;;;OAKG;IACH,IAAW,QAAQ,IAAI,SAAS,CAK/B;IAEqB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CA6B1E"}
@@ -14,7 +14,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
14
14
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
15
15
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
16
  };
17
- var _TreeDataObject_view;
17
+ var _TreeDataObject_sharedTree, _TreeDataObject_view;
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.TreeDataObject = void 0;
20
20
  const internal_1 = require("@fluidframework/telemetry-utils/internal");
@@ -54,12 +54,26 @@ const uninitializedErrorString = "The tree has not yet been initialized. The dat
54
54
  class TreeDataObject extends pureDataObject_js_1.PureDataObject {
55
55
  constructor() {
56
56
  super(...arguments);
57
+ /**
58
+ * Implementation of SharedTree which is used to generate the view.
59
+ * @remarks Created once during initialization.
60
+ */
61
+ _TreeDataObject_sharedTree.set(this, void 0);
57
62
  /**
58
63
  * View derived from the underlying tree.
59
64
  * @remarks Populated via {@link TreeDataObject.generateView}.
60
65
  */
61
66
  _TreeDataObject_view.set(this, void 0);
62
67
  }
68
+ /**
69
+ * Gets the underlying {@link @fluidframework/tree#ITree | tree}.
70
+ */
71
+ get sharedTree() {
72
+ if (__classPrivateFieldGet(this, _TreeDataObject_sharedTree, "f") === undefined) {
73
+ throw new internal_1.UsageError(uninitializedErrorString);
74
+ }
75
+ return __classPrivateFieldGet(this, _TreeDataObject_sharedTree, "f");
76
+ }
63
77
  /**
64
78
  * Gets the derived view of the underlying tree.
65
79
  *
@@ -82,11 +96,13 @@ class TreeDataObject extends pureDataObject_js_1.PureDataObject {
82
96
  throw new Error(`Content with id ${channel.id} is not a SharedTree and cannot be loaded with treeDataObject.`);
83
97
  }
84
98
  const sharedTree = channel;
99
+ __classPrivateFieldSet(this, _TreeDataObject_sharedTree, sharedTree, "f");
85
100
  __classPrivateFieldSet(this, _TreeDataObject_view, this.generateView(sharedTree), "f");
86
101
  }
87
102
  else {
88
103
  const sharedTree = internal_2.SharedTree.create(this.runtime, treeChannelId);
89
104
  sharedTree.bindToContext();
105
+ __classPrivateFieldSet(this, _TreeDataObject_sharedTree, sharedTree, "f");
90
106
  __classPrivateFieldSet(this, _TreeDataObject_view, this.generateView(sharedTree), "f");
91
107
  // Note, the implementer is responsible for initializing the tree with initial data.
92
108
  // Generally, this can be done via `initializingFirstTime`.
@@ -95,5 +111,5 @@ class TreeDataObject extends pureDataObject_js_1.PureDataObject {
95
111
  }
96
112
  }
97
113
  exports.TreeDataObject = TreeDataObject;
98
- _TreeDataObject_view = new WeakMap();
114
+ _TreeDataObject_sharedTree = new WeakMap(), _TreeDataObject_view = new WeakMap();
99
115
  //# sourceMappingURL=treeDataObject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeDataObject.js","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAGH,uEAAsE;AACtE,4DAAuE;AAEvE,2DAAqD;AAErD;;GAEG;AACH,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEzC,MAAM,wBAAwB,GAC7B,8FAA8F,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAsB,cAA0B,SAAQ,kCAAc;IAAtE;;QAOC;;;WAGG;QACH,uCAA6B;IAyC9B,CAAC;IAvCA;;;;;OAKG;IACH,IAAW,QAAQ;QAClB,IAAI,uBAAA,IAAI,4BAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,qBAAU,CAAC,wBAAwB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,uBAAA,IAAI,4BAAM,CAAC;IACnB,CAAC;IAEe,KAAK,CAAC,kBAAkB,CAAC,QAAiB;QACzD,IAAI,QAAQ,EAAE,CAAC;YACd,+FAA+F;YAC/F,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YAE7D,0FAA0F;YAC1F,8FAA8F;YAC9F,IAAI,CAAC,qBAAU,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CACd,mBAAmB,OAAO,CAAC,EAAE,gEAAgE,CAC7F,CAAC;YACH,CAAC;YACD,MAAM,UAAU,GAAU,OAAO,CAAC;YAClC,uBAAA,IAAI,wBAAS,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAA,CAAC;QAC5C,CAAC;aAAM,CAAC;YACP,MAAM,UAAU,GAAG,qBAAU,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YACjE,UAAuC,CAAC,aAAa,EAAE,CAAC;YAEzD,uBAAA,IAAI,wBAAS,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAA,CAAC;YAE3C,oFAAoF;YACpF,2DAA2D;QAC5D,CAAC;QAED,MAAM,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACD;AApDD,wCAoDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ISharedObject } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { type ITree, SharedTree } from \"@fluidframework/tree/internal\";\n\nimport { PureDataObject } from \"./pureDataObject.js\";\n\n/**\n * Channel ID of {@link TreeDataObject}'s root {@link @fluidframework/tree#SharedTree}.\n */\nconst treeChannelId = \"tree-data-object\";\n\nconst uninitializedErrorString =\n\t\"The tree has not yet been initialized. The data object must be initialized before accessing.\";\n\n/**\n * {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.\n *\n * @remarks\n *\n * Note: to initialize the tree's data for initial creation, implementers of this class will need to override {@link PureDataObject.initializingFirstTime} and set the data in {@link TreeDataObject.treeView}.\n *\n * @typeParam TTreeView - View derived from the underlying tree.\n * Can be used to derive schema-aware views of the tree.\n * See {@link TreeDataObject.generateView}.\n *\n * @example Implementing `initializingFirstTime`\n *\n * ```typescript\n * protected override async initializingFirstTime(): Promise<void> {\n * \tthis.tree.initialize(...);\n * }\n * ```\n *\n * @privateRemarks\n * TODO: Before promoting this beyond internal, we should consider alternative API patterns that don't depend on\n * sub-classing and don't leak Fluid concepts that should ideally be internal.\n * See `tree-react-api` for an example of a pattern that avoids unnecessary leakage of implementation details.\n *\n * @internal\n */\nexport abstract class TreeDataObject<TTreeView> extends PureDataObject {\n\t/**\n\t * Generates a view of the data object's {@link @fluidframework/tree#ITree | tree}.\n\t * @remarks Called once during initialization.\n\t */\n\tprotected abstract generateView(tree: ITree): TTreeView;\n\n\t/**\n\t * View derived from the underlying tree.\n\t * @remarks Populated via {@link TreeDataObject.generateView}.\n\t */\n\t#view: TTreeView | undefined;\n\n\t/**\n\t * Gets the derived view of the underlying tree.\n\t *\n\t * @throws\n\t * If the tree has not yet been initialized, this will throw an error.\n\t */\n\tpublic get treeView(): TTreeView {\n\t\tif (this.#view === undefined) {\n\t\t\tthrow new UsageError(uninitializedErrorString);\n\t\t}\n\t\treturn this.#view;\n\t}\n\n\tpublic override async initializeInternal(existing: boolean): Promise<void> {\n\t\tif (existing) {\n\t\t\t// data store has a root tree so we just need to set it before calling initializingFromExisting\n\t\t\tconst channel = await this.runtime.getChannel(treeChannelId);\n\n\t\t\t// TODO: Support using a Directory to Tree migration shim and DataObject's root channel ID\n\t\t\t// to allow migrating from DataObject to TreeDataObject instead of just erroring in that case.\n\t\t\tif (!SharedTree.is(channel)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Content with id ${channel.id} is not a SharedTree and cannot be loaded with treeDataObject.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst sharedTree: ITree = channel;\n\t\t\tthis.#view = this.generateView(sharedTree);\n\t\t} else {\n\t\t\tconst sharedTree = SharedTree.create(this.runtime, treeChannelId);\n\t\t\t(sharedTree as unknown as ISharedObject).bindToContext();\n\n\t\t\tthis.#view = this.generateView(sharedTree);\n\n\t\t\t// Note, the implementer is responsible for initializing the tree with initial data.\n\t\t\t// Generally, this can be done via `initializingFirstTime`.\n\t\t}\n\n\t\tawait super.initializeInternal(existing);\n\t}\n}\n"]}
1
+ {"version":3,"file":"treeDataObject.js","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAGH,uEAAsE;AACtE,4DAAuE;AAEvE,2DAAqD;AAErD;;GAEG;AACH,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEzC,MAAM,wBAAwB,GAC7B,8FAA8F,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAsB,cAA0B,SAAQ,kCAAc;IAAtE;;QAOC;;;WAGG;QACH,6CAA+B;QAY/B;;;WAGG;QACH,uCAA6B;IA4C9B,CAAC;IA1DA;;OAEG;IACH,IAAW,UAAU;QACpB,IAAI,uBAAA,IAAI,kCAAY,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,IAAI,qBAAU,CAAC,wBAAwB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,uBAAA,IAAI,kCAAY,CAAC;IACzB,CAAC;IAQD;;;;;OAKG;IACH,IAAW,QAAQ;QAClB,IAAI,uBAAA,IAAI,4BAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,qBAAU,CAAC,wBAAwB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,uBAAA,IAAI,4BAAM,CAAC;IACnB,CAAC;IAEe,KAAK,CAAC,kBAAkB,CAAC,QAAiB;QACzD,IAAI,QAAQ,EAAE,CAAC;YACd,+FAA+F;YAC/F,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YAE7D,0FAA0F;YAC1F,8FAA8F;YAC9F,IAAI,CAAC,qBAAU,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CACd,mBAAmB,OAAO,CAAC,EAAE,gEAAgE,CAC7F,CAAC;YACH,CAAC;YACD,MAAM,UAAU,GAAU,OAAO,CAAC;YAElC,uBAAA,IAAI,8BAAe,UAAU,MAAA,CAAC;YAC9B,uBAAA,IAAI,wBAAS,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAA,CAAC;QAC5C,CAAC;aAAM,CAAC;YACP,MAAM,UAAU,GAAG,qBAAU,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YACjE,UAAuC,CAAC,aAAa,EAAE,CAAC;YAEzD,uBAAA,IAAI,8BAAe,UAAU,MAAA,CAAC;YAC9B,uBAAA,IAAI,wBAAS,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAA,CAAC;YAE3C,oFAAoF;YACpF,2DAA2D;QAC5D,CAAC;QAED,MAAM,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACD;AAvED,wCAuEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ISharedObject } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { type ITree, SharedTree } from \"@fluidframework/tree/internal\";\n\nimport { PureDataObject } from \"./pureDataObject.js\";\n\n/**\n * Channel ID of {@link TreeDataObject}'s root {@link @fluidframework/tree#SharedTree}.\n */\nconst treeChannelId = \"tree-data-object\";\n\nconst uninitializedErrorString =\n\t\"The tree has not yet been initialized. The data object must be initialized before accessing.\";\n\n/**\n * {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.\n *\n * @remarks\n *\n * Note: to initialize the tree's data for initial creation, implementers of this class will need to override {@link PureDataObject.initializingFirstTime} and set the data in {@link TreeDataObject.treeView}.\n *\n * @typeParam TTreeView - View derived from the underlying tree.\n * Can be used to derive schema-aware views of the tree.\n * See {@link TreeDataObject.generateView}.\n *\n * @example Implementing `initializingFirstTime`\n *\n * ```typescript\n * protected override async initializingFirstTime(): Promise<void> {\n * \tthis.tree.initialize(...);\n * }\n * ```\n *\n * @privateRemarks\n * TODO: Before promoting this beyond internal, we should consider alternative API patterns that don't depend on\n * sub-classing and don't leak Fluid concepts that should ideally be internal.\n * See `tree-react-api` for an example of a pattern that avoids unnecessary leakage of implementation details.\n *\n * @internal\n */\nexport abstract class TreeDataObject<TTreeView> extends PureDataObject {\n\t/**\n\t * Generates a view of the data object's {@link @fluidframework/tree#ITree | tree}.\n\t * @remarks Called once during initialization.\n\t */\n\tprotected abstract generateView(tree: ITree): TTreeView;\n\n\t/**\n\t * Implementation of SharedTree which is used to generate the view.\n\t * @remarks Created once during initialization.\n\t */\n\t#sharedTree: ITree | undefined;\n\n\t/**\n\t * Gets the underlying {@link @fluidframework/tree#ITree | tree}.\n\t */\n\tpublic get sharedTree(): ITree {\n\t\tif (this.#sharedTree === undefined) {\n\t\t\tthrow new UsageError(uninitializedErrorString);\n\t\t}\n\t\treturn this.#sharedTree;\n\t}\n\n\t/**\n\t * View derived from the underlying tree.\n\t * @remarks Populated via {@link TreeDataObject.generateView}.\n\t */\n\t#view: TTreeView | undefined;\n\n\t/**\n\t * Gets the derived view of the underlying tree.\n\t *\n\t * @throws\n\t * If the tree has not yet been initialized, this will throw an error.\n\t */\n\tpublic get treeView(): TTreeView {\n\t\tif (this.#view === undefined) {\n\t\t\tthrow new UsageError(uninitializedErrorString);\n\t\t}\n\t\treturn this.#view;\n\t}\n\n\tpublic override async initializeInternal(existing: boolean): Promise<void> {\n\t\tif (existing) {\n\t\t\t// data store has a root tree so we just need to set it before calling initializingFromExisting\n\t\t\tconst channel = await this.runtime.getChannel(treeChannelId);\n\n\t\t\t// TODO: Support using a Directory to Tree migration shim and DataObject's root channel ID\n\t\t\t// to allow migrating from DataObject to TreeDataObject instead of just erroring in that case.\n\t\t\tif (!SharedTree.is(channel)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Content with id ${channel.id} is not a SharedTree and cannot be loaded with treeDataObject.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst sharedTree: ITree = channel;\n\n\t\t\tthis.#sharedTree = sharedTree;\n\t\t\tthis.#view = this.generateView(sharedTree);\n\t\t} else {\n\t\t\tconst sharedTree = SharedTree.create(this.runtime, treeChannelId);\n\t\t\t(sharedTree as unknown as ISharedObject).bindToContext();\n\n\t\t\tthis.#sharedTree = sharedTree;\n\t\t\tthis.#view = this.generateView(sharedTree);\n\n\t\t\t// Note, the implementer is responsible for initializing the tree with initial data.\n\t\t\t// Generally, this can be done via `initializingFirstTime`.\n\t\t}\n\n\t\tawait super.initializeInternal(existing);\n\t}\n}\n"]}
@@ -37,6 +37,10 @@ export declare abstract class TreeDataObject<TTreeView> extends PureDataObject {
37
37
  * @remarks Called once during initialization.
38
38
  */
39
39
  protected abstract generateView(tree: ITree): TTreeView;
40
+ /**
41
+ * Gets the underlying {@link @fluidframework/tree#ITree | tree}.
42
+ */
43
+ get sharedTree(): ITree;
40
44
  /**
41
45
  * Gets the derived view of the underlying tree.
42
46
  *
@@ -1 +1 @@
1
- {"version":3,"file":"treeDataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,KAAK,EAAc,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUrD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,8BAAsB,cAAc,CAAC,SAAS,CAAE,SAAQ,cAAc;;IACrE;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS;IAQvD;;;;;OAKG;IACH,IAAW,QAAQ,IAAI,SAAS,CAK/B;IAEqB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CA0B1E"}
1
+ {"version":3,"file":"treeDataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,KAAK,EAAc,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUrD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,8BAAsB,cAAc,CAAC,SAAS,CAAE,SAAQ,cAAc;;IACrE;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS;IAQvD;;OAEG;IACH,IAAW,UAAU,IAAI,KAAK,CAK7B;IAQD;;;;;OAKG;IACH,IAAW,QAAQ,IAAI,SAAS,CAK/B;IAEqB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CA6B1E"}
@@ -13,7 +13,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
13
13
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
14
14
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
15
15
  };
16
- var _TreeDataObject_view;
16
+ var _TreeDataObject_sharedTree, _TreeDataObject_view;
17
17
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
18
18
  import { SharedTree } from "@fluidframework/tree/internal";
19
19
  import { PureDataObject } from "./pureDataObject.js";
@@ -51,12 +51,26 @@ const uninitializedErrorString = "The tree has not yet been initialized. The dat
51
51
  export class TreeDataObject extends PureDataObject {
52
52
  constructor() {
53
53
  super(...arguments);
54
+ /**
55
+ * Implementation of SharedTree which is used to generate the view.
56
+ * @remarks Created once during initialization.
57
+ */
58
+ _TreeDataObject_sharedTree.set(this, void 0);
54
59
  /**
55
60
  * View derived from the underlying tree.
56
61
  * @remarks Populated via {@link TreeDataObject.generateView}.
57
62
  */
58
63
  _TreeDataObject_view.set(this, void 0);
59
64
  }
65
+ /**
66
+ * Gets the underlying {@link @fluidframework/tree#ITree | tree}.
67
+ */
68
+ get sharedTree() {
69
+ if (__classPrivateFieldGet(this, _TreeDataObject_sharedTree, "f") === undefined) {
70
+ throw new UsageError(uninitializedErrorString);
71
+ }
72
+ return __classPrivateFieldGet(this, _TreeDataObject_sharedTree, "f");
73
+ }
60
74
  /**
61
75
  * Gets the derived view of the underlying tree.
62
76
  *
@@ -79,11 +93,13 @@ export class TreeDataObject extends PureDataObject {
79
93
  throw new Error(`Content with id ${channel.id} is not a SharedTree and cannot be loaded with treeDataObject.`);
80
94
  }
81
95
  const sharedTree = channel;
96
+ __classPrivateFieldSet(this, _TreeDataObject_sharedTree, sharedTree, "f");
82
97
  __classPrivateFieldSet(this, _TreeDataObject_view, this.generateView(sharedTree), "f");
83
98
  }
84
99
  else {
85
100
  const sharedTree = SharedTree.create(this.runtime, treeChannelId);
86
101
  sharedTree.bindToContext();
102
+ __classPrivateFieldSet(this, _TreeDataObject_sharedTree, sharedTree, "f");
87
103
  __classPrivateFieldSet(this, _TreeDataObject_view, this.generateView(sharedTree), "f");
88
104
  // Note, the implementer is responsible for initializing the tree with initial data.
89
105
  // Generally, this can be done via `initializingFirstTime`.
@@ -91,5 +107,5 @@ export class TreeDataObject extends PureDataObject {
91
107
  await super.initializeInternal(existing);
92
108
  }
93
109
  }
94
- _TreeDataObject_view = new WeakMap();
110
+ _TreeDataObject_sharedTree = new WeakMap(), _TreeDataObject_view = new WeakMap();
95
111
  //# sourceMappingURL=treeDataObject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeDataObject.js","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAc,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;GAEG;AACH,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEzC,MAAM,wBAAwB,GAC7B,8FAA8F,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAgB,cAA0B,SAAQ,cAAc;IAAtE;;QAOC;;;WAGG;QACH,uCAA6B;IAyC9B,CAAC;IAvCA;;;;;OAKG;IACH,IAAW,QAAQ;QAClB,IAAI,uBAAA,IAAI,4BAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,UAAU,CAAC,wBAAwB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,uBAAA,IAAI,4BAAM,CAAC;IACnB,CAAC;IAEe,KAAK,CAAC,kBAAkB,CAAC,QAAiB;QACzD,IAAI,QAAQ,EAAE,CAAC;YACd,+FAA+F;YAC/F,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YAE7D,0FAA0F;YAC1F,8FAA8F;YAC9F,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CACd,mBAAmB,OAAO,CAAC,EAAE,gEAAgE,CAC7F,CAAC;YACH,CAAC;YACD,MAAM,UAAU,GAAU,OAAO,CAAC;YAClC,uBAAA,IAAI,wBAAS,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAA,CAAC;QAC5C,CAAC;aAAM,CAAC;YACP,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YACjE,UAAuC,CAAC,aAAa,EAAE,CAAC;YAEzD,uBAAA,IAAI,wBAAS,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAA,CAAC;YAE3C,oFAAoF;YACpF,2DAA2D;QAC5D,CAAC;QAED,MAAM,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ISharedObject } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { type ITree, SharedTree } from \"@fluidframework/tree/internal\";\n\nimport { PureDataObject } from \"./pureDataObject.js\";\n\n/**\n * Channel ID of {@link TreeDataObject}'s root {@link @fluidframework/tree#SharedTree}.\n */\nconst treeChannelId = \"tree-data-object\";\n\nconst uninitializedErrorString =\n\t\"The tree has not yet been initialized. The data object must be initialized before accessing.\";\n\n/**\n * {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.\n *\n * @remarks\n *\n * Note: to initialize the tree's data for initial creation, implementers of this class will need to override {@link PureDataObject.initializingFirstTime} and set the data in {@link TreeDataObject.treeView}.\n *\n * @typeParam TTreeView - View derived from the underlying tree.\n * Can be used to derive schema-aware views of the tree.\n * See {@link TreeDataObject.generateView}.\n *\n * @example Implementing `initializingFirstTime`\n *\n * ```typescript\n * protected override async initializingFirstTime(): Promise<void> {\n * \tthis.tree.initialize(...);\n * }\n * ```\n *\n * @privateRemarks\n * TODO: Before promoting this beyond internal, we should consider alternative API patterns that don't depend on\n * sub-classing and don't leak Fluid concepts that should ideally be internal.\n * See `tree-react-api` for an example of a pattern that avoids unnecessary leakage of implementation details.\n *\n * @internal\n */\nexport abstract class TreeDataObject<TTreeView> extends PureDataObject {\n\t/**\n\t * Generates a view of the data object's {@link @fluidframework/tree#ITree | tree}.\n\t * @remarks Called once during initialization.\n\t */\n\tprotected abstract generateView(tree: ITree): TTreeView;\n\n\t/**\n\t * View derived from the underlying tree.\n\t * @remarks Populated via {@link TreeDataObject.generateView}.\n\t */\n\t#view: TTreeView | undefined;\n\n\t/**\n\t * Gets the derived view of the underlying tree.\n\t *\n\t * @throws\n\t * If the tree has not yet been initialized, this will throw an error.\n\t */\n\tpublic get treeView(): TTreeView {\n\t\tif (this.#view === undefined) {\n\t\t\tthrow new UsageError(uninitializedErrorString);\n\t\t}\n\t\treturn this.#view;\n\t}\n\n\tpublic override async initializeInternal(existing: boolean): Promise<void> {\n\t\tif (existing) {\n\t\t\t// data store has a root tree so we just need to set it before calling initializingFromExisting\n\t\t\tconst channel = await this.runtime.getChannel(treeChannelId);\n\n\t\t\t// TODO: Support using a Directory to Tree migration shim and DataObject's root channel ID\n\t\t\t// to allow migrating from DataObject to TreeDataObject instead of just erroring in that case.\n\t\t\tif (!SharedTree.is(channel)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Content with id ${channel.id} is not a SharedTree and cannot be loaded with treeDataObject.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst sharedTree: ITree = channel;\n\t\t\tthis.#view = this.generateView(sharedTree);\n\t\t} else {\n\t\t\tconst sharedTree = SharedTree.create(this.runtime, treeChannelId);\n\t\t\t(sharedTree as unknown as ISharedObject).bindToContext();\n\n\t\t\tthis.#view = this.generateView(sharedTree);\n\n\t\t\t// Note, the implementer is responsible for initializing the tree with initial data.\n\t\t\t// Generally, this can be done via `initializingFirstTime`.\n\t\t}\n\n\t\tawait super.initializeInternal(existing);\n\t}\n}\n"]}
1
+ {"version":3,"file":"treeDataObject.js","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAc,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;GAEG;AACH,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEzC,MAAM,wBAAwB,GAC7B,8FAA8F,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAgB,cAA0B,SAAQ,cAAc;IAAtE;;QAOC;;;WAGG;QACH,6CAA+B;QAY/B;;;WAGG;QACH,uCAA6B;IA4C9B,CAAC;IA1DA;;OAEG;IACH,IAAW,UAAU;QACpB,IAAI,uBAAA,IAAI,kCAAY,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,IAAI,UAAU,CAAC,wBAAwB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,uBAAA,IAAI,kCAAY,CAAC;IACzB,CAAC;IAQD;;;;;OAKG;IACH,IAAW,QAAQ;QAClB,IAAI,uBAAA,IAAI,4BAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,UAAU,CAAC,wBAAwB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,uBAAA,IAAI,4BAAM,CAAC;IACnB,CAAC;IAEe,KAAK,CAAC,kBAAkB,CAAC,QAAiB;QACzD,IAAI,QAAQ,EAAE,CAAC;YACd,+FAA+F;YAC/F,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YAE7D,0FAA0F;YAC1F,8FAA8F;YAC9F,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CACd,mBAAmB,OAAO,CAAC,EAAE,gEAAgE,CAC7F,CAAC;YACH,CAAC;YACD,MAAM,UAAU,GAAU,OAAO,CAAC;YAElC,uBAAA,IAAI,8BAAe,UAAU,MAAA,CAAC;YAC9B,uBAAA,IAAI,wBAAS,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAA,CAAC;QAC5C,CAAC;aAAM,CAAC;YACP,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YACjE,UAAuC,CAAC,aAAa,EAAE,CAAC;YAEzD,uBAAA,IAAI,8BAAe,UAAU,MAAA,CAAC;YAC9B,uBAAA,IAAI,wBAAS,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAA,CAAC;YAE3C,oFAAoF;YACpF,2DAA2D;QAC5D,CAAC;QAED,MAAM,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ISharedObject } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { type ITree, SharedTree } from \"@fluidframework/tree/internal\";\n\nimport { PureDataObject } from \"./pureDataObject.js\";\n\n/**\n * Channel ID of {@link TreeDataObject}'s root {@link @fluidframework/tree#SharedTree}.\n */\nconst treeChannelId = \"tree-data-object\";\n\nconst uninitializedErrorString =\n\t\"The tree has not yet been initialized. The data object must be initialized before accessing.\";\n\n/**\n * {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.\n *\n * @remarks\n *\n * Note: to initialize the tree's data for initial creation, implementers of this class will need to override {@link PureDataObject.initializingFirstTime} and set the data in {@link TreeDataObject.treeView}.\n *\n * @typeParam TTreeView - View derived from the underlying tree.\n * Can be used to derive schema-aware views of the tree.\n * See {@link TreeDataObject.generateView}.\n *\n * @example Implementing `initializingFirstTime`\n *\n * ```typescript\n * protected override async initializingFirstTime(): Promise<void> {\n * \tthis.tree.initialize(...);\n * }\n * ```\n *\n * @privateRemarks\n * TODO: Before promoting this beyond internal, we should consider alternative API patterns that don't depend on\n * sub-classing and don't leak Fluid concepts that should ideally be internal.\n * See `tree-react-api` for an example of a pattern that avoids unnecessary leakage of implementation details.\n *\n * @internal\n */\nexport abstract class TreeDataObject<TTreeView> extends PureDataObject {\n\t/**\n\t * Generates a view of the data object's {@link @fluidframework/tree#ITree | tree}.\n\t * @remarks Called once during initialization.\n\t */\n\tprotected abstract generateView(tree: ITree): TTreeView;\n\n\t/**\n\t * Implementation of SharedTree which is used to generate the view.\n\t * @remarks Created once during initialization.\n\t */\n\t#sharedTree: ITree | undefined;\n\n\t/**\n\t * Gets the underlying {@link @fluidframework/tree#ITree | tree}.\n\t */\n\tpublic get sharedTree(): ITree {\n\t\tif (this.#sharedTree === undefined) {\n\t\t\tthrow new UsageError(uninitializedErrorString);\n\t\t}\n\t\treturn this.#sharedTree;\n\t}\n\n\t/**\n\t * View derived from the underlying tree.\n\t * @remarks Populated via {@link TreeDataObject.generateView}.\n\t */\n\t#view: TTreeView | undefined;\n\n\t/**\n\t * Gets the derived view of the underlying tree.\n\t *\n\t * @throws\n\t * If the tree has not yet been initialized, this will throw an error.\n\t */\n\tpublic get treeView(): TTreeView {\n\t\tif (this.#view === undefined) {\n\t\t\tthrow new UsageError(uninitializedErrorString);\n\t\t}\n\t\treturn this.#view;\n\t}\n\n\tpublic override async initializeInternal(existing: boolean): Promise<void> {\n\t\tif (existing) {\n\t\t\t// data store has a root tree so we just need to set it before calling initializingFromExisting\n\t\t\tconst channel = await this.runtime.getChannel(treeChannelId);\n\n\t\t\t// TODO: Support using a Directory to Tree migration shim and DataObject's root channel ID\n\t\t\t// to allow migrating from DataObject to TreeDataObject instead of just erroring in that case.\n\t\t\tif (!SharedTree.is(channel)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Content with id ${channel.id} is not a SharedTree and cannot be loaded with treeDataObject.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst sharedTree: ITree = channel;\n\n\t\t\tthis.#sharedTree = sharedTree;\n\t\t\tthis.#view = this.generateView(sharedTree);\n\t\t} else {\n\t\t\tconst sharedTree = SharedTree.create(this.runtime, treeChannelId);\n\t\t\t(sharedTree as unknown as ISharedObject).bindToContext();\n\n\t\t\tthis.#sharedTree = sharedTree;\n\t\t\tthis.#view = this.generateView(sharedTree);\n\n\t\t\t// Note, the implementer is responsible for initializing the tree with initial data.\n\t\t\t// Generally, this can be done via `initializingFirstTime`.\n\t\t}\n\n\t\tawait super.initializeInternal(existing);\n\t}\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.5"
8
+ "packageVersion": "7.52.8"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/aqueduct",
3
- "version": "2.40.0",
3
+ "version": "2.41.0-338186",
4
4
  "description": "A set of implementations for Fluid Framework interfaces.",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -69,33 +69,33 @@
69
69
  "temp-directory": "nyc/.nyc_output"
70
70
  },
71
71
  "dependencies": {
72
- "@fluid-internal/client-utils": "~2.40.0",
73
- "@fluidframework/container-definitions": "~2.40.0",
74
- "@fluidframework/container-runtime": "~2.40.0",
75
- "@fluidframework/container-runtime-definitions": "~2.40.0",
76
- "@fluidframework/core-interfaces": "~2.40.0",
77
- "@fluidframework/core-utils": "~2.40.0",
78
- "@fluidframework/datastore": "~2.40.0",
79
- "@fluidframework/datastore-definitions": "~2.40.0",
80
- "@fluidframework/map": "~2.40.0",
81
- "@fluidframework/request-handler": "~2.40.0",
82
- "@fluidframework/runtime-definitions": "~2.40.0",
83
- "@fluidframework/runtime-utils": "~2.40.0",
84
- "@fluidframework/shared-object-base": "~2.40.0",
85
- "@fluidframework/synthesize": "~2.40.0",
86
- "@fluidframework/telemetry-utils": "~2.40.0",
87
- "@fluidframework/tree": "~2.40.0"
72
+ "@fluid-internal/client-utils": "2.41.0-338186",
73
+ "@fluidframework/container-definitions": "2.41.0-338186",
74
+ "@fluidframework/container-runtime": "2.41.0-338186",
75
+ "@fluidframework/container-runtime-definitions": "2.41.0-338186",
76
+ "@fluidframework/core-interfaces": "2.41.0-338186",
77
+ "@fluidframework/core-utils": "2.41.0-338186",
78
+ "@fluidframework/datastore": "2.41.0-338186",
79
+ "@fluidframework/datastore-definitions": "2.41.0-338186",
80
+ "@fluidframework/map": "2.41.0-338186",
81
+ "@fluidframework/request-handler": "2.41.0-338186",
82
+ "@fluidframework/runtime-definitions": "2.41.0-338186",
83
+ "@fluidframework/runtime-utils": "2.41.0-338186",
84
+ "@fluidframework/shared-object-base": "2.41.0-338186",
85
+ "@fluidframework/synthesize": "2.41.0-338186",
86
+ "@fluidframework/telemetry-utils": "2.41.0-338186",
87
+ "@fluidframework/tree": "2.41.0-338186"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@arethetypeswrong/cli": "^0.17.1",
91
91
  "@biomejs/biome": "~1.9.3",
92
- "@fluid-internal/mocha-test-setup": "~2.40.0",
92
+ "@fluid-internal/mocha-test-setup": "2.41.0-338186",
93
93
  "@fluid-tools/build-cli": "^0.55.0",
94
- "@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@2.33.0",
94
+ "@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@2.40.0",
95
95
  "@fluidframework/build-common": "^2.0.3",
96
96
  "@fluidframework/build-tools": "^0.55.0",
97
97
  "@fluidframework/eslint-config-fluid": "^5.7.3",
98
- "@microsoft/api-extractor": "7.52.5",
98
+ "@microsoft/api-extractor": "7.52.8",
99
99
  "@types/mocha": "^10.0.10",
100
100
  "@types/node": "^18.19.0",
101
101
  "c8": "^8.0.1",
@@ -50,6 +50,22 @@ export abstract class TreeDataObject<TTreeView> extends PureDataObject {
50
50
  */
51
51
  protected abstract generateView(tree: ITree): TTreeView;
52
52
 
53
+ /**
54
+ * Implementation of SharedTree which is used to generate the view.
55
+ * @remarks Created once during initialization.
56
+ */
57
+ #sharedTree: ITree | undefined;
58
+
59
+ /**
60
+ * Gets the underlying {@link @fluidframework/tree#ITree | tree}.
61
+ */
62
+ public get sharedTree(): ITree {
63
+ if (this.#sharedTree === undefined) {
64
+ throw new UsageError(uninitializedErrorString);
65
+ }
66
+ return this.#sharedTree;
67
+ }
68
+
53
69
  /**
54
70
  * View derived from the underlying tree.
55
71
  * @remarks Populated via {@link TreeDataObject.generateView}.
@@ -82,11 +98,14 @@ export abstract class TreeDataObject<TTreeView> extends PureDataObject {
82
98
  );
83
99
  }
84
100
  const sharedTree: ITree = channel;
101
+
102
+ this.#sharedTree = sharedTree;
85
103
  this.#view = this.generateView(sharedTree);
86
104
  } else {
87
105
  const sharedTree = SharedTree.create(this.runtime, treeChannelId);
88
106
  (sharedTree as unknown as ISharedObject).bindToContext();
89
107
 
108
+ this.#sharedTree = sharedTree;
90
109
  this.#view = this.generateView(sharedTree);
91
110
 
92
111
  // Note, the implementer is responsible for initializing the tree with initial data.