@fluidframework/tree 2.31.1 → 2.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/.vscode/settings.json +1 -1
  2. package/CHANGELOG.md +44 -0
  3. package/api-extractor/api-extractor.current.json +5 -1
  4. package/api-report/tree.alpha.api.md +44 -20
  5. package/dist/alpha.d.ts +6 -2
  6. package/dist/feature-libraries/flex-tree/context.d.ts +1 -1
  7. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  8. package/dist/feature-libraries/flex-tree/context.js +1 -2
  9. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  10. package/dist/feature-libraries/flex-tree/index.d.ts +1 -1
  11. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  12. package/dist/feature-libraries/flex-tree/index.js +1 -2
  13. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  14. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +6 -15
  15. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  16. package/dist/feature-libraries/flex-tree/lazyEntity.js +9 -18
  17. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  18. package/dist/feature-libraries/flex-tree/lazyField.d.ts +3 -3
  19. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  20. package/dist/feature-libraries/flex-tree/lazyField.js +14 -14
  21. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  22. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +4 -4
  23. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  24. package/dist/feature-libraries/flex-tree/lazyNode.js +12 -12
  25. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  26. package/dist/feature-libraries/index.d.ts +1 -1
  27. package/dist/feature-libraries/index.d.ts.map +1 -1
  28. package/dist/feature-libraries/index.js +1 -2
  29. package/dist/feature-libraries/index.js.map +1 -1
  30. package/dist/index.d.ts +2 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +5 -2
  33. package/dist/index.js.map +1 -1
  34. package/dist/packageVersion.d.ts +1 -1
  35. package/dist/packageVersion.js +1 -1
  36. package/dist/packageVersion.js.map +1 -1
  37. package/dist/shared-tree/sharedTree.js +2 -2
  38. package/dist/shared-tree/sharedTree.js.map +1 -1
  39. package/dist/shared-tree/treeApiAlpha.d.ts +6 -6
  40. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
  41. package/dist/shared-tree/treeApiAlpha.js.map +1 -1
  42. package/dist/shared-tree-core/sharedTreeCore.d.ts +0 -6
  43. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  44. package/dist/shared-tree-core/sharedTreeCore.js +0 -17
  45. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  46. package/dist/simple-tree/api/conciseTree.d.ts +2 -2
  47. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  48. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  49. package/dist/simple-tree/api/customTree.d.ts +14 -12
  50. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  51. package/dist/simple-tree/api/customTree.js.map +1 -1
  52. package/dist/simple-tree/api/getJsonSchema.d.ts +21 -7
  53. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  54. package/dist/simple-tree/api/getJsonSchema.js +8 -16
  55. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  56. package/dist/simple-tree/api/getSimpleSchema.d.ts +3 -10
  57. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  58. package/dist/simple-tree/api/getSimpleSchema.js +4 -16
  59. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  60. package/dist/simple-tree/api/index.d.ts +4 -3
  61. package/dist/simple-tree/api/index.d.ts.map +1 -1
  62. package/dist/simple-tree/api/index.js +2 -1
  63. package/dist/simple-tree/api/index.js.map +1 -1
  64. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
  65. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  66. package/dist/simple-tree/api/schemaFactoryAlpha.js +4 -0
  67. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  68. package/dist/simple-tree/api/schemaFromSimple.d.ts +5 -2
  69. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  70. package/dist/simple-tree/api/schemaFromSimple.js +24 -8
  71. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  72. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +11 -3
  73. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  74. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +40 -28
  75. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  76. package/dist/simple-tree/api/tree.d.ts +32 -5
  77. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  78. package/dist/simple-tree/api/tree.js +17 -1
  79. package/dist/simple-tree/api/tree.js.map +1 -1
  80. package/dist/simple-tree/api/verboseTree.d.ts +4 -28
  81. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  82. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  83. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  84. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +7 -3
  85. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  86. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  87. package/dist/simple-tree/core/treeNodeKernel.js +7 -6
  88. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  89. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  90. package/dist/simple-tree/core/unhydratedFlexTree.js +12 -1
  91. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  92. package/dist/simple-tree/index.d.ts +1 -1
  93. package/dist/simple-tree/index.d.ts.map +1 -1
  94. package/dist/simple-tree/index.js +3 -2
  95. package/dist/simple-tree/index.js.map +1 -1
  96. package/dist/simple-tree/simpleSchema.d.ts +4 -11
  97. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  98. package/dist/simple-tree/simpleSchema.js.map +1 -1
  99. package/dist/tableSchema.d.ts +227 -0
  100. package/dist/tableSchema.d.ts.map +1 -0
  101. package/dist/tableSchema.js +234 -0
  102. package/dist/tableSchema.js.map +1 -0
  103. package/dist/treeFactory.d.ts +4 -4
  104. package/dist/treeFactory.d.ts.map +1 -1
  105. package/dist/treeFactory.js.map +1 -1
  106. package/dist/util/breakable.d.ts.map +1 -1
  107. package/dist/util/breakable.js +9 -7
  108. package/dist/util/breakable.js.map +1 -1
  109. package/lib/alpha.d.ts +6 -2
  110. package/lib/feature-libraries/flex-tree/context.d.ts +1 -1
  111. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  112. package/lib/feature-libraries/flex-tree/context.js +1 -2
  113. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  114. package/lib/feature-libraries/flex-tree/index.d.ts +1 -1
  115. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  116. package/lib/feature-libraries/flex-tree/index.js +1 -1
  117. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  118. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +6 -15
  119. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  120. package/lib/feature-libraries/flex-tree/lazyEntity.js +8 -17
  121. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  122. package/lib/feature-libraries/flex-tree/lazyField.d.ts +3 -3
  123. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  124. package/lib/feature-libraries/flex-tree/lazyField.js +15 -15
  125. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  126. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +4 -4
  127. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  128. package/lib/feature-libraries/flex-tree/lazyNode.js +13 -13
  129. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  130. package/lib/feature-libraries/index.d.ts +1 -1
  131. package/lib/feature-libraries/index.d.ts.map +1 -1
  132. package/lib/feature-libraries/index.js +1 -1
  133. package/lib/feature-libraries/index.js.map +1 -1
  134. package/lib/index.d.ts +2 -1
  135. package/lib/index.d.ts.map +1 -1
  136. package/lib/index.js +2 -1
  137. package/lib/index.js.map +1 -1
  138. package/lib/packageVersion.d.ts +1 -1
  139. package/lib/packageVersion.js +1 -1
  140. package/lib/packageVersion.js.map +1 -1
  141. package/lib/shared-tree/sharedTree.js +2 -2
  142. package/lib/shared-tree/sharedTree.js.map +1 -1
  143. package/lib/shared-tree/treeApiAlpha.d.ts +6 -6
  144. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
  145. package/lib/shared-tree/treeApiAlpha.js.map +1 -1
  146. package/lib/shared-tree-core/sharedTreeCore.d.ts +0 -6
  147. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  148. package/lib/shared-tree-core/sharedTreeCore.js +0 -17
  149. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  150. package/lib/simple-tree/api/conciseTree.d.ts +2 -2
  151. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  152. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  153. package/lib/simple-tree/api/customTree.d.ts +14 -12
  154. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  155. package/lib/simple-tree/api/customTree.js.map +1 -1
  156. package/lib/simple-tree/api/getJsonSchema.d.ts +21 -7
  157. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  158. package/lib/simple-tree/api/getJsonSchema.js +8 -16
  159. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  160. package/lib/simple-tree/api/getSimpleSchema.d.ts +3 -10
  161. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  162. package/lib/simple-tree/api/getSimpleSchema.js +4 -16
  163. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  164. package/lib/simple-tree/api/index.d.ts +4 -3
  165. package/lib/simple-tree/api/index.d.ts.map +1 -1
  166. package/lib/simple-tree/api/index.js +1 -1
  167. package/lib/simple-tree/api/index.js.map +1 -1
  168. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
  169. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  170. package/lib/simple-tree/api/schemaFactoryAlpha.js +4 -0
  171. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  172. package/lib/simple-tree/api/schemaFromSimple.d.ts +5 -2
  173. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  174. package/lib/simple-tree/api/schemaFromSimple.js +24 -8
  175. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  176. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +11 -3
  177. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  178. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +41 -29
  179. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  180. package/lib/simple-tree/api/tree.d.ts +32 -5
  181. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  182. package/lib/simple-tree/api/tree.js +16 -1
  183. package/lib/simple-tree/api/tree.js.map +1 -1
  184. package/lib/simple-tree/api/verboseTree.d.ts +4 -28
  185. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  186. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  187. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  188. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +7 -3
  189. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  190. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  191. package/lib/simple-tree/core/treeNodeKernel.js +8 -7
  192. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  193. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  194. package/lib/simple-tree/core/unhydratedFlexTree.js +12 -1
  195. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  196. package/lib/simple-tree/index.d.ts +1 -1
  197. package/lib/simple-tree/index.d.ts.map +1 -1
  198. package/lib/simple-tree/index.js +1 -1
  199. package/lib/simple-tree/index.js.map +1 -1
  200. package/lib/simple-tree/simpleSchema.d.ts +4 -11
  201. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  202. package/lib/simple-tree/simpleSchema.js.map +1 -1
  203. package/lib/tableSchema.d.ts +227 -0
  204. package/lib/tableSchema.d.ts.map +1 -0
  205. package/lib/tableSchema.js +231 -0
  206. package/lib/tableSchema.js.map +1 -0
  207. package/lib/treeFactory.d.ts +4 -4
  208. package/lib/treeFactory.d.ts.map +1 -1
  209. package/lib/treeFactory.js.map +1 -1
  210. package/lib/util/breakable.d.ts.map +1 -1
  211. package/lib/util/breakable.js +9 -7
  212. package/lib/util/breakable.js.map +1 -1
  213. package/package.json +23 -22
  214. package/src/feature-libraries/flex-tree/context.ts +2 -2
  215. package/src/feature-libraries/flex-tree/index.ts +0 -1
  216. package/src/feature-libraries/flex-tree/lazyEntity.ts +11 -21
  217. package/src/feature-libraries/flex-tree/lazyField.ts +17 -26
  218. package/src/feature-libraries/flex-tree/lazyNode.ts +13 -19
  219. package/src/feature-libraries/index.ts +0 -1
  220. package/src/index.ts +6 -2
  221. package/src/packageVersion.ts +1 -1
  222. package/src/shared-tree/sharedTree.ts +2 -2
  223. package/src/shared-tree/treeApiAlpha.ts +17 -15
  224. package/src/shared-tree-core/sharedTreeCore.ts +0 -23
  225. package/src/simple-tree/api/conciseTree.ts +4 -4
  226. package/src/simple-tree/api/customTree.ts +16 -14
  227. package/src/simple-tree/api/getJsonSchema.ts +25 -16
  228. package/src/simple-tree/api/getSimpleSchema.ts +4 -18
  229. package/src/simple-tree/api/index.ts +4 -2
  230. package/src/simple-tree/api/schemaFactoryAlpha.ts +18 -1
  231. package/src/simple-tree/api/schemaFromSimple.ts +45 -16
  232. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +53 -34
  233. package/src/simple-tree/api/tree.ts +51 -4
  234. package/src/simple-tree/api/verboseTree.ts +7 -32
  235. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +8 -3
  236. package/src/simple-tree/core/treeNodeKernel.ts +11 -7
  237. package/src/simple-tree/core/unhydratedFlexTree.ts +17 -4
  238. package/src/simple-tree/index.ts +4 -2
  239. package/src/simple-tree/simpleSchema.ts +4 -12
  240. package/src/tableSchema.ts +609 -0
  241. package/src/treeFactory.ts +4 -3
  242. package/src/util/breakable.ts +9 -6
@@ -1 +1 @@
1
- {"version":3,"file":"treeNodeKernel.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeKernel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,kEAAyE;AACzE,+DAA6D;AAG7D,kDAO6B;AAC7B,+DAS0C;AAE1C,0EAA0E;AAC1E,sDAAsD;AACtD,+EAAyE;AACzE,6CAAqF;AACrF,mEAAiE;AAEjE,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA4B,CAAC;AAEjE,SAAgB,SAAS,CAAC,IAAc;IACvC,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAA,iBAAM,EAAC,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC5E,OAAO,MAAM,CAAC;AACf,CAAC;AAJD,8BAIC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,UAAU,CAAC,SAAkB;IAC5C,OAAO,gBAAgB,CAAC,GAAG,CAAC,SAAqB,CAAC,CAAC;AACpD,CAAC;AAFD,gCAEC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,KAAc;IA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AI,EAAE,CAAC;IACd,OAAO,WAAW,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,UAAsB;IACxD,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAS,CAAC,CAAC;IAC/C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC;IACf,CAAC;IAED,MAAM,QAAQ,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAChD,OAAO,uBAAuB,CAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC;AARD,gDAQC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,SAAoB;IAC3D,MAAM,WAAW,GAAG,gCAAgC,CAAC,SAAS,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,SAAwC,CAAC;IAC1D,OAAO,OAAO,WAAW,KAAK,UAAU;QACvC,CAAC,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC;QAC3B,CAAC,CAAE,WAAwE,CAAC,MAAM,CAChF,QAAQ,CACR,CAAC;AACL,CAAC;AARD,0DAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy, fail } from \"@fluidframework/core-utils/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable, Off } from \"@fluidframework/core-interfaces\";\nimport type { InternalTreeNode, TreeNode, Unhydrated } from \"./types.js\";\nimport {\n\tanchorSlot,\n\ttype AnchorEvents,\n\ttype AnchorNode,\n\ttype AnchorSet,\n\ttype TreeValue,\n\ttype UpPath,\n} from \"../../core/index.js\";\nimport {\n\tassertFlexTreeEntityNotFreed,\n\tContextSlot,\n\tflexTreeSlot,\n\tisFreedSymbol,\n\tLazyEntity,\n\tTreeStatus,\n\ttreeStatusFromAnchorCache,\n\ttype FlexTreeNode,\n} from \"../../feature-libraries/index.js\";\nimport type { TreeNodeSchema } from \"./treeNodeSchema.js\";\n// TODO: decide how to deal with dependencies on flex-tree implementation.\n// eslint-disable-next-line import/no-internal-modules\nimport { makeTree } from \"../../feature-libraries/flex-tree/lazyNode.js\";\nimport { SimpleContextSlot, type Context, type HydratedContext } from \"./context.js\";\nimport { UnhydratedFlexTreeNode } from \"./unhydratedFlexTree.js\";\n\nconst treeNodeToKernel = new WeakMap<TreeNode, TreeNodeKernel>();\n\nexport function getKernel(node: TreeNode): TreeNodeKernel {\n\tconst kernel = treeNodeToKernel.get(node);\n\tassert(kernel !== undefined, 0x9b1 /* Expected tree node to have kernel */);\n\treturn kernel;\n}\n\n/**\n * Detects if the given 'candidate' is a TreeNode.\n *\n * @remarks\n * Supports both Hydrated and {@link Unhydrated} TreeNodes, both of which return true.\n *\n * Because the common usage is to check if a value being inserted/set is a TreeNode,\n * this function permits calling with primitives as well as objects.\n *\n * Primitives will always return false (as they are copies of data, not references to nodes).\n *\n * @param candidate - Value which may be a TreeNode\n * @returns true if the given 'candidate' is a hydrated TreeNode.\n */\nexport function isTreeNode(candidate: unknown): candidate is TreeNode | Unhydrated<TreeNode> {\n\treturn treeNodeToKernel.has(candidate as TreeNode);\n}\n\n/**\n * Returns a schema for a value if the value is a {@link TreeNode}.\n *\n * Returns undefined for other values.\n * @remarks\n * Does not give schema for a {@link TreeLeafValue}.\n */\nexport function tryGetTreeNodeSchema(value: unknown): undefined | TreeNodeSchema {\n\tconst kernel = treeNodeToKernel.get(value as TreeNode);\n\treturn kernel?.schema;\n}\n\n/** The {@link HydrationState} of a {@link TreeNodeKernel} before the kernel is hydrated */\ninterface UnhydratedState {\n\toff: Off;\n\tinnerNode: UnhydratedFlexTreeNode;\n}\n\n/** The {@link HydrationState} of a {@link TreeNodeKernel} after the kernel is hydrated */\ninterface HydratedState {\n\t/** The flex node for this kernel (lazy - undefined if it has not yet been demanded) */\n\tinnerNode?: FlexTreeNode;\n\t/** The {@link AnchorNode} that this node is associated with. */\n\tanchorNode: AnchorNode;\n\t/** All {@link Off | event deregistration functions} that should be run when the kernel is disposed. */\n\toffAnchorNode: Set<Off>;\n}\n\n/** State within a {@link TreeNodeKernel} that is related to the hydration process */\ntype HydrationState = UnhydratedState | HydratedState;\n\n/** True if and only if the given {@link HydrationState} is post-hydration */\nfunction isHydrated(state: HydrationState): state is HydratedState {\n\treturn (state as Partial<HydratedState>).anchorNode !== undefined;\n}\n\n/**\n * Contains state and an internal API for managing {@link TreeNode}s.\n * @remarks All {@link TreeNode}s have an associated kernel object.\n * The kernel has the same lifetime as the node and spans both its unhydrated and hydrated states.\n */\nexport class TreeNodeKernel {\n\tprivate disposed = false;\n\n\t/**\n\t * Generation number which is incremented any time we have an edit on the node.\n\t * Used during iteration to make sure there has been no edits that were concurrently made.\n\t * @remarks\n\t * This is updated monotonically by this class when edits are applied.\n\t * TODO: update this when applying edits to unhydrated trees.\n\t *\n\t * If TypeScript supported making this immutable from outside the class without making it readonly from inside, that would be used here,\n\t * but they only way to do that is add a separate public accessor and make it private, which was deemed not worth the boilerplate, runtime overhead and bundle size.\n\t */\n\tpublic generationNumber: number = 0;\n\n\t#hydrationState: HydrationState;\n\n\t/**\n\t * Events registered before hydration.\n\t * @remarks\n\t * Since these are usually not used, they are allocated lazily as an optimization.\n\t * The laziness also avoids extra forwarding overhead for events from this kernel's anchor node and also avoids registering for events that are unneeded.\n\t * This means optimizations like skipping processing data in subtrees where no subtreeChanged events are subscribed to would be able to work,\n\t * since the kernel does not unconditionally subscribe to those events (like a design which simply forwards all events would).\n\t */\n\treadonly #unhydratedEvents = new Lazy(createEmitter<KernelEvents>);\n\n\t/**\n\t * Create a TreeNodeKernel which can be looked up with {@link getKernel}.\n\t *\n\t * @param initialContext - context from when this node was originally crated.\n\t * @param innerNode - When unhydrated/raw or marinated the MapTreeNode. FlexTreeNode when cooked.\n\t * @remarks\n\t * Exactly one kernel per TreeNode should be created.\n\t */\n\tpublic constructor(\n\t\tpublic readonly node: TreeNode,\n\t\tpublic readonly schema: TreeNodeSchema,\n\t\tinnerNode: InnerNode,\n\t\tprivate readonly initialContext: Context,\n\t) {\n\t\tassert(!treeNodeToKernel.has(node), 0xa1a /* only one kernel per node can be made */);\n\t\ttreeNodeToKernel.set(node, this);\n\n\t\tif (innerNode instanceof UnhydratedFlexTreeNode) {\n\t\t\t// Unhydrated case\n\t\t\tunhydratedFlexTreeNodeToTreeNodeInternal.set(innerNode, node);\n\t\t\t// Register for change events from the unhydrated flex node.\n\t\t\t// These will be fired if the unhydrated node is edited, and will also be forwarded later to the hydrated node.\n\t\t\tthis.#hydrationState = {\n\t\t\t\tinnerNode,\n\t\t\t\toff: innerNode.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\tthis.#unhydratedEvents.value.emit(\"childrenChangedAfterBatch\", {\n\t\t\t\t\t\tchangedFields,\n\t\t\t\t\t});\n\n\t\t\t\t\tlet n: UnhydratedFlexTreeNode | undefined = innerNode;\n\t\t\t\t\twhile (n !== undefined) {\n\t\t\t\t\t\tconst treeNode = unhydratedFlexTreeNodeToTreeNodeInternal.get(n);\n\t\t\t\t\t\tif (treeNode !== undefined) {\n\t\t\t\t\t\t\tconst kernel = getKernel(treeNode);\n\t\t\t\t\t\t\tkernel.#unhydratedEvents.value.emit(\"subtreeChangedAfterBatch\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// This cast is safe because the parent (if it exists) of an unhydrated flex node is always another unhydrated flex node.\n\t\t\t\t\t\tn = n.parentField.parent.parent as UnhydratedFlexTreeNode | undefined;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t};\n\t\t} else {\n\t\t\t// Hydrated case\n\t\t\tconst { anchorNode } = innerNode;\n\t\t\tassert(\n\t\t\t\t!anchorNode.slots.has(proxySlot),\n\t\t\t\t0x7f5 /* Cannot associate an flex node with multiple simple-tree nodes */,\n\t\t\t);\n\t\t\tthis.#hydrationState = this.createHydratedState(anchorNode);\n\t\t}\n\t}\n\n\tpublic get context(): Context {\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\t// This can't be cached on this.#hydrated during hydration since initial tree is hydrated before the context is cached on the anchorSet.\n\t\t\treturn (\n\t\t\t\tthis.#hydrationState?.anchorNode.anchorSet.slots.get(SimpleContextSlot) ??\n\t\t\t\tfail(0xb40 /* missing simple-tree context */)\n\t\t\t);\n\t\t}\n\t\treturn this.initialContext;\n\t}\n\n\t/**\n\t * Transition from {@link Unhydrated} to hydrated.\n\t * Bi-directionally associates the given hydrated TreeNode to the given anchor node.\n\t * @remarks\n\t * Happens at most once for any given node.\n\t * Cleans up mappings to {@link UnhydratedFlexTreeNode} - it is assumed that they are no longer needed once the proxy has an anchor node.\n\t */\n\tprivate hydrate(anchorNode: AnchorNode): void {\n\t\tassert(!this.disposed, 0xa2a /* cannot hydrate a disposed node */);\n\t\tassert(!isHydrated(this.#hydrationState), 0xa2b /* hydration should only happen once */);\n\t\tunhydratedFlexTreeNodeToTreeNodeInternal.delete(this.#hydrationState.innerNode);\n\t\tthis.#hydrationState = this.createHydratedState(anchorNode);\n\n\t\t// If needed, register forwarding emitters for events from before hydration\n\t\tif (this.#unhydratedEvents.evaluated) {\n\t\t\tconst events = this.#unhydratedEvents.value;\n\t\t\tfor (const eventName of kernelEvents) {\n\t\t\t\tif (events.hasListeners(eventName)) {\n\t\t\t\t\tthis.#hydrationState.offAnchorNode.add(\n\t\t\t\t\t\t// Argument is forwarded between matching events, so the type should be correct.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\tanchorNode.events.on(eventName, (arg: any) => events.emit(eventName, arg)),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate createHydratedState(anchorNode: AnchorNode): HydratedState {\n\t\tanchorNode.slots.set(proxySlot, this.node);\n\t\treturn {\n\t\t\tanchorNode,\n\t\t\toffAnchorNode: new Set([\n\t\t\t\tanchorNode.events.on(\"afterDestroy\", () => this.dispose()),\n\t\t\t\t// TODO: this should be triggered on change even for unhydrated nodes.\n\t\t\t\tanchorNode.events.on(\"childrenChanging\", () => {\n\t\t\t\t\tthis.generationNumber += 1;\n\t\t\t\t}),\n\t\t\t]),\n\t\t};\n\t}\n\n\tpublic getStatus(): TreeStatus {\n\t\tif (this.disposed) {\n\t\t\treturn TreeStatus.Deleted;\n\t\t}\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\treturn TreeStatus.New;\n\t\t}\n\n\t\t// TODO: Replace this check with the proper check against the cursor state when the cursor becomes part of the kernel\n\t\tconst flex = this.#hydrationState.anchorNode.slots.get(flexTreeSlot);\n\t\tif (flex !== undefined) {\n\t\t\tassert(flex instanceof LazyEntity, 0x9b4 /* Unexpected flex node implementation */);\n\t\t\tif (flex[isFreedSymbol]()) {\n\t\t\t\treturn TreeStatus.Deleted;\n\t\t\t}\n\t\t}\n\n\t\treturn treeStatusFromAnchorCache(this.#hydrationState.anchorNode);\n\t}\n\n\tpublic get events(): Listenable<KernelEvents> {\n\t\t// Retrieve the correct events object based on whether this node is pre or post hydration.\n\t\treturn isHydrated(this.#hydrationState)\n\t\t\t? this.#hydrationState.anchorNode.events\n\t\t\t: this.#unhydratedEvents.value;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.disposed = true;\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\tfor (const off of this.#hydrationState.offAnchorNode) {\n\t\t\t\toff();\n\t\t\t}\n\t\t}\n\t\t// TODO: go to the context and remove myself from withAnchors\n\t}\n\n\tpublic isHydrated(): this is { anchorNode: AnchorNode; context: HydratedContext } {\n\t\treturn isHydrated(this.#hydrationState);\n\t}\n\n\tpublic get anchorNode(): AnchorNode | undefined {\n\t\treturn isHydrated(this.#hydrationState) ? this.#hydrationState.anchorNode : undefined;\n\t}\n\n\t/**\n\t * Retrieves the flex node associated with the given target via {@link setInnerNode}.\n\t * @remarks\n\t * For {@link Unhydrated} nodes, this returns the MapTreeNode.\n\t *\n\t * For hydrated nodes it returns a FlexTreeNode backed by the forest.\n\t * Note that for \"marinated\" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.\n\t */\n\tpublic getOrCreateInnerNode(allowFreed = false): InnerNode {\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\treturn this.#hydrationState.innerNode; // Unhydrated case\n\t\t}\n\n\t\tif (this.#hydrationState.innerNode !== undefined) {\n\t\t\treturn this.#hydrationState.innerNode; // Cooked case\n\t\t}\n\n\t\t// Marinated case -> cooked\n\t\tconst anchorNode = this.#hydrationState.anchorNode;\n\t\t// The proxy is bound to an anchor node, but it may or may not have an actual flex node yet\n\t\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\t\tif (flexNode !== undefined) {\n\t\t\t// If the flex node already exists, use it...\n\t\t\tthis.#hydrationState.innerNode = flexNode;\n\t\t} else {\n\t\t\t// ...otherwise, the flex node must be created\n\t\t\tconst context =\n\t\t\t\tanchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb41 /* missing context */);\n\t\t\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\t\t\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\t\t\tthis.#hydrationState.innerNode = makeTree(context, cursor);\n\t\t\tcursor.free();\n\t\t\t// Calling this is a performance improvement, however, do this only after demand to avoid momentarily having no anchors to anchorNode\n\t\t\tanchorForgetters?.get(this.node)?.();\n\t\t\tif (!allowFreed) {\n\t\t\t\tassertFlexTreeEntityNotFreed(this.#hydrationState.innerNode);\n\t\t\t}\n\t\t}\n\n\t\treturn this.#hydrationState.innerNode;\n\t}\n\n\t/**\n\t * Creates an anchor node and associates it with the given proxy.\n\t * @privateRemarks\n\t * Use `forgetters` to cleanup the anchor allocated by this function once the anchor is no longer needed.\n\t * In practice, this happens when either the anchor node is destroyed, or another anchor to the same node is created by a new flex node.\n\t *\n\t * The FlexTreeNode holds a reference to the same anchor, and has a lifetime at least as long as the simple-tree,\n\t * so this would be unnecessary except for the case of \"marinated\" nodes, which have an anchor,\n\t * but might not have a FlexTreeNode.\n\t * Handling this case is an optimization assuming that this extra anchor reference is cheaper than eagerly creating FlexTreeNodes.\n\t */\n\tpublic anchorProxy(anchors: AnchorSet, path: UpPath): AnchorNode {\n\t\tassert(!anchorForgetters.has(this.node), 0x91c /* Proxy anchor should not be set twice */);\n\t\tconst anchor = anchors.track(path);\n\t\tconst anchorNode =\n\t\t\tanchors.locate(anchor) ?? fail(0xb42 /* Expected anchor node to be present */);\n\t\tthis.hydrate(anchorNode);\n\t\tconst forget = (): void => {\n\t\t\tif (anchors.locate(anchor)) {\n\t\t\t\tanchors.forget(anchor);\n\t\t\t}\n\t\t\tanchorForgetters.delete(this.node);\n\t\t\toff();\n\t\t};\n\t\tanchorForgetters.set(this.node, forget);\n\t\tconst off = anchorNode.events.on(\"afterDestroy\", forget);\n\t\treturn anchorNode;\n\t}\n\n\t/**\n\t * Retrieves the InnerNode associated with the given target via {@link setInnerNode}, if any.\n\t * @remarks\n\t * If `target` is an unhydrated node, returns its UnhydratedFlexTreeNode.\n\t * If `target` is a cooked node (or marinated but a FlexTreeNode exists) returns the FlexTreeNode.\n\t * If the target is a marinated node with no FlexTreeNode for its anchor, returns undefined.\n\t */\n\tpublic tryGetInnerNode(): InnerNode | undefined {\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\treturn (\n\t\t\t\tthis.#hydrationState.innerNode ??\n\t\t\t\tthis.#hydrationState.anchorNode.slots.get(flexTreeSlot)\n\t\t\t);\n\t\t}\n\n\t\treturn this.#hydrationState.innerNode;\n\t}\n}\n\n/**\n * Used by {@link anchorProxy} as an optimization to ensure that only one anchor is remembered at a time for a given anchor node\n */\nconst anchorForgetters = new WeakMap<TreeNode, () => void>();\n\nconst kernelEvents = [\"childrenChangedAfterBatch\", \"subtreeChangedAfterBatch\"] as const;\n\ntype KernelEvents = Pick<AnchorEvents, (typeof kernelEvents)[number]>;\n\n/**\n * For \"cooked\" nodes this is a FlexTreeNode thats a projection of forest content.\n * For {@link Unhydrated} nodes this is a MapTreeNode.\n * For \"marinated\" nodes, some code (ex: getOrCreateInnerNode) returns the FlexTreeNode thats a projection of forest content, and some code (ex: tryGetInnerNode) returns undefined.\n *\n * @remarks\n * Currently MapTreeNode extends FlexTreeNode, and most code which can work with either just uses FlexTreeNode.\n * TODO: Code should be migrating toward using this type to distinguish to two use-cases.\n *\n * TODO: The inconsistent handling of \"marinated\" cases should be cleaned up.\n * Maybe getOrCreateInnerNode should cook marinated nodes so they have a proper InnerNode?\n */\nexport type InnerNode = FlexTreeNode | UnhydratedFlexTreeNode;\n\n/**\n * Associates a given {@link UnhydratedFlexTreeNode} with a {@link TreeNode}.\n */\nconst unhydratedFlexTreeNodeToTreeNodeInternal = new WeakMap<\n\tUnhydratedFlexTreeNode,\n\tTreeNode\n>();\n/**\n * Retrieves the {@link TreeNode} associated with the given {@link UnhydratedFlexTreeNode} if any.\n */\nexport const unhydratedFlexTreeNodeToTreeNode =\n\tunhydratedFlexTreeNodeToTreeNodeInternal as Pick<\n\t\tWeakMap<UnhydratedFlexTreeNode, TreeNode>,\n\t\t\"get\"\n\t>;\n\n/**\n * An anchor slot which associates an anchor with its corresponding TreeNode, if there is one.\n * @remarks\n * For this to work, we have to require that there is at most a single view using a given AnchorSet.\n * FlexTree already has this assumption, and we also assume there is a single simple-tree per FlexTree, so this is valid.\n */\nexport const proxySlot = anchorSlot<TreeNode>();\n\nexport function tryDisposeTreeNode(anchorNode: AnchorNode): void {\n\tconst treeNode = anchorNode.slots.get(proxySlot);\n\tif (treeNode !== undefined) {\n\t\tconst kernel = getKernel(treeNode);\n\t\tkernel.dispose();\n\t}\n}\n\n/**\n * Gets the {@link TreeNodeSchema} for the {@link InnerNode}.\n */\nexport function getSimpleNodeSchemaFromInnerNode(innerNode: InnerNode): TreeNodeSchema {\n\tconst context: Context = getSimpleContextFromInnerNode(innerNode);\n\treturn context.schema.get(innerNode.schema) ?? fail(0xb3f /* missing schema from context */);\n}\n\n/**\n * Gets the {@link Context} for the {@link InnerNode}.\n */\nexport function getSimpleContextFromInnerNode(innerNode: InnerNode): Context {\n\tif (innerNode instanceof UnhydratedFlexTreeNode) {\n\t\treturn innerNode.simpleContext;\n\t}\n\n\tconst context = innerNode.anchorNode.anchorSet.slots.get(SimpleContextSlot);\n\tassert(context !== undefined, 0xa55 /* missing simple tree context */);\n\n\treturn context;\n}\n\n/**\n * Retrieves the flex node associated with the given target via {@link setInnerNode}.\n * @remarks\n * For {@link Unhydrated} nodes, this returns the MapTreeNode.\n *\n * For hydrated nodes it returns a FlexTreeNode backed by the forest.\n * Note that for \"marinated\" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.\n */\nexport function getOrCreateInnerNode(treeNode: TreeNode, allowFreed = false): InnerNode {\n\tconst kernel = getKernel(treeNode);\n\treturn kernel.getOrCreateInnerNode(allowFreed);\n}\n\n/**\n * Gets a flex node from an anchor node\n */\nfunction flexNodeFromAnchor(anchorNode: AnchorNode): FlexTreeNode {\n\t// the proxy is bound to an anchor node, but it may or may not have an actual flex node yet\n\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\tif (flexNode !== undefined) {\n\t\treturn flexNode; // If it does have a flex node, return it...\n\t} // ...otherwise, the flex node must be created\n\tconst context =\n\t\tanchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb45 /* missing context */);\n\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\tconst newFlexNode = makeTree(context, cursor);\n\tcursor.free();\n\treturn newFlexNode;\n}\n\n/**\n * Gets a tree node from an anchor node\n */\nexport function treeNodeFromAnchor(anchorNode: AnchorNode): TreeNode | TreeValue {\n\tconst cached = anchorNode.slots.get(proxySlot);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tconst flexNode = flexNodeFromAnchor(anchorNode);\n\treturn createTreeNodeFromInner(flexNode);\n}\n\n/**\n * Constructs a TreeNode from an InnerNode.\n * @remarks\n * This does not do caching or validation: caller must ensure duplicate nodes for a given inner node are not created, and that the inner node is valid.\n */\nexport function createTreeNodeFromInner(innerNode: InnerNode): TreeNode | TreeValue {\n\tconst classSchema = getSimpleNodeSchemaFromInnerNode(innerNode);\n\tconst internal = innerNode as unknown as InternalTreeNode;\n\treturn typeof classSchema === \"function\"\n\t\t? new classSchema(internal)\n\t\t: (classSchema as { create(data: InternalTreeNode): TreeNode | TreeValue }).create(\n\t\t\t\tinternal,\n\t\t\t);\n}\n"]}
1
+ {"version":3,"file":"treeNodeKernel.js","sourceRoot":"","sources":["../../../src/simple-tree/core/treeNodeKernel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,kEAAyE;AACzE,+DAA6D;AAG7D,kDAO6B;AAC7B,+DAQ0C;AAE1C,0EAA0E;AAC1E,sDAAsD;AACtD,+EAAyE;AACzE,6CAAqF;AACrF,mEAAiE;AAEjE,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA4B,CAAC;AAEjE,SAAgB,SAAS,CAAC,IAAc;IACvC,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAA,iBAAM,EAAC,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC5E,OAAO,MAAM,CAAC;AACf,CAAC;AAJD,8BAIC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,UAAU,CAAC,SAAkB;IAC5C,OAAO,gBAAgB,CAAC,GAAG,CAAC,SAAqB,CAAC,CAAC;AACpD,CAAC;AAFD,gCAEC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,KAAc;IAClD,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,KAAiB,CAAC,CAAC;IACvD,OAAO,MAAM,EAAE,MAAM,CAAC;AACvB,CAAC;AAHD,oDAGC;AAqBD,6EAA6E;AAC7E,SAAS,UAAU,CAAC,KAAqB;IACxC,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;AACH,SAAgB,kBAAkB,CAAC,UAAsB;IACxD,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAS,CAAC,CAAC;IAC/C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC;IACf,CAAC;IAED,MAAM,QAAQ,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAChD,OAAO,uBAAuB,CAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC;AARD,gDAQC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,SAAoB;IAC3D,MAAM,WAAW,GAAG,gCAAgC,CAAC,SAAS,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,SAAwC,CAAC;IAC1D,OAAO,OAAO,WAAW,KAAK,UAAU;QACvC,CAAC,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC;QAC3B,CAAC,CAAE,WAAwE,CAAC,MAAM,CAChF,QAAQ,CACR,CAAC;AACL,CAAC;AARD,0DAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy, fail } from \"@fluidframework/core-utils/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable, Off } from \"@fluidframework/core-interfaces\";\nimport type { InternalTreeNode, TreeNode, Unhydrated } from \"./types.js\";\nimport {\n\tanchorSlot,\n\ttype AnchorEvents,\n\ttype AnchorNode,\n\ttype AnchorSet,\n\ttype TreeValue,\n\ttype UpPath,\n} from \"../../core/index.js\";\nimport {\n\tassertFlexTreeEntityNotFreed,\n\tContextSlot,\n\tflexTreeSlot,\n\tLazyEntity,\n\tTreeStatus,\n\ttreeStatusFromAnchorCache,\n\ttype FlexTreeNode,\n} from \"../../feature-libraries/index.js\";\nimport type { TreeNodeSchema } from \"./treeNodeSchema.js\";\n// TODO: decide how to deal with dependencies on flex-tree implementation.\n// eslint-disable-next-line import/no-internal-modules\nimport { makeTree } from \"../../feature-libraries/flex-tree/lazyNode.js\";\nimport { SimpleContextSlot, type Context, type HydratedContext } from \"./context.js\";\nimport { UnhydratedFlexTreeNode } from \"./unhydratedFlexTree.js\";\n\nconst treeNodeToKernel = new WeakMap<TreeNode, TreeNodeKernel>();\n\nexport function getKernel(node: TreeNode): TreeNodeKernel {\n\tconst kernel = treeNodeToKernel.get(node);\n\tassert(kernel !== undefined, 0x9b1 /* Expected tree node to have kernel */);\n\treturn kernel;\n}\n\n/**\n * Detects if the given 'candidate' is a TreeNode.\n *\n * @remarks\n * Supports both Hydrated and {@link Unhydrated} TreeNodes, both of which return true.\n *\n * Because the common usage is to check if a value being inserted/set is a TreeNode,\n * this function permits calling with primitives as well as objects.\n *\n * Primitives will always return false (as they are copies of data, not references to nodes).\n *\n * @param candidate - Value which may be a TreeNode\n * @returns true if the given 'candidate' is a hydrated TreeNode.\n */\nexport function isTreeNode(candidate: unknown): candidate is TreeNode | Unhydrated<TreeNode> {\n\treturn treeNodeToKernel.has(candidate as TreeNode);\n}\n\n/**\n * Returns a schema for a value if the value is a {@link TreeNode}.\n *\n * Returns undefined for other values.\n * @remarks\n * Does not give schema for a {@link TreeLeafValue}.\n */\nexport function tryGetTreeNodeSchema(value: unknown): undefined | TreeNodeSchema {\n\tconst kernel = treeNodeToKernel.get(value as TreeNode);\n\treturn kernel?.schema;\n}\n\n/** The {@link HydrationState} of a {@link TreeNodeKernel} before the kernel is hydrated */\ninterface UnhydratedState {\n\toff: Off;\n\tinnerNode: UnhydratedFlexTreeNode;\n}\n\n/** The {@link HydrationState} of a {@link TreeNodeKernel} after the kernel is hydrated */\ninterface HydratedState {\n\t/** The flex node for this kernel (lazy - undefined if it has not yet been demanded) */\n\tinnerNode?: FlexTreeNode;\n\t/** The {@link AnchorNode} that this node is associated with. */\n\tanchorNode: AnchorNode;\n\t/** All {@link Off | event deregistration functions} that should be run when the kernel is disposed. */\n\toffAnchorNode: Set<Off>;\n}\n\n/** State within a {@link TreeNodeKernel} that is related to the hydration process */\ntype HydrationState = UnhydratedState | HydratedState;\n\n/** True if and only if the given {@link HydrationState} is post-hydration */\nfunction isHydrated(state: HydrationState): state is HydratedState {\n\treturn (state as Partial<HydratedState>).anchorNode !== undefined;\n}\n\n/**\n * Contains state and an internal API for managing {@link TreeNode}s.\n * @remarks All {@link TreeNode}s have an associated kernel object.\n * The kernel has the same lifetime as the node and spans both its unhydrated and hydrated states.\n */\nexport class TreeNodeKernel {\n\tprivate disposed = false;\n\n\t/**\n\t * Generation number which is incremented any time we have an edit on the node.\n\t * Used during iteration to make sure there has been no edits that were concurrently made.\n\t * @remarks\n\t * This is updated monotonically by this class when edits are applied.\n\t * TODO: update this when applying edits to unhydrated trees.\n\t *\n\t * If TypeScript supported making this immutable from outside the class without making it readonly from inside, that would be used here,\n\t * but they only way to do that is add a separate public accessor and make it private, which was deemed not worth the boilerplate, runtime overhead and bundle size.\n\t */\n\tpublic generationNumber: number = 0;\n\n\t#hydrationState: HydrationState;\n\n\t/**\n\t * Events registered before hydration.\n\t * @remarks\n\t * Since these are usually not used, they are allocated lazily as an optimization.\n\t * The laziness also avoids extra forwarding overhead for events from this kernel's anchor node and also avoids registering for events that are unneeded.\n\t * This means optimizations like skipping processing data in subtrees where no subtreeChanged events are subscribed to would be able to work,\n\t * since the kernel does not unconditionally subscribe to those events (like a design which simply forwards all events would).\n\t */\n\treadonly #unhydratedEvents = new Lazy(createEmitter<KernelEvents>);\n\n\t/**\n\t * Create a TreeNodeKernel which can be looked up with {@link getKernel}.\n\t *\n\t * @param initialContext - context from when this node was originally crated.\n\t * @param innerNode - When unhydrated/raw or marinated the MapTreeNode. FlexTreeNode when cooked.\n\t * @remarks\n\t * Exactly one kernel per TreeNode should be created.\n\t */\n\tpublic constructor(\n\t\tpublic readonly node: TreeNode,\n\t\tpublic readonly schema: TreeNodeSchema,\n\t\tinnerNode: InnerNode,\n\t\tprivate readonly initialContext: Context,\n\t) {\n\t\tassert(!treeNodeToKernel.has(node), 0xa1a /* only one kernel per node can be made */);\n\t\ttreeNodeToKernel.set(node, this);\n\n\t\tif (innerNode instanceof UnhydratedFlexTreeNode) {\n\t\t\t// Unhydrated case\n\t\t\tunhydratedFlexTreeNodeToTreeNodeInternal.set(innerNode, node);\n\t\t\t// Register for change events from the unhydrated flex node.\n\t\t\t// These will be fired if the unhydrated node is edited, and will also be forwarded later to the hydrated node.\n\t\t\tthis.#hydrationState = {\n\t\t\t\tinnerNode,\n\t\t\t\toff: innerNode.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\tthis.#unhydratedEvents.value.emit(\"childrenChangedAfterBatch\", {\n\t\t\t\t\t\tchangedFields,\n\t\t\t\t\t});\n\n\t\t\t\t\tlet unhydratedNode: UnhydratedFlexTreeNode | undefined = innerNode;\n\t\t\t\t\twhile (unhydratedNode !== undefined) {\n\t\t\t\t\t\tconst treeNode = unhydratedFlexTreeNodeToTreeNodeInternal.get(unhydratedNode);\n\t\t\t\t\t\tif (treeNode !== undefined) {\n\t\t\t\t\t\t\tconst kernel = getKernel(treeNode);\n\t\t\t\t\t\t\tkernel.#unhydratedEvents.value.emit(\"subtreeChangedAfterBatch\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst parentNode: FlexTreeNode | undefined =\n\t\t\t\t\t\t\tunhydratedNode.parentField.parent.parent;\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tparentNode === undefined || parentNode instanceof UnhydratedFlexTreeNode,\n\t\t\t\t\t\t\t0xb76 /* Unhydrated node's parent should be an unhydrated node */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tunhydratedNode = parentNode;\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t};\n\t\t} else {\n\t\t\t// Hydrated case\n\t\t\tconst { anchorNode } = innerNode;\n\t\t\tassert(\n\t\t\t\t!anchorNode.slots.has(proxySlot),\n\t\t\t\t0x7f5 /* Cannot associate an flex node with multiple simple-tree nodes */,\n\t\t\t);\n\t\t\tthis.#hydrationState = this.createHydratedState(anchorNode);\n\t\t}\n\t}\n\n\tpublic get context(): Context {\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\t// This can't be cached on this.#hydrated during hydration since initial tree is hydrated before the context is cached on the anchorSet.\n\t\t\treturn (\n\t\t\t\tthis.#hydrationState?.anchorNode.anchorSet.slots.get(SimpleContextSlot) ??\n\t\t\t\tfail(0xb40 /* missing simple-tree context */)\n\t\t\t);\n\t\t}\n\t\treturn this.initialContext;\n\t}\n\n\t/**\n\t * Transition from {@link Unhydrated} to hydrated.\n\t * Bi-directionally associates the given hydrated TreeNode to the given anchor node.\n\t * @remarks\n\t * Happens at most once for any given node.\n\t * Cleans up mappings to {@link UnhydratedFlexTreeNode} - it is assumed that they are no longer needed once the proxy has an anchor node.\n\t */\n\tprivate hydrate(anchorNode: AnchorNode): void {\n\t\tassert(!this.disposed, 0xa2a /* cannot hydrate a disposed node */);\n\t\tassert(!isHydrated(this.#hydrationState), 0xa2b /* hydration should only happen once */);\n\t\tunhydratedFlexTreeNodeToTreeNodeInternal.delete(this.#hydrationState.innerNode);\n\t\tthis.#hydrationState = this.createHydratedState(anchorNode);\n\n\t\t// If needed, register forwarding emitters for events from before hydration\n\t\tif (this.#unhydratedEvents.evaluated) {\n\t\t\tconst events = this.#unhydratedEvents.value;\n\t\t\tfor (const eventName of kernelEvents) {\n\t\t\t\tif (events.hasListeners(eventName)) {\n\t\t\t\t\tthis.#hydrationState.offAnchorNode.add(\n\t\t\t\t\t\t// Argument is forwarded between matching events, so the type should be correct.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\tanchorNode.events.on(eventName, (arg: any) => events.emit(eventName, arg)),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate createHydratedState(anchorNode: AnchorNode): HydratedState {\n\t\tanchorNode.slots.set(proxySlot, this.node);\n\t\treturn {\n\t\t\tanchorNode,\n\t\t\toffAnchorNode: new Set([\n\t\t\t\tanchorNode.events.on(\"afterDestroy\", () => this.dispose()),\n\t\t\t\t// TODO: this should be triggered on change even for unhydrated nodes.\n\t\t\t\tanchorNode.events.on(\"childrenChanging\", () => {\n\t\t\t\t\tthis.generationNumber += 1;\n\t\t\t\t}),\n\t\t\t]),\n\t\t};\n\t}\n\n\tpublic getStatus(): TreeStatus {\n\t\tif (this.disposed) {\n\t\t\treturn TreeStatus.Deleted;\n\t\t}\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\treturn TreeStatus.New;\n\t\t}\n\n\t\t// TODO: Replace this check with the proper check against the cursor state when the cursor becomes part of the kernel\n\t\tconst flex = this.#hydrationState.anchorNode.slots.get(flexTreeSlot);\n\t\tif (flex !== undefined) {\n\t\t\tassert(flex instanceof LazyEntity, 0x9b4 /* Unexpected flex node implementation */);\n\t\t\tif (flex.isFreed()) {\n\t\t\t\treturn TreeStatus.Deleted;\n\t\t\t}\n\t\t}\n\n\t\treturn treeStatusFromAnchorCache(this.#hydrationState.anchorNode);\n\t}\n\n\tpublic get events(): Listenable<KernelEvents> {\n\t\t// Retrieve the correct events object based on whether this node is pre or post hydration.\n\t\treturn isHydrated(this.#hydrationState)\n\t\t\t? this.#hydrationState.anchorNode.events\n\t\t\t: this.#unhydratedEvents.value;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.disposed = true;\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\tfor (const off of this.#hydrationState.offAnchorNode) {\n\t\t\t\toff();\n\t\t\t}\n\t\t}\n\t\t// TODO: go to the context and remove myself from withAnchors\n\t}\n\n\tpublic isHydrated(): this is { anchorNode: AnchorNode; context: HydratedContext } {\n\t\treturn isHydrated(this.#hydrationState);\n\t}\n\n\tpublic get anchorNode(): AnchorNode | undefined {\n\t\treturn isHydrated(this.#hydrationState) ? this.#hydrationState.anchorNode : undefined;\n\t}\n\n\t/**\n\t * Retrieves the flex node associated with the given target via {@link setInnerNode}.\n\t * @remarks\n\t * For {@link Unhydrated} nodes, this returns the MapTreeNode.\n\t *\n\t * For hydrated nodes it returns a FlexTreeNode backed by the forest.\n\t * Note that for \"marinated\" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.\n\t */\n\tpublic getOrCreateInnerNode(allowFreed = false): InnerNode {\n\t\tif (!isHydrated(this.#hydrationState)) {\n\t\t\treturn this.#hydrationState.innerNode; // Unhydrated case\n\t\t}\n\n\t\tif (this.#hydrationState.innerNode !== undefined) {\n\t\t\treturn this.#hydrationState.innerNode; // Cooked case\n\t\t}\n\n\t\t// Marinated case -> cooked\n\t\tconst anchorNode = this.#hydrationState.anchorNode;\n\t\t// The proxy is bound to an anchor node, but it may or may not have an actual flex node yet\n\t\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\t\tif (flexNode !== undefined) {\n\t\t\t// If the flex node already exists, use it...\n\t\t\tthis.#hydrationState.innerNode = flexNode;\n\t\t} else {\n\t\t\t// ...otherwise, the flex node must be created\n\t\t\tconst context =\n\t\t\t\tanchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb41 /* missing context */);\n\t\t\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\t\t\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\t\t\tthis.#hydrationState.innerNode = makeTree(context, cursor);\n\t\t\tcursor.free();\n\t\t\t// Calling this is a performance improvement, however, do this only after demand to avoid momentarily having no anchors to anchorNode\n\t\t\tanchorForgetters?.get(this.node)?.();\n\t\t\tif (!allowFreed) {\n\t\t\t\tassertFlexTreeEntityNotFreed(this.#hydrationState.innerNode);\n\t\t\t}\n\t\t}\n\n\t\treturn this.#hydrationState.innerNode;\n\t}\n\n\t/**\n\t * Creates an anchor node and associates it with the given proxy.\n\t * @privateRemarks\n\t * Use `forgetters` to cleanup the anchor allocated by this function once the anchor is no longer needed.\n\t * In practice, this happens when either the anchor node is destroyed, or another anchor to the same node is created by a new flex node.\n\t *\n\t * The FlexTreeNode holds a reference to the same anchor, and has a lifetime at least as long as the simple-tree,\n\t * so this would be unnecessary except for the case of \"marinated\" nodes, which have an anchor,\n\t * but might not have a FlexTreeNode.\n\t * Handling this case is an optimization assuming that this extra anchor reference is cheaper than eagerly creating FlexTreeNodes.\n\t */\n\tpublic anchorProxy(anchors: AnchorSet, path: UpPath): AnchorNode {\n\t\tassert(!anchorForgetters.has(this.node), 0x91c /* Proxy anchor should not be set twice */);\n\t\tconst anchor = anchors.track(path);\n\t\tconst anchorNode =\n\t\t\tanchors.locate(anchor) ?? fail(0xb42 /* Expected anchor node to be present */);\n\t\tthis.hydrate(anchorNode);\n\t\tconst forget = (): void => {\n\t\t\tif (anchors.locate(anchor)) {\n\t\t\t\tanchors.forget(anchor);\n\t\t\t}\n\t\t\tanchorForgetters.delete(this.node);\n\t\t\toff();\n\t\t};\n\t\tanchorForgetters.set(this.node, forget);\n\t\tconst off = anchorNode.events.on(\"afterDestroy\", forget);\n\t\treturn anchorNode;\n\t}\n\n\t/**\n\t * Retrieves the InnerNode associated with the given target via {@link setInnerNode}, if any.\n\t * @remarks\n\t * If `target` is an unhydrated node, returns its UnhydratedFlexTreeNode.\n\t * If `target` is a cooked node (or marinated but a FlexTreeNode exists) returns the FlexTreeNode.\n\t * If the target is a marinated node with no FlexTreeNode for its anchor, returns undefined.\n\t */\n\tpublic tryGetInnerNode(): InnerNode | undefined {\n\t\tif (isHydrated(this.#hydrationState)) {\n\t\t\treturn (\n\t\t\t\tthis.#hydrationState.innerNode ??\n\t\t\t\tthis.#hydrationState.anchorNode.slots.get(flexTreeSlot)\n\t\t\t);\n\t\t}\n\n\t\treturn this.#hydrationState.innerNode;\n\t}\n}\n\n/**\n * Used by {@link anchorProxy} as an optimization to ensure that only one anchor is remembered at a time for a given anchor node\n */\nconst anchorForgetters = new WeakMap<TreeNode, () => void>();\n\nconst kernelEvents = [\"childrenChangedAfterBatch\", \"subtreeChangedAfterBatch\"] as const;\n\ntype KernelEvents = Pick<AnchorEvents, (typeof kernelEvents)[number]>;\n\n/**\n * For \"cooked\" nodes this is a FlexTreeNode thats a projection of forest content.\n * For {@link Unhydrated} nodes this is a MapTreeNode.\n * For \"marinated\" nodes, some code (ex: getOrCreateInnerNode) returns the FlexTreeNode thats a projection of forest content, and some code (ex: tryGetInnerNode) returns undefined.\n *\n * @remarks\n * Currently MapTreeNode extends FlexTreeNode, and most code which can work with either just uses FlexTreeNode.\n * TODO: Code should be migrating toward using this type to distinguish to two use-cases.\n *\n * TODO: The inconsistent handling of \"marinated\" cases should be cleaned up.\n * Maybe getOrCreateInnerNode should cook marinated nodes so they have a proper InnerNode?\n */\nexport type InnerNode = FlexTreeNode | UnhydratedFlexTreeNode;\n\n/**\n * Associates a given {@link UnhydratedFlexTreeNode} with a {@link TreeNode}.\n */\nconst unhydratedFlexTreeNodeToTreeNodeInternal = new WeakMap<\n\tUnhydratedFlexTreeNode,\n\tTreeNode\n>();\n/**\n * Retrieves the {@link TreeNode} associated with the given {@link UnhydratedFlexTreeNode} if any.\n */\nexport const unhydratedFlexTreeNodeToTreeNode =\n\tunhydratedFlexTreeNodeToTreeNodeInternal as Pick<\n\t\tWeakMap<UnhydratedFlexTreeNode, TreeNode>,\n\t\t\"get\"\n\t>;\n\n/**\n * An anchor slot which associates an anchor with its corresponding TreeNode, if there is one.\n * @remarks\n * For this to work, we have to require that there is at most a single view using a given AnchorSet.\n * FlexTree already has this assumption, and we also assume there is a single simple-tree per FlexTree, so this is valid.\n */\nexport const proxySlot = anchorSlot<TreeNode>();\n\nexport function tryDisposeTreeNode(anchorNode: AnchorNode): void {\n\tconst treeNode = anchorNode.slots.get(proxySlot);\n\tif (treeNode !== undefined) {\n\t\tconst kernel = getKernel(treeNode);\n\t\tkernel.dispose();\n\t}\n}\n\n/**\n * Gets the {@link TreeNodeSchema} for the {@link InnerNode}.\n */\nexport function getSimpleNodeSchemaFromInnerNode(innerNode: InnerNode): TreeNodeSchema {\n\tconst context: Context = getSimpleContextFromInnerNode(innerNode);\n\treturn context.schema.get(innerNode.schema) ?? fail(0xb3f /* missing schema from context */);\n}\n\n/**\n * Gets the {@link Context} for the {@link InnerNode}.\n */\nexport function getSimpleContextFromInnerNode(innerNode: InnerNode): Context {\n\tif (innerNode instanceof UnhydratedFlexTreeNode) {\n\t\treturn innerNode.simpleContext;\n\t}\n\n\tconst context = innerNode.anchorNode.anchorSet.slots.get(SimpleContextSlot);\n\tassert(context !== undefined, 0xa55 /* missing simple tree context */);\n\n\treturn context;\n}\n\n/**\n * Retrieves the flex node associated with the given target via {@link setInnerNode}.\n * @remarks\n * For {@link Unhydrated} nodes, this returns the MapTreeNode.\n *\n * For hydrated nodes it returns a FlexTreeNode backed by the forest.\n * Note that for \"marinated\" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode.\n */\nexport function getOrCreateInnerNode(treeNode: TreeNode, allowFreed = false): InnerNode {\n\tconst kernel = getKernel(treeNode);\n\treturn kernel.getOrCreateInnerNode(allowFreed);\n}\n\n/**\n * Gets a flex node from an anchor node\n */\nfunction flexNodeFromAnchor(anchorNode: AnchorNode): FlexTreeNode {\n\t// the proxy is bound to an anchor node, but it may or may not have an actual flex node yet\n\tconst flexNode = anchorNode.slots.get(flexTreeSlot);\n\tif (flexNode !== undefined) {\n\t\treturn flexNode; // If it does have a flex node, return it...\n\t} // ...otherwise, the flex node must be created\n\tconst context =\n\t\tanchorNode.anchorSet.slots.get(ContextSlot) ?? fail(0xb45 /* missing context */);\n\tconst cursor = context.checkout.forest.allocateCursor(\"getFlexNode\");\n\tcontext.checkout.forest.moveCursorToPath(anchorNode, cursor);\n\tconst newFlexNode = makeTree(context, cursor);\n\tcursor.free();\n\treturn newFlexNode;\n}\n\n/**\n * Gets a tree node from an anchor node\n */\nexport function treeNodeFromAnchor(anchorNode: AnchorNode): TreeNode | TreeValue {\n\tconst cached = anchorNode.slots.get(proxySlot);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tconst flexNode = flexNodeFromAnchor(anchorNode);\n\treturn createTreeNodeFromInner(flexNode);\n}\n\n/**\n * Constructs a TreeNode from an InnerNode.\n * @remarks\n * This does not do caching or validation: caller must ensure duplicate nodes for a given inner node are not created, and that the inner node is valid.\n */\nexport function createTreeNodeFromInner(innerNode: InnerNode): TreeNode | TreeValue {\n\tconst classSchema = getSimpleNodeSchemaFromInnerNode(innerNode);\n\tconst internal = innerNode as unknown as InternalTreeNode;\n\treturn typeof classSchema === \"function\"\n\t\t? new classSchema(internal)\n\t\t: (classSchema as { create(data: InternalTreeNode): TreeNode | TreeValue }).create(\n\t\t\t\tinternal,\n\t\t\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"unhydratedFlexTree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/core/unhydratedFlexTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,UAAU,EAEf,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EAExB,KAAK,sBAAsB,EAC3B,KAAK,OAAO,EACZ,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,KAAK,EACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACN,KAAK,eAAe,EACpB,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EAGjB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,cAAc,EAEd,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAElB,KAAK,wBAAwB,EAE7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,UAAU,sCACT,SAAQ,wBAAwB,CAAC,gBAAgB,EAAE,CAAC;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gB,EAAE,CAEjD;IAED,IAAW,MAAM,IAAI,MAAM,CAE1B;IAEM,EAAE,CAAC,MAAM,SAAS,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAAC,MAAM,CAAC;IAIlF,aAAa,IAAI,gBAAgB,CAAC,YAAY,CAAC;IAY/C,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAcvD;;;;;;;OAOG;IACH,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,IAAI,GAAG,gBAAgB,EAAE,GAAG,IAAI;IAYhF,YAAY,IAAI,qBAAqB;IAI5C,yCAAyC;IACzC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,sBAAsB;CASxD;AAoDD,qBAAa,2BACZ,SAAQ,uBACR,YAAW,qBAAqB;IAEhC,SAAgB,MAAM,EAAE,sCAAsC,CA6B5D;IAEK,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS;IAOrD,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE;IAI3E,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,sBAAsB,CAAC;CAKrE;AAkBD;;;GAGG;AACH,wBAAgB,yBAAyB,CACxC,OAAO,EAAE,OAAO,GACd,sBAAsB,GAAG,SAAS,CAEpC;AAgDD,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAM7D"}
@@ -74,8 +74,19 @@ class UnhydratedFlexTreeNode {
74
74
  }
75
75
  adoptBy(parent, index) {
76
76
  if (parent !== undefined) {
77
- (0, internal_1.assert)(this.location === unparentedLocation, 0x98c /* Node may not be adopted if it already has a parent */);
78
77
  (0, internal_1.assert)(index !== undefined, 0xa08 /* Expected index */);
78
+ if (this.location !== unparentedLocation) {
79
+ throw new internal_2.UsageError("A node may not be inserted if it's already in a tree");
80
+ }
81
+ let unhydratedNode = parent.parent;
82
+ while (unhydratedNode !== undefined) {
83
+ if (unhydratedNode === this) {
84
+ throw new internal_2.UsageError("A node may not be inserted into a location that is under itself");
85
+ }
86
+ const parentNode = unhydratedNode.parentField.parent.parent;
87
+ (0, internal_1.assert)(parentNode === undefined || parentNode instanceof UnhydratedFlexTreeNode, 0xb77 /* Unhydrated node's parent should be an unhydrated node */);
88
+ unhydratedNode = parentNode;
89
+ }
79
90
  this.location = { parent, index };
80
91
  }
81
92
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"unhydratedFlexTree.js","sourceRoot":"","sources":["../../../src/simple-tree/core/unhydratedFlexTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,kEAAwE;AACxE,+DAA6D;AAE7D,uEAAsE;AAEtE,kDAgB6B;AAC7B,kDAAsE;AACtE,+DAiB0C;AAsB1C;;;;;;;GAOG;AACH,MAAa,sBAAsB;IAClC,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAW,YAAY;QACtB,OAAO,CACN,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,oBAAoB,CAAC,CACzF,CAAC;IACH,CAAC;IAKD,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,WAAW,CACxB,OAAgB,EAChB,OAAyB;QAEzB,OAAO,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAC1F,CAAC;IAED,IAAW,OAAO;QACjB,O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G,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC;IACf,CAAC;IAED,IACC,MAAM,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU;QACzC,MAAM,KAAK,qBAAU,CAAC,UAAU,CAAC,UAAU,EAC1C,CAAC;QACF,OAAO,IAAI,yBAAyB,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzF,CAAC;IAED,IAAI,MAAM,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC/C,OAAO,IAAI,yBAAyB,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzF,CAAC;IAED,IAAI,MAAM,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC/C,OAAO,IAAI,2BAA2B,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3F,CAAC;IAED,OAAO,IAAI,uBAAuB,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACvF,CAAC;AAED,4CAA4C;AAE5C,SAAgB,qBAAqB,CAAC,OAAgB;IACrD,OAAO,IAAI,qBAAU,CACpB,GACC,OAAO,IAAI,WACZ,4EAA4E,CAC5E,CAAC;AACH,CAAC;AAND,sDAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob, fail } from \"@fluidframework/core-utils/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype AnchorEvents,\n\ttype AnchorNode,\n\tEmptyKey,\n\ttype ExclusiveMapTree,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\tforbiddenFieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype MapTree,\n\ttype NormalizedFieldUpPath,\n\ttype SchemaPolicy,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype Value,\n} from \"../../core/index.js\";\nimport { brand, getOrCreate, mapIterable } from \"../../util/index.js\";\nimport {\n\ttype FlexTreeContext,\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeUnknownUnboxed,\n\tflexTreeMarker,\n\tindexForAt,\n\ttype FlexTreeHydratedContext,\n\ttype FlexFieldKind,\n\tFieldKinds,\n\ttype SequenceFieldEditBuilder,\n\tcursorForMapTreeNode,\n} from \"../../feature-libraries/index.js\";\nimport type { Context } from \"./context.js\";\n\ninterface UnhydratedTreeSequenceFieldEditBuilder\n\textends SequenceFieldEditBuilder<ExclusiveMapTree[]> {\n\t/**\n\t * Issues a change which removes `count` elements starting at the given `index`.\n\t * @param index - The index of the first removed element.\n\t * @param count - The number of elements to remove.\n\t * @returns the MapTrees that were removed\n\t */\n\tremove(index: number, count: number): ExclusiveMapTree[];\n}\n\ntype UnhydratedFlexTreeNodeEvents = Pick<AnchorEvents, \"childrenChangedAfterBatch\">;\n\n/** A node's parent field and its index in that field */\ninterface LocationInField {\n\treadonly parent: FlexTreeField;\n\treadonly index: number;\n}\n\n/**\n * An unhydrated implementation of {@link FlexTreeNode} which wraps a {@link MapTree}.\n * @remarks\n * MapTreeNodes are unconditionally cached -\n * when retrieved via {@link getOrCreateNode}, the same {@link MapTree} object will always produce the same `UnhydratedFlexTreeNode` object.\n *\n * Create a `UnhydratedFlexTreeNode` by calling {@link getOrCreate}.\n */\nexport class UnhydratedFlexTreeNode implements UnhydratedFlexTreeNode {\n\tpublic get schema(): TreeNodeSchemaIdentifier {\n\t\treturn this.mapTree.type;\n\t}\n\n\tpublic get storedSchema(): TreeNodeStoredSchema {\n\t\treturn (\n\t\t\tthis.context.schema.nodeSchema.get(this.mapTree.type) ?? fail(0xb46 /* missing schema */)\n\t\t);\n\t}\n\n\tpublic readonly [flexTreeMarker] = FlexTreeEntityKind.Node as const;\n\n\tprivate readonly _events = createEmitter<UnhydratedFlexTreeNodeEvents>();\n\tpublic get events(): Listenable<UnhydratedFlexTreeNodeEvents> {\n\t\treturn this._events;\n\t}\n\n\t/**\n\t * Create a {@link UnhydratedFlexTreeNode} that wraps the given {@link MapTree}, or get the node that already exists for that {@link MapTree} if there is one.\n\t * @param nodeSchema - the {@link FlexTreeNodeSchema | schema} that the node conforms to\n\t * @param mapTree - the {@link MapTree} containing the data for this node.\n\t * @remarks It must conform to the `nodeSchema`.\n\t */\n\tpublic static getOrCreate(\n\t\tcontext: Context,\n\t\tmapTree: ExclusiveMapTree,\n\t): UnhydratedFlexTreeNode {\n\t\treturn nodeCache.get(mapTree) ?? new UnhydratedFlexTreeNode(context, mapTree, undefined);\n\t}\n\n\tpublic get context(): FlexTreeContext {\n\t\treturn this.simpleContext.flexContext;\n\t}\n\n\t/**\n\t * Create a new UnhydratedFlexTreeNode.\n\t * @param location - the parentage of this node, if it is being created underneath an existing node and field, or undefined if not\n\t * @remarks This class (and its subclasses) should not be directly constructed outside of this module.\n\t * Instead, use {@link getOrCreateNode} to create a UnhydratedFlexTreeNode from a {@link MapTree}.\n\t * A `UnhydratedFlexTreeNode` may never be constructed more than once for the same {@link MapTree} object.\n\t * Instead, it should always be acquired via {@link getOrCreateNode}.\n\t */\n\tpublic constructor(\n\t\tpublic readonly simpleContext: Context,\n\t\t/** The underlying {@link MapTree} that this `UnhydratedFlexTreeNode` reads its data from */\n\t\tpublic readonly mapTree: ExclusiveMapTree,\n\t\tprivate location = unparentedLocation,\n\t) {\n\t\tassert(!nodeCache.has(mapTree), 0x98b /* A node already exists for the given MapTree */);\n\t\tnodeCache.set(mapTree, this);\n\n\t\t// Fully demand the tree to ensure that parent pointers are present and accurate on all nodes.\n\t\t// When a UnhydratedFlexTreeNode is constructed, its MapTree may contain nodes (anywhere below) that map (via the `nodeCache`) to pre-existing UnhydratedFlexTreeNodes.\n\t\t// Put another way, for a given MapTree, some ancestor UnhydratedFlexTreeNode can be created after any number of its descendant UnhydratedFlexTreeNodes already exist.\n\t\t// In such a case, the spine of nodes between the descendant and ancestor need to exist in order for the ancestor to be able to walk upwards via the `parentField` property.\n\t\t// This needs to happen for all UnhydratedFlexTreeNodes that are descendants of the ancestor UnhydratedFlexTreeNode.\n\t\t// Demanding the entire tree is overkill to solve this problem since not all descendant MapTree nodes will have corresponding UnhydratedFlexTreeNodes.\n\t\t// However, demanding the full tree also lets us eagerly validate that there are no duplicate MapTrees (i.e. same MapTree object) anywhere in the tree.\n\t\tthis.walkTree();\n\t}\n\n\tpublic get type(): TreeNodeSchemaIdentifier {\n\t\treturn this.mapTree.type;\n\t}\n\n\t/**\n\t * Set this node's parentage (see {@link FlexTreeNode.parentField}).\n\t * @remarks The node may be given a parent if it has none, or may have its parent removed (by passing `undefined`).\n\t * However, a node with a parent may not be directly re-assigned a different parent.\n\t * That likely indicates either an attempted multi-parenting or an attempt to \"move\" the node, neither of which are supported.\n\t * Removing a node's parent twice in a row is also not supported, as it likely indicates a bug.\n\t */\n\tpublic adoptBy(parent: undefined): void;\n\tpublic adoptBy(parent: UnhydratedFlexTreeField, index: number): void;\n\tpublic adoptBy(parent: UnhydratedFlexTreeField | undefined, index?: number): void {\n\t\tif (parent !== undefined) {\n\t\t\tassert(\n\t\t\t\tthis.location === unparentedLocation,\n\t\t\t\t0x98c /* Node may not be adopted if it already has a parent */,\n\t\t\t);\n\t\t\tassert(index !== undefined, 0xa08 /* Expected index */);\n\t\t\tthis.location = { parent, index };\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tthis.location !== unparentedLocation,\n\t\t\t\t0xa09 /* Node may not be un-adopted if it does not have a parent */,\n\t\t\t);\n\t\t\tthis.location = unparentedLocation;\n\t\t}\n\t}\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t * @remarks If this node is unparented, this method will return the special {@link unparentedLocation} as the parent.\n\t */\n\tpublic get parentField(): LocationInField {\n\t\treturn this.location;\n\t}\n\n\tpublic borrowCursor(): ITreeCursorSynchronous {\n\t\treturn cursorForMapTreeNode(this.mapTree);\n\t}\n\n\tpublic tryGetField(key: FieldKey): UnhydratedFlexTreeField | undefined {\n\t\tconst field = this.mapTree.fields.get(key);\n\t\t// Only return the field if it is not empty, in order to fulfill the contract of `tryGetField`.\n\t\tif (field !== undefined && field.length > 0) {\n\t\t\treturn getOrCreateField(this, key, this.storedSchema.getFieldSchema(key).kind, () =>\n\t\t\t\tthis.emitChangedEvent(key),\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic getBoxed(key: string): FlexTreeField {\n\t\tconst fieldKey: FieldKey = brand(key);\n\t\treturn getOrCreateField(\n\t\t\tthis,\n\t\t\tfieldKey,\n\t\t\tthis.storedSchema.getFieldSchema(fieldKey).kind,\n\t\t\t() => this.emitChangedEvent(fieldKey),\n\t\t);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeField> {\n\t\treturn mapIterable(this.mapTree.fields.entries(), ([key]) =>\n\t\t\tgetOrCreateField(this, key, this.storedSchema.getFieldSchema(key).kind, () =>\n\t\t\t\tthis.emitChangedEvent(key),\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic keys(): IterableIterator<FieldKey> {\n\t\t// TODO: how this should handle missing defaults (and empty keys if they end up being allowed) needs to be determined.\n\t\treturn this.mapTree.fields.keys();\n\t}\n\n\tpublic get value(): Value {\n\t\treturn this.mapTree.value;\n\t}\n\n\tpublic get anchorNode(): AnchorNode {\n\t\t// This API is relevant to `LazyTreeNode`s, but not `UnhydratedFlexTreeNode`s.\n\t\t// TODO: Refactor the FlexTreeNode interface so that stubbing this out isn't necessary.\n\t\treturn fail(0xb47 /* UnhydratedFlexTreeNode does not implement anchorNode */);\n\t}\n\n\tprivate walkTree(): void {\n\t\tfor (const [key, mapTrees] of this.mapTree.fields) {\n\t\t\tconst field = getOrCreateField(\n\t\t\t\tthis,\n\t\t\t\tkey,\n\t\t\t\tthis.storedSchema.getFieldSchema(key).kind,\n\t\t\t\t() => this.emitChangedEvent(key),\n\t\t\t);\n\t\t\tfor (let index = 0; index < field.length; index++) {\n\t\t\t\tconst child = getOrCreateChild(this.simpleContext, mapTrees[index] ?? oob(), {\n\t\t\t\t\tparent: field,\n\t\t\t\t\tindex,\n\t\t\t\t});\n\t\t\t\t// These next asserts detect the case where `getOrCreateChild` gets a cache hit of a different node than the one we're trying to create\n\t\t\t\tassert(child.location !== undefined, 0x98d /* Expected node to have parent */);\n\t\t\t\tassert(\n\t\t\t\t\tchild.location.parent.parent === this,\n\t\t\t\t\t0x98e /* Node may not be multi-parented */,\n\t\t\t\t);\n\t\t\t\tassert(child.location.index === index, 0x98f /* Node may not be multi-parented */);\n\t\t\t\tchild.walkTree();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate emitChangedEvent(key: FieldKey): void {\n\t\tthis._events.emit(\"childrenChangedAfterBatch\", { changedFields: new Set([key]) });\n\t}\n}\n\n/**\n * Implementation of `FlexTreeContext`.\n *\n * @remarks An editor is required to edit the FlexTree.\n */\nexport class UnhydratedContext implements FlexTreeContext {\n\t/**\n\t * @param flexSchema - Schema to use when working with the tree.\n\t */\n\tpublic constructor(\n\t\tpublic readonly schemaPolicy: SchemaPolicy,\n\t\tpublic readonly schema: TreeStoredSchema,\n\t) {}\n\n\tpublic isHydrated(): this is FlexTreeHydratedContext {\n\t\treturn false;\n\t}\n}\n\n// #region Fields\n\n/**\n * A special singleton that is the implicit {@link LocationInField} of all un-parented {@link UnhydratedFlexTreeNode}s.\n * @remarks This exists because {@link UnhydratedFlexTreeNode.parentField} must return a field.\n * If a {@link UnhydratedFlexTreeNode} is created without a parent, its {@link UnhydratedFlexTreeNode.parentField} property will point to this object.\n * However, this field cannot be used in any practical way because it is empty, i.e. it does not actually contain the children that claim to be parented under it.\n * It has the \"empty\" schema and it will always contain zero children if queried.\n * Any nodes with this location will have a dummy parent index of `-1`.\n */\nconst unparentedLocation: LocationInField = {\n\tparent: {\n\t\t[flexTreeMarker]: FlexTreeEntityKind.Field as const,\n\t\tlength: 0,\n\t\tkey: EmptyKey,\n\t\tparent: undefined,\n\t\tis<TKind2 extends FlexFieldKind>(kind: TKind2) {\n\t\t\treturn this.schema === kind.identifier;\n\t\t},\n\t\tboxedIterator(): IterableIterator<FlexTreeNode> {\n\t\t\treturn [].values();\n\t\t},\n\t\tboxedAt(index: number): FlexTreeNode | undefined {\n\t\t\treturn undefined;\n\t\t},\n\t\tschema: brand(forbiddenFieldKindIdentifier),\n\t\tget context(): never {\n\t\t\treturn fail(0xb48 /* unsupported */);\n\t\t},\n\t\tgetFieldPath() {\n\t\t\tfail(0xb49 /* unsupported */);\n\t\t},\n\t},\n\tindex: -1,\n};\n\nclass UnhydratedFlexTreeField implements FlexTreeField {\n\tpublic [flexTreeMarker] = FlexTreeEntityKind.Field as const;\n\n\tpublic get context(): FlexTreeContext {\n\t\treturn this.simpleContext.flexContext;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly simpleContext: Context,\n\t\tpublic readonly schema: FieldKindIdentifier,\n\t\tpublic readonly key: FieldKey,\n\t\tpublic readonly parent: UnhydratedFlexTreeNode,\n\t\tpublic readonly onEdit?: () => void,\n\t) {\n\t\tconst fieldKeyCache = getFieldKeyCache(parent);\n\t\tassert(!fieldKeyCache.has(key), 0x990 /* A field already exists for the given MapTrees */);\n\t\tfieldKeyCache.set(key, this);\n\n\t\t// When this field is created (which only happens one time, because it is cached), all the children become parented for the first time.\n\t\t// \"Adopt\" each child by updating its parent information to point to this field.\n\t\tfor (const [i, mapTree] of this.mapTrees.entries()) {\n\t\t\tconst mapTreeNodeChild = nodeCache.get(mapTree);\n\t\t\tif (mapTreeNodeChild !== undefined) {\n\t\t\t\tif (mapTreeNodeChild.parentField !== unparentedLocation) {\n\t\t\t\t\tthrow new UsageError(\"A node may not be in more than one place in the tree\");\n\t\t\t\t}\n\t\t\t\tmapTreeNodeChild.adoptBy(this, i);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get mapTrees(): readonly ExclusiveMapTree[] {\n\t\treturn this.parent.mapTree.fields.get(this.key) ?? [];\n\t}\n\n\tpublic get length(): number {\n\t\treturn this.mapTrees.length;\n\t}\n\n\tpublic is<TKind2 extends FlexFieldKind>(kind: TKind2): this is FlexTreeTypedField<TKind2> {\n\t\treturn this.schema === kind.identifier;\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeNode> {\n\t\treturn this.mapTrees\n\t\t\t.map(\n\t\t\t\t(m, index) =>\n\t\t\t\t\tgetOrCreateChild(this.simpleContext, m, {\n\t\t\t\t\t\tparent: this,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t}) as FlexTreeNode,\n\t\t\t)\n\t\t\t.values();\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeNode | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst m = this.mapTrees[i];\n\t\tif (m !== undefined) {\n\t\t\treturn getOrCreateChild(this.simpleContext, m, {\n\t\t\t\tparent: this,\n\t\t\t\tindex: i,\n\t\t\t}) as FlexTreeNode;\n\t\t}\n\t}\n\n\t/**\n\t * Mutate this field.\n\t * @param edit - A function which receives the current `MapTree`s that comprise the contents of the field so that it may be mutated.\n\t * The function may mutate the array in place or return a new array.\n\t * If a new array is returned then it will be used as the new contents of the field, otherwise the original array will be continue to be used.\n\t * @remarks All edits to the field (i.e. mutations of the field's MapTrees) should be directed through this function.\n\t * This function ensures that the parent MapTree has no empty fields (which is an invariant of `MapTree`) after the mutation.\n\t */\n\tprotected edit(edit: (mapTrees: ExclusiveMapTree[]) => void | ExclusiveMapTree[]): void {\n\t\tconst oldMapTrees = this.parent.mapTree.fields.get(this.key) ?? [];\n\t\tconst newMapTrees = edit(oldMapTrees) ?? oldMapTrees;\n\t\tif (newMapTrees.length > 0) {\n\t\t\tthis.parent.mapTree.fields.set(this.key, newMapTrees);\n\t\t} else {\n\t\t\tthis.parent.mapTree.fields.delete(this.key);\n\t\t}\n\n\t\tthis.onEdit?.();\n\t}\n\n\tpublic getFieldPath(): NormalizedFieldUpPath {\n\t\tthrow unsupportedUsageError(\"Editing an array\");\n\t}\n\n\t/** Unboxes leaf nodes to their values */\n\tprotected unboxed(index: number): FlexTreeUnknownUnboxed {\n\t\tconst mapTree: ExclusiveMapTree = this.mapTrees[index] ?? oob();\n\t\tconst value = mapTree.value;\n\t\tif (value !== undefined) {\n\t\t\treturn value;\n\t\t}\n\n\t\treturn getOrCreateChild(this.simpleContext, mapTree, { parent: this, index });\n\t}\n}\n\nclass EagerMapTreeOptionalField\n\textends UnhydratedFlexTreeField\n\timplements FlexTreeOptionalField\n{\n\tpublic readonly editor = {\n\t\tset: (newContent: ExclusiveMapTree | undefined): void => {\n\t\t\t// If the new content is a UnhydratedFlexTreeNode, it needs to have its parent pointer updated\n\t\t\tif (newContent !== undefined) {\n\t\t\t\tnodeCache.get(newContent)?.adoptBy(this, 0);\n\t\t\t}\n\t\t\t// If the old content is a UnhydratedFlexTreeNode, it needs to have its parent pointer unset\n\t\t\tconst oldContent = this.mapTrees[0];\n\t\t\tif (oldContent !== undefined) {\n\t\t\t\tnodeCache.get(oldContent)?.adoptBy(undefined);\n\t\t\t}\n\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent !== undefined) {\n\t\t\t\t\tmapTrees[0] = newContent;\n\t\t\t\t} else {\n\t\t\t\t\tmapTrees.length = 0;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n\n\tpublic get content(): FlexTreeUnknownUnboxed | undefined {\n\t\tconst value = this.mapTrees[0];\n\t\tif (value !== undefined) {\n\t\t\treturn this.unboxed(0);\n\t\t}\n\n\t\treturn undefined;\n\t}\n}\n\nclass EagerMapTreeRequiredField\n\textends EagerMapTreeOptionalField\n\timplements FlexTreeRequiredField\n{\n\tpublic override get content(): FlexTreeUnknownUnboxed {\n\t\t// This cannot use ?? since null is a legal value here.\n\t\tassert(\n\t\t\tsuper.content !== undefined,\n\t\t\t0xa57 /* Expected EagerMapTree required field to have a value */,\n\t\t);\n\t\treturn super.content;\n\t}\n}\n\nexport class UnhydratedTreeSequenceField\n\textends UnhydratedFlexTreeField\n\timplements FlexTreeSequenceField\n{\n\tpublic readonly editor: UnhydratedTreeSequenceFieldEditBuilder = {\n\t\tinsert: (index, newContent): void => {\n\t\t\tfor (let i = 0; i < newContent.length; i++) {\n\t\t\t\tconst c = newContent[i];\n\t\t\t\tassert(c !== undefined, 0xa0a /* Unexpected sparse array content */);\n\t\t\t\tnodeCache.get(c)?.adoptBy(this, index + i);\n\t\t\t}\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent.length < 1000) {\n\t\t\t\t\t// For \"smallish arrays\" (`1000` is not empirically derived), the `splice` function is appropriate...\n\t\t\t\t\tmapTrees.splice(index, 0, ...newContent);\n\t\t\t\t} else {\n\t\t\t\t\t// ...but we avoid using `splice` + spread for very large input arrays since there is a limit on how many elements can be spread (too many will overflow the stack).\n\t\t\t\t\treturn mapTrees.slice(0, index).concat(newContent, mapTrees.slice(index));\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tremove: (index, count): ExclusiveMapTree[] => {\n\t\t\tfor (let i = index; i < index + count; i++) {\n\t\t\t\tconst c = this.mapTrees[i];\n\t\t\t\tassert(c !== undefined, 0xa0b /* Unexpected sparse array */);\n\t\t\t\tnodeCache.get(c)?.adoptBy(undefined);\n\t\t\t}\n\t\t\tlet removed: ExclusiveMapTree[] | undefined;\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tremoved = mapTrees.splice(index, count);\n\t\t\t});\n\t\t\treturn removed ?? fail(0xb4a /* Expected removed to be set by edit */);\n\t\t},\n\t};\n\n\tpublic at(index: number): FlexTreeUnknownUnboxed | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.unboxed(i);\n\t}\n\tpublic map<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<FlexTreeUnknownUnboxed> {\n\t\tfor (const [i] of this.mapTrees.entries()) {\n\t\t\tyield this.unboxed(i);\n\t\t}\n\t}\n}\n\n// #endregion Fields\n\n// #region Caching and unboxing utilities\n\nconst nodeCache = new WeakMap<MapTree, UnhydratedFlexTreeNode>();\n/** Node Parent -\\> Field Key -\\> Field */\nconst fieldCache = new WeakMap<\n\tUnhydratedFlexTreeNode,\n\tMap<FieldKey, UnhydratedFlexTreeField>\n>();\nfunction getFieldKeyCache(\n\tparent: UnhydratedFlexTreeNode,\n): WeakMap<FieldKey, UnhydratedFlexTreeField> {\n\treturn getOrCreate(fieldCache, parent, () => new Map());\n}\n\n/**\n * If there exists a {@link UnhydratedFlexTreeNode} for the given {@link MapTree}, returns it, otherwise returns `undefined`.\n * @remarks {@link UnhydratedFlexTreeNode | UnhydratedFlexTreeNodes} are created via {@link getOrCreateNode}.\n */\nexport function tryUnhydratedFlexTreeNode(\n\tmapTree: MapTree,\n): UnhydratedFlexTreeNode | undefined {\n\treturn nodeCache.get(mapTree);\n}\n\n/** Helper for creating a `UnhydratedFlexTreeNode` given the parent field (e.g. when \"walking down\") */\nfunction getOrCreateChild(\n\tcontext: Context,\n\tmapTree: ExclusiveMapTree,\n\tparent: LocationInField | undefined,\n): UnhydratedFlexTreeNode {\n\tconst cached = nodeCache.get(mapTree);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\treturn new UnhydratedFlexTreeNode(context, mapTree, parent);\n}\n\n/** Creates a field with the given attributes, or returns a cached field if there is one */\nfunction getOrCreateField(\n\tparent: UnhydratedFlexTreeNode,\n\tkey: FieldKey,\n\tschema: FieldKindIdentifier,\n\tonEdit?: () => void,\n): UnhydratedFlexTreeField {\n\tconst cached = getFieldKeyCache(parent).get(key);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tif (\n\t\tschema === FieldKinds.required.identifier ||\n\t\tschema === FieldKinds.identifier.identifier\n\t) {\n\t\treturn new EagerMapTreeRequiredField(parent.simpleContext, schema, key, parent, onEdit);\n\t}\n\n\tif (schema === FieldKinds.optional.identifier) {\n\t\treturn new EagerMapTreeOptionalField(parent.simpleContext, schema, key, parent, onEdit);\n\t}\n\n\tif (schema === FieldKinds.sequence.identifier) {\n\t\treturn new UnhydratedTreeSequenceField(parent.simpleContext, schema, key, parent, onEdit);\n\t}\n\n\treturn new UnhydratedFlexTreeField(parent.simpleContext, schema, key, parent, onEdit);\n}\n\n// #endregion Caching and unboxing utilities\n\nexport function unsupportedUsageError(message?: string): Error {\n\treturn new UsageError(\n\t\t`${\n\t\t\tmessage ?? \"Operation\"\n\t\t} is not supported for content that has not yet been inserted into the tree`,\n\t);\n}\n"]}
1
+ {"version":3,"file":"unhydratedFlexTree.js","sourceRoot":"","sources":["../../../src/simple-tree/core/unhydratedFlexTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,kEAAwE;AACxE,+DAA6D;AAE7D,uEAAsE;AAEtE,kDAgB6B;AAC7B,kDAAsE;AACtE,+DAiB0C;AAsB1C;;;;;;;GAOG;AACH,MAAa,sBAAsB;IAClC,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAW,YAAY;QACtB,OAAO,CACN,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,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AAC;IAED,IAAI,MAAM,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC/C,OAAO,IAAI,yBAAyB,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzF,CAAC;IAED,IAAI,MAAM,KAAK,qBAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC/C,OAAO,IAAI,2BAA2B,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3F,CAAC;IAED,OAAO,IAAI,uBAAuB,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACvF,CAAC;AAED,4CAA4C;AAE5C,SAAgB,qBAAqB,CAAC,OAAgB;IACrD,OAAO,IAAI,qBAAU,CACpB,GACC,OAAO,IAAI,WACZ,4EAA4E,CAC5E,CAAC;AACH,CAAC;AAND,sDAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob, fail } from \"@fluidframework/core-utils/internal\";\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\ttype AnchorEvents,\n\ttype AnchorNode,\n\tEmptyKey,\n\ttype ExclusiveMapTree,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\tforbiddenFieldKindIdentifier,\n\ttype ITreeCursorSynchronous,\n\ttype MapTree,\n\ttype NormalizedFieldUpPath,\n\ttype SchemaPolicy,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype Value,\n} from \"../../core/index.js\";\nimport { brand, getOrCreate, mapIterable } from \"../../util/index.js\";\nimport {\n\ttype FlexTreeContext,\n\tFlexTreeEntityKind,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n\ttype FlexTreeSequenceField,\n\ttype FlexTreeTypedField,\n\ttype FlexTreeUnknownUnboxed,\n\tflexTreeMarker,\n\tindexForAt,\n\ttype FlexTreeHydratedContext,\n\ttype FlexFieldKind,\n\tFieldKinds,\n\ttype SequenceFieldEditBuilder,\n\tcursorForMapTreeNode,\n} from \"../../feature-libraries/index.js\";\nimport type { Context } from \"./context.js\";\n\ninterface UnhydratedTreeSequenceFieldEditBuilder\n\textends SequenceFieldEditBuilder<ExclusiveMapTree[]> {\n\t/**\n\t * Issues a change which removes `count` elements starting at the given `index`.\n\t * @param index - The index of the first removed element.\n\t * @param count - The number of elements to remove.\n\t * @returns the MapTrees that were removed\n\t */\n\tremove(index: number, count: number): ExclusiveMapTree[];\n}\n\ntype UnhydratedFlexTreeNodeEvents = Pick<AnchorEvents, \"childrenChangedAfterBatch\">;\n\n/** A node's parent field and its index in that field */\ninterface LocationInField {\n\treadonly parent: FlexTreeField;\n\treadonly index: number;\n}\n\n/**\n * An unhydrated implementation of {@link FlexTreeNode} which wraps a {@link MapTree}.\n * @remarks\n * MapTreeNodes are unconditionally cached -\n * when retrieved via {@link getOrCreateNode}, the same {@link MapTree} object will always produce the same `UnhydratedFlexTreeNode` object.\n *\n * Create a `UnhydratedFlexTreeNode` by calling {@link getOrCreate}.\n */\nexport class UnhydratedFlexTreeNode implements UnhydratedFlexTreeNode {\n\tpublic get schema(): TreeNodeSchemaIdentifier {\n\t\treturn this.mapTree.type;\n\t}\n\n\tpublic get storedSchema(): TreeNodeStoredSchema {\n\t\treturn (\n\t\t\tthis.context.schema.nodeSchema.get(this.mapTree.type) ?? fail(0xb46 /* missing schema */)\n\t\t);\n\t}\n\n\tpublic readonly [flexTreeMarker] = FlexTreeEntityKind.Node as const;\n\n\tprivate readonly _events = createEmitter<UnhydratedFlexTreeNodeEvents>();\n\tpublic get events(): Listenable<UnhydratedFlexTreeNodeEvents> {\n\t\treturn this._events;\n\t}\n\n\t/**\n\t * Create a {@link UnhydratedFlexTreeNode} that wraps the given {@link MapTree}, or get the node that already exists for that {@link MapTree} if there is one.\n\t * @param nodeSchema - the {@link FlexTreeNodeSchema | schema} that the node conforms to\n\t * @param mapTree - the {@link MapTree} containing the data for this node.\n\t * @remarks It must conform to the `nodeSchema`.\n\t */\n\tpublic static getOrCreate(\n\t\tcontext: Context,\n\t\tmapTree: ExclusiveMapTree,\n\t): UnhydratedFlexTreeNode {\n\t\treturn nodeCache.get(mapTree) ?? new UnhydratedFlexTreeNode(context, mapTree, undefined);\n\t}\n\n\tpublic get context(): FlexTreeContext {\n\t\treturn this.simpleContext.flexContext;\n\t}\n\n\t/**\n\t * Create a new UnhydratedFlexTreeNode.\n\t * @param location - the parentage of this node, if it is being created underneath an existing node and field, or undefined if not\n\t * @remarks This class (and its subclasses) should not be directly constructed outside of this module.\n\t * Instead, use {@link getOrCreateNode} to create a UnhydratedFlexTreeNode from a {@link MapTree}.\n\t * A `UnhydratedFlexTreeNode` may never be constructed more than once for the same {@link MapTree} object.\n\t * Instead, it should always be acquired via {@link getOrCreateNode}.\n\t */\n\tpublic constructor(\n\t\tpublic readonly simpleContext: Context,\n\t\t/** The underlying {@link MapTree} that this `UnhydratedFlexTreeNode` reads its data from */\n\t\tpublic readonly mapTree: ExclusiveMapTree,\n\t\tprivate location = unparentedLocation,\n\t) {\n\t\tassert(!nodeCache.has(mapTree), 0x98b /* A node already exists for the given MapTree */);\n\t\tnodeCache.set(mapTree, this);\n\n\t\t// Fully demand the tree to ensure that parent pointers are present and accurate on all nodes.\n\t\t// When a UnhydratedFlexTreeNode is constructed, its MapTree may contain nodes (anywhere below) that map (via the `nodeCache`) to pre-existing UnhydratedFlexTreeNodes.\n\t\t// Put another way, for a given MapTree, some ancestor UnhydratedFlexTreeNode can be created after any number of its descendant UnhydratedFlexTreeNodes already exist.\n\t\t// In such a case, the spine of nodes between the descendant and ancestor need to exist in order for the ancestor to be able to walk upwards via the `parentField` property.\n\t\t// This needs to happen for all UnhydratedFlexTreeNodes that are descendants of the ancestor UnhydratedFlexTreeNode.\n\t\t// Demanding the entire tree is overkill to solve this problem since not all descendant MapTree nodes will have corresponding UnhydratedFlexTreeNodes.\n\t\t// However, demanding the full tree also lets us eagerly validate that there are no duplicate MapTrees (i.e. same MapTree object) anywhere in the tree.\n\t\tthis.walkTree();\n\t}\n\n\tpublic get type(): TreeNodeSchemaIdentifier {\n\t\treturn this.mapTree.type;\n\t}\n\n\t/**\n\t * Set this node's parentage (see {@link FlexTreeNode.parentField}).\n\t * @remarks The node may be given a parent if it has none, or may have its parent removed (by passing `undefined`).\n\t * However, a node with a parent may not be directly re-assigned a different parent.\n\t * That likely indicates either an attempted multi-parenting or an attempt to \"move\" the node, neither of which are supported.\n\t * Removing a node's parent twice in a row is also not supported, as it likely indicates a bug.\n\t */\n\tpublic adoptBy(parent: undefined): void;\n\tpublic adoptBy(parent: UnhydratedFlexTreeField, index: number): void;\n\tpublic adoptBy(parent: UnhydratedFlexTreeField | undefined, index?: number): void {\n\t\tif (parent !== undefined) {\n\t\t\tassert(index !== undefined, 0xa08 /* Expected index */);\n\t\t\tif (this.location !== unparentedLocation) {\n\t\t\t\tthrow new UsageError(\"A node may not be inserted if it's already in a tree\");\n\t\t\t}\n\t\t\tlet unhydratedNode: UnhydratedFlexTreeNode | undefined = parent.parent;\n\t\t\twhile (unhydratedNode !== undefined) {\n\t\t\t\tif (unhydratedNode === this) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"A node may not be inserted into a location that is under itself\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst parentNode: FlexTreeNode | undefined = unhydratedNode.parentField.parent.parent;\n\t\t\t\tassert(\n\t\t\t\t\tparentNode === undefined || parentNode instanceof UnhydratedFlexTreeNode,\n\t\t\t\t\t0xb77 /* Unhydrated node's parent should be an unhydrated node */,\n\t\t\t\t);\n\t\t\t\tunhydratedNode = parentNode;\n\t\t\t}\n\t\t\tthis.location = { parent, index };\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tthis.location !== unparentedLocation,\n\t\t\t\t0xa09 /* Node may not be un-adopted if it does not have a parent */,\n\t\t\t);\n\t\t\tthis.location = unparentedLocation;\n\t\t}\n\t}\n\n\t/**\n\t * The field this tree is in, and the index within that field.\n\t * @remarks If this node is unparented, this method will return the special {@link unparentedLocation} as the parent.\n\t */\n\tpublic get parentField(): LocationInField {\n\t\treturn this.location;\n\t}\n\n\tpublic borrowCursor(): ITreeCursorSynchronous {\n\t\treturn cursorForMapTreeNode(this.mapTree);\n\t}\n\n\tpublic tryGetField(key: FieldKey): UnhydratedFlexTreeField | undefined {\n\t\tconst field = this.mapTree.fields.get(key);\n\t\t// Only return the field if it is not empty, in order to fulfill the contract of `tryGetField`.\n\t\tif (field !== undefined && field.length > 0) {\n\t\t\treturn getOrCreateField(this, key, this.storedSchema.getFieldSchema(key).kind, () =>\n\t\t\t\tthis.emitChangedEvent(key),\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic getBoxed(key: string): FlexTreeField {\n\t\tconst fieldKey: FieldKey = brand(key);\n\t\treturn getOrCreateField(\n\t\t\tthis,\n\t\t\tfieldKey,\n\t\t\tthis.storedSchema.getFieldSchema(fieldKey).kind,\n\t\t\t() => this.emitChangedEvent(fieldKey),\n\t\t);\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeField> {\n\t\treturn mapIterable(this.mapTree.fields.entries(), ([key]) =>\n\t\t\tgetOrCreateField(this, key, this.storedSchema.getFieldSchema(key).kind, () =>\n\t\t\t\tthis.emitChangedEvent(key),\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic keys(): IterableIterator<FieldKey> {\n\t\t// TODO: how this should handle missing defaults (and empty keys if they end up being allowed) needs to be determined.\n\t\treturn this.mapTree.fields.keys();\n\t}\n\n\tpublic get value(): Value {\n\t\treturn this.mapTree.value;\n\t}\n\n\tpublic get anchorNode(): AnchorNode {\n\t\t// This API is relevant to `LazyTreeNode`s, but not `UnhydratedFlexTreeNode`s.\n\t\t// TODO: Refactor the FlexTreeNode interface so that stubbing this out isn't necessary.\n\t\treturn fail(0xb47 /* UnhydratedFlexTreeNode does not implement anchorNode */);\n\t}\n\n\tprivate walkTree(): void {\n\t\tfor (const [key, mapTrees] of this.mapTree.fields) {\n\t\t\tconst field = getOrCreateField(\n\t\t\t\tthis,\n\t\t\t\tkey,\n\t\t\t\tthis.storedSchema.getFieldSchema(key).kind,\n\t\t\t\t() => this.emitChangedEvent(key),\n\t\t\t);\n\t\t\tfor (let index = 0; index < field.length; index++) {\n\t\t\t\tconst child = getOrCreateChild(this.simpleContext, mapTrees[index] ?? oob(), {\n\t\t\t\t\tparent: field,\n\t\t\t\t\tindex,\n\t\t\t\t});\n\t\t\t\t// These next asserts detect the case where `getOrCreateChild` gets a cache hit of a different node than the one we're trying to create\n\t\t\t\tassert(child.location !== undefined, 0x98d /* Expected node to have parent */);\n\t\t\t\tassert(\n\t\t\t\t\tchild.location.parent.parent === this,\n\t\t\t\t\t0x98e /* Node may not be multi-parented */,\n\t\t\t\t);\n\t\t\t\tassert(child.location.index === index, 0x98f /* Node may not be multi-parented */);\n\t\t\t\tchild.walkTree();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate emitChangedEvent(key: FieldKey): void {\n\t\tthis._events.emit(\"childrenChangedAfterBatch\", { changedFields: new Set([key]) });\n\t}\n}\n\n/**\n * Implementation of `FlexTreeContext`.\n *\n * @remarks An editor is required to edit the FlexTree.\n */\nexport class UnhydratedContext implements FlexTreeContext {\n\t/**\n\t * @param flexSchema - Schema to use when working with the tree.\n\t */\n\tpublic constructor(\n\t\tpublic readonly schemaPolicy: SchemaPolicy,\n\t\tpublic readonly schema: TreeStoredSchema,\n\t) {}\n\n\tpublic isHydrated(): this is FlexTreeHydratedContext {\n\t\treturn false;\n\t}\n}\n\n// #region Fields\n\n/**\n * A special singleton that is the implicit {@link LocationInField} of all un-parented {@link UnhydratedFlexTreeNode}s.\n * @remarks This exists because {@link UnhydratedFlexTreeNode.parentField} must return a field.\n * If a {@link UnhydratedFlexTreeNode} is created without a parent, its {@link UnhydratedFlexTreeNode.parentField} property will point to this object.\n * However, this field cannot be used in any practical way because it is empty, i.e. it does not actually contain the children that claim to be parented under it.\n * It has the \"empty\" schema and it will always contain zero children if queried.\n * Any nodes with this location will have a dummy parent index of `-1`.\n */\nconst unparentedLocation: LocationInField = {\n\tparent: {\n\t\t[flexTreeMarker]: FlexTreeEntityKind.Field as const,\n\t\tlength: 0,\n\t\tkey: EmptyKey,\n\t\tparent: undefined,\n\t\tis<TKind2 extends FlexFieldKind>(kind: TKind2) {\n\t\t\treturn this.schema === kind.identifier;\n\t\t},\n\t\tboxedIterator(): IterableIterator<FlexTreeNode> {\n\t\t\treturn [].values();\n\t\t},\n\t\tboxedAt(index: number): FlexTreeNode | undefined {\n\t\t\treturn undefined;\n\t\t},\n\t\tschema: brand(forbiddenFieldKindIdentifier),\n\t\tget context(): never {\n\t\t\treturn fail(0xb48 /* unsupported */);\n\t\t},\n\t\tgetFieldPath() {\n\t\t\tfail(0xb49 /* unsupported */);\n\t\t},\n\t},\n\tindex: -1,\n};\n\nclass UnhydratedFlexTreeField implements FlexTreeField {\n\tpublic [flexTreeMarker] = FlexTreeEntityKind.Field as const;\n\n\tpublic get context(): FlexTreeContext {\n\t\treturn this.simpleContext.flexContext;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly simpleContext: Context,\n\t\tpublic readonly schema: FieldKindIdentifier,\n\t\tpublic readonly key: FieldKey,\n\t\tpublic readonly parent: UnhydratedFlexTreeNode,\n\t\tpublic readonly onEdit?: () => void,\n\t) {\n\t\tconst fieldKeyCache = getFieldKeyCache(parent);\n\t\tassert(!fieldKeyCache.has(key), 0x990 /* A field already exists for the given MapTrees */);\n\t\tfieldKeyCache.set(key, this);\n\n\t\t// When this field is created (which only happens one time, because it is cached), all the children become parented for the first time.\n\t\t// \"Adopt\" each child by updating its parent information to point to this field.\n\t\tfor (const [i, mapTree] of this.mapTrees.entries()) {\n\t\t\tconst mapTreeNodeChild = nodeCache.get(mapTree);\n\t\t\tif (mapTreeNodeChild !== undefined) {\n\t\t\t\tif (mapTreeNodeChild.parentField !== unparentedLocation) {\n\t\t\t\t\tthrow new UsageError(\"A node may not be in more than one place in the tree\");\n\t\t\t\t}\n\t\t\t\tmapTreeNodeChild.adoptBy(this, i);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get mapTrees(): readonly ExclusiveMapTree[] {\n\t\treturn this.parent.mapTree.fields.get(this.key) ?? [];\n\t}\n\n\tpublic get length(): number {\n\t\treturn this.mapTrees.length;\n\t}\n\n\tpublic is<TKind2 extends FlexFieldKind>(kind: TKind2): this is FlexTreeTypedField<TKind2> {\n\t\treturn this.schema === kind.identifier;\n\t}\n\n\tpublic boxedIterator(): IterableIterator<FlexTreeNode> {\n\t\treturn this.mapTrees\n\t\t\t.map(\n\t\t\t\t(m, index) =>\n\t\t\t\t\tgetOrCreateChild(this.simpleContext, m, {\n\t\t\t\t\t\tparent: this,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t}) as FlexTreeNode,\n\t\t\t)\n\t\t\t.values();\n\t}\n\n\tpublic boxedAt(index: number): FlexTreeNode | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst m = this.mapTrees[i];\n\t\tif (m !== undefined) {\n\t\t\treturn getOrCreateChild(this.simpleContext, m, {\n\t\t\t\tparent: this,\n\t\t\t\tindex: i,\n\t\t\t}) as FlexTreeNode;\n\t\t}\n\t}\n\n\t/**\n\t * Mutate this field.\n\t * @param edit - A function which receives the current `MapTree`s that comprise the contents of the field so that it may be mutated.\n\t * The function may mutate the array in place or return a new array.\n\t * If a new array is returned then it will be used as the new contents of the field, otherwise the original array will be continue to be used.\n\t * @remarks All edits to the field (i.e. mutations of the field's MapTrees) should be directed through this function.\n\t * This function ensures that the parent MapTree has no empty fields (which is an invariant of `MapTree`) after the mutation.\n\t */\n\tprotected edit(edit: (mapTrees: ExclusiveMapTree[]) => void | ExclusiveMapTree[]): void {\n\t\tconst oldMapTrees = this.parent.mapTree.fields.get(this.key) ?? [];\n\t\tconst newMapTrees = edit(oldMapTrees) ?? oldMapTrees;\n\t\tif (newMapTrees.length > 0) {\n\t\t\tthis.parent.mapTree.fields.set(this.key, newMapTrees);\n\t\t} else {\n\t\t\tthis.parent.mapTree.fields.delete(this.key);\n\t\t}\n\n\t\tthis.onEdit?.();\n\t}\n\n\tpublic getFieldPath(): NormalizedFieldUpPath {\n\t\tthrow unsupportedUsageError(\"Editing an array\");\n\t}\n\n\t/** Unboxes leaf nodes to their values */\n\tprotected unboxed(index: number): FlexTreeUnknownUnboxed {\n\t\tconst mapTree: ExclusiveMapTree = this.mapTrees[index] ?? oob();\n\t\tconst value = mapTree.value;\n\t\tif (value !== undefined) {\n\t\t\treturn value;\n\t\t}\n\n\t\treturn getOrCreateChild(this.simpleContext, mapTree, { parent: this, index });\n\t}\n}\n\nclass EagerMapTreeOptionalField\n\textends UnhydratedFlexTreeField\n\timplements FlexTreeOptionalField\n{\n\tpublic readonly editor = {\n\t\tset: (newContent: ExclusiveMapTree | undefined): void => {\n\t\t\t// If the new content is a UnhydratedFlexTreeNode, it needs to have its parent pointer updated\n\t\t\tif (newContent !== undefined) {\n\t\t\t\tnodeCache.get(newContent)?.adoptBy(this, 0);\n\t\t\t}\n\t\t\t// If the old content is a UnhydratedFlexTreeNode, it needs to have its parent pointer unset\n\t\t\tconst oldContent = this.mapTrees[0];\n\t\t\tif (oldContent !== undefined) {\n\t\t\t\tnodeCache.get(oldContent)?.adoptBy(undefined);\n\t\t\t}\n\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent !== undefined) {\n\t\t\t\t\tmapTrees[0] = newContent;\n\t\t\t\t} else {\n\t\t\t\t\tmapTrees.length = 0;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n\n\tpublic get content(): FlexTreeUnknownUnboxed | undefined {\n\t\tconst value = this.mapTrees[0];\n\t\tif (value !== undefined) {\n\t\t\treturn this.unboxed(0);\n\t\t}\n\n\t\treturn undefined;\n\t}\n}\n\nclass EagerMapTreeRequiredField\n\textends EagerMapTreeOptionalField\n\timplements FlexTreeRequiredField\n{\n\tpublic override get content(): FlexTreeUnknownUnboxed {\n\t\t// This cannot use ?? since null is a legal value here.\n\t\tassert(\n\t\t\tsuper.content !== undefined,\n\t\t\t0xa57 /* Expected EagerMapTree required field to have a value */,\n\t\t);\n\t\treturn super.content;\n\t}\n}\n\nexport class UnhydratedTreeSequenceField\n\textends UnhydratedFlexTreeField\n\timplements FlexTreeSequenceField\n{\n\tpublic readonly editor: UnhydratedTreeSequenceFieldEditBuilder = {\n\t\tinsert: (index, newContent): void => {\n\t\t\tfor (let i = 0; i < newContent.length; i++) {\n\t\t\t\tconst c = newContent[i];\n\t\t\t\tassert(c !== undefined, 0xa0a /* Unexpected sparse array content */);\n\t\t\t\tnodeCache.get(c)?.adoptBy(this, index + i);\n\t\t\t}\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tif (newContent.length < 1000) {\n\t\t\t\t\t// For \"smallish arrays\" (`1000` is not empirically derived), the `splice` function is appropriate...\n\t\t\t\t\tmapTrees.splice(index, 0, ...newContent);\n\t\t\t\t} else {\n\t\t\t\t\t// ...but we avoid using `splice` + spread for very large input arrays since there is a limit on how many elements can be spread (too many will overflow the stack).\n\t\t\t\t\treturn mapTrees.slice(0, index).concat(newContent, mapTrees.slice(index));\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tremove: (index, count): ExclusiveMapTree[] => {\n\t\t\tfor (let i = index; i < index + count; i++) {\n\t\t\t\tconst c = this.mapTrees[i];\n\t\t\t\tassert(c !== undefined, 0xa0b /* Unexpected sparse array */);\n\t\t\t\tnodeCache.get(c)?.adoptBy(undefined);\n\t\t\t}\n\t\t\tlet removed: ExclusiveMapTree[] | undefined;\n\t\t\tthis.edit((mapTrees) => {\n\t\t\t\tremoved = mapTrees.splice(index, count);\n\t\t\t});\n\t\t\treturn removed ?? fail(0xb4a /* Expected removed to be set by edit */);\n\t\t},\n\t};\n\n\tpublic at(index: number): FlexTreeUnknownUnboxed | undefined {\n\t\tconst i = indexForAt(index, this.length);\n\t\tif (i === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.unboxed(i);\n\t}\n\tpublic map<U>(callbackfn: (value: FlexTreeUnknownUnboxed, index: number) => U): U[] {\n\t\treturn Array.from(this, callbackfn);\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<FlexTreeUnknownUnboxed> {\n\t\tfor (const [i] of this.mapTrees.entries()) {\n\t\t\tyield this.unboxed(i);\n\t\t}\n\t}\n}\n\n// #endregion Fields\n\n// #region Caching and unboxing utilities\n\nconst nodeCache = new WeakMap<MapTree, UnhydratedFlexTreeNode>();\n/** Node Parent -\\> Field Key -\\> Field */\nconst fieldCache = new WeakMap<\n\tUnhydratedFlexTreeNode,\n\tMap<FieldKey, UnhydratedFlexTreeField>\n>();\nfunction getFieldKeyCache(\n\tparent: UnhydratedFlexTreeNode,\n): WeakMap<FieldKey, UnhydratedFlexTreeField> {\n\treturn getOrCreate(fieldCache, parent, () => new Map());\n}\n\n/**\n * If there exists a {@link UnhydratedFlexTreeNode} for the given {@link MapTree}, returns it, otherwise returns `undefined`.\n * @remarks {@link UnhydratedFlexTreeNode | UnhydratedFlexTreeNodes} are created via {@link getOrCreateNode}.\n */\nexport function tryUnhydratedFlexTreeNode(\n\tmapTree: MapTree,\n): UnhydratedFlexTreeNode | undefined {\n\treturn nodeCache.get(mapTree);\n}\n\n/** Helper for creating a `UnhydratedFlexTreeNode` given the parent field (e.g. when \"walking down\") */\nfunction getOrCreateChild(\n\tcontext: Context,\n\tmapTree: ExclusiveMapTree,\n\tparent: LocationInField | undefined,\n): UnhydratedFlexTreeNode {\n\tconst cached = nodeCache.get(mapTree);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\treturn new UnhydratedFlexTreeNode(context, mapTree, parent);\n}\n\n/** Creates a field with the given attributes, or returns a cached field if there is one */\nfunction getOrCreateField(\n\tparent: UnhydratedFlexTreeNode,\n\tkey: FieldKey,\n\tschema: FieldKindIdentifier,\n\tonEdit?: () => void,\n): UnhydratedFlexTreeField {\n\tconst cached = getFieldKeyCache(parent).get(key);\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\tif (\n\t\tschema === FieldKinds.required.identifier ||\n\t\tschema === FieldKinds.identifier.identifier\n\t) {\n\t\treturn new EagerMapTreeRequiredField(parent.simpleContext, schema, key, parent, onEdit);\n\t}\n\n\tif (schema === FieldKinds.optional.identifier) {\n\t\treturn new EagerMapTreeOptionalField(parent.simpleContext, schema, key, parent, onEdit);\n\t}\n\n\tif (schema === FieldKinds.sequence.identifier) {\n\t\treturn new UnhydratedTreeSequenceField(parent.simpleContext, schema, key, parent, onEdit);\n\t}\n\n\treturn new UnhydratedFlexTreeField(parent.simpleContext, schema, key, parent, onEdit);\n}\n\n// #endregion Caching and unboxing utilities\n\nexport function unsupportedUsageError(message?: string): Error {\n\treturn new UsageError(\n\t\t`${\n\t\t\tmessage ?? \"Operation\"\n\t\t} is not supported for content that has not yet been inserted into the tree`,\n\t);\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export { typeNameSymbol, typeSchemaSymbol, type WithType, type TreeNodeSchema, NodeKind, type TreeNodeSchemaClass, type TreeNodeSchemaNonClass, type TreeNodeSchemaCore, type TreeChangeEvents, type TreeNode, type Unhydrated, type InternalTreeNode, isTreeNode, tryDisposeTreeNode, HydratedContext, SimpleContextSlot, getOrCreateInnerNode, getKernel, } from "./core/index.js";
6
- export { type ITree, type TreeView, type ViewableTree, type TreeViewEvents, TreeViewConfiguration, type ITreeViewConfiguration, type SchemaCompatibilityStatus, type ITreeConfigurationOptions, SchemaFactory, SchemaFactoryAlpha, type SchemaFactoryObjectOptions, type ScopedSchemaName, type ValidateRecursiveSchema, type FixRecursiveArraySchema, adaptEnum, enumFromStrings, singletonSchema, test_RecursiveObject, test_RecursiveObject_base, test_RecursiveObjectPojoMode, treeNodeApi, type TreeNodeApi, cursorFromInsertable, createFromInsertable, type NodeChangedData, TreeBeta, type TreeChangeEventsBeta, type SimpleTreeIndex, type IdentifierIndex, createSimpleTreeIndex, createIdentifierIndex, type JsonSchemaId, type JsonSchemaType, type JsonObjectNodeSchema, type JsonArrayNodeSchema, type JsonMapNodeSchema, type JsonLeafNodeSchema, type JsonSchemaRef, type JsonRefPath, type JsonNodeSchema, type JsonNodeSchemaBase, type JsonTreeSchema, type JsonFieldSchema, type JsonLeafSchemaType, getJsonSchema, getSimpleSchema, type VerboseTreeNode, type EncodeOptions, type ParseOptions, type VerboseTree, extractPersistedSchema, comparePersistedSchema, type ConciseTree, comparePersistedSchemaInternal, ViewSchema, type Unenforced, type FieldHasDefaultUnsafe, type ObjectFromSchemaRecordUnsafe, type TreeObjectNodeUnsafe, type TreeFieldFromImplicitFieldUnsafe, type TreeNodeFromImplicitAllowedTypesUnsafe, type FieldSchemaUnsafe, type InsertableTreeNodeFromImplicitAllowedTypesUnsafe, type TreeArrayNodeUnsafe, type TreeMapNodeUnsafe, type InsertableObjectFromSchemaRecordUnsafe, type InsertableTreeFieldFromImplicitFieldUnsafe, type InsertableTypedNodeUnsafe, type NodeBuilderDataUnsafe, type NodeFromSchemaUnsafe, type ReadonlyMapInlined, type TreeNodeSchemaClassUnsafe, type TreeNodeSchemaUnsafe, type AllowedTypesUnsafe, type ImplicitAllowedTypesUnsafe, type ImplicitFieldSchemaUnsafe, type TreeNodeSchemaNonClassUnsafe, type InsertableTreeNodeFromAllowedTypesUnsafe, type ArrayNodeCustomizableSchemaUnsafe, type MapNodeCustomizableSchemaUnsafe, type TreeViewAlpha, type TreeBranch, type TreeBranchEvents, tryGetSchema, applySchemaToParserOptions, cursorFromVerbose, verboseFromCursor, conciseFromCursor, createFromCursor, asTreeViewAlpha, customFromCursorStored, type CustomTreeNode, type CustomTreeValue, tryStoredSchemaAsArray, type SchemaStatics, type ITreeAlpha, type TransactionConstraint, type NodeInDocumentConstraint, type RunTransactionParams, type VoidTransactionCallbackStatus, type TransactionCallbackStatus, type TransactionResult, type TransactionResultExt, type TransactionResultSuccess, type TransactionResultFailed, rollback, generateSchemaFromSimpleSchema, replaceConciseTreeHandles, replaceHandles, replaceVerboseTreeHandles, type HandleConverter, type FieldSchemaAlphaUnsafe, } from "./api/index.js";
6
+ export { type ITree, type TreeView, type ViewableTree, type TreeViewEvents, TreeViewConfiguration, TreeViewConfigurationAlpha, type ITreeViewConfiguration, type SchemaCompatibilityStatus, type ITreeConfigurationOptions, SchemaFactory, SchemaFactoryAlpha, type SchemaFactoryObjectOptions, type ScopedSchemaName, type ValidateRecursiveSchema, type FixRecursiveArraySchema, adaptEnum, enumFromStrings, singletonSchema, test_RecursiveObject, test_RecursiveObject_base, test_RecursiveObjectPojoMode, treeNodeApi, type TreeNodeApi, cursorFromInsertable, createFromInsertable, type NodeChangedData, TreeBeta, type TreeChangeEventsBeta, type SimpleTreeIndex, type IdentifierIndex, createSimpleTreeIndex, createIdentifierIndex, type JsonSchemaId, type JsonSchemaType, type JsonObjectNodeSchema, type JsonArrayNodeSchema, type JsonMapNodeSchema, type JsonLeafNodeSchema, type JsonSchemaRef, type JsonRefPath, type JsonNodeSchema, type JsonNodeSchemaBase, type JsonTreeSchema, type JsonFieldSchema, type JsonLeafSchemaType, type TreeSchemaEncodingOptions, getJsonSchema, getSimpleSchema, type VerboseTreeNode, type TreeEncodingOptions, type VerboseTree, extractPersistedSchema, comparePersistedSchema, type ConciseTree, comparePersistedSchemaInternal, ViewSchema, type Unenforced, type FieldHasDefaultUnsafe, type ObjectFromSchemaRecordUnsafe, type TreeObjectNodeUnsafe, type TreeFieldFromImplicitFieldUnsafe, type TreeNodeFromImplicitAllowedTypesUnsafe, type FieldSchemaUnsafe, type InsertableTreeNodeFromImplicitAllowedTypesUnsafe, type TreeArrayNodeUnsafe, type TreeMapNodeUnsafe, type InsertableObjectFromSchemaRecordUnsafe, type InsertableTreeFieldFromImplicitFieldUnsafe, type InsertableTypedNodeUnsafe, type NodeBuilderDataUnsafe, type NodeFromSchemaUnsafe, type ReadonlyMapInlined, type TreeNodeSchemaClassUnsafe, type TreeNodeSchemaUnsafe, type AllowedTypesUnsafe, type ImplicitAllowedTypesUnsafe, type ImplicitFieldSchemaUnsafe, type TreeNodeSchemaNonClassUnsafe, type InsertableTreeNodeFromAllowedTypesUnsafe, type ArrayNodeCustomizableSchemaUnsafe, type MapNodeCustomizableSchemaUnsafe, type TreeViewAlpha, type TreeBranch, type TreeBranchEvents, tryGetSchema, applySchemaToParserOptions, cursorFromVerbose, verboseFromCursor, conciseFromCursor, createFromCursor, asTreeViewAlpha, customFromCursorStored, type CustomTreeNode, type CustomTreeValue, tryStoredSchemaAsArray, type SchemaStatics, type ITreeAlpha, type TransactionConstraint, type NodeInDocumentConstraint, type RunTransactionParams, type VoidTransactionCallbackStatus, type TransactionCallbackStatus, type TransactionResult, type TransactionResultExt, type TransactionResultSuccess, type TransactionResultFailed, rollback, generateSchemaFromSimpleSchema, replaceConciseTreeHandles, replaceHandles, replaceVerboseTreeHandles, type HandleConverter, type FieldSchemaAlphaUnsafe, type TreeSchema, } from "./api/index.js";
7
7
  export type { SimpleTreeSchema, SimpleNodeSchema, SimpleFieldSchema, SimpleLeafNodeSchema, SimpleMapNodeSchema, SimpleArrayNodeSchema, SimpleObjectNodeSchema, SimpleNodeSchemaBase, SimpleObjectFieldSchema, } from "./simpleSchema.js";
8
8
  export { type NodeFromSchema, isTreeNodeSchemaClass, type ImplicitFieldSchema, type TreeFieldFromImplicitField, type ImplicitAllowedTypes, type TreeNodeFromImplicitAllowedTypes, type InsertableTreeNodeFromImplicitAllowedTypes, type TreeLeafValue, type AllowedTypes, FieldKind, FieldSchema, type FieldSchemaAlpha, type InsertableTreeFieldFromImplicitField, type InsertableTypedNode, type NodeBuilderData, type DefaultProvider, type FieldProps, normalizeFieldSchema, areFieldSchemaEqual, areImplicitFieldSchemaEqual, type ApplyKind, type FieldSchemaMetadata, type InsertableField, type Insertable, type UnsafeUnknownSchema, normalizeAllowedTypes, type ApplyKindInput, type InsertableTreeNodeFromAllowedTypes, type Input, type ReadableField, type ReadSchema, type NodeSchemaOptions, type NodeSchemaMetadata, evaluateLazySchema, } from "./schemaTypes.js";
9
9
  export { getTreeNodeForField, prepareContentForHydration, } from "./proxies.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,QAAQ,EACR,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EAGrB,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,aAAa,EACb,kBAAkB,EAClB,KAAK,0BAA0B,EAC/B,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,SAAS,EACT,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,yBAAyB,EACzB,4BAA4B,EAC5B,WAAW,EACX,KAAK,WAAW,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,eAA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MAAM,sBAAsB,CAAC;AACxD,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EACN,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,oBAAoB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,UAAU,GACV,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
@@ -4,8 +4,8 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.areImplicitFieldSchemaEqual = exports.areFieldSchemaEqual = exports.normalizeFieldSchema = exports.FieldSchema = exports.FieldKind = exports.isTreeNodeSchemaClass = exports.replaceVerboseTreeHandles = exports.replaceHandles = exports.replaceConciseTreeHandles = exports.generateSchemaFromSimpleSchema = exports.rollback = exports.tryStoredSchemaAsArray = exports.customFromCursorStored = exports.asTreeViewAlpha = exports.createFromCursor = exports.conciseFromCursor = exports.verboseFromCursor = exports.cursorFromVerbose = exports.applySchemaToParserOptions = exports.tryGetSchema = exports.ViewSchema = exports.comparePersistedSchemaInternal = exports.comparePersistedSchema = exports.extractPersistedSchema = exports.getSimpleSchema = exports.getJsonSchema = exports.createIdentifierIndex = exports.createSimpleTreeIndex = exports.TreeBeta = exports.createFromInsertable = exports.cursorFromInsertable = exports.treeNodeApi = exports.test_RecursiveObjectPojoMode = exports.test_RecursiveObject_base = exports.test_RecursiveObject = exports.singletonSchema = exports.enumFromStrings = exports.adaptEnum = exports.SchemaFactoryAlpha = exports.SchemaFactory = exports.TreeViewConfiguration = exports.getKernel = exports.getOrCreateInnerNode = exports.SimpleContextSlot = exports.HydratedContext = exports.tryDisposeTreeNode = exports.isTreeNode = exports.NodeKind = exports.typeSchemaSymbol = exports.typeNameSymbol = void 0;
8
- exports.nullSchema = exports.handleSchema = exports.booleanSchema = exports.stringSchema = exports.numberSchema = exports.getStoredSchema = exports.toStoredSchema = exports.mapTreeFromNodeData = exports.ObjectNodeSchema = exports.createUnknownOptionalFieldPolicy = exports.setField = exports.isMapNodeSchema = exports.MapNodeSchema = exports.isArrayNodeSchema = exports.ArrayNodeSchema = exports.IterableTreeArrayContent = exports.TreeArrayNode = exports.prepareContentForHydration = exports.getTreeNodeForField = exports.evaluateLazySchema = exports.normalizeAllowedTypes = void 0;
7
+ exports.areFieldSchemaEqual = exports.normalizeFieldSchema = exports.FieldSchema = exports.FieldKind = exports.isTreeNodeSchemaClass = exports.replaceVerboseTreeHandles = exports.replaceHandles = exports.replaceConciseTreeHandles = exports.generateSchemaFromSimpleSchema = exports.rollback = exports.tryStoredSchemaAsArray = exports.customFromCursorStored = exports.asTreeViewAlpha = exports.createFromCursor = exports.conciseFromCursor = exports.verboseFromCursor = exports.cursorFromVerbose = exports.applySchemaToParserOptions = exports.tryGetSchema = exports.ViewSchema = exports.comparePersistedSchemaInternal = exports.comparePersistedSchema = exports.extractPersistedSchema = exports.getSimpleSchema = exports.getJsonSchema = exports.createIdentifierIndex = exports.createSimpleTreeIndex = exports.TreeBeta = exports.createFromInsertable = exports.cursorFromInsertable = exports.treeNodeApi = exports.test_RecursiveObjectPojoMode = exports.test_RecursiveObject_base = exports.test_RecursiveObject = exports.singletonSchema = exports.enumFromStrings = exports.adaptEnum = exports.SchemaFactoryAlpha = exports.SchemaFactory = exports.TreeViewConfigurationAlpha = exports.TreeViewConfiguration = exports.getKernel = exports.getOrCreateInnerNode = exports.SimpleContextSlot = exports.HydratedContext = exports.tryDisposeTreeNode = exports.isTreeNode = exports.NodeKind = exports.typeSchemaSymbol = exports.typeNameSymbol = void 0;
8
+ exports.nullSchema = exports.handleSchema = exports.booleanSchema = exports.stringSchema = exports.numberSchema = exports.getStoredSchema = exports.toStoredSchema = exports.mapTreeFromNodeData = exports.ObjectNodeSchema = exports.createUnknownOptionalFieldPolicy = exports.setField = exports.isMapNodeSchema = exports.MapNodeSchema = exports.isArrayNodeSchema = exports.ArrayNodeSchema = exports.IterableTreeArrayContent = exports.TreeArrayNode = exports.prepareContentForHydration = exports.getTreeNodeForField = exports.evaluateLazySchema = exports.normalizeAllowedTypes = exports.areImplicitFieldSchemaEqual = void 0;
9
9
  var index_js_1 = require("./core/index.js");
10
10
  Object.defineProperty(exports, "typeNameSymbol", { enumerable: true, get: function () { return index_js_1.typeNameSymbol; } });
11
11
  Object.defineProperty(exports, "typeSchemaSymbol", { enumerable: true, get: function () { return index_js_1.typeSchemaSymbol; } });
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "getOrCreateInnerNode", { enumerable: true, get:
18
18
  Object.defineProperty(exports, "getKernel", { enumerable: true, get: function () { return index_js_1.getKernel; } });
19
19
  var index_js_2 = require("./api/index.js");
20
20
  Object.defineProperty(exports, "TreeViewConfiguration", { enumerable: true, get: function () { return index_js_2.TreeViewConfiguration; } });
21
+ Object.defineProperty(exports, "TreeViewConfigurationAlpha", { enumerable: true, get: function () { return index_js_2.TreeViewConfigurationAlpha; } });
21
22
  Object.defineProperty(exports, "SchemaFactory", { enumerable: true, get: function () { return index_js_2.SchemaFactory; } });
22
23
  Object.defineProperty(exports, "SchemaFactoryAlpha", { enumerable: true, get: function () { return index_js_2.SchemaFactoryAlpha; } });
23
24
  Object.defineProperty(exports, "adaptEnum", { enumerable: true, get: function () { return index_js_2.adaptEnum; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,4CAqByB;AApBxB,0GAAA,cAAc,OAAA;AACd,4GAAA,gBAAgB,OAAA;AAGhB,oGAAA,QAAQ,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AA,oBAAoB,OAAA;AACpB,qHAAA,mBAAmB,OAAA;AACnB,6HAAA,2BAA2B,OAAA;AAM3B,uHAAA,qBAAqB,OAAA;AAQrB,oHAAA,kBAAkB,OAAA;AAEnB,2CAGsB;AAFrB,iHAAA,mBAAmB,OAAA;AACnB,wHAAA,0BAA0B,OAAA;AAE3B,+CAIwB;AAHvB,6GAAA,aAAa,OAAA;AACb,wHAAA,wBAAwB,OAAA;AAOzB,yDAAyE;AAAhE,oHAAA,eAAe,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AAK3C,qDAAmE;AAA1D,gHAAA,aAAa,OAAA;AAAE,kHAAA,eAAe,OAAA;AACvC,iDAOyB;AAFxB,yGAAA,QAAQ,OAAA;AACR,iIAAA,gCAAgC,OAAA;AAEjC,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AAEzB,+CAKwB;AAJvB,mHAAA,mBAAmB,OAAA;AAKpB,yDAAsE;AAA7D,mHAAA,cAAc,OAAA;AAAE,oHAAA,eAAe,OAAA;AACxC,yDAM6B;AAL5B,iHAAA,YAAY,OAAA;AACZ,iHAAA,YAAY,OAAA;AACZ,kHAAA,aAAa,OAAA;AACb,iHAAA,YAAY,OAAA;AACZ,+GAAA,UAAU,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype WithType,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype TreeNodeSchemaNonClass,\n\ttype TreeNodeSchemaCore,\n\ttype TreeChangeEvents,\n\t// TreeNode is only type exported, which prevents use of the class object for unsupported use-cases like direct sub-classing and instanceof.\n\t// See docs on TreeNode for more details.\n\ttype TreeNode,\n\ttype Unhydrated,\n\ttype InternalTreeNode,\n\tisTreeNode,\n\ttryDisposeTreeNode,\n\tHydratedContext,\n\tSimpleContextSlot,\n\tgetOrCreateInnerNode,\n\tgetKernel,\n} from \"./core/index.js\";\nexport {\n\ttype ITree,\n\ttype TreeView,\n\ttype ViewableTree,\n\ttype TreeViewEvents,\n\tTreeViewConfiguration,\n\ttype ITreeViewConfiguration,\n\ttype SchemaCompatibilityStatus,\n\ttype ITreeConfigurationOptions,\n\tSchemaFactory,\n\tSchemaFactoryAlpha,\n\ttype SchemaFactoryObjectOptions,\n\ttype ScopedSchemaName,\n\ttype ValidateRecursiveSchema,\n\ttype FixRecursiveArraySchema,\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n\ttest_RecursiveObject,\n\ttest_RecursiveObject_base,\n\ttest_RecursiveObjectPojoMode,\n\ttreeNodeApi,\n\ttype TreeNodeApi,\n\tcursorFromInsertable,\n\tcreateFromInsertable,\n\ttype NodeChangedData,\n\tTreeBeta,\n\ttype TreeChangeEventsBeta,\n\ttype SimpleTreeIndex,\n\ttype IdentifierIndex,\n\tcreateSimpleTreeIndex,\n\tcreateIdentifierIndex,\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n\tgetJsonSchema,\n\tgetSimpleSchema,\n\ttype VerboseTreeNode,\n\ttype EncodeOptions,\n\ttype ParseOptions,\n\ttype VerboseTree,\n\textractPersistedSchema,\n\tcomparePersistedSchema,\n\ttype ConciseTree,\n\tcomparePersistedSchemaInternal,\n\tViewSchema,\n\ttype Unenforced,\n\ttype FieldHasDefaultUnsafe,\n\ttype ObjectFromSchemaRecordUnsafe,\n\ttype TreeObjectNodeUnsafe,\n\ttype TreeFieldFromImplicitFieldUnsafe,\n\ttype TreeNodeFromImplicitAllowedTypesUnsafe,\n\ttype FieldSchemaUnsafe,\n\ttype InsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\ttype TreeArrayNodeUnsafe,\n\ttype TreeMapNodeUnsafe,\n\ttype InsertableObjectFromSchemaRecordUnsafe,\n\ttype InsertableTreeFieldFromImplicitFieldUnsafe,\n\ttype InsertableTypedNodeUnsafe,\n\ttype NodeBuilderDataUnsafe,\n\ttype NodeFromSchemaUnsafe,\n\ttype ReadonlyMapInlined,\n\ttype TreeNodeSchemaClassUnsafe,\n\ttype TreeNodeSchemaUnsafe,\n\ttype AllowedTypesUnsafe,\n\ttype ImplicitAllowedTypesUnsafe,\n\ttype ImplicitFieldSchemaUnsafe,\n\ttype TreeNodeSchemaNonClassUnsafe,\n\ttype InsertableTreeNodeFromAllowedTypesUnsafe,\n\ttype ArrayNodeCustomizableSchemaUnsafe,\n\ttype MapNodeCustomizableSchemaUnsafe,\n\ttype TreeViewAlpha,\n\ttype TreeBranch,\n\ttype TreeBranchEvents,\n\ttryGetSchema,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\tconciseFromCursor,\n\tcreateFromCursor,\n\tasTreeViewAlpha,\n\tcustomFromCursorStored,\n\ttype CustomTreeNode,\n\ttype CustomTreeValue,\n\ttryStoredSchemaAsArray,\n\ttype SchemaStatics,\n\ttype ITreeAlpha,\n\ttype TransactionConstraint,\n\ttype NodeInDocumentConstraint,\n\ttype RunTransactionParams,\n\ttype VoidTransactionCallbackStatus,\n\ttype TransactionCallbackStatus,\n\ttype TransactionResult,\n\ttype TransactionResultExt,\n\ttype TransactionResultSuccess,\n\ttype TransactionResultFailed,\n\trollback,\n\tgenerateSchemaFromSimpleSchema,\n\treplaceConciseTreeHandles,\n\treplaceHandles,\n\treplaceVerboseTreeHandles,\n\ttype HandleConverter,\n\ttype FieldSchemaAlphaUnsafe,\n} from \"./api/index.js\";\nexport type {\n\tSimpleTreeSchema,\n\tSimpleNodeSchema,\n\tSimpleFieldSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleArrayNodeSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleNodeSchemaBase,\n\tSimpleObjectFieldSchema,\n} from \"./simpleSchema.js\";\nexport {\n\ttype NodeFromSchema,\n\tisTreeNodeSchemaClass,\n\ttype ImplicitFieldSchema,\n\ttype TreeFieldFromImplicitField,\n\ttype ImplicitAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype TreeLeafValue,\n\ttype AllowedTypes,\n\tFieldKind,\n\tFieldSchema,\n\ttype FieldSchemaAlpha,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype InsertableTypedNode,\n\ttype NodeBuilderData,\n\ttype DefaultProvider,\n\ttype FieldProps,\n\tnormalizeFieldSchema,\n\tareFieldSchemaEqual,\n\tareImplicitFieldSchemaEqual,\n\ttype ApplyKind,\n\ttype FieldSchemaMetadata,\n\ttype InsertableField,\n\ttype Insertable,\n\ttype UnsafeUnknownSchema,\n\tnormalizeAllowedTypes,\n\ttype ApplyKindInput,\n\ttype InsertableTreeNodeFromAllowedTypes,\n\ttype Input,\n\ttype ReadableField,\n\ttype ReadSchema,\n\ttype NodeSchemaOptions,\n\ttype NodeSchemaMetadata,\n\tevaluateLazySchema,\n} from \"./schemaTypes.js\";\nexport {\n\tgetTreeNodeForField,\n\tprepareContentForHydration,\n} from \"./proxies.js\";\nexport {\n\tTreeArrayNode,\n\tIterableTreeArrayContent,\n\ttype ReadonlyArrayNode,\n} from \"./arrayNode.js\";\nexport type {\n\tArrayNodeCustomizableSchema,\n\tArrayNodePojoEmulationSchema,\n} from \"./arrayNodeTypes.js\";\nexport { ArrayNodeSchema, isArrayNodeSchema } from \"./arrayNodeTypes.js\";\nexport type {\n\tMapNodeCustomizableSchema,\n\tMapNodePojoEmulationSchema,\n} from \"./mapNodeTypes.js\";\nexport { MapNodeSchema, isMapNodeSchema } from \"./mapNodeTypes.js\";\nexport {\n\ttype FieldHasDefault,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype ObjectFromSchemaRecord,\n\ttype TreeObjectNode,\n\tsetField,\n\tcreateUnknownOptionalFieldPolicy,\n} from \"./objectNode.js\";\nexport { ObjectNodeSchema } from \"./objectNodeTypes.js\";\nexport type { TreeMapNode, MapNodeInsertableData } from \"./mapNode.js\";\nexport {\n\tmapTreeFromNodeData,\n\ttype InsertableContent,\n\ttype FactoryContent,\n\ttype FactoryContentObject,\n} from \"./toMapTree.js\";\nexport { toStoredSchema, getStoredSchema } from \"./toStoredSchema.js\";\nexport {\n\tnumberSchema,\n\tstringSchema,\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n} from \"./leafNodeSchema.js\";\nexport type { LeafSchema } from \"./leafNodeSchema.js\";\nexport type { LazyItem, FlexList, FlexListToUnion, ExtractItemType } from \"./flexList.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,4CAqByB;AApBxB,0GAAA,cAAc,OAAA;AACd,4GAAA,gBAAgB,OAAA;AAGhB,oGAAA,QAAQ,OAAA;AAUR,sGAAA,UAAU,OAAA;AACV,8GAAA,kBAAkB,OAAA;AAClB,2GAAA,eAAe,OAAA;AACf,6GAAA,iBAAiB,OAAA;AACjB,gHAAA,oBAAoB,OAAA;AACpB,qGAAA,SAAS,OAAA;AAEV,2CAmHwB;AA9GvB,iHAAA,qBAAqB,OAAA;AACrB,sHAAA,0BAA0B,OAAA;AAI1B,yGAAA,aAAa,OAAA;AACb,8GAAA,kBAAkB,OAAA;AAKlB,qGAAA,SAAS,OAAA;AACT,2GAAA,eAAe,OAAA;AACf,2GAAA,eAAe,OAAA;AACf,gHAAA,oBAAoB,OAAA;AACpB,qHAAA,yBAAyB,OAAA;AACzB,wHAAA,4BAA4B,OAAA;AAC5B,uGAAA,WAAW,OAAA;AAEX,gHAAA,oBAAoB,OA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gC,OAAA;AAEjC,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AAEzB,+CAKwB;AAJvB,mHAAA,mBAAmB,OAAA;AAKpB,yDAAsE;AAA7D,mHAAA,cAAc,OAAA;AAAE,oHAAA,eAAe,OAAA;AACxC,yDAM6B;AAL5B,iHAAA,YAAY,OAAA;AACZ,iHAAA,YAAY,OAAA;AACZ,kHAAA,aAAa,OAAA;AACb,iHAAA,YAAY,OAAA;AACZ,+GAAA,UAAU,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype WithType,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype TreeNodeSchemaNonClass,\n\ttype TreeNodeSchemaCore,\n\ttype TreeChangeEvents,\n\t// TreeNode is only type exported, which prevents use of the class object for unsupported use-cases like direct sub-classing and instanceof.\n\t// See docs on TreeNode for more details.\n\ttype TreeNode,\n\ttype Unhydrated,\n\ttype InternalTreeNode,\n\tisTreeNode,\n\ttryDisposeTreeNode,\n\tHydratedContext,\n\tSimpleContextSlot,\n\tgetOrCreateInnerNode,\n\tgetKernel,\n} from \"./core/index.js\";\nexport {\n\ttype ITree,\n\ttype TreeView,\n\ttype ViewableTree,\n\ttype TreeViewEvents,\n\tTreeViewConfiguration,\n\tTreeViewConfigurationAlpha,\n\ttype ITreeViewConfiguration,\n\ttype SchemaCompatibilityStatus,\n\ttype ITreeConfigurationOptions,\n\tSchemaFactory,\n\tSchemaFactoryAlpha,\n\ttype SchemaFactoryObjectOptions,\n\ttype ScopedSchemaName,\n\ttype ValidateRecursiveSchema,\n\ttype FixRecursiveArraySchema,\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n\ttest_RecursiveObject,\n\ttest_RecursiveObject_base,\n\ttest_RecursiveObjectPojoMode,\n\ttreeNodeApi,\n\ttype TreeNodeApi,\n\tcursorFromInsertable,\n\tcreateFromInsertable,\n\ttype NodeChangedData,\n\tTreeBeta,\n\ttype TreeChangeEventsBeta,\n\ttype SimpleTreeIndex,\n\ttype IdentifierIndex,\n\tcreateSimpleTreeIndex,\n\tcreateIdentifierIndex,\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n\ttype TreeSchemaEncodingOptions,\n\tgetJsonSchema,\n\tgetSimpleSchema,\n\ttype VerboseTreeNode,\n\ttype TreeEncodingOptions,\n\ttype VerboseTree,\n\textractPersistedSchema,\n\tcomparePersistedSchema,\n\ttype ConciseTree,\n\tcomparePersistedSchemaInternal,\n\tViewSchema,\n\ttype Unenforced,\n\ttype FieldHasDefaultUnsafe,\n\ttype ObjectFromSchemaRecordUnsafe,\n\ttype TreeObjectNodeUnsafe,\n\ttype TreeFieldFromImplicitFieldUnsafe,\n\ttype TreeNodeFromImplicitAllowedTypesUnsafe,\n\ttype FieldSchemaUnsafe,\n\ttype InsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\ttype TreeArrayNodeUnsafe,\n\ttype TreeMapNodeUnsafe,\n\ttype InsertableObjectFromSchemaRecordUnsafe,\n\ttype InsertableTreeFieldFromImplicitFieldUnsafe,\n\ttype InsertableTypedNodeUnsafe,\n\ttype NodeBuilderDataUnsafe,\n\ttype NodeFromSchemaUnsafe,\n\ttype ReadonlyMapInlined,\n\ttype TreeNodeSchemaClassUnsafe,\n\ttype TreeNodeSchemaUnsafe,\n\ttype AllowedTypesUnsafe,\n\ttype ImplicitAllowedTypesUnsafe,\n\ttype ImplicitFieldSchemaUnsafe,\n\ttype TreeNodeSchemaNonClassUnsafe,\n\ttype InsertableTreeNodeFromAllowedTypesUnsafe,\n\ttype ArrayNodeCustomizableSchemaUnsafe,\n\ttype MapNodeCustomizableSchemaUnsafe,\n\ttype TreeViewAlpha,\n\ttype TreeBranch,\n\ttype TreeBranchEvents,\n\ttryGetSchema,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\tconciseFromCursor,\n\tcreateFromCursor,\n\tasTreeViewAlpha,\n\tcustomFromCursorStored,\n\ttype CustomTreeNode,\n\ttype CustomTreeValue,\n\ttryStoredSchemaAsArray,\n\ttype SchemaStatics,\n\ttype ITreeAlpha,\n\ttype TransactionConstraint,\n\ttype NodeInDocumentConstraint,\n\ttype RunTransactionParams,\n\ttype VoidTransactionCallbackStatus,\n\ttype TransactionCallbackStatus,\n\ttype TransactionResult,\n\ttype TransactionResultExt,\n\ttype TransactionResultSuccess,\n\ttype TransactionResultFailed,\n\trollback,\n\tgenerateSchemaFromSimpleSchema,\n\treplaceConciseTreeHandles,\n\treplaceHandles,\n\treplaceVerboseTreeHandles,\n\ttype HandleConverter,\n\ttype FieldSchemaAlphaUnsafe,\n\ttype TreeSchema,\n} from \"./api/index.js\";\nexport type {\n\tSimpleTreeSchema,\n\tSimpleNodeSchema,\n\tSimpleFieldSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleArrayNodeSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleNodeSchemaBase,\n\tSimpleObjectFieldSchema,\n} from \"./simpleSchema.js\";\nexport {\n\ttype NodeFromSchema,\n\tisTreeNodeSchemaClass,\n\ttype ImplicitFieldSchema,\n\ttype TreeFieldFromImplicitField,\n\ttype ImplicitAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype TreeLeafValue,\n\ttype AllowedTypes,\n\tFieldKind,\n\tFieldSchema,\n\ttype FieldSchemaAlpha,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype InsertableTypedNode,\n\ttype NodeBuilderData,\n\ttype DefaultProvider,\n\ttype FieldProps,\n\tnormalizeFieldSchema,\n\tareFieldSchemaEqual,\n\tareImplicitFieldSchemaEqual,\n\ttype ApplyKind,\n\ttype FieldSchemaMetadata,\n\ttype InsertableField,\n\ttype Insertable,\n\ttype UnsafeUnknownSchema,\n\tnormalizeAllowedTypes,\n\ttype ApplyKindInput,\n\ttype InsertableTreeNodeFromAllowedTypes,\n\ttype Input,\n\ttype ReadableField,\n\ttype ReadSchema,\n\ttype NodeSchemaOptions,\n\ttype NodeSchemaMetadata,\n\tevaluateLazySchema,\n} from \"./schemaTypes.js\";\nexport {\n\tgetTreeNodeForField,\n\tprepareContentForHydration,\n} from \"./proxies.js\";\nexport {\n\tTreeArrayNode,\n\tIterableTreeArrayContent,\n\ttype ReadonlyArrayNode,\n} from \"./arrayNode.js\";\nexport type {\n\tArrayNodeCustomizableSchema,\n\tArrayNodePojoEmulationSchema,\n} from \"./arrayNodeTypes.js\";\nexport { ArrayNodeSchema, isArrayNodeSchema } from \"./arrayNodeTypes.js\";\nexport type {\n\tMapNodeCustomizableSchema,\n\tMapNodePojoEmulationSchema,\n} from \"./mapNodeTypes.js\";\nexport { MapNodeSchema, isMapNodeSchema } from \"./mapNodeTypes.js\";\nexport {\n\ttype FieldHasDefault,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype ObjectFromSchemaRecord,\n\ttype TreeObjectNode,\n\tsetField,\n\tcreateUnknownOptionalFieldPolicy,\n} from \"./objectNode.js\";\nexport { ObjectNodeSchema } from \"./objectNodeTypes.js\";\nexport type { TreeMapNode, MapNodeInsertableData } from \"./mapNode.js\";\nexport {\n\tmapTreeFromNodeData,\n\ttype InsertableContent,\n\ttype FactoryContent,\n\ttype FactoryContentObject,\n} from \"./toMapTree.js\";\nexport { toStoredSchema, getStoredSchema } from \"./toStoredSchema.js\";\nexport {\n\tnumberSchema,\n\tstringSchema,\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n} from \"./leafNodeSchema.js\";\nexport type { LeafSchema } from \"./leafNodeSchema.js\";\nexport type { LazyItem, FlexList, FlexListToUnion, ExtractItemType } from \"./flexList.js\";\n"]}
@@ -152,20 +152,13 @@ export interface SimpleFieldSchema {
152
152
  * @alpha
153
153
  * @sealed
154
154
  */
155
- export interface SimpleTreeSchema extends SimpleFieldSchema {
155
+ export interface SimpleTreeSchema {
156
156
  /**
157
- * The kind of tree field representing the root of the tree.
157
+ * The tree field representing the root of the tree.
158
158
  */
159
- readonly kind: FieldKind;
160
- /**
161
- * The types allowed under the tree root.
162
- *
163
- * @remarks Refers to the types by identifier.
164
- * Can be resolved via {@link SimpleTreeSchema.definitions}.
165
- */
166
- readonly allowedTypesIdentifiers: ReadonlySet<string>;
159
+ readonly root: SimpleFieldSchema;
167
160
  /**
168
- * The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.allowedTypesIdentifiers}.
161
+ * The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.root}.
169
162
  *
170
163
  * @remarks the keys are the schemas' {@link TreeNodeSchemaCore.identifier | identifiers}.
171
164
  */
@@ -1 +1 @@
1
- {"version":3,"file":"simpleSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/simpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAO3F;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB,CACpC,GAAG,CAAC,SAAS,SAAS,QAAQ,EAC9B,GAAG,CAAC,eAAe,GAAG,OAAO;IAE7B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAEzB;;OAEG;IAC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E,iBAAiB,CAAC;IAEjC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"simpleSchema.js","sourceRoot":"","sources":["../../src/simple-tree/simpleSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ValueSchema } from \"../core/index.js\";\nimport type { NodeKind } from \"./core/index.js\";\nimport type { FieldKind, FieldSchemaMetadata, NodeSchemaMetadata } from \"./schemaTypes.js\";\n\n/*\n * TODO:\n * - Customize their JSON serialization to use these formats or provide some other serialization scheme.\n */\n\n/**\n * Base interface for {@link TreeNodeSchema} and {@link SimpleNodeSchema} types.\n * Once simple schema is stable this doesn't have a reason to be kept `@system`, but it could be.\n * @system\n * @public\n * @sealed\n */\nexport interface SimpleNodeSchemaBase<\n\tout TNodeKind extends NodeKind,\n\tout TCustomMetadata = unknown,\n> {\n\t/**\n\t * The {@link NodeKind}.\n\t *\n\t * @remarks can be used to type-switch between implementations.\n\t */\n\treadonly kind: TNodeKind;\n\n\t/**\n\t * User-provided {@link NodeSchemaMetadata} for this schema.\n\t */\n\treadonly metadata: NodeSchemaMetadata<TCustomMetadata>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for an object node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleObjectNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBase<NodeKind.Object, TCustomMetadata> {\n\t/**\n\t * Schemas for each of the object's fields, keyed off of schema's keys.\n\t * @remarks\n\t * The keys are the property keys if known, otherwise they are the stored keys.\n\t * Use {@link SimpleObjectFieldSchema.storedKey} to get the stored key.\n\t * @privateRemarks\n\t * TODO: Provide and link a way to translate from stored keys to the property keys.\n\t * TODO: Consider adding `storedKeysToFields` or something similar to reduce confusion,\n\t * especially if/when TreeNodeSchema for objects provide more maps.\n\t */\n\treadonly fields: ReadonlyMap<string, SimpleObjectFieldSchema>;\n}\n\n/**\n * A {@link SimpleFieldSchema} for an {@link SimpleObjectNodeSchema} field.\n * @remarks\n * The only other case fields are uses in the root schema.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleObjectFieldSchema extends SimpleFieldSchema {\n\t/**\n\t * The stored key of the field.\n\t * @remarks\n\t * See {@link FieldProps.key} for more information.\n\t */\n\treadonly storedKey: string;\n}\n\n/**\n * A {@link SimpleNodeSchema} for an array node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleArrayNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBase<NodeKind.Array, TCustomMetadata> {\n\t/**\n\t * The types allowed in the array.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for a map node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleMapNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBase<NodeKind.Map, TCustomMetadata> {\n\t/**\n\t * The types allowed as values in the map.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for a leaf node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleLeafNodeSchema extends SimpleNodeSchemaBase<NodeKind.Leaf> {\n\t/**\n\t * The kind of leaf node.\n\t */\n\treadonly leafKind: ValueSchema;\n}\n\n/**\n * A simple, shallow representation of a schema for a node.\n *\n * @remarks This definition is incomplete, and references child types by identifiers.\n * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which\n * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.\n *\n * Note that, as documented on {@link NodeKind}, more kinds of nodes may be added,\n * and therefore code should not assume that switching over all these cases can be done exhaustively.\n * @privateRemarks\n * Because of the above mentioned extensibility of node kinds, does it make sense to stabilize this?\n *\n * @alpha\n */\nexport type SimpleNodeSchema =\n\t| SimpleLeafNodeSchema\n\t| SimpleMapNodeSchema\n\t| SimpleArrayNodeSchema\n\t| SimpleObjectNodeSchema;\n\n/**\n * A simple, shallow representation of a schema for a field.\n *\n * @remarks This definition is incomplete, and references child types by identifiers.\n * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which\n * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleFieldSchema {\n\t/**\n\t * The kind of tree field.\n\t */\n\treadonly kind: FieldKind;\n\n\t/**\n\t * The types allowed under the field.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n\n\t/**\n\t * {@inheritDoc FieldSchemaMetadata}\n\t */\n\treadonly metadata: FieldSchemaMetadata;\n}\n\n/**\n * A simplified representation of a schema for a tree.\n *\n * @remarks Contains the complete set of schema {@link SimpleTreeSchema.definitions} required to resolve references,\n * which are represented inline with identifiers.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleTreeSchema extends SimpleFieldSchema {\n\t/**\n\t * The kind of tree field representing the root of the tree.\n\t */\n\treadonly kind: FieldKind;\n\n\t/**\n\t * The types allowed under the tree root.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * Can be resolved via {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n\n\t/**\n\t * The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.allowedTypesIdentifiers}.\n\t *\n\t * @remarks the keys are the schemas' {@link TreeNodeSchemaCore.identifier | identifiers}.\n\t */\n\treadonly definitions: ReadonlyMap<string, SimpleNodeSchema>;\n}\n"]}
1
+ {"version":3,"file":"simpleSchema.js","sourceRoot":"","sources":["../../src/simple-tree/simpleSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ValueSchema } from \"../core/index.js\";\nimport type { NodeKind } from \"./core/index.js\";\nimport type { FieldKind, FieldSchemaMetadata, NodeSchemaMetadata } from \"./schemaTypes.js\";\n\n/*\n * TODO:\n * - Customize their JSON serialization to use these formats or provide some other serialization scheme.\n */\n\n/**\n * Base interface for {@link TreeNodeSchema} and {@link SimpleNodeSchema} types.\n * Once simple schema is stable this doesn't have a reason to be kept `@system`, but it could be.\n * @system\n * @public\n * @sealed\n */\nexport interface SimpleNodeSchemaBase<\n\tout TNodeKind extends NodeKind,\n\tout TCustomMetadata = unknown,\n> {\n\t/**\n\t * The {@link NodeKind}.\n\t *\n\t * @remarks can be used to type-switch between implementations.\n\t */\n\treadonly kind: TNodeKind;\n\n\t/**\n\t * User-provided {@link NodeSchemaMetadata} for this schema.\n\t */\n\treadonly metadata: NodeSchemaMetadata<TCustomMetadata>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for an object node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleObjectNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBase<NodeKind.Object, TCustomMetadata> {\n\t/**\n\t * Schemas for each of the object's fields, keyed off of schema's keys.\n\t * @remarks\n\t * The keys are the property keys if known, otherwise they are the stored keys.\n\t * Use {@link SimpleObjectFieldSchema.storedKey} to get the stored key.\n\t * @privateRemarks\n\t * TODO: Provide and link a way to translate from stored keys to the property keys.\n\t * TODO: Consider adding `storedKeysToFields` or something similar to reduce confusion,\n\t * especially if/when TreeNodeSchema for objects provide more maps.\n\t */\n\treadonly fields: ReadonlyMap<string, SimpleObjectFieldSchema>;\n}\n\n/**\n * A {@link SimpleFieldSchema} for an {@link SimpleObjectNodeSchema} field.\n * @remarks\n * The only other case fields are uses in the root schema.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleObjectFieldSchema extends SimpleFieldSchema {\n\t/**\n\t * The stored key of the field.\n\t * @remarks\n\t * See {@link FieldProps.key} for more information.\n\t */\n\treadonly storedKey: string;\n}\n\n/**\n * A {@link SimpleNodeSchema} for an array node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleArrayNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBase<NodeKind.Array, TCustomMetadata> {\n\t/**\n\t * The types allowed in the array.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for a map node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleMapNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBase<NodeKind.Map, TCustomMetadata> {\n\t/**\n\t * The types allowed as values in the map.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for a leaf node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleLeafNodeSchema extends SimpleNodeSchemaBase<NodeKind.Leaf> {\n\t/**\n\t * The kind of leaf node.\n\t */\n\treadonly leafKind: ValueSchema;\n}\n\n/**\n * A simple, shallow representation of a schema for a node.\n *\n * @remarks This definition is incomplete, and references child types by identifiers.\n * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which\n * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.\n *\n * Note that, as documented on {@link NodeKind}, more kinds of nodes may be added,\n * and therefore code should not assume that switching over all these cases can be done exhaustively.\n * @privateRemarks\n * Because of the above mentioned extensibility of node kinds, does it make sense to stabilize this?\n *\n * @alpha\n */\nexport type SimpleNodeSchema =\n\t| SimpleLeafNodeSchema\n\t| SimpleMapNodeSchema\n\t| SimpleArrayNodeSchema\n\t| SimpleObjectNodeSchema;\n\n/**\n * A simple, shallow representation of a schema for a field.\n *\n * @remarks This definition is incomplete, and references child types by identifiers.\n * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which\n * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleFieldSchema {\n\t/**\n\t * The kind of tree field.\n\t */\n\treadonly kind: FieldKind;\n\n\t/**\n\t * The types allowed under the field.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n\n\t/**\n\t * {@inheritDoc FieldSchemaMetadata}\n\t */\n\treadonly metadata: FieldSchemaMetadata;\n}\n\n/**\n * A simplified representation of a schema for a tree.\n *\n * @remarks Contains the complete set of schema {@link SimpleTreeSchema.definitions} required to resolve references,\n * which are represented inline with identifiers.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleTreeSchema {\n\t/**\n\t * The tree field representing the root of the tree.\n\t */\n\treadonly root: SimpleFieldSchema;\n\n\t/**\n\t * The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.root}.\n\t *\n\t * @remarks the keys are the schemas' {@link TreeNodeSchemaCore.identifier | identifiers}.\n\t */\n\treadonly definitions: ReadonlyMap<string, SimpleNodeSchema>;\n}\n"]}