@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
@@ -1 +1 @@
1
- {"version":3,"file":"flexTreeTypes.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/flexTreeTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAO6B;AA2B7B;;;GAGG;AACU,QAAA,YAAY,GAAG,IAAA,qBAAU,GAAgB,CAAC;AAEvD;;;GAGG;AACU,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD,SAAgB,gBAAgB,CAAC,CAAU;IAC1C,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,sBAAc,IAAI,CAAC,CAAC;AACnE,CAAC;AAFD,4CAEC;AAED,SAAgB,cAAc,CAAC,CAAU;IACxC,OAAO,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,sBAAc,CAAC,KAAK,kBAAkB,CAAC,IAAI,CAAC;AAC7E,CAAC;AAFD,wCAEC;AAED;;GAEG;AACH,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC7B,2DAAI,CAAA;IACJ,6DAAK,CAAA;AACN,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAqDD;;;GAGG;AACH,IAAY,UAoBX;AApBD,WAAY,UAAU;IACrB;;OAEG;IACH,uDAAc,CAAA;IAEd;;OAEG;IACH,iDAAW,CAAA;IAEX;;OAEG;IACH,iDAAW,CAAA;IAEX;;OAEG;IACH,yCAAO,CAAA;AACR,CAAC,EApBW,UAAU,0BAAV,UAAU,QAoBrB;AAkdD;;;GAGG;AACU,QAAA,oCAAoC,GAAG;IACnD,YAAY;IACZ,aAAa;IACb,SAAS;IACT,IAAI;IACJ,IAAI;IACJ,aAAa;IACb,QAAQ;IACR,YAAY;IACZ,aAAa;IACb,MAAM;IACN,OAAO;IACP,eAAe;IACf,UAAU;IACV,UAAU;CACD,CAAC;AAEX;;;;;;GAMG;AACU,QAAA,2CAA2C,GAAG;IAC1D,KAAK;IACL,OAAO;IACP,OAAO;IACP,OAAO;CACE,CAAC;AAygBX,aAAa","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype AnchorNode,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype ITreeCursorSynchronous,\n\ttype TreeValue,\n\tanchorSlot,\n} from \"../../core/index.js\";\nimport type { Assume, FlattenKeys } from \"../../util/index.js\";\nimport type { FieldKinds, SequenceFieldEditBuilder } from \"../default-schema/index.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport type { LocalNodeKey, StableNodeKey } from \"../node-key/index.js\";\nimport type {\n\tAllowedTypesToFlexInsertableTree,\n\tInsertableFlexField,\n} from \"../schema-aware/index.js\";\nimport type {\n\tAny,\n\tFlexAllowedTypes,\n\tFlexFieldNodeSchema,\n\tFlexFieldSchema,\n\tFlexList,\n\tFlexListToUnion,\n\tFlexMapNodeSchema,\n\tFlexObjectNodeFields,\n\tFlexObjectNodeSchema,\n\tFlexTreeNodeSchema,\n\tLazyItem,\n\tLeafNodeSchema,\n} from \"../typed-schema/index.js\";\n\nimport type { FlexTreeContext } from \"./context.js\";\nimport type { FlexTreeNodeEvents } from \"./treeEvents.js\";\n\n/**\n * An anchor slot which records the {@link FlexTreeNode} associated with that anchor, if there is one.\n * @remarks This always points to a \"real\" {@link FlexTreeNode} (i.e. a `LazyTreeNode`), never to a \"raw\" node.\n */\nexport const flexTreeSlot = anchorSlot<FlexTreeNode>();\n\n/**\n * Indicates that an object is a flex tree.\n * @internal\n */\nexport const flexTreeMarker = Symbol(\"flexTreeMarker\");\n\nexport function isFlexTreeEntity(t: unknown): t is FlexTreeEntity {\n\treturn typeof t === \"object\" && t !== null && flexTreeMarker in t;\n}\n\nexport function isFlexTreeNode(t: unknown): t is FlexTreeNode {\n\treturn isFlexTreeEntity(t) && t[flexTreeMarker] === FlexTreeEntityKind.Node;\n}\n\n/**\n * @internal\n */\nexport enum FlexTreeEntityKind {\n\tNode,\n\tField,\n}\n\n/**\n * Part of a tree.\n * Iterates over children.\n *\n * @privateRemarks\n * This exists mainly as a place to share common members between nodes and fields.\n * It is not expected to be useful or common to write code which handles this type directly.\n * If this assumption turns out to be false, and generically processing `UntypedEntity`s is useful,\n * then this interface should probably be extended with some down casting functionality (like `is`).\n *\n * TODO:\n * Design and document iterator invalidation rules and ordering rules.\n * Providing a custom iterator type with place anchor semantics would be a good approach.\n *\n * @internal\n */\nexport interface FlexTreeEntity<out TSchema = unknown> {\n\t/**\n\t * Indicates that an object is a specific kind of flex tree FlexTreeEntity.\n\t * This makes it possible to both down cast FlexTreeEntities safely as well as validate if an object is or is not a FlexTreeEntity.\n\t */\n\treadonly [flexTreeMarker]: FlexTreeEntityKind;\n\n\t/**\n\t * Schema for this entity.\n\t * If well-formed, it must follow this schema.\n\t */\n\treadonly schema: TSchema;\n\n\t/**\n\t * A common context of a \"forest\" of FlexTrees.\n\t */\n\treadonly context: FlexTreeContext;\n\n\t/**\n\t * Gets the {@link TreeStatus} of this tree.\n\t *\n\t * @remarks\n\t * For non-root fields, this is the status of the parent node, since fields do not have a separate lifetime.\n\t */\n\ttreeStatus(): TreeStatus;\n\n\t/**\n\t * Iterate through all nodes/fields in this field/node.\n\t *\n\t * @remarks\n\t * No mutations to the current view of the shared tree are permitted during iteration.\n\t */\n\tboxedIterator(): IterableIterator<FlexTreeEntity>;\n}\n\n/**\n * Status of the tree that a particular node belongs to.\n * @public\n */\nexport enum TreeStatus {\n\t/**\n\t * Is parented under the root field.\n\t */\n\tInDocument = 0,\n\n\t/**\n\t * Is not parented under the root field, but can be added back to the original document tree.\n\t */\n\tRemoved = 1,\n\n\t/**\n\t * Is removed and cannot be added back to the original document tree.\n\t */\n\tDeleted = 2,\n\n\t/**\n\t * Is created but has not yet been inserted into the tree.\n\t */\n\tNew = 3,\n}\n\n/**\n * Generic tree node API.\n *\n * Nodes are (shallowly) immutable and have a logical identity, a type and either a value or fields under string keys.\n *\n * This \"logical identity\" is exposed as the object identity: if a node is moved within a document,\n * the same {@link FlexTreeNode} instance will be used in the new location.\n * Similarly, edits applied to a node's sub-tree concurrently with the move of the node will still be applied to its subtree in its new location.\n *\n *\n * @remarks\n * Down-casting (via {@link FlexTreeNode#is}) is required to access Schema-Aware APIs, including editing.\n * All content in the tree is accessible without down-casting, but if the schema is known,\n * the schema aware API may be more ergonomic.\n * All editing is actually done via {@link FlexTreeField}s: the nodes are immutable other than that they contain mutable fields.\n *\n * @internal\n */\nexport interface FlexTreeNode extends FlexTreeEntity<FlexTreeNodeSchema> {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Node;\n\n\t/**\n\t * Value stored on this node.\n\t */\n\treadonly value?: TreeValue;\n\n\t/**\n\t * {@inheritDoc ISubscribable#on}\n\t */\n\ton<K extends keyof FlexTreeNodeEvents>(\n\t\teventName: K,\n\t\tlistener: FlexTreeNodeEvents[K],\n\t): () => void;\n\n\t/**\n\t * Gets a field of this node, if it is not empty.\n\t */\n\ttryGetField(key: FieldKey): undefined | FlexTreeField;\n\n\t/**\n\t * Get the field for `key`.\n\t * @param key - which entry to look up.\n\t *\n\t * @remarks\n\t * All fields implicitly exist, so `getBoxed` can be called with any key and will always return a field.\n\t * Even if the field is empty, it will still be returned, and can be edited to insert content if allowed by the field kind.\n\t * See {@link FlexTreeNode.tryGetField} for a variant that does not allocate afield in the empty case.\n\t */\n\tgetBoxed(key: FieldKey): FlexTreeField;\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t */\n\treadonly parentField: { readonly parent: FlexTreeField; readonly index: number };\n\n\t/**\n\t * Type guard for narrowing / down-casting to a specific schema.\n\t */\n\tis<TSchema extends FlexTreeNodeSchema>(schema: TSchema): this is FlexTreeTypedNode<TSchema>;\n\n\tboxedIterator(): IterableIterator<FlexTreeField>;\n\n\t/**\n\t * The anchor node associated with this node\n\t *\n\t * @remarks\n\t * The ref count keeping this alive is owned by the FlexTreeNode:\n\t * if holding onto this anchor for longer than the FlexTreeNode might be alive,\n\t * a separate Anchor (and thus ref count) must be allocated to keep it alive.\n\t */\n\treadonly anchorNode: AnchorNode;\n}\n\n/**\n * A collaboratively editable collection of nodes within a {@link FlexTreeEntity}.\n *\n * Fields are inherently part of their parent, and thus cannot be moved.\n * Instead their content can be moved, deleted or created.\n *\n * Editing operations are only valid on trees with the {@link TreeStatus#InDocument} `TreeStatus`.\n *\n * @remarks\n * Fields are used wherever an editable collection of nodes is required.\n * This is required in two places:\n * 1. To hold the children of non-leaf {@link FlexTreeNode}s.\n * 2. As the root of a {@link FlexTreeEntity}.\n *\n * Down-casting (via {@link FlexTreeField.is}) is required to access Schema-Aware APIs, including editing.\n * All content in the tree is accessible without down-casting, but if the schema is known,\n * the schema aware API may be more ergonomic.\n *\n * @internal\n */\nexport interface FlexTreeField extends FlexTreeEntity<FlexFieldSchema> {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Field;\n\n\t/**\n\t * The number of nodes in this field\n\t */\n\treadonly length: number;\n\n\t/**\n\t * The `FieldKey` this field is under.\n\t * Defines what part of its parent this field makes up.\n\t */\n\treadonly key: FieldKey;\n\n\t/**\n\t * The node which has this field on it under `fieldKey`.\n\t * `undefined` iff this field is a detached field.\n\t */\n\treadonly parent?: FlexTreeNode;\n\n\t/**\n\t * Type guard for narrowing / down-casting to a specific schema.\n\t */\n\tis<TSchema extends FlexFieldSchema>(schema: TSchema): this is FlexTreeTypedField<TSchema>;\n\n\tboxedIterator(): IterableIterator<FlexTreeNode>;\n\n\t/**\n\t * Check if this field is the same as a different field.\n\t * This is defined to mean that both are in the same flex tree, and are the same field on the same node.\n\t * This is more than just a reference comparison because unlike FlexTree nodes, fields are not cached on anchors and can be duplicated.\n\t *\n\t * @privateRemarks\n\t * TODO:\n\t * If practical, cache TreeField instances so use of this method can be replaced with `===` to compare object identity.\n\t * Implementing this will require some care to preserve lazy-ness and work efficiently (without leaks) for empty fields, particularly on MapNodes.\n\t */\n\tisSameAs(other: FlexTreeField): boolean;\n\n\t/**\n\t * Gets a node of this field by its index without unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= sequence.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tboxedAt(index: number): FlexTreeNode | undefined;\n}\n\n// #region Node Kinds\n\n/**\n * A {@link FlexTreeNode} that behaves like a `Map<string, Field>` for a specific `Field` type.\n *\n * @remarks\n * Unlike TypeScript Map type, {@link FlexTreeMapNode.get} always provides a reference to any field looked up, even if it has never been set.\n *\n * This means that, for example, a `MapNode` of {@link FlexTreeSequenceField} fields will return an empty sequence when a previously unused key is looked up,\n * and that sequence can be used to insert new items into the field.\n * Additionally empty fields (those containing no nodes) are not distinguished from fields which do not exist.\n * This differs from JavaScript Maps which have a subtle distinction between storing undefined as a value in the map and deleting an entry from the map.\n *\n * @internal\n */\nexport interface FlexTreeMapNode<in out TSchema extends FlexMapNodeSchema>\n\textends FlexTreeNode {\n\treadonly schema: TSchema;\n\n\t/**\n\t * The number of elements in the map.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `size` will count only the fields which contain one or more nodes.\n\t */\n\treadonly size: number;\n\n\t/**\n\t * Checks whether a value exists for the given key.\n\t * @param key - Which map entry to look up.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `has` will only return true if there are one or more nodes present in the given field.\n\t */\n\thas(key: string): boolean;\n\n\t/**\n\t * Get the value associated with `key`.\n\t * @param key - which map entry to look up.\n\t */\n\tget(key: string): FlexTreeUnboxField<TSchema[\"info\"]>;\n\n\t/**\n\t * Get the field for `key`.\n\t * @param key - which map entry to look up.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, so `get` can be called with any key and will always return a field.\n\t * Even if the field is empty, it will still be returned, and can be edited to insert content into the map.\n\t */\n\tgetBoxed(key: string): FlexTreeTypedField<TSchema[\"info\"]>;\n\n\t/**\n\t * Returns an iterable of keys in the map.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `keys` will yield only the keys of fields which contain one or more nodes.\n\t *\n\t * No guarantees are made regarding the order of the keys returned.\n\t */\n\tkeys(): IterableIterator<FieldKey>;\n\n\t/**\n\t * Returns an iterable of values in the map.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `values` will yield only the fields containing one or more nodes.\n\t *\n\t * No guarantees are made regarding the order of the values returned.\n\t */\n\tvalues(): IterableIterator<FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">>;\n\n\t/**\n\t * Returns an iterable of key, value pairs for every entry in the map.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `entries` will yield only the entries whose fields contain one or more nodes.\n\t *\n\t * This iteration provided by `entries()` is equivalent to that provided by direct iteration of the {@link FlexTreeMapNode} (a.k.a. `[Symbol.Iterator]()`).\n\t *\n\t * No guarantees are made regarding the order of the entries returned.\n\t */\n\tentries(): IterableIterator<[FieldKey, FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">]>;\n\n\t/**\n\t * Executes a provided function once per each key/value pair in the map.\n\t * @param callbackFn - The function to run for each map entry\n\t * @param thisArg - If present, `callbackFn` will be bound to `thisArg`\n\t *\n\t * @privateRemarks\n\t * TODO: This should run over fields in insertion order if we want to match the javascript foreach spec.\n\t */\n\tforEach(\n\t\tcallbackFn: (\n\t\t\tvalue: FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">,\n\t\t\tkey: FieldKey,\n\t\t\tmap: FlexTreeMapNode<TSchema>,\n\t\t) => void,\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tthisArg?: any,\n\t): void;\n\n\t/**\n\t * Adds or updates an entry in the map with a specified `key` and a `value`.\n\t *\n\t * @param key - The key of the element to add to the map.\n\t * @param value - The value of the element to add to the map.\n\t */\n\tset(key: string, value: FlexibleFieldContent<TSchema[\"info\"]>): void;\n\n\t/**\n\t * Removes the specified element from this map by its `key`.\n\t *\n\t * @remarks\n\t * Note: unlike JavaScript's Map API, this method does not return a flag indicating whether or not the value was\n\t * deleted.\n\t *\n\t * @privateRemarks\n\t * Regarding the choice to not return a boolean: Since this data structure is distributed in nature, it isn't\n\t * possible to tell whether or not the item was deleted as a result of this method call. Returning a \"best guess\"\n\t * is more likely to create issues / promote bad usage patterns than offer useful information.\n\t *\n\t * @param key - The key of the element to remove from the map.\n\t */\n\tdelete(key: string): void;\n\n\t/**\n\t * Iterate through all fields in the map.\n\t *\n\t * @remarks\n\t * No mutations to the current view of the shared tree are permitted during iteration.\n\t * To iterate over the unboxed values of the map, use `Symbol.Iterator()`.\n\t */\n\tboxedIterator(): IterableIterator<FlexTreeTypedField<TSchema[\"info\"]>>;\n\n\t[Symbol.iterator](): IterableIterator<\n\t\t[FieldKey, FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">]\n\t>;\n}\n\n/**\n * A {@link FlexTreeNode} that wraps a single {@link FlexTreeField} (which is placed under the {@link EmptyKey}).\n *\n * @remarks\n * A FieldNode is mostly identical to a struct node with a single field using the {@link EmptyKey}, but provides access to it via a field named \"content\".\n *\n * There are several use-cases where it makes sense to use a field node.\n * Here are a few:\n * - When it's necessary to differentiate between an empty sequence, and no sequence.\n * One case where this is needed is encoding Json.\n * - When polymorphism over {@link FlexFieldSchema} (and not just a union of {@link FlexAllowedTypes}) is required.\n * For example when encoding a schema for a type like\n * `Foo[] | Bar[]`, `Foo | Foo[]` or `Optional<Foo> | Optional<Bar>` (Where `Optional` is the Optional field kind, not TypeScript's `Optional`).\n * Since this schema system only allows `|` of {@link FlexTreeNodeSchema} (and only when declaring a {@link FlexFieldSchema}), see {@link SchemaBuilderBase.field},\n * these aggregate types are most simply expressed by creating fieldNodes for the terms like `Foo[]`, and `Optional<Foo>`.\n * Note that these are distinct from types like `(Foo | Bar)[]` and `Optional<Foo | Bar>` which can be expressed as single fields without extra nodes.\n * - When a distinct merge identity is desired for a field.\n * For example, if the application wants to be able to have an optional node or a sequence which it can pass around, edit and observe changes to,\n * in some cases (like when the content is moved to a different parent) this can be more flexible if a field node is introduced\n * to create a separate logical entity (node) which wraps the field.\n * This can even be useful with value fields to wrap terminal nodes if a stable merge\n * - When a field (such as a {@link FlexTreeSequenceField}) is desired in a location where {@link FlexTreeNode}s are required\n * (like the member of a union or the child of another {@link FlexTreeField}).\n * This can is typically just a different perspective on one of the above cases.\n * For example:\n * `Sequence<Foo> | Sequence<Bar>` or `OptionalField<Sequence<Foo>>` can't be expressed as simple fields\n * (unlike `Sequence<Foo | Bar>` or `OptionalField<Foo>` which can be done as simple fields).\n * Instead {@link FlexTreeFieldNode}s can be use to achieve something similar, more like:\n * `FieldNode<Sequence<Foo>> | FieldNode<Sequence<Bar>>` or `OptionalField<FieldNode<Sequence<Foo>>>`.\n *\n * @privateRemarks\n * FieldNodes do not unbox to their content, so in schema aware APIs which do unboxing, the FieldNode will NOT be skipped over.\n * This is a change from the old behavior to simplify unboxing and prevent cases where arbitrary deep chains of field nodes could unbox omitting information about the tree depth.\n * @internal\n */\nexport interface FlexTreeFieldNode<in out TSchema extends FlexFieldNodeSchema>\n\textends FlexTreeNode {\n\treadonly schema: TSchema;\n\n\t/**\n\t * The content this field node wraps.\n\t * @remarks\n\t * This is a version of {@link FlexTreeFieldNode.boxedContent} but does unboxing.\n\t * Since field node are usually used to wrap fields which don't do unboxing (like {@link FlexTreeSequenceField})\n\t */\n\treadonly content: FlexTreeUnboxField<TSchema[\"info\"]>;\n\t/**\n\t * The field this field node wraps.\n\t *\n\t * @remarks\n\t * Since field nodes are usually used to wrap fields which don't do unboxing (like {@link FlexTreeSequenceField}),\n\t * this is usually the same as {@link FlexTreeFieldNode.content}.\n\t * This is also the same as `[...this][0]`.\n\t */\n\treadonly boxedContent: FlexTreeTypedField<TSchema[\"info\"]>;\n}\n\n/**\n * A {@link FlexTreeNode} that behaves like an \"object\" or \"struct\", providing properties to access its fields.\n *\n * ObjectNodes consist of a finite collection of fields, each with their own (distinct) key and {@link FlexFieldSchema}.\n *\n * @remarks\n * ObjectNodes require complex typing, and have been split into two parts for implementation purposes.\n * See {@link FlexTreeObjectNodeTyped} for the schema aware extensions to this that provide access to the fields.\n *\n * These \"Objects\" resemble \"Structs\" from a wide variety of programming languages\n * (Including Algol 68, C, Go, Rust, C# etc.).\n * ObjectNodes also somewhat resemble JavaScript objects: this analogy is less precise (objects don't have a fixed schema for example),\n * but for consistency with other systems in the JavaScript ecosystem (like JSON) is \"ObjectNodes\" nodes are named \"Objects\".\n *\n * Another common name for this abstraction is [record](https://en.wikipedia.org/wiki/Record_(computer_science)).\n * The name \"Record\" is avoided (in favor of Object) here because it has less precise connotations for most TypeScript developers.\n * For example, TypeScript has a built in `Record` type, but it requires all of the fields to have the same type,\n * putting its semantics half way between this library's \"Object\" schema and {@link FlexTreeMapNode}.\n *\n * @internal\n */\nexport interface FlexTreeObjectNode extends FlexTreeNode {\n\treadonly schema: FlexObjectNodeSchema;\n\n\t/**\n\t * {@link LocalNodeKey} that identifies this node.\n\t */\n\treadonly localNodeKey?: LocalNodeKey;\n}\n\n/**\n * Leaf holding a value.\n *\n * @remarks\n * Leaves are immutable and have no children.\n * Leaf unboxes its content, so in schema aware APIs which do unboxing, the Leaf itself will be skipped over and its value will be returned directly.\n * @internal\n */\nexport interface FlexTreeLeafNode<in out TSchema extends LeafNodeSchema> extends FlexTreeNode {\n\treadonly schema: TSchema;\n\n\t/**\n\t * Value stored on this node.\n\t */\n\treadonly value: TreeValue<TSchema[\"info\"]>;\n}\n\n/**\n * An {@link FlexTreeObjectNode} with schema aware accessors for its fields.\n *\n * @privateRemarks\n *\n * The corresponding implementation logic for this lives in `LazyTree.ts` under `buildStructClass`.\n * If you change the signature here, you will need to update that logic to match.\n *\n * @internal\n */\nexport type FlexTreeObjectNodeTyped<TSchema extends FlexObjectNodeSchema> =\n\tFlexObjectNodeSchema extends TSchema\n\t\t? FlexTreeObjectNode\n\t\t: FlexTreeObjectNode & FlexTreeObjectNodeFields<TSchema[\"info\"]>;\n\n/**\n * Properties to access an object node's fields. See {@link FlexTreeObjectNodeTyped}.\n *\n * @privateRemarks\n * TODO: Support custom field keys.\n * @internal\n */\nexport type FlexTreeObjectNodeFields<TFields extends FlexObjectNodeFields> =\n\tFlexTreeObjectNodeFieldsInner<\n\t\tFlattenKeys<\n\t\t\t{\n\t\t\t\t// When the key does not need to be escaped, map it from the input TFields in a way that doesn't break navigate to declaration\n\t\t\t\t[key in keyof TFields as key extends PropertyNameFromFieldKey<key & string>\n\t\t\t\t\t? key\n\t\t\t\t\t: never]: TFields[key];\n\t\t\t} & {\n\t\t\t\t[key in keyof TFields as key extends PropertyNameFromFieldKey<key & string>\n\t\t\t\t\t? never\n\t\t\t\t\t: PropertyNameFromFieldKey<key & string>]: TFields[key];\n\t\t\t}\n\t\t>\n\t>;\n\n/**\n * Properties to access an object node's fields. See {@link FlexTreeObjectNodeTyped}.\n *\n * @privateRemarks\n * TODO: Do we keep assignment operator + \"setFoo\" methods, or just use methods?\n * Inconsistency in the API experience could confusing for consumers.\n *\n * @internal\n */\nexport type FlexTreeObjectNodeFieldsInner<TFields extends FlexObjectNodeFields> = FlattenKeys<\n\t{\n\t\t// boxed fields (TODO: maybe remove these when same as non-boxed version?)\n\t\treadonly [key in keyof TFields as `boxed${Capitalize<key & string>}`]: FlexTreeTypedField<\n\t\t\tTFields[key]\n\t\t>;\n\t} & {\n\t\t// Add getter only (make property readonly) when the field is **not** of a kind that has a logical set operation.\n\t\t// If we could map to getters and setters separately, we would preferably do that, but we can't.\n\t\t// See https://github.com/microsoft/TypeScript/issues/43826 for more details on this limitation.\n\t\treadonly [key in keyof TFields as TFields[key][\"kind\"] extends AssignableFieldKinds\n\t\t\t? never\n\t\t\t: key]: FlexTreeUnboxField<TFields[key]>;\n\t} & {\n\t\t// Add setter (make property writable) when the field is of a kind that has a logical set operation.\n\t\t// If we could map to getters and setters separately, we would preferably do that, but we can't.\n\t\t// See https://github.com/microsoft/TypeScript/issues/43826 for more details on this limitation.\n\t\t-readonly [key in keyof TFields as TFields[key][\"kind\"] extends AssignableFieldKinds\n\t\t\t? key\n\t\t\t: never]: FlexTreeUnboxField<TFields[key]>;\n\t} & {\n\t\t// Setter method (when the field is of a kind that has a logical set operation).\n\t\treadonly [key in keyof TFields as TFields[key][\"kind\"] extends AssignableFieldKinds\n\t\t\t? `set${Capitalize<key & string>}`\n\t\t\t: never]: (content: FlexibleFieldContent<TFields[key]>) => void;\n\t}\n>;\n\n/**\n * Reserved object node field property names to avoid collisions with the rest of the object node API.\n * @internal\n */\nexport const reservedObjectNodeFieldPropertyNames = [\n\t\"anchorNode\",\n\t\"constructor\",\n\t\"context\",\n\t\"is\",\n\t\"on\",\n\t\"parentField\",\n\t\"schema\",\n\t\"treeStatus\",\n\t\"tryGetField\",\n\t\"type\",\n\t\"value\",\n\t\"boxedIterator\",\n\t\"iterator\",\n\t\"getBoxed\",\n] as const;\n\n/**\n * Reserved object node field property names prefixes.\n * These are reserved to avoid collisions with properties derived from field other field names.\n *\n * Field names starting with these must be followed by a lowercase letter, or be escaped.\n * @internal\n */\nexport const reservedObjectNodeFieldPropertyNamePrefixes = [\n\t\"set\",\n\t\"boxed\",\n\t\"field\",\n\t\"Field\",\n] as const;\n\n/**\n * {@link reservedObjectNodeFieldPropertyNamePrefixes} as a type union.\n * @internal\n */\nexport type ReservedObjectNodeFieldPropertyNames =\n\t(typeof reservedObjectNodeFieldPropertyNames)[number];\n\n/**\n * {@link reservedObjectNodeFieldPropertyNamePrefixes} as a type union.\n * @internal\n */\nexport type ReservedObjectNodeFieldPropertyNamePrefixes =\n\t(typeof reservedObjectNodeFieldPropertyNamePrefixes)[number];\n\n/**\n * Convert an object node's field key into an escaped string usable as a property name.\n *\n * @privateRemarks\n * TODO:\n * Collisions are still possible.\n * For example fields named \"foo\" and \"Foo\" would both produce a setter \"setFoo\".\n * Consider naming schemes to avoid this, ensure that there is a good workaround for these cases.\n * Another approach would be to support custom field names (separate from keys),\n * and do the escaping (if needed) when creating the flex tree schema (both when manually creating them and when doing so automatically):\n * this would enable better intellisense for escaped fields, as well as allow the feature of custom field property names.\n *\n * @internal\n */\nexport type PropertyNameFromFieldKey<T extends string> =\n\tT extends ReservedObjectNodeFieldPropertyNames\n\t\t? `field${Capitalize<T>}`\n\t\t: T extends `${ReservedObjectNodeFieldPropertyNamePrefixes}${Capitalize<string>}`\n\t\t\t? `field${Capitalize<T>}`\n\t\t\t: T;\n\n/**\n * Field kinds that allow value assignment.\n *\n * @internal\n */\nexport type AssignableFieldKinds = typeof FieldKinds.optional | typeof FieldKinds.required;\n\n// #endregion\n\n// #region Field Kinds\n\n/**\n * Strongly typed tree literals for inserting as the content of a field.\n *\n * If a cursor is provided, it must be in Fields mode.\n * @internal\n */\nexport type FlexibleFieldContent<TSchema extends FlexFieldSchema> =\n\t| InsertableFlexField<TSchema>\n\t| ITreeCursorSynchronous;\n\n/**\n * Strongly typed tree literals for inserting as a node.\n *\n * If a cursor is provided, it must be in Nodes mode.\n * @internal\n */\nexport type FlexibleNodeContent<TTypes extends FlexAllowedTypes> =\n\t| AllowedTypesToFlexInsertableTree<TTypes>\n\t| ITreeCursorSynchronous;\n\n/**\n * Strongly typed tree literals for inserting a subsequence of nodes.\n *\n * Used to insert a batch of 0 or more nodes into some location in a {@link FlexTreeSequenceField}.\n *\n * If a cursor is provided, it must be in Fields mode.\n * @internal\n */\nexport type FlexibleNodeSubSequence<TTypes extends FlexAllowedTypes> =\n\t| Iterable<AllowedTypesToFlexInsertableTree<TTypes>>\n\t| ITreeCursorSynchronous;\n\n/**\n * Type to ensures two types overlap in at least one way.\n * It evaluates to the input type if this is true, and never otherwise.\n * Examples:\n * CheckTypesOverlap\\<number | boolean, number | object\\> = number | boolean\n * CheckTypesOverlap\\<number | boolean, string | object\\> = never\n * @internal\n */\nexport type CheckTypesOverlap<T, TCheck> = [Extract<T, TCheck> extends never ? never : T][0];\n\n/**\n * {@link FlexTreeField} that stores a sequence of children.\n *\n * Sequence fields can contain an ordered sequence any number of {@link FlexTreeNode}s which must be of the {@link FlexAllowedTypes} from the {@link FlexFieldSchema}).\n *\n * @remarks\n * Allows for concurrent editing based on index, adjusting the locations of indexes as needed so they apply to the same logical place in the sequence when rebased and merged.\n *\n * Edits to sequence fields are anchored relative to their surroundings, so concurrent edits can result in the indexes of nodes and edits getting shifted.\n * To hold onto locations in sequence across an edit, use anchors.\n *\n * @privateRemarks\n * TODO:\n * Add anchor API that can actually hold onto locations in a sequence.\n * Currently only nodes can be held onto with anchors, and this does not replicate the behavior implemented for editing.\n * @internal\n */\nexport interface FlexTreeSequenceField<in out TTypes extends FlexAllowedTypes>\n\textends FlexTreeField {\n\t/**\n\t * Gets a node of this field by its index with unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= array.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tat(index: number): FlexTreeUnboxNodeUnion<TTypes> | undefined;\n\n\t/**\n\t * {@inheritdoc FlexTreeField.boxedAt}\n\t */\n\tboxedAt(index: number): FlexTreeTypedNodeUnion<TTypes> | undefined;\n\n\t/**\n\t * Calls the provided callback function on each child of this sequence, and returns an array that contains the results.\n\t * @param callbackfn - A function that accepts the child and its index.\n\t */\n\tmap<U>(callbackfn: (value: FlexTreeUnboxNodeUnion<TTypes>, index: number) => U): U[];\n\n\t/**\n\t * Calls the provided callback function on each child of this sequence, and returns an array that contains the results.\n\t * @param callbackfn - A function that accepts the child and its index.\n\t */\n\tmapBoxed<U>(callbackfn: (value: FlexTreeTypedNodeUnion<TTypes>, index: number) => U): U[];\n\n\treadonly length: number;\n\n\t/**\n\t * Get an editor for this sequence.\n\t */\n\tsequenceEditor(): SequenceFieldEditBuilder;\n\n\t/*\n\t * TODO:\n\t * Remove these editing methods and replace their use with use of `sequenceEditor`.\n\t * These editing methods replicate the API exposed by simple-tree, but using flex-tree types.\n\t * As these methods just re-abstract the lower level SequenceFieldEditBuilder API, they add little value.\n\t * Migrating the logic implementing them to simple-tree (and having it just use `sequenceEditor` directly)\n\t * avoids duplicating the API surface (and documentation), as well as makes it simpler to implement the desired user facing validation and errors\n\t * since simple-tree becomes responsible for all the validation and can produce usage errors in terms of the public package API.\n\t */\n\t// #region Editing Methods\n\n\t/**\n\t * Inserts new item(s) at a specified location.\n\t * @param index - The index at which to insert `value`.\n\t * @param value - The content to insert.\n\t * @throws Throws if `index` is not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tinsertAt(index: number, value: FlexibleNodeSubSequence<TTypes>): void;\n\n\t/**\n\t * Inserts new item(s) at the start of the sequence.\n\t * @param value - The content to insert.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tinsertAtStart(value: FlexibleNodeSubSequence<TTypes>): void;\n\n\t/**\n\t * Inserts new item(s) at the end of the sequence.\n\t * @param value - The content to insert.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tinsertAtEnd(value: FlexibleNodeSubSequence<TTypes>): void;\n\n\t/**\n\t * Removes the item at the specified location.\n\t * @param index - The index at which to remove the item.\n\t * @throws Throws if `index` is not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tremoveAt(index: number): void;\n\n\t/**\n\t * Moves the specified item to the start of the sequence.\n\t * @param sourceIndex - The index of the item to move.\n\t * @throws Throws if `sourceIndex` is not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveToStart(sourceIndex: number): void;\n\n\t/**\n\t * Moves the specified item to the start of the sequence.\n\t * @param sourceIndex - The index of the item to move.\n\t * @param source - The source sequence to move the item out of.\n\t * @throws Throws if `sourceIndex` is not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveToStart(sourceIndex: number, source: FlexTreeSequenceField<FlexAllowedTypes>): void;\n\n\t/**\n\t * Moves the specified item to the end of the sequence.\n\t * @param sourceIndex - The index of the item to move.\n\t * @throws Throws if `sourceIndex` is not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveToEnd(sourceIndex: number): void;\n\n\t/**\n\t * Moves the specified item to the end of the sequence.\n\t * @param sourceIndex - The index of the item to move.\n\t * @param source - The source sequence to move the item out of.\n\t * @throws Throws if `sourceIndex` is not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveToEnd(sourceIndex: number, source: FlexTreeSequenceField<FlexAllowedTypes>): void;\n\n\t/**\n\t * Moves the specified item to the desired location in the sequence.\n\t * @param index - The index to move the item to.\n\t * This is based on the state of the sequence before moving the source item.\n\t * @param sourceIndex - The index of the item to move.\n\t * @throws Throws if any of the input indices are not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveToIndex(index: number, sourceIndex: number): void;\n\n\t/**\n\t * Moves the specified item to the desired location in the sequence.\n\t * @param index - The index to move the item to.\n\t * @param sourceIndex - The index of the item to move.\n\t * @param source - The source sequence to move the item out of.\n\t * @throws Throws if any of the input indices are not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveToIndex(\n\t\tindex: number,\n\t\tsourceIndex: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\n\t/**\n\t * Moves the specified items to the start of the sequence.\n\t * @param sourceStart - The starting index of the range to move (inclusive).\n\t * @param sourceEnd - The ending index of the range to move (exclusive)\n\t * @throws Throws if either of the input indices are not in the range [0, `list.length`) or if `sourceStart` is greater than `sourceEnd`.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveRangeToStart(sourceStart: number, sourceEnd: number): void;\n\n\t/**\n\t * Moves the specified items to the start of the sequence.\n\t * @param sourceStart - The starting index of the range to move (inclusive).\n\t * @param sourceEnd - The ending index of the range to move (exclusive)\n\t * @param source - The source sequence to move items out of.\n\t * @throws Throws if the types of any of the items being moved are not allowed in the destination sequence,\n\t * if either of the input indices are not in the range [0, `list.length`) or if `sourceStart` is greater than `sourceEnd`.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveRangeToStart(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\n\t/**\n\t * Moves the specified items to the end of the sequence.\n\t * @param sourceStart - The starting index of the range to move (inclusive).\n\t * @param sourceEnd - The ending index of the range to move (exclusive)\n\t * @throws Throws if either of the input indices are not in the range [0, `list.length`) or if `sourceStart` is greater than `sourceEnd`.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveRangeToEnd(sourceStart: number, sourceEnd: number): void;\n\n\t/**\n\t * Moves the specified items to the end of the sequence.\n\t * @param sourceStart - The starting index of the range to move (inclusive).\n\t * @param sourceEnd - The ending index of the range to move (exclusive)\n\t * @param source - The source sequence to move items out of.\n\t * @throws Throws if the types of any of the items being moved are not allowed in the destination sequence,\n\t * if either of the input indices are not in the range [0, `list.length`) or if `sourceStart` is greater than `sourceEnd`.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveRangeToEnd(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\n\t/**\n\t * Moves the specified items to the desired location within the sequence.\n\t * @param index - The index to move the items to.\n\t * This is based on the state of the sequence before moving the source items.\n\t * @param sourceStart - The starting index of the range to move (inclusive).\n\t * @param sourceEnd - The ending index of the range to move (exclusive)\n\t * @throws Throws if any of the input indices are not in the range [0, `list.length`) or if `sourceStart` is greater than `sourceEnd`.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveRangeToIndex(index: number, sourceStart: number, sourceEnd: number): void;\n\n\t/**\n\t * Moves the specified items to the desired location within the sequence.\n\t * @param index - The index to move the items to.\n\t * @param sourceStart - The starting index of the range to move (inclusive).\n\t * @param sourceEnd - The ending index of the range to move (exclusive)\n\t * @param source - The source sequence to move items out of.\n\t * @throws Throws if the types of any of the items being moved are not allowed in the destination sequence,\n\t * if any of the input indices are not in the range [0, `list.length`) or if `sourceStart` is greater than `sourceEnd`.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\n\t// #endregion\n\n\tboxedIterator(): IterableIterator<FlexTreeTypedNodeUnion<TTypes>>;\n\n\t/**\n\t * Gets the FieldUpPath of a field.\n\t */\n\tgetFieldPath(): FieldUpPath;\n\n\t[Symbol.iterator](): IterableIterator<FlexTreeUnboxNodeUnion<TTypes>>;\n}\n\n/**\n * Field that stores exactly one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the RequiredField itself will be skipped over and its content will be returned directly.\n * @internal\n */\nexport interface FlexTreeRequiredField<in out TTypes extends FlexAllowedTypes>\n\textends FlexTreeField {\n\tget content(): FlexTreeUnboxNodeUnion<TTypes>;\n\tset content(content: FlexibleNodeContent<TTypes>);\n\n\treadonly boxedContent: FlexTreeTypedNodeUnion<TTypes>;\n}\n\n/**\n * Field that stores zero or one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the OptionalField itself will be skipped over and its content will be returned directly.\n *\n * @privateRemarks\n * TODO: Document merge semitics\n * TODO: Allow Optional fields to be used with last write wins OR first write wins merge resolution.\n * TODO:\n * Better centralize the documentation about what kinds of merge semantics are available for field kinds.\n * Maybe link editor?\n * @internal\n */\nexport interface FlexTreeOptionalField<in out TTypes extends FlexAllowedTypes>\n\textends FlexTreeField {\n\tget content(): FlexTreeUnboxNodeUnion<TTypes> | undefined;\n\tset content(newContent: FlexibleNodeContent<TTypes> | undefined);\n\n\treadonly boxedContent?: FlexTreeTypedNodeUnion<TTypes>;\n}\n\n/**\n * Field that contains an immutable {@link StableNodeKey} identifying this node.\n * @internal\n */\nexport interface FlexTreeNodeKeyField extends FlexTreeField {\n\treadonly localNodeKey: LocalNodeKey;\n\treadonly stableNodeKey: StableNodeKey;\n}\n\n// #endregion\n\n// #region Typed\n\n/**\n * Schema aware specialization of {@link FlexTreeField}.\n * @internal\n */\nexport type FlexTreeTypedField<TSchema extends FlexFieldSchema> = FlexTreeTypedFieldInner<\n\tTSchema[\"kind\"],\n\tTSchema[\"allowedTypes\"]\n>;\n\n/**\n * Helper for implementing {@link FlexTreeTypedField}.\n * @internal\n */\nexport type FlexTreeTypedFieldInner<\n\tKind extends FlexFieldKind,\n\tTypes extends FlexAllowedTypes,\n> = Kind extends typeof FieldKinds.sequence\n\t? FlexTreeSequenceField<Types>\n\t: Kind extends typeof FieldKinds.required\n\t\t? FlexTreeRequiredField<Types>\n\t\t: Kind extends typeof FieldKinds.optional\n\t\t\t? FlexTreeOptionalField<Types>\n\t\t\t: FlexTreeField;\n\n/**\n * Schema aware specialization of {@link FlexTreeNode} for a given {@link FlexAllowedTypes}.\n * @internal\n */\nexport type FlexTreeTypedNodeUnion<T extends FlexAllowedTypes> =\n\tT extends FlexList<FlexTreeNodeSchema>\n\t\t? FlexTreeTypedNode<Assume<FlexListToUnion<T>, FlexTreeNodeSchema>>\n\t\t: FlexTreeNode;\n\n/**\n * Schema aware specialization of {@link FlexTreeNode} for a given {@link FlexTreeNodeSchema}.\n * @internal\n */\nexport type FlexTreeTypedNode<TSchema extends FlexTreeNodeSchema> =\n\tTSchema extends LeafNodeSchema\n\t\t? FlexTreeLeafNode<TSchema>\n\t\t: TSchema extends FlexMapNodeSchema\n\t\t\t? FlexTreeMapNode<TSchema>\n\t\t\t: TSchema extends FlexFieldNodeSchema\n\t\t\t\t? FlexTreeFieldNode<TSchema>\n\t\t\t\t: TSchema extends FlexObjectNodeSchema\n\t\t\t\t\t? FlexTreeObjectNodeTyped<TSchema>\n\t\t\t\t\t: FlexTreeNode;\n\n// #endregion\n\n// #region Unbox\n\n/**\n * Schema aware unboxed field.\n * @remarks\n * Unboxes fields to their content if appropriate for the kind.\n * Recursively unboxes that content (then its content etc.) as well if the node union does unboxing.\n * @internal\n */\nexport type FlexTreeUnboxField<\n\tTSchema extends FlexFieldSchema,\n\t// If \"notEmpty\", then optional fields will unbox to their content (not their content | undefined)\n\tEmptiness extends \"maybeEmpty\" | \"notEmpty\" = \"maybeEmpty\",\n> = FlexTreeUnboxFieldInner<TSchema[\"kind\"], TSchema[\"allowedTypes\"], Emptiness>;\n\n/**\n * Helper for implementing FlexTreeUnboxField.\n * @internal\n */\nexport type FlexTreeUnboxFieldInner<\n\tKind extends FlexFieldKind,\n\tTTypes extends FlexAllowedTypes,\n\tEmptiness extends \"maybeEmpty\" | \"notEmpty\",\n> = Kind extends typeof FieldKinds.sequence\n\t? FlexTreeSequenceField<TTypes>\n\t: Kind extends typeof FieldKinds.required\n\t\t? FlexTreeUnboxNodeUnion<TTypes>\n\t\t: Kind extends typeof FieldKinds.optional\n\t\t\t? FlexTreeUnboxNodeUnion<TTypes> | (Emptiness extends \"notEmpty\" ? never : undefined)\n\t\t\t: // TODO: forbidden\n\t\t\t\tunknown;\n\n/**\n * Schema aware unboxed union of tree types.\n * @remarks\n * Unboxes when not polymorphic.\n * Recursively unboxes that content as well if the node kind does unboxing.\n * @internal\n */\nexport type FlexTreeUnboxNodeUnion<TTypes extends FlexAllowedTypes> = TTypes extends readonly [\n\tLazyItem<infer InnerType>,\n]\n\t? InnerType extends FlexTreeNodeSchema\n\t\t? FlexTreeUnboxNode<InnerType>\n\t\t: InnerType extends Any\n\t\t\t? FlexTreeNode\n\t\t\t: // This case should not occur. If the result ever ends up unknown, look at places like this to debug.\n\t\t\t\tunknown\n\t: boolean extends IsArrayOfOne<TTypes>\n\t\t? FlexTreeUnknownUnboxed // Unknown if this will unbox. This should mainly happen when TTypes is AllowedTypes.\n\t\t: FlexTreeTypedNodeUnion<TTypes>; // Known to not be a single type, so known not to unbox.\n\n/**\n * `true` if T is known to be an array of one item.\n * `false` if T is known not to be an array of one item.\n * `boolean` if it is unknown if T is an array of one item or not.\n * @internal\n */\nexport type IsArrayOfOne<T extends readonly unknown[]> = T[\"length\"] extends 1\n\t? true\n\t: 1 extends T[\"length\"]\n\t\t? boolean\n\t\t: false;\n\n/**\n * Schema aware unboxed tree type.\n * @remarks\n * Unboxes if the node kind does unboxing.\n * Recursively unboxes that content as well if it does unboxing.\n * @internal\n */\nexport type FlexTreeUnboxNode<TSchema extends FlexTreeNodeSchema> =\n\tTSchema extends LeafNodeSchema\n\t\t? TreeValue<TSchema[\"info\"]>\n\t\t: TSchema extends FlexMapNodeSchema\n\t\t\t? FlexTreeMapNode<TSchema>\n\t\t\t: TSchema extends FlexFieldNodeSchema\n\t\t\t\t? FlexTreeFieldNode<TSchema>\n\t\t\t\t: TSchema extends FlexObjectNodeSchema\n\t\t\t\t\t? FlexTreeObjectNodeTyped<TSchema>\n\t\t\t\t\t: FlexTreeUnknownUnboxed;\n\n/**\n * Unboxed tree type for unknown schema cases.\n * @internal\n */\nexport type FlexTreeUnknownUnboxed = TreeValue | FlexTreeNode;\n\n// #endregion\n"]}
1
+ {"version":3,"file":"flexTreeTypes.js","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/flexTreeTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kDAO6B;AA2B7B;;;GAGG;AACU,QAAA,YAAY,GAAG,IAAA,qBAAU,GAAgB,CAAC;AAEvD;;;GAGG;AACU,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD,SAAgB,gBAAgB,CAAC,CAAU;IAC1C,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,sBAAc,IAAI,CAAC,CAAC;AACnE,CAAC;AAFD,4CAEC;AAED,SAAgB,cAAc,CAAC,CAAU;IACxC,OAAO,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,sBAAc,CAAC,KAAK,kBAAkB,CAAC,IAAI,CAAC;AAC7E,CAAC;AAFD,wCAEC;AAED;;GAEG;AACH,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC7B,2DAAI,CAAA;IACJ,6DAAK,CAAA;AACN,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAqDD;;;GAGG;AACH,IAAY,UAoBX;AApBD,WAAY,UAAU;IACrB;;OAEG;IACH,uDAAc,CAAA;IAEd;;OAEG;IACH,iDAAW,CAAA;IAEX;;OAEG;IACH,iDAAW,CAAA;IAEX;;OAEG;IACH,yCAAO,CAAA;AACR,CAAC,EApBW,UAAU,0BAAV,UAAU,QAoBrB;AAkdD;;;GAGG;AACU,QAAA,oCAAoC,GAAG;IACnD,YAAY;IACZ,aAAa;IACb,SAAS;IACT,IAAI;IACJ,IAAI;IACJ,aAAa;IACb,QAAQ;IACR,YAAY;IACZ,aAAa;IACb,MAAM;IACN,OAAO;IACP,eAAe;IACf,UAAU;IACV,UAAU;CACD,CAAC;AAEX;;;;;;GAMG;AACU,QAAA,2CAA2C,GAAG;IAC1D,KAAK;IACL,OAAO;IACP,OAAO;IACP,OAAO;CACE,CAAC;AA6gBX,aAAa","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype AnchorNode,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype ITreeCursorSynchronous,\n\ttype TreeValue,\n\tanchorSlot,\n} from \"../../core/index.js\";\nimport type { Assume, FlattenKeys } from \"../../util/index.js\";\nimport type { FieldKinds, SequenceFieldEditBuilder } from \"../default-schema/index.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport type { LocalNodeKey, StableNodeKey } from \"../node-key/index.js\";\nimport type {\n\tAllowedTypesToFlexInsertableTree,\n\tInsertableFlexField,\n} from \"../schema-aware/index.js\";\nimport type {\n\tAny,\n\tFlexAllowedTypes,\n\tFlexFieldNodeSchema,\n\tFlexFieldSchema,\n\tFlexList,\n\tFlexListToUnion,\n\tFlexMapNodeSchema,\n\tFlexObjectNodeFields,\n\tFlexObjectNodeSchema,\n\tFlexTreeNodeSchema,\n\tLazyItem,\n\tLeafNodeSchema,\n} from \"../typed-schema/index.js\";\n\nimport type { FlexTreeContext } from \"./context.js\";\nimport type { FlexTreeNodeEvents } from \"./treeEvents.js\";\n\n/**\n * An anchor slot which records the {@link FlexTreeNode} associated with that anchor, if there is one.\n * @remarks This always points to a \"real\" {@link FlexTreeNode} (i.e. a `LazyTreeNode`), never to a \"raw\" node.\n */\nexport const flexTreeSlot = anchorSlot<FlexTreeNode>();\n\n/**\n * Indicates that an object is a flex tree.\n * @internal\n */\nexport const flexTreeMarker = Symbol(\"flexTreeMarker\");\n\nexport function isFlexTreeEntity(t: unknown): t is FlexTreeEntity {\n\treturn typeof t === \"object\" && t !== null && flexTreeMarker in t;\n}\n\nexport function isFlexTreeNode(t: unknown): t is FlexTreeNode {\n\treturn isFlexTreeEntity(t) && t[flexTreeMarker] === FlexTreeEntityKind.Node;\n}\n\n/**\n * @internal\n */\nexport enum FlexTreeEntityKind {\n\tNode,\n\tField,\n}\n\n/**\n * Part of a tree.\n * Iterates over children.\n *\n * @privateRemarks\n * This exists mainly as a place to share common members between nodes and fields.\n * It is not expected to be useful or common to write code which handles this type directly.\n * If this assumption turns out to be false, and generically processing `UntypedEntity`s is useful,\n * then this interface should probably be extended with some down casting functionality (like `is`).\n *\n * TODO:\n * Design and document iterator invalidation rules and ordering rules.\n * Providing a custom iterator type with place anchor semantics would be a good approach.\n *\n * @internal\n */\nexport interface FlexTreeEntity<out TSchema = unknown> {\n\t/**\n\t * Indicates that an object is a specific kind of flex tree FlexTreeEntity.\n\t * This makes it possible to both down cast FlexTreeEntities safely as well as validate if an object is or is not a FlexTreeEntity.\n\t */\n\treadonly [flexTreeMarker]: FlexTreeEntityKind;\n\n\t/**\n\t * Schema for this entity.\n\t * If well-formed, it must follow this schema.\n\t */\n\treadonly schema: TSchema;\n\n\t/**\n\t * A common context of a \"forest\" of FlexTrees.\n\t */\n\treadonly context: FlexTreeContext;\n\n\t/**\n\t * Gets the {@link TreeStatus} of this tree.\n\t *\n\t * @remarks\n\t * For non-root fields, this is the status of the parent node, since fields do not have a separate lifetime.\n\t */\n\ttreeStatus(): TreeStatus;\n\n\t/**\n\t * Iterate through all nodes/fields in this field/node.\n\t *\n\t * @remarks\n\t * No mutations to the current view of the shared tree are permitted during iteration.\n\t */\n\tboxedIterator(): IterableIterator<FlexTreeEntity>;\n}\n\n/**\n * Status of the tree that a particular node belongs to.\n * @public\n */\nexport enum TreeStatus {\n\t/**\n\t * Is parented under the root field.\n\t */\n\tInDocument = 0,\n\n\t/**\n\t * Is not parented under the root field, but can be added back to the original document tree.\n\t */\n\tRemoved = 1,\n\n\t/**\n\t * Is removed and cannot be added back to the original document tree.\n\t */\n\tDeleted = 2,\n\n\t/**\n\t * Is created but has not yet been inserted into the tree.\n\t */\n\tNew = 3,\n}\n\n/**\n * Generic tree node API.\n *\n * Nodes are (shallowly) immutable and have a logical identity, a type and either a value or fields under string keys.\n *\n * This \"logical identity\" is exposed as the object identity: if a node is moved within a document,\n * the same {@link FlexTreeNode} instance will be used in the new location.\n * Similarly, edits applied to a node's sub-tree concurrently with the move of the node will still be applied to its subtree in its new location.\n *\n *\n * @remarks\n * Down-casting (via {@link FlexTreeNode#is}) is required to access Schema-Aware APIs, including editing.\n * All content in the tree is accessible without down-casting, but if the schema is known,\n * the schema aware API may be more ergonomic.\n * All editing is actually done via {@link FlexTreeField}s: the nodes are immutable other than that they contain mutable fields.\n *\n * @internal\n */\nexport interface FlexTreeNode extends FlexTreeEntity<FlexTreeNodeSchema> {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Node;\n\n\t/**\n\t * Value stored on this node.\n\t */\n\treadonly value?: TreeValue;\n\n\t/**\n\t * {@inheritDoc ISubscribable#on}\n\t */\n\ton<K extends keyof FlexTreeNodeEvents>(\n\t\teventName: K,\n\t\tlistener: FlexTreeNodeEvents[K],\n\t): () => void;\n\n\t/**\n\t * Gets a field of this node, if it is not empty.\n\t */\n\ttryGetField(key: FieldKey): undefined | FlexTreeField;\n\n\t/**\n\t * Get the field for `key`.\n\t * @param key - which entry to look up.\n\t *\n\t * @remarks\n\t * All fields implicitly exist, so `getBoxed` can be called with any key and will always return a field.\n\t * Even if the field is empty, it will still be returned, and can be edited to insert content if allowed by the field kind.\n\t * See {@link FlexTreeNode.tryGetField} for a variant that does not allocate afield in the empty case.\n\t */\n\tgetBoxed(key: FieldKey): FlexTreeField;\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t */\n\treadonly parentField: { readonly parent: FlexTreeField; readonly index: number };\n\n\t/**\n\t * Type guard for narrowing / down-casting to a specific schema.\n\t */\n\tis<TSchema extends FlexTreeNodeSchema>(schema: TSchema): this is FlexTreeTypedNode<TSchema>;\n\n\tboxedIterator(): IterableIterator<FlexTreeField>;\n\n\t/**\n\t * The anchor node associated with this node\n\t *\n\t * @remarks\n\t * The ref count keeping this alive is owned by the FlexTreeNode:\n\t * if holding onto this anchor for longer than the FlexTreeNode might be alive,\n\t * a separate Anchor (and thus ref count) must be allocated to keep it alive.\n\t */\n\treadonly anchorNode: AnchorNode;\n}\n\n/**\n * A collaboratively editable collection of nodes within a {@link FlexTreeEntity}.\n *\n * Fields are inherently part of their parent, and thus cannot be moved.\n * Instead their content can be moved, deleted or created.\n *\n * Editing operations are only valid on trees with the {@link TreeStatus#InDocument} `TreeStatus`.\n *\n * @remarks\n * Fields are used wherever an editable collection of nodes is required.\n * This is required in two places:\n * 1. To hold the children of non-leaf {@link FlexTreeNode}s.\n * 2. As the root of a {@link FlexTreeEntity}.\n *\n * Down-casting (via {@link FlexTreeField.is}) is required to access Schema-Aware APIs, including editing.\n * All content in the tree is accessible without down-casting, but if the schema is known,\n * the schema aware API may be more ergonomic.\n *\n * @internal\n */\nexport interface FlexTreeField extends FlexTreeEntity<FlexFieldSchema> {\n\treadonly [flexTreeMarker]: FlexTreeEntityKind.Field;\n\n\t/**\n\t * The number of nodes in this field\n\t */\n\treadonly length: number;\n\n\t/**\n\t * The `FieldKey` this field is under.\n\t * Defines what part of its parent this field makes up.\n\t */\n\treadonly key: FieldKey;\n\n\t/**\n\t * The node which has this field on it under `fieldKey`.\n\t * `undefined` iff this field is a detached field.\n\t */\n\treadonly parent?: FlexTreeNode;\n\n\t/**\n\t * Type guard for narrowing / down-casting to a specific schema.\n\t */\n\tis<TSchema extends FlexFieldSchema>(schema: TSchema): this is FlexTreeTypedField<TSchema>;\n\n\tboxedIterator(): IterableIterator<FlexTreeNode>;\n\n\t/**\n\t * Check if this field is the same as a different field.\n\t * This is defined to mean that both are in the same flex tree, and are the same field on the same node.\n\t * This is more than just a reference comparison because unlike FlexTree nodes, fields are not cached on anchors and can be duplicated.\n\t *\n\t * @privateRemarks\n\t * TODO:\n\t * If practical, cache TreeField instances so use of this method can be replaced with `===` to compare object identity.\n\t * Implementing this will require some care to preserve lazy-ness and work efficiently (without leaks) for empty fields, particularly on MapNodes.\n\t */\n\tisSameAs(other: FlexTreeField): boolean;\n\n\t/**\n\t * Gets a node of this field by its index without unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= sequence.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tboxedAt(index: number): FlexTreeNode | undefined;\n}\n\n// #region Node Kinds\n\n/**\n * A {@link FlexTreeNode} that behaves like a `Map<string, Field>` for a specific `Field` type.\n *\n * @remarks\n * Unlike TypeScript Map type, {@link FlexTreeMapNode.get} always provides a reference to any field looked up, even if it has never been set.\n *\n * This means that, for example, a `MapNode` of {@link FlexTreeSequenceField} fields will return an empty sequence when a previously unused key is looked up,\n * and that sequence can be used to insert new items into the field.\n * Additionally empty fields (those containing no nodes) are not distinguished from fields which do not exist.\n * This differs from JavaScript Maps which have a subtle distinction between storing undefined as a value in the map and deleting an entry from the map.\n *\n * @internal\n */\nexport interface FlexTreeMapNode<in out TSchema extends FlexMapNodeSchema>\n\textends FlexTreeNode {\n\treadonly schema: TSchema;\n\n\t/**\n\t * The number of elements in the map.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `size` will count only the fields which contain one or more nodes.\n\t */\n\treadonly size: number;\n\n\t/**\n\t * Checks whether a value exists for the given key.\n\t * @param key - Which map entry to look up.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `has` will only return true if there are one or more nodes present in the given field.\n\t */\n\thas(key: string): boolean;\n\n\t/**\n\t * Get the value associated with `key`.\n\t * @param key - which map entry to look up.\n\t */\n\tget(key: string): FlexTreeUnboxField<TSchema[\"info\"]>;\n\n\t/**\n\t * Get the field for `key`.\n\t * @param key - which map entry to look up.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, so `get` can be called with any key and will always return a field.\n\t * Even if the field is empty, it will still be returned, and can be edited to insert content into the map.\n\t */\n\tgetBoxed(key: string): FlexTreeTypedField<TSchema[\"info\"]>;\n\n\t/**\n\t * Returns an iterable of keys in the map.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `keys` will yield only the keys of fields which contain one or more nodes.\n\t *\n\t * No guarantees are made regarding the order of the keys returned.\n\t */\n\tkeys(): IterableIterator<FieldKey>;\n\n\t/**\n\t * Returns an iterable of values in the map.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `values` will yield only the fields containing one or more nodes.\n\t *\n\t * No guarantees are made regarding the order of the values returned.\n\t */\n\tvalues(): IterableIterator<FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">>;\n\n\t/**\n\t * Returns an iterable of key, value pairs for every entry in the map.\n\t *\n\t * @remarks\n\t * All fields under a map implicitly exist, but `entries` will yield only the entries whose fields contain one or more nodes.\n\t *\n\t * This iteration provided by `entries()` is equivalent to that provided by direct iteration of the {@link FlexTreeMapNode} (a.k.a. `[Symbol.Iterator]()`).\n\t *\n\t * No guarantees are made regarding the order of the entries returned.\n\t */\n\tentries(): IterableIterator<[FieldKey, FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">]>;\n\n\t/**\n\t * Executes a provided function once per each key/value pair in the map.\n\t * @param callbackFn - The function to run for each map entry\n\t * @param thisArg - If present, `callbackFn` will be bound to `thisArg`\n\t *\n\t * @privateRemarks\n\t * TODO: This should run over fields in insertion order if we want to match the javascript foreach spec.\n\t */\n\tforEach(\n\t\tcallbackFn: (\n\t\t\tvalue: FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">,\n\t\t\tkey: FieldKey,\n\t\t\tmap: FlexTreeMapNode<TSchema>,\n\t\t) => void,\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tthisArg?: any,\n\t): void;\n\n\t/**\n\t * Adds or updates an entry in the map with a specified `key` and a `value`.\n\t *\n\t * @param key - The key of the element to add to the map.\n\t * @param value - The value of the element to add to the map.\n\t */\n\tset(key: string, value: FlexibleFieldContent<TSchema[\"info\"]>): void;\n\n\t/**\n\t * Removes the specified element from this map by its `key`.\n\t *\n\t * @remarks\n\t * Note: unlike JavaScript's Map API, this method does not return a flag indicating whether or not the value was\n\t * deleted.\n\t *\n\t * @privateRemarks\n\t * Regarding the choice to not return a boolean: Since this data structure is distributed in nature, it isn't\n\t * possible to tell whether or not the item was deleted as a result of this method call. Returning a \"best guess\"\n\t * is more likely to create issues / promote bad usage patterns than offer useful information.\n\t *\n\t * @param key - The key of the element to remove from the map.\n\t */\n\tdelete(key: string): void;\n\n\t/**\n\t * Iterate through all fields in the map.\n\t *\n\t * @remarks\n\t * No mutations to the current view of the shared tree are permitted during iteration.\n\t * To iterate over the unboxed values of the map, use `Symbol.Iterator()`.\n\t */\n\tboxedIterator(): IterableIterator<FlexTreeTypedField<TSchema[\"info\"]>>;\n\n\t[Symbol.iterator](): IterableIterator<\n\t\t[FieldKey, FlexTreeUnboxField<TSchema[\"info\"], \"notEmpty\">]\n\t>;\n}\n\n/**\n * A {@link FlexTreeNode} that wraps a single {@link FlexTreeField} (which is placed under the {@link EmptyKey}).\n *\n * @remarks\n * A FieldNode is mostly identical to a struct node with a single field using the {@link EmptyKey}, but provides access to it via a field named \"content\".\n *\n * There are several use-cases where it makes sense to use a field node.\n * Here are a few:\n * - When it's necessary to differentiate between an empty sequence, and no sequence.\n * One case where this is needed is encoding Json.\n * - When polymorphism over {@link FlexFieldSchema} (and not just a union of {@link FlexAllowedTypes}) is required.\n * For example when encoding a schema for a type like\n * `Foo[] | Bar[]`, `Foo | Foo[]` or `Optional<Foo> | Optional<Bar>` (Where `Optional` is the Optional field kind, not TypeScript's `Optional`).\n * Since this schema system only allows `|` of {@link FlexTreeNodeSchema} (and only when declaring a {@link FlexFieldSchema}), see {@link SchemaBuilderBase.field},\n * these aggregate types are most simply expressed by creating fieldNodes for the terms like `Foo[]`, and `Optional<Foo>`.\n * Note that these are distinct from types like `(Foo | Bar)[]` and `Optional<Foo | Bar>` which can be expressed as single fields without extra nodes.\n * - When a distinct merge identity is desired for a field.\n * For example, if the application wants to be able to have an optional node or a sequence which it can pass around, edit and observe changes to,\n * in some cases (like when the content is moved to a different parent) this can be more flexible if a field node is introduced\n * to create a separate logical entity (node) which wraps the field.\n * This can even be useful with value fields to wrap terminal nodes if a stable merge\n * - When a field (such as a {@link FlexTreeSequenceField}) is desired in a location where {@link FlexTreeNode}s are required\n * (like the member of a union or the child of another {@link FlexTreeField}).\n * This can is typically just a different perspective on one of the above cases.\n * For example:\n * `Sequence<Foo> | Sequence<Bar>` or `OptionalField<Sequence<Foo>>` can't be expressed as simple fields\n * (unlike `Sequence<Foo | Bar>` or `OptionalField<Foo>` which can be done as simple fields).\n * Instead {@link FlexTreeFieldNode}s can be use to achieve something similar, more like:\n * `FieldNode<Sequence<Foo>> | FieldNode<Sequence<Bar>>` or `OptionalField<FieldNode<Sequence<Foo>>>`.\n *\n * @privateRemarks\n * FieldNodes do not unbox to their content, so in schema aware APIs which do unboxing, the FieldNode will NOT be skipped over.\n * This is a change from the old behavior to simplify unboxing and prevent cases where arbitrary deep chains of field nodes could unbox omitting information about the tree depth.\n * @internal\n */\nexport interface FlexTreeFieldNode<in out TSchema extends FlexFieldNodeSchema>\n\textends FlexTreeNode {\n\treadonly schema: TSchema;\n\n\t/**\n\t * The content this field node wraps.\n\t * @remarks\n\t * This is a version of {@link FlexTreeFieldNode.boxedContent} but does unboxing.\n\t * Since field node are usually used to wrap fields which don't do unboxing (like {@link FlexTreeSequenceField})\n\t */\n\treadonly content: FlexTreeUnboxField<TSchema[\"info\"]>;\n\t/**\n\t * The field this field node wraps.\n\t *\n\t * @remarks\n\t * Since field nodes are usually used to wrap fields which don't do unboxing (like {@link FlexTreeSequenceField}),\n\t * this is usually the same as {@link FlexTreeFieldNode.content}.\n\t * This is also the same as `[...this][0]`.\n\t */\n\treadonly boxedContent: FlexTreeTypedField<TSchema[\"info\"]>;\n}\n\n/**\n * A {@link FlexTreeNode} that behaves like an \"object\" or \"struct\", providing properties to access its fields.\n *\n * ObjectNodes consist of a finite collection of fields, each with their own (distinct) key and {@link FlexFieldSchema}.\n *\n * @remarks\n * ObjectNodes require complex typing, and have been split into two parts for implementation purposes.\n * See {@link FlexTreeObjectNodeTyped} for the schema aware extensions to this that provide access to the fields.\n *\n * These \"Objects\" resemble \"Structs\" from a wide variety of programming languages\n * (Including Algol 68, C, Go, Rust, C# etc.).\n * ObjectNodes also somewhat resemble JavaScript objects: this analogy is less precise (objects don't have a fixed schema for example),\n * but for consistency with other systems in the JavaScript ecosystem (like JSON) is \"ObjectNodes\" nodes are named \"Objects\".\n *\n * Another common name for this abstraction is [record](https://en.wikipedia.org/wiki/Record_(computer_science)).\n * The name \"Record\" is avoided (in favor of Object) here because it has less precise connotations for most TypeScript developers.\n * For example, TypeScript has a built in `Record` type, but it requires all of the fields to have the same type,\n * putting its semantics half way between this library's \"Object\" schema and {@link FlexTreeMapNode}.\n *\n * @internal\n */\nexport interface FlexTreeObjectNode extends FlexTreeNode {\n\treadonly schema: FlexObjectNodeSchema;\n\n\t/**\n\t * {@link LocalNodeKey} that identifies this node.\n\t */\n\treadonly localNodeKey?: LocalNodeKey;\n}\n\n/**\n * Leaf holding a value.\n *\n * @remarks\n * Leaves are immutable and have no children.\n * Leaf unboxes its content, so in schema aware APIs which do unboxing, the Leaf itself will be skipped over and its value will be returned directly.\n * @internal\n */\nexport interface FlexTreeLeafNode<in out TSchema extends LeafNodeSchema> extends FlexTreeNode {\n\treadonly schema: TSchema;\n\n\t/**\n\t * Value stored on this node.\n\t */\n\treadonly value: TreeValue<TSchema[\"info\"]>;\n}\n\n/**\n * An {@link FlexTreeObjectNode} with schema aware accessors for its fields.\n *\n * @privateRemarks\n *\n * The corresponding implementation logic for this lives in `LazyTree.ts` under `buildStructClass`.\n * If you change the signature here, you will need to update that logic to match.\n *\n * @internal\n */\nexport type FlexTreeObjectNodeTyped<TSchema extends FlexObjectNodeSchema> =\n\tFlexObjectNodeSchema extends TSchema\n\t\t? FlexTreeObjectNode\n\t\t: FlexTreeObjectNode & FlexTreeObjectNodeFields<TSchema[\"info\"]>;\n\n/**\n * Properties to access an object node's fields. See {@link FlexTreeObjectNodeTyped}.\n *\n * @privateRemarks\n * TODO: Support custom field keys.\n * @internal\n */\nexport type FlexTreeObjectNodeFields<TFields extends FlexObjectNodeFields> =\n\tFlexTreeObjectNodeFieldsInner<\n\t\tFlattenKeys<\n\t\t\t{\n\t\t\t\t// When the key does not need to be escaped, map it from the input TFields in a way that doesn't break navigate to declaration\n\t\t\t\t[key in keyof TFields as key extends PropertyNameFromFieldKey<key & string>\n\t\t\t\t\t? key\n\t\t\t\t\t: never]: TFields[key];\n\t\t\t} & {\n\t\t\t\t[key in keyof TFields as key extends PropertyNameFromFieldKey<key & string>\n\t\t\t\t\t? never\n\t\t\t\t\t: PropertyNameFromFieldKey<key & string>]: TFields[key];\n\t\t\t}\n\t\t>\n\t>;\n\n/**\n * Properties to access an object node's fields. See {@link FlexTreeObjectNodeTyped}.\n *\n * @privateRemarks\n * TODO: Do we keep assignment operator + \"setFoo\" methods, or just use methods?\n * Inconsistency in the API experience could confusing for consumers.\n *\n * @internal\n */\nexport type FlexTreeObjectNodeFieldsInner<TFields extends FlexObjectNodeFields> = FlattenKeys<\n\t{\n\t\t// boxed fields (TODO: maybe remove these when same as non-boxed version?)\n\t\treadonly [key in keyof TFields as `boxed${Capitalize<key & string>}`]: FlexTreeTypedField<\n\t\t\tTFields[key]\n\t\t>;\n\t} & {\n\t\t// Add getter only (make property readonly) when the field is **not** of a kind that has a logical set operation.\n\t\t// If we could map to getters and setters separately, we would preferably do that, but we can't.\n\t\t// See https://github.com/microsoft/TypeScript/issues/43826 for more details on this limitation.\n\t\treadonly [key in keyof TFields as TFields[key][\"kind\"] extends AssignableFieldKinds\n\t\t\t? never\n\t\t\t: key]: FlexTreeUnboxField<TFields[key]>;\n\t} & {\n\t\t// Add setter (make property writable) when the field is of a kind that has a logical set operation.\n\t\t// If we could map to getters and setters separately, we would preferably do that, but we can't.\n\t\t// See https://github.com/microsoft/TypeScript/issues/43826 for more details on this limitation.\n\t\t-readonly [key in keyof TFields as TFields[key][\"kind\"] extends AssignableFieldKinds\n\t\t\t? key\n\t\t\t: never]: FlexTreeUnboxField<TFields[key]>;\n\t} & {\n\t\t// Setter method (when the field is of a kind that has a logical set operation).\n\t\treadonly [key in keyof TFields as TFields[key][\"kind\"] extends AssignableFieldKinds\n\t\t\t? `set${Capitalize<key & string>}`\n\t\t\t: never]: (content: FlexibleFieldContent<TFields[key]>) => void;\n\t}\n>;\n\n/**\n * Reserved object node field property names to avoid collisions with the rest of the object node API.\n * @internal\n */\nexport const reservedObjectNodeFieldPropertyNames = [\n\t\"anchorNode\",\n\t\"constructor\",\n\t\"context\",\n\t\"is\",\n\t\"on\",\n\t\"parentField\",\n\t\"schema\",\n\t\"treeStatus\",\n\t\"tryGetField\",\n\t\"type\",\n\t\"value\",\n\t\"boxedIterator\",\n\t\"iterator\",\n\t\"getBoxed\",\n] as const;\n\n/**\n * Reserved object node field property names prefixes.\n * These are reserved to avoid collisions with properties derived from field other field names.\n *\n * Field names starting with these must be followed by a lowercase letter, or be escaped.\n * @internal\n */\nexport const reservedObjectNodeFieldPropertyNamePrefixes = [\n\t\"set\",\n\t\"boxed\",\n\t\"field\",\n\t\"Field\",\n] as const;\n\n/**\n * {@link reservedObjectNodeFieldPropertyNamePrefixes} as a type union.\n * @internal\n */\nexport type ReservedObjectNodeFieldPropertyNames =\n\t(typeof reservedObjectNodeFieldPropertyNames)[number];\n\n/**\n * {@link reservedObjectNodeFieldPropertyNamePrefixes} as a type union.\n * @internal\n */\nexport type ReservedObjectNodeFieldPropertyNamePrefixes =\n\t(typeof reservedObjectNodeFieldPropertyNamePrefixes)[number];\n\n/**\n * Convert an object node's field key into an escaped string usable as a property name.\n *\n * @privateRemarks\n * TODO:\n * Collisions are still possible.\n * For example fields named \"foo\" and \"Foo\" would both produce a setter \"setFoo\".\n * Consider naming schemes to avoid this, ensure that there is a good workaround for these cases.\n * Another approach would be to support custom field names (separate from keys),\n * and do the escaping (if needed) when creating the flex tree schema (both when manually creating them and when doing so automatically):\n * this would enable better intellisense for escaped fields, as well as allow the feature of custom field property names.\n *\n * @internal\n */\nexport type PropertyNameFromFieldKey<T extends string> =\n\tT extends ReservedObjectNodeFieldPropertyNames\n\t\t? `field${Capitalize<T>}`\n\t\t: T extends `${ReservedObjectNodeFieldPropertyNamePrefixes}${Capitalize<string>}`\n\t\t\t? `field${Capitalize<T>}`\n\t\t\t: T;\n\n/**\n * Field kinds that allow value assignment.\n *\n * @internal\n */\nexport type AssignableFieldKinds = typeof FieldKinds.optional | typeof FieldKinds.required;\n\n// #endregion\n\n// #region Field Kinds\n\n/**\n * Strongly typed tree literals for inserting as the content of a field.\n *\n * If a cursor is provided, it must be in Fields mode.\n * @internal\n */\nexport type FlexibleFieldContent<TSchema extends FlexFieldSchema> =\n\t| InsertableFlexField<TSchema>\n\t| ITreeCursorSynchronous;\n\n/**\n * Strongly typed tree literals for inserting as a node.\n *\n * If a cursor is provided, it must be in Nodes mode.\n * @internal\n */\nexport type FlexibleNodeContent<TTypes extends FlexAllowedTypes> =\n\t| AllowedTypesToFlexInsertableTree<TTypes>\n\t| ITreeCursorSynchronous;\n\n/**\n * Strongly typed tree literals for inserting a subsequence of nodes.\n *\n * Used to insert a batch of 0 or more nodes into some location in a {@link FlexTreeSequenceField}.\n *\n * If a cursor is provided, it must be in Fields mode.\n * @internal\n */\nexport type FlexibleNodeSubSequence<TTypes extends FlexAllowedTypes> =\n\t| Iterable<AllowedTypesToFlexInsertableTree<TTypes>>\n\t| ITreeCursorSynchronous;\n\n/**\n * Type to ensures two types overlap in at least one way.\n * It evaluates to the input type if this is true, and never otherwise.\n * Examples:\n * CheckTypesOverlap\\<number | boolean, number | object\\> = number | boolean\n * CheckTypesOverlap\\<number | boolean, string | object\\> = never\n * @internal\n */\nexport type CheckTypesOverlap<T, TCheck> = [Extract<T, TCheck> extends never ? never : T][0];\n\n/**\n * {@link FlexTreeField} that stores a sequence of children.\n *\n * Sequence fields can contain an ordered sequence any number of {@link FlexTreeNode}s which must be of the {@link FlexAllowedTypes} from the {@link FlexFieldSchema}).\n *\n * @remarks\n * Allows for concurrent editing based on index, adjusting the locations of indexes as needed so they apply to the same logical place in the sequence when rebased and merged.\n *\n * Edits to sequence fields are anchored relative to their surroundings, so concurrent edits can result in the indexes of nodes and edits getting shifted.\n * To hold onto locations in sequence across an edit, use anchors.\n *\n * @privateRemarks\n * TODO:\n * Add anchor API that can actually hold onto locations in a sequence.\n * Currently only nodes can be held onto with anchors, and this does not replicate the behavior implemented for editing.\n * @internal\n */\nexport interface FlexTreeSequenceField<in out TTypes extends FlexAllowedTypes>\n\textends FlexTreeField {\n\t/**\n\t * Gets a node of this field by its index with unboxing.\n\t * @param index - Zero-based index of the item to retrieve. Negative values are interpreted from the end of the sequence.\n\t *\n\t * @returns The element in the sequence matching the given index. Always returns undefined if index \\< -sequence.length\n\t * or index \\>= array.length.\n\t *\n\t * @remarks\n\t * Semantics match {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at}.\n\t */\n\tat(index: number): FlexTreeUnboxNodeUnion<TTypes> | undefined;\n\n\t/**\n\t * {@inheritdoc FlexTreeField.boxedAt}\n\t */\n\tboxedAt(index: number): FlexTreeTypedNodeUnion<TTypes> | undefined;\n\n\t/**\n\t * Calls the provided callback function on each child of this sequence, and returns an array that contains the results.\n\t * @param callbackfn - A function that accepts the child and its index.\n\t */\n\tmap<U>(callbackfn: (value: FlexTreeUnboxNodeUnion<TTypes>, index: number) => U): U[];\n\n\t/**\n\t * Calls the provided callback function on each child of this sequence, and returns an array that contains the results.\n\t * @param callbackfn - A function that accepts the child and its index.\n\t */\n\tmapBoxed<U>(callbackfn: (value: FlexTreeTypedNodeUnion<TTypes>, index: number) => U): U[];\n\n\treadonly length: number;\n\n\t/**\n\t * Get an editor for this sequence.\n\t */\n\tsequenceEditor(): SequenceFieldEditBuilder;\n\n\t/*\n\t * TODO:\n\t * Remove these editing methods and replace their use with use of `sequenceEditor`.\n\t * These editing methods replicate the API exposed by simple-tree, but using flex-tree types.\n\t * As these methods just re-abstract the lower level SequenceFieldEditBuilder API, they add little value.\n\t * Migrating the logic implementing them to simple-tree (and having it just use `sequenceEditor` directly)\n\t * avoids duplicating the API surface (and documentation), as well as makes it simpler to implement the desired user facing validation and errors\n\t * since simple-tree becomes responsible for all the validation and can produce usage errors in terms of the public package API.\n\t */\n\t// #region Editing Methods\n\n\t/**\n\t * Inserts new item(s) at a specified location.\n\t * @param index - The index at which to insert `value`.\n\t * @param value - The content to insert.\n\t * @throws Throws if `index` is not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tinsertAt(index: number, value: FlexibleNodeSubSequence<TTypes>): void;\n\n\t/**\n\t * Inserts new item(s) at the start of the sequence.\n\t * @param value - The content to insert.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tinsertAtStart(value: FlexibleNodeSubSequence<TTypes>): void;\n\n\t/**\n\t * Inserts new item(s) at the end of the sequence.\n\t * @param value - The content to insert.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tinsertAtEnd(value: FlexibleNodeSubSequence<TTypes>): void;\n\n\t/**\n\t * Removes the item at the specified location.\n\t * @param index - The index at which to remove the item.\n\t * @throws Throws if `index` is not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tremoveAt(index: number): void;\n\n\t/**\n\t * Moves the specified item to the start of the sequence.\n\t * @param sourceIndex - The index of the item to move.\n\t * @throws Throws if `sourceIndex` is not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveToStart(sourceIndex: number): void;\n\n\t/**\n\t * Moves the specified item to the start of the sequence.\n\t * @param sourceIndex - The index of the item to move.\n\t * @param source - The source sequence to move the item out of.\n\t * @throws Throws if `sourceIndex` is not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveToStart(sourceIndex: number, source: FlexTreeSequenceField<FlexAllowedTypes>): void;\n\n\t/**\n\t * Moves the specified item to the end of the sequence.\n\t * @param sourceIndex - The index of the item to move.\n\t * @throws Throws if `sourceIndex` is not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveToEnd(sourceIndex: number): void;\n\n\t/**\n\t * Moves the specified item to the end of the sequence.\n\t * @param sourceIndex - The index of the item to move.\n\t * @param source - The source sequence to move the item out of.\n\t * @throws Throws if `sourceIndex` is not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveToEnd(sourceIndex: number, source: FlexTreeSequenceField<FlexAllowedTypes>): void;\n\n\t/**\n\t * Moves the specified item to the desired location in the sequence.\n\t * @param index - The index to move the item to.\n\t * This is based on the state of the sequence before moving the source item.\n\t * @param sourceIndex - The index of the item to move.\n\t * @throws Throws if any of the input indices are not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveToIndex(index: number, sourceIndex: number): void;\n\n\t/**\n\t * Moves the specified item to the desired location in the sequence.\n\t * @param index - The index to move the item to.\n\t * @param sourceIndex - The index of the item to move.\n\t * @param source - The source sequence to move the item out of.\n\t * @throws Throws if any of the input indices are not in the range [0, `list.length`).\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveToIndex(\n\t\tindex: number,\n\t\tsourceIndex: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\n\t/**\n\t * Moves the specified items to the start of the sequence.\n\t * @param sourceStart - The starting index of the range to move (inclusive).\n\t * @param sourceEnd - The ending index of the range to move (exclusive)\n\t * @throws Throws if either of the input indices are not in the range [0, `list.length`) or if `sourceStart` is greater than `sourceEnd`.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveRangeToStart(sourceStart: number, sourceEnd: number): void;\n\n\t/**\n\t * Moves the specified items to the start of the sequence.\n\t * @param sourceStart - The starting index of the range to move (inclusive).\n\t * @param sourceEnd - The ending index of the range to move (exclusive)\n\t * @param source - The source sequence to move items out of.\n\t * @throws Throws if the types of any of the items being moved are not allowed in the destination sequence,\n\t * if either of the input indices are not in the range [0, `list.length`) or if `sourceStart` is greater than `sourceEnd`.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveRangeToStart(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\n\t/**\n\t * Moves the specified items to the end of the sequence.\n\t * @param sourceStart - The starting index of the range to move (inclusive).\n\t * @param sourceEnd - The ending index of the range to move (exclusive)\n\t * @throws Throws if either of the input indices are not in the range [0, `list.length`) or if `sourceStart` is greater than `sourceEnd`.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveRangeToEnd(sourceStart: number, sourceEnd: number): void;\n\n\t/**\n\t * Moves the specified items to the end of the sequence.\n\t * @param sourceStart - The starting index of the range to move (inclusive).\n\t * @param sourceEnd - The ending index of the range to move (exclusive)\n\t * @param source - The source sequence to move items out of.\n\t * @throws Throws if the types of any of the items being moved are not allowed in the destination sequence,\n\t * if either of the input indices are not in the range [0, `list.length`) or if `sourceStart` is greater than `sourceEnd`.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveRangeToEnd(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\n\t/**\n\t * Moves the specified items to the desired location within the sequence.\n\t * @param index - The index to move the items to.\n\t * This is based on the state of the sequence before moving the source items.\n\t * @param sourceStart - The starting index of the range to move (inclusive).\n\t * @param sourceEnd - The ending index of the range to move (exclusive)\n\t * @throws Throws if any of the input indices are not in the range [0, `list.length`) or if `sourceStart` is greater than `sourceEnd`.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveRangeToIndex(index: number, sourceStart: number, sourceEnd: number): void;\n\n\t/**\n\t * Moves the specified items to the desired location within the sequence.\n\t * @param index - The index to move the items to.\n\t * @param sourceStart - The starting index of the range to move (inclusive).\n\t * @param sourceEnd - The ending index of the range to move (exclusive)\n\t * @param source - The source sequence to move items out of.\n\t * @throws Throws if the types of any of the items being moved are not allowed in the destination sequence,\n\t * if any of the input indices are not in the range [0, `list.length`) or if `sourceStart` is greater than `sourceEnd`.\n\t * @deprecated Migrate to using simple-tree layer editing APIs, or directly use the field editors.\n\t */\n\tmoveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\t// FlexTreeSequenceField is invariant over its schema so any is required here.\n\t\t// This use of any can be removed by migrating off this deprecated API and deleting it.\n\t\t// If kept, this function should be fixed by making it generic and constraining it to fields which are safe to move content from.\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tsource: FlexTreeSequenceField<any>,\n\t): void;\n\n\t// #endregion\n\n\tboxedIterator(): IterableIterator<FlexTreeTypedNodeUnion<TTypes>>;\n\n\t/**\n\t * Gets the FieldUpPath of a field.\n\t */\n\tgetFieldPath(): FieldUpPath;\n\n\t[Symbol.iterator](): IterableIterator<FlexTreeUnboxNodeUnion<TTypes>>;\n}\n\n/**\n * Field that stores exactly one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the RequiredField itself will be skipped over and its content will be returned directly.\n * @internal\n */\nexport interface FlexTreeRequiredField<in out TTypes extends FlexAllowedTypes>\n\textends FlexTreeField {\n\tget content(): FlexTreeUnboxNodeUnion<TTypes>;\n\tset content(content: FlexibleNodeContent<TTypes>);\n\n\treadonly boxedContent: FlexTreeTypedNodeUnion<TTypes>;\n}\n\n/**\n * Field that stores zero or one child.\n *\n * @remarks\n * Unboxes its content, so in schema aware APIs which do unboxing, the OptionalField itself will be skipped over and its content will be returned directly.\n *\n * @privateRemarks\n * TODO: Document merge semitics\n * TODO: Allow Optional fields to be used with last write wins OR first write wins merge resolution.\n * TODO:\n * Better centralize the documentation about what kinds of merge semantics are available for field kinds.\n * Maybe link editor?\n * @internal\n */\nexport interface FlexTreeOptionalField<in out TTypes extends FlexAllowedTypes>\n\textends FlexTreeField {\n\tget content(): FlexTreeUnboxNodeUnion<TTypes> | undefined;\n\tset content(newContent: FlexibleNodeContent<TTypes> | undefined);\n\n\treadonly boxedContent?: FlexTreeTypedNodeUnion<TTypes>;\n}\n\n/**\n * Field that contains an immutable {@link StableNodeKey} identifying this node.\n * @internal\n */\nexport interface FlexTreeNodeKeyField extends FlexTreeField {\n\treadonly localNodeKey: LocalNodeKey;\n\treadonly stableNodeKey: StableNodeKey;\n}\n\n// #endregion\n\n// #region Typed\n\n/**\n * Schema aware specialization of {@link FlexTreeField}.\n * @internal\n */\nexport type FlexTreeTypedField<TSchema extends FlexFieldSchema> = FlexTreeTypedFieldInner<\n\tTSchema[\"kind\"],\n\tTSchema[\"allowedTypes\"]\n>;\n\n/**\n * Helper for implementing {@link FlexTreeTypedField}.\n * @internal\n */\nexport type FlexTreeTypedFieldInner<\n\tKind extends FlexFieldKind,\n\tTypes extends FlexAllowedTypes,\n> = Kind extends typeof FieldKinds.sequence\n\t? FlexTreeSequenceField<Types>\n\t: Kind extends typeof FieldKinds.required\n\t\t? FlexTreeRequiredField<Types>\n\t\t: Kind extends typeof FieldKinds.optional\n\t\t\t? FlexTreeOptionalField<Types>\n\t\t\t: FlexTreeField;\n\n/**\n * Schema aware specialization of {@link FlexTreeNode} for a given {@link FlexAllowedTypes}.\n * @internal\n */\nexport type FlexTreeTypedNodeUnion<T extends FlexAllowedTypes> =\n\tT extends FlexList<FlexTreeNodeSchema>\n\t\t? FlexTreeTypedNode<Assume<FlexListToUnion<T>, FlexTreeNodeSchema>>\n\t\t: FlexTreeNode;\n\n/**\n * Schema aware specialization of {@link FlexTreeNode} for a given {@link FlexTreeNodeSchema}.\n * @internal\n */\nexport type FlexTreeTypedNode<TSchema extends FlexTreeNodeSchema> =\n\tTSchema extends LeafNodeSchema\n\t\t? FlexTreeLeafNode<TSchema>\n\t\t: TSchema extends FlexMapNodeSchema\n\t\t\t? FlexTreeMapNode<TSchema>\n\t\t\t: TSchema extends FlexFieldNodeSchema\n\t\t\t\t? FlexTreeFieldNode<TSchema>\n\t\t\t\t: TSchema extends FlexObjectNodeSchema\n\t\t\t\t\t? FlexTreeObjectNodeTyped<TSchema>\n\t\t\t\t\t: FlexTreeNode;\n\n// #endregion\n\n// #region Unbox\n\n/**\n * Schema aware unboxed field.\n * @remarks\n * Unboxes fields to their content if appropriate for the kind.\n * Recursively unboxes that content (then its content etc.) as well if the node union does unboxing.\n * @internal\n */\nexport type FlexTreeUnboxField<\n\tTSchema extends FlexFieldSchema,\n\t// If \"notEmpty\", then optional fields will unbox to their content (not their content | undefined)\n\tEmptiness extends \"maybeEmpty\" | \"notEmpty\" = \"maybeEmpty\",\n> = FlexTreeUnboxFieldInner<TSchema[\"kind\"], TSchema[\"allowedTypes\"], Emptiness>;\n\n/**\n * Helper for implementing FlexTreeUnboxField.\n * @internal\n */\nexport type FlexTreeUnboxFieldInner<\n\tKind extends FlexFieldKind,\n\tTTypes extends FlexAllowedTypes,\n\tEmptiness extends \"maybeEmpty\" | \"notEmpty\",\n> = Kind extends typeof FieldKinds.sequence\n\t? FlexTreeSequenceField<TTypes>\n\t: Kind extends typeof FieldKinds.required\n\t\t? FlexTreeUnboxNodeUnion<TTypes>\n\t\t: Kind extends typeof FieldKinds.optional\n\t\t\t? FlexTreeUnboxNodeUnion<TTypes> | (Emptiness extends \"notEmpty\" ? never : undefined)\n\t\t\t: // TODO: forbidden\n\t\t\t\tunknown;\n\n/**\n * Schema aware unboxed union of tree types.\n * @remarks\n * Unboxes when not polymorphic.\n * Recursively unboxes that content as well if the node kind does unboxing.\n * @internal\n */\nexport type FlexTreeUnboxNodeUnion<TTypes extends FlexAllowedTypes> = TTypes extends readonly [\n\tLazyItem<infer InnerType>,\n]\n\t? InnerType extends FlexTreeNodeSchema\n\t\t? FlexTreeUnboxNode<InnerType>\n\t\t: InnerType extends Any\n\t\t\t? FlexTreeNode\n\t\t\t: // This case should not occur. If the result ever ends up unknown, look at places like this to debug.\n\t\t\t\tunknown\n\t: boolean extends IsArrayOfOne<TTypes>\n\t\t? FlexTreeUnknownUnboxed // Unknown if this will unbox. This should mainly happen when TTypes is AllowedTypes.\n\t\t: FlexTreeTypedNodeUnion<TTypes>; // Known to not be a single type, so known not to unbox.\n\n/**\n * `true` if T is known to be an array of one item.\n * `false` if T is known not to be an array of one item.\n * `boolean` if it is unknown if T is an array of one item or not.\n * @internal\n */\nexport type IsArrayOfOne<T extends readonly unknown[]> = T[\"length\"] extends 1\n\t? true\n\t: 1 extends T[\"length\"]\n\t\t? boolean\n\t\t: false;\n\n/**\n * Schema aware unboxed tree type.\n * @remarks\n * Unboxes if the node kind does unboxing.\n * Recursively unboxes that content as well if it does unboxing.\n * @internal\n */\nexport type FlexTreeUnboxNode<TSchema extends FlexTreeNodeSchema> =\n\tTSchema extends LeafNodeSchema\n\t\t? TreeValue<TSchema[\"info\"]>\n\t\t: TSchema extends FlexMapNodeSchema\n\t\t\t? FlexTreeMapNode<TSchema>\n\t\t\t: TSchema extends FlexFieldNodeSchema\n\t\t\t\t? FlexTreeFieldNode<TSchema>\n\t\t\t\t: TSchema extends FlexObjectNodeSchema\n\t\t\t\t\t? FlexTreeObjectNodeTyped<TSchema>\n\t\t\t\t\t: FlexTreeUnknownUnboxed;\n\n/**\n * Unboxed tree type for unknown schema cases.\n * @internal\n */\nexport type FlexTreeUnknownUnboxed = TreeValue | FlexTreeNode;\n\n// #endregion\n"]}
@@ -14,7 +14,7 @@ export declare function makeField(context: Context, schema: FlexFieldSchema, cur
14
14
  * A Proxy target, which together with a `fieldProxyHandler` implements a basic access to
15
15
  * the nodes of {@link EditableField} by means of the cursors.
16
16
  */
17
- export declare abstract class LazyField<TKind extends FlexFieldKind, TTypes extends FlexAllowedTypes> extends LazyEntity<FlexFieldSchema<TKind, TTypes>, FieldAnchor> implements FlexTreeField {
17
+ export declare abstract class LazyField<out TKind extends FlexFieldKind, TTypes extends FlexAllowedTypes> extends LazyEntity<FlexFieldSchema<TKind, TTypes>, FieldAnchor> implements FlexTreeField {
18
18
  get [flexTreeMarker](): FlexTreeEntityKind.Field;
19
19
  readonly key: FieldKey;
20
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"lazyField.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/flex-tree/lazyField.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,WAAW,EAEhB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAKzB,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EACN,UAAU,EAEV,KAAK,wBAAwB,EAE7B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,E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AS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;CACD;AAzCD,8CAyCC;AAED,MAAa,kBAAoD,SAAQ,SAGxE;CAAG;AAHJ,gDAGI;AAaJ,MAAM,WAAW,GAA+B;IAC/C,CAAC,qBAAU,CAAC,SAAS,EAAE,kBAAkB,CAAC;IAC1C,CAAC,qBAAU,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACxC,CAAC,qBAAU,CAAC,QAAQ,EAAE,YAAY,CAAC;IACnC,CAAC,qBAAU,CAAC,QAAQ,EAAE,cAAc,CAAC;IACrC,CAAC,qBAAU,CAAC,UAAU,EAAE,mBAAmB,CAAC;CAC5C,CAAC;AAEF,MAAM,WAAW,GAAwC,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;AAE9E;;GAEG;AACH,SAAS,2BAA2B,CAAC,MAA8B;IAClE,oDAAoD;IAEpD,IAAA,iBAAM,EAAC,MAAM,CAAC,IAAI,sCAA8B,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;GAEG;AACH,SAAS,0BAA0B,CAAC,MAA8B;IACjE,oDAAoD;IAEpD,IAAA,iBAAM,EAAC,MAAM,CAAC,IAAI,qCAA6B,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACtF,OAAO,CAAC,MAAM,CAAC,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldAnchor,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\ttype TreeNavigationResult,\n\tinCursorNode,\n\tisCursor,\n\titerateCursorField,\n\tkeyAsDetachedField,\n} from \"../../core/index.js\";\nimport {\n\tassertValidIndex,\n\tassertValidRangeIndices,\n\tdisposeSymbol,\n\tfail,\n\tgetOrCreate,\n} from \"../../util/index.js\";\n// TODO: stop depending on contextuallyTyped\nimport { applyTypesFromContext, cursorFromContextualData } from \"../contextuallyTyped.js\";\nimport {\n\tFieldKinds,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\ttype ValueFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport { cursorForMapTreeField } from \"../mapTreeCursor.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport type { FlexAllowedTypes, FlexFieldSchema } from \"../typed-schema/index.js\";\n\nimport type { Context } from \"./context.js\";\nimport {\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeTypedNodeUnion,\n\ttype FlexTreeUnboxNodeUnion,\n\ttype FlexibleNodeContent,\n\ttype FlexibleNodeSubSequence,\n\tTreeStatus,\n\tflexTreeMarker,\n\tflexTreeSlot,\n} from \"./flexTreeTypes.js\";\nimport {\n\tLazyEntity,\n\tanchorSymbol,\n\tcursorSymbol,\n\tforgetAnchorSymbol,\n\tisFreedSymbol,\n\ttryMoveCursorToAnchorSymbol,\n} from \"./lazyEntity.js\";\nimport { type LazyTreeNode, makeTree } from \"./lazyNode.js\";\nimport { unboxedUnion } from \"./unboxed.js\";\nimport {\n\tindexForAt,\n\ttreeStatusFromAnchorCache,\n\ttreeStatusFromDetachedField,\n} from \"./utilities.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Reuse fields.\n * Since field currently own cursors and register themselves for disposal when the node hit end of life,\n * not reusing them results in memory leaks every time the field is accessed.\n * Since the fields stay alive until the node is end of life reusing them this way is safe.\n *\n * This ins't a perfect solution:\n *\n * - This can cause leaks, like map nodes will keep all accessed field objects around. Since other things cause this same leak already, its not too bad.\n * - This does not cache the root.\n * - Finding the parent anchor to do the caching on has significant cost.\n *\n * Despite these limitations, this cache provides a large performance win in some common cases (over 10x), especially with how simple tree requests far more field objects than necessary currently.\n */\nconst fieldCache: WeakMap<LazyTreeNode, Map<FieldKey, FlexTreeField>> = new WeakMap();\n\nexport function makeField(\n\tcontext: Context,\n\tschema: FlexFieldSchema,\n\tcursor: ITreeSubscriptionCursor,\n): FlexTreeField {\n\tconst fieldAnchor = cursor.buildFieldAnchor();\n\tlet usedAnchor = false;\n\n\tconst makeFlexTreeField = (): FlexTreeField => {\n\t\tusedAnchor = true;\n\t\tconst field = new (kindToClass.get(schema.kind) ?? fail(\"missing field implementation\"))(\n\t\t\tcontext,\n\t\t\tschema,\n\t\t\tcursor,\n\t\t\tfieldAnchor,\n\t\t);\n\t\treturn field;\n\t};\n\n\tif (fieldAnchor.parent === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\t// For the common case (all but roots), cache field associated with its node's anchor and field key.\n\tconst anchorNode =\n\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ?? fail(\"missing anchor\");\n\n\t// Since anchor-set could be reused across a flex tree context getting disposed, key off the flex tree node not the anchor.\n\tconst cacheKey = anchorNode.slots.get(flexTreeSlot);\n\n\t// If there is no flex tree parent node, skip caching: this is not expected to be a hot path, but should probably be fixed at some point.\n\tif (cacheKey === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\tconst innerCache = getOrCreate(\n\t\tfieldCache,\n\t\tcacheKey,\n\t\t() => new Map<FieldKey, FlexTreeField>(),\n\t);\n\tconst result = getOrCreate(innerCache, fieldAnchor.fieldKey, makeFlexTreeField);\n\tif (!usedAnchor) {\n\t\t// The anchor must be disposed to avoid leaking. In the case of a cache hit,\n\t\t// we are not transferring ownership to a new FlexTreeField, so it must be disposed of here to avoid the leak.\n\t\tcontext.checkout.forest.anchors.forget(fieldAnchor.parent);\n\t}\n\treturn result;\n}\n\n/**\n * A Proxy target, which together with a `fieldProxyHandler` implements a basic access to\n * the nodes of {@link EditableField} by means of the cursors.\n */\nexport abstract class LazyField<TKind extends FlexFieldKind, TTypes extends FlexAllowedTypes>\n\textends LazyEntity<FlexFieldSchema<TKind, TTypes>, FieldAnchor>\n\timplements FlexTreeField\n{\n\tpublic get [flexTreeMarker](): FlexTreeEntityKind.Field {\n\t\treturn FlexTreeEntityKind.Field;\n\t}\n\tpublic readonly key: FieldKey;\n\n\t/**\n\t * If this field ends its lifetime before the Anchor does, this needs to be invoked to avoid a double free\n\t * if/when the Anchor is destroyed.\n\t */\n\tprivate readonly offAfterDestroy?: () => void;\n\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<TKind, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t\tassert(cursor.mode === CursorLocationType.Fields, 0x77b /* must be in fields mode */);\n\t\tthis.key = cursor.getFieldKey();\n\t\t// Fields currently live as long as their parent does.\n\t\t// For root fields, this means forever, but other cases can be cleaned up when their parent anchor is deleted.\n\t\tif (fieldAnchor.parent !== undefined) {\n\t\t\tconst anchorNode =\n\t\t\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ??\n\t\t\t\tfail(\"parent anchor node should always exist since field is under a node\");\n\t\t\tthis.offAfterDestroy = anchorNode.on(\"afterDestroy\", () => {\n\t\t\t\tthis[disposeSymbol]();\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic is<TSchema extends FlexFieldSchema>(\n\t\tschema: TSchema,\n\t): this is FlexTreeTypedField<TSchema> {\n\t\tassert(\n\t\t\tthis.context.schema.policy.fieldKinds.get(schema.kind.identifier) === schema.kind,\n\t\t\t0x77c /* Narrowing must be done to a kind that exists in this context */,\n\t\t);\n\n\t\treturn this.schema.equals(schema);\n\t}\n\n\tpublic isSameAs(other: FlexTreeField): boolean {\n\t\tassert(\n\t\t\tother.context === this.context,\n\t\t\t0x77d /* Content from different flex trees should not be used together */,\n\t\t);\n\t\treturn this.key === other.key && this.parent === other.parent;\n\t}\n\n\tpublic get parent(): FlexTreeNode | undefined {\n\t\tif (this[anchorSymbol].parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst cursor = this[cursorSymbol];\n\t\tcursor.exitField();\n\t\tconst output = makeTree(this.context, cursor);\n\t\tcursor.enterField(this.key);\n\t\treturn output;\n\t}\n\n\tprotected override [tryMoveCursorToAnchorSymbol](\n\t\tcursor: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\treturn this.context.checkout.forest.tryMoveCursorToField(this[anchorSymbol], cursor);\n\t}\n\n\tprotected override [forgetAnchorSymbol](): void {\n\t\tthis.offAfterDestroy?.();\n\t\tif (this[anchorSymbol].parent === undefined) return;\n\t\tthis.context.checkout.forest.anchors.forget(this[anchorSymbol].parent);\n\t}\n\n\tpublic get length(): number {\n\t\treturn this[cursorSymbol].getFieldLength();\n\t}\n\n\tpublic atIndex(index: number): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn inCursorNode(this[cursorSymbol], index, (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeTypedNodeUnion<TTypes> | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tmakeTree(this.context, cursor),\n\t\t) as unknown as FlexTreeTypedNodeUnion<TTypes>;\n\t}\n\n\tpublic map<U>(callbackfn: (value: FlexTreeUnboxNodeUnion<TTypes>, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\n\tpublic mapBoxed<U>(\n\t\tcallbackfn: (value: FlexTreeTypedNodeUnion<TTypes>, index: number) => U,\n\t): U[] {\n\t\treturn Array.from(this.boxedIterator(), callbackfn);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeTypedNodeUnion<TTypes>> {\n\t\treturn iterateCursorField(\n\t\t\tthis[cursorSymbol],\n\t\t\t(cursor) => makeTree(this.context, cursor) as unknown as FlexTreeTypedNodeUnion<TTypes>,\n\t\t);\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<FlexTreeUnboxNodeUnion<TTypes>> {\n\t\treturn iterateCursorField(this[cursorSymbol], (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\n\tpublic treeStatus(): TreeStatus {\n\t\tif (this[isFreedSymbol]()) {\n\t\t\treturn TreeStatus.Deleted;\n\t\t}\n\t\tconst fieldAnchor = this[anchorSymbol];\n\t\tconst parentAnchor = fieldAnchor.parent;\n\t\t// If the parentAnchor is undefined it is a detached field.\n\t\tif (parentAnchor === undefined) {\n\t\t\treturn treeStatusFromDetachedField(keyAsDetachedField(fieldAnchor.fieldKey));\n\t\t}\n\t\tconst parentAnchorNode = this.context.checkout.forest.anchors.locate(parentAnchor);\n\n\t\t// As the \"parentAnchor === undefined\" case is handled above, parentAnchorNode should exist.\n\t\tassert(parentAnchorNode !== undefined, 0x77e /* parentAnchorNode must exist. */);\n\t\treturn treeStatusFromAnchorCache(parentAnchorNode);\n\t}\n\n\tpublic getFieldPath(): FieldUpPath {\n\t\treturn this[cursorSymbol].getFieldPath();\n\t}\n\n\t/**\n\t * Returns the path to this field to use for editing. Throws iff this path is not {@link TreeStatus#InDocument}.\n\t * This path is not valid to hold onto across edits: this must be recalled for each edit.\n\t */\n\tpublic getFieldPathForEditing(): FieldUpPath {\n\t\tif (this.treeStatus() !== TreeStatus.InDocument) {\n\t\t\tthrow new UsageError(\"Editing only allowed on fields with TreeStatus.InDocument status\");\n\t\t}\n\t\treturn this.getFieldPath();\n\t}\n}\n\nexport class LazySequence<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.sequence, TTypes>\n\timplements FlexTreeSequenceField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.sequence, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic at(index: number): FlexTreeUnboxNodeUnion<TTypes> | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\tpublic get asArray(): readonly FlexTreeUnboxNodeUnion<TTypes>[] {\n\t\treturn this.map((x) => x);\n\t}\n\n\tpublic sequenceEditor(): SequenceFieldEditBuilder {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.sequenceField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic insertAt(index: number, value: FlexibleNodeSubSequence<TTypes>): void {\n\t\tassertValidIndex(index, this, true);\n\t\tconst content: ITreeCursorSynchronous = isCursor(value)\n\t\t\t? prepareFieldCursorForInsert(value)\n\t\t\t: cursorForMapTreeField(\n\t\t\t\t\tArray.from(value, (item) =>\n\t\t\t\t\t\tapplyTypesFromContext(this.context, this.schema.allowedTypeSet, item),\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\tconst fieldEditor = this.sequenceEditor();\n\t\tfieldEditor.insert(index, content);\n\t}\n\n\tpublic insertAtStart(value: FlexibleNodeSubSequence<TTypes>): void {\n\t\tthis.insertAt(0, value);\n\t}\n\n\tpublic insertAtEnd(value: FlexibleNodeSubSequence<TTypes>): void {\n\t\tthis.insertAt(this.length, value);\n\t}\n\n\tpublic removeAt(index: number): void {\n\t\tconst fieldEditor = this.sequenceEditor();\n\t\tfieldEditor.remove(index, 1);\n\t}\n\n\tpublic moveToStart(sourceIndex: number): void;\n\tpublic moveToStart(\n\t\tsourceIndex: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveToStart(\n\t\tsourceIndex: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(0, sourceIndex, sourceIndex + 1, source);\n\t}\n\tpublic moveToEnd(sourceIndex: number): void;\n\tpublic moveToEnd(sourceIndex: number, source: FlexTreeSequenceField<FlexAllowedTypes>): void;\n\tpublic moveToEnd(\n\t\tsourceIndex: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(this.length, sourceIndex, sourceIndex + 1, source);\n\t}\n\tpublic moveToIndex(index: number, sourceIndex: number): void;\n\tpublic moveToIndex(\n\t\tindex: number,\n\t\tsourceIndex: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveToIndex(\n\t\tindex: number,\n\t\tsourceIndex: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(index, sourceIndex, sourceIndex + 1, source);\n\t}\n\n\tpublic moveRangeToStart(sourceStart: number, sourceEnd: number): void;\n\tpublic moveRangeToStart(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveRangeToStart(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(0, sourceStart, sourceEnd, source);\n\t}\n\n\tpublic moveRangeToEnd(sourceStart: number, sourceEnd: number): void;\n\tpublic moveRangeToEnd(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveRangeToEnd(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(this.length, sourceStart, sourceEnd, source);\n\t}\n\n\tpublic moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number): void;\n\tpublic moveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(index, sourceStart, sourceEnd, source);\n\t}\n\n\tprivate _moveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tconst sourceField = source !== undefined ? (this.isSameAs(source) ? this : source) : this;\n\n\t\t// TODO: determine support for move across different sequence types\n\t\tassert(\n\t\t\tsourceField instanceof LazySequence,\n\t\t\t0x7b1 /* Unsupported sequence implementation. */,\n\t\t);\n\t\tassertValidRangeIndices(sourceStart, sourceEnd, sourceField);\n\t\tif (this.schema.types !== undefined && sourceField !== this) {\n\t\t\tfor (let i = sourceStart; i < sourceEnd; i++) {\n\t\t\t\tconst sourceNode =\n\t\t\t\t\tsourceField.boxedAt(sourceStart) ?? fail(\"impossible out of bounds index\");\n\t\t\t\tif (!this.schema.types.has(sourceNode.schema.name)) {\n\t\t\t\t\tthrow new Error(\"Type in source sequence is not allowed in destination.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst movedCount = sourceEnd - sourceStart;\n\t\tassertValidIndex(index, this, true);\n\t\tconst sourceFieldPath = sourceField.getFieldPath();\n\t\tconst destinationFieldPath = this.getFieldPath();\n\t\tthis.context.checkout.editor.move(\n\t\t\tsourceFieldPath,\n\t\t\tsourceStart,\n\t\t\tmovedCount,\n\t\t\tdestinationFieldPath,\n\t\t\tindex,\n\t\t);\n\t}\n}\n\nexport class ReadonlyLazyValueField<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.required, TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic get content(): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn this.atIndex(0);\n\t}\n\n\tpublic set content(newContent: FlexibleNodeContent<TTypes>) {\n\t\tfail(\"cannot set content in readonly field\");\n\t}\n\n\tpublic get boxedContent(): FlexTreeTypedNodeUnion<TTypes> {\n\t\treturn this.boxedAt(0) ?? fail(\"value node must have 1 item\");\n\t}\n}\n\nexport class LazyValueField<TTypes extends FlexAllowedTypes>\n\textends ReadonlyLazyValueField<TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tprivate valueFieldEditor(): ValueFieldEditBuilder {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.valueField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic override get content(): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn this.atIndex(0);\n\t}\n\n\tpublic override set content(newContent: FlexibleNodeContent<TTypes>) {\n\t\tconst content: ITreeCursorSynchronous[] = isCursor(newContent)\n\t\t\t? prepareNodeCursorForInsert(newContent)\n\t\t\t: [cursorFromContextualData(this.context, this.schema.allowedTypeSet, newContent)];\n\t\tconst fieldEditor = this.valueFieldEditor();\n\t\tassert(content.length === 1, 0x780 /* value field content should normalize to one item */);\n\t\tfieldEditor.set(content[0]);\n\t}\n\n\tpublic override get boxedContent(): FlexTreeTypedNodeUnion<TTypes> {\n\t\treturn this.boxedAt(0) ?? fail(\"value node must have 1 item\");\n\t}\n}\n\nexport class LazyIdentifierField<TTypes extends FlexAllowedTypes>\n\textends ReadonlyLazyValueField<TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n}\n\nexport class LazyOptionalField<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.optional, TTypes>\n\timplements FlexTreeOptionalField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.optional, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tprivate optionalEditor(): OptionalFieldEditBuilder {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.optionalField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic get content(): FlexTreeUnboxNodeUnion<TTypes> | undefined {\n\t\treturn this.length === 0 ? undefined : this.atIndex(0);\n\t}\n\n\tpublic set content(newContent: FlexibleNodeContent<TTypes> | undefined) {\n\t\tconst content: ITreeCursorSynchronous[] =\n\t\t\tnewContent === undefined\n\t\t\t\t? []\n\t\t\t\t: isCursor(newContent)\n\t\t\t\t\t? prepareNodeCursorForInsert(newContent)\n\t\t\t\t\t: [cursorFromContextualData(this.context, this.schema.allowedTypeSet, newContent)];\n\t\tconst fieldEditor = this.optionalEditor();\n\t\tassert(\n\t\t\tcontent.length <= 1,\n\t\t\t0x781 /* optional field content should normalize at most one item */,\n\t\t);\n\t\tfieldEditor.set(content.length === 0 ? undefined : content[0], this.length === 0);\n\t}\n\n\tpublic get boxedContent(): FlexTreeTypedNodeUnion<TTypes> | undefined {\n\t\treturn this.length === 0 ? undefined : this.boxedAt(0);\n\t}\n}\n\nexport class LazyForbiddenField<TTypes extends FlexAllowedTypes> extends LazyField<\n\ttypeof FieldKinds.forbidden,\n\tTTypes\n> {}\n\ntype Builder = new <TTypes extends FlexAllowedTypes>(\n\tcontext: Context,\n\t// TODO: use something other than `any`\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tschema: FlexFieldSchema<any, TTypes>,\n\tcursor: ITreeSubscriptionCursor,\n\tfieldAnchor: FieldAnchor,\n\t// TODO: use something other than `any`\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => LazyField<any, TTypes>;\n\nconst builderList: [FlexFieldKind, Builder][] = [\n\t[FieldKinds.forbidden, LazyForbiddenField],\n\t[FieldKinds.optional, LazyOptionalField],\n\t[FieldKinds.sequence, LazySequence],\n\t[FieldKinds.required, LazyValueField],\n\t[FieldKinds.identifier, LazyIdentifierField],\n];\n\nconst kindToClass: ReadonlyMap<FlexFieldKind, Builder> = new Map(builderList);\n\n/**\n * Prepare a fields cursor (holding a sequence of nodes) for inserting.\n */\nfunction prepareFieldCursorForInsert(cursor: ITreeCursorSynchronous): ITreeCursorSynchronous {\n\t// TODO: optionally validate content against schema.\n\n\tassert(cursor.mode === CursorLocationType.Fields, 0x8cb /* should be in fields mode */);\n\treturn cursor;\n}\n\n/**\n * Prepare a node cursor (holding a single node) for inserting.\n */\nfunction prepareNodeCursorForInsert(cursor: ITreeCursorSynchronous): ITreeCursorSynchronous[] {\n\t// TODO: optionally validate content against schema.\n\n\tassert(cursor.mode === CursorLocationType.Nodes, 0x805 /* should be in nodes mode */);\n\treturn [cursor];\n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C;IACxD,CAAC;CACD;AAzCD,8CAyCC;AAED,MAAa,kBAAoD,SAAQ,SAGxE;CAAG;AAHJ,gDAGI;AAaJ,MAAM,WAAW,GAA+B;IAC/C,CAAC,qBAAU,CAAC,SAAS,EAAE,kBAAkB,CAAC;IAC1C,CAAC,qBAAU,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACxC,CAAC,qBAAU,CAAC,QAAQ,EAAE,YAAY,CAAC;IACnC,CAAC,qBAAU,CAAC,QAAQ,EAAE,cAAc,CAAC;IACrC,CAAC,qBAAU,CAAC,UAAU,EAAE,mBAAmB,CAAC;CAC5C,CAAC;AAEF,MAAM,WAAW,GAAwC,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;AAE9E;;GAEG;AACH,SAAS,2BAA2B,CAAC,MAA8B;IAClE,oDAAoD;IAEpD,IAAA,iBAAM,EAAC,MAAM,CAAC,IAAI,sCAA8B,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;GAEG;AACH,SAAS,0BAA0B,CAAC,MAA8B;IACjE,oDAAoD;IAEpD,IAAA,iBAAM,EAAC,MAAM,CAAC,IAAI,qCAA6B,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACtF,OAAO,CAAC,MAAM,CAAC,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldAnchor,\n\ttype FieldKey,\n\ttype FieldUpPath,\n\ttype ITreeCursorSynchronous,\n\ttype ITreeSubscriptionCursor,\n\ttype TreeNavigationResult,\n\tinCursorNode,\n\tisCursor,\n\titerateCursorField,\n\tkeyAsDetachedField,\n} from \"../../core/index.js\";\nimport {\n\tassertValidIndex,\n\tassertValidRangeIndices,\n\tdisposeSymbol,\n\tfail,\n\tgetOrCreate,\n} from \"../../util/index.js\";\n// TODO: stop depending on contextuallyTyped\nimport { applyTypesFromContext, cursorFromContextualData } from \"../contextuallyTyped.js\";\nimport {\n\tFieldKinds,\n\ttype OptionalFieldEditBuilder,\n\ttype SequenceFieldEditBuilder,\n\ttype ValueFieldEditBuilder,\n} from \"../default-schema/index.js\";\nimport { cursorForMapTreeField } from \"../mapTreeCursor.js\";\nimport type { FlexFieldKind } from \"../modular-schema/index.js\";\nimport type { FlexAllowedTypes, FlexFieldSchema } from \"../typed-schema/index.js\";\n\nimport type { Context } from \"./context.js\";\nimport {\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeTypedNodeUnion,\n\ttype FlexTreeUnboxNodeUnion,\n\ttype FlexibleNodeContent,\n\ttype FlexibleNodeSubSequence,\n\tTreeStatus,\n\tflexTreeMarker,\n\tflexTreeSlot,\n} from \"./flexTreeTypes.js\";\nimport {\n\tLazyEntity,\n\tanchorSymbol,\n\tcursorSymbol,\n\tforgetAnchorSymbol,\n\tisFreedSymbol,\n\ttryMoveCursorToAnchorSymbol,\n} from \"./lazyEntity.js\";\nimport { type LazyTreeNode, makeTree } from \"./lazyNode.js\";\nimport { unboxedUnion } from \"./unboxed.js\";\nimport {\n\tindexForAt,\n\ttreeStatusFromAnchorCache,\n\ttreeStatusFromDetachedField,\n} from \"./utilities.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Reuse fields.\n * Since field currently own cursors and register themselves for disposal when the node hit end of life,\n * not reusing them results in memory leaks every time the field is accessed.\n * Since the fields stay alive until the node is end of life reusing them this way is safe.\n *\n * This ins't a perfect solution:\n *\n * - This can cause leaks, like map nodes will keep all accessed field objects around. Since other things cause this same leak already, its not too bad.\n * - This does not cache the root.\n * - Finding the parent anchor to do the caching on has significant cost.\n *\n * Despite these limitations, this cache provides a large performance win in some common cases (over 10x), especially with how simple tree requests far more field objects than necessary currently.\n */\nconst fieldCache: WeakMap<LazyTreeNode, Map<FieldKey, FlexTreeField>> = new WeakMap();\n\nexport function makeField(\n\tcontext: Context,\n\tschema: FlexFieldSchema,\n\tcursor: ITreeSubscriptionCursor,\n): FlexTreeField {\n\tconst fieldAnchor = cursor.buildFieldAnchor();\n\tlet usedAnchor = false;\n\n\tconst makeFlexTreeField = (): FlexTreeField => {\n\t\tusedAnchor = true;\n\t\tconst field = new (kindToClass.get(schema.kind) ?? fail(\"missing field implementation\"))(\n\t\t\tcontext,\n\t\t\tschema,\n\t\t\tcursor,\n\t\t\tfieldAnchor,\n\t\t);\n\t\treturn field;\n\t};\n\n\tif (fieldAnchor.parent === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\t// For the common case (all but roots), cache field associated with its node's anchor and field key.\n\tconst anchorNode =\n\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ?? fail(\"missing anchor\");\n\n\t// Since anchor-set could be reused across a flex tree context getting disposed, key off the flex tree node not the anchor.\n\tconst cacheKey = anchorNode.slots.get(flexTreeSlot);\n\n\t// If there is no flex tree parent node, skip caching: this is not expected to be a hot path, but should probably be fixed at some point.\n\tif (cacheKey === undefined) {\n\t\treturn makeFlexTreeField();\n\t}\n\n\tconst innerCache = getOrCreate(\n\t\tfieldCache,\n\t\tcacheKey,\n\t\t() => new Map<FieldKey, FlexTreeField>(),\n\t);\n\tconst result = getOrCreate(innerCache, fieldAnchor.fieldKey, makeFlexTreeField);\n\tif (!usedAnchor) {\n\t\t// The anchor must be disposed to avoid leaking. In the case of a cache hit,\n\t\t// we are not transferring ownership to a new FlexTreeField, so it must be disposed of here to avoid the leak.\n\t\tcontext.checkout.forest.anchors.forget(fieldAnchor.parent);\n\t}\n\treturn result;\n}\n\n/**\n * A Proxy target, which together with a `fieldProxyHandler` implements a basic access to\n * the nodes of {@link EditableField} by means of the cursors.\n */\nexport abstract class LazyField<\n\t\tout TKind extends FlexFieldKind,\n\t\tTTypes extends FlexAllowedTypes,\n\t>\n\textends LazyEntity<FlexFieldSchema<TKind, TTypes>, FieldAnchor>\n\timplements FlexTreeField\n{\n\tpublic get [flexTreeMarker](): FlexTreeEntityKind.Field {\n\t\treturn FlexTreeEntityKind.Field;\n\t}\n\tpublic readonly key: FieldKey;\n\n\t/**\n\t * If this field ends its lifetime before the Anchor does, this needs to be invoked to avoid a double free\n\t * if/when the Anchor is destroyed.\n\t */\n\tprivate readonly offAfterDestroy?: () => void;\n\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<TKind, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t\tassert(cursor.mode === CursorLocationType.Fields, 0x77b /* must be in fields mode */);\n\t\tthis.key = cursor.getFieldKey();\n\t\t// Fields currently live as long as their parent does.\n\t\t// For root fields, this means forever, but other cases can be cleaned up when their parent anchor is deleted.\n\t\tif (fieldAnchor.parent !== undefined) {\n\t\t\tconst anchorNode =\n\t\t\t\tcontext.checkout.forest.anchors.locate(fieldAnchor.parent) ??\n\t\t\t\tfail(\"parent anchor node should always exist since field is under a node\");\n\t\t\tthis.offAfterDestroy = anchorNode.on(\"afterDestroy\", () => {\n\t\t\t\tthis[disposeSymbol]();\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic is<TSchema extends FlexFieldSchema>(\n\t\tschema: TSchema,\n\t): this is FlexTreeTypedField<TSchema> {\n\t\tassert(\n\t\t\tthis.context.schema.policy.fieldKinds.get(schema.kind.identifier) === schema.kind,\n\t\t\t0x77c /* Narrowing must be done to a kind that exists in this context */,\n\t\t);\n\n\t\treturn this.schema.equals(schema);\n\t}\n\n\tpublic isSameAs(other: FlexTreeField): boolean {\n\t\tassert(\n\t\t\tother.context === this.context,\n\t\t\t0x77d /* Content from different flex trees should not be used together */,\n\t\t);\n\t\treturn this.key === other.key && this.parent === other.parent;\n\t}\n\n\tpublic get parent(): FlexTreeNode | undefined {\n\t\tif (this[anchorSymbol].parent === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst cursor = this[cursorSymbol];\n\t\tcursor.exitField();\n\t\tconst output = makeTree(this.context, cursor);\n\t\tcursor.enterField(this.key);\n\t\treturn output;\n\t}\n\n\tprotected override [tryMoveCursorToAnchorSymbol](\n\t\tcursor: ITreeSubscriptionCursor,\n\t): TreeNavigationResult {\n\t\treturn this.context.checkout.forest.tryMoveCursorToField(this[anchorSymbol], cursor);\n\t}\n\n\tprotected override [forgetAnchorSymbol](): void {\n\t\tthis.offAfterDestroy?.();\n\t\tif (this[anchorSymbol].parent === undefined) return;\n\t\tthis.context.checkout.forest.anchors.forget(this[anchorSymbol].parent);\n\t}\n\n\tpublic get length(): number {\n\t\treturn this[cursorSymbol].getFieldLength();\n\t}\n\n\tpublic atIndex(index: number): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn inCursorNode(this[cursorSymbol], index, (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeTypedNodeUnion<TTypes> | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tmakeTree(this.context, cursor),\n\t\t) as unknown as FlexTreeTypedNodeUnion<TTypes>;\n\t}\n\n\tpublic map<U>(callbackfn: (value: FlexTreeUnboxNodeUnion<TTypes>, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\n\tpublic mapBoxed<U>(\n\t\tcallbackfn: (value: FlexTreeTypedNodeUnion<TTypes>, index: number) => U,\n\t): U[] {\n\t\treturn Array.from(this.boxedIterator(), callbackfn);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeTypedNodeUnion<TTypes>> {\n\t\treturn iterateCursorField(\n\t\t\tthis[cursorSymbol],\n\t\t\t(cursor) => makeTree(this.context, cursor) as unknown as FlexTreeTypedNodeUnion<TTypes>,\n\t\t);\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<FlexTreeUnboxNodeUnion<TTypes>> {\n\t\treturn iterateCursorField(this[cursorSymbol], (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\n\tpublic treeStatus(): TreeStatus {\n\t\tif (this[isFreedSymbol]()) {\n\t\t\treturn TreeStatus.Deleted;\n\t\t}\n\t\tconst fieldAnchor = this[anchorSymbol];\n\t\tconst parentAnchor = fieldAnchor.parent;\n\t\t// If the parentAnchor is undefined it is a detached field.\n\t\tif (parentAnchor === undefined) {\n\t\t\treturn treeStatusFromDetachedField(keyAsDetachedField(fieldAnchor.fieldKey));\n\t\t}\n\t\tconst parentAnchorNode = this.context.checkout.forest.anchors.locate(parentAnchor);\n\n\t\t// As the \"parentAnchor === undefined\" case is handled above, parentAnchorNode should exist.\n\t\tassert(parentAnchorNode !== undefined, 0x77e /* parentAnchorNode must exist. */);\n\t\treturn treeStatusFromAnchorCache(parentAnchorNode);\n\t}\n\n\tpublic getFieldPath(): FieldUpPath {\n\t\treturn this[cursorSymbol].getFieldPath();\n\t}\n\n\t/**\n\t * Returns the path to this field to use for editing. Throws iff this path is not {@link TreeStatus#InDocument}.\n\t * This path is not valid to hold onto across edits: this must be recalled for each edit.\n\t */\n\tpublic getFieldPathForEditing(): FieldUpPath {\n\t\tif (this.treeStatus() !== TreeStatus.InDocument) {\n\t\t\tthrow new UsageError(\"Editing only allowed on fields with TreeStatus.InDocument status\");\n\t\t}\n\t\treturn this.getFieldPath();\n\t}\n}\n\nexport class LazySequence<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.sequence, TTypes>\n\timplements FlexTreeSequenceField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.sequence, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic at(index: number): FlexTreeUnboxNodeUnion<TTypes> | undefined {\n\t\tconst finalIndex = indexForAt(index, this.length);\n\n\t\tif (finalIndex === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn inCursorNode(this[cursorSymbol], finalIndex, (cursor) =>\n\t\t\tunboxedUnion(this.context, this.schema, cursor),\n\t\t);\n\t}\n\tpublic get asArray(): readonly FlexTreeUnboxNodeUnion<TTypes>[] {\n\t\treturn this.map((x) => x);\n\t}\n\n\tpublic sequenceEditor(): SequenceFieldEditBuilder {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.sequenceField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic insertAt(index: number, value: FlexibleNodeSubSequence<TTypes>): void {\n\t\tassertValidIndex(index, this, true);\n\t\tconst content: ITreeCursorSynchronous = isCursor(value)\n\t\t\t? prepareFieldCursorForInsert(value)\n\t\t\t: cursorForMapTreeField(\n\t\t\t\t\tArray.from(value, (item) =>\n\t\t\t\t\t\tapplyTypesFromContext(this.context, this.schema.allowedTypeSet, item),\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\tconst fieldEditor = this.sequenceEditor();\n\t\tfieldEditor.insert(index, content);\n\t}\n\n\tpublic insertAtStart(value: FlexibleNodeSubSequence<TTypes>): void {\n\t\tthis.insertAt(0, value);\n\t}\n\n\tpublic insertAtEnd(value: FlexibleNodeSubSequence<TTypes>): void {\n\t\tthis.insertAt(this.length, value);\n\t}\n\n\tpublic removeAt(index: number): void {\n\t\tconst fieldEditor = this.sequenceEditor();\n\t\tfieldEditor.remove(index, 1);\n\t}\n\n\tpublic moveToStart(sourceIndex: number): void;\n\tpublic moveToStart(\n\t\tsourceIndex: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveToStart(\n\t\tsourceIndex: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(0, sourceIndex, sourceIndex + 1, source);\n\t}\n\tpublic moveToEnd(sourceIndex: number): void;\n\tpublic moveToEnd(sourceIndex: number, source: FlexTreeSequenceField<FlexAllowedTypes>): void;\n\tpublic moveToEnd(\n\t\tsourceIndex: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(this.length, sourceIndex, sourceIndex + 1, source);\n\t}\n\tpublic moveToIndex(index: number, sourceIndex: number): void;\n\tpublic moveToIndex(\n\t\tindex: number,\n\t\tsourceIndex: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveToIndex(\n\t\tindex: number,\n\t\tsourceIndex: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(index, sourceIndex, sourceIndex + 1, source);\n\t}\n\n\tpublic moveRangeToStart(sourceStart: number, sourceEnd: number): void;\n\tpublic moveRangeToStart(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveRangeToStart(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(0, sourceStart, sourceEnd, source);\n\t}\n\n\tpublic moveRangeToEnd(sourceStart: number, sourceEnd: number): void;\n\tpublic moveRangeToEnd(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveRangeToEnd(\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(this.length, sourceStart, sourceEnd, source);\n\t}\n\n\tpublic moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number): void;\n\tpublic moveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void;\n\tpublic moveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tthis._moveRangeToIndex(index, sourceStart, sourceEnd, source);\n\t}\n\n\tprivate _moveRangeToIndex(\n\t\tindex: number,\n\t\tsourceStart: number,\n\t\tsourceEnd: number,\n\t\tsource?: FlexTreeSequenceField<FlexAllowedTypes>,\n\t): void {\n\t\tconst sourceField = source !== undefined ? (this.isSameAs(source) ? this : source) : this;\n\n\t\t// TODO: determine support for move across different sequence types\n\t\tassert(\n\t\t\tsourceField instanceof LazySequence,\n\t\t\t0x7b1 /* Unsupported sequence implementation. */,\n\t\t);\n\t\tassertValidRangeIndices(sourceStart, sourceEnd, sourceField);\n\t\tif (this.schema.types !== undefined && sourceField !== this) {\n\t\t\tfor (let i = sourceStart; i < sourceEnd; i++) {\n\t\t\t\tconst sourceNode =\n\t\t\t\t\tsourceField.boxedAt(sourceStart) ?? fail(\"impossible out of bounds index\");\n\t\t\t\tif (!this.schema.types.has(sourceNode.schema.name)) {\n\t\t\t\t\tthrow new Error(\"Type in source sequence is not allowed in destination.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst movedCount = sourceEnd - sourceStart;\n\t\tassertValidIndex(index, this, true);\n\t\tconst sourceFieldPath = sourceField.getFieldPath();\n\t\tconst destinationFieldPath = this.getFieldPath();\n\t\tthis.context.checkout.editor.move(\n\t\t\tsourceFieldPath,\n\t\t\tsourceStart,\n\t\t\tmovedCount,\n\t\t\tdestinationFieldPath,\n\t\t\tindex,\n\t\t);\n\t}\n}\n\nexport class ReadonlyLazyValueField<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.required, TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tpublic get content(): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn this.atIndex(0);\n\t}\n\n\tpublic set content(newContent: FlexibleNodeContent<TTypes>) {\n\t\tfail(\"cannot set content in readonly field\");\n\t}\n\n\tpublic get boxedContent(): FlexTreeTypedNodeUnion<TTypes> {\n\t\treturn this.boxedAt(0) ?? fail(\"value node must have 1 item\");\n\t}\n}\n\nexport class LazyValueField<TTypes extends FlexAllowedTypes>\n\textends ReadonlyLazyValueField<TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tprivate valueFieldEditor(): ValueFieldEditBuilder {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.valueField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic override get content(): FlexTreeUnboxNodeUnion<TTypes> {\n\t\treturn this.atIndex(0);\n\t}\n\n\tpublic override set content(newContent: FlexibleNodeContent<TTypes>) {\n\t\tconst content: ITreeCursorSynchronous[] = isCursor(newContent)\n\t\t\t? prepareNodeCursorForInsert(newContent)\n\t\t\t: [cursorFromContextualData(this.context, this.schema.allowedTypeSet, newContent)];\n\t\tconst fieldEditor = this.valueFieldEditor();\n\t\tassert(content.length === 1, 0x780 /* value field content should normalize to one item */);\n\t\tfieldEditor.set(content[0]);\n\t}\n\n\tpublic override get boxedContent(): FlexTreeTypedNodeUnion<TTypes> {\n\t\treturn this.boxedAt(0) ?? fail(\"value node must have 1 item\");\n\t}\n}\n\nexport class LazyIdentifierField<TTypes extends FlexAllowedTypes>\n\textends ReadonlyLazyValueField<TTypes>\n\timplements FlexTreeRequiredField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.required, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n}\n\nexport class LazyOptionalField<TTypes extends FlexAllowedTypes>\n\textends LazyField<typeof FieldKinds.optional, TTypes>\n\timplements FlexTreeOptionalField<TTypes>\n{\n\tpublic constructor(\n\t\tcontext: Context,\n\t\tschema: FlexFieldSchema<typeof FieldKinds.optional, TTypes>,\n\t\tcursor: ITreeSubscriptionCursor,\n\t\tfieldAnchor: FieldAnchor,\n\t) {\n\t\tsuper(context, schema, cursor, fieldAnchor);\n\t}\n\n\tprivate optionalEditor(): OptionalFieldEditBuilder {\n\t\tconst fieldPath = this.getFieldPathForEditing();\n\t\tconst fieldEditor = this.context.checkout.editor.optionalField(fieldPath);\n\t\treturn fieldEditor;\n\t}\n\n\tpublic get content(): FlexTreeUnboxNodeUnion<TTypes> | undefined {\n\t\treturn this.length === 0 ? undefined : this.atIndex(0);\n\t}\n\n\tpublic set content(newContent: FlexibleNodeContent<TTypes> | undefined) {\n\t\tconst content: ITreeCursorSynchronous[] =\n\t\t\tnewContent === undefined\n\t\t\t\t? []\n\t\t\t\t: isCursor(newContent)\n\t\t\t\t\t? prepareNodeCursorForInsert(newContent)\n\t\t\t\t\t: [cursorFromContextualData(this.context, this.schema.allowedTypeSet, newContent)];\n\t\tconst fieldEditor = this.optionalEditor();\n\t\tassert(\n\t\t\tcontent.length <= 1,\n\t\t\t0x781 /* optional field content should normalize at most one item */,\n\t\t);\n\t\tfieldEditor.set(content.length === 0 ? undefined : content[0], this.length === 0);\n\t}\n\n\tpublic get boxedContent(): FlexTreeTypedNodeUnion<TTypes> | undefined {\n\t\treturn this.length === 0 ? undefined : this.boxedAt(0);\n\t}\n}\n\nexport class LazyForbiddenField<TTypes extends FlexAllowedTypes> extends LazyField<\n\ttypeof FieldKinds.forbidden,\n\tTTypes\n> {}\n\ntype Builder = new <TTypes extends FlexAllowedTypes>(\n\tcontext: Context,\n\t// Correct use of these builders requires the builder of the matching type to be used.\n\t// 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)\n\t// does not seem worth it (ends up requiring type casts that are just as unsafe).\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tschema: FlexFieldSchema<any, TTypes>,\n\tcursor: ITreeSubscriptionCursor,\n\tfieldAnchor: FieldAnchor,\n) => LazyField<FlexFieldKind, TTypes>;\n\nconst builderList: [FlexFieldKind, Builder][] = [\n\t[FieldKinds.forbidden, LazyForbiddenField],\n\t[FieldKinds.optional, LazyOptionalField],\n\t[FieldKinds.sequence, LazySequence],\n\t[FieldKinds.required, LazyValueField],\n\t[FieldKinds.identifier, LazyIdentifierField],\n];\n\nconst kindToClass: ReadonlyMap<FlexFieldKind, Builder> = new Map(builderList);\n\n/**\n * Prepare a fields cursor (holding a sequence of nodes) for inserting.\n */\nfunction prepareFieldCursorForInsert(cursor: ITreeCursorSynchronous): ITreeCursorSynchronous {\n\t// TODO: optionally validate content against schema.\n\n\tassert(cursor.mode === CursorLocationType.Fields, 0x8cb /* should be in fields mode */);\n\treturn cursor;\n}\n\n/**\n * Prepare a node cursor (holding a single node) for inserting.\n */\nfunction prepareNodeCursorForInsert(cursor: ITreeCursorSynchronous): ITreeCursorSynchronous[] {\n\t// TODO: optionally validate content against schema.\n\n\tassert(cursor.mode === CursorLocationType.Nodes, 0x805 /* should be in nodes mode */);\n\treturn [cursor];\n}\n"]}
@@ -232,6 +232,7 @@ function makeModularChangeCodec(fieldKinds, revisionTagCodec, fieldsCodec, { jso
232
232
  changes: encodeFieldChangesForJson(change.fieldChanges, context, change.nodeChanges),
233
233
  builds: encodeDetachedNodes(change.builds, context),
234
234
  refreshers: encodeDetachedNodes(change.refreshers, context),
235
+ violations: change.constraintViolationCount,
235
236
  };
236
237
  },
237
238
  decode: (encodedChange, context) => {
@@ -246,6 +247,9 @@ function makeModularChangeCodec(fieldKinds, revisionTagCodec, fieldsCodec, { jso
246
247
  if (encodedChange.refreshers !== undefined) {
247
248
  decoded.refreshers = decodeDetachedNodes(encodedChange.builds, context);
248
249
  }
250
+ if (encodedChange.violations !== undefined) {
251
+ decoded.constraintViolationCount = encodedChange.violations;
252
+ }
249
253
  const decodedRevInfos = decodeRevisionInfos(encodedChange.revisions, context);
250
254
  if (decodedRevInfos !== undefined) {
251
255
  decoded.revisions = decodedRevInfos;
@@ -1 +1 @@
1
- {"version":3,"file":"modularChangeCodecs.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema/modularChangeCodecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,mDAQ8B;AAY9B,kDAS6B;AAC7B,yDAKoC;AACpC,wEAAqE;AAMrE,+DAAyD;AACzD,qEAQkC;AAUlC,SAAgB,4BAA4B,CAC3C,uBAAoE,EACpE,gBAKC,EACD,WAA4B,EAC5B,EAAE,aAAa,EAAE,SAAS,EAAiB,EAC3C,2BAAoD,iDAAuB,CAAC,UAAU;IAEtF,OAAO,IAAA,0BAAe,EACrB,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC;QACxE,OAAO;QACP,sBAAsB,CACrB,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,EAAE,aAAa,EAAE,SAAS,EAAE,EAC5B,wBAAwB,C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AAC,CACzC,CAAC;YACF,MAAM,OAAO,GAA8B;gBAC1C,YAAY;gBACZ,WAAW;aACX,CAAC;YAEF,IAAI,aAAa,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBACxC,OAAO,CAAC,MAAM,GAAG,mBAAmB,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACrE,CAAC;YACD,IAAI,aAAa,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC5C,OAAO,CAAC,UAAU,GAAG,mBAAmB,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACzE,CAAC;YAED,MAAM,eAAe,GAAG,mBAAmB,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC9E,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;gBACnC,OAAO,CAAC,SAAS,GAAG,eAAe,CAAC;YACrC,CAAC;YACD,IAAI,aAAa,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBACvC,OAAO,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;YACrC,CAAC;YACD,OAAO,OAAO,CAAC;QAChB,CAAC;KACD,CAAC;IAEF,OAAO,IAAA,+BAAoB,EAAC,gDAAuB,EAAE,kBAAkB,EAAE,SAAS,CAAC,CAAC;AACrF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { TAnySchema } from \"@sinclair/typebox\";\n\nimport {\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\ttype IMultiFormatCodec,\n\ttype SchemaValidationFunction,\n\tmakeCodecFamily,\n\twithSchemaValidation,\n} from \"../../codec/index.js\";\nimport type {\n\tChangeAtomIdMap,\n\tChangeEncodingContext,\n\tChangesetLocalId,\n\tEncodedRevisionTag,\n\tFieldKey,\n\tFieldKindIdentifier,\n\tITreeCursorSynchronous,\n\tRevisionInfo,\n\tRevisionTag,\n} from \"../../core/index.js\";\nimport {\n\ttype IdAllocator,\n\ttype JsonCompatibleReadOnly,\n\ttype Mutable,\n\tbrand,\n\tfail,\n\tidAllocatorFromMaxId,\n\tsetInNestedMap,\n\ttryGetFromNestedMap,\n} from \"../../util/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeChunk,\n\tchunkFieldSingle,\n\tdefaultChunkPolicy,\n} from \"../chunked-forest/index.js\";\nimport { TreeCompressionStrategy } from \"../treeCompressionUtils.js\";\n\nimport type {\n\tFieldKindConfiguration,\n\tFieldKindConfigurationEntry,\n} from \"./fieldKindConfiguration.js\";\nimport { genericFieldKind } from \"./genericFieldKind.js\";\nimport {\n\ttype EncodedBuilds,\n\ttype EncodedBuildsArray,\n\ttype EncodedFieldChange,\n\ttype EncodedFieldChangeMap,\n\tEncodedModularChangeset,\n\ttype EncodedNodeChangeset,\n\ttype EncodedRevisionInfo,\n} from \"./modularChangeFormat.js\";\nimport type {\n\tFieldChangeMap,\n\tFieldChangeset,\n\tModularChangeset,\n\tNodeChangeset,\n\tNodeId,\n} from \"./modularChangeTypes.js\";\nimport type { FieldChangeEncodingContext } from \"./fieldChangeHandler.js\";\n\nexport function makeModularChangeCodecFamily(\n\tfieldKindConfigurations: ReadonlyMap<number, FieldKindConfiguration>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\t{ jsonValidator: validator }: ICodecOptions,\n\tchunkCompressionStrategy: TreeCompressionStrategy = TreeCompressionStrategy.Compressed,\n): ICodecFamily<ModularChangeset, ChangeEncodingContext> {\n\treturn makeCodecFamily(\n\t\tArray.from(fieldKindConfigurations.entries(), ([version, fieldKinds]) => [\n\t\t\tversion,\n\t\t\tmakeModularChangeCodec(\n\t\t\t\tfieldKinds,\n\t\t\t\trevisionTagCodec,\n\t\t\t\tfieldsCodec,\n\t\t\t\t{ jsonValidator: validator },\n\t\t\t\tchunkCompressionStrategy,\n\t\t\t),\n\t\t]),\n\t);\n}\n\ntype ModularChangeCodec = IJsonCodec<\n\tModularChangeset,\n\tEncodedModularChangeset,\n\tEncodedModularChangeset,\n\tChangeEncodingContext\n>;\n\ntype FieldCodec = IMultiFormatCodec<\n\tFieldChangeset,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tFieldChangeEncodingContext\n>;\n\nfunction makeModularChangeCodec(\n\tfieldKinds: FieldKindConfiguration,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\t{ jsonValidator: validator }: ICodecOptions,\n\tchunkCompressionStrategy: TreeCompressionStrategy = TreeCompressionStrategy.Compressed,\n): ModularChangeCodec {\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tconst getMapEntry = ({ kind, formatVersion }: FieldKindConfigurationEntry) => {\n\t\tconst codec = kind.changeHandler.codecsFactory(revisionTagCodec).resolve(formatVersion);\n\t\treturn {\n\t\t\tcodec,\n\t\t\tcompiledSchema: codec.json.encodedSchema\n\t\t\t\t? validator.compile(codec.json.encodedSchema)\n\t\t\t\t: undefined,\n\t\t};\n\t};\n\n\t/**\n\t * The codec version for the generic field kind.\n\t */\n\tconst genericFieldKindFormatVersion = 1;\n\tconst fieldChangesetCodecs: Map<\n\t\tFieldKindIdentifier,\n\t\t{\n\t\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\t\tcodec: FieldCodec;\n\t\t}\n\t> = new Map([\n\t\t[\n\t\t\tgenericFieldKind.identifier,\n\t\t\tgetMapEntry({ kind: genericFieldKind, formatVersion: genericFieldKindFormatVersion }),\n\t\t],\n\t]);\n\n\tfieldKinds.forEach((entry, identifier) => {\n\t\tfieldChangesetCodecs.set(identifier, getMapEntry(entry));\n\t});\n\n\tconst getFieldChangesetCodec = (\n\t\tfieldKind: FieldKindIdentifier,\n\t): {\n\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\tcodec: FieldCodec;\n\t} => {\n\t\tconst entry = fieldChangesetCodecs.get(fieldKind);\n\t\tassert(entry !== undefined, 0x5ea /* Tried to encode unsupported fieldKind */);\n\t\treturn entry;\n\t};\n\n\tfunction encodeFieldChangesForJson(\n\t\tchange: FieldChangeMap,\n\t\tcontext: ChangeEncodingContext,\n\t\tnodeChanges: ChangeAtomIdMap<NodeChangeset>,\n\t): EncodedFieldChangeMap {\n\t\tconst fieldContext: FieldChangeEncodingContext = {\n\t\t\tbaseContext: context,\n\n\t\t\tencodeNode: (nodeId: NodeId): EncodedNodeChangeset => {\n\t\t\t\tconst node = tryGetFromNestedMap(nodeChanges, nodeId.revision, nodeId.localId);\n\t\t\t\tassert(node !== undefined, 0x92e /* Unknown node ID */);\n\t\t\t\treturn encodeNodeChangesForJson(node, fieldContext);\n\t\t\t},\n\n\t\t\tdecodeNode: () => fail(\"Should not decode nodes during field encoding\"),\n\t\t};\n\n\t\treturn encodeFieldChangesForJsonI(change, fieldContext);\n\t}\n\n\tfunction encodeFieldChangesForJsonI(\n\t\tchange: FieldChangeMap,\n\t\tcontext: FieldChangeEncodingContext,\n\t): EncodedFieldChangeMap {\n\t\tconst encodedFields: EncodedFieldChangeMap = [];\n\n\t\tfor (const [field, fieldChange] of change) {\n\t\t\tconst { codec, compiledSchema } = getFieldChangesetCodec(fieldChange.fieldKind);\n\t\t\tconst encodedChange = codec.json.encode(fieldChange.change, context);\n\t\t\tif (compiledSchema !== undefined && !compiledSchema.check(encodedChange)) {\n\t\t\t\tfail(\"Encoded change didn't pass schema validation.\");\n\t\t\t}\n\n\t\t\tconst fieldKey: FieldKey = field;\n\t\t\tconst encodedField: EncodedFieldChange = {\n\t\t\t\tfieldKey,\n\t\t\t\tfieldKind: fieldChange.fieldKind,\n\t\t\t\tchange: encodedChange,\n\t\t\t};\n\n\t\t\tencodedFields.push(encodedField);\n\t\t}\n\n\t\treturn encodedFields;\n\t}\n\n\tfunction encodeNodeChangesForJson(\n\t\tchange: NodeChangeset,\n\t\tcontext: FieldChangeEncodingContext,\n\t): EncodedNodeChangeset {\n\t\tconst encodedChange: EncodedNodeChangeset = {};\n\t\tconst { fieldChanges, nodeExistsConstraint } = change;\n\n\t\tif (fieldChanges !== undefined) {\n\t\t\tencodedChange.fieldChanges = encodeFieldChangesForJsonI(fieldChanges, context);\n\t\t}\n\n\t\tif (nodeExistsConstraint !== undefined) {\n\t\t\tencodedChange.nodeExistsConstraint = nodeExistsConstraint;\n\t\t}\n\n\t\treturn encodedChange;\n\t}\n\n\tfunction decodeFieldChangesFromJson(\n\t\tencodedChange: EncodedFieldChangeMap,\n\t\tcontext: ChangeEncodingContext,\n\t\tidAllocator: IdAllocator,\n\t): [FieldChangeMap, ChangeAtomIdMap<NodeChangeset>] {\n\t\tconst decodedNodes: ChangeAtomIdMap<NodeChangeset> = new Map();\n\t\tconst fieldContext: FieldChangeEncodingContext = {\n\t\t\tbaseContext: context,\n\n\t\t\tencodeNode: () => fail(\"Should not encode nodes during field decoding\"),\n\n\t\t\tdecodeNode: (encodedNode: EncodedNodeChangeset): NodeId => {\n\t\t\t\tconst node = decodeNodeChangesetFromJson(encodedNode, fieldContext);\n\t\t\t\tconst nodeId: NodeId = {\n\t\t\t\t\trevision: context.revision,\n\t\t\t\t\tlocalId: brand(idAllocator.allocate()),\n\t\t\t\t};\n\t\t\t\tsetInNestedMap(decodedNodes, nodeId.revision, nodeId.localId, node);\n\t\t\t\treturn nodeId;\n\t\t\t},\n\t\t};\n\n\t\tconst decodedFields = decodeFieldChangesFromJsonI(encodedChange, fieldContext);\n\t\treturn [decodedFields, decodedNodes];\n\t}\n\n\tfunction decodeFieldChangesFromJsonI(\n\t\tencodedChange: EncodedFieldChangeMap,\n\t\tcontext: FieldChangeEncodingContext,\n\t): FieldChangeMap {\n\t\tconst decodedFields: FieldChangeMap = new Map();\n\t\tfor (const field of encodedChange) {\n\t\t\tconst { codec, compiledSchema } = getFieldChangesetCodec(field.fieldKind);\n\t\t\tif (compiledSchema !== undefined && !compiledSchema.check(field.change)) {\n\t\t\t\tfail(\"Encoded change didn't pass schema validation.\");\n\t\t\t}\n\t\t\tconst fieldChangeset = codec.json.decode(field.change, context);\n\n\t\t\tconst fieldKey: FieldKey = brand<FieldKey>(field.fieldKey);\n\n\t\t\tdecodedFields.set(fieldKey, {\n\t\t\t\tfieldKind: field.fieldKind,\n\t\t\t\tchange: brand(fieldChangeset),\n\t\t\t});\n\t\t}\n\n\t\treturn decodedFields;\n\t}\n\n\tfunction decodeNodeChangesetFromJson(\n\t\tencodedChange: EncodedNodeChangeset,\n\t\tcontext: FieldChangeEncodingContext,\n\t): NodeChangeset {\n\t\tconst decodedChange: NodeChangeset = {};\n\t\tconst { fieldChanges, nodeExistsConstraint } = encodedChange;\n\n\t\tif (fieldChanges !== undefined) {\n\t\t\tdecodedChange.fieldChanges = decodeFieldChangesFromJsonI(fieldChanges, context);\n\t\t}\n\n\t\tif (nodeExistsConstraint !== undefined) {\n\t\t\tdecodedChange.nodeExistsConstraint = nodeExistsConstraint;\n\t\t}\n\n\t\treturn decodedChange;\n\t}\n\n\tfunction encodeDetachedNodes(\n\t\tdetachedNodes: ChangeAtomIdMap<TreeChunk> | undefined,\n\t\tcontext: ChangeEncodingContext,\n\t): EncodedBuilds | undefined {\n\t\tif (detachedNodes === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst treesToEncode: ITreeCursorSynchronous[] = [];\n\t\tconst buildsArray: EncodedBuildsArray = Array.from(detachedNodes.entries()).map(\n\t\t\t([r, commitBuilds]) => {\n\t\t\t\tconst commitBuildsEncoded: [ChangesetLocalId, number][] = Array.from(\n\t\t\t\t\tcommitBuilds.entries(),\n\t\t\t\t).map(([i, t]) => {\n\t\t\t\t\ttreesToEncode.push(t.cursor());\n\t\t\t\t\tconst treeIndexInBatch = treesToEncode.length - 1;\n\t\t\t\t\treturn [i, treeIndexInBatch];\n\t\t\t\t});\n\t\t\t\t// `undefined` does not round-trip through JSON strings, so it needs special handling.\n\t\t\t\t// Most entries will have an undefined revision due to the revision information being inherited from the `ModularChangeset`.\n\t\t\t\t// We therefore optimize for the common case by omitting the revision when it is undefined.\n\t\t\t\treturn r === undefined || r === context.revision\n\t\t\t\t\t? [commitBuildsEncoded]\n\t\t\t\t\t: [commitBuildsEncoded, revisionTagCodec.encode(r, context)];\n\t\t\t},\n\t\t);\n\t\treturn buildsArray.length === 0\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tbuilds: buildsArray,\n\t\t\t\t\ttrees: fieldsCodec.encode(treesToEncode, {\n\t\t\t\t\t\tencodeType: chunkCompressionStrategy,\n\t\t\t\t\t\tschema: context.schema,\n\t\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t}),\n\t\t\t\t};\n\t}\n\n\tfunction decodeDetachedNodes(\n\t\tencoded: EncodedBuilds | undefined,\n\t\tcontext: ChangeEncodingContext,\n\t): ChangeAtomIdMap<TreeChunk> | undefined {\n\t\tif (encoded === undefined || encoded.builds.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst chunks = fieldsCodec.decode(encoded.trees, {\n\t\t\tencodeType: chunkCompressionStrategy,\n\t\t\toriginatorId: context.originatorId,\n\t\t\tidCompressor: context.idCompressor,\n\t\t});\n\t\tconst getChunk = (index: number): TreeChunk => {\n\t\t\tassert(index < chunks.length, 0x898 /* out of bounds index for build chunk */);\n\t\t\treturn chunkFieldSingle(chunks[index], defaultChunkPolicy);\n\t\t};\n\n\t\tconst map: ModularChangeset[\"builds\"] = new Map();\n\t\tencoded.builds.forEach((build) => {\n\t\t\t// EncodedRevisionTag cannot be an array so this ensures that we can isolate the tuple\n\t\t\tconst revision =\n\t\t\t\tbuild[1] === undefined ? context.revision : revisionTagCodec.decode(build[1], context);\n\t\t\tmap.set(revision, new Map(build[0].map(([i, n]) => [i, getChunk(n)])));\n\t\t});\n\n\t\treturn map;\n\t}\n\n\tfunction encodeRevisionInfos(\n\t\trevisions: readonly RevisionInfo[],\n\t\tcontext: ChangeEncodingContext,\n\t): EncodedRevisionInfo[] | undefined {\n\t\tif (context.revision !== undefined) {\n\t\t\tassert(\n\t\t\t\trevisions.length === 1 &&\n\t\t\t\t\trevisions[0].revision === context.revision &&\n\t\t\t\t\trevisions[0].rollbackOf === undefined,\n\t\t\t\t0x964 /* A tagged change should only contain the tagged revision */,\n\t\t\t);\n\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst encodedRevisions = [];\n\t\tfor (const revision of revisions) {\n\t\t\tconst encodedRevision: Mutable<EncodedRevisionInfo> = {\n\t\t\t\trevision: revisionTagCodec.encode(revision.revision, context),\n\t\t\t};\n\n\t\t\tif (revision.rollbackOf !== undefined) {\n\t\t\t\tencodedRevision.rollbackOf = revisionTagCodec.encode(revision.rollbackOf, context);\n\t\t\t}\n\n\t\t\tencodedRevisions.push(encodedRevision);\n\t\t}\n\n\t\treturn encodedRevisions;\n\t}\n\n\tfunction decodeRevisionInfos(\n\t\trevisions: readonly EncodedRevisionInfo[] | undefined,\n\t\tcontext: ChangeEncodingContext,\n\t): RevisionInfo[] | undefined {\n\t\tif (revisions === undefined) {\n\t\t\treturn context.revision !== undefined ? [{ revision: context.revision }] : undefined;\n\t\t}\n\n\t\tconst decodedRevisions = [];\n\t\tfor (const revision of revisions) {\n\t\t\tconst decodedRevision: Mutable<RevisionInfo> = {\n\t\t\t\trevision: revisionTagCodec.decode(revision.revision, context),\n\t\t\t};\n\n\t\t\tif (revision.rollbackOf !== undefined) {\n\t\t\t\tdecodedRevision.rollbackOf = revisionTagCodec.decode(revision.rollbackOf, context);\n\t\t\t}\n\n\t\t\tdecodedRevisions.push(decodedRevision);\n\t\t}\n\n\t\treturn decodedRevisions;\n\t}\n\n\tconst modularChangeCodec: ModularChangeCodec = {\n\t\tencode: (change, context) => {\n\t\t\t// Destroys only exist in rollback changesets, which are never sent.\n\t\t\tassert(change.destroys === undefined, 0x899 /* Unexpected changeset with destroys */);\n\t\t\treturn {\n\t\t\t\tmaxId: change.maxId,\n\t\t\t\trevisions:\n\t\t\t\t\tchange.revisions === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: encodeRevisionInfos(change.revisions, context),\n\t\t\t\tchanges: encodeFieldChangesForJson(change.fieldChanges, context, change.nodeChanges),\n\t\t\t\tbuilds: encodeDetachedNodes(change.builds, context),\n\t\t\t\trefreshers: encodeDetachedNodes(change.refreshers, context),\n\t\t\t};\n\t\t},\n\n\t\tdecode: (encodedChange: EncodedModularChangeset, context) => {\n\t\t\tconst [fieldChanges, nodeChanges] = decodeFieldChangesFromJson(\n\t\t\t\tencodedChange.changes,\n\t\t\t\tcontext,\n\t\t\t\tidAllocatorFromMaxId(encodedChange.maxId),\n\t\t\t);\n\t\t\tconst decoded: Mutable<ModularChangeset> = {\n\t\t\t\tfieldChanges,\n\t\t\t\tnodeChanges,\n\t\t\t};\n\n\t\t\tif (encodedChange.builds !== undefined) {\n\t\t\t\tdecoded.builds = decodeDetachedNodes(encodedChange.builds, context);\n\t\t\t}\n\t\t\tif (encodedChange.refreshers !== undefined) {\n\t\t\t\tdecoded.refreshers = decodeDetachedNodes(encodedChange.builds, context);\n\t\t\t}\n\n\t\t\tconst decodedRevInfos = decodeRevisionInfos(encodedChange.revisions, context);\n\t\t\tif (decodedRevInfos !== undefined) {\n\t\t\t\tdecoded.revisions = decodedRevInfos;\n\t\t\t}\n\t\t\tif (encodedChange.maxId !== undefined) {\n\t\t\t\tdecoded.maxId = encodedChange.maxId;\n\t\t\t}\n\t\t\treturn decoded;\n\t\t},\n\t};\n\n\treturn withSchemaValidation(EncodedModularChangeset, modularChangeCodec, validator);\n}\n"]}
1
+ {"version":3,"file":"modularChangeCodecs.js","sourceRoot":"","sources":["../../../src/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AE,CAAC;gBACnC,OAAO,CAAC,SAAS,GAAG,eAAe,CAAC;YACrC,CAAC;YACD,IAAI,aAAa,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBACvC,OAAO,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;YACrC,CAAC;YACD,OAAO,OAAO,CAAC;QAChB,CAAC;KACD,CAAC;IAEF,OAAO,IAAA,+BAAoB,EAAC,gDAAuB,EAAE,kBAAkB,EAAE,SAAS,CAAC,CAAC;AACrF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { TAnySchema } from \"@sinclair/typebox\";\n\nimport {\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\ttype IMultiFormatCodec,\n\ttype SchemaValidationFunction,\n\tmakeCodecFamily,\n\twithSchemaValidation,\n} from \"../../codec/index.js\";\nimport type {\n\tChangeAtomIdMap,\n\tChangeEncodingContext,\n\tChangesetLocalId,\n\tEncodedRevisionTag,\n\tFieldKey,\n\tFieldKindIdentifier,\n\tITreeCursorSynchronous,\n\tRevisionInfo,\n\tRevisionTag,\n} from \"../../core/index.js\";\nimport {\n\ttype IdAllocator,\n\ttype JsonCompatibleReadOnly,\n\ttype Mutable,\n\tbrand,\n\tfail,\n\tidAllocatorFromMaxId,\n\tsetInNestedMap,\n\ttryGetFromNestedMap,\n} from \"../../util/index.js\";\nimport {\n\ttype FieldBatchCodec,\n\ttype TreeChunk,\n\tchunkFieldSingle,\n\tdefaultChunkPolicy,\n} from \"../chunked-forest/index.js\";\nimport { TreeCompressionStrategy } from \"../treeCompressionUtils.js\";\n\nimport type {\n\tFieldKindConfiguration,\n\tFieldKindConfigurationEntry,\n} from \"./fieldKindConfiguration.js\";\nimport { genericFieldKind } from \"./genericFieldKind.js\";\nimport {\n\ttype EncodedBuilds,\n\ttype EncodedBuildsArray,\n\ttype EncodedFieldChange,\n\ttype EncodedFieldChangeMap,\n\tEncodedModularChangeset,\n\ttype EncodedNodeChangeset,\n\ttype EncodedRevisionInfo,\n} from \"./modularChangeFormat.js\";\nimport type {\n\tFieldChangeMap,\n\tFieldChangeset,\n\tModularChangeset,\n\tNodeChangeset,\n\tNodeId,\n} from \"./modularChangeTypes.js\";\nimport type { FieldChangeEncodingContext } from \"./fieldChangeHandler.js\";\n\nexport function makeModularChangeCodecFamily(\n\tfieldKindConfigurations: ReadonlyMap<number, FieldKindConfiguration>,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\t{ jsonValidator: validator }: ICodecOptions,\n\tchunkCompressionStrategy: TreeCompressionStrategy = TreeCompressionStrategy.Compressed,\n): ICodecFamily<ModularChangeset, ChangeEncodingContext> {\n\treturn makeCodecFamily(\n\t\tArray.from(fieldKindConfigurations.entries(), ([version, fieldKinds]) => [\n\t\t\tversion,\n\t\t\tmakeModularChangeCodec(\n\t\t\t\tfieldKinds,\n\t\t\t\trevisionTagCodec,\n\t\t\t\tfieldsCodec,\n\t\t\t\t{ jsonValidator: validator },\n\t\t\t\tchunkCompressionStrategy,\n\t\t\t),\n\t\t]),\n\t);\n}\n\ntype ModularChangeCodec = IJsonCodec<\n\tModularChangeset,\n\tEncodedModularChangeset,\n\tEncodedModularChangeset,\n\tChangeEncodingContext\n>;\n\ntype FieldCodec = IMultiFormatCodec<\n\tFieldChangeset,\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnly,\n\tFieldChangeEncodingContext\n>;\n\nfunction makeModularChangeCodec(\n\tfieldKinds: FieldKindConfiguration,\n\trevisionTagCodec: IJsonCodec<\n\t\tRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tEncodedRevisionTag,\n\t\tChangeEncodingContext\n\t>,\n\tfieldsCodec: FieldBatchCodec,\n\t{ jsonValidator: validator }: ICodecOptions,\n\tchunkCompressionStrategy: TreeCompressionStrategy = TreeCompressionStrategy.Compressed,\n): ModularChangeCodec {\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tconst getMapEntry = ({ kind, formatVersion }: FieldKindConfigurationEntry) => {\n\t\tconst codec = kind.changeHandler.codecsFactory(revisionTagCodec).resolve(formatVersion);\n\t\treturn {\n\t\t\tcodec,\n\t\t\tcompiledSchema: codec.json.encodedSchema\n\t\t\t\t? validator.compile(codec.json.encodedSchema)\n\t\t\t\t: undefined,\n\t\t};\n\t};\n\n\t/**\n\t * The codec version for the generic field kind.\n\t */\n\tconst genericFieldKindFormatVersion = 1;\n\tconst fieldChangesetCodecs: Map<\n\t\tFieldKindIdentifier,\n\t\t{\n\t\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\t\tcodec: FieldCodec;\n\t\t}\n\t> = new Map([\n\t\t[\n\t\t\tgenericFieldKind.identifier,\n\t\t\tgetMapEntry({ kind: genericFieldKind, formatVersion: genericFieldKindFormatVersion }),\n\t\t],\n\t]);\n\n\tfieldKinds.forEach((entry, identifier) => {\n\t\tfieldChangesetCodecs.set(identifier, getMapEntry(entry));\n\t});\n\n\tconst getFieldChangesetCodec = (\n\t\tfieldKind: FieldKindIdentifier,\n\t): {\n\t\tcompiledSchema?: SchemaValidationFunction<TAnySchema>;\n\t\tcodec: FieldCodec;\n\t} => {\n\t\tconst entry = fieldChangesetCodecs.get(fieldKind);\n\t\tassert(entry !== undefined, 0x5ea /* Tried to encode unsupported fieldKind */);\n\t\treturn entry;\n\t};\n\n\tfunction encodeFieldChangesForJson(\n\t\tchange: FieldChangeMap,\n\t\tcontext: ChangeEncodingContext,\n\t\tnodeChanges: ChangeAtomIdMap<NodeChangeset>,\n\t): EncodedFieldChangeMap {\n\t\tconst fieldContext: FieldChangeEncodingContext = {\n\t\t\tbaseContext: context,\n\n\t\t\tencodeNode: (nodeId: NodeId): EncodedNodeChangeset => {\n\t\t\t\tconst node = tryGetFromNestedMap(nodeChanges, nodeId.revision, nodeId.localId);\n\t\t\t\tassert(node !== undefined, 0x92e /* Unknown node ID */);\n\t\t\t\treturn encodeNodeChangesForJson(node, fieldContext);\n\t\t\t},\n\n\t\t\tdecodeNode: () => fail(\"Should not decode nodes during field encoding\"),\n\t\t};\n\n\t\treturn encodeFieldChangesForJsonI(change, fieldContext);\n\t}\n\n\tfunction encodeFieldChangesForJsonI(\n\t\tchange: FieldChangeMap,\n\t\tcontext: FieldChangeEncodingContext,\n\t): EncodedFieldChangeMap {\n\t\tconst encodedFields: EncodedFieldChangeMap = [];\n\n\t\tfor (const [field, fieldChange] of change) {\n\t\t\tconst { codec, compiledSchema } = getFieldChangesetCodec(fieldChange.fieldKind);\n\t\t\tconst encodedChange = codec.json.encode(fieldChange.change, context);\n\t\t\tif (compiledSchema !== undefined && !compiledSchema.check(encodedChange)) {\n\t\t\t\tfail(\"Encoded change didn't pass schema validation.\");\n\t\t\t}\n\n\t\t\tconst fieldKey: FieldKey = field;\n\t\t\tconst encodedField: EncodedFieldChange = {\n\t\t\t\tfieldKey,\n\t\t\t\tfieldKind: fieldChange.fieldKind,\n\t\t\t\tchange: encodedChange,\n\t\t\t};\n\n\t\t\tencodedFields.push(encodedField);\n\t\t}\n\n\t\treturn encodedFields;\n\t}\n\n\tfunction encodeNodeChangesForJson(\n\t\tchange: NodeChangeset,\n\t\tcontext: FieldChangeEncodingContext,\n\t): EncodedNodeChangeset {\n\t\tconst encodedChange: EncodedNodeChangeset = {};\n\t\tconst { fieldChanges, nodeExistsConstraint } = change;\n\n\t\tif (fieldChanges !== undefined) {\n\t\t\tencodedChange.fieldChanges = encodeFieldChangesForJsonI(fieldChanges, context);\n\t\t}\n\n\t\tif (nodeExistsConstraint !== undefined) {\n\t\t\tencodedChange.nodeExistsConstraint = nodeExistsConstraint;\n\t\t}\n\n\t\treturn encodedChange;\n\t}\n\n\tfunction decodeFieldChangesFromJson(\n\t\tencodedChange: EncodedFieldChangeMap,\n\t\tcontext: ChangeEncodingContext,\n\t\tidAllocator: IdAllocator,\n\t): [FieldChangeMap, ChangeAtomIdMap<NodeChangeset>] {\n\t\tconst decodedNodes: ChangeAtomIdMap<NodeChangeset> = new Map();\n\t\tconst fieldContext: FieldChangeEncodingContext = {\n\t\t\tbaseContext: context,\n\n\t\t\tencodeNode: () => fail(\"Should not encode nodes during field decoding\"),\n\n\t\t\tdecodeNode: (encodedNode: EncodedNodeChangeset): NodeId => {\n\t\t\t\tconst node = decodeNodeChangesetFromJson(encodedNode, fieldContext);\n\t\t\t\tconst nodeId: NodeId = {\n\t\t\t\t\trevision: context.revision,\n\t\t\t\t\tlocalId: brand(idAllocator.allocate()),\n\t\t\t\t};\n\t\t\t\tsetInNestedMap(decodedNodes, nodeId.revision, nodeId.localId, node);\n\t\t\t\treturn nodeId;\n\t\t\t},\n\t\t};\n\n\t\tconst decodedFields = decodeFieldChangesFromJsonI(encodedChange, fieldContext);\n\t\treturn [decodedFields, decodedNodes];\n\t}\n\n\tfunction decodeFieldChangesFromJsonI(\n\t\tencodedChange: EncodedFieldChangeMap,\n\t\tcontext: FieldChangeEncodingContext,\n\t): FieldChangeMap {\n\t\tconst decodedFields: FieldChangeMap = new Map();\n\t\tfor (const field of encodedChange) {\n\t\t\tconst { codec, compiledSchema } = getFieldChangesetCodec(field.fieldKind);\n\t\t\tif (compiledSchema !== undefined && !compiledSchema.check(field.change)) {\n\t\t\t\tfail(\"Encoded change didn't pass schema validation.\");\n\t\t\t}\n\t\t\tconst fieldChangeset = codec.json.decode(field.change, context);\n\n\t\t\tconst fieldKey: FieldKey = brand<FieldKey>(field.fieldKey);\n\n\t\t\tdecodedFields.set(fieldKey, {\n\t\t\t\tfieldKind: field.fieldKind,\n\t\t\t\tchange: brand(fieldChangeset),\n\t\t\t});\n\t\t}\n\n\t\treturn decodedFields;\n\t}\n\n\tfunction decodeNodeChangesetFromJson(\n\t\tencodedChange: EncodedNodeChangeset,\n\t\tcontext: FieldChangeEncodingContext,\n\t): NodeChangeset {\n\t\tconst decodedChange: NodeChangeset = {};\n\t\tconst { fieldChanges, nodeExistsConstraint } = encodedChange;\n\n\t\tif (fieldChanges !== undefined) {\n\t\t\tdecodedChange.fieldChanges = decodeFieldChangesFromJsonI(fieldChanges, context);\n\t\t}\n\n\t\tif (nodeExistsConstraint !== undefined) {\n\t\t\tdecodedChange.nodeExistsConstraint = nodeExistsConstraint;\n\t\t}\n\n\t\treturn decodedChange;\n\t}\n\n\tfunction encodeDetachedNodes(\n\t\tdetachedNodes: ChangeAtomIdMap<TreeChunk> | undefined,\n\t\tcontext: ChangeEncodingContext,\n\t): EncodedBuilds | undefined {\n\t\tif (detachedNodes === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst treesToEncode: ITreeCursorSynchronous[] = [];\n\t\tconst buildsArray: EncodedBuildsArray = Array.from(detachedNodes.entries()).map(\n\t\t\t([r, commitBuilds]) => {\n\t\t\t\tconst commitBuildsEncoded: [ChangesetLocalId, number][] = Array.from(\n\t\t\t\t\tcommitBuilds.entries(),\n\t\t\t\t).map(([i, t]) => {\n\t\t\t\t\ttreesToEncode.push(t.cursor());\n\t\t\t\t\tconst treeIndexInBatch = treesToEncode.length - 1;\n\t\t\t\t\treturn [i, treeIndexInBatch];\n\t\t\t\t});\n\t\t\t\t// `undefined` does not round-trip through JSON strings, so it needs special handling.\n\t\t\t\t// Most entries will have an undefined revision due to the revision information being inherited from the `ModularChangeset`.\n\t\t\t\t// We therefore optimize for the common case by omitting the revision when it is undefined.\n\t\t\t\treturn r === undefined || r === context.revision\n\t\t\t\t\t? [commitBuildsEncoded]\n\t\t\t\t\t: [commitBuildsEncoded, revisionTagCodec.encode(r, context)];\n\t\t\t},\n\t\t);\n\t\treturn buildsArray.length === 0\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tbuilds: buildsArray,\n\t\t\t\t\ttrees: fieldsCodec.encode(treesToEncode, {\n\t\t\t\t\t\tencodeType: chunkCompressionStrategy,\n\t\t\t\t\t\tschema: context.schema,\n\t\t\t\t\t\toriginatorId: context.originatorId,\n\t\t\t\t\t\tidCompressor: context.idCompressor,\n\t\t\t\t\t}),\n\t\t\t\t};\n\t}\n\n\tfunction decodeDetachedNodes(\n\t\tencoded: EncodedBuilds | undefined,\n\t\tcontext: ChangeEncodingContext,\n\t): ChangeAtomIdMap<TreeChunk> | undefined {\n\t\tif (encoded === undefined || encoded.builds.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst chunks = fieldsCodec.decode(encoded.trees, {\n\t\t\tencodeType: chunkCompressionStrategy,\n\t\t\toriginatorId: context.originatorId,\n\t\t\tidCompressor: context.idCompressor,\n\t\t});\n\t\tconst getChunk = (index: number): TreeChunk => {\n\t\t\tassert(index < chunks.length, 0x898 /* out of bounds index for build chunk */);\n\t\t\treturn chunkFieldSingle(chunks[index], defaultChunkPolicy);\n\t\t};\n\n\t\tconst map: ModularChangeset[\"builds\"] = new Map();\n\t\tencoded.builds.forEach((build) => {\n\t\t\t// EncodedRevisionTag cannot be an array so this ensures that we can isolate the tuple\n\t\t\tconst revision =\n\t\t\t\tbuild[1] === undefined ? context.revision : revisionTagCodec.decode(build[1], context);\n\t\t\tmap.set(revision, new Map(build[0].map(([i, n]) => [i, getChunk(n)])));\n\t\t});\n\n\t\treturn map;\n\t}\n\n\tfunction encodeRevisionInfos(\n\t\trevisions: readonly RevisionInfo[],\n\t\tcontext: ChangeEncodingContext,\n\t): EncodedRevisionInfo[] | undefined {\n\t\tif (context.revision !== undefined) {\n\t\t\tassert(\n\t\t\t\trevisions.length === 1 &&\n\t\t\t\t\trevisions[0].revision === context.revision &&\n\t\t\t\t\trevisions[0].rollbackOf === undefined,\n\t\t\t\t0x964 /* A tagged change should only contain the tagged revision */,\n\t\t\t);\n\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst encodedRevisions = [];\n\t\tfor (const revision of revisions) {\n\t\t\tconst encodedRevision: Mutable<EncodedRevisionInfo> = {\n\t\t\t\trevision: revisionTagCodec.encode(revision.revision, context),\n\t\t\t};\n\n\t\t\tif (revision.rollbackOf !== undefined) {\n\t\t\t\tencodedRevision.rollbackOf = revisionTagCodec.encode(revision.rollbackOf, context);\n\t\t\t}\n\n\t\t\tencodedRevisions.push(encodedRevision);\n\t\t}\n\n\t\treturn encodedRevisions;\n\t}\n\n\tfunction decodeRevisionInfos(\n\t\trevisions: readonly EncodedRevisionInfo[] | undefined,\n\t\tcontext: ChangeEncodingContext,\n\t): RevisionInfo[] | undefined {\n\t\tif (revisions === undefined) {\n\t\t\treturn context.revision !== undefined ? [{ revision: context.revision }] : undefined;\n\t\t}\n\n\t\tconst decodedRevisions = [];\n\t\tfor (const revision of revisions) {\n\t\t\tconst decodedRevision: Mutable<RevisionInfo> = {\n\t\t\t\trevision: revisionTagCodec.decode(revision.revision, context),\n\t\t\t};\n\n\t\t\tif (revision.rollbackOf !== undefined) {\n\t\t\t\tdecodedRevision.rollbackOf = revisionTagCodec.decode(revision.rollbackOf, context);\n\t\t\t}\n\n\t\t\tdecodedRevisions.push(decodedRevision);\n\t\t}\n\n\t\treturn decodedRevisions;\n\t}\n\n\tconst modularChangeCodec: ModularChangeCodec = {\n\t\tencode: (change, context) => {\n\t\t\t// Destroys only exist in rollback changesets, which are never sent.\n\t\t\tassert(change.destroys === undefined, 0x899 /* Unexpected changeset with destroys */);\n\t\t\treturn {\n\t\t\t\tmaxId: change.maxId,\n\t\t\t\trevisions:\n\t\t\t\t\tchange.revisions === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: encodeRevisionInfos(change.revisions, context),\n\t\t\t\tchanges: encodeFieldChangesForJson(change.fieldChanges, context, change.nodeChanges),\n\t\t\t\tbuilds: encodeDetachedNodes(change.builds, context),\n\t\t\t\trefreshers: encodeDetachedNodes(change.refreshers, context),\n\t\t\t\tviolations: change.constraintViolationCount,\n\t\t\t};\n\t\t},\n\n\t\tdecode: (encodedChange: EncodedModularChangeset, context) => {\n\t\t\tconst [fieldChanges, nodeChanges] = decodeFieldChangesFromJson(\n\t\t\t\tencodedChange.changes,\n\t\t\t\tcontext,\n\t\t\t\tidAllocatorFromMaxId(encodedChange.maxId),\n\t\t\t);\n\t\t\tconst decoded: Mutable<ModularChangeset> = {\n\t\t\t\tfieldChanges,\n\t\t\t\tnodeChanges,\n\t\t\t};\n\n\t\t\tif (encodedChange.builds !== undefined) {\n\t\t\t\tdecoded.builds = decodeDetachedNodes(encodedChange.builds, context);\n\t\t\t}\n\t\t\tif (encodedChange.refreshers !== undefined) {\n\t\t\t\tdecoded.refreshers = decodeDetachedNodes(encodedChange.builds, context);\n\t\t\t}\n\n\t\t\tif (encodedChange.violations !== undefined) {\n\t\t\t\tdecoded.constraintViolationCount = encodedChange.violations;\n\t\t\t}\n\n\t\t\tconst decodedRevInfos = decodeRevisionInfos(encodedChange.revisions, context);\n\t\t\tif (decodedRevInfos !== undefined) {\n\t\t\t\tdecoded.revisions = decodedRevInfos;\n\t\t\t}\n\t\t\tif (encodedChange.maxId !== undefined) {\n\t\t\t\tdecoded.maxId = encodedChange.maxId;\n\t\t\t}\n\t\t\treturn decoded;\n\t\t},\n\t};\n\n\treturn withSchemaValidation(EncodedModularChangeset, modularChangeCodec, validator);\n}\n"]}
@@ -149,6 +149,10 @@ export declare const EncodedModularChangeset: import("@sinclair/typebox").TObjec
149
149
  }>>;
150
150
  }>;
151
151
  }>>;
152
+ /**
153
+ * The number of constraints within this changeset that are violated.
154
+ */
155
+ violations: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
152
156
  }>;
153
157
  export type EncodedModularChangeset = Static<typeof EncodedModularChangeset>;
154
158
  export {};