@fluidframework/aqueduct 2.30.0 → 2.31.1
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 +221 -217
- package/dist/data-objects/createDataObjectKind.d.ts +13 -0
- package/dist/data-objects/createDataObjectKind.d.ts.map +1 -0
- package/dist/data-objects/createDataObjectKind.js +17 -0
- package/dist/data-objects/createDataObjectKind.js.map +1 -0
- package/dist/data-objects/dataObject.d.ts +1 -8
- package/dist/data-objects/dataObject.d.ts.map +1 -1
- package/dist/data-objects/dataObject.js +1 -10
- package/dist/data-objects/dataObject.js.map +1 -1
- package/dist/data-objects/index.d.ts +3 -1
- package/dist/data-objects/index.d.ts.map +1 -1
- package/dist/data-objects/index.js +5 -2
- package/dist/data-objects/index.js.map +1 -1
- package/dist/data-objects/treeDataObject.d.ts +49 -0
- package/dist/data-objects/treeDataObject.d.ts.map +1 -0
- package/dist/data-objects/treeDataObject.js +99 -0
- package/dist/data-objects/treeDataObject.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/lib/data-objects/createDataObjectKind.d.ts +13 -0
- package/lib/data-objects/createDataObjectKind.d.ts.map +1 -0
- package/lib/data-objects/createDataObjectKind.js +13 -0
- package/lib/data-objects/createDataObjectKind.js.map +1 -0
- package/lib/data-objects/dataObject.d.ts +1 -8
- package/lib/data-objects/dataObject.d.ts.map +1 -1
- package/lib/data-objects/dataObject.js +0 -8
- package/lib/data-objects/dataObject.js.map +1 -1
- package/lib/data-objects/index.d.ts +3 -1
- package/lib/data-objects/index.d.ts.map +1 -1
- package/lib/data-objects/index.js +3 -1
- package/lib/data-objects/index.js.map +1 -1
- package/lib/data-objects/treeDataObject.d.ts +49 -0
- package/lib/data-objects/treeDataObject.d.ts.map +1 -0
- package/lib/data-objects/treeDataObject.js +95 -0
- package/lib/data-objects/treeDataObject.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +20 -21
- package/src/data-objects/createDataObjectKind.ts +19 -0
- package/src/data-objects/dataObject.ts +1 -13
- package/src/data-objects/index.ts +3 -1
- package/src/data-objects/treeDataObject.ts +98 -0
- package/src/index.ts +5 -1
- package/prettier.config.cjs +0 -8
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
6
|
+
import type { DataObjectKind } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Utility for creating SharedObjectKind instances for data objects.
|
|
9
|
+
* @typeParam T - The kind of data object.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function createDataObjectKind<T extends DataObjectKind>(factory: T): T & SharedObjectKind<T extends DataObjectKind<infer I> ? I : unknown>;
|
|
13
|
+
//# sourceMappingURL=createDataObjectKind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDataObjectKind.d.ts","sourceRoot":"","sources":["../../src/data-objects/createDataObjectKind.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,cAAc,EAC5D,OAAO,EAAE,CAAC,GACR,CAAC,GAAG,gBAAgB,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAEvE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createDataObjectKind = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Utility for creating SharedObjectKind instances for data objects.
|
|
10
|
+
* @typeParam T - The kind of data object.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
function createDataObjectKind(factory) {
|
|
14
|
+
return factory;
|
|
15
|
+
}
|
|
16
|
+
exports.createDataObjectKind = createDataObjectKind;
|
|
17
|
+
//# sourceMappingURL=createDataObjectKind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDataObjectKind.js","sourceRoot":"","sources":["../../src/data-objects/createDataObjectKind.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;;;GAIG;AACH,SAAgB,oBAAoB,CACnC,OAAU;IAEV,OAAO,OAAgF,CAAC;AACzF,CAAC;AAJD,oDAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\n\nimport type { DataObjectKind } from \"./types.js\";\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 DataObjectKind>(\n\tfactory: T,\n): T & SharedObjectKind<T extends DataObjectKind<infer I> ? I : unknown> {\n\treturn factory as T & SharedObjectKind<T extends DataObjectKind<infer I> ? I : unknown>;\n}\n"]}
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { type ISharedDirectory } from "@fluidframework/map/internal";
|
|
6
|
-
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
7
6
|
import { PureDataObject } from "./pureDataObject.js";
|
|
8
|
-
import type {
|
|
7
|
+
import type { DataObjectTypes } from "./types.js";
|
|
9
8
|
/**
|
|
10
9
|
* DataObject is a base data store that is primed with a root directory. It
|
|
11
10
|
* ensures that it is created and ready before you can access it.
|
|
@@ -37,10 +36,4 @@ export declare abstract class DataObject<I extends DataObjectTypes = DataObjectT
|
|
|
37
36
|
*/
|
|
38
37
|
protected getUninitializedErrorString(item: string): string;
|
|
39
38
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Utility for creating SharedObjectKind instances for data objects.
|
|
42
|
-
* @typeParam T - The kind of data object.
|
|
43
|
-
* @internal
|
|
44
|
-
*/
|
|
45
|
-
export declare function createDataObjectKind<T extends DataObjectKind>(factory: T): T & SharedObjectKind<T extends DataObjectKind<infer I> ? I : unknown>;
|
|
46
39
|
//# sourceMappingURL=dataObject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAEtC,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"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.DataObject = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/map/internal");
|
|
9
9
|
const pureDataObject_js_1 = require("./pureDataObject.js");
|
|
10
10
|
/**
|
|
@@ -69,13 +69,4 @@ class DataObject extends pureDataObject_js_1.PureDataObject {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
exports.DataObject = DataObject;
|
|
72
|
-
/**
|
|
73
|
-
* Utility for creating SharedObjectKind instances for data objects.
|
|
74
|
-
* @typeParam T - The kind of data object.
|
|
75
|
-
* @internal
|
|
76
|
-
*/
|
|
77
|
-
function createDataObjectKind(factory) {
|
|
78
|
-
return factory;
|
|
79
|
-
}
|
|
80
|
-
exports.createDataObjectKind = createDataObjectKind;
|
|
81
72
|
//# sourceMappingURL=dataObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAIsC;
|
|
1
|
+
{"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAIsC;AAEtC,2DAAqD;AAGrD;;;;;;;;;;;GAWG;AACH,MAAsB,UAEpB,SAAQ,kCAAiB;IAF3B;;QAIkB,oBAAe,GAAG,MAAM,CAAC;IAoD3C,CAAC;IAlDA;;;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;IACa,KAAK,CAAC,kBAAkB,CAAC,QAAiB;QACzD,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,qBAAU,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,IAAI,CAAC,YAAY,GAAG,0BAAe,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;AAxDD,gCAwDC","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\";\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"]}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export {
|
|
5
|
+
export { createDataObjectKind } from "./createDataObjectKind.js";
|
|
6
|
+
export { DataObject } from "./dataObject.js";
|
|
6
7
|
export { PureDataObject } from "./pureDataObject.js";
|
|
8
|
+
export { TreeDataObject } from "./treeDataObject.js";
|
|
7
9
|
export type { DataObjectKind, DataObjectTypes, IDataObjectProps } from "./types.js";
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data-objects/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data-objects/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.TreeDataObject = exports.PureDataObject = exports.DataObject = exports.createDataObjectKind = void 0;
|
|
8
|
+
var createDataObjectKind_js_1 = require("./createDataObjectKind.js");
|
|
9
|
+
Object.defineProperty(exports, "createDataObjectKind", { enumerable: true, get: function () { return createDataObjectKind_js_1.createDataObjectKind; } });
|
|
8
10
|
var dataObject_js_1 = require("./dataObject.js");
|
|
9
11
|
Object.defineProperty(exports, "DataObject", { enumerable: true, get: function () { return dataObject_js_1.DataObject; } });
|
|
10
|
-
Object.defineProperty(exports, "createDataObjectKind", { enumerable: true, get: function () { return dataObject_js_1.createDataObjectKind; } });
|
|
11
12
|
var pureDataObject_js_1 = require("./pureDataObject.js");
|
|
12
13
|
Object.defineProperty(exports, "PureDataObject", { enumerable: true, get: function () { return pureDataObject_js_1.PureDataObject; } });
|
|
14
|
+
var treeDataObject_js_1 = require("./treeDataObject.js");
|
|
15
|
+
Object.defineProperty(exports, "TreeDataObject", { enumerable: true, get: function () { return treeDataObject_js_1.TreeDataObject; } });
|
|
13
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-objects/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-objects/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,iDAA6C;AAApC,2GAAA,UAAU,OAAA;AACnB,yDAAqD;AAA5C,mHAAA,cAAc,OAAA;AACvB,yDAAqD;AAA5C,mHAAA,cAAc,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { createDataObjectKind } from \"./createDataObjectKind.js\";\nexport { DataObject } from \"./dataObject.js\";\nexport { PureDataObject } from \"./pureDataObject.js\";\nexport { TreeDataObject } from \"./treeDataObject.js\";\nexport type { DataObjectKind, DataObjectTypes, IDataObjectProps } from \"./types.js\";\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { type ITree } from "@fluidframework/tree/internal";
|
|
6
|
+
import { PureDataObject } from "./pureDataObject.js";
|
|
7
|
+
/**
|
|
8
|
+
* {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
*
|
|
12
|
+
* 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}.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam TTreeView - View derived from the underlying tree.
|
|
15
|
+
* Can be used to derive schema-aware views of the tree.
|
|
16
|
+
* See {@link TreeDataObject.generateView}.
|
|
17
|
+
*
|
|
18
|
+
* @example Implementing `initializingFirstTime`
|
|
19
|
+
*
|
|
20
|
+
* ```typescript
|
|
21
|
+
* protected override async initializingFirstTime(): Promise<void> {
|
|
22
|
+
* this.tree.initialize(...);
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @privateRemarks
|
|
27
|
+
* TODO: Before promoting this beyond internal, we should consider alternative API patterns that don't depend on
|
|
28
|
+
* sub-classing and don't leak Fluid concepts that should ideally be internal.
|
|
29
|
+
* See `tree-react-api` for an example of a pattern that avoids unnecessary leakage of implementation details.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export declare abstract class TreeDataObject<TTreeView> extends PureDataObject {
|
|
34
|
+
#private;
|
|
35
|
+
/**
|
|
36
|
+
* Generates a view of the data object's {@link @fluidframework/tree#ITree | tree}.
|
|
37
|
+
* @remarks Called once during initialization.
|
|
38
|
+
*/
|
|
39
|
+
protected abstract generateView(tree: ITree): TTreeView;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the derived view of the underlying tree.
|
|
42
|
+
*
|
|
43
|
+
* @throws
|
|
44
|
+
* If the tree has not yet been initialized, this will throw an error.
|
|
45
|
+
*/
|
|
46
|
+
get treeView(): TTreeView;
|
|
47
|
+
initializeInternal(existing: boolean): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=treeDataObject.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
7
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
8
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
9
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
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
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var _TreeDataObject_view;
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.TreeDataObject = void 0;
|
|
20
|
+
const internal_1 = require("@fluidframework/telemetry-utils/internal");
|
|
21
|
+
const internal_2 = require("@fluidframework/tree/internal");
|
|
22
|
+
const pureDataObject_js_1 = require("./pureDataObject.js");
|
|
23
|
+
/**
|
|
24
|
+
* Channel ID of {@link TreeDataObject}'s root {@link @fluidframework/tree#SharedTree}.
|
|
25
|
+
*/
|
|
26
|
+
const treeChannelId = "tree-data-object";
|
|
27
|
+
const uninitializedErrorString = "The tree has not yet been initialized. The data object must be initialized before accessing.";
|
|
28
|
+
/**
|
|
29
|
+
* {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
*
|
|
33
|
+
* 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}.
|
|
34
|
+
*
|
|
35
|
+
* @typeParam TTreeView - View derived from the underlying tree.
|
|
36
|
+
* Can be used to derive schema-aware views of the tree.
|
|
37
|
+
* See {@link TreeDataObject.generateView}.
|
|
38
|
+
*
|
|
39
|
+
* @example Implementing `initializingFirstTime`
|
|
40
|
+
*
|
|
41
|
+
* ```typescript
|
|
42
|
+
* protected override async initializingFirstTime(): Promise<void> {
|
|
43
|
+
* this.tree.initialize(...);
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @privateRemarks
|
|
48
|
+
* TODO: Before promoting this beyond internal, we should consider alternative API patterns that don't depend on
|
|
49
|
+
* sub-classing and don't leak Fluid concepts that should ideally be internal.
|
|
50
|
+
* See `tree-react-api` for an example of a pattern that avoids unnecessary leakage of implementation details.
|
|
51
|
+
*
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
class TreeDataObject extends pureDataObject_js_1.PureDataObject {
|
|
55
|
+
constructor() {
|
|
56
|
+
super(...arguments);
|
|
57
|
+
/**
|
|
58
|
+
* View derived from the underlying tree.
|
|
59
|
+
* @remarks Populated via {@link TreeDataObject.generateView}.
|
|
60
|
+
*/
|
|
61
|
+
_TreeDataObject_view.set(this, void 0);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets the derived view of the underlying tree.
|
|
65
|
+
*
|
|
66
|
+
* @throws
|
|
67
|
+
* If the tree has not yet been initialized, this will throw an error.
|
|
68
|
+
*/
|
|
69
|
+
get treeView() {
|
|
70
|
+
if (__classPrivateFieldGet(this, _TreeDataObject_view, "f") === undefined) {
|
|
71
|
+
throw new internal_1.UsageError(uninitializedErrorString);
|
|
72
|
+
}
|
|
73
|
+
return __classPrivateFieldGet(this, _TreeDataObject_view, "f");
|
|
74
|
+
}
|
|
75
|
+
async initializeInternal(existing) {
|
|
76
|
+
if (existing) {
|
|
77
|
+
// data store has a root tree so we just need to set it before calling initializingFromExisting
|
|
78
|
+
const channel = await this.runtime.getChannel(treeChannelId);
|
|
79
|
+
// TODO: Support using a Directory to Tree migration shim and DataObject's root channel ID
|
|
80
|
+
// to allow migrating from DataObject to TreeDataObject instead of just erroring in that case.
|
|
81
|
+
if (!internal_2.SharedTree.is(channel)) {
|
|
82
|
+
throw new Error(`Content with id ${channel.id} is not a SharedTree and cannot be loaded with treeDataObject.`);
|
|
83
|
+
}
|
|
84
|
+
const sharedTree = channel;
|
|
85
|
+
__classPrivateFieldSet(this, _TreeDataObject_view, this.generateView(sharedTree), "f");
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const sharedTree = internal_2.SharedTree.create(this.runtime, treeChannelId);
|
|
89
|
+
sharedTree.bindToContext();
|
|
90
|
+
__classPrivateFieldSet(this, _TreeDataObject_view, this.generateView(sharedTree), "f");
|
|
91
|
+
// Note, the implementer is responsible for initializing the tree with initial data.
|
|
92
|
+
// Generally, this can be done via `initializingFirstTime`.
|
|
93
|
+
}
|
|
94
|
+
await super.initializeInternal(existing);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.TreeDataObject = TreeDataObject;
|
|
98
|
+
_TreeDataObject_view = new WeakMap();
|
|
99
|
+
//# sourceMappingURL=treeDataObject.js.map
|
|
@@ -0,0 +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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @packageDocumentation
|
|
18
18
|
*/
|
|
19
|
-
export { DataObjectFactory, PureDataObjectFactory } from "./data-object-factories/index.js";
|
|
20
|
-
export { DataObject, type DataObjectKind, type DataObjectTypes, type IDataObjectProps, PureDataObject, createDataObjectKind, } from "./data-objects/index.js";
|
|
19
|
+
export { DataObjectFactory, PureDataObjectFactory, } from "./data-object-factories/index.js";
|
|
20
|
+
export { DataObject, type DataObjectKind, type DataObjectTypes, type IDataObjectProps, PureDataObject, TreeDataObject, createDataObjectKind, } from "./data-objects/index.js";
|
|
21
21
|
export { BaseContainerRuntimeFactory, type BaseContainerRuntimeFactoryProps, ContainerRuntimeFactoryWithDefaultDataStore, type ContainerRuntimeFactoryWithDefaultDataStoreProps, } from "./container-runtime-factories/index.js";
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACN,iBAAiB,EACjB,qBAAqB,GACrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,cAAc,EACd,cAAc,EACd,oBAAoB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,2BAA2B,EAC3B,KAAK,gCAAgC,EACrC,2CAA2C,EAC3C,KAAK,gDAAgD,GACrD,MAAM,wCAAwC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ContainerRuntimeFactoryWithDefaultDataStore = exports.BaseContainerRuntimeFactory = exports.createDataObjectKind = exports.PureDataObject = exports.DataObject = exports.PureDataObjectFactory = exports.DataObjectFactory = void 0;
|
|
7
|
+
exports.ContainerRuntimeFactoryWithDefaultDataStore = exports.BaseContainerRuntimeFactory = exports.createDataObjectKind = exports.TreeDataObject = exports.PureDataObject = exports.DataObject = exports.PureDataObjectFactory = exports.DataObjectFactory = void 0;
|
|
8
8
|
/**
|
|
9
9
|
* The `aqueduct` package is a library for building Fluid objects and Fluid
|
|
10
10
|
* containers within the Fluid Framework. Its goal is to provide a thin base
|
|
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "PureDataObjectFactory", { enumerable: true, get:
|
|
|
25
25
|
var index_js_2 = require("./data-objects/index.js");
|
|
26
26
|
Object.defineProperty(exports, "DataObject", { enumerable: true, get: function () { return index_js_2.DataObject; } });
|
|
27
27
|
Object.defineProperty(exports, "PureDataObject", { enumerable: true, get: function () { return index_js_2.PureDataObject; } });
|
|
28
|
+
Object.defineProperty(exports, "TreeDataObject", { enumerable: true, get: function () { return index_js_2.TreeDataObject; } });
|
|
28
29
|
Object.defineProperty(exports, "createDataObjectKind", { enumerable: true, get: function () { return index_js_2.createDataObjectKind; } });
|
|
29
30
|
var index_js_3 = require("./container-runtime-factories/index.js");
|
|
30
31
|
Object.defineProperty(exports, "BaseContainerRuntimeFactory", { enumerable: true, get: function () { return index_js_3.BaseContainerRuntimeFactory; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;;;;;;;;;GAaG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;;;;;;;;;GAaG;AAEH,6DAG0C;AAFzC,6GAAA,iBAAiB,OAAA;AACjB,iHAAA,qBAAqB,OAAA;AAEtB,oDAQiC;AAPhC,sGAAA,UAAU,OAAA;AAIV,0GAAA,cAAc,OAAA;AACd,0GAAA,cAAc,OAAA;AACd,gHAAA,oBAAoB,OAAA;AAErB,mEAKgD;AAJ/C,uHAAA,2BAA2B,OAAA;AAE3B,uIAAA,2CAA2C,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * The `aqueduct` package is a library for building Fluid objects and Fluid\n * containers within the Fluid Framework. Its goal is to provide a thin base\n * layer over the existing Fluid Framework interfaces that allows developers to\n * get started quickly.\n *\n * @remarks\n * About the library name: An \"aqueduct\" is a way to transport water from a source\n * to another location. The library name was chosen because its purpose is to\n * facilitate using lower level constructs and therefore handle 'fluid' items\n * same as an aqueduct.\n *\n * @packageDocumentation\n */\n\nexport {\n\tDataObjectFactory,\n\tPureDataObjectFactory,\n} from \"./data-object-factories/index.js\";\nexport {\n\tDataObject,\n\ttype DataObjectKind,\n\ttype DataObjectTypes,\n\ttype IDataObjectProps,\n\tPureDataObject,\n\tTreeDataObject,\n\tcreateDataObjectKind,\n} from \"./data-objects/index.js\";\nexport {\n\tBaseContainerRuntimeFactory,\n\ttype BaseContainerRuntimeFactoryProps,\n\tContainerRuntimeFactoryWithDefaultDataStore,\n\ttype ContainerRuntimeFactoryWithDefaultDataStoreProps,\n} from \"./container-runtime-factories/index.js\";\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
6
|
+
import type { DataObjectKind } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Utility for creating SharedObjectKind instances for data objects.
|
|
9
|
+
* @typeParam T - The kind of data object.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function createDataObjectKind<T extends DataObjectKind>(factory: T): T & SharedObjectKind<T extends DataObjectKind<infer I> ? I : unknown>;
|
|
13
|
+
//# sourceMappingURL=createDataObjectKind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDataObjectKind.d.ts","sourceRoot":"","sources":["../../src/data-objects/createDataObjectKind.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,cAAc,EAC5D,OAAO,EAAE,CAAC,GACR,CAAC,GAAG,gBAAgB,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAEvE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Utility for creating SharedObjectKind instances for data objects.
|
|
7
|
+
* @typeParam T - The kind of data object.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export function createDataObjectKind(factory) {
|
|
11
|
+
return factory;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=createDataObjectKind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDataObjectKind.js","sourceRoot":"","sources":["../../src/data-objects/createDataObjectKind.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CACnC,OAAU;IAEV,OAAO,OAAgF,CAAC;AACzF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\n\nimport type { DataObjectKind } from \"./types.js\";\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 DataObjectKind>(\n\tfactory: T,\n): T & SharedObjectKind<T extends DataObjectKind<infer I> ? I : unknown> {\n\treturn factory as T & SharedObjectKind<T extends DataObjectKind<infer I> ? I : unknown>;\n}\n"]}
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { type ISharedDirectory } from "@fluidframework/map/internal";
|
|
6
|
-
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
7
6
|
import { PureDataObject } from "./pureDataObject.js";
|
|
8
|
-
import type {
|
|
7
|
+
import type { DataObjectTypes } from "./types.js";
|
|
9
8
|
/**
|
|
10
9
|
* DataObject is a base data store that is primed with a root directory. It
|
|
11
10
|
* ensures that it is created and ready before you can access it.
|
|
@@ -37,10 +36,4 @@ export declare abstract class DataObject<I extends DataObjectTypes = DataObjectT
|
|
|
37
36
|
*/
|
|
38
37
|
protected getUninitializedErrorString(item: string): string;
|
|
39
38
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Utility for creating SharedObjectKind instances for data objects.
|
|
42
|
-
* @typeParam T - The kind of data object.
|
|
43
|
-
* @internal
|
|
44
|
-
*/
|
|
45
|
-
export declare function createDataObjectKind<T extends DataObjectKind>(factory: T): T & SharedObjectKind<T extends DataObjectKind<infer I> ? I : unknown>;
|
|
46
39
|
//# sourceMappingURL=dataObject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAEtC,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"}
|
|
@@ -65,12 +65,4 @@ export class DataObject extends PureDataObject {
|
|
|
65
65
|
return `${item} must be initialized before being accessed.`;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Utility for creating SharedObjectKind instances for data objects.
|
|
70
|
-
* @typeParam T - The kind of data object.
|
|
71
|
-
* @internal
|
|
72
|
-
*/
|
|
73
|
-
export function createDataObjectKind(factory) {
|
|
74
|
-
return factory;
|
|
75
|
-
}
|
|
76
68
|
//# sourceMappingURL=dataObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,UAAU,EACV,eAAe,GACf,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,UAAU,EACV,eAAe,GACf,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;;;;;;;;;GAWG;AACH,MAAM,OAAgB,UAEpB,SAAQ,cAAiB;IAF3B;;QAIkB,oBAAe,GAAG,MAAM,CAAC;IAoD3C,CAAC;IAlDA;;;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;IACa,KAAK,CAAC,kBAAkB,CAAC,QAAiB;QACzD,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,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","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\";\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"]}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export {
|
|
5
|
+
export { createDataObjectKind } from "./createDataObjectKind.js";
|
|
6
|
+
export { DataObject } from "./dataObject.js";
|
|
6
7
|
export { PureDataObject } from "./pureDataObject.js";
|
|
8
|
+
export { TreeDataObject } from "./treeDataObject.js";
|
|
7
9
|
export type { DataObjectKind, DataObjectTypes, IDataObjectProps } from "./types.js";
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data-objects/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data-objects/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export {
|
|
5
|
+
export { createDataObjectKind } from "./createDataObjectKind.js";
|
|
6
|
+
export { DataObject } from "./dataObject.js";
|
|
6
7
|
export { PureDataObject } from "./pureDataObject.js";
|
|
8
|
+
export { TreeDataObject } from "./treeDataObject.js";
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-objects/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-objects/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { createDataObjectKind } from \"./createDataObjectKind.js\";\nexport { DataObject } from \"./dataObject.js\";\nexport { PureDataObject } from \"./pureDataObject.js\";\nexport { TreeDataObject } from \"./treeDataObject.js\";\nexport type { DataObjectKind, DataObjectTypes, IDataObjectProps } from \"./types.js\";\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { type ITree } from "@fluidframework/tree/internal";
|
|
6
|
+
import { PureDataObject } from "./pureDataObject.js";
|
|
7
|
+
/**
|
|
8
|
+
* {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
*
|
|
12
|
+
* 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}.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam TTreeView - View derived from the underlying tree.
|
|
15
|
+
* Can be used to derive schema-aware views of the tree.
|
|
16
|
+
* See {@link TreeDataObject.generateView}.
|
|
17
|
+
*
|
|
18
|
+
* @example Implementing `initializingFirstTime`
|
|
19
|
+
*
|
|
20
|
+
* ```typescript
|
|
21
|
+
* protected override async initializingFirstTime(): Promise<void> {
|
|
22
|
+
* this.tree.initialize(...);
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @privateRemarks
|
|
27
|
+
* TODO: Before promoting this beyond internal, we should consider alternative API patterns that don't depend on
|
|
28
|
+
* sub-classing and don't leak Fluid concepts that should ideally be internal.
|
|
29
|
+
* See `tree-react-api` for an example of a pattern that avoids unnecessary leakage of implementation details.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export declare abstract class TreeDataObject<TTreeView> extends PureDataObject {
|
|
34
|
+
#private;
|
|
35
|
+
/**
|
|
36
|
+
* Generates a view of the data object's {@link @fluidframework/tree#ITree | tree}.
|
|
37
|
+
* @remarks Called once during initialization.
|
|
38
|
+
*/
|
|
39
|
+
protected abstract generateView(tree: ITree): TTreeView;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the derived view of the underlying tree.
|
|
42
|
+
*
|
|
43
|
+
* @throws
|
|
44
|
+
* If the tree has not yet been initialized, this will throw an error.
|
|
45
|
+
*/
|
|
46
|
+
get treeView(): TTreeView;
|
|
47
|
+
initializeInternal(existing: boolean): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=treeDataObject.d.ts.map
|
|
@@ -0,0 +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"}
|