@fluidframework/tree 2.11.0 → 2.12.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 (537) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-report/tree.alpha.api.md +2 -2
  3. package/api-report/tree.beta.api.md +1 -1
  4. package/api-report/tree.legacy.alpha.api.md +1 -1
  5. package/api-report/tree.legacy.public.api.md +1 -1
  6. package/api-report/tree.public.api.md +1 -1
  7. package/dist/core/index.d.ts +2 -2
  8. package/dist/core/index.d.ts.map +1 -1
  9. package/dist/core/index.js +5 -3
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/core/rebase/utils.d.ts.map +1 -1
  12. package/dist/core/rebase/utils.js +2 -9
  13. package/dist/core/rebase/utils.js.map +1 -1
  14. package/dist/core/schema-stored/format.d.ts +0 -3
  15. package/dist/core/schema-stored/format.d.ts.map +1 -1
  16. package/dist/core/schema-stored/format.js.map +1 -1
  17. package/dist/core/schema-stored/schema.d.ts +12 -10
  18. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  19. package/dist/core/schema-stored/schema.js +3 -5
  20. package/dist/core/schema-stored/schema.js.map +1 -1
  21. package/dist/core/schema-view/index.d.ts +1 -1
  22. package/dist/core/schema-view/index.d.ts.map +1 -1
  23. package/dist/core/schema-view/index.js +1 -2
  24. package/dist/core/schema-view/index.js.map +1 -1
  25. package/dist/core/schema-view/view.d.ts +0 -7
  26. package/dist/core/schema-view/view.d.ts.map +1 -1
  27. package/dist/core/schema-view/view.js +1 -12
  28. package/dist/core/schema-view/view.js.map +1 -1
  29. package/dist/{feature-libraries/chunked-forest → core/tree}/chunk.d.ts +2 -1
  30. package/dist/core/tree/chunk.d.ts.map +1 -0
  31. package/dist/{feature-libraries/chunked-forest → core/tree}/chunk.js +2 -2
  32. package/dist/core/tree/chunk.js.map +1 -0
  33. package/dist/core/tree/index.d.ts +1 -0
  34. package/dist/core/tree/index.d.ts.map +1 -1
  35. package/dist/core/tree/index.js +5 -1
  36. package/dist/core/tree/index.js.map +1 -1
  37. package/dist/core/tree/treeTextFormat.d.ts +0 -5
  38. package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
  39. package/dist/core/tree/treeTextFormat.js.map +1 -1
  40. package/dist/core/tree/types.d.ts +0 -5
  41. package/dist/core/tree/types.d.ts.map +1 -1
  42. package/dist/core/tree/types.js +0 -1
  43. package/dist/core/tree/types.js.map +1 -1
  44. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +1 -2
  45. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/basicChunk.js +14 -14
  47. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  48. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +1 -2
  49. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/chunkTree.js +2 -3
  51. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -2
  53. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  54. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  55. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts +1 -2
  56. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
  57. package/dist/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  58. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -2
  59. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  60. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  62. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  63. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  64. package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts +1 -1
  65. package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  66. package/dist/feature-libraries/chunked-forest/emptyChunk.js +2 -3
  67. package/dist/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  68. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  69. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  70. package/dist/feature-libraries/chunked-forest/index.js +5 -5
  71. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  72. package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
  73. package/dist/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
  74. package/dist/feature-libraries/chunked-forest/sequenceChunk.js +2 -2
  75. package/dist/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  76. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -2
  77. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/uniformChunk.js +13 -13
  79. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  80. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  81. package/dist/feature-libraries/default-schema/defaultSchema.js +1 -0
  82. package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  83. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  84. package/dist/feature-libraries/default-schema/schemaChecker.js +2 -1
  85. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  86. package/dist/feature-libraries/index.d.ts +1 -1
  87. package/dist/feature-libraries/index.d.ts.map +1 -1
  88. package/dist/feature-libraries/index.js +6 -2
  89. package/dist/feature-libraries/index.js.map +1 -1
  90. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts +8 -1
  91. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  92. package/dist/feature-libraries/indexing/anchorTreeIndex.js +31 -5
  93. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  94. package/dist/feature-libraries/modular-schema/discrepancies.d.ts +84 -24
  95. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  96. package/dist/feature-libraries/modular-schema/discrepancies.js +32 -33
  97. package/dist/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  98. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  99. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  100. package/dist/feature-libraries/modular-schema/index.js +5 -1
  101. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  102. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts +0 -1
  103. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  104. package/dist/feature-libraries/modular-schema/isNeverTree.js +0 -1
  105. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  106. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
  107. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  108. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
  109. package/dist/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  110. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +12 -12
  111. package/dist/feature-libraries/sequence-field/formatV1.d.ts +99 -99
  112. package/dist/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  113. package/dist/feature-libraries/sequence-field/formatV2.d.ts +76 -76
  114. package/dist/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  115. package/dist/feature-libraries/sequence-field/formatV3.d.ts +54 -54
  116. package/dist/feature-libraries/sequence-field/types.d.ts +0 -1
  117. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  118. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  119. package/dist/index.d.ts +4 -5
  120. package/dist/index.d.ts.map +1 -1
  121. package/dist/index.js +1 -14
  122. package/dist/index.js.map +1 -1
  123. package/dist/packageVersion.d.ts +1 -1
  124. package/dist/packageVersion.js +1 -1
  125. package/dist/packageVersion.js.map +1 -1
  126. package/dist/shared-tree/index.d.ts +1 -1
  127. package/dist/shared-tree/index.d.ts.map +1 -1
  128. package/dist/shared-tree/index.js.map +1 -1
  129. package/dist/shared-tree/schematizeTree.d.ts +1 -1
  130. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  131. package/dist/shared-tree/schematizeTree.js +6 -6
  132. package/dist/shared-tree/schematizeTree.js.map +1 -1
  133. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  134. package/dist/shared-tree/schematizingTreeView.js +8 -12
  135. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  136. package/dist/shared-tree/sharedTree.d.ts +25 -7
  137. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  138. package/dist/shared-tree/sharedTree.js +104 -15
  139. package/dist/shared-tree/sharedTree.js.map +1 -1
  140. package/dist/shared-tree/treeCheckout.d.ts +35 -12
  141. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  142. package/dist/shared-tree/treeCheckout.js +159 -127
  143. package/dist/shared-tree/treeCheckout.js.map +1 -1
  144. package/dist/shared-tree-core/branch.d.ts +13 -35
  145. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  146. package/dist/shared-tree-core/branch.js +12 -77
  147. package/dist/shared-tree-core/branch.js.map +1 -1
  148. package/dist/shared-tree-core/branchCommitEnricher.d.ts +7 -1
  149. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  150. package/dist/shared-tree-core/branchCommitEnricher.js +16 -18
  151. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  152. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  153. package/dist/shared-tree-core/editManager.js +2 -2
  154. package/dist/shared-tree-core/editManager.js.map +1 -1
  155. package/dist/shared-tree-core/index.d.ts +3 -3
  156. package/dist/shared-tree-core/index.d.ts.map +1 -1
  157. package/dist/shared-tree-core/index.js +2 -2
  158. package/dist/shared-tree-core/index.js.map +1 -1
  159. package/dist/shared-tree-core/sharedTreeCore.d.ts +2 -9
  160. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  161. package/dist/shared-tree-core/sharedTreeCore.js +4 -16
  162. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  163. package/dist/shared-tree-core/transaction.d.ts +38 -0
  164. package/dist/shared-tree-core/transaction.d.ts.map +1 -1
  165. package/dist/shared-tree-core/transaction.js +118 -6
  166. package/dist/shared-tree-core/transaction.js.map +1 -1
  167. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  168. package/dist/simple-tree/api/conciseTree.js +1 -1
  169. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  170. package/dist/simple-tree/api/create.d.ts.map +1 -1
  171. package/dist/simple-tree/api/create.js +5 -1
  172. package/dist/simple-tree/api/create.js.map +1 -1
  173. package/dist/simple-tree/api/customTree.d.ts +14 -2
  174. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  175. package/dist/simple-tree/api/customTree.js +53 -3
  176. package/dist/simple-tree/api/customTree.js.map +1 -1
  177. package/dist/simple-tree/api/index.d.ts +2 -2
  178. package/dist/simple-tree/api/index.d.ts.map +1 -1
  179. package/dist/simple-tree/api/index.js +4 -1
  180. package/dist/simple-tree/api/index.js.map +1 -1
  181. package/dist/simple-tree/api/schemaFactory.d.ts +48 -0
  182. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  183. package/dist/simple-tree/api/schemaFactory.js +5 -2
  184. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  185. package/dist/simple-tree/api/simpleSchema.d.ts +3 -1
  186. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
  187. package/dist/simple-tree/api/simpleSchema.js.map +1 -1
  188. package/dist/simple-tree/api/simpleTreeIndex.js +3 -1
  189. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  190. package/dist/simple-tree/api/storedSchema.d.ts +4 -4
  191. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  192. package/dist/simple-tree/api/storedSchema.js +8 -21
  193. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  194. package/dist/simple-tree/api/tree.d.ts +1 -0
  195. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  196. package/dist/simple-tree/api/tree.js.map +1 -1
  197. package/dist/simple-tree/api/verboseTree.js +1 -1
  198. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  199. package/dist/simple-tree/api/view.d.ts +14 -9
  200. package/dist/simple-tree/api/view.d.ts.map +1 -1
  201. package/dist/simple-tree/api/view.js +129 -40
  202. package/dist/simple-tree/api/view.js.map +1 -1
  203. package/dist/simple-tree/index.d.ts +2 -2
  204. package/dist/simple-tree/index.d.ts.map +1 -1
  205. package/dist/simple-tree/index.js +5 -2
  206. package/dist/simple-tree/index.js.map +1 -1
  207. package/dist/simple-tree/leafNodeSchema.d.ts +0 -15
  208. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  209. package/dist/simple-tree/leafNodeSchema.js +0 -15
  210. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  211. package/dist/simple-tree/objectNode.d.ts +8 -3
  212. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  213. package/dist/simple-tree/objectNode.js +18 -2
  214. package/dist/simple-tree/objectNode.js.map +1 -1
  215. package/dist/simple-tree/objectNodeTypes.d.ts +4 -0
  216. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  217. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  218. package/dist/simple-tree/schemaTypes.d.ts +4 -2
  219. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  220. package/dist/simple-tree/schemaTypes.js.map +1 -1
  221. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  222. package/dist/simple-tree/toStoredSchema.js +18 -13
  223. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  224. package/dist/util/brand.d.ts +0 -2
  225. package/dist/util/brand.d.ts.map +1 -1
  226. package/dist/util/brand.js +0 -1
  227. package/dist/util/brand.js.map +1 -1
  228. package/dist/util/index.d.ts +1 -1
  229. package/dist/util/index.d.ts.map +1 -1
  230. package/dist/util/index.js +2 -1
  231. package/dist/util/index.js.map +1 -1
  232. package/dist/util/typeCheck.d.ts +0 -2
  233. package/dist/util/typeCheck.d.ts.map +1 -1
  234. package/dist/util/typeCheck.js.map +1 -1
  235. package/dist/util/utils.d.ts +13 -0
  236. package/dist/util/utils.d.ts.map +1 -1
  237. package/dist/util/utils.js +23 -1
  238. package/dist/util/utils.js.map +1 -1
  239. package/lib/core/index.d.ts +2 -2
  240. package/lib/core/index.d.ts.map +1 -1
  241. package/lib/core/index.js +2 -2
  242. package/lib/core/index.js.map +1 -1
  243. package/lib/core/rebase/utils.d.ts.map +1 -1
  244. package/lib/core/rebase/utils.js +3 -10
  245. package/lib/core/rebase/utils.js.map +1 -1
  246. package/lib/core/schema-stored/format.d.ts +0 -3
  247. package/lib/core/schema-stored/format.d.ts.map +1 -1
  248. package/lib/core/schema-stored/format.js.map +1 -1
  249. package/lib/core/schema-stored/schema.d.ts +12 -10
  250. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  251. package/lib/core/schema-stored/schema.js +3 -5
  252. package/lib/core/schema-stored/schema.js.map +1 -1
  253. package/lib/core/schema-view/index.d.ts +1 -1
  254. package/lib/core/schema-view/index.d.ts.map +1 -1
  255. package/lib/core/schema-view/index.js +1 -1
  256. package/lib/core/schema-view/index.js.map +1 -1
  257. package/lib/core/schema-view/view.d.ts +0 -7
  258. package/lib/core/schema-view/view.d.ts.map +1 -1
  259. package/lib/core/schema-view/view.js +0 -11
  260. package/lib/core/schema-view/view.js.map +1 -1
  261. package/lib/{feature-libraries/chunked-forest → core/tree}/chunk.d.ts +2 -1
  262. package/lib/core/tree/chunk.d.ts.map +1 -0
  263. package/lib/{feature-libraries/chunked-forest → core/tree}/chunk.js +1 -1
  264. package/lib/core/tree/chunk.js.map +1 -0
  265. package/lib/core/tree/index.d.ts +1 -0
  266. package/lib/core/tree/index.d.ts.map +1 -1
  267. package/lib/core/tree/index.js +1 -0
  268. package/lib/core/tree/index.js.map +1 -1
  269. package/lib/core/tree/treeTextFormat.d.ts +0 -5
  270. package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
  271. package/lib/core/tree/treeTextFormat.js.map +1 -1
  272. package/lib/core/tree/types.d.ts +0 -5
  273. package/lib/core/tree/types.d.ts.map +1 -1
  274. package/lib/core/tree/types.js +0 -1
  275. package/lib/core/tree/types.js.map +1 -1
  276. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +1 -2
  277. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  278. package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
  279. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  280. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +1 -2
  281. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  282. package/lib/feature-libraries/chunked-forest/chunkTree.js +1 -2
  283. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  284. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -2
  285. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  286. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  287. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts +1 -2
  288. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.d.ts.map +1 -1
  289. package/lib/feature-libraries/chunked-forest/codec/chunkCodecUtilities.js.map +1 -1
  290. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -2
  291. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  292. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  293. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  294. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  295. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  296. package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts +1 -1
  297. package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  298. package/lib/feature-libraries/chunked-forest/emptyChunk.js +1 -2
  299. package/lib/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  300. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  301. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  302. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  303. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  304. package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts +1 -1
  305. package/lib/feature-libraries/chunked-forest/sequenceChunk.d.ts.map +1 -1
  306. package/lib/feature-libraries/chunked-forest/sequenceChunk.js +1 -1
  307. package/lib/feature-libraries/chunked-forest/sequenceChunk.js.map +1 -1
  308. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +1 -2
  309. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  310. package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
  311. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  312. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  313. package/lib/feature-libraries/default-schema/defaultSchema.js +1 -0
  314. package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  315. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  316. package/lib/feature-libraries/default-schema/schemaChecker.js +2 -1
  317. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  318. package/lib/feature-libraries/index.d.ts +1 -1
  319. package/lib/feature-libraries/index.d.ts.map +1 -1
  320. package/lib/feature-libraries/index.js +1 -1
  321. package/lib/feature-libraries/index.js.map +1 -1
  322. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts +8 -1
  323. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  324. package/lib/feature-libraries/indexing/anchorTreeIndex.js +31 -5
  325. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  326. package/lib/feature-libraries/modular-schema/discrepancies.d.ts +84 -24
  327. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +1 -1
  328. package/lib/feature-libraries/modular-schema/discrepancies.js +25 -28
  329. package/lib/feature-libraries/modular-schema/discrepancies.js.map +1 -1
  330. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  331. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  332. package/lib/feature-libraries/modular-schema/index.js +1 -1
  333. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  334. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts +0 -1
  335. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  336. package/lib/feature-libraries/modular-schema/isNeverTree.js +0 -1
  337. package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  338. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts +6 -6
  339. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV1.d.ts.map +1 -1
  340. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts +7 -7
  341. package/lib/feature-libraries/optional-field/optionalFieldChangeFormatV2.d.ts.map +1 -1
  342. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +12 -12
  343. package/lib/feature-libraries/sequence-field/formatV1.d.ts +99 -99
  344. package/lib/feature-libraries/sequence-field/formatV1.d.ts.map +1 -1
  345. package/lib/feature-libraries/sequence-field/formatV2.d.ts +76 -76
  346. package/lib/feature-libraries/sequence-field/formatV2.d.ts.map +1 -1
  347. package/lib/feature-libraries/sequence-field/formatV3.d.ts +54 -54
  348. package/lib/feature-libraries/sequence-field/types.d.ts +0 -1
  349. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  350. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  351. package/lib/index.d.ts +4 -5
  352. package/lib/index.d.ts.map +1 -1
  353. package/lib/index.js +2 -3
  354. package/lib/index.js.map +1 -1
  355. package/lib/packageVersion.d.ts +1 -1
  356. package/lib/packageVersion.js +1 -1
  357. package/lib/packageVersion.js.map +1 -1
  358. package/lib/shared-tree/index.d.ts +1 -1
  359. package/lib/shared-tree/index.d.ts.map +1 -1
  360. package/lib/shared-tree/index.js.map +1 -1
  361. package/lib/shared-tree/schematizeTree.d.ts +1 -1
  362. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  363. package/lib/shared-tree/schematizeTree.js +7 -7
  364. package/lib/shared-tree/schematizeTree.js.map +1 -1
  365. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  366. package/lib/shared-tree/schematizingTreeView.js +10 -14
  367. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  368. package/lib/shared-tree/sharedTree.d.ts +25 -7
  369. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  370. package/lib/shared-tree/sharedTree.js +105 -16
  371. package/lib/shared-tree/sharedTree.js.map +1 -1
  372. package/lib/shared-tree/treeCheckout.d.ts +35 -12
  373. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  374. package/lib/shared-tree/treeCheckout.js +161 -129
  375. package/lib/shared-tree/treeCheckout.js.map +1 -1
  376. package/lib/shared-tree-core/branch.d.ts +13 -35
  377. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  378. package/lib/shared-tree-core/branch.js +12 -76
  379. package/lib/shared-tree-core/branch.js.map +1 -1
  380. package/lib/shared-tree-core/branchCommitEnricher.d.ts +7 -1
  381. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  382. package/lib/shared-tree-core/branchCommitEnricher.js +16 -18
  383. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  384. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  385. package/lib/shared-tree-core/editManager.js +3 -3
  386. package/lib/shared-tree-core/editManager.js.map +1 -1
  387. package/lib/shared-tree-core/index.d.ts +3 -3
  388. package/lib/shared-tree-core/index.d.ts.map +1 -1
  389. package/lib/shared-tree-core/index.js +2 -2
  390. package/lib/shared-tree-core/index.js.map +1 -1
  391. package/lib/shared-tree-core/sharedTreeCore.d.ts +2 -9
  392. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  393. package/lib/shared-tree-core/sharedTreeCore.js +4 -16
  394. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  395. package/lib/shared-tree-core/transaction.d.ts +38 -0
  396. package/lib/shared-tree-core/transaction.d.ts.map +1 -1
  397. package/lib/shared-tree-core/transaction.js +112 -1
  398. package/lib/shared-tree-core/transaction.js.map +1 -1
  399. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  400. package/lib/simple-tree/api/conciseTree.js +2 -2
  401. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  402. package/lib/simple-tree/api/create.d.ts.map +1 -1
  403. package/lib/simple-tree/api/create.js +5 -1
  404. package/lib/simple-tree/api/create.js.map +1 -1
  405. package/lib/simple-tree/api/customTree.d.ts +14 -2
  406. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  407. package/lib/simple-tree/api/customTree.js +50 -2
  408. package/lib/simple-tree/api/customTree.js.map +1 -1
  409. package/lib/simple-tree/api/index.d.ts +2 -2
  410. package/lib/simple-tree/api/index.d.ts.map +1 -1
  411. package/lib/simple-tree/api/index.js +2 -1
  412. package/lib/simple-tree/api/index.js.map +1 -1
  413. package/lib/simple-tree/api/schemaFactory.d.ts +48 -0
  414. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  415. package/lib/simple-tree/api/schemaFactory.js +4 -1
  416. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  417. package/lib/simple-tree/api/simpleSchema.d.ts +3 -1
  418. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
  419. package/lib/simple-tree/api/simpleSchema.js.map +1 -1
  420. package/lib/simple-tree/api/simpleTreeIndex.js +3 -1
  421. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  422. package/lib/simple-tree/api/storedSchema.d.ts +4 -4
  423. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  424. package/lib/simple-tree/api/storedSchema.js +5 -18
  425. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  426. package/lib/simple-tree/api/tree.d.ts +1 -0
  427. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  428. package/lib/simple-tree/api/tree.js.map +1 -1
  429. package/lib/simple-tree/api/verboseTree.js +2 -2
  430. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  431. package/lib/simple-tree/api/view.d.ts +14 -9
  432. package/lib/simple-tree/api/view.d.ts.map +1 -1
  433. package/lib/simple-tree/api/view.js +131 -42
  434. package/lib/simple-tree/api/view.js.map +1 -1
  435. package/lib/simple-tree/index.d.ts +2 -2
  436. package/lib/simple-tree/index.d.ts.map +1 -1
  437. package/lib/simple-tree/index.js +2 -2
  438. package/lib/simple-tree/index.js.map +1 -1
  439. package/lib/simple-tree/leafNodeSchema.d.ts +0 -15
  440. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  441. package/lib/simple-tree/leafNodeSchema.js +0 -15
  442. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  443. package/lib/simple-tree/objectNode.d.ts +8 -3
  444. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  445. package/lib/simple-tree/objectNode.js +16 -1
  446. package/lib/simple-tree/objectNode.js.map +1 -1
  447. package/lib/simple-tree/objectNodeTypes.d.ts +4 -0
  448. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  449. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  450. package/lib/simple-tree/schemaTypes.d.ts +4 -2
  451. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  452. package/lib/simple-tree/schemaTypes.js.map +1 -1
  453. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  454. package/lib/simple-tree/toStoredSchema.js +19 -14
  455. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  456. package/lib/util/brand.d.ts +0 -2
  457. package/lib/util/brand.d.ts.map +1 -1
  458. package/lib/util/brand.js +0 -1
  459. package/lib/util/brand.js.map +1 -1
  460. package/lib/util/index.d.ts +1 -1
  461. package/lib/util/index.d.ts.map +1 -1
  462. package/lib/util/index.js +1 -1
  463. package/lib/util/index.js.map +1 -1
  464. package/lib/util/typeCheck.d.ts +0 -2
  465. package/lib/util/typeCheck.d.ts.map +1 -1
  466. package/lib/util/typeCheck.js.map +1 -1
  467. package/lib/util/utils.d.ts +13 -0
  468. package/lib/util/utils.d.ts.map +1 -1
  469. package/lib/util/utils.js +21 -0
  470. package/lib/util/utils.js.map +1 -1
  471. package/package.json +22 -22
  472. package/src/core/index.ts +5 -1
  473. package/src/core/rebase/utils.ts +17 -20
  474. package/src/core/schema-stored/format.ts +0 -3
  475. package/src/core/schema-stored/schema.ts +13 -10
  476. package/src/core/schema-view/index.ts +0 -1
  477. package/src/core/schema-view/view.ts +0 -11
  478. package/src/{feature-libraries/chunked-forest → core/tree}/chunk.ts +4 -4
  479. package/src/core/tree/index.ts +8 -0
  480. package/src/core/tree/treeTextFormat.ts +0 -5
  481. package/src/core/tree/types.ts +0 -5
  482. package/src/feature-libraries/chunked-forest/basicChunk.ts +4 -2
  483. package/src/feature-libraries/chunked-forest/chunkTree.ts +2 -1
  484. package/src/feature-libraries/chunked-forest/chunkedForest.ts +2 -1
  485. package/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts +1 -2
  486. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +6 -2
  487. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -1
  488. package/src/feature-libraries/chunked-forest/emptyChunk.ts +4 -2
  489. package/src/feature-libraries/chunked-forest/index.ts +1 -1
  490. package/src/feature-libraries/chunked-forest/sequenceChunk.ts +1 -1
  491. package/src/feature-libraries/chunked-forest/uniformChunk.ts +4 -1
  492. package/src/feature-libraries/default-schema/defaultSchema.ts +1 -0
  493. package/src/feature-libraries/default-schema/schemaChecker.ts +4 -1
  494. package/src/feature-libraries/index.ts +13 -0
  495. package/src/feature-libraries/indexing/anchorTreeIndex.ts +34 -5
  496. package/src/feature-libraries/modular-schema/discrepancies.ts +76 -38
  497. package/src/feature-libraries/modular-schema/index.ts +13 -0
  498. package/src/feature-libraries/modular-schema/isNeverTree.ts +0 -2
  499. package/src/feature-libraries/sequence-field/types.ts +0 -1
  500. package/src/index.ts +1 -29
  501. package/src/packageVersion.ts +1 -1
  502. package/src/shared-tree/index.ts +1 -0
  503. package/src/shared-tree/schematizeTree.ts +6 -10
  504. package/src/shared-tree/schematizingTreeView.ts +11 -21
  505. package/src/shared-tree/sharedTree.ts +173 -41
  506. package/src/shared-tree/treeCheckout.ts +224 -175
  507. package/src/shared-tree-core/branch.ts +29 -122
  508. package/src/shared-tree-core/branchCommitEnricher.ts +19 -20
  509. package/src/shared-tree-core/editManager.ts +3 -8
  510. package/src/shared-tree-core/index.ts +2 -1
  511. package/src/shared-tree-core/sharedTreeCore.ts +8 -19
  512. package/src/shared-tree-core/transaction.ts +145 -0
  513. package/src/simple-tree/api/conciseTree.ts +2 -2
  514. package/src/simple-tree/api/create.ts +5 -1
  515. package/src/simple-tree/api/customTree.ts +69 -1
  516. package/src/simple-tree/api/index.ts +12 -2
  517. package/src/simple-tree/api/schemaFactory.ts +62 -1
  518. package/src/simple-tree/api/simpleSchema.ts +3 -1
  519. package/src/simple-tree/api/simpleTreeIndex.ts +2 -0
  520. package/src/simple-tree/api/storedSchema.ts +7 -22
  521. package/src/simple-tree/api/tree.ts +6 -0
  522. package/src/simple-tree/api/verboseTree.ts +2 -2
  523. package/src/simple-tree/api/view.ts +197 -51
  524. package/src/simple-tree/index.ts +6 -0
  525. package/src/simple-tree/leafNodeSchema.ts +0 -19
  526. package/src/simple-tree/objectNode.ts +26 -2
  527. package/src/simple-tree/objectNodeTypes.ts +5 -0
  528. package/src/simple-tree/schemaTypes.ts +7 -2
  529. package/src/simple-tree/toStoredSchema.ts +25 -19
  530. package/src/util/brand.ts +0 -2
  531. package/src/util/index.ts +1 -0
  532. package/src/util/typeCheck.ts +0 -2
  533. package/src/util/utils.ts +26 -0
  534. package/dist/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
  535. package/dist/feature-libraries/chunked-forest/chunk.js.map +0 -1
  536. package/lib/feature-libraries/chunked-forest/chunk.d.ts.map +0 -1
  537. package/lib/feature-libraries/chunked-forest/chunk.js.map +0 -1
@@ -68,27 +68,8 @@ function makeLeaf<Name extends string, const T extends ValueSchema>(
68
68
  }
69
69
 
70
70
  // Leaf schema shared between all SchemaFactory instances.
71
- /**
72
- * @internal
73
- */
74
71
  export const stringSchema = makeLeaf("string", ValueSchema.String);
75
-
76
- /**
77
- * @internal
78
- */
79
72
  export const numberSchema = makeLeaf("number", ValueSchema.Number);
80
-
81
- /**
82
- * @internal
83
- */
84
73
  export const booleanSchema = makeLeaf("boolean", ValueSchema.Boolean);
85
-
86
- /**
87
- * @internal
88
- */
89
74
  export const nullSchema = makeLeaf("null", ValueSchema.Null);
90
-
91
- /**
92
- * @internal
93
- */
94
75
  export const handleSchema = makeLeaf("handle", ValueSchema.FluidHandle);
@@ -6,7 +6,7 @@
6
6
  import { assert, Lazy } from "@fluidframework/core-utils/internal";
7
7
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
8
8
 
9
- import type { FieldKey } from "../core/index.js";
9
+ import type { FieldKey, SchemaPolicy } from "../core/index.js";
10
10
  import {
11
11
  FieldKinds,
12
12
  type FlexTreeField,
@@ -42,7 +42,11 @@ import {
42
42
  } from "./core/index.js";
43
43
  import { mapTreeFromNodeData, type InsertableContent } from "./toMapTree.js";
44
44
  import { type RestrictiveStringRecord, fail, type FlattenKeys } from "../util/index.js";
45
- import type { ObjectNodeSchema, ObjectNodeSchemaInternalData } from "./objectNodeTypes.js";
45
+ import {
46
+ isObjectNodeSchema,
47
+ type ObjectNodeSchema,
48
+ type ObjectNodeSchemaInternalData,
49
+ } from "./objectNodeTypes.js";
46
50
  import { TreeNodeValid, type MostDerivedData } from "./treeNodeValid.js";
47
51
  import { getUnhydratedContext } from "./createContext.js";
48
52
 
@@ -330,6 +334,7 @@ export function objectSchema<
330
334
  identifier: TName,
331
335
  info: T,
332
336
  implicitlyConstructable: ImplicitlyConstructable,
337
+ allowUnknownOptionalFields: boolean,
333
338
  ): ObjectNodeSchema<TName, T, ImplicitlyConstructable> & ObjectNodeSchemaInternalData {
334
339
  // Ensure no collisions between final set of property keys, and final set of stored keys (including those
335
340
  // implicitly derived from property keys)
@@ -368,6 +373,7 @@ export function objectSchema<
368
373
  ]),
369
374
  );
370
375
  public static readonly identifierFieldKeys: readonly FieldKey[] = identifierFieldKeys;
376
+ public static readonly allowUnknownOptionalFields: boolean = allowUnknownOptionalFields;
371
377
 
372
378
  public static override prepareInstance<T2>(
373
379
  this: typeof TreeNodeValid<T2>,
@@ -509,3 +515,21 @@ function assertUniqueKeys<
509
515
  derivedStoredKeys.add(storedKey);
510
516
  }
511
517
  }
518
+
519
+ /**
520
+ * Creates a policy for allowing unknown optional fields on an object node which delegates to the policy defined
521
+ * on the object node's internal schema data.
522
+ */
523
+ export function createUnknownOptionalFieldPolicy(
524
+ schema: ImplicitFieldSchema,
525
+ ): SchemaPolicy["allowUnknownOptionalFields"] {
526
+ const context = getUnhydratedContext(schema);
527
+ return (identifier) => {
528
+ const storedSchema = context.schema.get(identifier);
529
+ return (
530
+ storedSchema !== undefined &&
531
+ isObjectNodeSchema(storedSchema) &&
532
+ storedSchema.allowUnknownOptionalFields
533
+ );
534
+ };
535
+ }
@@ -55,6 +55,11 @@ export interface ObjectNodeSchemaInternalData {
55
55
  * Stored keys which hold identifiers.
56
56
  */
57
57
  readonly identifierFieldKeys: readonly FieldKey[];
58
+
59
+ /**
60
+ * Whether to tolerate (and preserve) additional unknown optional fields in instances of this object node.
61
+ */
62
+ readonly allowUnknownOptionalFields: boolean;
58
63
  }
59
64
 
60
65
  export const ObjectNodeSchema = {
@@ -24,6 +24,7 @@ import type {
24
24
  TreeNodeSchemaClass,
25
25
  TreeNode,
26
26
  TreeNodeSchemaCore,
27
+ TreeNodeSchemaNonClass,
27
28
  } from "./core/index.js";
28
29
  import type { FieldKey } from "../core/index.js";
29
30
  import type { InsertableContent } from "./toMapTree.js";
@@ -759,15 +760,19 @@ export type InsertableTreeNodeFromAllowedTypes<TList extends AllowedTypes> =
759
760
 
760
761
  /**
761
762
  * Takes in `TreeNodeSchema[]` and returns a TypedNode union.
763
+ * @privateRemarks
764
+ * If a schema is both TreeNodeSchemaClass and TreeNodeSchemaNonClass, prefer TreeNodeSchemaClass since that includes subclasses properly.
762
765
  * @public
763
766
  */
764
- export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchema<
767
+ export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchemaClass<
765
768
  string,
766
769
  NodeKind,
767
770
  infer TNode
768
771
  >
769
772
  ? TNode
770
- : never;
773
+ : T extends TreeNodeSchemaNonClass<string, NodeKind, infer TNode>
774
+ ? TNode
775
+ : never;
771
776
 
772
777
  /**
773
778
  * Data which can be used as a node to be inserted.
@@ -20,7 +20,7 @@ import {
20
20
  type TreeTypeSet,
21
21
  } from "../core/index.js";
22
22
  import { FieldKinds, type FlexFieldKind } from "../feature-libraries/index.js";
23
- import { brand, fail, isReadonlyArray } from "../util/index.js";
23
+ import { brand, fail, getOrCreate, isReadonlyArray } from "../util/index.js";
24
24
  import { NodeKind, type TreeNodeSchema } from "./core/index.js";
25
25
  import {
26
26
  FieldKind,
@@ -33,29 +33,35 @@ import { LeafNodeSchema } from "./leafNodeSchema.js";
33
33
  import { isObjectNodeSchema } from "./objectNodeTypes.js";
34
34
  import { normalizeFlexListEager } from "./flexList.js";
35
35
 
36
+ const viewToStoredCache = new WeakMap<ImplicitFieldSchema, TreeStoredSchema>();
37
+
36
38
  /**
37
39
  * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.
38
40
  */
39
41
  export function toStoredSchema(root: ImplicitFieldSchema): TreeStoredSchema {
40
- const nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();
41
- walkFieldSchema(root, {
42
- node(schema) {
43
- if (nodeSchema.has(brand(schema.identifier))) {
44
- // Use JSON.stringify to quote and escape identifier string.
45
- throw new UsageError(
46
- `Multiple schema encountered with the identifier ${JSON.stringify(
47
- schema.identifier,
48
- )}. Remove or rename them to avoid the collision.`,
49
- );
50
- }
51
- nodeSchema.set(brand(schema.identifier), getStoredSchema(schema));
52
- },
53
- });
42
+ return getOrCreate(viewToStoredCache, root, () => {
43
+ const nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();
44
+ walkFieldSchema(root, {
45
+ node(schema) {
46
+ if (nodeSchema.has(brand(schema.identifier))) {
47
+ // Use JSON.stringify to quote and escape identifier string.
48
+ throw new UsageError(
49
+ `Multiple schema encountered with the identifier ${JSON.stringify(
50
+ schema.identifier,
51
+ )}. Remove or rename them to avoid the collision.`,
52
+ );
53
+ }
54
+ nodeSchema.set(brand(schema.identifier), getStoredSchema(schema));
55
+ },
56
+ });
54
57
 
55
- return {
56
- nodeSchema,
57
- rootFieldSchema: convertField(root),
58
- };
58
+ const result: TreeStoredSchema = {
59
+ nodeSchema,
60
+ rootFieldSchema: convertField(root),
61
+ };
62
+ viewToStoredCache.set(root, result);
63
+ return result;
64
+ });
59
65
  }
60
66
 
61
67
  /**
package/src/util/brand.ts CHANGED
@@ -18,7 +18,6 @@ import type { Covariant } from "./typeCheck.js";
18
18
  * `Type 'Name1' is not assignable to type 'Name2'.`
19
19
  *
20
20
  * These branded types are not opaque: A `Brand<A, B>` can still be used as a `B`.
21
- * @internal
22
21
  */
23
22
  export type Brand<ValueType, Name> = ValueType & BrandedType<ValueType, Name>;
24
23
 
@@ -42,7 +41,6 @@ export type Brand<ValueType, Name> = ValueType & BrandedType<ValueType, Name>;
42
41
  * - get nominal typing (so types produced without using this class can never be assignable to it).
43
42
  *
44
43
  * @sealed
45
- * @internal
46
44
  */
47
45
  export abstract class BrandedType<out ValueType, Name> {
48
46
  protected _typeCheck?: Covariant<ValueType>;
package/src/util/index.ts CHANGED
@@ -93,6 +93,7 @@ export {
93
93
  getLast,
94
94
  hasSome,
95
95
  hasSingle,
96
+ defineLazyCachedProperty,
96
97
  } from "./utils.js";
97
98
  export { ReferenceCountedBase, type ReferenceCounted } from "./referenceCounting.js";
98
99
 
@@ -107,8 +107,6 @@ export interface Contravariant<in T> {
107
107
  * ```typescript
108
108
  * protected _typeCheck?: Covariant<T>;
109
109
  * ```
110
- *
111
- * @internal
112
110
  */
113
111
  export interface Covariant<out T> {
114
112
  _removeContravariance?: T;
package/src/util/utils.ts CHANGED
@@ -537,3 +537,29 @@ export function capitalize<S extends string>(s: S): Capitalize<S> {
537
537
  export function compareStrings<T extends string>(a: T, b: T): number {
538
538
  return a > b ? 1 : a === b ? 0 : -1;
539
539
  }
540
+
541
+ /**
542
+ * Defines a property on an object that is lazily initialized and cached.
543
+ * @remarks This is useful for properties that are expensive to compute and it is not guaranteed that they will be accessed.
544
+ * This function initially defines a getter on the object, but after first read it replaces the getter with a value property.
545
+ * @param obj - The object on which to define the property.
546
+ * @param key - The key of the property to define.
547
+ * @param get - The function (called either once or not at all) to compute the value of the property.
548
+ * @returns `obj`, typed such that it has the new property.
549
+ * This allows for the new property to be read off of `obj` in a type-safe manner after calling this function.
550
+ */
551
+ export function defineLazyCachedProperty<
552
+ T extends object,
553
+ K extends string | number | symbol,
554
+ V,
555
+ >(obj: T, key: K, get: () => V): typeof obj & { [P in K]: V } {
556
+ Reflect.defineProperty(obj, key, {
557
+ get() {
558
+ const value = get();
559
+ Reflect.defineProperty(obj, key, { value });
560
+ return value;
561
+ },
562
+ configurable: true,
563
+ });
564
+ return obj as typeof obj & { [P in K]: V };
565
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAE3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,SAAU,SAAQ,gBAAgB;IAClD;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC;;;;;;;;;;OAUG;IACH,MAAM,IAAI,aAAa,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,QAAuB,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,OAAO,MAA8B,CAAC;AAEhE;;GAEG;AACH,UAAU,SAAS;IAClB;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAC/C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,CAMtE;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,sBAAsB,EAAE,SAAS;IACvE;;;;OAIG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;;OAGG;IACH,IAAI,IAAI,aAAa,CAAC;CACtB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunk.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D,kDAM6B;AA8B7B;;;;GAIG;AACU,QAAA,SAAS,GAAa,uBAAY,CAAC;AAEhD;;GAEG;AACU,QAAA,WAAW,GAAkB,MAAM,CAAC,aAAa,CAAC,CAAC;AA2BhE;;GAEG;AACH,SAAgB,WAAW,CAAC,MAAmB;IAC9C,IAAA,iBAAM,EACL,MAAM,CAAC,IAAI,qCAA6B,EACxC,KAAK,CAAC,+CAA+C,CACrD,CAAC;IACF,OAAQ,MAAoB,CAAC,mBAAW,CAAC,CAAC;AAC3C,CAAC;AAND,kCAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype ITreeCursorSynchronous,\n\trootFieldKey,\n} from \"../../core/index.js\";\nimport type { ReferenceCounted } from \"../../util/index.js\";\n\n/**\n * Contiguous part of the tree which get stored together in some data format.\n * Copy-on-write, but optimized to be mutated in place when a chunk only has a single user (detected using reference counting).\n * This allows for efficient cloning without major performance overheads for non-cloning scenarios.\n */\nexport interface TreeChunk extends ReferenceCounted {\n\t/**\n\t * The number of nodes at the top level of this chunk.\n\t *\n\t * If this chunk is included in a field, this is the amount this chunk contributes to the length of the field.\n\t */\n\treadonly topLevelLength: number;\n\n\t/**\n\t * Creates a cursor for navigating the content of this chunk.\n\t *\n\t * Starts in \"fields\" mode in a `dummyRoot` field containing the top level nodes.\n\t *\n\t * This cursor does not own a reference to the data:\n\t * it is up to the caller of this function to ensure the cursor is not used after they release their owning ref to this chunk.\n\t *\n\t * TODO: consider starting this in \"fields\" mode above the top level\n\t * which would compose better with utilities for processing sequences of nodes.\n\t */\n\tcursor(): ChunkedCursor;\n}\n\n/**\n * The key used for the field that contains the root of chunks when not parented anywhere.\n *\n * For now this is using the document root key to ease testing/compatibility, but this may change.\n */\nexport const dummyRoot: FieldKey = rootFieldKey;\n\n/**\n * A symbol for extracting a TreeChunk from {@link ITreeCursor}.\n */\nexport const cursorChunk: unique symbol = Symbol(\"cursorChunk\");\n\n/**\n * Cursors can optionally implement this interface, allowing querying them for the chunk they are traversing.\n */\ninterface WithChunk {\n\t/**\n\t * When in nodes mode, if a value is returned, it is a TreeChunk who's top level nodes are the\n\t * chunkLength nodes starting from chunkStart.\n\t *\n\t *\n\t * @remarks\n\t * Note that there may be other tree representations with different chunk APIs and thus different ways to query them.\n\t * The chunkStart and chunkLength values thus to not uniquely apply to the chunks accessed through this field.\n\t *\n\t * TODO:\n\t * This API (including the chunk start and end on ITreeCUrsor) have some issues:\n\t * 1. There are cases where multiple possible chunks could be considered.\n\t * For example, when in a SequenceChunk, it could be returned, or the chunk within it could be.\n\t * 2. When in a location other than the root of a chunk,\n\t * it can't provide information about the containing chunk other than by allocating a new chunk that just represents that field.\n\t *\n\t * As more optimizations get implemented, this API may need to change to better address these issues.\n\t */\n\treadonly [cursorChunk]?: TreeChunk | undefined;\n}\n\n/**\n * See {@link WithChunk}.\n */\nexport function tryGetChunk(cursor: ITreeCursor): undefined | TreeChunk {\n\tassert(\n\t\tcursor.mode === CursorLocationType.Nodes,\n\t\t0x57b /* cursorChunk only accessible in nodes mode */,\n\t);\n\treturn (cursor as WithChunk)[cursorChunk];\n}\n\n/**\n * Cursor for a chunk which can be wrapped by another cursor.\n *\n * @remarks See `BasicChunkCursor` which uses this.\n */\nexport interface ChunkedCursor extends ITreeCursorSynchronous, WithChunk {\n\t/**\n\t * Checks if the cursor is in the top level nodes of the chunk.\n\t *\n\t * @returns true iff cursor is within the root field, including at a node within that field.\n\t */\n\tatChunkRoot(): boolean;\n\n\t/**\n\t * Clones the cursor to produce a new independent cursor.\n\t * Does not add any counted references to any chunks.\n\t */\n\tfork(): ChunkedCursor;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAE3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,SAAU,SAAQ,gBAAgB;IAClD;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC;;;;;;;;;;OAUG;IACH,MAAM,IAAI,aAAa,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,QAAuB,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,OAAO,MAA8B,CAAC;AAEhE;;GAEG;AACH,UAAU,SAAS;IAClB;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAC/C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,CAMtE;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,sBAAsB,EAAE,SAAS;IACvE;;;;OAIG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;;OAGG;IACH,IAAI,IAAI,aAAa,CAAC;CACtB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAKN,YAAY,GACZ,MAAM,qBAAqB,CAAC;AA8B7B;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAa,YAAY,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAkB,MAAM,CAAC,aAAa,CAAC,CAAC;AA2BhE;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,MAAmB;IAC9C,MAAM,CACL,MAAM,CAAC,IAAI,qCAA6B,EACxC,KAAK,CAAC,+CAA+C,CACrD,CAAC;IACF,OAAQ,MAAoB,CAAC,WAAW,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype ITreeCursorSynchronous,\n\trootFieldKey,\n} from \"../../core/index.js\";\nimport type { ReferenceCounted } from \"../../util/index.js\";\n\n/**\n * Contiguous part of the tree which get stored together in some data format.\n * Copy-on-write, but optimized to be mutated in place when a chunk only has a single user (detected using reference counting).\n * This allows for efficient cloning without major performance overheads for non-cloning scenarios.\n */\nexport interface TreeChunk extends ReferenceCounted {\n\t/**\n\t * The number of nodes at the top level of this chunk.\n\t *\n\t * If this chunk is included in a field, this is the amount this chunk contributes to the length of the field.\n\t */\n\treadonly topLevelLength: number;\n\n\t/**\n\t * Creates a cursor for navigating the content of this chunk.\n\t *\n\t * Starts in \"fields\" mode in a `dummyRoot` field containing the top level nodes.\n\t *\n\t * This cursor does not own a reference to the data:\n\t * it is up to the caller of this function to ensure the cursor is not used after they release their owning ref to this chunk.\n\t *\n\t * TODO: consider starting this in \"fields\" mode above the top level\n\t * which would compose better with utilities for processing sequences of nodes.\n\t */\n\tcursor(): ChunkedCursor;\n}\n\n/**\n * The key used for the field that contains the root of chunks when not parented anywhere.\n *\n * For now this is using the document root key to ease testing/compatibility, but this may change.\n */\nexport const dummyRoot: FieldKey = rootFieldKey;\n\n/**\n * A symbol for extracting a TreeChunk from {@link ITreeCursor}.\n */\nexport const cursorChunk: unique symbol = Symbol(\"cursorChunk\");\n\n/**\n * Cursors can optionally implement this interface, allowing querying them for the chunk they are traversing.\n */\ninterface WithChunk {\n\t/**\n\t * When in nodes mode, if a value is returned, it is a TreeChunk who's top level nodes are the\n\t * chunkLength nodes starting from chunkStart.\n\t *\n\t *\n\t * @remarks\n\t * Note that there may be other tree representations with different chunk APIs and thus different ways to query them.\n\t * The chunkStart and chunkLength values thus to not uniquely apply to the chunks accessed through this field.\n\t *\n\t * TODO:\n\t * This API (including the chunk start and end on ITreeCUrsor) have some issues:\n\t * 1. There are cases where multiple possible chunks could be considered.\n\t * For example, when in a SequenceChunk, it could be returned, or the chunk within it could be.\n\t * 2. When in a location other than the root of a chunk,\n\t * it can't provide information about the containing chunk other than by allocating a new chunk that just represents that field.\n\t *\n\t * As more optimizations get implemented, this API may need to change to better address these issues.\n\t */\n\treadonly [cursorChunk]?: TreeChunk | undefined;\n}\n\n/**\n * See {@link WithChunk}.\n */\nexport function tryGetChunk(cursor: ITreeCursor): undefined | TreeChunk {\n\tassert(\n\t\tcursor.mode === CursorLocationType.Nodes,\n\t\t0x57b /* cursorChunk only accessible in nodes mode */,\n\t);\n\treturn (cursor as WithChunk)[cursorChunk];\n}\n\n/**\n * Cursor for a chunk which can be wrapped by another cursor.\n *\n * @remarks See `BasicChunkCursor` which uses this.\n */\nexport interface ChunkedCursor extends ITreeCursorSynchronous, WithChunk {\n\t/**\n\t * Checks if the cursor is in the top level nodes of the chunk.\n\t *\n\t * @returns true iff cursor is within the root field, including at a node within that field.\n\t */\n\tatChunkRoot(): boolean;\n\n\t/**\n\t * Clones the cursor to produce a new independent cursor.\n\t * Does not add any counted references to any chunks.\n\t */\n\tfork(): ChunkedCursor;\n}\n"]}