@fluidframework/tree 2.80.0 → 2.81.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 (1138) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/api-report/tree.alpha.api.md +42 -7
  3. package/dist/alpha.d.ts +5 -0
  4. package/dist/codec/codec.d.ts +2 -2
  5. package/dist/codec/codec.d.ts.map +1 -1
  6. package/dist/codec/codec.js +8 -8
  7. package/dist/codec/codec.js.map +1 -1
  8. package/dist/codec/versioned/codec.d.ts +1 -1
  9. package/dist/codec/versioned/codec.d.ts.map +1 -1
  10. package/dist/codec/versioned/codec.js +12 -12
  11. package/dist/codec/versioned/codec.js.map +1 -1
  12. package/dist/core/index.d.ts +1 -1
  13. package/dist/core/index.d.ts.map +1 -1
  14. package/dist/core/index.js.map +1 -1
  15. package/dist/core/rebase/index.d.ts +1 -1
  16. package/dist/core/rebase/index.d.ts.map +1 -1
  17. package/dist/core/rebase/index.js.map +1 -1
  18. package/dist/core/rebase/types.d.ts +44 -7
  19. package/dist/core/rebase/types.d.ts.map +1 -1
  20. package/dist/core/rebase/types.js.map +1 -1
  21. package/dist/core/rebase/utils.d.ts.map +1 -1
  22. package/dist/core/rebase/utils.js +5 -1
  23. package/dist/core/rebase/utils.js.map +1 -1
  24. package/dist/core/schema-stored/formatV2.d.ts.map +1 -1
  25. package/dist/core/schema-stored/formatV2.js +4 -4
  26. package/dist/core/schema-stored/formatV2.js.map +1 -1
  27. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  28. package/dist/core/tree/anchorSet.js +2 -1
  29. package/dist/core/tree/anchorSet.js.map +1 -1
  30. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  31. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  32. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +1 -1
  33. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  34. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  35. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  36. package/dist/core/tree/detachedFieldIndexCodecV1.js +3 -3
  37. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  38. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  39. package/dist/core/tree/detachedFieldIndexCodecV2.js +2 -2
  40. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  41. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -1
  42. package/dist/core/tree/detachedFieldIndexFormatV1.js +3 -3
  43. package/dist/core/tree/detachedFieldIndexFormatV1.js.map +1 -1
  44. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
  45. package/dist/core/tree/detachedFieldIndexFormatV2.js +4 -4
  46. package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
  47. package/dist/core/tree/visitDelta.d.ts +1 -1
  48. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  49. package/dist/core/tree/visitDelta.js +3 -2
  50. package/dist/core/tree/visitDelta.js.map +1 -1
  51. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  52. package/dist/core/tree/visitorUtils.js +59 -19
  53. package/dist/core/tree/visitorUtils.js.map +1 -1
  54. package/dist/feature-libraries/changeAtomIdBTree.d.ts +6 -1
  55. package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  56. package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -1
  57. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +1 -1
  58. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  59. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  60. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  61. package/dist/feature-libraries/chunked-forest/chunkedForest.js +3 -1
  62. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  63. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  65. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  66. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  67. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  68. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +1 -1
  70. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  71. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  72. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  73. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  74. package/dist/feature-libraries/chunked-forest/codec/codecs.js +1 -1
  75. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  76. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  77. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -0
  79. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  81. package/dist/feature-libraries/chunked-forest/codec/format.js +1 -1
  82. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  83. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +1 -1
  84. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.js.map +1 -1
  85. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +1 -1
  86. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  87. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +2 -2
  88. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  89. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  90. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +17 -15
  91. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  92. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +10 -52
  93. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  94. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +23 -64
  95. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  96. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  97. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  98. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  99. package/dist/feature-libraries/fieldKindIdentifiers.d.ts +9 -0
  100. package/dist/feature-libraries/fieldKindIdentifiers.d.ts.map +1 -0
  101. package/dist/feature-libraries/fieldKindIdentifiers.js +16 -0
  102. package/dist/feature-libraries/fieldKindIdentifiers.js.map +1 -0
  103. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  104. package/dist/feature-libraries/flex-tree/lazyField.js +8 -8
  105. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  106. package/dist/feature-libraries/flex-tree/observer.d.ts +1 -1
  107. package/dist/feature-libraries/flex-tree/observer.d.ts.map +1 -1
  108. package/dist/feature-libraries/flex-tree/observer.js.map +1 -1
  109. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  110. package/dist/feature-libraries/forest-summary/codec.js +1 -1
  111. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  112. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  113. package/dist/feature-libraries/forest-summary/forestSummarizer.js +6 -4
  114. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  115. package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  116. package/dist/feature-libraries/forest-summary/formatV1.js.map +1 -1
  117. package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  118. package/dist/feature-libraries/forest-summary/formatV2.js.map +1 -1
  119. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +4 -4
  120. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  121. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +2 -2
  122. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  123. package/dist/feature-libraries/forest-summary/summaryTypes.d.ts.map +1 -1
  124. package/dist/feature-libraries/forest-summary/summaryTypes.js.map +1 -1
  125. package/dist/feature-libraries/index.d.ts +1 -1
  126. package/dist/feature-libraries/index.d.ts.map +1 -1
  127. package/dist/feature-libraries/index.js.map +1 -1
  128. package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  129. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  130. package/dist/feature-libraries/modular-schema/fieldKindConfiguration.d.ts.map +1 -1
  131. package/dist/feature-libraries/modular-schema/fieldKindConfiguration.js.map +1 -1
  132. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts +1 -1
  133. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  134. package/dist/feature-libraries/modular-schema/genericFieldKind.js +2 -2
  135. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  136. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +1 -1
  137. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  138. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +2 -0
  139. package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  140. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  141. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -1
  142. package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  143. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  144. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +1 -1
  145. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  146. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +2 -2
  147. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  148. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +52 -43
  149. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  150. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +3 -3
  151. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  152. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  153. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  154. package/dist/feature-libraries/object-forest/objectForest.js +5 -3
  155. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  156. package/dist/feature-libraries/optional-field/index.d.ts +3 -3
  157. package/dist/feature-libraries/optional-field/index.d.ts.map +1 -1
  158. package/dist/feature-libraries/optional-field/index.js +4 -8
  159. package/dist/feature-libraries/optional-field/index.js.map +1 -1
  160. package/dist/feature-libraries/optional-field/optionalField.d.ts +10 -2
  161. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  162. package/dist/feature-libraries/optional-field/optionalField.js +13 -1
  163. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  164. package/dist/feature-libraries/optional-field/requiredField.d.ts +36 -0
  165. package/dist/feature-libraries/optional-field/requiredField.d.ts.map +1 -0
  166. package/dist/feature-libraries/optional-field/requiredField.js +27 -0
  167. package/dist/feature-libraries/optional-field/requiredField.js.map +1 -0
  168. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +1 -1
  169. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  170. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +7 -7
  171. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  172. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  173. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  174. package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
  175. package/dist/feature-libraries/schemaChecker.js +1 -1
  176. package/dist/feature-libraries/schemaChecker.js.map +1 -1
  177. package/dist/feature-libraries/sequence-field/index.d.ts +2 -14
  178. package/dist/feature-libraries/sequence-field/index.d.ts.map +1 -1
  179. package/dist/feature-libraries/sequence-field/index.js +3 -30
  180. package/dist/feature-libraries/sequence-field/index.js.map +1 -1
  181. package/dist/feature-libraries/sequence-field/rebase.js +1 -1
  182. package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
  183. package/dist/feature-libraries/sequence-field/sequenceKind.d.ts +16 -0
  184. package/dist/feature-libraries/sequence-field/sequenceKind.d.ts.map +1 -0
  185. package/dist/feature-libraries/sequence-field/sequenceKind.js +24 -0
  186. package/dist/feature-libraries/sequence-field/sequenceKind.js.map +1 -0
  187. package/dist/index.d.ts +3 -2
  188. package/dist/index.d.ts.map +1 -1
  189. package/dist/index.js +5 -1
  190. package/dist/index.js.map +1 -1
  191. package/dist/packageVersion.d.ts +1 -1
  192. package/dist/packageVersion.js +1 -1
  193. package/dist/packageVersion.js.map +1 -1
  194. package/dist/shared-tree/independentView.d.ts.map +1 -1
  195. package/dist/shared-tree/independentView.js +7 -7
  196. package/dist/shared-tree/independentView.js.map +1 -1
  197. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  198. package/dist/shared-tree/schematizingTreeView.js +12 -10
  199. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  200. package/dist/shared-tree/sharedTree.d.ts +2 -2
  201. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  202. package/dist/shared-tree/sharedTree.js +6 -33
  203. package/dist/shared-tree/sharedTree.js.map +1 -1
  204. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  205. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  206. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts +31 -24
  207. package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  208. package/dist/shared-tree/sharedTreeChangeEnricher.js +75 -58
  209. package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  210. package/dist/shared-tree/tree.d.ts.map +1 -1
  211. package/dist/shared-tree/tree.js +14 -14
  212. package/dist/shared-tree/tree.js.map +1 -1
  213. package/dist/shared-tree/treeAlpha.d.ts +1 -1
  214. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  215. package/dist/shared-tree/treeAlpha.js +77 -77
  216. package/dist/shared-tree/treeAlpha.js.map +1 -1
  217. package/dist/shared-tree/treeCheckout.d.ts +21 -6
  218. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  219. package/dist/shared-tree/treeCheckout.js +93 -37
  220. package/dist/shared-tree/treeCheckout.js.map +1 -1
  221. package/dist/shared-tree-core/branch.d.ts +1 -1
  222. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  223. package/dist/shared-tree-core/branch.js +5 -1
  224. package/dist/shared-tree-core/branch.js.map +1 -1
  225. package/dist/shared-tree-core/branchCommitEnricher.d.ts +18 -31
  226. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  227. package/dist/shared-tree-core/branchCommitEnricher.js +24 -76
  228. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  229. package/dist/shared-tree-core/branchIdCodec.d.ts.map +1 -1
  230. package/dist/shared-tree-core/branchIdCodec.js.map +1 -1
  231. package/dist/shared-tree-core/changeEnricher.d.ts +8 -43
  232. package/dist/shared-tree-core/changeEnricher.d.ts.map +1 -1
  233. package/dist/shared-tree-core/changeEnricher.js +0 -13
  234. package/dist/shared-tree-core/changeEnricher.js.map +1 -1
  235. package/dist/shared-tree-core/defaultResubmitMachine.d.ts +4 -12
  236. package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  237. package/dist/shared-tree-core/defaultResubmitMachine.js +26 -36
  238. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  239. package/dist/shared-tree-core/editManager.d.ts +1 -1
  240. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  241. package/dist/shared-tree-core/editManager.js +13 -7
  242. package/dist/shared-tree-core/editManager.js.map +1 -1
  243. package/dist/shared-tree-core/editManagerCodecs.d.ts +1 -1
  244. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  245. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  246. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  247. package/dist/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  248. package/dist/shared-tree-core/editManagerCodecsCommons.js +1 -2
  249. package/dist/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  250. package/dist/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  251. package/dist/shared-tree-core/editManagerCodecsV1toV4.js +1 -1
  252. package/dist/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  253. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  254. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
  255. package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  256. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  257. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  258. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  259. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  260. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
  261. package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  262. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js +1 -1
  263. package/dist/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
  264. package/dist/shared-tree-core/index.d.ts +2 -2
  265. package/dist/shared-tree-core/index.d.ts.map +1 -1
  266. package/dist/shared-tree-core/index.js +1 -3
  267. package/dist/shared-tree-core/index.js.map +1 -1
  268. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  269. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  270. package/dist/shared-tree-core/messageCodecV1ToV4.js +1 -1
  271. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  272. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts +1 -1
  273. package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  274. package/dist/shared-tree-core/messageCodecVSharedBranches.js +2 -2
  275. package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  276. package/dist/shared-tree-core/messageCodecs.d.ts +2 -2
  277. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  278. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  279. package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  280. package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  281. package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  282. package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  283. package/dist/shared-tree-core/messageTypes.d.ts.map +1 -1
  284. package/dist/shared-tree-core/messageTypes.js.map +1 -1
  285. package/dist/shared-tree-core/sharedTreeCore.d.ts +8 -4
  286. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  287. package/dist/shared-tree-core/sharedTreeCore.js +13 -13
  288. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  289. package/dist/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
  290. package/dist/shared-tree-core/versionedSummarizer.js +1 -1
  291. package/dist/shared-tree-core/versionedSummarizer.js.map +1 -1
  292. package/dist/simple-tree/api/configuration.d.ts +2 -2
  293. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  294. package/dist/simple-tree/api/configuration.js +14 -14
  295. package/dist/simple-tree/api/configuration.js.map +1 -1
  296. package/dist/simple-tree/api/create.d.ts +1 -1
  297. package/dist/simple-tree/api/create.d.ts.map +1 -1
  298. package/dist/simple-tree/api/create.js +7 -7
  299. package/dist/simple-tree/api/create.js.map +1 -1
  300. package/dist/simple-tree/api/dirtyIndex.d.ts +1 -1
  301. package/dist/simple-tree/api/dirtyIndex.d.ts.map +1 -1
  302. package/dist/simple-tree/api/dirtyIndex.js.map +1 -1
  303. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
  304. package/dist/simple-tree/api/discrepancies.js +23 -23
  305. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  306. package/dist/simple-tree/api/getJsonSchema.d.ts +1 -1
  307. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  308. package/dist/simple-tree/api/getJsonSchema.js +1 -1
  309. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  310. package/dist/simple-tree/api/identifierIndex.d.ts +2 -2
  311. package/dist/simple-tree/api/identifierIndex.d.ts.map +1 -1
  312. package/dist/simple-tree/api/identifierIndex.js.map +1 -1
  313. package/dist/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
  314. package/dist/simple-tree/api/incrementalAllowedTypes.d.ts.map +1 -1
  315. package/dist/simple-tree/api/incrementalAllowedTypes.js +6 -6
  316. package/dist/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  317. package/dist/simple-tree/api/index.d.ts +1 -1
  318. package/dist/simple-tree/api/index.d.ts.map +1 -1
  319. package/dist/simple-tree/api/index.js +2 -1
  320. package/dist/simple-tree/api/index.js.map +1 -1
  321. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +1 -1
  322. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  323. package/dist/simple-tree/api/schemaCompatibilityTester.js +1 -1
  324. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  325. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +2 -2
  326. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  327. package/dist/simple-tree/api/schemaCreationUtilities.js +7 -7
  328. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  329. package/dist/simple-tree/api/schemaFactory.d.ts +2 -2
  330. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  331. package/dist/simple-tree/api/schemaFactory.js +7 -7
  332. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  333. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +6 -6
  334. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  335. package/dist/simple-tree/api/schemaFactoryAlpha.js +2 -2
  336. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  337. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +2 -2
  338. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  339. package/dist/simple-tree/api/schemaFactoryBeta.js +2 -1
  340. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  341. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -1
  342. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  343. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  344. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  345. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  346. package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -1
  347. package/dist/simple-tree/api/schemaStatics.js.map +1 -1
  348. package/dist/simple-tree/api/simpleSchemaCodec.d.ts +1 -1
  349. package/dist/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -1
  350. package/dist/simple-tree/api/simpleSchemaCodec.js +17 -17
  351. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  352. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +2 -2
  353. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  354. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +6 -6
  355. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  356. package/dist/simple-tree/api/simpleTreeIndex.d.ts +1 -1
  357. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  358. package/dist/simple-tree/api/simpleTreeIndex.js +1 -1
  359. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  360. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +244 -0
  361. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  362. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +298 -2
  363. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  364. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  365. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  366. package/dist/simple-tree/api/tree.d.ts +5 -3
  367. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  368. package/dist/simple-tree/api/tree.js.map +1 -1
  369. package/dist/simple-tree/api/treeBeta.d.ts +1 -1
  370. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  371. package/dist/simple-tree/api/treeBeta.js +2 -2
  372. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  373. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  374. package/dist/simple-tree/api/treeNodeApi.js +4 -4
  375. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  376. package/dist/simple-tree/api/typesUnsafe.d.ts +1 -1
  377. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  378. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  379. package/dist/simple-tree/api/verboseTree.d.ts +1 -1
  380. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  381. package/dist/simple-tree/api/verboseTree.js +22 -22
  382. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  383. package/dist/simple-tree/core/allowedTypes.d.ts +1 -1
  384. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  385. package/dist/simple-tree/core/allowedTypes.js +7 -7
  386. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  387. package/dist/simple-tree/core/context.d.ts.map +1 -1
  388. package/dist/simple-tree/core/context.js.map +1 -1
  389. package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
  390. package/dist/simple-tree/core/treeNode.js +1 -1
  391. package/dist/simple-tree/core/treeNode.js.map +1 -1
  392. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  393. package/dist/simple-tree/core/treeNodeKernel.js +7 -5
  394. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  395. package/dist/simple-tree/core/treeNodeSchema.d.ts +5 -5
  396. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  397. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  398. package/dist/simple-tree/core/treeNodeValid.d.ts +3 -3
  399. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  400. package/dist/simple-tree/core/treeNodeValid.js +2 -2
  401. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  402. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  403. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  404. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  405. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  406. package/dist/simple-tree/core/withType.js.map +1 -1
  407. package/dist/simple-tree/createContext.d.ts.map +1 -1
  408. package/dist/simple-tree/createContext.js.map +1 -1
  409. package/dist/simple-tree/fieldSchema.d.ts +1 -1
  410. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  411. package/dist/simple-tree/fieldSchema.js.map +1 -1
  412. package/dist/simple-tree/index.d.ts +1 -1
  413. package/dist/simple-tree/index.d.ts.map +1 -1
  414. package/dist/simple-tree/index.js +3 -2
  415. package/dist/simple-tree/index.js.map +1 -1
  416. package/dist/simple-tree/leafNodeSchema.d.ts +1 -1
  417. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  418. package/dist/simple-tree/leafNodeSchema.js +15 -15
  419. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  420. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +1 -1
  421. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  422. package/dist/simple-tree/node-kinds/array/arrayNode.js +46 -46
  423. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  424. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +1 -1
  425. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  426. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  427. package/dist/simple-tree/node-kinds/common.d.ts.map +1 -1
  428. package/dist/simple-tree/node-kinds/common.js.map +1 -1
  429. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +2 -2
  430. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  431. package/dist/simple-tree/node-kinds/map/mapNode.js +24 -24
  432. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  433. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts +1 -1
  434. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  435. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  436. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +2 -2
  437. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  438. package/dist/simple-tree/node-kinds/object/objectNode.js +9 -9
  439. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  440. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +3 -3
  441. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  442. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  443. package/dist/simple-tree/node-kinds/record/recordNode.d.ts +1 -1
  444. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  445. package/dist/simple-tree/node-kinds/record/recordNode.js +34 -34
  446. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  447. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +1 -1
  448. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  449. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  450. package/dist/simple-tree/prepareForInsertion.d.ts +2 -2
  451. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  452. package/dist/simple-tree/prepareForInsertion.js +13 -13
  453. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  454. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  455. package/dist/simple-tree/simpleSchema.js.map +1 -1
  456. package/dist/simple-tree/treeSchema.d.ts.map +1 -1
  457. package/dist/simple-tree/treeSchema.js.map +1 -1
  458. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +1 -1
  459. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  460. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +10 -10
  461. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  462. package/dist/tableSchema.d.ts.map +1 -1
  463. package/dist/tableSchema.js +22 -21
  464. package/dist/tableSchema.js.map +1 -1
  465. package/dist/text/index.d.ts +7 -0
  466. package/dist/text/index.d.ts.map +1 -0
  467. package/dist/text/index.js +12 -0
  468. package/dist/text/index.js.map +1 -0
  469. package/dist/text/textDomain.d.ts +146 -0
  470. package/dist/text/textDomain.d.ts.map +1 -0
  471. package/dist/text/textDomain.js +122 -0
  472. package/dist/text/textDomain.js.map +1 -0
  473. package/dist/text/textDomainFormatted.d.ts +572 -0
  474. package/dist/text/textDomainFormatted.d.ts.map +1 -0
  475. package/dist/text/textDomainFormatted.js +183 -0
  476. package/dist/text/textDomainFormatted.js.map +1 -0
  477. package/dist/treeFactory.d.ts.map +1 -1
  478. package/dist/treeFactory.js +9 -9
  479. package/dist/treeFactory.js.map +1 -1
  480. package/dist/util/bTreeUtils.d.ts +12 -4
  481. package/dist/util/bTreeUtils.d.ts.map +1 -1
  482. package/dist/util/bTreeUtils.js +14 -18
  483. package/dist/util/bTreeUtils.js.map +1 -1
  484. package/dist/util/nestedMap.js +12 -12
  485. package/dist/util/nestedMap.js.map +1 -1
  486. package/dist/util/readSnapshotBlob.d.ts +1 -1
  487. package/dist/util/readSnapshotBlob.d.ts.map +1 -1
  488. package/dist/util/readSnapshotBlob.js.map +1 -1
  489. package/docs/user-facing/merge-semantics.md +3 -2
  490. package/eslint.config.mts +8 -36
  491. package/lib/alpha.d.ts +5 -0
  492. package/lib/codec/codec.d.ts +2 -2
  493. package/lib/codec/codec.d.ts.map +1 -1
  494. package/lib/codec/codec.js +1 -1
  495. package/lib/codec/codec.js.map +1 -1
  496. package/lib/codec/versioned/codec.d.ts +1 -1
  497. package/lib/codec/versioned/codec.d.ts.map +1 -1
  498. package/lib/codec/versioned/codec.js +2 -2
  499. package/lib/codec/versioned/codec.js.map +1 -1
  500. package/lib/core/index.d.ts +1 -1
  501. package/lib/core/index.d.ts.map +1 -1
  502. package/lib/core/index.js.map +1 -1
  503. package/lib/core/rebase/index.d.ts +1 -1
  504. package/lib/core/rebase/index.d.ts.map +1 -1
  505. package/lib/core/rebase/index.js.map +1 -1
  506. package/lib/core/rebase/types.d.ts +44 -7
  507. package/lib/core/rebase/types.d.ts.map +1 -1
  508. package/lib/core/rebase/types.js.map +1 -1
  509. package/lib/core/rebase/utils.d.ts.map +1 -1
  510. package/lib/core/rebase/utils.js +5 -1
  511. package/lib/core/rebase/utils.js.map +1 -1
  512. package/lib/core/schema-stored/formatV2.d.ts.map +1 -1
  513. package/lib/core/schema-stored/formatV2.js +1 -1
  514. package/lib/core/schema-stored/formatV2.js.map +1 -1
  515. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  516. package/lib/core/tree/anchorSet.js +2 -1
  517. package/lib/core/tree/anchorSet.js.map +1 -1
  518. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  519. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  520. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +1 -1
  521. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  522. package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  523. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  524. package/lib/core/tree/detachedFieldIndexCodecV1.js +1 -1
  525. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  526. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  527. package/lib/core/tree/detachedFieldIndexCodecV2.js +2 -2
  528. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  529. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -1
  530. package/lib/core/tree/detachedFieldIndexFormatV1.js +2 -2
  531. package/lib/core/tree/detachedFieldIndexFormatV1.js.map +1 -1
  532. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
  533. package/lib/core/tree/detachedFieldIndexFormatV2.js +2 -2
  534. package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
  535. package/lib/core/tree/visitDelta.d.ts +1 -1
  536. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  537. package/lib/core/tree/visitDelta.js +3 -2
  538. package/lib/core/tree/visitDelta.js.map +1 -1
  539. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  540. package/lib/core/tree/visitorUtils.js +59 -19
  541. package/lib/core/tree/visitorUtils.js.map +1 -1
  542. package/lib/feature-libraries/changeAtomIdBTree.d.ts +6 -1
  543. package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -1
  544. package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -1
  545. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +1 -1
  546. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  547. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  548. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  549. package/lib/feature-libraries/chunked-forest/chunkedForest.js +3 -1
  550. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  551. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +1 -1
  552. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  553. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  554. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +1 -1
  555. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  556. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  557. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +1 -1
  558. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  559. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  560. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  561. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  562. package/lib/feature-libraries/chunked-forest/codec/codecs.js +1 -1
  563. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  564. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  565. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  566. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -0
  567. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  568. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  569. package/lib/feature-libraries/chunked-forest/codec/format.js +1 -1
  570. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  571. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +1 -1
  572. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.js.map +1 -1
  573. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +1 -1
  574. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  575. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +2 -2
  576. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  577. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  578. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +5 -3
  579. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  580. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +10 -52
  581. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  582. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +4 -45
  583. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  584. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  585. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  586. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  587. package/lib/feature-libraries/fieldKindIdentifiers.d.ts +9 -0
  588. package/lib/feature-libraries/fieldKindIdentifiers.d.ts.map +1 -0
  589. package/lib/feature-libraries/fieldKindIdentifiers.js +13 -0
  590. package/lib/feature-libraries/fieldKindIdentifiers.js.map +1 -0
  591. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  592. package/lib/feature-libraries/flex-tree/lazyField.js +1 -1
  593. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  594. package/lib/feature-libraries/flex-tree/observer.d.ts +1 -1
  595. package/lib/feature-libraries/flex-tree/observer.d.ts.map +1 -1
  596. package/lib/feature-libraries/flex-tree/observer.js.map +1 -1
  597. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  598. package/lib/feature-libraries/forest-summary/codec.js +1 -1
  599. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  600. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  601. package/lib/feature-libraries/forest-summary/forestSummarizer.js +6 -4
  602. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  603. package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +1 -1
  604. package/lib/feature-libraries/forest-summary/formatV1.js.map +1 -1
  605. package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +1 -1
  606. package/lib/feature-libraries/forest-summary/formatV2.js.map +1 -1
  607. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +4 -4
  608. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
  609. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +2 -2
  610. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
  611. package/lib/feature-libraries/forest-summary/summaryTypes.d.ts.map +1 -1
  612. package/lib/feature-libraries/forest-summary/summaryTypes.js.map +1 -1
  613. package/lib/feature-libraries/index.d.ts +1 -1
  614. package/lib/feature-libraries/index.d.ts.map +1 -1
  615. package/lib/feature-libraries/index.js.map +1 -1
  616. package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  617. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  618. package/lib/feature-libraries/modular-schema/fieldKindConfiguration.d.ts.map +1 -1
  619. package/lib/feature-libraries/modular-schema/fieldKindConfiguration.js.map +1 -1
  620. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts +1 -1
  621. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  622. package/lib/feature-libraries/modular-schema/genericFieldKind.js +2 -2
  623. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  624. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +1 -1
  625. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -1
  626. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +2 -0
  627. package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -1
  628. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -1
  629. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +1 -1
  630. package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -1
  631. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  632. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +1 -1
  633. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  634. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +2 -2
  635. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  636. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +52 -43
  637. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  638. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +3 -3
  639. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  640. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  641. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  642. package/lib/feature-libraries/object-forest/objectForest.js +5 -3
  643. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  644. package/lib/feature-libraries/optional-field/index.d.ts +3 -3
  645. package/lib/feature-libraries/optional-field/index.d.ts.map +1 -1
  646. package/lib/feature-libraries/optional-field/index.js +2 -2
  647. package/lib/feature-libraries/optional-field/index.js.map +1 -1
  648. package/lib/feature-libraries/optional-field/optionalField.d.ts +10 -2
  649. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  650. package/lib/feature-libraries/optional-field/optionalField.js +14 -2
  651. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  652. package/lib/feature-libraries/optional-field/requiredField.d.ts +36 -0
  653. package/lib/feature-libraries/optional-field/requiredField.d.ts.map +1 -0
  654. package/lib/feature-libraries/optional-field/requiredField.js +24 -0
  655. package/lib/feature-libraries/optional-field/requiredField.js.map +1 -0
  656. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +1 -1
  657. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  658. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +1 -1
  659. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  660. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  661. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  662. package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
  663. package/lib/feature-libraries/schemaChecker.js +1 -1
  664. package/lib/feature-libraries/schemaChecker.js.map +1 -1
  665. package/lib/feature-libraries/sequence-field/index.d.ts +2 -14
  666. package/lib/feature-libraries/sequence-field/index.d.ts.map +1 -1
  667. package/lib/feature-libraries/sequence-field/index.js +1 -13
  668. package/lib/feature-libraries/sequence-field/index.js.map +1 -1
  669. package/lib/feature-libraries/sequence-field/rebase.js +1 -1
  670. package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
  671. package/lib/feature-libraries/sequence-field/sequenceKind.d.ts +16 -0
  672. package/lib/feature-libraries/sequence-field/sequenceKind.d.ts.map +1 -0
  673. package/lib/feature-libraries/sequence-field/sequenceKind.js +21 -0
  674. package/lib/feature-libraries/sequence-field/sequenceKind.js.map +1 -0
  675. package/lib/index.d.ts +3 -2
  676. package/lib/index.d.ts.map +1 -1
  677. package/lib/index.js +2 -1
  678. package/lib/index.js.map +1 -1
  679. package/lib/packageVersion.d.ts +1 -1
  680. package/lib/packageVersion.js +1 -1
  681. package/lib/packageVersion.js.map +1 -1
  682. package/lib/shared-tree/independentView.d.ts.map +1 -1
  683. package/lib/shared-tree/independentView.js +3 -3
  684. package/lib/shared-tree/independentView.js.map +1 -1
  685. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  686. package/lib/shared-tree/schematizingTreeView.js +12 -10
  687. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  688. package/lib/shared-tree/sharedTree.d.ts +2 -2
  689. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  690. package/lib/shared-tree/sharedTree.js +6 -33
  691. package/lib/shared-tree/sharedTree.js.map +1 -1
  692. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  693. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  694. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts +31 -24
  695. package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
  696. package/lib/shared-tree/sharedTreeChangeEnricher.js +73 -55
  697. package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
  698. package/lib/shared-tree/tree.d.ts.map +1 -1
  699. package/lib/shared-tree/tree.js +7 -7
  700. package/lib/shared-tree/tree.js.map +1 -1
  701. package/lib/shared-tree/treeAlpha.d.ts +1 -1
  702. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  703. package/lib/shared-tree/treeAlpha.js +3 -3
  704. package/lib/shared-tree/treeAlpha.js.map +1 -1
  705. package/lib/shared-tree/treeCheckout.d.ts +21 -6
  706. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  707. package/lib/shared-tree/treeCheckout.js +67 -11
  708. package/lib/shared-tree/treeCheckout.js.map +1 -1
  709. package/lib/shared-tree-core/branch.d.ts +1 -1
  710. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  711. package/lib/shared-tree-core/branch.js +5 -1
  712. package/lib/shared-tree-core/branch.js.map +1 -1
  713. package/lib/shared-tree-core/branchCommitEnricher.d.ts +18 -31
  714. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  715. package/lib/shared-tree-core/branchCommitEnricher.js +24 -76
  716. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  717. package/lib/shared-tree-core/branchIdCodec.d.ts.map +1 -1
  718. package/lib/shared-tree-core/branchIdCodec.js.map +1 -1
  719. package/lib/shared-tree-core/changeEnricher.d.ts +8 -43
  720. package/lib/shared-tree-core/changeEnricher.d.ts.map +1 -1
  721. package/lib/shared-tree-core/changeEnricher.js +1 -11
  722. package/lib/shared-tree-core/changeEnricher.js.map +1 -1
  723. package/lib/shared-tree-core/defaultResubmitMachine.d.ts +4 -12
  724. package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  725. package/lib/shared-tree-core/defaultResubmitMachine.js +28 -38
  726. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  727. package/lib/shared-tree-core/editManager.d.ts +1 -1
  728. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  729. package/lib/shared-tree-core/editManager.js +13 -7
  730. package/lib/shared-tree-core/editManager.js.map +1 -1
  731. package/lib/shared-tree-core/editManagerCodecs.d.ts +1 -1
  732. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  733. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  734. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts +1 -1
  735. package/lib/shared-tree-core/editManagerCodecsCommons.d.ts.map +1 -1
  736. package/lib/shared-tree-core/editManagerCodecsCommons.js +1 -2
  737. package/lib/shared-tree-core/editManagerCodecsCommons.js.map +1 -1
  738. package/lib/shared-tree-core/editManagerCodecsV1toV4.d.ts.map +1 -1
  739. package/lib/shared-tree-core/editManagerCodecsV1toV4.js +1 -1
  740. package/lib/shared-tree-core/editManagerCodecsV1toV4.js.map +1 -1
  741. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -1
  742. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js +1 -1
  743. package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -1
  744. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  745. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  746. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  747. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  748. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts +1 -1
  749. package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -1
  750. package/lib/shared-tree-core/editManagerFormatVSharedBranches.js +1 -1
  751. package/lib/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -1
  752. package/lib/shared-tree-core/index.d.ts +2 -2
  753. package/lib/shared-tree-core/index.d.ts.map +1 -1
  754. package/lib/shared-tree-core/index.js +0 -1
  755. package/lib/shared-tree-core/index.js.map +1 -1
  756. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
  757. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  758. package/lib/shared-tree-core/messageCodecV1ToV4.js +1 -1
  759. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  760. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts +1 -1
  761. package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
  762. package/lib/shared-tree-core/messageCodecVSharedBranches.js +2 -2
  763. package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
  764. package/lib/shared-tree-core/messageCodecs.d.ts +2 -2
  765. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  766. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  767. package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
  768. package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
  769. package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -1
  770. package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -1
  771. package/lib/shared-tree-core/messageTypes.d.ts.map +1 -1
  772. package/lib/shared-tree-core/messageTypes.js.map +1 -1
  773. package/lib/shared-tree-core/sharedTreeCore.d.ts +8 -4
  774. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  775. package/lib/shared-tree-core/sharedTreeCore.js +14 -14
  776. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  777. package/lib/shared-tree-core/versionedSummarizer.d.ts.map +1 -1
  778. package/lib/shared-tree-core/versionedSummarizer.js +1 -1
  779. package/lib/shared-tree-core/versionedSummarizer.js.map +1 -1
  780. package/lib/simple-tree/api/configuration.d.ts +2 -2
  781. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  782. package/lib/simple-tree/api/configuration.js +4 -4
  783. package/lib/simple-tree/api/configuration.js.map +1 -1
  784. package/lib/simple-tree/api/create.d.ts +1 -1
  785. package/lib/simple-tree/api/create.d.ts.map +1 -1
  786. package/lib/simple-tree/api/create.js +1 -1
  787. package/lib/simple-tree/api/create.js.map +1 -1
  788. package/lib/simple-tree/api/dirtyIndex.d.ts +1 -1
  789. package/lib/simple-tree/api/dirtyIndex.d.ts.map +1 -1
  790. package/lib/simple-tree/api/dirtyIndex.js.map +1 -1
  791. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
  792. package/lib/simple-tree/api/discrepancies.js +3 -3
  793. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  794. package/lib/simple-tree/api/getJsonSchema.d.ts +1 -1
  795. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  796. package/lib/simple-tree/api/getJsonSchema.js +1 -1
  797. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  798. package/lib/simple-tree/api/identifierIndex.d.ts +2 -2
  799. package/lib/simple-tree/api/identifierIndex.d.ts.map +1 -1
  800. package/lib/simple-tree/api/identifierIndex.js.map +1 -1
  801. package/lib/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
  802. package/lib/simple-tree/api/incrementalAllowedTypes.d.ts.map +1 -1
  803. package/lib/simple-tree/api/incrementalAllowedTypes.js +3 -3
  804. package/lib/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  805. package/lib/simple-tree/api/index.d.ts +1 -1
  806. package/lib/simple-tree/api/index.d.ts.map +1 -1
  807. package/lib/simple-tree/api/index.js +1 -1
  808. package/lib/simple-tree/api/index.js.map +1 -1
  809. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +1 -1
  810. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  811. package/lib/simple-tree/api/schemaCompatibilityTester.js +1 -1
  812. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  813. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +2 -2
  814. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  815. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -1
  816. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  817. package/lib/simple-tree/api/schemaFactory.d.ts +2 -2
  818. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  819. package/lib/simple-tree/api/schemaFactory.js +2 -2
  820. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  821. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +6 -6
  822. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  823. package/lib/simple-tree/api/schemaFactoryAlpha.js +2 -2
  824. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  825. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +2 -2
  826. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  827. package/lib/simple-tree/api/schemaFactoryBeta.js +2 -1
  828. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  829. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -1
  830. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  831. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  832. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  833. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  834. package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -1
  835. package/lib/simple-tree/api/schemaStatics.js.map +1 -1
  836. package/lib/simple-tree/api/simpleSchemaCodec.d.ts +1 -1
  837. package/lib/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -1
  838. package/lib/simple-tree/api/simpleSchemaCodec.js +3 -3
  839. package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  840. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +2 -2
  841. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  842. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +6 -6
  843. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  844. package/lib/simple-tree/api/simpleTreeIndex.d.ts +1 -1
  845. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  846. package/lib/simple-tree/api/simpleTreeIndex.js +1 -1
  847. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  848. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +244 -0
  849. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
  850. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +271 -1
  851. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
  852. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  853. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  854. package/lib/simple-tree/api/tree.d.ts +5 -3
  855. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  856. package/lib/simple-tree/api/tree.js.map +1 -1
  857. package/lib/simple-tree/api/treeBeta.d.ts +1 -1
  858. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  859. package/lib/simple-tree/api/treeBeta.js +2 -2
  860. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  861. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  862. package/lib/simple-tree/api/treeNodeApi.js +4 -4
  863. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  864. package/lib/simple-tree/api/typesUnsafe.d.ts +1 -1
  865. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  866. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  867. package/lib/simple-tree/api/verboseTree.d.ts +1 -1
  868. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  869. package/lib/simple-tree/api/verboseTree.js +3 -3
  870. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  871. package/lib/simple-tree/core/allowedTypes.d.ts +1 -1
  872. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  873. package/lib/simple-tree/core/allowedTypes.js +2 -2
  874. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  875. package/lib/simple-tree/core/context.d.ts.map +1 -1
  876. package/lib/simple-tree/core/context.js.map +1 -1
  877. package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
  878. package/lib/simple-tree/core/treeNode.js +1 -1
  879. package/lib/simple-tree/core/treeNode.js.map +1 -1
  880. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  881. package/lib/simple-tree/core/treeNodeKernel.js +7 -5
  882. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  883. package/lib/simple-tree/core/treeNodeSchema.d.ts +5 -5
  884. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  885. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  886. package/lib/simple-tree/core/treeNodeValid.d.ts +3 -3
  887. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  888. package/lib/simple-tree/core/treeNodeValid.js +2 -2
  889. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  890. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  891. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  892. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  893. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  894. package/lib/simple-tree/core/withType.js.map +1 -1
  895. package/lib/simple-tree/createContext.d.ts.map +1 -1
  896. package/lib/simple-tree/createContext.js.map +1 -1
  897. package/lib/simple-tree/fieldSchema.d.ts +1 -1
  898. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  899. package/lib/simple-tree/fieldSchema.js.map +1 -1
  900. package/lib/simple-tree/index.d.ts +1 -1
  901. package/lib/simple-tree/index.d.ts.map +1 -1
  902. package/lib/simple-tree/index.js +1 -1
  903. package/lib/simple-tree/index.js.map +1 -1
  904. package/lib/simple-tree/leafNodeSchema.d.ts +1 -1
  905. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  906. package/lib/simple-tree/leafNodeSchema.js +2 -2
  907. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  908. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +1 -1
  909. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  910. package/lib/simple-tree/node-kinds/array/arrayNode.js +5 -5
  911. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  912. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +1 -1
  913. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  914. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  915. package/lib/simple-tree/node-kinds/common.d.ts.map +1 -1
  916. package/lib/simple-tree/node-kinds/common.js.map +1 -1
  917. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +2 -2
  918. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  919. package/lib/simple-tree/node-kinds/map/mapNode.js +6 -6
  920. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  921. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts +1 -1
  922. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  923. package/lib/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  924. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +2 -2
  925. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  926. package/lib/simple-tree/node-kinds/object/objectNode.js +3 -3
  927. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  928. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +3 -3
  929. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  930. package/lib/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  931. package/lib/simple-tree/node-kinds/record/recordNode.d.ts +1 -1
  932. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  933. package/lib/simple-tree/node-kinds/record/recordNode.js +4 -4
  934. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  935. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +1 -1
  936. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  937. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  938. package/lib/simple-tree/prepareForInsertion.d.ts +2 -2
  939. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  940. package/lib/simple-tree/prepareForInsertion.js +4 -4
  941. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  942. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  943. package/lib/simple-tree/simpleSchema.js.map +1 -1
  944. package/lib/simple-tree/treeSchema.d.ts.map +1 -1
  945. package/lib/simple-tree/treeSchema.js.map +1 -1
  946. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +1 -1
  947. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  948. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +2 -2
  949. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  950. package/lib/tableSchema.d.ts.map +1 -1
  951. package/lib/tableSchema.js +2 -1
  952. package/lib/tableSchema.js.map +1 -1
  953. package/lib/text/index.d.ts +7 -0
  954. package/lib/text/index.d.ts.map +1 -0
  955. package/lib/text/index.js +7 -0
  956. package/lib/text/index.js.map +1 -0
  957. package/lib/text/textDomain.d.ts +146 -0
  958. package/lib/text/textDomain.d.ts.map +1 -0
  959. package/lib/text/textDomain.js +118 -0
  960. package/lib/text/textDomain.js.map +1 -0
  961. package/lib/text/textDomainFormatted.d.ts +572 -0
  962. package/lib/text/textDomainFormatted.d.ts.map +1 -0
  963. package/lib/text/textDomainFormatted.js +180 -0
  964. package/lib/text/textDomainFormatted.js.map +1 -0
  965. package/lib/treeFactory.d.ts.map +1 -1
  966. package/lib/treeFactory.js +2 -2
  967. package/lib/treeFactory.js.map +1 -1
  968. package/lib/util/bTreeUtils.d.ts +12 -4
  969. package/lib/util/bTreeUtils.d.ts.map +1 -1
  970. package/lib/util/bTreeUtils.js +15 -19
  971. package/lib/util/bTreeUtils.js.map +1 -1
  972. package/lib/util/nestedMap.js +12 -12
  973. package/lib/util/nestedMap.js.map +1 -1
  974. package/lib/util/readSnapshotBlob.d.ts +1 -1
  975. package/lib/util/readSnapshotBlob.d.ts.map +1 -1
  976. package/lib/util/readSnapshotBlob.js.map +1 -1
  977. package/package.json +25 -25
  978. package/src/codec/codec.ts +10 -7
  979. package/src/codec/versioned/codec.ts +3 -3
  980. package/src/core/index.ts +2 -0
  981. package/src/core/rebase/index.ts +2 -0
  982. package/src/core/rebase/types.ts +57 -20
  983. package/src/core/rebase/utils.ts +8 -4
  984. package/src/core/schema-stored/formatV2.ts +2 -1
  985. package/src/core/tree/anchorSet.ts +2 -1
  986. package/src/core/tree/detachedFieldIndex.ts +1 -1
  987. package/src/core/tree/detachedFieldIndexCodecCommon.ts +2 -1
  988. package/src/core/tree/detachedFieldIndexCodecV1.ts +2 -2
  989. package/src/core/tree/detachedFieldIndexCodecV2.ts +3 -3
  990. package/src/core/tree/detachedFieldIndexFormatV1.ts +3 -2
  991. package/src/core/tree/detachedFieldIndexFormatV2.ts +3 -2
  992. package/src/core/tree/visitDelta.ts +8 -5
  993. package/src/core/tree/visitorUtils.ts +57 -20
  994. package/src/feature-libraries/changeAtomIdBTree.ts +9 -1
  995. package/src/feature-libraries/chunked-forest/chunkTree.ts +1 -1
  996. package/src/feature-libraries/chunked-forest/chunkedForest.ts +3 -1
  997. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +1 -1
  998. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +1 -1
  999. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +1 -1
  1000. package/src/feature-libraries/chunked-forest/codec/codecs.ts +2 -2
  1001. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +2 -1
  1002. package/src/feature-libraries/chunked-forest/codec/format.ts +1 -1
  1003. package/src/feature-libraries/chunked-forest/codec/formatGeneric.ts +1 -0
  1004. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +3 -3
  1005. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +5 -10
  1006. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +22 -110
  1007. package/src/feature-libraries/default-schema/index.ts +0 -5
  1008. package/src/feature-libraries/fieldKindIdentifiers.ts +16 -0
  1009. package/src/feature-libraries/flex-tree/lazyField.ts +1 -1
  1010. package/src/feature-libraries/flex-tree/observer.ts +3 -1
  1011. package/src/feature-libraries/forest-summary/codec.ts +1 -1
  1012. package/src/feature-libraries/forest-summary/forestSummarizer.ts +9 -7
  1013. package/src/feature-libraries/forest-summary/formatV1.ts +1 -0
  1014. package/src/feature-libraries/forest-summary/formatV2.ts +1 -0
  1015. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +9 -7
  1016. package/src/feature-libraries/forest-summary/summaryTypes.ts +1 -0
  1017. package/src/feature-libraries/index.ts +0 -5
  1018. package/src/feature-libraries/mapTreeCursor.ts +1 -1
  1019. package/src/feature-libraries/modular-schema/fieldKindConfiguration.ts +1 -0
  1020. package/src/feature-libraries/modular-schema/genericFieldKind.ts +2 -2
  1021. package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +3 -1
  1022. package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +2 -2
  1023. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +3 -2
  1024. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +83 -74
  1025. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +3 -3
  1026. package/src/feature-libraries/object-forest/objectForest.ts +5 -3
  1027. package/src/feature-libraries/optional-field/index.ts +6 -8
  1028. package/src/feature-libraries/optional-field/optionalField.ts +31 -0
  1029. package/src/feature-libraries/optional-field/requiredField.ts +62 -0
  1030. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +1 -1
  1031. package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +1 -0
  1032. package/src/feature-libraries/schemaChecker.ts +3 -2
  1033. package/src/feature-libraries/sequence-field/index.ts +2 -51
  1034. package/src/feature-libraries/sequence-field/rebase.ts +1 -1
  1035. package/src/feature-libraries/sequence-field/sequenceKind.ts +40 -0
  1036. package/src/index.ts +7 -0
  1037. package/src/packageVersion.ts +1 -1
  1038. package/src/shared-tree/independentView.ts +4 -3
  1039. package/src/shared-tree/schematizingTreeView.ts +17 -13
  1040. package/src/shared-tree/sharedTree.ts +9 -46
  1041. package/src/shared-tree/sharedTreeChangeCodecs.ts +1 -0
  1042. package/src/shared-tree/sharedTreeChangeEnricher.ts +87 -66
  1043. package/src/shared-tree/tree.ts +10 -10
  1044. package/src/shared-tree/treeAlpha.ts +26 -25
  1045. package/src/shared-tree/treeCheckout.ts +119 -23
  1046. package/src/shared-tree-core/branch.ts +9 -5
  1047. package/src/shared-tree-core/branchCommitEnricher.ts +25 -77
  1048. package/src/shared-tree-core/branchIdCodec.ts +1 -0
  1049. package/src/shared-tree-core/changeEnricher.ts +8 -52
  1050. package/src/shared-tree-core/defaultResubmitMachine.ts +39 -51
  1051. package/src/shared-tree-core/editManager.ts +32 -32
  1052. package/src/shared-tree-core/editManagerCodecs.ts +2 -2
  1053. package/src/shared-tree-core/editManagerCodecsCommons.ts +7 -6
  1054. package/src/shared-tree-core/editManagerCodecsV1toV4.ts +1 -1
  1055. package/src/shared-tree-core/editManagerCodecsVSharedBranches.ts +2 -2
  1056. package/src/shared-tree-core/editManagerFormatCommons.ts +1 -0
  1057. package/src/shared-tree-core/editManagerFormatV1toV4.ts +1 -0
  1058. package/src/shared-tree-core/editManagerFormatVSharedBranches.ts +3 -2
  1059. package/src/shared-tree-core/index.ts +2 -5
  1060. package/src/shared-tree-core/messageCodecV1ToV4.ts +3 -3
  1061. package/src/shared-tree-core/messageCodecVSharedBranches.ts +4 -4
  1062. package/src/shared-tree-core/messageCodecs.ts +2 -2
  1063. package/src/shared-tree-core/messageFormatV1ToV4.ts +1 -0
  1064. package/src/shared-tree-core/messageFormatVSharedBranches.ts +1 -0
  1065. package/src/shared-tree-core/messageTypes.ts +1 -0
  1066. package/src/shared-tree-core/sharedTreeCore.ts +27 -28
  1067. package/src/shared-tree-core/versionedSummarizer.ts +3 -1
  1068. package/src/simple-tree/api/configuration.ts +9 -9
  1069. package/src/simple-tree/api/create.ts +7 -6
  1070. package/src/simple-tree/api/dirtyIndex.ts +4 -2
  1071. package/src/simple-tree/api/discrepancies.ts +9 -8
  1072. package/src/simple-tree/api/getJsonSchema.ts +4 -3
  1073. package/src/simple-tree/api/identifierIndex.ts +4 -2
  1074. package/src/simple-tree/api/incrementalAllowedTypes.ts +6 -5
  1075. package/src/simple-tree/api/index.ts +3 -0
  1076. package/src/simple-tree/api/schemaCompatibilityTester.ts +3 -3
  1077. package/src/simple-tree/api/schemaCreationUtilities.ts +4 -3
  1078. package/src/simple-tree/api/schemaFactory.ts +16 -17
  1079. package/src/simple-tree/api/schemaFactoryAlpha.ts +22 -22
  1080. package/src/simple-tree/api/schemaFactoryBeta.ts +18 -16
  1081. package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -1
  1082. package/src/simple-tree/api/schemaFromSimple.ts +1 -1
  1083. package/src/simple-tree/api/schemaStatics.ts +2 -0
  1084. package/src/simple-tree/api/simpleSchemaCodec.ts +12 -11
  1085. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +24 -22
  1086. package/src/simple-tree/api/simpleTreeIndex.ts +6 -4
  1087. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +504 -1
  1088. package/src/simple-tree/api/storedSchema.ts +2 -1
  1089. package/src/simple-tree/api/tree.ts +5 -3
  1090. package/src/simple-tree/api/treeBeta.ts +3 -3
  1091. package/src/simple-tree/api/treeNodeApi.ts +14 -13
  1092. package/src/simple-tree/api/typesUnsafe.ts +7 -8
  1093. package/src/simple-tree/api/verboseTree.ts +6 -5
  1094. package/src/simple-tree/core/allowedTypes.ts +4 -4
  1095. package/src/simple-tree/core/context.ts +1 -1
  1096. package/src/simple-tree/core/treeNode.ts +1 -1
  1097. package/src/simple-tree/core/treeNodeKernel.ts +7 -5
  1098. package/src/simple-tree/core/treeNodeSchema.ts +7 -6
  1099. package/src/simple-tree/core/treeNodeValid.ts +9 -9
  1100. package/src/simple-tree/core/unhydratedFlexTree.ts +1 -1
  1101. package/src/simple-tree/core/withType.ts +3 -2
  1102. package/src/simple-tree/createContext.ts +1 -0
  1103. package/src/simple-tree/fieldSchema.ts +1 -2
  1104. package/src/simple-tree/index.ts +3 -0
  1105. package/src/simple-tree/leafNodeSchema.ts +3 -3
  1106. package/src/simple-tree/node-kinds/array/arrayNode.ts +17 -16
  1107. package/src/simple-tree/node-kinds/array/arrayNodeTypes.ts +2 -2
  1108. package/src/simple-tree/node-kinds/common.ts +1 -1
  1109. package/src/simple-tree/node-kinds/map/mapNode.ts +16 -15
  1110. package/src/simple-tree/node-kinds/map/mapNodeTypes.ts +2 -2
  1111. package/src/simple-tree/node-kinds/object/objectNode.ts +11 -11
  1112. package/src/simple-tree/node-kinds/object/objectNodeTypes.ts +8 -7
  1113. package/src/simple-tree/node-kinds/record/recordNode.ts +12 -12
  1114. package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +1 -2
  1115. package/src/simple-tree/prepareForInsertion.ts +10 -8
  1116. package/src/simple-tree/simpleSchema.ts +1 -0
  1117. package/src/simple-tree/treeSchema.ts +1 -0
  1118. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +2 -2
  1119. package/src/tableSchema.ts +3 -1
  1120. package/src/text/README.md +8 -0
  1121. package/src/text/index.ts +7 -0
  1122. package/src/text/textDomain.ts +199 -0
  1123. package/src/text/textDomainFormatted.ts +309 -0
  1124. package/src/treeFactory.ts +4 -4
  1125. package/src/util/bTreeUtils.ts +33 -22
  1126. package/src/util/nestedMap.ts +12 -12
  1127. package/src/util/readSnapshotBlob.ts +4 -2
  1128. package/.eslintrc.cjs +0 -125
  1129. package/assertTagging.config.mjs +0 -14
  1130. package/dist/shared-tree-core/transactionEnricher.d.ts +0 -23
  1131. package/dist/shared-tree-core/transactionEnricher.d.ts.map +0 -1
  1132. package/dist/shared-tree-core/transactionEnricher.js +0 -74
  1133. package/dist/shared-tree-core/transactionEnricher.js.map +0 -1
  1134. package/lib/shared-tree-core/transactionEnricher.d.ts +0 -23
  1135. package/lib/shared-tree-core/transactionEnricher.d.ts.map +0 -1
  1136. package/lib/shared-tree-core/transactionEnricher.js +0 -70
  1137. package/lib/shared-tree-core/transactionEnricher.js.map +0 -1
  1138. package/src/shared-tree-core/transactionEnricher.ts +0 -74
@@ -0,0 +1,180 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { assert } from "@fluidframework/core-utils/internal";
6
+ import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
+ import { EmptyKey } from "../core/index.js";
8
+ import { enumFromStrings, eraseSchemaDetails, SchemaFactory, SchemaFactoryAlpha, TreeArrayNode, TreeBeta, } from "../simple-tree/index.js";
9
+ import { mapIterable } from "../util/index.js";
10
+ import { charactersFromString } from "./textDomain.js";
11
+ const sf = new SchemaFactoryAlpha("com.fluidframework.text.formatted");
12
+ class TextNode extends sf.object("Text", {
13
+ content: SchemaFactory.required([() => StringArray], { key: EmptyKey }),
14
+ }) {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.defaultFormat = new FormattedTextAsTree.CharacterFormat(defaultFormat);
18
+ }
19
+ insertAt(index, additionalCharacters) {
20
+ this.content.insertAt(index, TreeArrayNode.spread(textAtomsFromString(additionalCharacters, this.defaultFormat)));
21
+ }
22
+ removeRange(index, length) {
23
+ this.content.removeRange(index, length);
24
+ }
25
+ characters() {
26
+ return mapIterable(this.content, (atom) => atom.content.content);
27
+ }
28
+ fullString() {
29
+ return [...this.characters()].join("");
30
+ }
31
+ static fromString(value, format) {
32
+ // Constructing an ArrayNode from an iterator is supported, so creating an array from the iterable of characters seems like it's not necessary here,
33
+ // but to reduce the risk of incorrect data interpretation, we actually ban this in the special case where the iterable is a string directly, which is the case here.
34
+ // Thus the array construction here is necessary to avoid a runtime error.
35
+ return new TextNode({
36
+ content: [
37
+ ...textAtomsFromString(value, format ?? new FormattedTextAsTree.CharacterFormat(defaultFormat)),
38
+ ],
39
+ });
40
+ }
41
+ charactersWithFormatting() {
42
+ return this.content;
43
+ }
44
+ insertWithFormattingAt(index, additionalCharacters) {
45
+ this.content.insertAt(index, TreeArrayNode.spread(additionalCharacters));
46
+ }
47
+ formatRange(startIndex, length, format) {
48
+ for (let i = startIndex; i < startIndex + length; i++) {
49
+ const atom = this.content[i];
50
+ if (atom === undefined) {
51
+ throw new UsageError("Index out of bounds while formatting text range.");
52
+ }
53
+ for (const [key, value] of Object.entries(format)) {
54
+ // Object.entries should only return string keyed enumerable own properties.
55
+ // The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.
56
+ assert(typeof key === "string", "Object.entries returned a non-string key.");
57
+ const f = FormattedTextAsTree.CharacterFormat.fields.get(key);
58
+ if (f === undefined) {
59
+ throw new UsageError(`Unknown format key: ${key}`);
60
+ }
61
+ // Ensures that if the input is a node, it is cloned before being inserted into the tree.
62
+ atom.format[key] = TreeBeta.clone(TreeBeta.create(f, value));
63
+ }
64
+ }
65
+ }
66
+ }
67
+ const defaultFormat = {
68
+ bold: false,
69
+ italic: false,
70
+ underline: false,
71
+ size: 12,
72
+ font: "Arial",
73
+ };
74
+ function textAtomsFromString(value, format) {
75
+ const result = mapIterable(charactersFromString(value), (char) => new FormattedTextAsTree.StringAtom({
76
+ content: { content: char },
77
+ format: TreeBeta.clone(format),
78
+ }));
79
+ return result;
80
+ }
81
+ class StringArray extends sf.array("StringArray", [() => FormattedTextAsTree.StringAtom]) {
82
+ }
83
+ /**
84
+ * A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.
85
+ * @privateRemarks
86
+ * This has hard-coded assumptions about what kind of embedded content and what kind of formatting is supported.
87
+ * We will want to generalize this with a more generic schema factory function like with table.
88
+ * Then either that and/or the output from it can be package exported.
89
+ * This version is just an initial prototype.
90
+ * @internal
91
+ */
92
+ export var FormattedTextAsTree;
93
+ (function (FormattedTextAsTree) {
94
+ /**
95
+ * Formatting options for characters.
96
+ * @internal
97
+ */
98
+ class CharacterFormat extends sf.objectAlpha("CharacterFormat", {
99
+ bold: SchemaFactory.boolean,
100
+ italic: SchemaFactory.boolean,
101
+ underline: SchemaFactory.boolean,
102
+ size: SchemaFactory.number,
103
+ font: SchemaFactory.string,
104
+ }) {
105
+ }
106
+ FormattedTextAsTree.CharacterFormat = CharacterFormat;
107
+ /**
108
+ * Unit in the string representing a single character.
109
+ * @internal
110
+ */
111
+ class StringTextAtom extends sf.object("StringTextAtom", {
112
+ /**
113
+ * The underlying text content of this atom.
114
+ * @remarks
115
+ * This is typically a single unicode codepoint, and thus may contain multiple utf-16 surrogate pair code units.
116
+ * Using longer strings is still valid. For example, so users might store whole grapheme clusters here, or even longer sections of text.
117
+ * Anything combined into a single atom will be treated atomically, and can not be partially selected or formatted.
118
+ * Using larger atoms and splitting them as needed is NOT a recommended approach, since this will result in poor merge behavior for concurrent edits.
119
+ * Instead atoms should always be the smallest unit of text which will be independently selected, moved or formatted.
120
+ * @privateRemarks
121
+ * This content logically represents the whole atom's content, so using {@link EmptyKey} makes sense to help indicate that.
122
+ */
123
+ content: SchemaFactory.required([SchemaFactory.string], { key: EmptyKey }),
124
+ }) {
125
+ }
126
+ FormattedTextAsTree.StringTextAtom = StringTextAtom;
127
+ /**
128
+ * Tag with which a line in text can be formatted from HTML.
129
+ * @internal
130
+ */
131
+ FormattedTextAsTree.LineTag = enumFromStrings(sf.scopedFactory("lineTag"), [
132
+ "h1",
133
+ "h2",
134
+ "h3",
135
+ "h4",
136
+ "h5",
137
+ "li",
138
+ ]);
139
+ /**
140
+ * Unit in the string representing a new line character with line formatting.
141
+ * @remarks
142
+ * This aligns with how Quill represents line formatting.
143
+ * Note that not all new lines will use this,
144
+ * but only ones using this can have line specific formatting.
145
+ * @internal
146
+ */
147
+ class StringLineAtom extends sf.object("StringLineAtom", {
148
+ tag: FormattedTextAsTree.LineTag.schema,
149
+ }) {
150
+ constructor() {
151
+ super(...arguments);
152
+ this.content = "\n";
153
+ }
154
+ }
155
+ FormattedTextAsTree.StringLineAtom = StringLineAtom;
156
+ /**
157
+ * Types of "atoms" that make up the text.
158
+ * @internal
159
+ */
160
+ FormattedTextAsTree.StringAtomContent = [StringTextAtom, StringLineAtom];
161
+ /**
162
+ * A unit of the text, with formatting.
163
+ * @internal
164
+ */
165
+ class StringAtom extends sf.object("StringAtom", {
166
+ content: SchemaFactory.required(FormattedTextAsTree.StringAtomContent, { key: EmptyKey }),
167
+ format: CharacterFormat,
168
+ }) {
169
+ }
170
+ FormattedTextAsTree.StringAtom = StringAtom;
171
+ /**
172
+ * Schema for a text node.
173
+ * @remarks
174
+ * See {@link FormattedTextAsTree.Members} for the API.
175
+ * See {@link FormattedTextAsTree.Statics} for static APIs on this Schema, including construction.
176
+ * @internal
177
+ */
178
+ FormattedTextAsTree.Tree = eraseSchemaDetails()(TextNode);
179
+ })(FormattedTextAsTree || (FormattedTextAsTree = {}));
180
+ //# sourceMappingURL=textDomainFormatted.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textDomainFormatted.js","sourceRoot":"","sources":["../../src/text/textDomainFormatted.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACN,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,QAAQ,GACR,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAmB,MAAM,iBAAiB,CAAC;AAExE,MAAM,EAAE,GAAG,IAAI,kBAAkB,CAAC,mCAAmC,CAAC,CAAC;AAEvE,MAAM,QACL,SAAQ,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE;IACzB,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;CACvE,CAAC;IAHH;;QAMQ,kBAAa,GACnB,IAAI,mBAAmB,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IAsEzD,CAAC;IApEO,QAAQ,CAAC,KAAa,EAAE,oBAA4B;QAC1D,IAAI,CAAC,OAAO,CAAC,QAAQ,CACpB,KAAK,EACL,aAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC,oBAAoB,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CACnF,CAAC;IACH,CAAC;IACM,WAAW,CAAC,KAAa,EAAE,MAAc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ACrE,MAAM,EAAE,eAAe;KACvB,CAAC;KAAG;IAHQ,8BAAU,aAGlB,CAAA;IA2EL;;;;;;OAMG;IACU,wBAAI,GAAG,kBAAkB,EAAoB,CAAC,QAAQ,CAAC,CAAC;AAEtE,CAAC,EAtKgB,mBAAmB,KAAnB,mBAAmB,QAsKnC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { EmptyKey } from \"../core/index.js\";\nimport {\n\tenumFromStrings,\n\teraseSchemaDetails,\n\tSchemaFactory,\n\tSchemaFactoryAlpha,\n\tTreeArrayNode,\n\tTreeBeta,\n} from \"../simple-tree/index.js\";\nimport type {\n\tInsertableTypedNode,\n\tTreeNode,\n\tTreeNodeFromImplicitAllowedTypes,\n\tWithType,\n} from \"../simple-tree/index.js\";\nimport { mapIterable } from \"../util/index.js\";\n\nimport { charactersFromString, type TextAsTree } from \"./textDomain.js\";\n\nconst sf = new SchemaFactoryAlpha(\"com.fluidframework.text.formatted\");\n\nclass TextNode\n\textends sf.object(\"Text\", {\n\t\tcontent: SchemaFactory.required([() => StringArray], { key: EmptyKey }),\n\t})\n\timplements FormattedTextAsTree.Members\n{\n\tpublic defaultFormat: FormattedTextAsTree.CharacterFormat =\n\t\tnew FormattedTextAsTree.CharacterFormat(defaultFormat);\n\n\tpublic insertAt(index: number, additionalCharacters: string): void {\n\t\tthis.content.insertAt(\n\t\t\tindex,\n\t\t\tTreeArrayNode.spread(textAtomsFromString(additionalCharacters, this.defaultFormat)),\n\t\t);\n\t}\n\tpublic removeRange(index: number, length: number): void {\n\t\tthis.content.removeRange(index, length);\n\t}\n\tpublic characters(): Iterable<string> {\n\t\treturn mapIterable(this.content, (atom) => atom.content.content);\n\t}\n\tpublic fullString(): string {\n\t\treturn [...this.characters()].join(\"\");\n\t}\n\n\tpublic static fromString(\n\t\tvalue: string,\n\t\tformat?: FormattedTextAsTree.CharacterFormat,\n\t): TextNode {\n\t\t// Constructing an ArrayNode from an iterator is supported, so creating an array from the iterable of characters seems like it's not necessary here,\n\t\t// but to reduce the risk of incorrect data interpretation, we actually ban this in the special case where the iterable is a string directly, which is the case here.\n\t\t// Thus the array construction here is necessary to avoid a runtime error.\n\t\treturn new TextNode({\n\t\t\tcontent: [\n\t\t\t\t...textAtomsFromString(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformat ?? new FormattedTextAsTree.CharacterFormat(defaultFormat),\n\t\t\t\t),\n\t\t\t],\n\t\t});\n\t}\n\n\tpublic charactersWithFormatting(): Iterable<FormattedTextAsTree.StringAtom> {\n\t\treturn this.content;\n\t}\n\tpublic insertWithFormattingAt(\n\t\tindex: number,\n\t\tadditionalCharacters: Iterable<InsertableTypedNode<typeof FormattedTextAsTree.StringAtom>>,\n\t): void {\n\t\tthis.content.insertAt(index, TreeArrayNode.spread(additionalCharacters));\n\t}\n\tpublic formatRange(\n\t\tstartIndex: number,\n\t\tlength: number,\n\t\tformat: Partial<FormattedTextAsTree.CharacterFormat>,\n\t): void {\n\t\tfor (let i = startIndex; i < startIndex + length; i++) {\n\t\t\tconst atom = this.content[i];\n\t\t\tif (atom === undefined) {\n\t\t\t\tthrow new UsageError(\"Index out of bounds while formatting text range.\");\n\t\t\t}\n\t\t\tfor (const [key, value] of Object.entries(format) as [\n\t\t\t\tkeyof FormattedTextAsTree.CharacterFormat,\n\t\t\t\tunknown,\n\t\t\t][]) {\n\t\t\t\t// Object.entries should only return string keyed enumerable own properties.\n\t\t\t\t// The TypeScript typing does not account for this, and thus this assertion is necessary for this code to compile.\n\t\t\t\tassert(typeof key === \"string\", \"Object.entries returned a non-string key.\");\n\t\t\t\tconst f = FormattedTextAsTree.CharacterFormat.fields.get(key);\n\t\t\t\tif (f === undefined) {\n\t\t\t\t\tthrow new UsageError(`Unknown format key: ${key}`);\n\t\t\t\t}\n\t\t\t\t// Ensures that if the input is a node, it is cloned before being inserted into the tree.\n\t\t\t\tatom.format[key] = TreeBeta.clone(TreeBeta.create(f, value as never)) as never;\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst defaultFormat = {\n\tbold: false,\n\titalic: false,\n\tunderline: false,\n\tsize: 12,\n\tfont: \"Arial\",\n} as const;\n\nfunction textAtomsFromString(\n\tvalue: string,\n\tformat: FormattedTextAsTree.CharacterFormat,\n): Iterable<FormattedTextAsTree.StringAtom> {\n\tconst result = mapIterable(\n\t\tcharactersFromString(value),\n\t\t(char) =>\n\t\t\tnew FormattedTextAsTree.StringAtom({\n\t\t\t\tcontent: { content: char },\n\t\t\t\tformat: TreeBeta.clone<typeof FormattedTextAsTree.CharacterFormat>(format),\n\t\t\t}),\n\t);\n\treturn result;\n}\n\nclass StringArray extends sf.array(\"StringArray\", [() => FormattedTextAsTree.StringAtom]) {}\n\n/**\n * A collection of text related types, schema and utilities for working with text beyond the basic {@link SchemaStatics.string}.\n * @privateRemarks\n * This has hard-coded assumptions about what kind of embedded content and what kind of formatting is supported.\n * We will want to generalize this with a more generic schema factory function like with table.\n * Then either that and/or the output from it can be package exported.\n * This version is just an initial prototype.\n * @internal\n */\nexport namespace FormattedTextAsTree {\n\t/**\n\t * Formatting options for characters.\n\t * @internal\n\t */\n\texport class CharacterFormat extends sf.objectAlpha(\"CharacterFormat\", {\n\t\tbold: SchemaFactory.boolean,\n\t\titalic: SchemaFactory.boolean,\n\t\tunderline: SchemaFactory.boolean,\n\t\tsize: SchemaFactory.number,\n\t\tfont: SchemaFactory.string,\n\t}) {}\n\n\t/**\n\t * Unit in the string representing a single character.\n\t * @internal\n\t */\n\texport class StringTextAtom extends sf.object(\"StringTextAtom\", {\n\t\t/**\n\t\t * The underlying text content of this atom.\n\t\t * @remarks\n\t\t * This is typically a single unicode codepoint, and thus may contain multiple utf-16 surrogate pair code units.\n\t\t * Using longer strings is still valid. For example, so users might store whole grapheme clusters here, or even longer sections of text.\n\t\t * Anything combined into a single atom will be treated atomically, and can not be partially selected or formatted.\n\t\t * Using larger atoms and splitting them as needed is NOT a recommended approach, since this will result in poor merge behavior for concurrent edits.\n\t\t * Instead atoms should always be the smallest unit of text which will be independently selected, moved or formatted.\n\t\t * @privateRemarks\n\t\t * This content logically represents the whole atom's content, so using {@link EmptyKey} makes sense to help indicate that.\n\t\t */\n\t\tcontent: SchemaFactory.required([SchemaFactory.string], { key: EmptyKey }),\n\t}) {}\n\n\t/**\n\t * Tag with which a line in text can be formatted from HTML.\n\t * @internal\n\t */\n\texport const LineTag = enumFromStrings(sf.scopedFactory(\"lineTag\"), [\n\t\t\"h1\",\n\t\t\"h2\",\n\t\t\"h3\",\n\t\t\"h4\",\n\t\t\"h5\",\n\t\t\"li\",\n\t]);\n\t/**\n\t * {@inheritdoc FormattedTextAsTree.(LineTag:variable)}\n\t * @internal\n\t */\n\texport type LineTag = TreeNodeFromImplicitAllowedTypes<typeof LineTag.schema>;\n\n\t/**\n\t * Unit in the string representing a new line character with line formatting.\n\t * @remarks\n\t * This aligns with how Quill represents line formatting.\n\t * Note that not all new lines will use this,\n\t * but only ones using this can have line specific formatting.\n\t * @internal\n\t */\n\texport class StringLineAtom extends sf.object(\"StringLineAtom\", {\n\t\ttag: LineTag.schema,\n\t}) {\n\t\tpublic readonly content = \"\\n\";\n\t}\n\n\t/**\n\t * Types of \"atoms\" that make up the text.\n\t * @internal\n\t */\n\texport const StringAtomContent = [StringTextAtom, StringLineAtom] as const;\n\t/**\n\t * {@inheritdoc FormattedTextAsTree.(StringAtomContent:variable)}\n\t * @internal\n\t */\n\texport type StringAtomContent = TreeNodeFromImplicitAllowedTypes<typeof StringAtomContent>;\n\n\t/**\n\t * A unit of the text, with formatting.\n\t * @internal\n\t */\n\texport class StringAtom extends sf.object(\"StringAtom\", {\n\t\tcontent: SchemaFactory.required(StringAtomContent, { key: EmptyKey }),\n\t\tformat: CharacterFormat,\n\t}) {}\n\n\t/**\n\t * Statics for text nodes.\n\t * @internal\n\t */\n\texport interface Statics {\n\t\t/**\n\t\t * Construct a {@link FormattedTextAsTree.(Tree:type)} from a string, where each character (as defined by iterating over the string) becomes a single character in the text node.\n\t\t * @remarks This combines pairs of utf-16 surrogate code units into single characters as appropriate.\n\t\t */\n\t\tfromString(value: string): Tree;\n\t}\n\n\t/**\n\t * Interface for a text node.\n\t * @remarks\n\t * The string is broken up into substrings which are referred to as 'characters'.\n\t * Unlike with JavaScript strings, all indexes are by character, not UTF-16 code unit.\n\t * This avoids the problem JavaScript where it can split UTF-16 surrogate pairs producing invalid strings,\n\t * and avoids the issue where indexing a string and iterating it segment the string differently.\n\t * This does NOT mean the characters correspond to user perceived characters (like grapheme clusters try to do):\n\t * applications will likely want to include higher level segmentation logic\n\t * which might differ between operations like delete\n\t * (which often operates on something in between unicode code points and grapheme clusters)\n\t * and navigation/selection (which typically uses grapheme clusters).\n\t *\n\t * @see {@link FormattedTextAsTree.Statics.fromString} for construction.\n\t * @see {@link FormattedTextAsTree.(Tree:type)} for schema.\n\t * @internal\n\t */\n\texport interface Members extends TextAsTree.Members {\n\t\t/**\n\t\t * Format to use by default for text inserted with non-formatted APIs.\n\t\t * @remarks\n\t\t * This is not persisted in the tree, and observation of it is not tracked by the tree observation tracking.\n\t\t * @privateRemarks\n\t\t * Opt this into observation tracking.\n\t\t */\n\t\tdefaultFormat: CharacterFormat;\n\n\t\t/**\n\t\t * Gets an iterable over the characters currently in the text.\n\t\t * @remarks\n\t\t * This iterator matches the behavior of {@link (TreeArrayNode:interface)} with respect to edits during iteration.\n\t\t */\n\t\tcharactersWithFormatting(): Iterable<StringAtom>;\n\n\t\t/**\n\t\t * Insert a range of characters into the string based on character index.\n\t\t * @remarks\n\t\t * See {@link (TreeArrayNode:interface).insertAt} for more details on the behavior.\n\t\t * See {@link FormattedTextAsTree.Statics.fromString} for how the `additionalCharacters` string is broken into characters.\n\t\t * @privateRemarks\n\t\t * If we provide ways to customize character boundaries, that could be handled here by taking in an Iterable<string> instead of a string.\n\t\t * Doing this currently would enable insertion of text with different character boundaries than the existing text,\n\t\t * which would violate the currently documented character boundary invariants.\n\t\t *\n\t\t * Another option would be to take an approach like Table,\n\t\t * where the user of the API uses a factory function to generate the schema, and can inject custom logic, like a string character iterator.\n\t\t */\n\t\tinsertWithFormattingAt(\n\t\t\tindex: number,\n\t\t\tadditionalCharacters: Iterable<InsertableTypedNode<typeof StringAtom>>,\n\t\t): void;\n\n\t\t/**\n\t\t * Apply formatting to a range of characters based on character index.\n\t\t * @param startIndex - The starting index of the range to format.\n\t\t * @param length - The number of characters to format.\n\t\t * @param format - The formatting to apply to the specified range.\n\t\t */\n\t\tformatRange(startIndex: number, length: number, format: Partial<CharacterFormat>): void;\n\t}\n\n\t/**\n\t * Schema for a text node.\n\t * @remarks\n\t * See {@link FormattedTextAsTree.Members} for the API.\n\t * See {@link FormattedTextAsTree.Statics} for static APIs on this Schema, including construction.\n\t * @internal\n\t */\n\texport const Tree = eraseSchemaDetails<Members, Statics>()(TextNode);\n\texport type Tree = Members & TreeNode & WithType<\"com.fluidframework.text.formatted.Text\">;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"treeFactory.d.ts","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAMtB,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAE9B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAQpD;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,aAAa,EAAE,YAAY;CAAG;AA8DnE;;;;GAIG;AACH,eAAO,MAAM,UAAU,oDAA2B,CAAC;AAEnD;;;;;;;;;;;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nD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,qBAAqB,GAC5B,gBAAgB,CAAC,KAAK,CAAC,CAEzB;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,qBAAqB,GAC5B,iBAAiB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAEpD;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACxC,OAAO,EAAE,iBAAiB,GACxB,gBAAgB,CAAC,KAAK,CAAC,CAEzB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,iBAAiB,GACxB,iBAAiB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAGpD;AAED,wBAAgB,4BAA4B,CAC3C,OAAO,EAAE,yBAAyB,GAChC,iBAAiB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CASpD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,yBAAyB,CAQpF"}
@@ -4,11 +4,11 @@
4
4
  */
5
5
  import { makeSharedObjectKind, } from "@fluidframework/shared-object-base/internal";
6
6
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
+ import { FluidClientVersion } from "./codec/index.js";
7
8
  import { SharedTreeKernel, } from "./shared-tree/index.js";
9
+ import { editManagerFormatVersionSelectorForSharedBranches, messageFormatVersionSelectorForSharedBranches, } from "./shared-tree-core/index.js";
8
10
  import { SharedTreeFactoryType, SharedTreeAttributes } from "./sharedTreeAttributes.js";
9
11
  import { Breakable, copyProperty } from "./util/index.js";
10
- import { FluidClientVersion } from "./codec/index.js";
11
- import { editManagerFormatVersionSelectorForSharedBranches, messageFormatVersionSelectorForSharedBranches, } from "./shared-tree-core/index.js";
12
12
  /**
13
13
  * Creates a factory for shared tree kernels with the given options.
14
14
  * @remarks
@@ -1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mBAAmB,GAA+B;QACvD,IAAI,EAAE,qBAAqB;QAC3B,UAAU,EAAE,oBAAoB;QAChC,sBAAsB,EAAE,mBAAmB;QAC3C,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC;KACnC,CAAC;IAEF,OAAO,oBAAoB,CAAQ,mBAAmB,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAA0B;IACxD,MAAM,QAAQ,GAA8B;QAC3C,GAAG,oBAAoB,CAAC,OAAO,CAAC;KAChC,CAAC;IACF,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/C,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,SAAS,oBAAoB,CAAC,OAA0B;IACvD,MAAM,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,IAAI,KAAK,CAAC;IAEnE,IAAI,oBAAoB,EAAE,CAAC;QAC1B,OAAO,qBAAqB,CAAC;IAC9B,CAAC;IAED,OAAO,EAAE,CAAC;AACX,CAAC;AAED,MAAM,qBAAqB,GAA8B;IACxD,qBAAqB,EAAE,6CAA6C;IACpE,yBAAyB,EAAE,iDAAiD;CAC5E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport {\n\ttype ISharedObject,\n\ttype ISharedObjectKind,\n\tmakeSharedObjectKind,\n\ttype KernelArgs,\n\ttype SharedKernelFactory,\n\ttype SharedObjectOptions,\n\ttype FactoryOut,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tSharedTreeKernel,\n\ttype ITreePrivate,\n\ttype SharedTreeOptions,\n\ttype SharedTreeOptionsBeta,\n\ttype SharedTreeOptionsInternal,\n\ttype SharedTreeKernelView,\n} from \"./shared-tree/index.js\";\nimport { SharedTreeFactoryType, SharedTreeAttributes } from \"./sharedTreeAttributes.js\";\nimport type { ITree } from \"./simple-tree/index.js\";\nimport { Breakable, copyProperty } from \"./util/index.js\";\nimport { FluidClientVersion } from \"./codec/index.js\";\nimport {\n\teditManagerFormatVersionSelectorForSharedBranches,\n\tmessageFormatVersionSelectorForSharedBranches,\n} from \"./shared-tree-core/index.js\";\n\n/**\n * {@link ITreePrivate} extended with ISharedObject.\n * @remarks\n * This is used when integration testing this package with the Fluid runtime as it exposes the APIs the runtime consumes to manipulate the tree.\n */\nexport interface ISharedTree extends ISharedObject, ITreePrivate {}\n\n/**\n * Creates a factory for shared tree kernels with the given options.\n * @remarks\n * Exposes {@link ITreePrivate} to allow access to internals in tests without a cast.\n * Code exposing this beyond this package will need to update to a more public type.\n */\nfunction treeKernelFactory(\n\toptions: SharedTreeOptionsInternal,\n): SharedKernelFactory<SharedTreeKernelView> {\n\tfunction treeFromKernelArgs(args: KernelArgs): SharedTreeKernel {\n\t\tif (args.idCompressor === undefined) {\n\t\t\tthrow new UsageError(\"IdCompressor must be enabled to use SharedTree\");\n\t\t}\n\n\t\tconst { minVersionForCollab, ...otherOptions } = options;\n\n\t\tconst adjustedOptions = {\n\t\t\t...otherOptions,\n\t\t\t// Cases:\n\t\t\t// A. If options specifies minVersionForCollab, it takes precedence over args.minVersionForCollab.\n\t\t\t// This value is set when:\n\t\t\t// - A customer using the declarative SharedTree API specifies the setting at the Shared Tree level.\n\t\t\t// There is currently no way to set it via the declarative API, but it could be added in the future.\n\t\t\t// - treeKernelFactory is invoked in a fuzz test with a specific minVersionForCollab\n\t\t\t// B. Otherwise, we use args.minVersionForCollab, which is propagated from the ContainerRuntime.\n\t\t\t// C. If neither specifies it, we fall back to a default value default of 2.0 since that is the oldest version that supports SharedTree.\n\t\t\tminVersionForCollab:\n\t\t\t\tminVersionForCollab ?? args.minVersionForCollab ?? FluidClientVersion.v2_0,\n\t\t};\n\n\t\treturn new SharedTreeKernel(\n\t\t\tnew Breakable(\"SharedTree\"),\n\t\t\targs.sharedObject,\n\t\t\targs.serializer,\n\t\t\targs.submitLocalMessage,\n\t\t\targs.lastSequenceNumber,\n\t\t\targs.initialSequenceNumber,\n\t\t\targs.logger,\n\t\t\targs.idCompressor,\n\t\t\tadjustedOptions,\n\t\t);\n\t}\n\n\treturn {\n\t\tcreate: (args: KernelArgs): FactoryOut<SharedTreeKernelView> => {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\n\t\tasync loadCore(\n\t\t\targs: KernelArgs,\n\t\t\tstorage: IChannelStorageService,\n\t\t): Promise<FactoryOut<SharedTreeKernelView>> {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\tawait k.loadCore(storage);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\t};\n}\n\n/**\n * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees\n * of objects, arrays, and other data types.\n * @legacy @beta\n */\nexport const SharedTree = configuredSharedTree({});\n\n/**\n * {@link SharedTree} but allowing a non-default configuration.\n * @remarks\n * This is useful for debugging and testing.\n * For example it can be used to opt into extra validation or see if opting out of some optimizations fixes an issue.\n *\n * With great care, and knowledge of the support and stability of the options exposed here,\n * this can also be used to opt into some features early or for performance tuning.\n *\n * @example\n * ```typescript\n * import {\n * \tconfiguredSharedTreeBeta,\n * \tForestTypeReference,\n * } from \"fluid-framework/beta\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestTypeReference,\n * });\n * ```\n * @privateRemarks\n * The Legacy `ISharedObjectKind<ITree>` type is omitted here for simplicity.\n * @beta\n */\nexport function configuredSharedTreeBeta(\n\toptions: SharedTreeOptionsBeta,\n): SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBeta} including the legacy `ISharedObjectKind` type.\n * @privateRemarks\n * This is given a different export name (with legacy appended) to avoid the need to do the special reexport with different types from the fluid-framework package.\n * @legacy @beta\n */\nexport function configuredSharedTreeBetaLegacy(\n\toptions: SharedTreeOptionsBeta,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBeta} but including the alpha {@link SharedTreeOptions}.\n * @alpha\n */\nexport function configuredSharedTreeAlpha(\n\toptions: SharedTreeOptions,\n): SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBetaLegacy} but including `@alpha` options.\n *\n * @example\n * ```typescript\n * import {\n * \tTreeCompressionStrategy,\n * \tconfiguredSharedTree,\n * \tFormatValidatorBasic,\n * \tForestTypeReference,\n * } from \"@fluidframework/tree/internal\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestTypeReference,\n * \tjsonValidator: FormatValidatorBasic,\n * \ttreeEncodeType: TreeCompressionStrategy.Uncompressed,\n * });\n * ```\n * @privateRemarks\n * This should be legacy, but has to be internal due to no alpha+legacy being setup yet.\n *\n * This should be renamed to `configuredSharedTreeAlpha` to avoid colliding with the eventual public version which will have less options.\n * @internal\n */\nexport function configuredSharedTree(\n\toptions: SharedTreeOptions,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tconst internalOptions = resolveOptions(options);\n\treturn configuredSharedTreeInternal(internalOptions);\n}\n\nexport function configuredSharedTreeInternal(\n\toptions: SharedTreeOptionsInternal,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tconst sharedObjectOptions: SharedObjectOptions<ITree> = {\n\t\ttype: SharedTreeFactoryType,\n\t\tattributes: SharedTreeAttributes,\n\t\ttelemetryContextPrefix: \"fluid_sharedTree_\",\n\t\tfactory: treeKernelFactory(options),\n\t};\n\n\treturn makeSharedObjectKind<ITree>(sharedObjectOptions);\n}\n\nexport function resolveOptions(options: SharedTreeOptions): SharedTreeOptionsInternal {\n\tconst internal: SharedTreeOptionsInternal = {\n\t\t...resolveFormatOptions(options),\n\t};\n\tfor (const optionName of Object.keys(options)) {\n\t\tcopyProperty(options, optionName, internal);\n\t}\n\treturn internal;\n}\n\nfunction resolveFormatOptions(options: SharedTreeOptions): SharedTreeOptionsInternal {\n\tconst enableSharedBranches = options.enableSharedBranches ?? false;\n\n\tif (enableSharedBranches) {\n\t\treturn sharedBranchesOptions;\n\t}\n\n\treturn {};\n}\n\nconst sharedBranchesOptions: SharedTreeOptionsInternal = {\n\tmessageFormatSelector: messageFormatVersionSelectorForSharedBranches,\n\teditManagerFormatSelector: editManagerFormatVersionSelectorForSharedBranches,\n};\n"]}
1
+ {"version":3,"file":"treeFactory.js","sourceRoot":"","sources":["../src/treeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAGN,oBAAoB,GAKpB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACN,gBAAgB,GAMhB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,iDAAiD,EACjD,6CAA6C,GAC7C,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAExF,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAS1D;;;;;GAKG;AACH,SAAS,iBAAiB,CACzB,OAAkC;IAElC,SAAS,kBAAkB,CAAC,IAAgB;QAC3C,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,IAAI,UAAU,CAAC,gDAAgD,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,EAAE,mBAAmB,EAAE,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC;QAEzD,MAAM,eAAe,GAAG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EAAE,iDAAiD;CAC5E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport {\n\ttype ISharedObject,\n\ttype ISharedObjectKind,\n\tmakeSharedObjectKind,\n\ttype KernelArgs,\n\ttype SharedKernelFactory,\n\ttype SharedObjectOptions,\n\ttype FactoryOut,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { FluidClientVersion } from \"./codec/index.js\";\nimport {\n\tSharedTreeKernel,\n\ttype ITreePrivate,\n\ttype SharedTreeOptions,\n\ttype SharedTreeOptionsBeta,\n\ttype SharedTreeOptionsInternal,\n\ttype SharedTreeKernelView,\n} from \"./shared-tree/index.js\";\nimport {\n\teditManagerFormatVersionSelectorForSharedBranches,\n\tmessageFormatVersionSelectorForSharedBranches,\n} from \"./shared-tree-core/index.js\";\nimport { SharedTreeFactoryType, SharedTreeAttributes } from \"./sharedTreeAttributes.js\";\nimport type { ITree } from \"./simple-tree/index.js\";\nimport { Breakable, copyProperty } from \"./util/index.js\";\n\n/**\n * {@link ITreePrivate} extended with ISharedObject.\n * @remarks\n * This is used when integration testing this package with the Fluid runtime as it exposes the APIs the runtime consumes to manipulate the tree.\n */\nexport interface ISharedTree extends ISharedObject, ITreePrivate {}\n\n/**\n * Creates a factory for shared tree kernels with the given options.\n * @remarks\n * Exposes {@link ITreePrivate} to allow access to internals in tests without a cast.\n * Code exposing this beyond this package will need to update to a more public type.\n */\nfunction treeKernelFactory(\n\toptions: SharedTreeOptionsInternal,\n): SharedKernelFactory<SharedTreeKernelView> {\n\tfunction treeFromKernelArgs(args: KernelArgs): SharedTreeKernel {\n\t\tif (args.idCompressor === undefined) {\n\t\t\tthrow new UsageError(\"IdCompressor must be enabled to use SharedTree\");\n\t\t}\n\n\t\tconst { minVersionForCollab, ...otherOptions } = options;\n\n\t\tconst adjustedOptions = {\n\t\t\t...otherOptions,\n\t\t\t// Cases:\n\t\t\t// A. If options specifies minVersionForCollab, it takes precedence over args.minVersionForCollab.\n\t\t\t// This value is set when:\n\t\t\t// - A customer using the declarative SharedTree API specifies the setting at the Shared Tree level.\n\t\t\t// There is currently no way to set it via the declarative API, but it could be added in the future.\n\t\t\t// - treeKernelFactory is invoked in a fuzz test with a specific minVersionForCollab\n\t\t\t// B. Otherwise, we use args.minVersionForCollab, which is propagated from the ContainerRuntime.\n\t\t\t// C. If neither specifies it, we fall back to a default value default of 2.0 since that is the oldest version that supports SharedTree.\n\t\t\tminVersionForCollab:\n\t\t\t\tminVersionForCollab ?? args.minVersionForCollab ?? FluidClientVersion.v2_0,\n\t\t};\n\n\t\treturn new SharedTreeKernel(\n\t\t\tnew Breakable(\"SharedTree\"),\n\t\t\targs.sharedObject,\n\t\t\targs.serializer,\n\t\t\targs.submitLocalMessage,\n\t\t\targs.lastSequenceNumber,\n\t\t\targs.initialSequenceNumber,\n\t\t\targs.logger,\n\t\t\targs.idCompressor,\n\t\t\tadjustedOptions,\n\t\t);\n\t}\n\n\treturn {\n\t\tcreate: (args: KernelArgs): FactoryOut<SharedTreeKernelView> => {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\n\t\tasync loadCore(\n\t\t\targs: KernelArgs,\n\t\t\tstorage: IChannelStorageService,\n\t\t): Promise<FactoryOut<SharedTreeKernelView>> {\n\t\t\tconst k = treeFromKernelArgs(args);\n\t\t\tawait k.loadCore(storage);\n\t\t\treturn { kernel: k, view: k.view };\n\t\t},\n\t};\n}\n\n/**\n * SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees\n * of objects, arrays, and other data types.\n * @legacy @beta\n */\nexport const SharedTree = configuredSharedTree({});\n\n/**\n * {@link SharedTree} but allowing a non-default configuration.\n * @remarks\n * This is useful for debugging and testing.\n * For example it can be used to opt into extra validation or see if opting out of some optimizations fixes an issue.\n *\n * With great care, and knowledge of the support and stability of the options exposed here,\n * this can also be used to opt into some features early or for performance tuning.\n *\n * @example\n * ```typescript\n * import {\n * \tconfiguredSharedTreeBeta,\n * \tForestTypeReference,\n * } from \"fluid-framework/beta\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestTypeReference,\n * });\n * ```\n * @privateRemarks\n * The Legacy `ISharedObjectKind<ITree>` type is omitted here for simplicity.\n * @beta\n */\nexport function configuredSharedTreeBeta(\n\toptions: SharedTreeOptionsBeta,\n): SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBeta} including the legacy `ISharedObjectKind` type.\n * @privateRemarks\n * This is given a different export name (with legacy appended) to avoid the need to do the special reexport with different types from the fluid-framework package.\n * @legacy @beta\n */\nexport function configuredSharedTreeBetaLegacy(\n\toptions: SharedTreeOptionsBeta,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBeta} but including the alpha {@link SharedTreeOptions}.\n * @alpha\n */\nexport function configuredSharedTreeAlpha(\n\toptions: SharedTreeOptions,\n): SharedObjectKind<ITree> {\n\treturn configuredSharedTree(options);\n}\n\n/**\n * {@link configuredSharedTreeBetaLegacy} but including `@alpha` options.\n *\n * @example\n * ```typescript\n * import {\n * \tTreeCompressionStrategy,\n * \tconfiguredSharedTree,\n * \tFormatValidatorBasic,\n * \tForestTypeReference,\n * } from \"@fluidframework/tree/internal\";\n * const SharedTree = configuredSharedTree({\n * \tforest: ForestTypeReference,\n * \tjsonValidator: FormatValidatorBasic,\n * \ttreeEncodeType: TreeCompressionStrategy.Uncompressed,\n * });\n * ```\n * @privateRemarks\n * This should be legacy, but has to be internal due to no alpha+legacy being setup yet.\n *\n * This should be renamed to `configuredSharedTreeAlpha` to avoid colliding with the eventual public version which will have less options.\n * @internal\n */\nexport function configuredSharedTree(\n\toptions: SharedTreeOptions,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tconst internalOptions = resolveOptions(options);\n\treturn configuredSharedTreeInternal(internalOptions);\n}\n\nexport function configuredSharedTreeInternal(\n\toptions: SharedTreeOptionsInternal,\n): ISharedObjectKind<ITree> & SharedObjectKind<ITree> {\n\tconst sharedObjectOptions: SharedObjectOptions<ITree> = {\n\t\ttype: SharedTreeFactoryType,\n\t\tattributes: SharedTreeAttributes,\n\t\ttelemetryContextPrefix: \"fluid_sharedTree_\",\n\t\tfactory: treeKernelFactory(options),\n\t};\n\n\treturn makeSharedObjectKind<ITree>(sharedObjectOptions);\n}\n\nexport function resolveOptions(options: SharedTreeOptions): SharedTreeOptionsInternal {\n\tconst internal: SharedTreeOptionsInternal = {\n\t\t...resolveFormatOptions(options),\n\t};\n\tfor (const optionName of Object.keys(options)) {\n\t\tcopyProperty(options, optionName, internal);\n\t}\n\treturn internal;\n}\n\nfunction resolveFormatOptions(options: SharedTreeOptions): SharedTreeOptionsInternal {\n\tconst enableSharedBranches = options.enableSharedBranches ?? false;\n\n\tif (enableSharedBranches) {\n\t\treturn sharedBranchesOptions;\n\t}\n\n\treturn {};\n}\n\nconst sharedBranchesOptions: SharedTreeOptionsInternal = {\n\tmessageFormatSelector: messageFormatVersionSelectorForSharedBranches,\n\teditManagerFormatSelector: editManagerFormatVersionSelectorForSharedBranches,\n};\n"]}
@@ -2,9 +2,17 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { BTree } from "@tylerbu/sorted-btree-es6";
5
+ import { BTree, type DefaultComparable } from "@tylerbu/sorted-btree-es6";
6
6
  import { type Brand } from "./brand.js";
7
- export type TupleBTree<K, V> = Brand<BTree<K, V>, "TupleBTree">;
8
- export declare function newTupleBTree<K extends readonly unknown[], V>(entries?: [K, V][]): TupleBTree<K, V>;
9
- export declare function mergeTupleBTrees<K extends readonly unknown[], V>(tree1: TupleBTree<K, V> | undefined, tree2: TupleBTree<K, V> | undefined, preferLeft?: boolean): TupleBTree<K, V>;
7
+ /**
8
+ * A BTree which uses tuples (arrays) as the key.
9
+ * @remarks
10
+ * All keys must be the same length.
11
+ */
12
+ export type TupleBTree<K extends readonly DefaultComparable[], V> = Brand<BTree<K, V>, "TupleBTree">;
13
+ /**
14
+ * Create a new {@link TupleBTree}.
15
+ */
16
+ export declare function newTupleBTree<const K extends readonly DefaultComparable[], V>(entries?: [K, V][]): TupleBTree<K, V>;
17
+ export declare function mergeTupleBTrees<K extends readonly DefaultComparable[], V>(tree1: TupleBTree<K, V> | undefined, tree2: TupleBTree<K, V> | undefined, preferLeft?: boolean): TupleBTree<K, V>;
10
18
  //# sourceMappingURL=bTreeUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bTreeUtils.d.ts","sourceRoot":"","sources":["../../src/util/bTreeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAS,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;AAEhE,wBAAgB,aAAa,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EAAE,CAAC,EAC5D,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAChB,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAElB;AA0BD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EAAE,CAAC,EAC/D,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,EACnC,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,EACnC,UAAU,UAAO,GACf,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAelB"}
1
+ {"version":3,"file":"bTreeUtils.d.ts","sourceRoot":"","sources":["../../src/util/bTreeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,EAAqB,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE7F,OAAO,EAAS,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,SAAS,iBAAiB,EAAE,EAAE,CAAC,IAAI,KAAK,CACxE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EACX,YAAY,CACZ,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,iBAAiB,EAAE,EAAE,CAAC,EAC5E,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAChB,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAElB;AAyBD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,SAAS,iBAAiB,EAAE,EAAE,CAAC,EACzE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,EACnC,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,EACnC,UAAU,UAAO,GACf,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAelB"}
@@ -2,31 +2,27 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { BTree } from "@tylerbu/sorted-btree-es6";
5
+ import { debugAssert } from "@fluidframework/core-utils/internal";
6
+ import { BTree, defaultComparator } from "@tylerbu/sorted-btree-es6";
6
7
  import { brand } from "./brand.js";
8
+ /**
9
+ * Create a new {@link TupleBTree}.
10
+ */
7
11
  export function newTupleBTree(entries) {
8
12
  return brand(new BTree(entries, compareTuples));
9
13
  }
10
- // This assumes that the arrays are the same length.
14
+ /**
15
+ * Compares two tuples (arrays) element by element.
16
+ * @param arrayA - The first tuple to compare.
17
+ * @param arrayB - The second tuple to compare.
18
+ * @returns A negative number if arrayA \< arrayB, a positive number if arrayA \> arrayB, or 0 if they are equal.
19
+ */
11
20
  function compareTuples(arrayA, arrayB) {
21
+ debugAssert(() => arrayA.length === arrayB.length || "compareTuples requires arrays of the same length");
12
22
  for (let i = 0; i < arrayA.length; i++) {
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- const a = arrayA[i];
15
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
- const b = arrayB[i];
17
- // Less-than and greater-than always return false if either value is undefined,
18
- // so we handle undefined separately, treating it as less than all other values.
19
- if (a === undefined && b !== undefined) {
20
- return -1;
21
- }
22
- else if (b === undefined && a !== undefined) {
23
- return 1;
24
- }
25
- else if (a < b) {
26
- return -1;
27
- }
28
- else if (a > b) {
29
- return 1;
23
+ const result = defaultComparator(arrayA[i], arrayB[i]);
24
+ if (result !== 0) {
25
+ return result;
30
26
  }
31
27
  }
32
28
  return 0;
@@ -1 +1 @@
1
- {"version":3,"file":"bTreeUtils.js","sourceRoot":"","sources":["../../src/util/bTreeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAE,KAAK,EAAc,MAAM,YAAY,CAAC;AAI/C,MAAM,UAAU,aAAa,CAC5B,OAAkB;IAElB,OAAO,KAAK,CAAC,IAAI,KAAK,CAAO,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,oDAAoD;AACpD,SAAS,aAAa,CAAC,MAA0B,EAAE,MAA0B;IAC5E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,8DAA8D;QAC9D,MAAM,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served.\n * Licensed under the MIT License.\n */\n\nimport { BTree } from \"@tylerbu/sorted-btree-es6\";\n\nimport { brand, type Brand } from \"./brand.js\";\n\nexport type TupleBTree<K, V> = Brand<BTree<K, V>, \"TupleBTree\">;\n\nexport function newTupleBTree<K extends readonly unknown[], V>(\n\tentries?: [K, V][],\n): TupleBTree<K, V> {\n\treturn brand(new BTree<K, V>(entries, compareTuples));\n}\n\n// This assumes that the arrays are the same length.\nfunction compareTuples(arrayA: readonly unknown[], arrayB: readonly unknown[]): number {\n\tfor (let i = 0; i < arrayA.length; i++) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst a = arrayA[i] as any;\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tconst b = arrayB[i] as any;\n\n\t\t// Less-than and greater-than always return false if either value is undefined,\n\t\t// so we handle undefined separately, treating it as less than all other values.\n\t\tif (a === undefined && b !== undefined) {\n\t\t\treturn -1;\n\t\t} else if (b === undefined && a !== undefined) {\n\t\t\treturn 1;\n\t\t} else if (a < b) {\n\t\t\treturn -1;\n\t\t} else if (a > b) {\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nexport function mergeTupleBTrees<K extends readonly unknown[], V>(\n\ttree1: TupleBTree<K, V> | undefined,\n\ttree2: TupleBTree<K, V> | undefined,\n\tpreferLeft = true,\n): TupleBTree<K, V> {\n\tif (tree1 === undefined) {\n\t\treturn tree2 === undefined ? newTupleBTree<K, V>() : brand(tree2.clone());\n\t}\n\n\tconst result: TupleBTree<K, V> = brand(tree1.clone());\n\tif (tree2 === undefined) {\n\t\treturn result;\n\t}\n\n\tfor (const [key, value] of tree2.entries()) {\n\t\tresult.set(key, value, !preferLeft);\n\t}\n\n\treturn result;\n}\n"]}
1
+ {"version":3,"file":"bTreeUtils.js","sourceRoot":"","sources":["../../src/util/bTreeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,q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AAC,OAAO,EAAE,EAAE,CAAC;QAC5C,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { debugAssert } from \"@fluidframework/core-utils/internal\";\nimport { BTree, defaultComparator, type DefaultComparable } from \"@tylerbu/sorted-btree-es6\";\n\nimport { brand, type Brand } from \"./brand.js\";\n\n/**\n * A BTree which uses tuples (arrays) as the key.\n * @remarks\n * All keys must be the same length.\n */\nexport type TupleBTree<K extends readonly DefaultComparable[], V> = Brand<\n\tBTree<K, V>,\n\t\"TupleBTree\"\n>;\n\n/**\n * Create a new {@link TupleBTree}.\n */\nexport function newTupleBTree<const K extends readonly DefaultComparable[], V>(\n\tentries?: [K, V][],\n): TupleBTree<K, V> {\n\treturn brand(new BTree<K, V>(entries, compareTuples));\n}\n\n/**\n * Compares two tuples (arrays) element by element.\n * @param arrayA - The first tuple to compare.\n * @param arrayB - The second tuple to compare.\n * @returns A negative number if arrayA \\< arrayB, a positive number if arrayA \\> arrayB, or 0 if they are equal.\n */\nfunction compareTuples(\n\tarrayA: readonly DefaultComparable[],\n\tarrayB: readonly DefaultComparable[],\n): number {\n\tdebugAssert(\n\t\t() =>\n\t\t\tarrayA.length === arrayB.length || \"compareTuples requires arrays of the same length\",\n\t);\n\tfor (let i = 0; i < arrayA.length; i++) {\n\t\tconst result = defaultComparator(arrayA[i], arrayB[i]);\n\t\tif (result !== 0) {\n\t\t\treturn result;\n\t\t}\n\t}\n\treturn 0;\n}\n\nexport function mergeTupleBTrees<K extends readonly DefaultComparable[], V>(\n\ttree1: TupleBTree<K, V> | undefined,\n\ttree2: TupleBTree<K, V> | undefined,\n\tpreferLeft = true,\n): TupleBTree<K, V> {\n\tif (tree1 === undefined) {\n\t\treturn tree2 === undefined ? newTupleBTree<K, V>() : brand(tree2.clone());\n\t}\n\n\tconst result: TupleBTree<K, V> = brand(tree1.clone());\n\tif (tree2 === undefined) {\n\t\treturn result;\n\t}\n\n\tfor (const [key, value] of tree2.entries()) {\n\t\tresult.set(key, value, !preferLeft);\n\t}\n\n\treturn result;\n}\n"]}
@@ -114,11 +114,11 @@ export function deleteFromNestedMap(map, key1, key2) {
114
114
  */
115
115
  export function nestedMapToFlatList(map) {
116
116
  const list = [];
117
- map.forEach((innerMap, key1) => {
118
- innerMap.forEach((val, key2) => {
117
+ for (const [key1, innerMap] of map) {
118
+ for (const [key2, val] of innerMap) {
119
119
  list.push([key1, key2, val]);
120
- });
121
- });
120
+ }
121
+ }
122
122
  return list;
123
123
  }
124
124
  /**
@@ -132,11 +132,11 @@ export function nestedMapFromFlatList(list) {
132
132
  return map;
133
133
  }
134
134
  export function forEachInNestedMap(map, delegate) {
135
- map.forEach((innerMap, keyFirst) => {
136
- innerMap.forEach((val, keySecond) => {
135
+ for (const [keyFirst, innerMap] of map) {
136
+ for (const [keySecond, val] of innerMap) {
137
137
  delegate(val, keyFirst, keySecond);
138
- });
139
- });
138
+ }
139
+ }
140
140
  }
141
141
  /**
142
142
  * Maps the `input` map values using the provided `delegate`.
@@ -147,14 +147,14 @@ export function forEachInNestedMap(map, delegate) {
147
147
  */
148
148
  export function mapNestedMap(input, delegate) {
149
149
  const output = new Map();
150
- input.forEach((inputInnerMap, keyFirst) => {
150
+ for (const [keyFirst, inputInnerMap] of input) {
151
151
  const outputInnerMap = new Map();
152
- inputInnerMap.forEach((val, keySecond) => {
152
+ for (const [keySecond, val] of inputInnerMap) {
153
153
  const mappedValue = delegate(val, keyFirst, keySecond);
154
154
  outputInnerMap.set(keySecond, mappedValue);
155
- });
155
+ }
156
156
  output.set(keyFirst, outputInnerMap);
157
- });
157
+ }
158
158
  return output;
159
159
  }
160
160
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"nestedMap.js","sourceRoot":"","sources":["../../src/util/nestedMap.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,CAAC;QACd,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,QAAwD;QACtE,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACI,KAAK;QACX,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAEM,MAAM;QACZ,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;IAC1F,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC1C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { oob } from \"@fluidframework/core-utils/internal\";\n\nimport { getOrAddInMap, getOrCreate } from \"./utils.js\";\n\n/**\n * A dictionary whose values are keyed off of two objects (key1, key2).\n * As it is a nested map, size() will return the number of distinct key1s.\n * If you need constant-time access to the number of values, use SizedNestedMap instead.\n *\n * This code assumes values will not be undefined (keys can be undefined).\n */\nexport type NestedMap<Key1, Key2, Value> = Map<Key1, Map<Key2, Value>>;\n\n/**\n * A read-only version of {@link NestedMap}.\n */\nexport type ReadonlyNestedMap<Key1, Key2, Value> = ReadonlyMap<Key1, ReadonlyMap<Key2, Value>>;\n\n/**\n * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is returned.\n */\nexport function tryAddToNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value | undefined {\n\tlet innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\tinnerMap = new Map();\n\t\tmap.set(key1, innerMap);\n\t}\n\tif (innerMap.has(key2)) {\n\t\treturn innerMap.get(key2);\n\t}\n\tinnerMap.set(key2, value);\n\treturn undefined;\n}\n\n/**\n * Copies over all entries from the source map into the destination map.\n *\n * @param source - The map to copy data from. Not mutated.\n * @param destination - The map to copy data into. Both the outer and inner map may be mutated.\n * @param override - Whether existing entries in `destination` should be replaced by corresponding entries in `source`.\n *\n * @remarks This function performs deep copying when necessary.\n * This ensures that mutating `destination` after this call will not result in unexpected mutations to `source`.\n */\nexport function populateNestedMap<Key1, Key2, Value>(\n\tsource: ReadonlyNestedMap<Key1, Key2, Value>,\n\tdestination: NestedMap<Key1, Key2, Value>,\n\toverride: boolean,\n): void {\n\tfor (const [key1, sourceInner] of source) {\n\t\tlet destinationInner = destination.get(key1);\n\t\tif (destinationInner === undefined) {\n\t\t\tdestinationInner = new Map(sourceInner);\n\t\t\tdestination.set(key1, destinationInner);\n\t\t} else {\n\t\t\tfor (const [key2, value] of sourceInner) {\n\t\t\t\tif (override || !destinationInner.has(key2)) {\n\t\t\t\t\tdestinationInner.set(key2, value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Sets the value at (key1, key2) in map to value.\n * If there already is a value for (key1, key2), it is replaced with the provided one.\n */\nexport function setInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): void {\n\tconst innerMap = getOrAddInMap(map, key1, new Map<Key2, Value>());\n\tinnerMap.set(key2, value);\n}\n\n/**\n * {@link getOrCreate} for {@link NestedMap}.\n */\nexport function getOrCreateInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tdefaultValue: (key1: Key1, key2: Key2) => Value,\n): Value {\n\tconst innerMap = getOrAddInMap(map, key1, new Map<Key2, Value>());\n\treturn getOrCreate(innerMap, key2, (): Value => defaultValue(key1, key2));\n}\n\n/**\n * Returns the value at (key1, key2) in map, or undefined if not present.\n */\nexport function tryGetFromNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n): Value | undefined {\n\tconst innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\treturn undefined;\n\t}\n\treturn innerMap.get(key2);\n}\n\n/**\n * If (key1, key2) is not in the map, add value to the map.\n * Returns whatever is at (key1, key2) in map (which will be value if it was empty before).\n */\nexport function getOrAddInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value {\n\tconst existing = tryAddToNestedMap(map, key1, key2, value);\n\tif (existing !== undefined) {\n\t\treturn existing;\n\t}\n\treturn value;\n}\n\n/**\n * Does not change map.\n * If (key1, key2) is not in map, returns value.\n * If (key1, key2) is in map, return its entry.\n */\nexport function getOrDefaultInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value {\n\tconst existing = tryGetFromNestedMap(map, key1, key2);\n\tif (existing !== undefined) {\n\t\treturn existing;\n\t}\n\treturn value;\n}\n\n/**\n * Removes the value at (key1, key2) from the map.\n *\n * @returns true iff found.\n */\nexport function deleteFromNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n): boolean {\n\tconst innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\treturn false;\n\t}\n\tconst deleted = innerMap.delete(key2);\n\tif (innerMap.size === 0) {\n\t\tmap.delete(key1);\n\t}\n\treturn deleted;\n}\n\n/**\n * Converts a nested map to a flat list of triplets.\n */\nexport function nestedMapToFlatList<Key1, Key2, Value>(\n\tmap: ReadonlyNestedMap<Key1, Key2, Value>,\n): [Key1, Key2, Value][] {\n\tconst list: [Key1, Key2, Value][] = [];\n\tmap.forEach((innerMap, key1) => {\n\t\tinnerMap.forEach((val, key2) => {\n\t\t\tlist.push([key1, key2, val]);\n\t\t});\n\t});\n\treturn list;\n}\n\n/**\n * Builds a nested map from a flat list of triplets.\n */\nexport function nestedMapFromFlatList<Key1, Key2, Value>(\n\tlist: readonly (readonly [Key1, Key2, Value])[],\n): NestedMap<Key1, Key2, Value> {\n\tconst map = new Map<Key1, Map<Key2, Value>>();\n\tfor (const [key1, key2, val] of list) {\n\t\tgetOrAddInMap(map, key1, new Map<Key2, Value>()).set(key2, val);\n\t}\n\treturn map;\n}\n\nexport function forEachInNestedMap<Key1, Key2, Value>(\n\tmap: ReadonlyNestedMap<Key1, Key2, Value>,\n\tdelegate: (value: Value, key1: Key1, key2: Key2) => void,\n): void {\n\tmap.forEach((innerMap, keyFirst) => {\n\t\tinnerMap.forEach((val, keySecond) => {\n\t\t\tdelegate(val, keyFirst, keySecond);\n\t\t});\n\t});\n}\n\n/**\n * Maps the `input` map values using the provided `delegate`.\n *\n * @param input - The `NestedMap` whose contents are being mapped.\n * @param delegate - The delegate to use for mapping values,\n * @returns A new `NestedMap` with the same keys as `input`, but with the values produced by `delegate`.\n */\nexport function mapNestedMap<Key1, Key2, ValueIn, ValueOut = ValueIn>(\n\tinput: ReadonlyNestedMap<Key1, Key2, ValueIn>,\n\tdelegate: (value: ValueIn, key1: Key1, key2: Key2) => ValueOut,\n): NestedMap<Key1, Key2, ValueOut> {\n\tconst output = new Map<Key1, Map<Key2, ValueOut>>();\n\tinput.forEach((inputInnerMap, keyFirst) => {\n\t\tconst outputInnerMap = new Map<Key2, ValueOut>();\n\t\tinputInnerMap.forEach((val, keySecond) => {\n\t\t\tconst mappedValue = delegate(val, keyFirst, keySecond);\n\t\t\toutputInnerMap.set(keySecond, mappedValue);\n\t\t});\n\t\toutput.set(keyFirst, outputInnerMap);\n\t});\n\treturn output;\n}\n\n/**\n * Map with two keys; same semantics as NestedMap, but maintains a size count for the entire collection.\n * Note: undefined is not supported as a value, and will cause incorrect behavior.\n */\nexport class SizedNestedMap<Key1, Key2, Value> {\n\tprivate readonly nestedMap: NestedMap<Key1, Key2, Value> = new Map();\n\tprivate count = 0;\n\n\t/**\n\t * Returns the total number of elements in this nested map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.count;\n\t}\n\n\t/**\n\t * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is\n\t * returned.\n\t */\n\tpublic tryGet(key1: Key1, key2: Key2): Value | undefined {\n\t\treturn tryGetFromNestedMap(this.nestedMap, key1, key2);\n\t}\n\n\t/**\n\t * Does not change map.\n\t * If (key1, key2) is not in map, returns value.\n\t * If (key1, key2) is in map, return its entry.\n\t */\n\tpublic getOrDefault(key1: Key1, key2: Key2, value: Value): Value {\n\t\treturn getOrDefaultInNestedMap(this.nestedMap, key1, key2, value);\n\t}\n\n\t/**\n\t * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is\n\t * returned.\n\t */\n\tpublic tryAdd(key1: Key1, key2: Key2, value: Value): Value | undefined {\n\t\tconst currentVal = tryAddToNestedMap(this.nestedMap, key1, key2, value);\n\t\tif (currentVal === undefined) {\n\t\t\tthis.count++;\n\t\t}\n\t\treturn currentVal;\n\t}\n\n\t/**\n\t * Sets the value at (key1, key2) in map to value.\n\t * If there already is a value for (key1, key2), it is replaced with the provided one.\n\t */\n\tpublic set(key1: Key1, key2: Key2, value: Value): void {\n\t\tif (this.tryAdd(key1, key2, value) !== undefined) {\n\t\t\tsetInNestedMap(this.nestedMap, key1, key2, value);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the value at (key1, key2) from the map.\n\t * Returns true iff found.\n\t */\n\tpublic delete(key1: Key1, key2: Key2): boolean {\n\t\tconst deleted = deleteFromNestedMap(this.nestedMap, key1, key2);\n\t\tif (deleted) {\n\t\t\tthis.count--;\n\t\t}\n\t\treturn deleted;\n\t}\n\n\t/**\n\t * Runs the supplied delegate for every (value, key1, key2).\n\t */\n\tpublic forEach(delegate: (value: Value, key1: Key1, key2: Key2) => void): void {\n\t\tforEachInNestedMap(this.nestedMap, delegate);\n\t}\n\n\t/**\n\t * Clears the map.\n\t */\n\tpublic clear(): void {\n\t\tthis.count = 0;\n\t\tthis.nestedMap.clear();\n\t}\n\n\tpublic values(): IterableIterator<Value> {\n\t\treturn [...this.nestedMap.values()].flatMap((innerMap) => innerMap.values())[0] ?? oob();\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<[Key1, Map<Key2, Value>]> {\n\t\treturn this.nestedMap[Symbol.iterator]();\n\t}\n}\n"]}
1
+ {"version":3,"file":"nestedMap.js","sourceRoot":"","sources":["../../src/util/nestedMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAgBxD;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAChC,GAAiC,EACjC,IAAU,EACV,IAAU,EACV,KAAY;IAEZ,IAAI,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QACrB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1B,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;;;;;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AAO,UAAU,CAAC;IACnB,CAAC;IAED;;;OAGG;IACI,GAAG,CAAC,IAAU,EAAE,IAAU,EAAE,KAAY;QAC9C,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,SAAS,EAAE,CAAC;YAClD,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACnD,CAAC;IACF,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAU,EAAE,IAAU;QACnC,MAAM,OAAO,GAAG,mBAAmB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAChE,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,QAAwD;QACtE,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACI,KAAK;QACX,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAEM,MAAM;QACZ,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;IAC1F,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC1C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { oob } from \"@fluidframework/core-utils/internal\";\n\nimport { getOrAddInMap, getOrCreate } from \"./utils.js\";\n\n/**\n * A dictionary whose values are keyed off of two objects (key1, key2).\n * As it is a nested map, size() will return the number of distinct key1s.\n * If you need constant-time access to the number of values, use SizedNestedMap instead.\n *\n * This code assumes values will not be undefined (keys can be undefined).\n */\nexport type NestedMap<Key1, Key2, Value> = Map<Key1, Map<Key2, Value>>;\n\n/**\n * A read-only version of {@link NestedMap}.\n */\nexport type ReadonlyNestedMap<Key1, Key2, Value> = ReadonlyMap<Key1, ReadonlyMap<Key2, Value>>;\n\n/**\n * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is returned.\n */\nexport function tryAddToNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value | undefined {\n\tlet innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\tinnerMap = new Map();\n\t\tmap.set(key1, innerMap);\n\t}\n\tif (innerMap.has(key2)) {\n\t\treturn innerMap.get(key2);\n\t}\n\tinnerMap.set(key2, value);\n\treturn undefined;\n}\n\n/**\n * Copies over all entries from the source map into the destination map.\n *\n * @param source - The map to copy data from. Not mutated.\n * @param destination - The map to copy data into. Both the outer and inner map may be mutated.\n * @param override - Whether existing entries in `destination` should be replaced by corresponding entries in `source`.\n *\n * @remarks This function performs deep copying when necessary.\n * This ensures that mutating `destination` after this call will not result in unexpected mutations to `source`.\n */\nexport function populateNestedMap<Key1, Key2, Value>(\n\tsource: ReadonlyNestedMap<Key1, Key2, Value>,\n\tdestination: NestedMap<Key1, Key2, Value>,\n\toverride: boolean,\n): void {\n\tfor (const [key1, sourceInner] of source) {\n\t\tlet destinationInner = destination.get(key1);\n\t\tif (destinationInner === undefined) {\n\t\t\tdestinationInner = new Map(sourceInner);\n\t\t\tdestination.set(key1, destinationInner);\n\t\t} else {\n\t\t\tfor (const [key2, value] of sourceInner) {\n\t\t\t\tif (override || !destinationInner.has(key2)) {\n\t\t\t\t\tdestinationInner.set(key2, value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Sets the value at (key1, key2) in map to value.\n * If there already is a value for (key1, key2), it is replaced with the provided one.\n */\nexport function setInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): void {\n\tconst innerMap = getOrAddInMap(map, key1, new Map<Key2, Value>());\n\tinnerMap.set(key2, value);\n}\n\n/**\n * {@link getOrCreate} for {@link NestedMap}.\n */\nexport function getOrCreateInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tdefaultValue: (key1: Key1, key2: Key2) => Value,\n): Value {\n\tconst innerMap = getOrAddInMap(map, key1, new Map<Key2, Value>());\n\treturn getOrCreate(innerMap, key2, (): Value => defaultValue(key1, key2));\n}\n\n/**\n * Returns the value at (key1, key2) in map, or undefined if not present.\n */\nexport function tryGetFromNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n): Value | undefined {\n\tconst innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\treturn undefined;\n\t}\n\treturn innerMap.get(key2);\n}\n\n/**\n * If (key1, key2) is not in the map, add value to the map.\n * Returns whatever is at (key1, key2) in map (which will be value if it was empty before).\n */\nexport function getOrAddInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value {\n\tconst existing = tryAddToNestedMap(map, key1, key2, value);\n\tif (existing !== undefined) {\n\t\treturn existing;\n\t}\n\treturn value;\n}\n\n/**\n * Does not change map.\n * If (key1, key2) is not in map, returns value.\n * If (key1, key2) is in map, return its entry.\n */\nexport function getOrDefaultInNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n\tvalue: Value,\n): Value {\n\tconst existing = tryGetFromNestedMap(map, key1, key2);\n\tif (existing !== undefined) {\n\t\treturn existing;\n\t}\n\treturn value;\n}\n\n/**\n * Removes the value at (key1, key2) from the map.\n *\n * @returns true iff found.\n */\nexport function deleteFromNestedMap<Key1, Key2, Value>(\n\tmap: NestedMap<Key1, Key2, Value>,\n\tkey1: Key1,\n\tkey2: Key2,\n): boolean {\n\tconst innerMap = map.get(key1);\n\tif (innerMap === undefined) {\n\t\treturn false;\n\t}\n\tconst deleted = innerMap.delete(key2);\n\tif (innerMap.size === 0) {\n\t\tmap.delete(key1);\n\t}\n\treturn deleted;\n}\n\n/**\n * Converts a nested map to a flat list of triplets.\n */\nexport function nestedMapToFlatList<Key1, Key2, Value>(\n\tmap: ReadonlyNestedMap<Key1, Key2, Value>,\n): [Key1, Key2, Value][] {\n\tconst list: [Key1, Key2, Value][] = [];\n\tfor (const [key1, innerMap] of map) {\n\t\tfor (const [key2, val] of innerMap) {\n\t\t\tlist.push([key1, key2, val]);\n\t\t}\n\t}\n\treturn list;\n}\n\n/**\n * Builds a nested map from a flat list of triplets.\n */\nexport function nestedMapFromFlatList<Key1, Key2, Value>(\n\tlist: readonly (readonly [Key1, Key2, Value])[],\n): NestedMap<Key1, Key2, Value> {\n\tconst map = new Map<Key1, Map<Key2, Value>>();\n\tfor (const [key1, key2, val] of list) {\n\t\tgetOrAddInMap(map, key1, new Map<Key2, Value>()).set(key2, val);\n\t}\n\treturn map;\n}\n\nexport function forEachInNestedMap<Key1, Key2, Value>(\n\tmap: ReadonlyNestedMap<Key1, Key2, Value>,\n\tdelegate: (value: Value, key1: Key1, key2: Key2) => void,\n): void {\n\tfor (const [keyFirst, innerMap] of map) {\n\t\tfor (const [keySecond, val] of innerMap) {\n\t\t\tdelegate(val, keyFirst, keySecond);\n\t\t}\n\t}\n}\n\n/**\n * Maps the `input` map values using the provided `delegate`.\n *\n * @param input - The `NestedMap` whose contents are being mapped.\n * @param delegate - The delegate to use for mapping values,\n * @returns A new `NestedMap` with the same keys as `input`, but with the values produced by `delegate`.\n */\nexport function mapNestedMap<Key1, Key2, ValueIn, ValueOut = ValueIn>(\n\tinput: ReadonlyNestedMap<Key1, Key2, ValueIn>,\n\tdelegate: (value: ValueIn, key1: Key1, key2: Key2) => ValueOut,\n): NestedMap<Key1, Key2, ValueOut> {\n\tconst output = new Map<Key1, Map<Key2, ValueOut>>();\n\tfor (const [keyFirst, inputInnerMap] of input) {\n\t\tconst outputInnerMap = new Map<Key2, ValueOut>();\n\t\tfor (const [keySecond, val] of inputInnerMap) {\n\t\t\tconst mappedValue = delegate(val, keyFirst, keySecond);\n\t\t\toutputInnerMap.set(keySecond, mappedValue);\n\t\t}\n\t\toutput.set(keyFirst, outputInnerMap);\n\t}\n\treturn output;\n}\n\n/**\n * Map with two keys; same semantics as NestedMap, but maintains a size count for the entire collection.\n * Note: undefined is not supported as a value, and will cause incorrect behavior.\n */\nexport class SizedNestedMap<Key1, Key2, Value> {\n\tprivate readonly nestedMap: NestedMap<Key1, Key2, Value> = new Map();\n\tprivate count = 0;\n\n\t/**\n\t * Returns the total number of elements in this nested map.\n\t */\n\tpublic get size(): number {\n\t\treturn this.count;\n\t}\n\n\t/**\n\t * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is\n\t * returned.\n\t */\n\tpublic tryGet(key1: Key1, key2: Key2): Value | undefined {\n\t\treturn tryGetFromNestedMap(this.nestedMap, key1, key2);\n\t}\n\n\t/**\n\t * Does not change map.\n\t * If (key1, key2) is not in map, returns value.\n\t * If (key1, key2) is in map, return its entry.\n\t */\n\tpublic getOrDefault(key1: Key1, key2: Key2, value: Value): Value {\n\t\treturn getOrDefaultInNestedMap(this.nestedMap, key1, key2, value);\n\t}\n\n\t/**\n\t * If (key1, key2) already has a value in the map, it is returned, otherwise value is added under (key1, key2) and undefined is\n\t * returned.\n\t */\n\tpublic tryAdd(key1: Key1, key2: Key2, value: Value): Value | undefined {\n\t\tconst currentVal = tryAddToNestedMap(this.nestedMap, key1, key2, value);\n\t\tif (currentVal === undefined) {\n\t\t\tthis.count++;\n\t\t}\n\t\treturn currentVal;\n\t}\n\n\t/**\n\t * Sets the value at (key1, key2) in map to value.\n\t * If there already is a value for (key1, key2), it is replaced with the provided one.\n\t */\n\tpublic set(key1: Key1, key2: Key2, value: Value): void {\n\t\tif (this.tryAdd(key1, key2, value) !== undefined) {\n\t\t\tsetInNestedMap(this.nestedMap, key1, key2, value);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the value at (key1, key2) from the map.\n\t * Returns true iff found.\n\t */\n\tpublic delete(key1: Key1, key2: Key2): boolean {\n\t\tconst deleted = deleteFromNestedMap(this.nestedMap, key1, key2);\n\t\tif (deleted) {\n\t\t\tthis.count--;\n\t\t}\n\t\treturn deleted;\n\t}\n\n\t/**\n\t * Runs the supplied delegate for every (value, key1, key2).\n\t */\n\tpublic forEach(delegate: (value: Value, key1: Key1, key2: Key2) => void): void {\n\t\tforEachInNestedMap(this.nestedMap, delegate);\n\t}\n\n\t/**\n\t * Clears the map.\n\t */\n\tpublic clear(): void {\n\t\tthis.count = 0;\n\t\tthis.nestedMap.clear();\n\t}\n\n\tpublic values(): IterableIterator<Value> {\n\t\treturn [...this.nestedMap.values()].flatMap((innerMap) => innerMap.values())[0] ?? oob();\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<[Key1, Map<Key2, Value>]> {\n\t\treturn this.nestedMap[Symbol.iterator]();\n\t}\n}\n"]}
@@ -4,8 +4,8 @@
4
4
  */
5
5
  import type { IFluidHandle } from "@fluidframework/core-interfaces";
6
6
  import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
7
- import type { JsonCompatible } from "./utils.js";
8
7
  import type { SummaryElementParser } from "../shared-tree-core/index.js";
8
+ import type { JsonCompatible } from "./utils.js";
9
9
  /**
10
10
  * Reads and parses a snapshot blob from storage service.
11
11
  */
@@ -1 +1 @@
1
- {"version":3,"file":"readSnapshotBlob.d.ts","sourceRoot":"","sources":["../../src/util/readSnapshotBlob.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,wBAAwB,8DAC1B,MAAM,WACP,sBAAsB,SACxB,oBAAoB,KACzB,QAAQ,CAAC,CAIX,CAAC"}
1
+ {"version":3,"file":"readSnapshotBlob.d.ts","sourceRoot":"","sources":["../../src/util/readSnapshotBlob.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAE7F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,wBAAwB,8DAC1B,MAAM,WACP,sBAAsB,SACxB,oBAAoB,KACzB,QAAQ,CAAC,CAIX,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"readSnapshotBlob.js","sourceRoot":"","sources":["../../src/util/readSnapshotBlob.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAC5C,QAAgB,EAChB,OAA+B,EAC/B,KAA2B,EACd,EAAE;IACf,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpD,MAAM,gBAAgB,GAAG,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC5D,OAAO,KAAK,CAAC,gBAAgB,CAAM,CAAC;AACrC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport type { JsonCompatible } from \"./utils.js\";\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport type { SummaryElementParser } from \"../shared-tree-core/index.js\";\n\n/**\n * Reads and parses a snapshot blob from storage service.\n */\nexport const readAndParseSnapshotBlob = async <T extends JsonCompatible<IFluidHandle>>(\n\tblobPath: string,\n\tservice: IChannelStorageService,\n\tparse: SummaryElementParser,\n): Promise<T> => {\n\tconst treeBuffer = await service.readBlob(blobPath);\n\tconst treeBufferString = bufferToString(treeBuffer, \"utf8\");\n\treturn parse(treeBufferString) as T;\n};\n"]}
1
+ {"version":3,"file":"readSnapshotBlob.js","sourceRoot":"","sources":["../../src/util/readSnapshotBlob.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAQ9D;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAC5C,QAAgB,EAChB,OAA+B,EAC/B,KAA2B,EACd,EAAE;IACf,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpD,MAAM,gBAAgB,GAAG,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC5D,OAAO,KAAK,CAAC,gBAAgB,CAAM,CAAC;AACrC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\n\nimport type { SummaryElementParser } from \"../shared-tree-core/index.js\";\n\nimport type { JsonCompatible } from \"./utils.js\";\n\n/**\n * Reads and parses a snapshot blob from storage service.\n */\nexport const readAndParseSnapshotBlob = async <T extends JsonCompatible<IFluidHandle>>(\n\tblobPath: string,\n\tservice: IChannelStorageService,\n\tparse: SummaryElementParser,\n): Promise<T> => {\n\tconst treeBuffer = await service.readBlob(blobPath);\n\tconst treeBufferString = bufferToString(treeBuffer, \"utf8\");\n\treturn parse(treeBufferString) as T;\n};\n"]}