@fluidframework/tree 2.0.2 → 2.1.0-276326

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/.vscode/settings.json +16 -0
  2. package/README.md +6 -9
  3. package/api-report/tree.alpha.api.md +0 -15
  4. package/api-report/tree.beta.api.md +0 -12
  5. package/api-report/tree.public.api.md +0 -12
  6. package/dist/core/tree/anchorSet.js +2 -2
  7. package/dist/core/tree/anchorSet.js.map +1 -1
  8. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +1 -1
  9. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  10. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  11. package/dist/feature-libraries/flex-tree/lazyField.d.ts +1 -1
  12. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  13. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  14. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +4 -0
  15. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  16. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +4 -0
  17. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  18. package/dist/feature-libraries/modular-schema/modularChangeFormat.js +4 -0
  19. package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/packageVersion.d.ts +1 -1
  24. package/dist/packageVersion.d.ts.map +1 -1
  25. package/dist/packageVersion.js +1 -1
  26. package/dist/packageVersion.js.map +1 -1
  27. package/dist/shared-tree/index.d.ts +1 -1
  28. package/dist/shared-tree/index.d.ts.map +1 -1
  29. package/dist/shared-tree/index.js.map +1 -1
  30. package/dist/shared-tree/schematizingTreeView.d.ts +4 -6
  31. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  32. package/dist/shared-tree/schematizingTreeView.js +16 -12
  33. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  34. package/dist/shared-tree/sharedTree.d.ts +1 -2
  35. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  36. package/dist/shared-tree/sharedTree.js +0 -10
  37. package/dist/shared-tree/sharedTree.js.map +1 -1
  38. package/dist/shared-tree/treeApi.js.map +1 -1
  39. package/dist/shared-tree/treeView.d.ts +13 -6
  40. package/dist/shared-tree/treeView.d.ts.map +1 -1
  41. package/dist/shared-tree/treeView.js +0 -2
  42. package/dist/shared-tree/treeView.js.map +1 -1
  43. package/dist/simple-tree/index.d.ts +4 -3
  44. package/dist/simple-tree/index.d.ts.map +1 -1
  45. package/dist/simple-tree/index.js +5 -3
  46. package/dist/simple-tree/index.js.map +1 -1
  47. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  48. package/dist/simple-tree/objectNode.js +4 -0
  49. package/dist/simple-tree/objectNode.js.map +1 -1
  50. package/dist/simple-tree/proxies.d.ts.map +1 -1
  51. package/dist/simple-tree/proxies.js +13 -16
  52. package/dist/simple-tree/proxies.js.map +1 -1
  53. package/dist/simple-tree/schemaFactory.d.ts.map +1 -1
  54. package/dist/simple-tree/schemaFactory.js +2 -24
  55. package/dist/simple-tree/schemaFactory.js.map +1 -1
  56. package/dist/simple-tree/toFlexSchema.d.ts +0 -15
  57. package/dist/simple-tree/toFlexSchema.d.ts.map +1 -1
  58. package/dist/simple-tree/toFlexSchema.js +1 -35
  59. package/dist/simple-tree/toFlexSchema.js.map +1 -1
  60. package/dist/simple-tree/tree.d.ts +0 -29
  61. package/dist/simple-tree/tree.d.ts.map +1 -1
  62. package/dist/simple-tree/tree.js +1 -24
  63. package/dist/simple-tree/tree.js.map +1 -1
  64. package/dist/treeFactory.d.ts +1 -1
  65. package/dist/treeFactory.js +1 -1
  66. package/dist/treeFactory.js.map +1 -1
  67. package/dist/util/brandedMap.d.ts +9 -2
  68. package/dist/util/brandedMap.d.ts.map +1 -1
  69. package/dist/util/brandedMap.js +3 -4
  70. package/dist/util/brandedMap.js.map +1 -1
  71. package/lib/core/tree/anchorSet.js +2 -2
  72. package/lib/core/tree/anchorSet.js.map +1 -1
  73. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +1 -1
  74. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  75. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  76. package/lib/feature-libraries/flex-tree/lazyField.d.ts +1 -1
  77. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  78. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  79. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +4 -0
  80. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  81. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +4 -0
  82. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  83. package/lib/feature-libraries/modular-schema/modularChangeFormat.js +4 -0
  84. package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  85. package/lib/index.d.ts +1 -1
  86. package/lib/index.d.ts.map +1 -1
  87. package/lib/index.js.map +1 -1
  88. package/lib/packageVersion.d.ts +1 -1
  89. package/lib/packageVersion.d.ts.map +1 -1
  90. package/lib/packageVersion.js +1 -1
  91. package/lib/packageVersion.js.map +1 -1
  92. package/lib/shared-tree/index.d.ts +1 -1
  93. package/lib/shared-tree/index.d.ts.map +1 -1
  94. package/lib/shared-tree/index.js +1 -1
  95. package/lib/shared-tree/index.js.map +1 -1
  96. package/lib/shared-tree/schematizingTreeView.d.ts +4 -6
  97. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  98. package/lib/shared-tree/schematizingTreeView.js +19 -15
  99. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  100. package/lib/shared-tree/sharedTree.d.ts +1 -2
  101. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  102. package/lib/shared-tree/sharedTree.js +0 -10
  103. package/lib/shared-tree/sharedTree.js.map +1 -1
  104. package/lib/shared-tree/treeApi.js.map +1 -1
  105. package/lib/shared-tree/treeView.d.ts +13 -6
  106. package/lib/shared-tree/treeView.d.ts.map +1 -1
  107. package/lib/shared-tree/treeView.js +0 -2
  108. package/lib/shared-tree/treeView.js.map +1 -1
  109. package/lib/simple-tree/index.d.ts +4 -3
  110. package/lib/simple-tree/index.d.ts.map +1 -1
  111. package/lib/simple-tree/index.js +4 -3
  112. package/lib/simple-tree/index.js.map +1 -1
  113. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  114. package/lib/simple-tree/objectNode.js +4 -0
  115. package/lib/simple-tree/objectNode.js.map +1 -1
  116. package/lib/simple-tree/proxies.d.ts.map +1 -1
  117. package/lib/simple-tree/proxies.js +14 -17
  118. package/lib/simple-tree/proxies.js.map +1 -1
  119. package/lib/simple-tree/schemaFactory.d.ts.map +1 -1
  120. package/lib/simple-tree/schemaFactory.js +3 -25
  121. package/lib/simple-tree/schemaFactory.js.map +1 -1
  122. package/lib/simple-tree/toFlexSchema.d.ts +0 -15
  123. package/lib/simple-tree/toFlexSchema.d.ts.map +1 -1
  124. package/lib/simple-tree/toFlexSchema.js +0 -33
  125. package/lib/simple-tree/toFlexSchema.js.map +1 -1
  126. package/lib/simple-tree/tree.d.ts +0 -29
  127. package/lib/simple-tree/tree.d.ts.map +1 -1
  128. package/lib/simple-tree/tree.js +0 -22
  129. package/lib/simple-tree/tree.js.map +1 -1
  130. package/lib/treeFactory.d.ts +1 -1
  131. package/lib/treeFactory.js +1 -1
  132. package/lib/treeFactory.js.map +1 -1
  133. package/lib/util/brandedMap.d.ts +9 -2
  134. package/lib/util/brandedMap.d.ts.map +1 -1
  135. package/lib/util/brandedMap.js +3 -4
  136. package/lib/util/brandedMap.js.map +1 -1
  137. package/package.json +23 -23
  138. package/src/core/tree/anchorSet.ts +3 -3
  139. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +5 -1
  140. package/src/feature-libraries/flex-tree/lazyField.ts +8 -5
  141. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +5 -0
  142. package/src/feature-libraries/modular-schema/modularChangeFormat.ts +4 -0
  143. package/src/index.ts +1 -0
  144. package/src/packageVersion.ts +1 -1
  145. package/src/shared-tree/index.ts +6 -1
  146. package/src/shared-tree/schematizingTreeView.ts +32 -26
  147. package/src/shared-tree/sharedTree.ts +0 -18
  148. package/src/shared-tree/treeApi.ts +2 -2
  149. package/src/shared-tree/treeView.ts +14 -8
  150. package/src/simple-tree/index.ts +7 -3
  151. package/src/simple-tree/objectNode.ts +6 -0
  152. package/src/simple-tree/proxies.ts +22 -20
  153. package/src/simple-tree/schemaFactory.ts +5 -41
  154. package/src/simple-tree/toFlexSchema.ts +0 -47
  155. package/src/simple-tree/tree.ts +0 -37
  156. package/src/treeFactory.ts +1 -1
  157. package/src/util/brandedMap.ts +18 -11
@@ -10,8 +10,6 @@ import { brand, fail, isReadonlyArray, mapIterable } from "../util/index.js";
10
10
  import { cachedFlexSchemaFromClassSchema, setFlexSchemaFromClassSchema, tryGetSimpleNodeSchema, } from "./schemaCaching.js";
11
11
  import { FieldKind, FieldSchema, NodeKind, normalizeFieldSchema, getStoredKey, } from "./schemaTypes.js";
12
12
  import { cursorFromNodeData } from "./toMapTree.js";
13
- // eslint-disable-next-line import/no-deprecated
14
- import { TreeConfiguration } from "./tree.js";
15
13
  /**
16
14
  * Returns a cursor (in nodes mode) for the root node.
17
15
  *
@@ -25,37 +23,6 @@ export function cursorFromUnhydratedRoot(schema, tree, nodeKeyManager, schemaVal
25
23
  const normalizedFieldSchema = normalizeFieldSchema(schema);
26
24
  return (cursorFromNodeData(data, normalizedFieldSchema.allowedTypes, nodeKeyManager, schemaValidationPolicy) ?? fail("failed to decode tree"));
27
25
  }
28
- /* eslint-disable import/no-deprecated */
29
- function isTreeConfiguration(config) {
30
- return config instanceof TreeConfiguration;
31
- }
32
- /* eslint-enable import/no-deprecated */
33
- /**
34
- * Generates a configuration object (schema + initial tree) for a FlexTree.
35
- * @param config - Configuration for how to {@link ITree.schematize|schematize} a tree.
36
- * @param nodeKeyManager - See {@link NodeKeyManager}.
37
- * @param schemaValidationPolicy - Stored schema and policy for the tree. If the policy specifies
38
- * `{@link SchemaPolicy.validateSchema} === true`, new content inserted into the tree will be validated using this
39
- * object.
40
- * @returns A configuration object for a FlexTree.
41
- *
42
- * @privateremarks
43
- * I wrote these docs without a ton of context, they can probably be improved.
44
- */
45
- export function toFlexConfig(
46
- // eslint-disable-next-line import/no-deprecated
47
- config, nodeKeyManager, schemaValidationPolicy = undefined) {
48
- const unhydrated = isTreeConfiguration(config) ? config.initialTree() : undefined;
49
- const initialTree = unhydrated === undefined
50
- ? undefined
51
- : [
52
- cursorFromUnhydratedRoot(config.schema, unhydrated, nodeKeyManager, schemaValidationPolicy),
53
- ];
54
- return {
55
- schema: toFlexSchema(config.schema),
56
- initialTree,
57
- };
58
- }
59
26
  /**
60
27
  * Generate a {@link FlexTreeSchema} with `root` as the root field.
61
28
  *
@@ -1 +1 @@
1
- {"version":3,"file":"toFlexSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toFlexSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+CAA+C;AAC/C,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAO9E,OAAO,EACN,UAAU,EAGV,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EAIpB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,GACZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AAEvF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG7E,OAAO,EACN,+BAA+B,EAC/B,4BAA4B,EAC5B,sBAAsB,GACtB,MAAM,oBAAoB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AC,6BAA6B,CAAC,CAAC;QAC/E,CAAC;YACA,MAAM,MAAM,GAAG,+BAA+B,CAAC,MAAM,CAAC,CAAC;YACvD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC1B,MAAM,CACL,+BAA+B,CAAC,MAAM,CAAC,KAAK,GAAG,EAC/C,KAAK,CAAC,gCAAgC,CACtC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACP,4BAA4B,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAC3C,CAAC;QACF,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC,CAAC;IACF,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-internal-modules */\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\n\nimport type {\n\tITreeCursorSynchronous,\n\tTreeNodeSchemaIdentifier,\n\tSchemaAndPolicy,\n} from \"../core/index.js\";\nimport {\n\tFieldKinds,\n\ttype FlexAllowedTypes,\n\ttype FlexFieldKind,\n\tFlexFieldNodeSchema,\n\tFlexFieldSchema,\n\tFlexMapNodeSchema,\n\tFlexObjectNodeSchema,\n\ttype FlexTreeNodeSchema,\n\ttype FlexTreeSchema,\n\ttype NodeKeyManager,\n\tTreeNodeSchemaBase,\n\tdefaultSchemaPolicy,\n\tschemaIsLeaf,\n} from \"../feature-libraries/index.js\";\nimport { normalizeFlexListEager } from \"../feature-libraries/typed-schema/flexList.js\";\nimport type { TreeContent } from \"../shared-tree/index.js\";\nimport { brand, fail, isReadonlyArray, mapIterable } from \"../util/index.js\";\n\nimport type { InsertableContent } from \"./proxies.js\";\nimport {\n\tcachedFlexSchemaFromClassSchema,\n\tsetFlexSchemaFromClassSchema,\n\ttryGetSimpleNodeSchema,\n} from \"./schemaCaching.js\";\nimport {\n\tFieldKind,\n\tFieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\tNodeKind,\n\ttype TreeNodeSchema,\n\tnormalizeFieldSchema,\n\tgetStoredKey,\n} from \"./schemaTypes.js\";\nimport { cursorFromNodeData } from \"./toMapTree.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { TreeConfiguration, type TreeViewConfiguration } from \"./tree.js\";\n\n/**\n * Returns a cursor (in nodes mode) for the root node.\n *\n * @privateRemarks\n * Ideally this would work on any node, not just the root,\n * and the schema would come from the unhydrated node.\n * For now though, this is the only case that's needed, and we do have the data to make it work, so this is fine.\n */\nexport function cursorFromUnhydratedRoot(\n\tschema: ImplicitFieldSchema,\n\ttree: InsertableTreeNodeFromImplicitAllowedTypes,\n\tnodeKeyManager: NodeKeyManager,\n\tschemaValidationPolicy: SchemaAndPolicy | undefined = undefined,\n): ITreeCursorSynchronous {\n\tconst data = tree as InsertableContent;\n\tconst normalizedFieldSchema = normalizeFieldSchema(schema);\n\treturn (\n\t\tcursorFromNodeData(\n\t\t\tdata,\n\t\t\tnormalizedFieldSchema.allowedTypes,\n\t\t\tnodeKeyManager,\n\t\t\tschemaValidationPolicy,\n\t\t) ?? fail(\"failed to decode tree\")\n\t);\n}\n\n/* eslint-disable import/no-deprecated */\nfunction isTreeConfiguration(\n\tconfig: TreeViewConfiguration | TreeConfiguration,\n): config is TreeConfiguration {\n\treturn config instanceof TreeConfiguration;\n}\n/* eslint-enable import/no-deprecated */\n\n/**\n * Generates a configuration object (schema + initial tree) for a FlexTree.\n * @param config - Configuration for how to {@link ITree.schematize|schematize} a tree.\n * @param nodeKeyManager - See {@link NodeKeyManager}.\n * @param schemaValidationPolicy - Stored schema and policy for the tree. If the policy specifies\n * `{@link SchemaPolicy.validateSchema} === true`, new content inserted into the tree will be validated using this\n * object.\n * @returns A configuration object for a FlexTree.\n *\n * @privateremarks\n * I wrote these docs without a ton of context, they can probably be improved.\n */\nexport function toFlexConfig(\n\t// eslint-disable-next-line import/no-deprecated\n\tconfig: TreeViewConfiguration | TreeConfiguration,\n\tnodeKeyManager: NodeKeyManager,\n\tschemaValidationPolicy: SchemaAndPolicy | undefined = undefined,\n): TreeContent {\n\tconst unhydrated = isTreeConfiguration(config) ? config.initialTree() : undefined;\n\tconst initialTree =\n\t\tunhydrated === undefined\n\t\t\t? undefined\n\t\t\t: [\n\t\t\t\t\tcursorFromUnhydratedRoot(\n\t\t\t\t\t\tconfig.schema,\n\t\t\t\t\t\tunhydrated,\n\t\t\t\t\t\tnodeKeyManager,\n\t\t\t\t\t\tschemaValidationPolicy,\n\t\t\t\t\t),\n\t\t\t\t];\n\treturn {\n\t\tschema: toFlexSchema(config.schema),\n\t\tinitialTree,\n\t};\n}\n\ninterface SchemaInfo {\n\ttoFlex: () => FlexTreeNodeSchema;\n\toriginal: TreeNodeSchema;\n}\n\ntype SchemaMap = Map<TreeNodeSchemaIdentifier, SchemaInfo>;\n\n/**\n * Generate a {@link FlexTreeSchema} with `root` as the root field.\n *\n * This also has the side effect of populating the cached view schema on the class-based schema.\n */\nexport function toFlexSchema(root: ImplicitFieldSchema): FlexTreeSchema {\n\tconst schemaMap: SchemaMap = new Map();\n\tconst field = convertField(schemaMap, root);\n\tconst nodeSchema = new Map(\n\t\tmapIterable(schemaMap, ([key, value]) => {\n\t\t\tconst schema = value.toFlex();\n\t\t\tconst classSchema = tryGetSimpleNodeSchema(schema);\n\t\t\tif (classSchema === undefined) {\n\t\t\t\tassert(schemaIsLeaf(schema), 0x83e /* invalid leaf */);\n\t\t\t} else {\n\t\t\t\tassert(\n\t\t\t\t\tcachedFlexSchemaFromClassSchema(classSchema) === schema,\n\t\t\t\t\t0x83f /* mismatched schema */,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn [key, schema];\n\t\t}),\n\t);\n\n\tconst typed: FlexTreeSchema = {\n\t\tnodeSchema,\n\t\tadapters: {},\n\t\trootFieldSchema: field,\n\t\tpolicy: defaultSchemaPolicy,\n\t};\n\treturn typed;\n}\n\n/**\n * Return a flex schema for the provided class schema.\n *\n * This also has the side effect of populating the cached view schema on the class based schema.\n */\nexport function getFlexSchema(root: TreeNodeSchema): FlexTreeNodeSchema {\n\tconst treeSchema = toFlexSchema(root);\n\treturn treeSchema.rootFieldSchema.monomorphicChildType ?? fail(\"root should be monomorphic\");\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(\n\tschemaMap: SchemaMap,\n\tschema: ImplicitFieldSchema,\n): FlexFieldSchema {\n\tlet kind: FlexFieldKind;\n\tlet types: ImplicitAllowedTypes;\n\tif (schema instanceof FieldSchema) {\n\t\tkind = convertFieldKind.get(schema.kind) ?? fail(\"Invalid field kind\");\n\t\ttypes = schema.allowedTypes;\n\t} else {\n\t\tkind = FieldKinds.required;\n\t\ttypes = schema;\n\t}\n\tconst allowedTypes = convertAllowedTypes(schemaMap, types);\n\treturn FlexFieldSchema.create(kind, allowedTypes);\n}\n\nconst convertFieldKind = new Map<FieldKind, FlexFieldKind>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Normalizes an {@link ImplicitAllowedTypes} into an {@link AllowedTypes}.\n */\nexport function convertAllowedTypes(\n\tschemaMap: SchemaMap,\n\tschema: ImplicitAllowedTypes,\n): FlexAllowedTypes {\n\tif (isReadonlyArray(schema)) {\n\t\treturn normalizeFlexListEager(schema).map((item) => convertNodeSchema(schemaMap, item));\n\t}\n\treturn [convertNodeSchema(schemaMap, schema)];\n}\n\nconst builder = { name: \"simple schema\" };\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link FlexTreeNodeSchema}.\n * Ensures all types reachable from `schema` are included in `schemaMap`.\n *\n * Return value (and entries in map) are lazy to allow recursive types to work.\n * This laziness does NOT extend to adding entries to `schemaMap`:\n * all referenced types are added to it before this function returns.\n */\nexport function convertNodeSchema(\n\tschemaMap: SchemaMap,\n\tschema: TreeNodeSchema,\n): () => FlexTreeNodeSchema {\n\tconst fromMap = schemaMap.get(brand(schema.identifier));\n\tif (fromMap !== undefined) {\n\t\tif (fromMap.original !== schema) {\n\t\t\t// Use JSON.stringify to quote and escape string.\n\t\t\tthrow new Error(\n\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\tschema.identifier,\n\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t);\n\t\t}\n\t\treturn fromMap.toFlex;\n\t}\n\n\tconst toFlex = (): FlexTreeNodeSchema => {\n\t\tlet out: FlexTreeNodeSchema;\n\t\tconst kind = schema.kind;\n\t\tswitch (kind) {\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\tconst cached =\n\t\t\t\t\tcachedFlexSchemaFromClassSchema(schema) ?? fail(\"leaf schema should be pre-cached\");\n\t\t\t\tassert(schemaIsLeaf(cached), 0x840 /* expected leaf */);\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t\tcase NodeKind.Map: {\n\t\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\t\tconst field = FlexFieldSchema.create(\n\t\t\t\t\tFieldKinds.optional,\n\t\t\t\t\tconvertAllowedTypes(schemaMap, fieldInfo),\n\t\t\t\t);\n\t\t\t\t// Lookup of cached schema is done here instead of before since walking the schema recursively to populate schemaMap is still required.\n\t\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\t\tout = cached ?? FlexMapNodeSchema.create(builder, brand(schema.identifier), field);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\t\tconst field = FlexFieldSchema.create(\n\t\t\t\t\tFieldKinds.sequence,\n\t\t\t\t\tconvertAllowedTypes(schemaMap, fieldInfo),\n\t\t\t\t);\n\t\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\t\tout = cached ?? FlexFieldNodeSchema.create(builder, brand(schema.identifier), field);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tconst info = schema.info as Record<string, ImplicitFieldSchema>;\n\t\t\t\tconst fields: Record<string, FlexFieldSchema> = Object.create(null);\n\t\t\t\tfor (const [viewKey, implicitFieldSchema] of Object.entries(info)) {\n\t\t\t\t\t// If a `stored key` was provided, use it as the key in the flex schema.\n\t\t\t\t\t// Otherwise, use the view key.\n\t\t\t\t\tconst flexKey = getStoredKey(viewKey, implicitFieldSchema);\n\n\t\t\t\t\t// This code has to be careful to avoid assigning to __proto__ or similar built-in fields.\n\t\t\t\t\tObject.defineProperty(fields, flexKey, {\n\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\tconfigurable: false,\n\t\t\t\t\t\twritable: false,\n\t\t\t\t\t\tvalue: convertField(schemaMap, implicitFieldSchema),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\t\tout = cached ?? FlexObjectNodeSchema.create(builder, brand(schema.identifier), fields);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tunreachableCase(kind);\n\t\t}\n\t\tassert(out instanceof TreeNodeSchemaBase, 0x841 /* invalid schema produced */);\n\t\t{\n\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\tif (cached !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tcachedFlexSchemaFromClassSchema(schema) === out,\n\t\t\t\t\t0x842 /* incorrect flexSchemaSymbol */,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsetFlexSchemaFromClassSchema(schema, out);\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t};\n\tschemaMap.set(brand(schema.identifier), { original: schema, to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,SAAS,EAAE,CAAC;gBAC1B,MAAM,CACL,+BAA+B,CAAC,MAAM,CAAC,KAAK,GAAG,EAC/C,KAAK,CAAC,gCAAgC,CACtC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACP,4BAA4B,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAC3C,CAAC;QACF,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC,CAAC;IACF,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-internal-modules */\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\n\nimport type {\n\tITreeCursorSynchronous,\n\tTreeNodeSchemaIdentifier,\n\tSchemaAndPolicy,\n} from \"../core/index.js\";\nimport {\n\tFieldKinds,\n\ttype FlexAllowedTypes,\n\ttype FlexFieldKind,\n\tFlexFieldNodeSchema,\n\tFlexFieldSchema,\n\tFlexMapNodeSchema,\n\tFlexObjectNodeSchema,\n\ttype FlexTreeNodeSchema,\n\ttype FlexTreeSchema,\n\ttype NodeKeyManager,\n\tTreeNodeSchemaBase,\n\tdefaultSchemaPolicy,\n\tschemaIsLeaf,\n} from \"../feature-libraries/index.js\";\nimport { normalizeFlexListEager } from \"../feature-libraries/typed-schema/flexList.js\";\nimport { brand, fail, isReadonlyArray, mapIterable } from \"../util/index.js\";\n\nimport type { InsertableContent } from \"./proxies.js\";\nimport {\n\tcachedFlexSchemaFromClassSchema,\n\tsetFlexSchemaFromClassSchema,\n\ttryGetSimpleNodeSchema,\n} from \"./schemaCaching.js\";\nimport {\n\tFieldKind,\n\tFieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\tNodeKind,\n\ttype TreeNodeSchema,\n\tnormalizeFieldSchema,\n\tgetStoredKey,\n} from \"./schemaTypes.js\";\nimport { cursorFromNodeData } from \"./toMapTree.js\";\n\n/**\n * Returns a cursor (in nodes mode) for the root node.\n *\n * @privateRemarks\n * Ideally this would work on any node, not just the root,\n * and the schema would come from the unhydrated node.\n * For now though, this is the only case that's needed, and we do have the data to make it work, so this is fine.\n */\nexport function cursorFromUnhydratedRoot(\n\tschema: ImplicitFieldSchema,\n\ttree: InsertableTreeNodeFromImplicitAllowedTypes,\n\tnodeKeyManager: NodeKeyManager,\n\tschemaValidationPolicy: SchemaAndPolicy | undefined = undefined,\n): ITreeCursorSynchronous {\n\tconst data = tree as InsertableContent;\n\tconst normalizedFieldSchema = normalizeFieldSchema(schema);\n\treturn (\n\t\tcursorFromNodeData(\n\t\t\tdata,\n\t\t\tnormalizedFieldSchema.allowedTypes,\n\t\t\tnodeKeyManager,\n\t\t\tschemaValidationPolicy,\n\t\t) ?? fail(\"failed to decode tree\")\n\t);\n}\n\ninterface SchemaInfo {\n\ttoFlex: () => FlexTreeNodeSchema;\n\toriginal: TreeNodeSchema;\n}\n\ntype SchemaMap = Map<TreeNodeSchemaIdentifier, SchemaInfo>;\n\n/**\n * Generate a {@link FlexTreeSchema} with `root` as the root field.\n *\n * This also has the side effect of populating the cached view schema on the class-based schema.\n */\nexport function toFlexSchema(root: ImplicitFieldSchema): FlexTreeSchema {\n\tconst schemaMap: SchemaMap = new Map();\n\tconst field = convertField(schemaMap, root);\n\tconst nodeSchema = new Map(\n\t\tmapIterable(schemaMap, ([key, value]) => {\n\t\t\tconst schema = value.toFlex();\n\t\t\tconst classSchema = tryGetSimpleNodeSchema(schema);\n\t\t\tif (classSchema === undefined) {\n\t\t\t\tassert(schemaIsLeaf(schema), 0x83e /* invalid leaf */);\n\t\t\t} else {\n\t\t\t\tassert(\n\t\t\t\t\tcachedFlexSchemaFromClassSchema(classSchema) === schema,\n\t\t\t\t\t0x83f /* mismatched schema */,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn [key, schema];\n\t\t}),\n\t);\n\n\tconst typed: FlexTreeSchema = {\n\t\tnodeSchema,\n\t\tadapters: {},\n\t\trootFieldSchema: field,\n\t\tpolicy: defaultSchemaPolicy,\n\t};\n\treturn typed;\n}\n\n/**\n * Return a flex schema for the provided class schema.\n *\n * This also has the side effect of populating the cached view schema on the class based schema.\n */\nexport function getFlexSchema(root: TreeNodeSchema): FlexTreeNodeSchema {\n\tconst treeSchema = toFlexSchema(root);\n\treturn treeSchema.rootFieldSchema.monomorphicChildType ?? fail(\"root should be monomorphic\");\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(\n\tschemaMap: SchemaMap,\n\tschema: ImplicitFieldSchema,\n): FlexFieldSchema {\n\tlet kind: FlexFieldKind;\n\tlet types: ImplicitAllowedTypes;\n\tif (schema instanceof FieldSchema) {\n\t\tkind = convertFieldKind.get(schema.kind) ?? fail(\"Invalid field kind\");\n\t\ttypes = schema.allowedTypes;\n\t} else {\n\t\tkind = FieldKinds.required;\n\t\ttypes = schema;\n\t}\n\tconst allowedTypes = convertAllowedTypes(schemaMap, types);\n\treturn FlexFieldSchema.create(kind, allowedTypes);\n}\n\nconst convertFieldKind = new Map<FieldKind, FlexFieldKind>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Normalizes an {@link ImplicitAllowedTypes} into an {@link AllowedTypes}.\n */\nexport function convertAllowedTypes(\n\tschemaMap: SchemaMap,\n\tschema: ImplicitAllowedTypes,\n): FlexAllowedTypes {\n\tif (isReadonlyArray(schema)) {\n\t\treturn normalizeFlexListEager(schema).map((item) => convertNodeSchema(schemaMap, item));\n\t}\n\treturn [convertNodeSchema(schemaMap, schema)];\n}\n\nconst builder = { name: \"simple schema\" };\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link FlexTreeNodeSchema}.\n * Ensures all types reachable from `schema` are included in `schemaMap`.\n *\n * Return value (and entries in map) are lazy to allow recursive types to work.\n * This laziness does NOT extend to adding entries to `schemaMap`:\n * all referenced types are added to it before this function returns.\n */\nexport function convertNodeSchema(\n\tschemaMap: SchemaMap,\n\tschema: TreeNodeSchema,\n): () => FlexTreeNodeSchema {\n\tconst fromMap = schemaMap.get(brand(schema.identifier));\n\tif (fromMap !== undefined) {\n\t\tif (fromMap.original !== schema) {\n\t\t\t// Use JSON.stringify to quote and escape string.\n\t\t\tthrow new Error(\n\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\tschema.identifier,\n\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t);\n\t\t}\n\t\treturn fromMap.toFlex;\n\t}\n\n\tconst toFlex = (): FlexTreeNodeSchema => {\n\t\tlet out: FlexTreeNodeSchema;\n\t\tconst kind = schema.kind;\n\t\tswitch (kind) {\n\t\t\tcase NodeKind.Leaf: {\n\t\t\t\tconst cached =\n\t\t\t\t\tcachedFlexSchemaFromClassSchema(schema) ?? fail(\"leaf schema should be pre-cached\");\n\t\t\t\tassert(schemaIsLeaf(cached), 0x840 /* expected leaf */);\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t\tcase NodeKind.Map: {\n\t\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\t\tconst field = FlexFieldSchema.create(\n\t\t\t\t\tFieldKinds.optional,\n\t\t\t\t\tconvertAllowedTypes(schemaMap, fieldInfo),\n\t\t\t\t);\n\t\t\t\t// Lookup of cached schema is done here instead of before since walking the schema recursively to populate schemaMap is still required.\n\t\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\t\tout = cached ?? FlexMapNodeSchema.create(builder, brand(schema.identifier), field);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Array: {\n\t\t\t\tconst fieldInfo = schema.info as ImplicitAllowedTypes;\n\t\t\t\tconst field = FlexFieldSchema.create(\n\t\t\t\t\tFieldKinds.sequence,\n\t\t\t\t\tconvertAllowedTypes(schemaMap, fieldInfo),\n\t\t\t\t);\n\t\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\t\tout = cached ?? FlexFieldNodeSchema.create(builder, brand(schema.identifier), field);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase NodeKind.Object: {\n\t\t\t\tconst info = schema.info as Record<string, ImplicitFieldSchema>;\n\t\t\t\tconst fields: Record<string, FlexFieldSchema> = Object.create(null);\n\t\t\t\tfor (const [viewKey, implicitFieldSchema] of Object.entries(info)) {\n\t\t\t\t\t// If a `stored key` was provided, use it as the key in the flex schema.\n\t\t\t\t\t// Otherwise, use the view key.\n\t\t\t\t\tconst flexKey = getStoredKey(viewKey, implicitFieldSchema);\n\n\t\t\t\t\t// This code has to be careful to avoid assigning to __proto__ or similar built-in fields.\n\t\t\t\t\tObject.defineProperty(fields, flexKey, {\n\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\tconfigurable: false,\n\t\t\t\t\t\twritable: false,\n\t\t\t\t\t\tvalue: convertField(schemaMap, implicitFieldSchema),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\t\tout = cached ?? FlexObjectNodeSchema.create(builder, brand(schema.identifier), fields);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tunreachableCase(kind);\n\t\t}\n\t\tassert(out instanceof TreeNodeSchemaBase, 0x841 /* invalid schema produced */);\n\t\t{\n\t\t\tconst cached = cachedFlexSchemaFromClassSchema(schema);\n\t\t\tif (cached !== undefined) {\n\t\t\t\tassert(\n\t\t\t\t\tcachedFlexSchemaFromClassSchema(schema) === out,\n\t\t\t\t\t0x842 /* incorrect flexSchemaSymbol */,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsetFlexSchemaFromClassSchema(schema, out);\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t};\n\tschemaMap.set(brand(schema.identifier), { original: schema, toFlex });\n\treturn toFlex;\n}\n"]}
@@ -104,35 +104,6 @@ export declare class TreeViewConfiguration<TSchema extends ImplicitFieldSchema =
104
104
  */
105
105
  constructor(props: ITreeViewConfiguration<TSchema>);
106
106
  }
107
- /**
108
- * Configuration for how to {@link ITree.schematize | schematize} a tree.
109
- * @sealed @public
110
- * @deprecated Please migrate to use {@link TreeViewConfiguration} with {@link ITree.viewWith} instead.
111
- */
112
- export declare class TreeConfiguration<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> {
113
- readonly schema: TSchema;
114
- readonly initialTree: () => InsertableTreeFieldFromImplicitField<TSchema>;
115
- /**
116
- * If `true`, the tree will validate new content against its stored schema at insertion time
117
- * and throw an error if the new content doesn't match the expected schema.
118
- *
119
- * @defaultValue `false`.
120
- *
121
- * @remarks Enabling schema validation has a performance penalty when inserting new content into the tree because
122
- * additional checks are done. Enable this option only in scenarios where you are ok with that operation being a
123
- * bit slower.
124
- */
125
- readonly enableSchemaValidation: boolean;
126
- /**
127
- * @param schema - The schema which the application wants to view the tree with.
128
- * @param initialTree - A function that returns the default tree content to initialize the tree with iff the tree is uninitialized
129
- * (meaning it does not even have any schema set at all).
130
- * If `initialTree` returns any actual node instances, they should be recreated each time `initialTree` runs.
131
- * This is because if the config is used a second time any nodes that were not recreated could error since nodes cannot be inserted into the tree multiple times.
132
- * @param options - Additional options that can be specified when {@link ITree.schematize | schematizing } a tree.
133
- */
134
- constructor(schema: TSchema, initialTree: () => InsertableTreeFieldFromImplicitField<TSchema>, options?: ITreeConfigurationOptions);
135
- }
136
107
  /**
137
108
  * An editable view of a (version control style) branch of a shared tree based on some schema.
138
109
  *
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/simple-tree/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OA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EtB;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,aAAa,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC7E"}
@@ -19,26 +19,4 @@ export class TreeViewConfiguration {
19
19
  this.enableSchemaValidation = config.enableSchemaValidation;
20
20
  }
21
21
  }
22
- /**
23
- * Configuration for how to {@link ITree.schematize | schematize} a tree.
24
- * @sealed @public
25
- * @deprecated Please migrate to use {@link TreeViewConfiguration} with {@link ITree.viewWith} instead.
26
- */
27
- export class TreeConfiguration {
28
- /**
29
- * @param schema - The schema which the application wants to view the tree with.
30
- * @param initialTree - A function that returns the default tree content to initialize the tree with iff the tree is uninitialized
31
- * (meaning it does not even have any schema set at all).
32
- * If `initialTree` returns any actual node instances, they should be recreated each time `initialTree` runs.
33
- * This is because if the config is used a second time any nodes that were not recreated could error since nodes cannot be inserted into the tree multiple times.
34
- * @param options - Additional options that can be specified when {@link ITree.schematize | schematizing } a tree.
35
- */
36
- constructor(schema, initialTree, options) {
37
- this.schema = schema;
38
- this.initialTree = initialTree;
39
- this.enableSchemaValidation =
40
- options?.enableSchemaValidation ??
41
- defaultTreeConfigurationOptions.enableSchemaValidation;
42
- }
43
- }
44
22
  //# sourceMappingURL=tree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/simple-tree/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4EH,MAAM,+BAA+B,GAAwC;IAC5E,sBAAsB,EAAE,KAAK;CAC7B,CAAC;AA2BF;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAajC;;OAEG;IACH,YAAmB,KAAsC;QACxD,MAAM,MAAM,GAAG,EAAE,GAAG,+BAA+B,EAAE,GAAG,KAAK,EAAE,CAAC;QAChE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC,sBAAsB,CAAC;IAC7D,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAa7B;;;;;;;OAOG;IACH,YACiB,MAAe,EACf,WAAgE,EAChF,OAAmC;QAFnB,WAAM,GAAN,MAAM,CAAS;QACf,gBAAW,GAAX,WAAW,CAAqD;QAGhF,IAAI,CAAC,sBAAsB;YAC1B,OAAO,EAAE,sBAAsB;gBAC/B,+BAA+B,CAAC,sBAAsB,CAAC;IACzD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidLoadable, IDisposable } from \"@fluidframework/core-interfaces\";\n\nimport type { CommitMetadata } from \"../core/index.js\";\nimport type { Listenable } from \"../events/index.js\";\nimport type { RevertibleFactory } from \"../shared-tree/index.js\";\n\nimport type {\n\tImplicitFieldSchema,\n\tInsertableTreeFieldFromImplicitField,\n\tTreeFieldFromImplicitField,\n} from \"./schemaTypes.js\";\n\n/**\n * Channel for a Fluid Tree DDS.\n * @remarks\n * Allows storing and collaboratively editing schema-aware hierarchial data.\n * @sealed @public\n */\nexport interface ITree extends IFluidLoadable {\n\t/**\n\t * Returns a {@link TreeView} using the provided schema.\n\t * If the stored schema is compatible with the view schema specified by `config`,\n\t * the returned {@link TreeView} will expose the root with a schema-aware API based on the provided view schema.\n\t * If the provided schema is incompatible with the stored schema, the view will instead expose a status indicating the incompatibility.\n\t *\n\t * @remarks\n\t * If the tree is uninitialized (has no schema and no content), use {@link TreeView.initialize} on the returned view to set the schema and content together.\n\t * Using `viewWith` followed by {@link TreeView.upgradeSchema} to initialize only the schema for a document is technically valid when the schema\n\t * permits trees with no content.\n\t *\n\t * Note that other clients can modify the document at any time, causing the view to change its compatibility status: see {@link TreeView.events} for how to handle invalidation in these cases.\n\t *\n\t * Only one schematized view may exist for a given ITree at a time.\n\t * If creating a second, the first must be disposed before calling `viewWith` again.\n\t *\n\t * @privateRemarks\n\t * TODO: Provide a way to make a generic view schema for any document.\n\t * TODO: Support adapters for handling out-of-schema data.\n\t *\n\t * Doing initialization here allows a small API that is hard to use incorrectly.\n\t * Other approaches tend to have easy-to-make mistakes.\n\t * For example, having a separate initialization function means apps can forget to call it, making an app that can only open existing documents,\n\t * or call it unconditionally leaving an app that can only create new documents.\n\t * It also would require the schema to be passed into separate places and could cause issues if they didn't match.\n\t * Since the initialization function couldn't return a typed tree, the type checking wouldn't help catch that.\n\t * Also, if an app manages to create a document, but the initialization fails to get persisted, an app that only calls the initialization function\n\t * on the create code-path (for example how a schematized factory might do it),\n\t * would leave the document in an unusable state which could not be repaired when it is reopened (by the same or other clients).\n\t * Additionally, once out of schema content adapters are properly supported (with lazy document updates),\n\t * this initialization could become just another out of schema content adapter and this initialization is no longer a special case.\n\t */\n\tviewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * Options when constructing a tree view.\n * @public\n */\nexport interface ITreeConfigurationOptions {\n\t/**\n\t * If `true`, the tree will validate new content against its stored schema at insertion time\n\t * and throw an error if the new content doesn't match the expected schema.\n\t *\n\t * @defaultValue `false`.\n\t *\n\t * @remarks Enabling schema validation has a performance penalty when inserting new content into the tree because\n\t * additional checks are done. Enable this option only in scenarios where you are ok with that operation being a\n\t * bit slower.\n\t */\n\tenableSchemaValidation?: boolean;\n}\n\nconst defaultTreeConfigurationOptions: Required<ITreeConfigurationOptions> = {\n\tenableSchemaValidation: false,\n};\n\n/**\n * Property-bag configuration for {@link TreeViewConfiguration} construction.\n * @public\n */\nexport interface ITreeViewConfiguration<\n\tTSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n> {\n\t/**\n\t * The schema which the application wants to view the tree with.\n\t */\n\treadonly schema: TSchema;\n\n\t/**\n\t * If `true`, the tree will validate new content against its stored schema at insertion time\n\t * and throw an error if the new content doesn't match the expected schema.\n\t *\n\t * @defaultValue `false`.\n\t *\n\t * @remarks Enabling schema validation has a performance penalty when inserting new content into the tree because\n\t * additional checks are done. Enable this option only in scenarios where you are ok with that operation being a\n\t * bit slower.\n\t */\n\treadonly enableSchemaValidation?: boolean;\n}\n\n/**\n * Configuration for {@link ITree.viewWith}.\n * @sealed @public\n */\nexport class TreeViewConfiguration<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema>\n\timplements Required<ITreeViewConfiguration<TSchema>>\n{\n\t/**\n\t * {@inheritDoc ITreeViewConfiguration.schema}\n\t */\n\tpublic readonly schema: TSchema;\n\n\t/**\n\t * {@inheritDoc ITreeViewConfiguration.enableSchemaValidation}\n\t */\n\tpublic readonly enableSchemaValidation: boolean;\n\n\t/**\n\t * @param props - Property bag of configuration options.\n\t */\n\tpublic constructor(props: ITreeViewConfiguration<TSchema>) {\n\t\tconst config = { ...defaultTreeConfigurationOptions, ...props };\n\t\tthis.schema = config.schema;\n\t\tthis.enableSchemaValidation = config.enableSchemaValidation;\n\t}\n}\n\n/**\n * Configuration for how to {@link ITree.schematize | schematize} a tree.\n * @sealed @public\n * @deprecated Please migrate to use {@link TreeViewConfiguration} with {@link ITree.viewWith} instead.\n */\nexport class TreeConfiguration<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> {\n\t/**\n\t * If `true`, the tree will validate new content against its stored schema at insertion time\n\t * and throw an error if the new content doesn't match the expected schema.\n\t *\n\t * @defaultValue `false`.\n\t *\n\t * @remarks Enabling schema validation has a performance penalty when inserting new content into the tree because\n\t * additional checks are done. Enable this option only in scenarios where you are ok with that operation being a\n\t * bit slower.\n\t */\n\tpublic readonly enableSchemaValidation: boolean;\n\n\t/**\n\t * @param schema - The schema which the application wants to view the tree with.\n\t * @param initialTree - A function that returns the default tree content to initialize the tree with iff the tree is uninitialized\n\t * (meaning it does not even have any schema set at all).\n\t * If `initialTree` returns any actual node instances, they should be recreated each time `initialTree` runs.\n\t * This is because if the config is used a second time any nodes that were not recreated could error since nodes cannot be inserted into the tree multiple times.\n\t * @param options - Additional options that can be specified when {@link ITree.schematize | schematizing } a tree.\n\t */\n\tpublic constructor(\n\t\tpublic readonly schema: TSchema,\n\t\tpublic readonly initialTree: () => InsertableTreeFieldFromImplicitField<TSchema>,\n\t\toptions?: ITreeConfigurationOptions,\n\t) {\n\t\tthis.enableSchemaValidation =\n\t\t\toptions?.enableSchemaValidation ??\n\t\t\tdefaultTreeConfigurationOptions.enableSchemaValidation;\n\t}\n}\n\n/**\n * An editable view of a (version control style) branch of a shared tree based on some schema.\n *\n * This schema--known as the view schema--may or may not align the stored schema of the document.\n * Information about discrepancies between the two schemas is available via {@link TreeView.compatibility | compatibility}.\n *\n * Application authors are encouraged to read [schema-evolution.md](../../docs/user-facing/schema-evolution.md) and\n * choose a schema compatibility policy that aligns with their application's needs.\n *\n * @privateRemarks\n * From an API design perspective, `upgradeSchema` could be merged into `viewWith` and/or `viewWith` could return errors explicitly on incompatible documents.\n * Such approaches would make it discoverable that out of schema handling may need to be done.\n * Doing that would however complicate trivial \"hello world\" style example slightly, as well as be a breaking API change.\n * It also seems more complex to handle invalidation with that pattern.\n * Thus this design was chosen at the risk of apps blindly accessing `root` then breaking unexpectedly when the document is incompatible.\n * @sealed @public\n */\nexport interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {\n\t/**\n\t * The current root of the tree.\n\t *\n\t * If the view schema not sufficiently compatible with the stored schema, accessing this will throw.\n\t * To handle this case, check {@link TreeView.compatibility | compatibility}'s {@link SchemaCompatibilityStatus.canView | canView} before using.\n\t *\n\t * To get notified about changes to this field,\n\t * use {@link TreeViewEvents.rootChanged} via `view.events.on(\"rootChanged\", callback)`.\n\t *\n\t * To get notified about changes to stored schema (which may affect compatibility between this view's schema and\n\t * the stored schema), use {@link TreeViewEvents.schemaChanged} via `view.events.on(\"schemaChanged\", callback)`.\n\t */\n\tget root(): TreeFieldFromImplicitField<TSchema>;\n\n\tset root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);\n\n\t/**\n\t * Description of the current compatibility status between the view schema and stored schema.\n\t *\n\t * {@link TreeViewEvents.schemaChanged} is fired when the compatibility status changes.\n\t */\n\treadonly compatibility: SchemaCompatibilityStatus;\n\n\t/**\n\t * When the schemas are not an exact match and {@link SchemaCompatibilityStatus.canUpgrade} is true,\n\t * this can be used to modify the stored schema to make it match the view schema.\n\t * This will update the compatibility state, and allow access to `root`.\n\t * Beware that this may impact other clients' ability to view the document depending on the application's schema compatibility policy!\n\t * @remarks\n\t * It is an error to call this when {@link SchemaCompatibilityStatus.canUpgrade} is false, and a no-op when the stored and view schema are already an exact match.\n\t * @privateRemarks\n\t * In the future, more upgrade options could be provided here.\n\t * Some options that could be added:\n\t * - check the actual document contents (not just the schema) and attempt an atomic document update if the data is compatible.\n\t * - apply converters and upgrade the document.\n\t * - apply converters to lazily to adapt the document to the requested view schema (with optional lazy schema updates or transparent conversions on write).\n\t */\n\tupgradeSchema(): void;\n\n\t/**\n\t * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.\n\t *\n\t * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.\n\t *\n\t * Applications should typically call this function before attaching a `SharedTree`.\n\t * @param content - The content to initialize the tree with.\n\t */\n\tinitialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;\n\n\t/**\n\t * Events for the tree.\n\t */\n\treadonly events: Listenable<TreeViewEvents>;\n}\n\n/**\n * Information about a view schema's compatibility with the document's stored schema.\n *\n * See SharedTree's README for more information about choosing a compatibility policy.\n * @sealed @public\n */\nexport interface SchemaCompatibilityStatus {\n\t/**\n\t * Whether the view schema allows exactly the same set of documents as the stored schema.\n\t *\n\t * @remarks\n\t * Equivalence here is defined in terms of allowed documents because there are some degenerate cases where schemas are not\n\t * exact matches in a strict (schema-based) sense but still allow the same documents, and the document notion is more useful to applications.\n\t *\n\t * Examples which are expressible where this may occur include:\n\t * - schema repository `A` has extra schema which schema `B` doesn't have, but they are unused (i.e. not reachable from the root schema)\n\t * - field in schema `A` has allowed field members which the corresponding field in schema `B` does not have, but those types are not constructible (ex: an object node type containing a required field with no allowed types)\n\t *\n\t * These cases are typically not interesting to applications.\n\t */\n\treadonly isEquivalent: boolean;\n\n\t/**\n\t * Whether the current view schema is sufficiently compatible with the stored schema to allow viewing tree data.\n\t * If false, {@link TreeView.root} will throw upon access.\n\t *\n\t * Currently, this field is true iff `isEquivalent` is true.\n\t * Do not rely on this:\n\t * there are near-term plans to extend support for viewing documents when the stored schema contains additional optional fields not present in the view schema.\n\t * The other two types of backward-compatible changes (field relaxations and addition of allowed field types) will eventually be supported as well,\n\t * likely through out-of-schema content adapters that the application can provide alongside their view schema.\n\t *\n\t * Be aware that even with these SharedTree limitations fixed, application logic may not correctly tolerate the documents allowable by the stored schema!\n\t * Application authors are encouraged to read docs/user-facing/schema-evolution.md and choose a schema compatibility policy that\n\t * aligns with their application's needs.\n\t *\n\t * @remarks\n\t * When the documents allowed by the view schema is a strict superset of those by the stored schema,\n\t * this is false because writes to the document using the view schema could make the document violate its stored schema.\n\t * In this case, the stored schema could be updated to match the provided view schema, allowing read-write access to the tree.\n\t * See {@link SchemaCompatibilityStatus.canUpgrade}.\n\t *\n\t * Future version of SharedTree may provide readonly access to the document in this case because that would be safe,\n\t * but this is not currently supported.\n\t *\n\t * @privateRemarks\n\t * A necessary condition for this to be true is that the documents allowed by the view schema are a subset of those allowed by the stored schema.\n\t * This is not sufficient: the simple-tree layer's read APIs do not tolerate out-of-schema data.\n\t * For example, if the view schema for a node has a required `Point` field but the stored schema has an optional `Point` field,\n\t * read APIs on the view schema do not work correctly when the document has a node with a missing `Point` field.\n\t * Similar issues happen when the view schema has a field with less allowed types than the stored schema and the document actually leverages those types.\n\t */\n\treadonly canView: boolean;\n\n\t/**\n\t * True iff the view schema supports all possible documents permitted by the stored schema.\n\t * When true, it is valid to call {@link TreeView.upgradeSchema} (though if the stored schema is already an exact match, this is a no-op).\n\t */\n\treadonly canUpgrade: boolean;\n\n\t/**\n\t * True iff the document is uninitialized (i.e. it has no schema and no content).\n\t *\n\t * To initialize the document, call {@link TreeView.initialize}.\n\t *\n\t * @remarks\n\t * It's not necessary to check this field before calling {@link TreeView.initialize} in most scenarios; application authors typically know from\n\t * context that they're in a flow which creates a new `SharedTree` and would like to initialize it.\n\t */\n\treadonly canInitialize: boolean;\n\n\t// TODO: Consider extending this status to include:\n\t// - application-defined metadata about the stored schema\n\t// - details about the differences between the stored and view schema sufficient for implementing \"safe mismatch\" policies\n}\n\n/**\n * Events for {@link TreeView}.\n * @sealed @public\n */\nexport interface TreeViewEvents {\n\t/**\n\t * Raised whenever {@link TreeView.root} is invalidated.\n\t *\n\t * This includes changes to the document schema.\n\t * It also includes changes to the field containing the root such as setting or clearing an optional root or changing which node is the root.\n\t * This does NOT include changes to the content (fields/children) of the root node: for that case subscribe to events on the root node.\n\t */\n\trootChanged(): void;\n\n\t/**\n\t * The stored schema for the document has changed.\n\t * This may affect the compatibility between the view schema and the stored schema, and thus the ability to use the view.\n\t *\n\t * @remarks\n\t * This event implies that the old {@link TreeView.root} is no longer valid, but applications need not handle that separately:\n\t * {@link TreeViewEvents.rootChanged} will be fired after this event.\n\t */\n\tschemaChanged(): void;\n\n\t/**\n\t * Fired when:\n\t * - a local commit is applied outside of a transaction\n\t * - a local transaction is committed\n\t *\n\t * The event is not fired when:\n\t * - a local commit is applied within a transaction\n\t * - a remote commit is applied\n\t *\n\t * @param data - information about the commit that was applied\n\t * @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,\n\t * this commit is not revertible.\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n"]}
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/simple-tree/tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4EH,MAAM,+BAA+B,GAAwC;IAC5E,sBAAsB,EAAE,KAAK;CAC7B,CAAC;AA2BF;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAajC;;OAEG;IACH,YAAmB,KAAsC;QACxD,MAAM,MAAM,GAAG,EAAE,GAAG,+BAA+B,EAAE,GAAG,KAAK,EAAE,CAAC;QAChE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC,sBAAsB,CAAC;IAC7D,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidLoadable, IDisposable } from \"@fluidframework/core-interfaces\";\n\nimport type { CommitMetadata } from \"../core/index.js\";\nimport type { Listenable } from \"../events/index.js\";\nimport type { RevertibleFactory } from \"../shared-tree/index.js\";\n\nimport type {\n\tImplicitFieldSchema,\n\tInsertableTreeFieldFromImplicitField,\n\tTreeFieldFromImplicitField,\n} from \"./schemaTypes.js\";\n\n/**\n * Channel for a Fluid Tree DDS.\n * @remarks\n * Allows storing and collaboratively editing schema-aware hierarchial data.\n * @sealed @public\n */\nexport interface ITree extends IFluidLoadable {\n\t/**\n\t * Returns a {@link TreeView} using the provided schema.\n\t * If the stored schema is compatible with the view schema specified by `config`,\n\t * the returned {@link TreeView} will expose the root with a schema-aware API based on the provided view schema.\n\t * If the provided schema is incompatible with the stored schema, the view will instead expose a status indicating the incompatibility.\n\t *\n\t * @remarks\n\t * If the tree is uninitialized (has no schema and no content), use {@link TreeView.initialize} on the returned view to set the schema and content together.\n\t * Using `viewWith` followed by {@link TreeView.upgradeSchema} to initialize only the schema for a document is technically valid when the schema\n\t * permits trees with no content.\n\t *\n\t * Note that other clients can modify the document at any time, causing the view to change its compatibility status: see {@link TreeView.events} for how to handle invalidation in these cases.\n\t *\n\t * Only one schematized view may exist for a given ITree at a time.\n\t * If creating a second, the first must be disposed before calling `viewWith` again.\n\t *\n\t * @privateRemarks\n\t * TODO: Provide a way to make a generic view schema for any document.\n\t * TODO: Support adapters for handling out-of-schema data.\n\t *\n\t * Doing initialization here allows a small API that is hard to use incorrectly.\n\t * Other approaches tend to have easy-to-make mistakes.\n\t * For example, having a separate initialization function means apps can forget to call it, making an app that can only open existing documents,\n\t * or call it unconditionally leaving an app that can only create new documents.\n\t * It also would require the schema to be passed into separate places and could cause issues if they didn't match.\n\t * Since the initialization function couldn't return a typed tree, the type checking wouldn't help catch that.\n\t * Also, if an app manages to create a document, but the initialization fails to get persisted, an app that only calls the initialization function\n\t * on the create code-path (for example how a schematized factory might do it),\n\t * would leave the document in an unusable state which could not be repaired when it is reopened (by the same or other clients).\n\t * Additionally, once out of schema content adapters are properly supported (with lazy document updates),\n\t * this initialization could become just another out of schema content adapter and this initialization is no longer a special case.\n\t */\n\tviewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * Options when constructing a tree view.\n * @public\n */\nexport interface ITreeConfigurationOptions {\n\t/**\n\t * If `true`, the tree will validate new content against its stored schema at insertion time\n\t * and throw an error if the new content doesn't match the expected schema.\n\t *\n\t * @defaultValue `false`.\n\t *\n\t * @remarks Enabling schema validation has a performance penalty when inserting new content into the tree because\n\t * additional checks are done. Enable this option only in scenarios where you are ok with that operation being a\n\t * bit slower.\n\t */\n\tenableSchemaValidation?: boolean;\n}\n\nconst defaultTreeConfigurationOptions: Required<ITreeConfigurationOptions> = {\n\tenableSchemaValidation: false,\n};\n\n/**\n * Property-bag configuration for {@link TreeViewConfiguration} construction.\n * @public\n */\nexport interface ITreeViewConfiguration<\n\tTSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n> {\n\t/**\n\t * The schema which the application wants to view the tree with.\n\t */\n\treadonly schema: TSchema;\n\n\t/**\n\t * If `true`, the tree will validate new content against its stored schema at insertion time\n\t * and throw an error if the new content doesn't match the expected schema.\n\t *\n\t * @defaultValue `false`.\n\t *\n\t * @remarks Enabling schema validation has a performance penalty when inserting new content into the tree because\n\t * additional checks are done. Enable this option only in scenarios where you are ok with that operation being a\n\t * bit slower.\n\t */\n\treadonly enableSchemaValidation?: boolean;\n}\n\n/**\n * Configuration for {@link ITree.viewWith}.\n * @sealed @public\n */\nexport class TreeViewConfiguration<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema>\n\timplements Required<ITreeViewConfiguration<TSchema>>\n{\n\t/**\n\t * {@inheritDoc ITreeViewConfiguration.schema}\n\t */\n\tpublic readonly schema: TSchema;\n\n\t/**\n\t * {@inheritDoc ITreeViewConfiguration.enableSchemaValidation}\n\t */\n\tpublic readonly enableSchemaValidation: boolean;\n\n\t/**\n\t * @param props - Property bag of configuration options.\n\t */\n\tpublic constructor(props: ITreeViewConfiguration<TSchema>) {\n\t\tconst config = { ...defaultTreeConfigurationOptions, ...props };\n\t\tthis.schema = config.schema;\n\t\tthis.enableSchemaValidation = config.enableSchemaValidation;\n\t}\n}\n\n/**\n * An editable view of a (version control style) branch of a shared tree based on some schema.\n *\n * This schema--known as the view schema--may or may not align the stored schema of the document.\n * Information about discrepancies between the two schemas is available via {@link TreeView.compatibility | compatibility}.\n *\n * Application authors are encouraged to read [schema-evolution.md](../../docs/user-facing/schema-evolution.md) and\n * choose a schema compatibility policy that aligns with their application's needs.\n *\n * @privateRemarks\n * From an API design perspective, `upgradeSchema` could be merged into `viewWith` and/or `viewWith` could return errors explicitly on incompatible documents.\n * Such approaches would make it discoverable that out of schema handling may need to be done.\n * Doing that would however complicate trivial \"hello world\" style example slightly, as well as be a breaking API change.\n * It also seems more complex to handle invalidation with that pattern.\n * Thus this design was chosen at the risk of apps blindly accessing `root` then breaking unexpectedly when the document is incompatible.\n * @sealed @public\n */\nexport interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable {\n\t/**\n\t * The current root of the tree.\n\t *\n\t * If the view schema not sufficiently compatible with the stored schema, accessing this will throw.\n\t * To handle this case, check {@link TreeView.compatibility | compatibility}'s {@link SchemaCompatibilityStatus.canView | canView} before using.\n\t *\n\t * To get notified about changes to this field,\n\t * use {@link TreeViewEvents.rootChanged} via `view.events.on(\"rootChanged\", callback)`.\n\t *\n\t * To get notified about changes to stored schema (which may affect compatibility between this view's schema and\n\t * the stored schema), use {@link TreeViewEvents.schemaChanged} via `view.events.on(\"schemaChanged\", callback)`.\n\t */\n\tget root(): TreeFieldFromImplicitField<TSchema>;\n\n\tset root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);\n\n\t/**\n\t * Description of the current compatibility status between the view schema and stored schema.\n\t *\n\t * {@link TreeViewEvents.schemaChanged} is fired when the compatibility status changes.\n\t */\n\treadonly compatibility: SchemaCompatibilityStatus;\n\n\t/**\n\t * When the schemas are not an exact match and {@link SchemaCompatibilityStatus.canUpgrade} is true,\n\t * this can be used to modify the stored schema to make it match the view schema.\n\t * This will update the compatibility state, and allow access to `root`.\n\t * Beware that this may impact other clients' ability to view the document depending on the application's schema compatibility policy!\n\t * @remarks\n\t * It is an error to call this when {@link SchemaCompatibilityStatus.canUpgrade} is false, and a no-op when the stored and view schema are already an exact match.\n\t * @privateRemarks\n\t * In the future, more upgrade options could be provided here.\n\t * Some options that could be added:\n\t * - check the actual document contents (not just the schema) and attempt an atomic document update if the data is compatible.\n\t * - apply converters and upgrade the document.\n\t * - apply converters to lazily to adapt the document to the requested view schema (with optional lazy schema updates or transparent conversions on write).\n\t */\n\tupgradeSchema(): void;\n\n\t/**\n\t * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.\n\t *\n\t * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.\n\t *\n\t * Applications should typically call this function before attaching a `SharedTree`.\n\t * @param content - The content to initialize the tree with.\n\t */\n\tinitialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;\n\n\t/**\n\t * Events for the tree.\n\t */\n\treadonly events: Listenable<TreeViewEvents>;\n}\n\n/**\n * Information about a view schema's compatibility with the document's stored schema.\n *\n * See SharedTree's README for more information about choosing a compatibility policy.\n * @sealed @public\n */\nexport interface SchemaCompatibilityStatus {\n\t/**\n\t * Whether the view schema allows exactly the same set of documents as the stored schema.\n\t *\n\t * @remarks\n\t * Equivalence here is defined in terms of allowed documents because there are some degenerate cases where schemas are not\n\t * exact matches in a strict (schema-based) sense but still allow the same documents, and the document notion is more useful to applications.\n\t *\n\t * Examples which are expressible where this may occur include:\n\t * - schema repository `A` has extra schema which schema `B` doesn't have, but they are unused (i.e. not reachable from the root schema)\n\t * - field in schema `A` has allowed field members which the corresponding field in schema `B` does not have, but those types are not constructible (ex: an object node type containing a required field with no allowed types)\n\t *\n\t * These cases are typically not interesting to applications.\n\t */\n\treadonly isEquivalent: boolean;\n\n\t/**\n\t * Whether the current view schema is sufficiently compatible with the stored schema to allow viewing tree data.\n\t * If false, {@link TreeView.root} will throw upon access.\n\t *\n\t * Currently, this field is true iff `isEquivalent` is true.\n\t * Do not rely on this:\n\t * there are near-term plans to extend support for viewing documents when the stored schema contains additional optional fields not present in the view schema.\n\t * The other two types of backward-compatible changes (field relaxations and addition of allowed field types) will eventually be supported as well,\n\t * likely through out-of-schema content adapters that the application can provide alongside their view schema.\n\t *\n\t * Be aware that even with these SharedTree limitations fixed, application logic may not correctly tolerate the documents allowable by the stored schema!\n\t * Application authors are encouraged to read docs/user-facing/schema-evolution.md and choose a schema compatibility policy that\n\t * aligns with their application's needs.\n\t *\n\t * @remarks\n\t * When the documents allowed by the view schema is a strict superset of those by the stored schema,\n\t * this is false because writes to the document using the view schema could make the document violate its stored schema.\n\t * In this case, the stored schema could be updated to match the provided view schema, allowing read-write access to the tree.\n\t * See {@link SchemaCompatibilityStatus.canUpgrade}.\n\t *\n\t * Future version of SharedTree may provide readonly access to the document in this case because that would be safe,\n\t * but this is not currently supported.\n\t *\n\t * @privateRemarks\n\t * A necessary condition for this to be true is that the documents allowed by the view schema are a subset of those allowed by the stored schema.\n\t * This is not sufficient: the simple-tree layer's read APIs do not tolerate out-of-schema data.\n\t * For example, if the view schema for a node has a required `Point` field but the stored schema has an optional `Point` field,\n\t * read APIs on the view schema do not work correctly when the document has a node with a missing `Point` field.\n\t * Similar issues happen when the view schema has a field with less allowed types than the stored schema and the document actually leverages those types.\n\t */\n\treadonly canView: boolean;\n\n\t/**\n\t * True iff the view schema supports all possible documents permitted by the stored schema.\n\t * When true, it is valid to call {@link TreeView.upgradeSchema} (though if the stored schema is already an exact match, this is a no-op).\n\t */\n\treadonly canUpgrade: boolean;\n\n\t/**\n\t * True iff the document is uninitialized (i.e. it has no schema and no content).\n\t *\n\t * To initialize the document, call {@link TreeView.initialize}.\n\t *\n\t * @remarks\n\t * It's not necessary to check this field before calling {@link TreeView.initialize} in most scenarios; application authors typically know from\n\t * context that they're in a flow which creates a new `SharedTree` and would like to initialize it.\n\t */\n\treadonly canInitialize: boolean;\n\n\t// TODO: Consider extending this status to include:\n\t// - application-defined metadata about the stored schema\n\t// - details about the differences between the stored and view schema sufficient for implementing \"safe mismatch\" policies\n}\n\n/**\n * Events for {@link TreeView}.\n * @sealed @public\n */\nexport interface TreeViewEvents {\n\t/**\n\t * Raised whenever {@link TreeView.root} is invalidated.\n\t *\n\t * This includes changes to the document schema.\n\t * It also includes changes to the field containing the root such as setting or clearing an optional root or changing which node is the root.\n\t * This does NOT include changes to the content (fields/children) of the root node: for that case subscribe to events on the root node.\n\t */\n\trootChanged(): void;\n\n\t/**\n\t * The stored schema for the document has changed.\n\t * This may affect the compatibility between the view schema and the stored schema, and thus the ability to use the view.\n\t *\n\t * @remarks\n\t * This event implies that the old {@link TreeView.root} is no longer valid, but applications need not handle that separately:\n\t * {@link TreeViewEvents.rootChanged} will be fired after this event.\n\t */\n\tschemaChanged(): void;\n\n\t/**\n\t * Fired when:\n\t * - a local commit is applied outside of a transaction\n\t * - a local transaction is committed\n\t *\n\t * The event is not fired when:\n\t * - a local commit is applied within a transaction\n\t * - a remote commit is applied\n\t *\n\t * @param data - information about the commit that was applied\n\t * @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,\n\t * this commit is not revertible.\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n"]}
@@ -23,7 +23,7 @@ export declare class TreeFactory implements IChannelFactory<ITree> {
23
23
  /**
24
24
  * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees
25
25
  * of objects, arrays, and other data types.
26
- * @alpha
26
+ * @internal
27
27
  */
28
28
  export declare const SharedTree: ISharedObjectKind<ITree> & SharedObjectKind<ITree>;
29
29
  /**
@@ -36,7 +36,7 @@ TreeFactory.attributes = {
36
36
  /**
37
37
  * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees
38
38
  * of objects, arrays, and other data types.
39
- * @alpha
39
+ * @internal
40
40
  */
41
41
  export const SharedTree = configuredSharedTree({});
42
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"treeFactory.js","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AASH,OAAO,EAEN,sBAAsB,GACtB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,IAAI,cAAc,EAA0B,MAAM,wBAAwB,CAAC;AAG9F;;GAEG;AACH,MAAM,OAAO,WAAW;IAWvB,YAAoC,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;QAH9C,SAAI,GAAG,EAAW,CAAC,IAAI,CAAC;QACxB,eAAU,GAAuB,EAAW,CAAC,UAAU,CAAC;IAEP,CAAC;IAE3D,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,iBAA+C;QAE/C,MAAM,IAAI,GAAG,IAAI,cAAc,CAAC,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9E,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,MAAM,CAAC,OAA+B,EAAE,EAAU;QACxD,MAAM,IAAI,GAAG,IAAI,cAAc,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5E,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACb,CAAC;;;AA3BsB,gBAAI,GAAG,wCAAwC,AAA3C,CAA4C;AAChD,sBAAU,GAAuB;IACvD,IAAI,EAAE,EAAI,CAAC,IAAI;IACf,qBAAqB,EAAE,OAAO;IAC9B,cAAc,EAAE,UAAU;CAC1B,AAJgC,CAI/B;AAyBH;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,oBAAoB,CAAC,EAAE,CAAC,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,oBAAoB,CACnC,OAA0B;IAE1B,MAAM,iBAAkB,SAAQ,WAAW;QAC1C;YACC,KAAK,CAAC,OAAO,CAAC,CAAC;QAChB,CAAC;KACD;IACD,OAAO,sBAAsB,CAAQ,iBAAiB,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport {\n\ttype ISharedObjectKind,\n\tcreateSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\nimport { SharedTree as SharedTreeImpl, type SharedTreeOptions } from \"./shared-tree/index.js\";\nimport type { ITree } from \"./simple-tree/index.js\";\n\n/**\n * A channel factory that creates an {@link ITree}.\n */\nexport class TreeFactory implements IChannelFactory<ITree> {\n\tpublic static readonly Type = \"https://graph.microsoft.com/types/tree\";\n\tpublic static readonly attributes: IChannelAttributes = {\n\t\ttype: this.Type,\n\t\tsnapshotFormatVersion: \"0.0.0\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic readonly type = TreeFactory.Type;\n\tpublic readonly attributes: IChannelAttributes = TreeFactory.attributes;\n\n\tpublic constructor(private readonly options: SharedTreeOptions) {}\n\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tchannelAttributes: Readonly<IChannelAttributes>,\n\t): Promise<SharedTreeImpl> {\n\t\tconst tree = new SharedTreeImpl(id, runtime, channelAttributes, this.options);\n\t\tawait tree.load(services);\n\t\treturn tree;\n\t}\n\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): SharedTreeImpl {\n\t\tconst tree = new SharedTreeImpl(id, runtime, this.attributes, this.options);\n\t\ttree.initializeLocal();\n\t\treturn tree;\n\t}\n}\n\n/**\n * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees\n * of objects, arrays, and other data types.\n * @alpha\n */\nexport const SharedTree = configuredSharedTree({});\n\n/**\n * {@link SharedTree} but allowing a non-default configuration.\n * @remarks\n * This is useful for debugging and testing to opt into extra validation or see if opting out of some optimizations fixes an issue.\n * @example\n * ```typescript\n * import {\n * \tForestType,\n * \tTreeCompressionStrategy,\n * \tconfiguredSharedTree,\n * \ttypeboxValidator,\n * \t// eslint-disable-next-line import/no-internal-modules\n * } from \"@fluidframework/tree/internal\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestType.Reference,\n * \tjsonValidator: typeboxValidator,\n * \ttreeEncodeType: TreeCompressionStrategy.Uncompressed,\n * });\n * ```\n * @privateRemarks\n * TODO:\n * Expose Ajv validator for better error message quality somehow.\n * Maybe as part of a test utils or dev-tool package?\n * @internal\n */\nexport function configuredSharedTree(\n\toptions: SharedTreeOptions,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tclass ConfiguredFactory extends TreeFactory {\n\t\tpublic constructor() {\n\t\t\tsuper(options);\n\t\t}\n\t}\n\treturn createSharedObjectKind<ITree>(ConfiguredFactory);\n}\n"]}
1
+ {"version":3,"file":"treeFactory.js","sourceRoot":"","sources":["../src/treeFactory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CACnC,OAA0B;IAE1B,MAAM,iBAAkB,SAAQ,WAAW;QAC1C;YACC,KAAK,CAAC,OAAO,CAAC,CAAC;QAChB,CAAC;KACD;IACD,OAAO,sBAAsB,CAAQ,iBAAiB,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport {\n\ttype ISharedObjectKind,\n\tcreateSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\nimport { SharedTree as SharedTreeImpl, type SharedTreeOptions } from \"./shared-tree/index.js\";\nimport type { ITree } from \"./simple-tree/index.js\";\n\n/**\n * A channel factory that creates an {@link ITree}.\n */\nexport class TreeFactory implements IChannelFactory<ITree> {\n\tpublic static readonly Type = \"https://graph.microsoft.com/types/tree\";\n\tpublic static readonly attributes: IChannelAttributes = {\n\t\ttype: this.Type,\n\t\tsnapshotFormatVersion: \"0.0.0\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic readonly type = TreeFactory.Type;\n\tpublic readonly attributes: IChannelAttributes = TreeFactory.attributes;\n\n\tpublic constructor(private readonly options: SharedTreeOptions) {}\n\n\tpublic async load(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tchannelAttributes: Readonly<IChannelAttributes>,\n\t): Promise<SharedTreeImpl> {\n\t\tconst tree = new SharedTreeImpl(id, runtime, channelAttributes, this.options);\n\t\tawait tree.load(services);\n\t\treturn tree;\n\t}\n\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): SharedTreeImpl {\n\t\tconst tree = new SharedTreeImpl(id, runtime, this.attributes, this.options);\n\t\ttree.initializeLocal();\n\t\treturn tree;\n\t}\n}\n\n/**\n * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees\n * of objects, arrays, and other data types.\n * @internal\n */\nexport const SharedTree = configuredSharedTree({});\n\n/**\n * {@link SharedTree} but allowing a non-default configuration.\n * @remarks\n * This is useful for debugging and testing to opt into extra validation or see if opting out of some optimizations fixes an issue.\n * @example\n * ```typescript\n * import {\n * \tForestType,\n * \tTreeCompressionStrategy,\n * \tconfiguredSharedTree,\n * \ttypeboxValidator,\n * \t// eslint-disable-next-line import/no-internal-modules\n * } from \"@fluidframework/tree/internal\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestType.Reference,\n * \tjsonValidator: typeboxValidator,\n * \ttreeEncodeType: TreeCompressionStrategy.Uncompressed,\n * });\n * ```\n * @privateRemarks\n * TODO:\n * Expose Ajv validator for better error message quality somehow.\n * Maybe as part of a test utils or dev-tool package?\n * @internal\n */\nexport function configuredSharedTree(\n\toptions: SharedTreeOptions,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tclass ConfiguredFactory extends TreeFactory {\n\t\tpublic constructor() {\n\t\t\tsuper(options);\n\t\t}\n\t}\n\treturn createSharedObjectKind<ITree>(ConfiguredFactory);\n}\n"]}
@@ -2,9 +2,14 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import type { Brand } from "./brand.js";
6
+ import type { Opaque } from "./opaque.js";
5
7
  import type { Invariant } from "./typeCheck.js";
6
8
  /**
7
9
  * Key in a {@link BrandedMapSubset}.
10
+ * @remarks
11
+ * Due to the `TContent` type parameter being invariant (which it has to be since keys are used to both read and write data),
12
+ * generic collections end up needing to constrain their key's `TContent` to `any`.
8
13
  * @internal
9
14
  */
10
15
  export type BrandedKey<TKey, TContent> = TKey & Invariant<TContent>;
@@ -36,11 +41,13 @@ export interface BrandedMapSubset<K extends BrandedKey<unknown, any>> {
36
41
  }
37
42
  /**
38
43
  * Version of {@link getOrCreate} with better typing for {@link BrandedMapSubset}.
44
+ * @privateRemarks
45
+ * Only infers type from key to avoid inferring `any` from map's key.
39
46
  */
40
- export declare function getOrCreateSlotContent<M extends BrandedMapSubset<BrandedKey<unknown, any>>, K extends BrandedKey<unknown, any>>(map: M, key: K, defaultValue: (key: K) => BrandedKeyContent<K>): BrandedKeyContent<K>;
47
+ export declare function getOrCreateSlotContent<K, V>(map: NoInfer<BrandedMapSubset<BrandedKey<K, V>>>, key: BrandedKey<K, V>, defaultValue: NoInfer<(key: BrandedKey<K, V>) => V>): V;
41
48
  /**
42
49
  * Define a strongly typed slot in which data can be stored in a {@link BrandedMapSubset}.
43
50
  * @internal
44
51
  */
45
- export declare function brandedSlot<TSlot extends BrandedKey<any, any>>(): TSlot;
52
+ export declare function brandedSlot<TSlot extends BrandedKey<number | Opaque<Brand<number, string>>, any>>(): TSlot;
46
53
  //# sourceMappingURL=brandedMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"brandedMap.d.ts","sourceRoot":"","sources":["../../src/util/brandedMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,IAAI,EAAE,QAAQ,IAAI,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEpE;;GAEG;AAEH,MAAM,MAAM,iBAAiB,CAAC,IAAI,SAAS,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,IAAI,SAAS,UAAU,CAC7F,OAAO,EACP,MAAM,QAAQ,CACd,GACE,QAAQ,GACR,KAAK,CAAC;AAET;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC;IACnE,GAAG,CAAC,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,iBAAiB,CAA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CACd,GACE,QAAQ,GACR,KAAK,CAAC;AAET;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC;IACnE,GAAG,CAAC,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,iBAAiB,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;IAC9D,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,iBAAiB,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IAC/D,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,CAAC,EAC1C,GAAG,EAAE,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAChD,GAAG,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EACrB,YAAY,EAAE,OAAO,CAAC,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GACjD,CAAC,CAEH;AASD;;;GAGG;AACH,wBAAgB,WAAW,CAG1B,KAAK,SAAS,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,KACjE,KAAK,CAET"}
@@ -5,11 +5,11 @@
5
5
  import { getOrCreate } from "./utils.js";
6
6
  /**
7
7
  * Version of {@link getOrCreate} with better typing for {@link BrandedMapSubset}.
8
+ * @privateRemarks
9
+ * Only infers type from key to avoid inferring `any` from map's key.
8
10
  */
9
11
  export function getOrCreateSlotContent(map, key, defaultValue) {
10
- const result = getOrCreate(map, key, defaultValue);
11
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
12
- return result;
12
+ return getOrCreate(map, key, defaultValue);
13
13
  }
14
14
  /**
15
15
  * A counter used to allocate unique numbers (See {@link brandedSlot}) to use as {@link BrandedKey}s.
@@ -21,7 +21,6 @@ let slotCounter = 0;
21
21
  * Define a strongly typed slot in which data can be stored in a {@link BrandedMapSubset}.
22
22
  * @internal
23
23
  */
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
24
  export function brandedSlot() {
26
25
  return slotCounter++;
27
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"brandedMap.js","sourceRoot":"","sources":["../../src/util/brandedMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA2CzC;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAKpC,GAAM,EAAE,GAAM,EAAE,YAA8C;IAC/D,MAAM,MAAM,GAAyB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IACzE,+DAA+D;IAC/D,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB;;;GAGG;AACH,8DAA8D;AAC9D,MAAM,UAAU,WAAW;IAC1B,OAAO,WAAW,EAAW,CAAC;AAC/B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Invariant } from \"./typeCheck.js\";\nimport { getOrCreate } from \"./utils.js\";\n\n/**\n * Key in a {@link BrandedMapSubset}.\n * @internal\n */\nexport type BrandedKey<TKey, TContent> = TKey & Invariant<TContent>;\n\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type BrandedKeyContent<TKey extends BrandedKey<unknown, any>> = TKey extends BrandedKey<\n\tunknown,\n\tinfer TContent\n>\n\t? TContent\n\t: never;\n\n/**\n * A Map where the keys carry the types of values which they correspond to.\n *\n * Example usage:\n * ```typescript\n * type FooSlot<TContent> = BrandedKey<Opaque<Brand<number, \"FooSlot\">>, TContent>;\n * const counterSlot = brandedSlot<FooSlot<number>>();\n * const slots: BrandedMapSubset<FooSlot<any>> = new Map();\n * slots.set(counterSlot, slots.get(counterSlot) ?? 0 + 1);\n * ```\n *\n * @remarks\n * These APIs are designed so that a Map can be used to implement this type.\n *\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface BrandedMapSubset<K extends BrandedKey<unknown, any>> {\n\tget<K2 extends K>(key: K2): BrandedKeyContent<K2> | undefined;\n\thas(key: K): boolean;\n\tset<K2 extends K>(key: K2, value: BrandedKeyContent<K2>): this;\n\tdelete(key: K): boolean;\n}\n\n/**\n * Version of {@link getOrCreate} with better typing for {@link BrandedMapSubset}.\n */\nexport function getOrCreateSlotContent<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tM extends BrandedMapSubset<BrandedKey<unknown, any>>,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tK extends BrandedKey<unknown, any>,\n>(map: M, key: K, defaultValue: (key: K) => BrandedKeyContent<K>): BrandedKeyContent<K> {\n\tconst result: BrandedKeyContent<K> = getOrCreate(map, key, defaultValue);\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn result;\n}\n\n/**\n * A counter used to allocate unique numbers (See {@link brandedSlot}) to use as {@link BrandedKey}s.\n * This allows the keys to be small integers, which are efficient to use as keys in maps.\n * See {@link BrandedMapSubset}.\n */\nlet slotCounter = 0;\n\n/**\n * Define a strongly typed slot in which data can be stored in a {@link BrandedMapSubset}.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function brandedSlot<TSlot extends BrandedKey<any, any>>(): TSlot {\n\treturn slotCounter++ as TSlot;\n}\n"]}
1
+ {"version":3,"file":"brandedMap.js","sourceRoot":"","sources":["../../src/util/brandedMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA8CzC;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACrC,GAAgD,EAChD,GAAqB,EACrB,YAAmD;IAEnD,OAAO,WAAW,CAAsB,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACH,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB;;;GAGG;AACH,MAAM,UAAU,WAAW;IAK1B,OAAO,WAAW,EAAW,CAAC;AAC/B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Brand } from \"./brand.js\";\nimport type { Opaque } from \"./opaque.js\";\nimport type { Invariant } from \"./typeCheck.js\";\nimport { getOrCreate } from \"./utils.js\";\n\n/**\n * Key in a {@link BrandedMapSubset}.\n * @remarks\n * Due to the `TContent` type parameter being invariant (which it has to be since keys are used to both read and write data),\n * generic collections end up needing to constrain their key's `TContent` to `any`.\n * @internal\n */\nexport type BrandedKey<TKey, TContent> = TKey & Invariant<TContent>;\n\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type BrandedKeyContent<TKey extends BrandedKey<unknown, any>> = TKey extends BrandedKey<\n\tunknown,\n\tinfer TContent\n>\n\t? TContent\n\t: never;\n\n/**\n * A Map where the keys carry the types of values which they correspond to.\n *\n * Example usage:\n * ```typescript\n * type FooSlot<TContent> = BrandedKey<Opaque<Brand<number, \"FooSlot\">>, TContent>;\n * const counterSlot = brandedSlot<FooSlot<number>>();\n * const slots: BrandedMapSubset<FooSlot<any>> = new Map();\n * slots.set(counterSlot, slots.get(counterSlot) ?? 0 + 1);\n * ```\n *\n * @remarks\n * These APIs are designed so that a Map can be used to implement this type.\n *\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface BrandedMapSubset<K extends BrandedKey<unknown, any>> {\n\tget<K2 extends K>(key: K2): BrandedKeyContent<K2> | undefined;\n\thas(key: K): boolean;\n\tset<K2 extends K>(key: K2, value: BrandedKeyContent<K2>): this;\n\tdelete(key: K): boolean;\n}\n\n/**\n * Version of {@link getOrCreate} with better typing for {@link BrandedMapSubset}.\n * @privateRemarks\n * Only infers type from key to avoid inferring `any` from map's key.\n */\nexport function getOrCreateSlotContent<K, V>(\n\tmap: NoInfer<BrandedMapSubset<BrandedKey<K, V>>>,\n\tkey: BrandedKey<K, V>,\n\tdefaultValue: NoInfer<(key: BrandedKey<K, V>) => V>,\n): V {\n\treturn getOrCreate<BrandedKey<K, V>, V>(map, key, defaultValue);\n}\n\n/**\n * A counter used to allocate unique numbers (See {@link brandedSlot}) to use as {@link BrandedKey}s.\n * This allows the keys to be small integers, which are efficient to use as keys in maps.\n * See {@link BrandedMapSubset}.\n */\nlet slotCounter = 0;\n\n/**\n * Define a strongly typed slot in which data can be stored in a {@link BrandedMapSubset}.\n * @internal\n */\nexport function brandedSlot<\n\t// See note on BrandedKey.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlot extends BrandedKey<number | Opaque<Brand<number, string>>, any>,\n>(): TSlot {\n\treturn slotCounter++ as TSlot;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/tree",
3
- "version": "2.0.2",
3
+ "version": "2.1.0-276326",
4
4
  "description": "Distributed tree",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -67,17 +67,17 @@
67
67
  "temp-directory": "nyc/.nyc_output"
68
68
  },
69
69
  "dependencies": {
70
- "@fluid-internal/client-utils": "~2.0.2",
71
- "@fluidframework/container-runtime": "~2.0.2",
72
- "@fluidframework/core-interfaces": "~2.0.2",
73
- "@fluidframework/core-utils": "~2.0.2",
74
- "@fluidframework/datastore-definitions": "~2.0.2",
75
- "@fluidframework/driver-definitions": "~2.0.2",
76
- "@fluidframework/id-compressor": "~2.0.2",
77
- "@fluidframework/runtime-definitions": "~2.0.2",
78
- "@fluidframework/runtime-utils": "~2.0.2",
79
- "@fluidframework/shared-object-base": "~2.0.2",
80
- "@fluidframework/telemetry-utils": "~2.0.2",
70
+ "@fluid-internal/client-utils": "2.1.0-276326",
71
+ "@fluidframework/container-runtime": "2.1.0-276326",
72
+ "@fluidframework/core-interfaces": "2.1.0-276326",
73
+ "@fluidframework/core-utils": "2.1.0-276326",
74
+ "@fluidframework/datastore-definitions": "2.1.0-276326",
75
+ "@fluidframework/driver-definitions": "2.1.0-276326",
76
+ "@fluidframework/id-compressor": "2.1.0-276326",
77
+ "@fluidframework/runtime-definitions": "2.1.0-276326",
78
+ "@fluidframework/runtime-utils": "2.1.0-276326",
79
+ "@fluidframework/shared-object-base": "2.1.0-276326",
80
+ "@fluidframework/telemetry-utils": "2.1.0-276326",
81
81
  "@sinclair/typebox": "^0.32.29",
82
82
  "@tylerbu/sorted-btree-es6": "^1.8.0",
83
83
  "@ungap/structured-clone": "^1.2.0",
@@ -86,19 +86,19 @@
86
86
  "devDependencies": {
87
87
  "@arethetypeswrong/cli": "^0.15.2",
88
88
  "@biomejs/biome": "^1.7.3",
89
- "@fluid-internal/mocha-test-setup": "~2.0.2",
90
- "@fluid-private/stochastic-test-utils": "~2.0.2",
91
- "@fluid-private/test-dds-utils": "~2.0.2",
92
- "@fluid-private/test-drivers": "~2.0.2",
89
+ "@fluid-internal/mocha-test-setup": "2.1.0-276326",
90
+ "@fluid-private/stochastic-test-utils": "2.1.0-276326",
91
+ "@fluid-private/test-dds-utils": "2.1.0-276326",
92
+ "@fluid-private/test-drivers": "2.1.0-276326",
93
93
  "@fluid-tools/benchmark": "^0.48.0",
94
94
  "@fluid-tools/build-cli": "^0.39.0",
95
95
  "@fluidframework/build-common": "^2.0.3",
96
96
  "@fluidframework/build-tools": "^0.39.0",
97
- "@fluidframework/container-definitions": "~2.0.2",
98
- "@fluidframework/container-loader": "~2.0.2",
97
+ "@fluidframework/container-definitions": "2.1.0-276326",
98
+ "@fluidframework/container-loader": "2.1.0-276326",
99
99
  "@fluidframework/eslint-config-fluid": "^5.3.0",
100
- "@fluidframework/test-runtime-utils": "~2.0.2",
101
- "@fluidframework/test-utils": "~2.0.2",
100
+ "@fluidframework/test-runtime-utils": "2.1.0-276326",
101
+ "@fluidframework/test-utils": "2.1.0-276326",
102
102
  "@microsoft/api-extractor": "^7.45.1",
103
103
  "@types/diff": "^3.5.1",
104
104
  "@types/easy-table": "^0.0.32",
@@ -146,8 +146,8 @@
146
146
  },
147
147
  "scripts": {
148
148
  "api": "fluid-build . --task api",
149
- "api-extractor:commonjs": "flub generate entrypoints --outFileAlpha legacy --outDir ./dist",
150
- "api-extractor:esnext": "flub generate entrypoints --outFileAlpha legacy --outDir ./lib --node10TypeCompat",
149
+ "api-extractor:commonjs": "flub generate entrypoints --outDir ./dist",
150
+ "api-extractor:esnext": "flub generate entrypoints --outDir ./lib --node10TypeCompat",
151
151
  "bench": "mocha --timeout 999999 --perfMode --parentProcess --fgrep @Benchmark --reporter @fluid-tools/benchmark/dist/MochaReporter.js",
152
152
  "bench:profile": "mocha --v8-prof --v8-logfile=profile.log --v8-no-logfile-per-isolate --timeout 999999 --perfMode --fgrep @Benchmark --reporter @fluid-tools/benchmark/dist/MochaReporter.js && node --prof-process profile.log > profile.txt && rimraf profile.log && echo See results in profile.txt",
153
153
  "build": "fluid-build . --task build",
@@ -190,7 +190,7 @@
190
190
  "test:snapshots:regen": "pnpm test:mocha:esm --snapshot",
191
191
  "test:stress": "cross-env FUZZ_TEST_COUNT=20 FUZZ_STRESS_RUN=true mocha --ignore \"lib/test/memory/**/*\" --recursive \"lib/test/**/*.spec.js\"",
192
192
  "tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
193
- "typetests:gen": "flub generate typetests --dir . -v --publicFallback",
193
+ "typetests:gen": "flub generate typetests --dir . -v",
194
194
  "typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
195
195
  }
196
196
  }
@@ -220,7 +220,7 @@ export interface AnchorNode extends UpPath<AnchorNode>, Listenable<AnchorEvents>
220
220
  * Allows access to data stored on the Anchor in "slots".
221
221
  * Use {@link anchorSlot} to create slots.
222
222
  */
223
- // TODO: use something other than `any`
223
+ // See note on BrandedKey
224
224
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
225
225
  readonly slots: BrandedMapSubset<AnchorSlot<any>>;
226
226
 
@@ -328,7 +328,7 @@ export class AnchorSet implements Listenable<AnchorSetRootEvents>, AnchorLocator
328
328
  * @privateRemarks
329
329
  * This forwards to the slots of the special above root anchor which locate can't access.
330
330
  */
331
- // TODO: use something other than `any`
331
+ // See note on BrandedKey.
332
332
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
333
333
  public get slots(): BrandedMapSubset<AnchorSlot<any>> {
334
334
  return this.root.slots;
@@ -1142,7 +1142,7 @@ class PathNode extends ReferenceCountedBase implements UpPath<PathNode>, AnchorN
1142
1142
  */
1143
1143
  public readonly children: Map<FieldKey, PathNode[]> = new Map();
1144
1144
 
1145
- // TODO: use something other than `any`
1145
+ // See note on BrandedKey.
1146
1146
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1147
1147
  public readonly slots: BrandedMapSubset<AnchorSlot<any>> = new Map();
1148
1148
 
@@ -957,7 +957,11 @@ export interface FlexTreeSequenceField<in out TTypes extends FlexAllowedTypes>
957
957
  index: number,
958
958
  sourceStart: number,
959
959
  sourceEnd: number,
960
- source: FlexTreeSequenceField<FlexAllowedTypes>,
960
+ // FlexTreeSequenceField is invariant over its schema so any is required here.
961
+ // This use of any can be removed by migrating off this deprecated API and deleting it.
962
+ // If kept, this function should be fixed by making it generic and constraining it to fields which are safe to move content from.
963
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
964
+ source: FlexTreeSequenceField<any>,
961
965
  ): void;
962
966
 
963
967
  // #endregion
@@ -140,7 +140,10 @@ export function makeField(
140
140
  * A Proxy target, which together with a `fieldProxyHandler` implements a basic access to
141
141
  * the nodes of {@link EditableField} by means of the cursors.
142
142
  */
143
- export abstract class LazyField<TKind extends FlexFieldKind, TTypes extends FlexAllowedTypes>
143
+ export abstract class LazyField<
144
+ out TKind extends FlexFieldKind,
145
+ TTypes extends FlexAllowedTypes,
146
+ >
144
147
  extends LazyEntity<FlexFieldSchema<TKind, TTypes>, FieldAnchor>
145
148
  implements FlexTreeField
146
149
  {
@@ -599,14 +602,14 @@ export class LazyForbiddenField<TTypes extends FlexAllowedTypes> extends LazyFie
599
602
 
600
603
  type Builder = new <TTypes extends FlexAllowedTypes>(
601
604
  context: Context,
602
- // TODO: use something other than `any`
605
+ // Correct use of these builders requires the builder of the matching type to be used.
606
+ // Since this has to be done at runtime anyway, trying to use safer typing than `any` here (such as `never`, which is only slightly safer)
607
+ // does not seem worth it (ends up requiring type casts that are just as unsafe).
603
608
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
604
609
  schema: FlexFieldSchema<any, TTypes>,
605
610
  cursor: ITreeSubscriptionCursor,
606
611
  fieldAnchor: FieldAnchor,
607
- // TODO: use something other than `any`
608
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
609
- ) => LazyField<any, TTypes>;
612
+ ) => LazyField<FlexFieldKind, TTypes>;
610
613
 
611
614
  const builderList: [FlexFieldKind, Builder][] = [
612
615
  [FieldKinds.forbidden, LazyForbiddenField],
@@ -429,6 +429,7 @@ function makeModularChangeCodec(
429
429
  changes: encodeFieldChangesForJson(change.fieldChanges, context, change.nodeChanges),
430
430
  builds: encodeDetachedNodes(change.builds, context),
431
431
  refreshers: encodeDetachedNodes(change.refreshers, context),
432
+ violations: change.constraintViolationCount,
432
433
  };
433
434
  },
434
435
 
@@ -450,6 +451,10 @@ function makeModularChangeCodec(
450
451
  decoded.refreshers = decodeDetachedNodes(encodedChange.builds, context);
451
452
  }
452
453
 
454
+ if (encodedChange.violations !== undefined) {
455
+ decoded.constraintViolationCount = encodedChange.violations;
456
+ }
457
+
453
458
  const decodedRevInfos = decodeRevisionInfos(encodedChange.revisions, context);
454
459
  if (decodedRevInfos !== undefined) {
455
460
  decoded.revisions = decodedRevInfos;
@@ -132,6 +132,10 @@ export const EncodedModularChangeset = Type.Object(
132
132
  revisions: Type.ReadonlyOptional(Type.Array(EncodedRevisionInfo)),
133
133
  builds: Type.Optional(EncodedBuilds),
134
134
  refreshers: Type.Optional(EncodedBuilds),
135
+ /**
136
+ * The number of constraints within this changeset that are violated.
137
+ */
138
+ violations: Type.Optional(Type.Number({ minimum: 0, multipleOf: 1 })),
135
139
  },
136
140
  noAdditionalProps,
137
141
  );