@fluidframework/tree 2.70.0-361248 → 2.70.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 +52 -0
- package/api-report/tree.alpha.api.md +36 -17
- package/api-report/tree.beta.api.md +70 -2
- package/api-report/tree.legacy.beta.api.md +70 -2
- package/dist/alpha.d.ts +15 -11
- package/dist/api.d.ts +6 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +9 -1
- package/dist/api.js.map +1 -1
- package/dist/beta.d.ts +13 -0
- package/dist/core/forest/forest.d.ts +3 -4
- package/dist/core/forest/forest.d.ts.map +1 -1
- package/dist/core/forest/forest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +6 -0
- package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkTree.js +11 -2
- package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +21 -20
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +17 -43
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.js +2 -1
- package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +2 -1
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +43 -48
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +1 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +2 -1
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.d.ts +1 -1
- package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +13 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +2 -1
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +4 -3
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +1 -1
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +28 -2
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +12 -0
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/incrementalAllowedTypes.d.ts +47 -0
- package/dist/simple-tree/api/incrementalAllowedTypes.d.ts.map +1 -0
- package/dist/simple-tree/api/incrementalAllowedTypes.js +90 -0
- package/dist/simple-tree/api/incrementalAllowedTypes.js.map +1 -0
- package/dist/simple-tree/api/index.d.ts +2 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +4 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts +2 -2
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +51 -37
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/core/allowedTypes.d.ts +10 -11
- package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/dist/simple-tree/core/allowedTypes.js +1 -1
- package/dist/simple-tree/core/allowedTypes.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +1 -1
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +2 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/withType.d.ts +20 -0
- package/dist/simple-tree/core/withType.d.ts.map +1 -1
- package/dist/simple-tree/core/withType.js +21 -1
- package/dist/simple-tree/core/withType.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -2
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +5 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +1 -0
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +12 -0
- package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/lib/alpha.d.ts +15 -11
- package/lib/api.d.ts +6 -1
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +7 -0
- package/lib/api.js.map +1 -1
- package/lib/beta.d.ts +13 -0
- package/lib/core/forest/forest.d.ts +3 -4
- package/lib/core/forest/forest.d.ts.map +1 -1
- package/lib/core/forest/forest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +6 -0
- package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkTree.js +8 -0
- package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js +2 -2
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +21 -20
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +17 -43
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +2 -1
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +43 -48
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +1 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.d.ts +1 -1
- package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +2 -2
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- 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/legacy.d.ts +13 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +2 -1
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +4 -3
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +2 -2
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +28 -2
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +13 -1
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/incrementalAllowedTypes.d.ts +47 -0
- package/lib/simple-tree/api/incrementalAllowedTypes.d.ts.map +1 -0
- package/lib/simple-tree/api/incrementalAllowedTypes.js +86 -0
- package/lib/simple-tree/api/incrementalAllowedTypes.js.map +1 -0
- package/lib/simple-tree/api/index.d.ts +2 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -0
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts +2 -2
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +51 -37
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.d.ts +10 -11
- package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/lib/simple-tree/core/allowedTypes.js +1 -1
- package/lib/simple-tree/core/allowedTypes.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +1 -1
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +1 -1
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/withType.d.ts +20 -0
- package/lib/simple-tree/core/withType.d.ts.map +1 -1
- package/lib/simple-tree/core/withType.js +20 -0
- package/lib/simple-tree/core/withType.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -2
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +2 -2
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +1 -0
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +13 -1
- package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
- package/package.json +21 -21
- package/src/api.ts +11 -0
- package/src/core/forest/forest.ts +3 -4
- package/src/feature-libraries/chunked-forest/chunkTree.ts +9 -0
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +3 -3
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +20 -58
- package/src/feature-libraries/chunked-forest/index.ts +1 -0
- package/src/feature-libraries/flex-tree/lazyField.ts +3 -1
- package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +65 -71
- package/src/feature-libraries/index.ts +1 -0
- package/src/feature-libraries/object-forest/objectForest.ts +3 -3
- package/src/index.ts +4 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +4 -1
- package/src/shared-tree/schematizingTreeView.ts +10 -5
- package/src/shared-tree/treeAlpha.ts +50 -2
- package/src/shared-tree-core/sharedTreeCore.ts +1 -1
- package/src/simple-tree/api/incrementalAllowedTypes.ts +107 -0
- package/src/simple-tree/api/index.ts +6 -0
- package/src/simple-tree/api/schemaFactoryBeta.ts +6 -2
- package/src/simple-tree/api/tree.ts +64 -44
- package/src/simple-tree/core/allowedTypes.ts +10 -11
- package/src/simple-tree/core/index.ts +6 -1
- package/src/simple-tree/core/withType.ts +24 -0
- package/src/simple-tree/index.ts +5 -0
- package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +13 -0
|
@@ -6,7 +6,7 @@ import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { hasSingle } from "../util/index.js";
|
|
8
8
|
import { normalizeFieldSchema, FieldKind } from "./fieldSchema.js";
|
|
9
|
-
import { CompatibilityLevel, getKernel, getTreeNodeSchemaPrivateData, isTreeNode, UnhydratedFlexTreeNode, } from "./core/index.js";
|
|
9
|
+
import { CompatibilityLevel, getKernel, getTreeNodeSchemaPrivateData, isTreeNode, contentSchemaSymbol, UnhydratedFlexTreeNode, } from "./core/index.js";
|
|
10
10
|
import { getUnhydratedContext } from "./createContext.js";
|
|
11
11
|
/**
|
|
12
12
|
* Transforms an input {@link TypedNode} tree to an {@link UnhydratedFlexTreeNode}.
|
|
@@ -86,12 +86,24 @@ For class-based schema, this can be done by replacing an expression like "{foo:
|
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Returns all types for which the data is schema-compatible.
|
|
89
|
+
* @remarks This will respect the {@link contentSchemaSymbol} property on data to disambiguate types - if present, only that type will be returned.
|
|
89
90
|
*/
|
|
90
91
|
export function getPossibleTypes(allowedTypes, data) {
|
|
91
92
|
assert(data !== undefined, 0x889 /* undefined cannot be used as FactoryContent. */);
|
|
93
|
+
const type = typeof data === "object" && data !== null
|
|
94
|
+
? data[contentSchemaSymbol]
|
|
95
|
+
: undefined;
|
|
92
96
|
let best = CompatibilityLevel.None;
|
|
93
97
|
const possibleTypes = [];
|
|
94
98
|
for (const schema of allowedTypes) {
|
|
99
|
+
if (type !== undefined) {
|
|
100
|
+
if (schema.identifier === type) {
|
|
101
|
+
return [schema];
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
95
107
|
const handler = getTreeNodeSchemaPrivateData(schema).idempotentInitialize();
|
|
96
108
|
const level = handler.shallowCompatibilityTest(data);
|
|
97
109
|
if (level > best) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unhydratedFlexTreeFromInsertable.js","sourceRoot":"","sources":["../../src/simple-tree/unhydratedFlexTreeFromInsertable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAA4B,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,4BAA4B,EAC5B,UAAU,EAIV,sBAAsB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,gCAAgC,CAC/C,IAAS,EACT,YAAiC;IAEjC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAEjE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,+CAA+C;QAC/C,IAAI,qBAAqB,CAAC,IAAI,KAAK,SAAS,CAAC,QAAQ,EAAE,CAAC;YAC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I,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;AAC9D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { hasSingle } from \"../util/index.js\";\n\nimport { normalizeFieldSchema, FieldKind, type ImplicitFieldSchema } from \"./fieldSchema.js\";\nimport {\n\tCompatibilityLevel,\n\tgetKernel,\n\tgetTreeNodeSchemaPrivateData,\n\tisTreeNode,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\ttype Unhydrated,\n\tUnhydratedFlexTreeNode,\n} from \"./core/index.js\";\nimport { getUnhydratedContext } from \"./createContext.js\";\n\n/**\n * Transforms an input {@link TypedNode} tree to an {@link UnhydratedFlexTreeNode}.\n * @param data - The input tree to be converted.\n * If the data is an unsupported value (e.g. NaN), a fallback value will be used when supported,\n * otherwise an error will be thrown.\n *\n * Fallbacks:\n *\n * * `NaN` =\\> `null`\n *\n * * `+/-∞` =\\> `null`\n *\n * * `-0` =\\> `+0`\n *\n * For fields with a default value, the field may be omitted.\n * If `context` is not provided, defaults which require a context will be left empty which can be out of schema.\n *\n * @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.\n * @remarks\n * The resulting tree will be populated with any defaults from {@link FieldProvider}s in the schema.\n *\n * Often throws UsageErrors for invalid data, but may miss some cases.\n *\n * Output should comply with the provided view schema, but this is not explicitly validated:\n * validation against stored schema (to guard against document corruption) is done elsewhere.\n */\nexport function unhydratedFlexTreeFromInsertable<TIn extends InsertableContent | undefined>(\n\tdata: TIn,\n\tallowedTypes: ImplicitFieldSchema,\n): TIn extends undefined ? undefined : UnhydratedFlexTreeNode {\n\tconst normalizedFieldSchema = normalizeFieldSchema(allowedTypes);\n\n\tif (data === undefined) {\n\t\t// TODO: this code-path should support defaults\n\t\tif (normalizedFieldSchema.kind !== FieldKind.Optional) {\n\t\t\tthrow new UsageError(\"Got undefined for non-optional field.\");\n\t\t}\n\t\treturn undefined as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n\t}\n\n\tconst flexTree: UnhydratedFlexTreeNode = unhydratedFlexTreeFromInsertableNode(\n\t\tdata,\n\t\tnormalizedFieldSchema.allowedTypeSet,\n\t);\n\n\treturn flexTree as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n}\n\n/**\n * Copy content from `data` into a UnhydratedFlexTreeNode.\n */\nexport function unhydratedFlexTreeFromInsertableNode(\n\tdata: InsertableContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): UnhydratedFlexTreeNode {\n\tif (isTreeNode(data)) {\n\t\tconst kernel = getKernel(data);\n\t\tconst inner = kernel.getInnerNodeIfUnhydrated();\n\t\tif (inner === undefined) {\n\t\t\t// The node is already hydrated, meaning that it already got inserted into the tree previously\n\t\t\tthrow new UsageError(\"A node may not be inserted into the tree more than once\");\n\t\t} else {\n\t\t\tif (!allowedTypes.has(kernel.schema)) {\n\t\t\t\tthrow new UsageError(\"Invalid schema for this context.\");\n\t\t\t}\n\t\t\treturn inner;\n\t\t}\n\t}\n\n\tconst schema = getType(data, allowedTypes);\n\tconst handler = getTreeNodeSchemaPrivateData(schema).idempotentInitialize();\n\tconst result = handler.toFlexContent(data, allowedTypes);\n\n\treturn new UnhydratedFlexTreeNode(...result, getUnhydratedContext(schema));\n}\n\nfunction getType(\n\tdata: FactoryContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): TreeNodeSchema {\n\tconst possibleTypes = getPossibleTypes(allowedTypes, data);\n\tif (possibleTypes.length === 0) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is incompatible with all of the types allowed by the schema. The set of allowed types is: ${JSON.stringify(\n\t\t\t\t[...allowedTypes].map((schema) => schema.identifier),\n\t\t\t)}.`,\n\t\t);\n\t}\n\tif (!hasSingle(possibleTypes)) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is compatible with more than one type allowed by the schema.\nThe set of possible types is ${JSON.stringify([\n\t\t\t\t...possibleTypes.map((schema) => schema.identifier),\n\t\t\t])}.\nExplicitly construct an unhydrated node of the desired type to disambiguate.\nFor class-based schema, this can be done by replacing an expression like \"{foo: 1}\" with \"new MySchema({foo: 1})\".`,\n\t\t);\n\t}\n\treturn possibleTypes[0];\n}\n\n/**\n * Returns all types for which the data is schema-compatible.\n */\nexport function getPossibleTypes(\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\tdata: FactoryContent,\n): TreeNodeSchema[] {\n\tassert(data !== undefined, 0x889 /* undefined cannot be used as FactoryContent. */);\n\n\tlet best = CompatibilityLevel.None;\n\tconst possibleTypes: TreeNodeSchema[] = [];\n\tfor (const schema of allowedTypes) {\n\t\tconst handler = getTreeNodeSchemaPrivateData(schema).idempotentInitialize();\n\t\tconst level = handler.shallowCompatibilityTest(data);\n\t\tif (level > best) {\n\t\t\tpossibleTypes.length = 0;\n\t\t\tbest = level;\n\t\t}\n\t\tif (best === level) {\n\t\t\tpossibleTypes.push(schema);\n\t\t}\n\t}\n\treturn best === CompatibilityLevel.None ? [] : possibleTypes;\n}\n\n/**\n * Content which can be used to build a node.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n * @system @alpha\n */\nexport type FactoryContent =\n\t| IFluidHandle\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| Iterable<readonly [string, InsertableContent]>\n\t| readonly InsertableContent[]\n\t| FactoryContentObject;\n\n/**\n * Record-like object which can be used to build some kinds of nodes.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n *\n * Supports object and map nodes.\n * @system @alpha\n */\nexport type FactoryContentObject = {\n\treadonly [P in string]?: InsertableContent;\n};\n\n/**\n * Content which can be inserted into a tree.\n * @system @alpha\n */\nexport type InsertableContent = Unhydrated<TreeNode> | FactoryContent;\n"]}
|
|
1
|
+
{"version":3,"file":"unhydratedFlexTreeFromInsertable.js","sourceRoot":"","sources":["../../src/simple-tree/unhydratedFlexTreeFromInsertable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAA4B,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,4BAA4B,EAC5B,UAAU,EAGV,mBAAmB,EAEnB,sBAAsB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,gCAAgC,CAC/C,IAAS,EACT,YAAiC;IAEjC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAEjE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,+CAA+C;QAC/C,IAAI,qBAAqB,CAAC,IAAI,KAAK,SAAS,CAAC,QAAQ,EAAE,CAAC;YACvD,MAAM,IAAI,UAAU,CAAC,uCAAuC,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,SAAuE,CAAC;IAChF,CAAC;IAED,MAAM,QAAQ,GAA2B,oCAAoC,CAC5E,IAAI,EACJ,qBAAqB,CAAC,cAAc,CACpC,CAAC;IAEF,OAAO,QAAsE,CAAC;AAC/E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oCAAoC,CACnD,IAAuB,EACvB,YAAyC;IAEzC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAC/B,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;AAC9D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { hasSingle } from \"../util/index.js\";\n\nimport { normalizeFieldSchema, FieldKind, type ImplicitFieldSchema } from \"./fieldSchema.js\";\nimport {\n\tCompatibilityLevel,\n\tgetKernel,\n\tgetTreeNodeSchemaPrivateData,\n\tisTreeNode,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\tcontentSchemaSymbol,\n\ttype Unhydrated,\n\tUnhydratedFlexTreeNode,\n} from \"./core/index.js\";\nimport { getUnhydratedContext } from \"./createContext.js\";\n\n/**\n * Transforms an input {@link TypedNode} tree to an {@link UnhydratedFlexTreeNode}.\n * @param data - The input tree to be converted.\n * If the data is an unsupported value (e.g. NaN), a fallback value will be used when supported,\n * otherwise an error will be thrown.\n *\n * Fallbacks:\n *\n * * `NaN` =\\> `null`\n *\n * * `+/-∞` =\\> `null`\n *\n * * `-0` =\\> `+0`\n *\n * For fields with a default value, the field may be omitted.\n * If `context` is not provided, defaults which require a context will be left empty which can be out of schema.\n *\n * @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.\n * @remarks\n * The resulting tree will be populated with any defaults from {@link FieldProvider}s in the schema.\n *\n * Often throws UsageErrors for invalid data, but may miss some cases.\n *\n * Output should comply with the provided view schema, but this is not explicitly validated:\n * validation against stored schema (to guard against document corruption) is done elsewhere.\n */\nexport function unhydratedFlexTreeFromInsertable<TIn extends InsertableContent | undefined>(\n\tdata: TIn,\n\tallowedTypes: ImplicitFieldSchema,\n): TIn extends undefined ? undefined : UnhydratedFlexTreeNode {\n\tconst normalizedFieldSchema = normalizeFieldSchema(allowedTypes);\n\n\tif (data === undefined) {\n\t\t// TODO: this code-path should support defaults\n\t\tif (normalizedFieldSchema.kind !== FieldKind.Optional) {\n\t\t\tthrow new UsageError(\"Got undefined for non-optional field.\");\n\t\t}\n\t\treturn undefined as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n\t}\n\n\tconst flexTree: UnhydratedFlexTreeNode = unhydratedFlexTreeFromInsertableNode(\n\t\tdata,\n\t\tnormalizedFieldSchema.allowedTypeSet,\n\t);\n\n\treturn flexTree as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n}\n\n/**\n * Copy content from `data` into a UnhydratedFlexTreeNode.\n */\nexport function unhydratedFlexTreeFromInsertableNode(\n\tdata: InsertableContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): UnhydratedFlexTreeNode {\n\tif (isTreeNode(data)) {\n\t\tconst kernel = getKernel(data);\n\t\tconst inner = kernel.getInnerNodeIfUnhydrated();\n\t\tif (inner === undefined) {\n\t\t\t// The node is already hydrated, meaning that it already got inserted into the tree previously\n\t\t\tthrow new UsageError(\"A node may not be inserted into the tree more than once\");\n\t\t} else {\n\t\t\tif (!allowedTypes.has(kernel.schema)) {\n\t\t\t\tthrow new UsageError(\"Invalid schema for this context.\");\n\t\t\t}\n\t\t\treturn inner;\n\t\t}\n\t}\n\n\tconst schema = getType(data, allowedTypes);\n\tconst handler = getTreeNodeSchemaPrivateData(schema).idempotentInitialize();\n\tconst result = handler.toFlexContent(data, allowedTypes);\n\n\treturn new UnhydratedFlexTreeNode(...result, getUnhydratedContext(schema));\n}\n\nfunction getType(\n\tdata: FactoryContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): TreeNodeSchema {\n\tconst possibleTypes = getPossibleTypes(allowedTypes, data);\n\tif (possibleTypes.length === 0) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is incompatible with all of the types allowed by the schema. The set of allowed types is: ${JSON.stringify(\n\t\t\t\t[...allowedTypes].map((schema) => schema.identifier),\n\t\t\t)}.`,\n\t\t);\n\t}\n\tif (!hasSingle(possibleTypes)) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is compatible with more than one type allowed by the schema.\nThe set of possible types is ${JSON.stringify([\n\t\t\t\t...possibleTypes.map((schema) => schema.identifier),\n\t\t\t])}.\nExplicitly construct an unhydrated node of the desired type to disambiguate.\nFor class-based schema, this can be done by replacing an expression like \"{foo: 1}\" with \"new MySchema({foo: 1})\".`,\n\t\t);\n\t}\n\treturn possibleTypes[0];\n}\n\n/**\n * Returns all types for which the data is schema-compatible.\n * @remarks This will respect the {@link contentSchemaSymbol} property on data to disambiguate types - if present, only that type will be returned.\n */\nexport function getPossibleTypes(\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\tdata: FactoryContent,\n): TreeNodeSchema[] {\n\tassert(data !== undefined, 0x889 /* undefined cannot be used as FactoryContent. */);\n\tconst type =\n\t\ttypeof data === \"object\" && data !== null\n\t\t\t? (data as Partial<{ [contentSchemaSymbol]: string }>)[contentSchemaSymbol]\n\t\t\t: undefined;\n\n\tlet best = CompatibilityLevel.None;\n\tconst possibleTypes: TreeNodeSchema[] = [];\n\tfor (const schema of allowedTypes) {\n\t\tif (type !== undefined) {\n\t\t\tif (schema.identifier === type) {\n\t\t\t\treturn [schema];\n\t\t\t} else {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tconst handler = getTreeNodeSchemaPrivateData(schema).idempotentInitialize();\n\t\tconst level = handler.shallowCompatibilityTest(data);\n\t\tif (level > best) {\n\t\t\tpossibleTypes.length = 0;\n\t\t\tbest = level;\n\t\t}\n\t\tif (best === level) {\n\t\t\tpossibleTypes.push(schema);\n\t\t}\n\t}\n\treturn best === CompatibilityLevel.None ? [] : possibleTypes;\n}\n\n/**\n * Content which can be used to build a node.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n * @system @alpha\n */\nexport type FactoryContent =\n\t| IFluidHandle\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| Iterable<readonly [string, InsertableContent]>\n\t| readonly InsertableContent[]\n\t| FactoryContentObject;\n\n/**\n * Record-like object which can be used to build some kinds of nodes.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n *\n * Supports object and map nodes.\n * @system @alpha\n */\nexport type FactoryContentObject = {\n\treadonly [P in string]?: InsertableContent;\n};\n\n/**\n * Content which can be inserted into a tree.\n * @system @alpha\n */\nexport type InsertableContent = Unhydrated<TreeNode> | FactoryContent;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/tree",
|
|
3
|
-
"version": "2.70.0
|
|
3
|
+
"version": "2.70.0",
|
|
4
4
|
"description": "Distributed tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -101,17 +101,17 @@
|
|
|
101
101
|
"temp-directory": "nyc/.nyc_output"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@fluid-internal/client-utils": "2.70.0
|
|
105
|
-
"@fluidframework/container-runtime": "2.70.0
|
|
106
|
-
"@fluidframework/core-interfaces": "2.70.0
|
|
107
|
-
"@fluidframework/core-utils": "2.70.0
|
|
108
|
-
"@fluidframework/datastore-definitions": "2.70.0
|
|
109
|
-
"@fluidframework/driver-definitions": "2.70.0
|
|
110
|
-
"@fluidframework/id-compressor": "2.70.0
|
|
111
|
-
"@fluidframework/runtime-definitions": "2.70.0
|
|
112
|
-
"@fluidframework/runtime-utils": "2.70.0
|
|
113
|
-
"@fluidframework/shared-object-base": "2.70.0
|
|
114
|
-
"@fluidframework/telemetry-utils": "2.70.0
|
|
104
|
+
"@fluid-internal/client-utils": "~2.70.0",
|
|
105
|
+
"@fluidframework/container-runtime": "~2.70.0",
|
|
106
|
+
"@fluidframework/core-interfaces": "~2.70.0",
|
|
107
|
+
"@fluidframework/core-utils": "~2.70.0",
|
|
108
|
+
"@fluidframework/datastore-definitions": "~2.70.0",
|
|
109
|
+
"@fluidframework/driver-definitions": "~2.70.0",
|
|
110
|
+
"@fluidframework/id-compressor": "~2.70.0",
|
|
111
|
+
"@fluidframework/runtime-definitions": "~2.70.0",
|
|
112
|
+
"@fluidframework/runtime-utils": "~2.70.0",
|
|
113
|
+
"@fluidframework/shared-object-base": "~2.70.0",
|
|
114
|
+
"@fluidframework/telemetry-utils": "~2.70.0",
|
|
115
115
|
"@sinclair/typebox": "^0.34.13",
|
|
116
116
|
"@tylerbu/sorted-btree-es6": "^1.8.0",
|
|
117
117
|
"@types/ungap__structured-clone": "^1.2.0",
|
|
@@ -122,19 +122,19 @@
|
|
|
122
122
|
"devDependencies": {
|
|
123
123
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
124
124
|
"@biomejs/biome": "~1.9.3",
|
|
125
|
-
"@fluid-internal/mocha-test-setup": "2.70.0
|
|
126
|
-
"@fluid-private/stochastic-test-utils": "2.70.0
|
|
127
|
-
"@fluid-private/test-dds-utils": "2.70.0
|
|
128
|
-
"@fluid-private/test-drivers": "2.70.0
|
|
125
|
+
"@fluid-internal/mocha-test-setup": "~2.70.0",
|
|
126
|
+
"@fluid-private/stochastic-test-utils": "~2.70.0",
|
|
127
|
+
"@fluid-private/test-dds-utils": "~2.70.0",
|
|
128
|
+
"@fluid-private/test-drivers": "~2.70.0",
|
|
129
129
|
"@fluid-tools/benchmark": "^0.51.0",
|
|
130
130
|
"@fluid-tools/build-cli": "^0.58.3",
|
|
131
131
|
"@fluidframework/build-common": "^2.0.3",
|
|
132
132
|
"@fluidframework/build-tools": "^0.58.3",
|
|
133
|
-
"@fluidframework/container-definitions": "2.70.0
|
|
134
|
-
"@fluidframework/container-loader": "2.70.0
|
|
133
|
+
"@fluidframework/container-definitions": "~2.70.0",
|
|
134
|
+
"@fluidframework/container-loader": "~2.70.0",
|
|
135
135
|
"@fluidframework/eslint-config-fluid": "^6.1.0",
|
|
136
|
-
"@fluidframework/test-runtime-utils": "2.70.0
|
|
137
|
-
"@fluidframework/test-utils": "2.70.0
|
|
136
|
+
"@fluidframework/test-runtime-utils": "~2.70.0",
|
|
137
|
+
"@fluidframework/test-utils": "~2.70.0",
|
|
138
138
|
"@fluidframework/tree-previous": "npm:@fluidframework/tree@2.63.0",
|
|
139
139
|
"@microsoft/api-extractor": "7.52.11",
|
|
140
140
|
"@types/diff": "^3.5.1",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"concurrently": "^8.2.1",
|
|
148
148
|
"copyfiles": "^2.4.1",
|
|
149
149
|
"cross-env": "^7.0.3",
|
|
150
|
-
"dependency-cruiser": "^
|
|
150
|
+
"dependency-cruiser": "^17.1.0",
|
|
151
151
|
"diff": "^3.5.0",
|
|
152
152
|
"easy-table": "^1.1.1",
|
|
153
153
|
"eslint": "~8.57.1",
|
package/src/api.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import {
|
|
7
7
|
type TreeView,
|
|
8
8
|
type TreeViewAlpha,
|
|
9
|
+
type TreeViewBeta,
|
|
9
10
|
type ImplicitFieldSchema,
|
|
10
11
|
// eslint-disable-next-line import/no-deprecated
|
|
11
12
|
asTreeViewAlpha,
|
|
@@ -28,3 +29,13 @@ export function asAlpha<TSchema extends ImplicitFieldSchema>(
|
|
|
28
29
|
// eslint-disable-next-line import/no-deprecated
|
|
29
30
|
return asTreeViewAlpha(view);
|
|
30
31
|
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Retrieve the {@link TreeViewBeta | beta API} for a {@link TreeView}.
|
|
35
|
+
* @beta
|
|
36
|
+
*/
|
|
37
|
+
export function asBeta<TSchema extends ImplicitFieldSchema>(
|
|
38
|
+
view: TreeView<TSchema>,
|
|
39
|
+
): TreeViewBeta<TSchema> {
|
|
40
|
+
return view as TreeViewBeta<TSchema>;
|
|
41
|
+
}
|
|
@@ -84,15 +84,14 @@ export interface IForestSubscription {
|
|
|
84
84
|
clone(schema: TreeStoredSchemaSubscription, anchors: AnchorSet): IEditableForest;
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
* Generate a TreeChunk for the
|
|
87
|
+
* Generate a TreeChunk[] for the current field (and its children) of cursor.
|
|
88
88
|
* This can be used to chunk data that is then inserted into the forest.
|
|
89
89
|
*
|
|
90
90
|
* @remarks
|
|
91
|
-
*
|
|
92
|
-
* While any TreeChunk is compatible with any forest, this method creates one optimized for this specific forest.
|
|
91
|
+
* Similar to {@link chunkField} but it creates chunks optimized for this specific forest by using its compression policy.
|
|
93
92
|
* The provided data must be compatible with the forest's current schema.
|
|
94
93
|
*/
|
|
95
|
-
chunkField(cursor: ITreeCursorSynchronous): TreeChunk;
|
|
94
|
+
chunkField(cursor: ITreeCursorSynchronous): TreeChunk[];
|
|
96
95
|
|
|
97
96
|
/**
|
|
98
97
|
* Allocates a cursor in the "cleared" state.
|
|
@@ -197,6 +197,15 @@ export function chunkFieldSingle(
|
|
|
197
197
|
policy: ChunkCompressor,
|
|
198
198
|
): TreeChunk {
|
|
199
199
|
const chunks = chunkField(cursor, policy);
|
|
200
|
+
return combineChunks(chunks);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Create a single TreeChunk from an array of TreeChunks.
|
|
205
|
+
* @remarks
|
|
206
|
+
* This takes ownership of the provided TreeChunk references, and returns an owned referenced.
|
|
207
|
+
*/
|
|
208
|
+
export function combineChunks(chunks: TreeChunk[]): TreeChunk {
|
|
200
209
|
if (chunks.length === 1) {
|
|
201
210
|
return chunks[0] ?? oob();
|
|
202
211
|
}
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
} from "../../util/index.js";
|
|
45
45
|
|
|
46
46
|
import { BasicChunk, BasicChunkCursor, type SiblingsOrKey } from "./basicChunk.js";
|
|
47
|
-
import { type IChunker, basicChunkTree,
|
|
47
|
+
import { type IChunker, basicChunkTree, chunkField, chunkTree } from "./chunkTree.js";
|
|
48
48
|
|
|
49
49
|
function makeRoot(): BasicChunk {
|
|
50
50
|
return new BasicChunk(aboveRootPlaceholder, new Map());
|
|
@@ -90,8 +90,8 @@ export class ChunkedForest implements IEditableForest {
|
|
|
90
90
|
return new ChunkedForest(this.roots, schema, this.chunker.clone(schema), anchors);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
public chunkField(cursor: ITreeCursorSynchronous): TreeChunk {
|
|
94
|
-
return
|
|
93
|
+
public chunkField(cursor: ITreeCursorSynchronous): TreeChunk[] {
|
|
94
|
+
return chunkField(cursor, { idCompressor: this.idCompressor, policy: this.chunker });
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
public forgetAnchor(anchor: Anchor): void {
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
SpecialField,
|
|
37
37
|
version,
|
|
38
38
|
} from "./format.js";
|
|
39
|
-
import type {
|
|
39
|
+
import type { IncrementalEncoder } from "./codecs.js";
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Encode data from `FieldBatch` into an `EncodedFieldBatch`.
|
|
@@ -223,8 +223,8 @@ export const anyNodeEncoder: NodeEncoder = {
|
|
|
223
223
|
outputBuffer: BufferFormat,
|
|
224
224
|
): void {
|
|
225
225
|
// TODO: Fast path uniform chunk content.
|
|
226
|
-
const
|
|
227
|
-
AnyShape.encodeNode(cursor, context, outputBuffer,
|
|
226
|
+
const nodeEncoder = context.nodeEncoderFromSchema(cursor.type);
|
|
227
|
+
AnyShape.encodeNode(cursor, context, outputBuffer, nodeEncoder);
|
|
228
228
|
},
|
|
229
229
|
|
|
230
230
|
shape: AnyShape.instance,
|
|
@@ -350,7 +350,7 @@ export class InlineArrayEncoder
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
/**
|
|
353
|
-
* Encodes the shape for a nested array as {@link
|
|
353
|
+
* Encodes the shape for a nested array as {@link EncodedNestedArrayShape} shape.
|
|
354
354
|
*/
|
|
355
355
|
export class NestedArrayShape extends ShapeGeneric<EncodedChunkShape> {
|
|
356
356
|
/**
|
|
@@ -420,30 +420,9 @@ export class NestedArrayEncoder implements FieldEncoder {
|
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
/**
|
|
423
|
-
* Encodes
|
|
424
|
-
* This chunks will be encoded separately, i.e., the contents of the chunk will not be part of the main buffer.
|
|
425
|
-
* A reference to the chunk will be stored in the main buffer as an {@link ChunkReferenceId}.
|
|
423
|
+
* Encodes the shape for an incremental chunk as {@link EncodedIncrementalChunkShape} shape.
|
|
426
424
|
*/
|
|
427
425
|
export class IncrementalChunkShape extends ShapeGeneric<EncodedChunkShape> {
|
|
428
|
-
/**
|
|
429
|
-
* Encodes all the nodes in the chunk at the cursor position using `InlineArrayShape`.
|
|
430
|
-
*/
|
|
431
|
-
public static encodeChunk(chunk: TreeChunk, context: EncoderContext): BufferFormat {
|
|
432
|
-
const chunkOutputBuffer: BufferFormat = [];
|
|
433
|
-
const nodesEncoder = asNodesEncoder(anyNodeEncoder);
|
|
434
|
-
const chunkCursor = chunk.cursor();
|
|
435
|
-
chunkCursor.firstNode();
|
|
436
|
-
const chunkLength = chunkCursor.chunkLength;
|
|
437
|
-
for (let index = 0; index < chunkLength; index++) {
|
|
438
|
-
nodesEncoder.encodeNodes(chunkCursor, context, chunkOutputBuffer);
|
|
439
|
-
}
|
|
440
|
-
assert(
|
|
441
|
-
chunkCursor.mode === CursorLocationType.Fields,
|
|
442
|
-
0xc29 /* should return to fields mode when finished encoding */,
|
|
443
|
-
);
|
|
444
|
-
return chunkOutputBuffer;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
426
|
public encodeShape(
|
|
448
427
|
identifiers: DeduplicationTable<string>,
|
|
449
428
|
shapes: DeduplicationTable<Shape>,
|
|
@@ -464,9 +443,10 @@ export class IncrementalChunkShape extends ShapeGeneric<EncodedChunkShape> {
|
|
|
464
443
|
}
|
|
465
444
|
|
|
466
445
|
/**
|
|
467
|
-
* Encodes an incremental field whose chunks are encoded separately and referenced by their {@link ChunkReferenceId}.
|
|
468
|
-
* The shape of the content of this field is {@link
|
|
469
|
-
* the {@link
|
|
446
|
+
* Encodes an incremental field whose tree chunks are encoded separately and referenced by their {@link ChunkReferenceId}.
|
|
447
|
+
* The shape of the content of this field is {@link NestedArrayShape}.
|
|
448
|
+
* The inner items of the array have shape {@link IncrementalChunkShape} and are {@link ChunkReferenceId}s
|
|
449
|
+
* of the encoded chunks.
|
|
470
450
|
*/
|
|
471
451
|
export const incrementalFieldEncoder: FieldEncoder = {
|
|
472
452
|
encodeField(
|
|
@@ -475,12 +455,13 @@ export const incrementalFieldEncoder: FieldEncoder = {
|
|
|
475
455
|
outputBuffer: BufferFormat,
|
|
476
456
|
): void {
|
|
477
457
|
assert(
|
|
478
|
-
context.
|
|
479
|
-
|
|
458
|
+
context.incrementalEncoder !== undefined,
|
|
459
|
+
0xc88 /* incremental encoder must be defined to use incrementalFieldEncoder */,
|
|
480
460
|
);
|
|
481
461
|
|
|
482
|
-
const chunkReferenceIds = context.encodeIncrementalField(
|
|
483
|
-
|
|
462
|
+
const chunkReferenceIds = context.incrementalEncoder.encodeIncrementalField(
|
|
463
|
+
cursor,
|
|
464
|
+
(chunk: TreeChunk) => compressedEncode([chunk.cursor()], context),
|
|
484
465
|
);
|
|
485
466
|
outputBuffer.push(chunkReferenceIds);
|
|
486
467
|
},
|
|
@@ -540,7 +521,12 @@ export class EncoderContext implements NodeEncodeBuilder, FieldEncodeBuilder {
|
|
|
540
521
|
private readonly fieldEncoderFromPolicy: FieldEncoderPolicy,
|
|
541
522
|
public readonly fieldShapes: ReadonlyMap<FieldKindIdentifier, FlexFieldKind>,
|
|
542
523
|
public readonly idCompressor: IIdCompressor,
|
|
543
|
-
|
|
524
|
+
/**
|
|
525
|
+
* To be used to encode incremental chunks, if any.
|
|
526
|
+
* @remarks
|
|
527
|
+
* See {@link IncrementalEncoder} for more information.
|
|
528
|
+
*/
|
|
529
|
+
public readonly incrementalEncoder: IncrementalEncoder | undefined,
|
|
544
530
|
) {}
|
|
545
531
|
|
|
546
532
|
public nodeEncoderFromSchema(schemaName: TreeNodeSchemaIdentifier): NodeEncoder {
|
|
@@ -556,30 +542,6 @@ export class EncoderContext implements NodeEncodeBuilder, FieldEncodeBuilder {
|
|
|
556
542
|
public nestedArrayEncoder(inner: NodeEncoder): NestedArrayEncoder {
|
|
557
543
|
return getOrCreate(this.nestedArrayEncoders, inner, () => new NestedArrayEncoder(inner));
|
|
558
544
|
}
|
|
559
|
-
|
|
560
|
-
public get shouldEncodeIncrementally(): boolean {
|
|
561
|
-
return this.incrementalEncoder !== undefined;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* {@link IncrementalEncoder.encodeIncrementalField}
|
|
566
|
-
*/
|
|
567
|
-
public encodeIncrementalField(
|
|
568
|
-
cursor: ITreeCursorSynchronous,
|
|
569
|
-
encoder: (chunk: TreeChunk) => BufferFormat,
|
|
570
|
-
): ChunkReferenceId[] {
|
|
571
|
-
assert(
|
|
572
|
-
this.incrementalEncoder !== undefined,
|
|
573
|
-
0xc2b /* incremental encoding must be enabled */,
|
|
574
|
-
);
|
|
575
|
-
// Encoder for the chunk that encodes its data using the provided encoder function and
|
|
576
|
-
// updates the encoded data for shapes and identifiers.
|
|
577
|
-
const chunkEncoder = (chunk: TreeChunk): EncodedFieldBatch => {
|
|
578
|
-
const chunkOutputBuffer = encoder(chunk);
|
|
579
|
-
return updateShapesAndIdentifiersEncoding(version, [chunkOutputBuffer]);
|
|
580
|
-
};
|
|
581
|
-
return this.incrementalEncoder.encodeIncrementalField(cursor, chunkEncoder);
|
|
582
|
-
}
|
|
583
545
|
}
|
|
584
546
|
|
|
585
547
|
export interface NodeEncodeBuilder {
|
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
import { LazyEntity } from "./lazyEntity.js";
|
|
54
54
|
import { type LazyTreeNode, getOrCreateHydratedFlexTreeNode } from "./lazyNode.js";
|
|
55
55
|
import { indexForAt, treeStatusFromAnchorCache } from "./utilities.js";
|
|
56
|
+
import { combineChunks } from "../chunked-forest/index.js";
|
|
56
57
|
|
|
57
58
|
/**
|
|
58
59
|
* Reuse fields.
|
|
@@ -247,7 +248,8 @@ export abstract class LazyField extends LazyEntity<FieldAnchor> implements FlexT
|
|
|
247
248
|
protected getEditor(): IDefaultEditBuilder<ITreeCursorSynchronous> {
|
|
248
249
|
return new MappedEditBuilder(
|
|
249
250
|
this.context.checkout.editor,
|
|
250
|
-
(cursor: ITreeCursorSynchronous) =>
|
|
251
|
+
(cursor: ITreeCursorSynchronous) =>
|
|
252
|
+
combineChunks(this.context.checkout.forest.chunkField(cursor)),
|
|
251
253
|
);
|
|
252
254
|
}
|
|
253
255
|
}
|
|
@@ -288,7 +288,7 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
|
|
|
288
288
|
|
|
289
289
|
public constructor(
|
|
290
290
|
private readonly enableIncrementalSummary: boolean,
|
|
291
|
-
private readonly getChunkAtCursor: (cursor: ITreeCursorSynchronous) => TreeChunk,
|
|
291
|
+
private readonly getChunkAtCursor: (cursor: ITreeCursorSynchronous) => TreeChunk[],
|
|
292
292
|
public readonly shouldEncodeIncrementally: IncrementalEncodingPolicy,
|
|
293
293
|
private readonly initialSequenceNumber: number,
|
|
294
294
|
) {}
|
|
@@ -392,80 +392,74 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
|
|
|
392
392
|
// Validate that a summary is currently being tracked and that the tracked summary properties are defined.
|
|
393
393
|
validateTrackingSummary(this.forestSummaryState, this.trackedSummaryProperties);
|
|
394
394
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
395
|
+
const chunkReferenceIds: ChunkReferenceId[] = [];
|
|
396
|
+
const chunks = this.getChunkAtCursor(cursor);
|
|
397
|
+
for (const chunk of chunks) {
|
|
398
|
+
let chunkProperties: ChunkSummaryProperties;
|
|
399
|
+
|
|
400
|
+
// Try and get the properties of the chunk from the latest successful summary.
|
|
401
|
+
// If it exists and the summary is not a full tree, use the properties to generate a summary handle.
|
|
402
|
+
// If it does not exist, encode the chunk and generate new properties for it.
|
|
403
|
+
const previousChunkProperties = tryGetFromNestedMap(
|
|
404
|
+
this.chunkTrackingPropertiesMap,
|
|
405
|
+
this.latestSummarySequenceNumber,
|
|
406
|
+
chunk,
|
|
407
|
+
);
|
|
408
|
+
if (previousChunkProperties !== undefined && !this.trackedSummaryProperties.fullTree) {
|
|
409
|
+
chunkProperties = previousChunkProperties;
|
|
410
|
+
this.trackedSummaryProperties.parentSummaryBuilder.addHandle(
|
|
411
|
+
`${chunkProperties.referenceId}`,
|
|
412
|
+
SummaryType.Tree,
|
|
413
|
+
`${this.trackedSummaryProperties.latestSummaryBasePath}/${chunkProperties.summaryPath}`,
|
|
414
|
+
);
|
|
415
|
+
} else {
|
|
416
|
+
// Generate a new reference ID for the chunk.
|
|
417
|
+
const newReferenceId: ChunkReferenceId = brand(this.nextReferenceId++);
|
|
418
|
+
|
|
419
|
+
// Add the reference ID of this chunk to the chunk summary path and use the path as the summary path
|
|
420
|
+
// for the chunk in its summary properties.
|
|
421
|
+
// This is done before encoding the chunk so that the summary path is updated correctly when encoding
|
|
422
|
+
// any incremental chunks that are under this chunk.
|
|
423
|
+
this.trackedSummaryProperties.chunkSummaryPath.push(newReferenceId);
|
|
424
|
+
|
|
425
|
+
chunkProperties = {
|
|
426
|
+
referenceId: newReferenceId,
|
|
427
|
+
summaryPath: this.trackedSummaryProperties.chunkSummaryPath.join("/"),
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
const parentSummaryBuilder = this.trackedSummaryProperties.parentSummaryBuilder;
|
|
431
|
+
// Create a new summary builder for this chunk to build its summary tree which will be stored in the
|
|
432
|
+
// parent's summary tree under its reference ID.
|
|
433
|
+
// Before encoding the chunk, set the parent summary builder to this chunk's summary builder so that
|
|
434
|
+
// any incremental chunks in the subtree of this chunk will use that as their parent summary builder.
|
|
435
|
+
const chunkSummaryBuilder = new SummaryTreeBuilder();
|
|
436
|
+
this.trackedSummaryProperties.parentSummaryBuilder = chunkSummaryBuilder;
|
|
437
|
+
chunkSummaryBuilder.addBlob(
|
|
438
|
+
chunkContentsBlobKey,
|
|
439
|
+
this.trackedSummaryProperties.stringify(chunkEncoder(chunk)),
|
|
440
|
+
);
|
|
401
441
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
442
|
+
// Add this chunk's summary tree to the parent's summary tree. The summary tree contains its encoded
|
|
443
|
+
// contents and the summary trees of any incremental chunks under it.
|
|
444
|
+
parentSummaryBuilder.addWithStats(
|
|
445
|
+
`${newReferenceId}`,
|
|
446
|
+
chunkSummaryBuilder.getSummaryTree(),
|
|
447
|
+
);
|
|
407
448
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
this.chunkTrackingPropertiesMap,
|
|
413
|
-
this.latestSummarySequenceNumber,
|
|
414
|
-
chunk,
|
|
415
|
-
);
|
|
416
|
-
if (previousChunkProperties !== undefined && !this.trackedSummaryProperties.fullTree) {
|
|
417
|
-
chunkProperties = previousChunkProperties;
|
|
418
|
-
chunkReferenceId = previousChunkProperties.referenceId;
|
|
419
|
-
this.trackedSummaryProperties.parentSummaryBuilder.addHandle(
|
|
420
|
-
`${chunkReferenceId}`,
|
|
421
|
-
SummaryType.Tree,
|
|
422
|
-
`${this.trackedSummaryProperties.latestSummaryBasePath}/${previousChunkProperties.summaryPath}`,
|
|
423
|
-
);
|
|
424
|
-
} else {
|
|
425
|
-
// Generate a new reference ID for the chunk.
|
|
426
|
-
chunkReferenceId = brand(this.nextReferenceId++);
|
|
427
|
-
// Add the reference ID of this chunk to the chunk summary path and use the path as the summary path
|
|
428
|
-
// for the chunk in its summary properties.
|
|
429
|
-
// This is done before encoding the chunk so that the summary path is updated correctly when encoding
|
|
430
|
-
// any incremental chunks that are under this chunk.
|
|
431
|
-
this.trackedSummaryProperties.chunkSummaryPath.push(chunkReferenceId);
|
|
432
|
-
|
|
433
|
-
chunkProperties = {
|
|
434
|
-
referenceId: chunkReferenceId,
|
|
435
|
-
summaryPath: this.trackedSummaryProperties.chunkSummaryPath.join("/"),
|
|
436
|
-
};
|
|
437
|
-
|
|
438
|
-
const parentSummaryBuilder = this.trackedSummaryProperties.parentSummaryBuilder;
|
|
439
|
-
// Create a new summary builder for this chunk to build its summary tree which will be stored in the
|
|
440
|
-
// parent's summary tree under its reference ID.
|
|
441
|
-
// Before encoding the chunk, set the parent summary builder to this chunk's summary builder so that
|
|
442
|
-
// any incremental chunks in the subtree of this chunk will use that as their parent summary builder.
|
|
443
|
-
const chunkSummaryBuilder = new SummaryTreeBuilder();
|
|
444
|
-
this.trackedSummaryProperties.parentSummaryBuilder = chunkSummaryBuilder;
|
|
445
|
-
chunkSummaryBuilder.addBlob(
|
|
446
|
-
chunkContentsBlobKey,
|
|
447
|
-
this.trackedSummaryProperties.stringify(chunkEncoder(chunk)),
|
|
448
|
-
);
|
|
449
|
+
// Restore the parent summary builder and chunk summary path.
|
|
450
|
+
this.trackedSummaryProperties.parentSummaryBuilder = parentSummaryBuilder;
|
|
451
|
+
this.trackedSummaryProperties.chunkSummaryPath.pop();
|
|
452
|
+
}
|
|
449
453
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
454
|
+
setInNestedMap(
|
|
455
|
+
this.chunkTrackingPropertiesMap,
|
|
456
|
+
this.trackedSummaryProperties.summarySequenceNumber,
|
|
457
|
+
chunk,
|
|
458
|
+
chunkProperties,
|
|
455
459
|
);
|
|
456
|
-
|
|
457
|
-
// Restore the parent summary builder and chunk summary path.
|
|
458
|
-
this.trackedSummaryProperties.parentSummaryBuilder = parentSummaryBuilder;
|
|
459
|
-
this.trackedSummaryProperties.chunkSummaryPath.pop();
|
|
460
|
+
chunkReferenceIds.push(chunkProperties.referenceId);
|
|
460
461
|
}
|
|
461
|
-
|
|
462
|
-
setInNestedMap(
|
|
463
|
-
this.chunkTrackingPropertiesMap,
|
|
464
|
-
this.trackedSummaryProperties.summarySequenceNumber,
|
|
465
|
-
chunk,
|
|
466
|
-
chunkProperties,
|
|
467
|
-
);
|
|
468
|
-
return [chunkReferenceId];
|
|
462
|
+
return chunkReferenceIds;
|
|
469
463
|
}
|
|
470
464
|
|
|
471
465
|
/**
|
|
@@ -535,7 +529,7 @@ export class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecode
|
|
|
535
529
|
chunkDecoder: (encoded: EncodedFieldBatch) => TreeChunk,
|
|
536
530
|
): TreeChunk {
|
|
537
531
|
const ChunkLoadProperties = this.loadedChunksMap.get(`${referenceId}`);
|
|
538
|
-
assert(ChunkLoadProperties !== undefined,
|
|
532
|
+
assert(ChunkLoadProperties !== undefined, 0xc86 /* Encoded incremental chunk not found */);
|
|
539
533
|
const chunk = chunkDecoder(ChunkLoadProperties.encodedContents);
|
|
540
534
|
|
|
541
535
|
// Account for the reference about to be added in `chunkTrackingPropertiesMap`
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
type Breakable,
|
|
50
50
|
type WithBreakable,
|
|
51
51
|
} from "../../util/index.js";
|
|
52
|
-
import {
|
|
52
|
+
import { chunkField, defaultChunkPolicy } from "../chunked-forest/index.js";
|
|
53
53
|
import { cursorForMapTreeNode, mapTreeFromCursor } from "../mapTreeCursor.js";
|
|
54
54
|
import { type CursorWithNode, SynchronousCursor } from "../treeCursorUtils.js";
|
|
55
55
|
import {
|
|
@@ -128,8 +128,8 @@ export class ObjectForest implements IEditableForest, WithBreakable {
|
|
|
128
128
|
return new ObjectForest(this.breaker, schema, anchors, this.additionalAsserts, this.roots);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
public chunkField(cursor: ITreeCursorSynchronous): TreeChunk {
|
|
132
|
-
return
|
|
131
|
+
public chunkField(cursor: ITreeCursorSynchronous): TreeChunk[] {
|
|
132
|
+
return chunkField(cursor, { idCompressor: undefined, policy: defaultChunkPolicy });
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
public forgetAnchor(anchor: Anchor): void {
|
package/src/index.ts
CHANGED
|
@@ -123,6 +123,7 @@ export {
|
|
|
123
123
|
type WithType,
|
|
124
124
|
type NodeChangedData,
|
|
125
125
|
type SchemaUpgrade,
|
|
126
|
+
contentSchemaSymbol,
|
|
126
127
|
// Types not really intended for public use, but used in links.
|
|
127
128
|
// Can not be moved to internalTypes since doing so causes app code to throw errors like:
|
|
128
129
|
// Error: src/simple-tree/objectNode.ts:72:1 - (ae-unresolved-link) The @link reference could not be resolved: The package "@fluidframework/tree" does not have an export "TreeNodeApi"
|
|
@@ -164,6 +165,7 @@ export {
|
|
|
164
165
|
singletonSchema,
|
|
165
166
|
type UnsafeUnknownSchema,
|
|
166
167
|
type TreeViewAlpha,
|
|
168
|
+
type TreeViewBeta,
|
|
167
169
|
type InsertableField,
|
|
168
170
|
type Insertable,
|
|
169
171
|
type InsertableContent,
|
|
@@ -234,6 +236,7 @@ export {
|
|
|
234
236
|
type InsertableTreeNodeFromAllowedTypes,
|
|
235
237
|
type Input,
|
|
236
238
|
type TreeBranch,
|
|
239
|
+
type TreeBranchAlpha,
|
|
237
240
|
type TreeBranchEvents,
|
|
238
241
|
asTreeViewAlpha,
|
|
239
242
|
type NodeSchemaOptions,
|
|
@@ -337,4 +340,4 @@ export type { MapNodeInsertableData } from "./simple-tree/index.js";
|
|
|
337
340
|
export { JsonAsTree } from "./jsonDomainSchema.js";
|
|
338
341
|
export { FluidSerializableAsTree } from "./serializableDomainSchema.js";
|
|
339
342
|
export { TableSchema, type System_TableSchema } from "./tableSchema.js";
|
|
340
|
-
export { asAlpha } from "./api.js";
|
|
343
|
+
export { asAlpha, asBeta } from "./api.js";
|
package/src/packageVersion.ts
CHANGED