@fluidframework/tree 2.31.1 → 2.33.0-333010

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 (280) 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 +6 -1
  7. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  8. package/dist/feature-libraries/flex-tree/context.js +5 -2
  9. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  10. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  11. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  12. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  13. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  14. package/dist/feature-libraries/flex-tree/index.d.ts +1 -1
  15. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  16. package/dist/feature-libraries/flex-tree/index.js +1 -2
  17. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  18. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +6 -15
  19. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  20. package/dist/feature-libraries/flex-tree/lazyEntity.js +9 -18
  21. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  22. package/dist/feature-libraries/flex-tree/lazyField.d.ts +3 -3
  23. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  24. package/dist/feature-libraries/flex-tree/lazyField.js +14 -14
  25. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  26. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +4 -4
  27. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  28. package/dist/feature-libraries/flex-tree/lazyNode.js +12 -12
  29. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  30. package/dist/feature-libraries/index.d.ts +1 -1
  31. package/dist/feature-libraries/index.d.ts.map +1 -1
  32. package/dist/feature-libraries/index.js +1 -2
  33. package/dist/feature-libraries/index.js.map +1 -1
  34. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  35. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +29 -25
  36. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  37. package/dist/index.d.ts +2 -1
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +5 -2
  40. package/dist/index.js.map +1 -1
  41. package/dist/packageVersion.d.ts +1 -1
  42. package/dist/packageVersion.d.ts.map +1 -1
  43. package/dist/packageVersion.js +1 -1
  44. package/dist/packageVersion.js.map +1 -1
  45. package/dist/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  46. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  47. package/dist/shared-tree/checkoutFlexTreeView.js +4 -0
  48. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  49. package/dist/shared-tree/sharedTree.js +2 -2
  50. package/dist/shared-tree/sharedTree.js.map +1 -1
  51. package/dist/shared-tree/treeApiAlpha.d.ts +6 -6
  52. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
  53. package/dist/shared-tree/treeApiAlpha.js.map +1 -1
  54. package/dist/shared-tree-core/sharedTreeCore.d.ts +0 -6
  55. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  56. package/dist/shared-tree-core/sharedTreeCore.js +0 -17
  57. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  58. package/dist/simple-tree/api/conciseTree.d.ts +2 -2
  59. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  60. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  61. package/dist/simple-tree/api/customTree.d.ts +14 -12
  62. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  63. package/dist/simple-tree/api/customTree.js.map +1 -1
  64. package/dist/simple-tree/api/getJsonSchema.d.ts +21 -7
  65. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  66. package/dist/simple-tree/api/getJsonSchema.js +8 -16
  67. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  68. package/dist/simple-tree/api/getSimpleSchema.d.ts +3 -10
  69. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  70. package/dist/simple-tree/api/getSimpleSchema.js +4 -16
  71. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  72. package/dist/simple-tree/api/index.d.ts +4 -3
  73. package/dist/simple-tree/api/index.d.ts.map +1 -1
  74. package/dist/simple-tree/api/index.js +2 -1
  75. package/dist/simple-tree/api/index.js.map +1 -1
  76. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
  77. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  78. package/dist/simple-tree/api/schemaFactoryAlpha.js +4 -0
  79. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  80. package/dist/simple-tree/api/schemaFromSimple.d.ts +5 -2
  81. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  82. package/dist/simple-tree/api/schemaFromSimple.js +24 -8
  83. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  84. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +11 -3
  85. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  86. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +40 -28
  87. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  88. package/dist/simple-tree/api/tree.d.ts +32 -5
  89. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  90. package/dist/simple-tree/api/tree.js +17 -1
  91. package/dist/simple-tree/api/tree.js.map +1 -1
  92. package/dist/simple-tree/api/verboseTree.d.ts +4 -28
  93. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  94. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  95. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  96. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +7 -3
  97. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  98. package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -2
  99. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  100. package/dist/simple-tree/core/treeNodeKernel.js +46 -30
  101. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  102. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  103. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  104. package/dist/simple-tree/core/unhydratedFlexTree.js +15 -1
  105. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  106. package/dist/simple-tree/index.d.ts +1 -1
  107. package/dist/simple-tree/index.d.ts.map +1 -1
  108. package/dist/simple-tree/index.js +3 -2
  109. package/dist/simple-tree/index.js.map +1 -1
  110. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  111. package/dist/simple-tree/objectNode.js +3 -0
  112. package/dist/simple-tree/objectNode.js.map +1 -1
  113. package/dist/simple-tree/simpleSchema.d.ts +4 -11
  114. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  115. package/dist/simple-tree/simpleSchema.js.map +1 -1
  116. package/dist/tableSchema.d.ts +241 -0
  117. package/dist/tableSchema.d.ts.map +1 -0
  118. package/dist/tableSchema.js +238 -0
  119. package/dist/tableSchema.js.map +1 -0
  120. package/dist/treeFactory.d.ts +4 -4
  121. package/dist/treeFactory.d.ts.map +1 -1
  122. package/dist/treeFactory.js.map +1 -1
  123. package/dist/util/breakable.d.ts.map +1 -1
  124. package/dist/util/breakable.js +9 -7
  125. package/dist/util/breakable.js.map +1 -1
  126. package/lib/alpha.d.ts +6 -2
  127. package/lib/feature-libraries/flex-tree/context.d.ts +6 -1
  128. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  129. package/lib/feature-libraries/flex-tree/context.js +6 -3
  130. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  131. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  132. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  133. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  134. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  135. package/lib/feature-libraries/flex-tree/index.d.ts +1 -1
  136. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  137. package/lib/feature-libraries/flex-tree/index.js +1 -1
  138. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  139. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +6 -15
  140. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  141. package/lib/feature-libraries/flex-tree/lazyEntity.js +8 -17
  142. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  143. package/lib/feature-libraries/flex-tree/lazyField.d.ts +3 -3
  144. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  145. package/lib/feature-libraries/flex-tree/lazyField.js +15 -15
  146. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  147. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +4 -4
  148. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  149. package/lib/feature-libraries/flex-tree/lazyNode.js +13 -13
  150. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  151. package/lib/feature-libraries/index.d.ts +1 -1
  152. package/lib/feature-libraries/index.d.ts.map +1 -1
  153. package/lib/feature-libraries/index.js +1 -1
  154. package/lib/feature-libraries/index.js.map +1 -1
  155. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  156. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +28 -24
  157. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  158. package/lib/index.d.ts +2 -1
  159. package/lib/index.d.ts.map +1 -1
  160. package/lib/index.js +2 -1
  161. package/lib/index.js.map +1 -1
  162. package/lib/packageVersion.d.ts +1 -1
  163. package/lib/packageVersion.d.ts.map +1 -1
  164. package/lib/packageVersion.js +1 -1
  165. package/lib/packageVersion.js.map +1 -1
  166. package/lib/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  167. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  168. package/lib/shared-tree/checkoutFlexTreeView.js +4 -0
  169. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  170. package/lib/shared-tree/sharedTree.js +2 -2
  171. package/lib/shared-tree/sharedTree.js.map +1 -1
  172. package/lib/shared-tree/treeApiAlpha.d.ts +6 -6
  173. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
  174. package/lib/shared-tree/treeApiAlpha.js.map +1 -1
  175. package/lib/shared-tree-core/sharedTreeCore.d.ts +0 -6
  176. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  177. package/lib/shared-tree-core/sharedTreeCore.js +0 -17
  178. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  179. package/lib/simple-tree/api/conciseTree.d.ts +2 -2
  180. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  181. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  182. package/lib/simple-tree/api/customTree.d.ts +14 -12
  183. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  184. package/lib/simple-tree/api/customTree.js.map +1 -1
  185. package/lib/simple-tree/api/getJsonSchema.d.ts +21 -7
  186. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  187. package/lib/simple-tree/api/getJsonSchema.js +8 -16
  188. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  189. package/lib/simple-tree/api/getSimpleSchema.d.ts +3 -10
  190. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  191. package/lib/simple-tree/api/getSimpleSchema.js +4 -16
  192. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  193. package/lib/simple-tree/api/index.d.ts +4 -3
  194. package/lib/simple-tree/api/index.d.ts.map +1 -1
  195. package/lib/simple-tree/api/index.js +1 -1
  196. package/lib/simple-tree/api/index.js.map +1 -1
  197. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
  198. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  199. package/lib/simple-tree/api/schemaFactoryAlpha.js +4 -0
  200. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  201. package/lib/simple-tree/api/schemaFromSimple.d.ts +5 -2
  202. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  203. package/lib/simple-tree/api/schemaFromSimple.js +24 -8
  204. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  205. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +11 -3
  206. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  207. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +41 -29
  208. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  209. package/lib/simple-tree/api/tree.d.ts +32 -5
  210. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  211. package/lib/simple-tree/api/tree.js +16 -1
  212. package/lib/simple-tree/api/tree.js.map +1 -1
  213. package/lib/simple-tree/api/verboseTree.d.ts +4 -28
  214. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  215. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  216. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  217. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +7 -3
  218. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  219. package/lib/simple-tree/core/treeNodeKernel.d.ts +9 -2
  220. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  221. package/lib/simple-tree/core/treeNodeKernel.js +48 -32
  222. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  223. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  224. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  225. package/lib/simple-tree/core/unhydratedFlexTree.js +15 -1
  226. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  227. package/lib/simple-tree/index.d.ts +1 -1
  228. package/lib/simple-tree/index.d.ts.map +1 -1
  229. package/lib/simple-tree/index.js +1 -1
  230. package/lib/simple-tree/index.js.map +1 -1
  231. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  232. package/lib/simple-tree/objectNode.js +4 -1
  233. package/lib/simple-tree/objectNode.js.map +1 -1
  234. package/lib/simple-tree/simpleSchema.d.ts +4 -11
  235. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  236. package/lib/simple-tree/simpleSchema.js.map +1 -1
  237. package/lib/tableSchema.d.ts +241 -0
  238. package/lib/tableSchema.d.ts.map +1 -0
  239. package/lib/tableSchema.js +235 -0
  240. package/lib/tableSchema.js.map +1 -0
  241. package/lib/treeFactory.d.ts +4 -4
  242. package/lib/treeFactory.d.ts.map +1 -1
  243. package/lib/treeFactory.js.map +1 -1
  244. package/lib/util/breakable.d.ts.map +1 -1
  245. package/lib/util/breakable.js +9 -7
  246. package/lib/util/breakable.js.map +1 -1
  247. package/package.json +23 -22
  248. package/src/feature-libraries/flex-tree/context.ts +13 -3
  249. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +8 -0
  250. package/src/feature-libraries/flex-tree/index.ts +0 -1
  251. package/src/feature-libraries/flex-tree/lazyEntity.ts +11 -21
  252. package/src/feature-libraries/flex-tree/lazyField.ts +17 -26
  253. package/src/feature-libraries/flex-tree/lazyNode.ts +13 -19
  254. package/src/feature-libraries/index.ts +0 -1
  255. package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +39 -38
  256. package/src/index.ts +6 -2
  257. package/src/packageVersion.ts +1 -1
  258. package/src/shared-tree/checkoutFlexTreeView.ts +6 -0
  259. package/src/shared-tree/sharedTree.ts +2 -2
  260. package/src/shared-tree/treeApiAlpha.ts +17 -15
  261. package/src/shared-tree-core/sharedTreeCore.ts +0 -23
  262. package/src/simple-tree/api/conciseTree.ts +4 -4
  263. package/src/simple-tree/api/customTree.ts +16 -14
  264. package/src/simple-tree/api/getJsonSchema.ts +25 -16
  265. package/src/simple-tree/api/getSimpleSchema.ts +4 -18
  266. package/src/simple-tree/api/index.ts +4 -2
  267. package/src/simple-tree/api/schemaFactoryAlpha.ts +18 -1
  268. package/src/simple-tree/api/schemaFromSimple.ts +45 -16
  269. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +53 -34
  270. package/src/simple-tree/api/tree.ts +51 -4
  271. package/src/simple-tree/api/verboseTree.ts +7 -32
  272. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +8 -3
  273. package/src/simple-tree/core/treeNodeKernel.ts +57 -35
  274. package/src/simple-tree/core/unhydratedFlexTree.ts +22 -5
  275. package/src/simple-tree/index.ts +4 -2
  276. package/src/simple-tree/objectNode.ts +4 -2
  277. package/src/simple-tree/simpleSchema.ts +4 -12
  278. package/src/tableSchema.ts +668 -0
  279. package/src/treeFactory.ts +4 -3
  280. package/src/util/breakable.ts +9 -6
@@ -46,46 +46,47 @@ export interface NodeIdentifierManager {
46
46
  export function createNodeIdentifierManager(
47
47
  idCompressor?: IIdCompressor | undefined,
48
48
  ): NodeIdentifierManager {
49
- return {
50
- generateLocalNodeIdentifier: () => {
51
- assert(
52
- idCompressor !== undefined,
53
- 0x6e4 /* Runtime IdCompressor must be available to generate local node identifiers */,
54
- );
55
- return brand(idCompressor.generateCompressedId());
56
- },
57
-
58
- localizeNodeIdentifier: (identifier: StableNodeIdentifier) => {
59
- assert(
60
- idCompressor !== undefined,
61
- 0x6e5 /* Runtime IdCompressor must be available to convert node identifiers */,
62
- );
63
- return brand(idCompressor.recompress(identifier));
64
- },
49
+ return new DefaultNodeIdentifierManager(idCompressor);
50
+ }
65
51
 
66
- stabilizeNodeIdentifier: (identifier: LocalNodeIdentifier) => {
67
- assert(
68
- idCompressor !== undefined,
69
- 0x6e6 /* Runtime IdCompressor must be available to convert node identifiers */,
70
- );
71
- return brand(
72
- // TODO: The assert below is required for type safety but is maybe slow
73
- assertIsStableId(idCompressor.decompress(extractFromOpaque(identifier))),
74
- );
75
- },
76
- tryLocalizeNodeIdentifier: (identifier: string) => {
77
- assert(
78
- idCompressor !== undefined,
79
- 0x6e9 /* Runtime IdCompressor must be available to convert node identifiers */,
80
- );
81
- if (isStableNodeIdentifier(identifier)) {
82
- const compressedIdentifier = idCompressor.tryRecompress(identifier);
83
- if (compressedIdentifier !== undefined) {
84
- return brand(compressedIdentifier);
85
- }
52
+ class DefaultNodeIdentifierManager implements NodeIdentifierManager {
53
+ public constructor(private readonly idCompressor: IIdCompressor | undefined) {}
54
+ public generateLocalNodeIdentifier(): LocalNodeIdentifier {
55
+ assert(
56
+ this.idCompressor !== undefined,
57
+ 0x6e4 /* Runtime IdCompressor must be available to generate local node identifiers */,
58
+ );
59
+ return brand(this.idCompressor.generateCompressedId());
60
+ }
61
+ public localizeNodeIdentifier(identifier: StableNodeIdentifier): LocalNodeIdentifier {
62
+ assert(
63
+ this.idCompressor !== undefined,
64
+ 0x6e5 /* Runtime IdCompressor must be available to convert node identifiers */,
65
+ );
66
+ return brand(this.idCompressor.recompress(identifier));
67
+ }
68
+ public stabilizeNodeIdentifier(identifier: LocalNodeIdentifier): StableNodeIdentifier {
69
+ assert(
70
+ this.idCompressor !== undefined,
71
+ 0x6e6 /* Runtime IdCompressor must be available to convert node identifiers */,
72
+ );
73
+ return brand(
74
+ // TODO: The assert below is required for type safety but is maybe slow
75
+ assertIsStableId(this.idCompressor.decompress(extractFromOpaque(identifier))),
76
+ );
77
+ }
78
+ public tryLocalizeNodeIdentifier(identifier: string): LocalNodeIdentifier | undefined {
79
+ assert(
80
+ this.idCompressor !== undefined,
81
+ 0x6e9 /* Runtime IdCompressor must be available to convert node identifiers */,
82
+ );
83
+ if (isStableNodeIdentifier(identifier)) {
84
+ const compressedIdentifier = this.idCompressor.tryRecompress(identifier);
85
+ if (compressedIdentifier !== undefined) {
86
+ return brand(compressedIdentifier);
86
87
  }
87
- },
88
- };
88
+ }
89
+ }
89
90
  }
90
91
 
91
92
  export function isStableNodeIdentifier(
package/src/index.ts CHANGED
@@ -169,9 +169,12 @@ export {
169
169
  // Beta APIs
170
170
  TreeBeta,
171
171
  type TreeChangeEventsBeta,
172
+ // Other
172
173
  type VerboseTreeNode,
173
- type EncodeOptions,
174
- type ParseOptions,
174
+ type TreeEncodingOptions,
175
+ type TreeSchemaEncodingOptions,
176
+ type TreeSchema,
177
+ TreeViewConfigurationAlpha,
175
178
  type VerboseTree,
176
179
  extractPersistedSchema,
177
180
  comparePersistedSchema,
@@ -291,3 +294,4 @@ export type { MapNodeInsertableData } from "./simple-tree/index.js";
291
294
 
292
295
  export { JsonAsTree } from "./jsonDomainSchema.js";
293
296
  export { FluidSerializableAsTree } from "./serializableDomainSchema.js";
297
+ export { TableSchema } from "./tableSchema.js";
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/tree";
9
- export const pkgVersion = "2.31.1";
9
+ export const pkgVersion = "2.33.0-333010";
@@ -34,6 +34,8 @@ export class CheckoutFlexTreeView<out TCheckout extends ITreeCheckout = ITreeChe
34
34
  */
35
35
  public readonly flexTree: FlexTreeField;
36
36
 
37
+ private disposed = false;
38
+
37
39
  public constructor(
38
40
  /**
39
41
  * Access non-view schema specific aspects of this branch.
@@ -52,6 +54,9 @@ export class CheckoutFlexTreeView<out TCheckout extends ITreeCheckout = ITreeChe
52
54
  }
53
55
 
54
56
  public [disposeSymbol](): void {
57
+ assert(!this.disposed, "Double disposed");
58
+ this.disposed = true;
59
+
55
60
  for (const anchorNode of this.checkout.forest.anchors) {
56
61
  tryDisposeTreeNode(anchorNode);
57
62
  }
@@ -65,6 +70,7 @@ export class CheckoutFlexTreeView<out TCheckout extends ITreeCheckout = ITreeChe
65
70
  * Any mutations of the new view will not apply to this view until the new view is merged back into this view via `merge()`.
66
71
  */
67
72
  public fork(): CheckoutFlexTreeView<ITreeCheckout & ITreeCheckoutFork> {
73
+ assert(!this.disposed, "disposed");
68
74
  const branch = this.checkout.branch();
69
75
  return new CheckoutFlexTreeView(branch, this.schema, this.nodeKeyManager);
70
76
  }
@@ -250,7 +250,7 @@ export class SharedTree extends SharedObject implements ISharedTree {
250
250
  local: boolean,
251
251
  localOpMetadata: unknown,
252
252
  ): void {
253
- this.kernel.processCore(message, local, localOpMetadata);
253
+ fail(0xb75 /* processCore should not be called on SharedTree */);
254
254
  }
255
255
 
256
256
  protected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {
@@ -569,7 +569,7 @@ class SharedTreeKernel extends SharedTreeCore<SharedTreeEditBuilder, SharedTreeC
569
569
 
570
570
  export function exportSimpleSchema(storedSchema: TreeStoredSchema): SimpleTreeSchema {
571
571
  return {
572
- ...exportSimpleFieldSchemaStored(storedSchema.rootFieldSchema),
572
+ root: exportSimpleFieldSchemaStored(storedSchema.rootFieldSchema),
573
573
  definitions: new Map(
574
574
  [...storedSchema.nodeSchema].map(([key, schema]) => {
575
575
  return [key, exportSimpleNodeSchemaStored(schema)];
@@ -30,10 +30,9 @@ import {
30
30
  applySchemaToParserOptions,
31
31
  cursorFromVerbose,
32
32
  verboseFromCursor,
33
- type ParseOptions,
33
+ type TreeEncodingOptions,
34
34
  type VerboseTree,
35
35
  toStoredSchema,
36
- type EncodeOptions,
37
36
  extractPersistedSchema,
38
37
  TreeViewConfiguration,
39
38
  type TreeBranch,
@@ -129,20 +128,20 @@ export const TreeAlpha: {
129
128
  importVerbose<const TSchema extends ImplicitFieldSchema>(
130
129
  schema: TSchema,
131
130
  data: VerboseTree | undefined,
132
- options?: Partial<ParseOptions>,
131
+ options?: Partial<TreeEncodingOptions>,
133
132
  ): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
134
133
 
135
134
  /**
136
135
  * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}.
137
136
  */
138
- exportConcise(node: TreeNode | TreeLeafValue, options?: EncodeOptions): ConciseTree;
137
+ exportConcise(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): ConciseTree;
139
138
 
140
139
  /**
141
140
  * Copy a snapshot of the current version of a TreeNode into a {@link ConciseTree}, allowing undefined.
142
141
  */
143
142
  exportConcise(
144
143
  node: TreeNode | TreeLeafValue | undefined,
145
- options?: EncodeOptions,
144
+ options?: TreeEncodingOptions,
146
145
  ): ConciseTree | undefined;
147
146
 
148
147
  /**
@@ -159,7 +158,7 @@ export const TreeAlpha: {
159
158
  *
160
159
  * 3. When easy access to the type is desired.
161
160
  */
162
- exportVerbose(node: TreeNode | TreeLeafValue, options?: EncodeOptions): VerboseTree;
161
+ exportVerbose(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): VerboseTree;
163
162
 
164
163
  /**
165
164
  * Export the content of the provided `tree` in a compressed JSON compatible format.
@@ -167,7 +166,7 @@ export const TreeAlpha: {
167
166
  * If an `idCompressor` is provided, it will be used to compress identifiers and thus will be needed to decompress the data.
168
167
  *
169
168
  * Always uses "stored" keys.
170
- * See {@link EncodeOptions.useStoredKeys} for details.
169
+ * See {@link TreeEncodingOptions.useStoredKeys} for details.
171
170
  * @privateRemarks
172
171
  * TODO: It is currently not clear how to work with the idCompressors correctly in the package API.
173
172
  * Better APIs should probably be provided as there is currently no way to associate an un-hydrated tree with an idCompressor,
@@ -243,9 +242,9 @@ export const TreeAlpha: {
243
242
  importVerbose<const TSchema extends ImplicitFieldSchema>(
244
243
  schema: TSchema,
245
244
  data: VerboseTree | undefined,
246
- options?: ParseOptions,
245
+ options?: TreeEncodingOptions,
247
246
  ): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
248
- const config: ParseOptions = { ...options };
247
+ const config: TreeEncodingOptions = { ...options };
249
248
  // Create a config which is standalone, and thus can be used without having to refer back to the schema.
250
249
  const schemalessConfig = applySchemaToParserOptions(schema, config);
251
250
  if (data === undefined) {
@@ -261,8 +260,8 @@ export const TreeAlpha: {
261
260
 
262
261
  exportConcise,
263
262
 
264
- exportVerbose(node: TreeNode | TreeLeafValue, options?: EncodeOptions): VerboseTree {
265
- const config: EncodeOptions = { ...options };
263
+ exportVerbose(node: TreeNode | TreeLeafValue, options?: TreeEncodingOptions): VerboseTree {
264
+ const config: TreeEncodingOptions = { ...options };
266
265
 
267
266
  const cursor = borrowCursorFromTreeNodeOrValue(node);
268
267
  return verboseFromCursor(
@@ -314,21 +313,24 @@ export const TreeAlpha: {
314
313
  },
315
314
  };
316
315
 
317
- function exportConcise(node: TreeNode | TreeLeafValue, options?: EncodeOptions): ConciseTree;
316
+ function exportConcise(
317
+ node: TreeNode | TreeLeafValue,
318
+ options?: TreeEncodingOptions,
319
+ ): ConciseTree;
318
320
 
319
321
  function exportConcise(
320
322
  node: TreeNode | TreeLeafValue | undefined,
321
- options?: EncodeOptions,
323
+ options?: TreeEncodingOptions,
322
324
  ): ConciseTree | undefined;
323
325
 
324
326
  function exportConcise(
325
327
  node: TreeNode | TreeLeafValue | undefined,
326
- options?: EncodeOptions,
328
+ options?: TreeEncodingOptions,
327
329
  ): ConciseTree | undefined {
328
330
  if (node === undefined) {
329
331
  return undefined;
330
332
  }
331
- const config: EncodeOptions = { ...options };
333
+ const config: TreeEncodingOptions = { ...options };
332
334
 
333
335
  const cursor = borrowCursorFromTreeNodeOrValue(node);
334
336
  return conciseFromCursor(
@@ -6,7 +6,6 @@
6
6
  import { assert } from "@fluidframework/core-utils/internal";
7
7
  import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
8
8
  import type { IIdCompressor, SessionId } from "@fluidframework/id-compressor";
9
- import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
10
9
  import type {
11
10
  IExperimentalIncrementalSummaryContext,
12
11
  IRuntimeMessageCollection,
@@ -331,28 +330,6 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
331
330
  this.resubmitMachine.onCommitSubmitted(enrichedCommit);
332
331
  }
333
332
 
334
- /**
335
- * Process a message from the runtime.
336
- * @deprecated - Use processMessagesCore to process a bunch of messages together.
337
- */
338
- public processCore(
339
- message: ISequencedDocumentMessage,
340
- local: boolean,
341
- localOpMetadata: unknown,
342
- ): void {
343
- this.processMessagesCore({
344
- envelope: message,
345
- local,
346
- messagesContent: [
347
- {
348
- clientSequenceNumber: message.clientSequenceNumber,
349
- contents: message.contents,
350
- localOpMetadata,
351
- },
352
- ],
353
- });
354
- }
355
-
356
333
  /**
357
334
  * Process a bunch of messages from the runtime. SharedObject will call this method with a bunch of messages.
358
335
  */
@@ -11,7 +11,7 @@ import type { TreeNodeSchema } from "../core/index.js";
11
11
  import {
12
12
  customFromCursor,
13
13
  replaceHandles,
14
- type EncodeOptions,
14
+ type TreeEncodingOptions,
15
15
  type HandleConverter,
16
16
  } from "./customTree.js";
17
17
  import { getUnhydratedContext } from "../createContext.js";
@@ -44,9 +44,9 @@ export type ConciseTree<THandle = IFluidHandle> =
44
44
  export function conciseFromCursor(
45
45
  reader: ITreeCursor,
46
46
  rootSchema: ImplicitAllowedTypes,
47
- options: EncodeOptions,
47
+ options: TreeEncodingOptions,
48
48
  ): ConciseTree {
49
- const config: Required<EncodeOptions> = {
49
+ const config: Required<TreeEncodingOptions> = {
50
50
  useStoredKeys: false,
51
51
  ...options,
52
52
  };
@@ -57,7 +57,7 @@ export function conciseFromCursor(
57
57
 
58
58
  function conciseFromCursorInner(
59
59
  reader: ITreeCursor,
60
- options: Required<EncodeOptions>,
60
+ options: Required<TreeEncodingOptions>,
61
61
  schema: ReadonlyMap<string, TreeNodeSchema>,
62
62
  ): ConciseTree {
63
63
  return customFromCursor(reader, options, schema, conciseFromCursorInner);
@@ -33,26 +33,20 @@ import { isObjectNodeSchema } from "../objectNodeTypes.js";
33
33
  import { FieldKinds, valueSchemaAllows } from "../../feature-libraries/index.js";
34
34
 
35
35
  /**
36
- * Options for how to encode a tree.
36
+ * Options for how to interpret or encode a tree when schema information is available.
37
37
  * @alpha
38
38
  */
39
- export interface EncodeOptions {
39
+ export interface TreeEncodingOptions {
40
40
  /**
41
- * If true, interpret the input keys of object nodes as stored keys.
42
- * If false, interpret them as property keys.
41
+ * If true, use the stored keys of object nodes.
42
+ * If false, use the property keys.
43
+ * @remarks
44
+ * Has no effect on {@link NodeKind}s other than {@link NodeKind.Object}.
43
45
  * @defaultValue false.
44
46
  */
45
47
  readonly useStoredKeys?: boolean;
46
48
  }
47
49
 
48
- /**
49
- * Options for how to transcode handles.
50
- * @remarks
51
- * Can be applied using {@link replaceHandles}.
52
- * @alpha
53
- */
54
- export type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;
55
-
56
50
  /**
57
51
  * Options for how to interpret a `ConciseTree<TCustom>` without relying on schema.
58
52
  */
@@ -86,11 +80,11 @@ export type CustomTreeNode<TChild> = TChild[] | { [key: string]: TChild };
86
80
  */
87
81
  export function customFromCursor<TChild>(
88
82
  reader: ITreeCursor,
89
- options: Required<EncodeOptions>,
83
+ options: Required<TreeEncodingOptions>,
90
84
  schema: ReadonlyMap<string, TreeNodeSchema>,
91
85
  childHandler: (
92
86
  reader: ITreeCursor,
93
- options: Required<EncodeOptions>,
87
+ options: Required<TreeEncodingOptions>,
94
88
  schema: ReadonlyMap<string, TreeNodeSchema>,
95
89
  ) => TChild,
96
90
  ): CustomTree<TChild> {
@@ -203,6 +197,14 @@ export function tryStoredSchemaAsArray(
203
197
  }
204
198
  }
205
199
 
200
+ /**
201
+ * Options for how to transcode handles.
202
+ * @remarks
203
+ * Can be applied using {@link replaceHandles}.
204
+ * @alpha
205
+ */
206
+ export type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;
207
+
206
208
  /**
207
209
  * Clones tree, replacing any handles.
208
210
  * @remarks
@@ -4,16 +4,25 @@
4
4
  */
5
5
 
6
6
  import type { JsonTreeSchema } from "./jsonSchema.js";
7
- import type { ImplicitFieldSchema } from "../schemaTypes.js";
7
+ import type { ImplicitAllowedTypes } from "../schemaTypes.js";
8
8
  import { toJsonSchema } from "./simpleSchemaToJsonSchema.js";
9
- import { getSimpleSchema } from "./getSimpleSchema.js";
10
- import { getOrCreate } from "../../util/index.js";
11
- import type { TreeNodeSchema } from "../core/index.js";
9
+ import type { TreeEncodingOptions } from "./customTree.js";
10
+ import { TreeViewConfigurationAlpha } from "./tree.js";
12
11
 
13
12
  /**
14
- * Cache in which the results of {@link getJsonSchema} are saved.
13
+ * Options for how to interpret or encode a tree when schema information is available.
14
+ * @alpha
15
15
  */
16
- const jsonSchemaCache = new WeakMap<TreeNodeSchema, JsonTreeSchema>();
16
+ export interface TreeSchemaEncodingOptions extends TreeEncodingOptions {
17
+ /**
18
+ * If true, fields with default providers (like {@link SchemaFactory.identifier}) will be required.
19
+ * If false, they will be optional.
20
+ * @remarks
21
+ * Has no effect on {@link NodeKind}s other than {@link NodeKind.Object}.
22
+ * @defaultValue false.
23
+ */
24
+ readonly requireFieldsWithDefaults?: boolean;
25
+ }
17
26
 
18
27
  /**
19
28
  * Creates a {@link https://json-schema.org/ | JSON Schema} representation of the provided {@link TreeNodeSchema}.
@@ -63,18 +72,18 @@ const jsonSchemaCache = new WeakMap<TreeNodeSchema, JsonTreeSchema>();
63
72
  * TODO:
64
73
  * This API should allow generating JSON schema for the whole matrix of combinations:
65
74
  *
66
- * 1. VerboseTree and ConciseTree
67
- * 2. With and without requiring values with defaults (for insertion vs reading)
68
- * 3. Using stored keys and property keys
69
- *
70
- * This current API seems to give ConciseTree with property keys and ignoring default values.
75
+ * 1. VerboseTree and (Done) ConciseTree
76
+ * 2. (Done) With and without requiring values with defaults (for insertion vs reading)
77
+ * 3. (Done) Using stored keys and property keys.
71
78
  *
79
+ * This takes in `ImplicitAllowedTypes` since underlying `toJsonSchema` can't handle optional roots.
72
80
  *
73
81
  * @alpha
74
82
  */
75
- export function getJsonSchema(schema: ImplicitFieldSchema): JsonTreeSchema {
76
- return getOrCreate(jsonSchemaCache, schema, () => {
77
- const simpleSchema = getSimpleSchema(schema);
78
- return toJsonSchema(simpleSchema);
79
- });
83
+ export function getJsonSchema(
84
+ schema: ImplicitAllowedTypes,
85
+ options: Required<TreeSchemaEncodingOptions>,
86
+ ): JsonTreeSchema {
87
+ const treeSchema = new TreeViewConfigurationAlpha({ schema });
88
+ return toJsonSchema(treeSchema, options);
80
89
  }
@@ -3,39 +3,25 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { getOrCreate } from "../../util/index.js";
7
- import type { TreeNodeSchema } from "../core/index.js";
8
6
  import type { ImplicitFieldSchema } from "../schemaTypes.js";
9
7
  import type { SimpleTreeSchema } from "../simpleSchema.js";
10
8
  import { toSimpleTreeSchema } from "./viewSchemaToSimpleSchema.js";
11
9
 
12
10
  /**
13
- * Cache in which the results of {@link getSimpleSchema} saved.
14
- */
15
- const simpleSchemaCache = new WeakMap<TreeNodeSchema, SimpleTreeSchema>();
16
-
17
- /**
18
- * Creates a {@link SimpleTreeSchema} from the provided {@link ImplicitFieldSchema}.
11
+ * Copies data from {@link ImplicitFieldSchema} to create a {@link SimpleTreeSchema} out of new plain JavaScript objects, Sets and Maps.
19
12
  *
20
13
  * @remarks
21
- * This provides easy access by identifier to any schema transitively referenced by the input schema via {@link SimpleTreeSchema.definitions}.
22
- *
23
- * Caches the result on the input schema for future calls.
14
+ * See also {@link TreeViewConfigurationAlpha} which implements {@link SimpleTreeSchema} as a way to get a `SimpleTreeSchema` without copying the node and field schema and without losing as much type information.
24
15
  *
25
16
  * @privateRemarks
26
17
  * In the future, we may wish to move this to a more discoverable API location.
27
18
  * For now, while still an experimental API, it is surfaced as a free function.
28
19
  *
29
- * If the main use for this is the "definitions" map, we should provide a better way to access it (that doesn't type erase the TreeNodeSchema down to SimpleNodeSchema).
30
- * TODO: Having TreeViewConfiguration implement SimpleTreeSchema directly but with more specific types would be a good way to do this.
31
- *
32
20
  * Note that all TreeNodeSchema get a {@link Context} cached on them as part of one time initialization which contains a map from identifier to all transitively referenced schema.
33
21
  * Perhaps exposing access to that would cover this use-case as well.
34
22
  *
35
- * TODO: does having this caching layer add value? Maybe this wrapper around toSimpleTreeSchema should be removed.
36
- *
37
- * @internal
23
+ * @alpha
38
24
  */
39
25
  export function getSimpleSchema(schema: ImplicitFieldSchema): SimpleTreeSchema {
40
- return getOrCreate(simpleSchemaCache, schema, () => toSimpleTreeSchema(schema, false));
26
+ return toSimpleTreeSchema(schema, true);
41
27
  }
@@ -9,6 +9,8 @@ export {
9
9
  type ViewableTree,
10
10
  type TreeViewEvents,
11
11
  TreeViewConfiguration,
12
+ TreeViewConfigurationAlpha,
13
+ type TreeSchema,
12
14
  type ITreeViewConfiguration,
13
15
  type SchemaCompatibilityStatus,
14
16
  type ITreeConfigurationOptions,
@@ -51,6 +53,7 @@ export {
51
53
  type JsonFieldSchema,
52
54
  type JsonLeafSchemaType,
53
55
  } from "./jsonSchema.js";
56
+ export type { TreeSchemaEncodingOptions } from "./getJsonSchema.js";
54
57
  export { getJsonSchema } from "./getJsonSchema.js";
55
58
  export { getSimpleSchema } from "./getSimpleSchema.js";
56
59
  export { ViewSchema } from "./view.js";
@@ -85,7 +88,6 @@ export type {
85
88
 
86
89
  export {
87
90
  type VerboseTreeNode,
88
- type ParseOptions,
89
91
  type VerboseTree,
90
92
  applySchemaToParserOptions,
91
93
  cursorFromVerbose,
@@ -94,7 +96,7 @@ export {
94
96
  } from "./verboseTree.js";
95
97
 
96
98
  export {
97
- type EncodeOptions,
99
+ type TreeEncodingOptions,
98
100
  customFromCursorStored,
99
101
  type CustomTreeNode,
100
102
  type CustomTreeValue,
@@ -69,7 +69,19 @@ export class SchemaFactoryAlpha<
69
69
  name: Name,
70
70
  fields: T,
71
71
  options?: SchemaFactoryObjectOptions<TCustomMetadata>,
72
- ): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {
72
+ ): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> & {
73
+ /**
74
+ * Typing checking workaround: not for for actual use.
75
+ * @remarks
76
+ * This API collides with {@link TreeNodeSchemaCore.createFromInsertable} to disable a type checking optimization which produces different and undesired results.
77
+ * See {@link https://github.com/microsoft/TypeScript/issues/59049#issuecomment-2773459693} for more details.
78
+ * @privateRemarks
79
+ * The specific issue here is non-empty POJO mode object schema not being assignable to `ObjectNodeSchema`,
80
+ * See the above link and the tests in objectNode.spec.ts which reference it.
81
+ * @system
82
+ */
83
+ readonly createFromInsertable: unknown;
84
+ } {
73
85
  return objectSchema(
74
86
  this.scoped2(name),
75
87
  fields,
@@ -136,6 +148,11 @@ export class SchemaFactoryAlpha<
136
148
  >;
137
149
  }
138
150
 
151
+ /**
152
+ * {@inheritDoc SchemaStatics.optional}
153
+ */
154
+ public static override readonly leaves = schemaStatics.leaves;
155
+
139
156
  /**
140
157
  * {@inheritDoc SchemaStatics.optional}
141
158
  */