@fluidframework/tree 2.74.0 → 2.80.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.
- package/.eslintrc.cjs +1 -16
- package/CHANGELOG.md +18 -0
- package/api-report/tree.alpha.api.md +20 -2
- package/dist/alpha.d.ts +4 -0
- package/dist/codec/codec.d.ts +31 -3
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +10 -0
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +2 -2
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +2 -2
- package/dist/codec/index.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +80 -22
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +137 -15
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/codec/versioned/index.d.ts +1 -1
- package/dist/codec/versioned/index.d.ts.map +1 -1
- package/dist/codec/versioned/index.js +2 -2
- package/dist/codec/versioned/index.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/changeRebaser.d.ts +36 -2
- package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
- package/dist/core/rebase/changeRebaser.js.map +1 -1
- package/dist/core/rebase/index.d.ts +2 -2
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +1 -2
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +6 -2
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +1 -12
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/rebase/utils.js +3 -3
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/core/schema-stored/schema.js +3 -3
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +3 -4
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts +1 -2
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +12 -56
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
- package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecCommon.js +6 -6
- package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.js +4 -5
- package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.js +4 -6
- package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js +11 -41
- package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/dist/core/tree/index.d.ts +1 -1
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js +2 -2
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/mapTree.js +1 -1
- package/dist/core/tree/mapTree.js.map +1 -1
- package/dist/core/tree/sparseTree.d.ts.map +1 -1
- package/dist/core/tree/sparseTree.js +1 -0
- package/dist/core/tree/sparseTree.js.map +1 -1
- package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
- package/dist/core/tree/treeTextFormat.js +5 -9
- package/dist/core/tree/treeTextFormat.js.map +1 -1
- package/dist/feature-libraries/changeAtomIdBTree.d.ts +10 -0
- package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
- package/dist/feature-libraries/changeAtomIdBTree.js +16 -0
- package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -0
- package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js +6 -6
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +19 -11
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +15 -5
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +19 -14
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +2 -0
- package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/mappedEditBuilder.js +6 -0
- package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +11 -13
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +3 -2
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +9 -7
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js +6 -6
- package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.js +10 -1
- package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.js +12 -9
- package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +59 -0
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js +4 -4
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js +2 -2
- package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +4 -2
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +11 -7
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +49 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +315 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +15 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +31 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +25 -288
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +14 -8
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +225 -195
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/{modularChangeFormat.d.ts → modularChangeFormatV1.d.ts} +5 -6
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +7 -7
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +112 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +21 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +13 -3
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
- package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +4 -4
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +34 -39
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +14 -2
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts +7 -21
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +28 -70
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/feature-libraries/schema-index/index.d.ts +2 -2
- package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/index.js +2 -5
- package/dist/feature-libraries/schema-index/index.js.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -12
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/schemaChecker.js +11 -6
- package/dist/feature-libraries/schemaChecker.js.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.js +17 -13
- package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
- package/dist/feature-libraries/sequence-field/invert.js +5 -4
- package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.js +15 -9
- package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/dist/feature-libraries/sequence-field/rebase.js +26 -18
- package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/replaceRevisions.js +40 -35
- package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +16 -8
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +4 -2
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +6 -3
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.js +46 -27
- package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.js +7 -7
- package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
- package/dist/feature-libraries/treeTextCursor.js +2 -2
- package/dist/feature-libraries/treeTextCursor.js.map +1 -1
- package/dist/feature-libraries/valueUtilities.d.ts.map +1 -1
- package/dist/feature-libraries/valueUtilities.js +16 -8
- package/dist/feature-libraries/valueUtilities.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +2 -3
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +20 -9
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +61 -44
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +9 -8
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.js +4 -2
- package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +3 -2
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +19 -14
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.js +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +35 -29
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +21 -23
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +2 -0
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +31 -18
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +3 -1
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +5 -3
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.js +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/dist/shared-tree-core/editManager.js +1 -1
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js +9 -4
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js +6 -0
- package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.js +1 -0
- package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +3 -3
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js +2 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +8 -4
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/messageFormat.d.ts +1 -0
- package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormat.js +6 -0
- package/dist/shared-tree-core/messageFormat.js.map +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
- package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.js +8 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.js +4 -4
- package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +12 -8
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +25 -8
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +65 -30
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.d.ts +2 -2
- package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.js +3 -3
- package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
- package/dist/simple-tree/api/configuration.js +1 -1
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js +13 -9
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/dist/simple-tree/api/discrepancies.js +21 -17
- package/dist/simple-tree/api/discrepancies.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +12 -8
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js +18 -9
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaCodec.js +10 -5
- package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +15 -11
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.js +10 -10
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +2 -3
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/transactionTypes.d.ts +17 -4
- package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/dist/simple-tree/api/transactionTypes.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +21 -13
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +14 -9
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +6 -3
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +20 -15
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/getTreeNodeForField.d.ts.map +1 -1
- package/dist/simple-tree/getTreeNodeForField.js +2 -1
- package/dist/simple-tree/getTreeNodeForField.js.map +1 -1
- package/dist/simple-tree/index.d.ts +1 -1
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +9 -6
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +15 -15
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +4 -5
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +2 -3
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +9 -5
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/treeFactory.js +7 -3
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/bTreeUtils.js +1 -1
- package/dist/util/bTreeUtils.js.map +1 -1
- package/dist/util/breakable.js +7 -9
- package/dist/util/breakable.js.map +1 -1
- package/dist/util/idAllocator.d.ts.map +1 -1
- package/dist/util/idAllocator.js +1 -2
- package/dist/util/idAllocator.js.map +1 -1
- package/dist/util/nestedMap.d.ts.map +1 -1
- package/dist/util/nestedMap.js +1 -1
- package/dist/util/nestedMap.js.map +1 -1
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +16 -15
- package/dist/util/utils.js.map +1 -1
- package/eslint.config.mts +1 -16
- package/lib/alpha.d.ts +4 -0
- package/lib/codec/codec.d.ts +31 -3
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +10 -0
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +2 -2
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/codec/versioned/codec.d.ts +80 -22
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +138 -15
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/codec/versioned/index.d.ts +1 -1
- package/lib/codec/versioned/index.d.ts.map +1 -1
- package/lib/codec/versioned/index.js +1 -1
- package/lib/codec/versioned/index.js.map +1 -1
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -2
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/changeRebaser.d.ts +36 -2
- package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
- package/lib/core/rebase/changeRebaser.js.map +1 -1
- package/lib/core/rebase/index.d.ts +2 -2
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +1 -1
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +6 -2
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +0 -10
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/rebase/utils.js +3 -3
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/core/schema-stored/schema.js +3 -3
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +3 -4
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts +1 -2
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +13 -57
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
- package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecCommon.js +4 -4
- package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.js +4 -5
- package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.js +4 -6
- package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.js +12 -39
- package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/lib/core/tree/index.d.ts +1 -1
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js +1 -1
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/mapTree.js +1 -1
- package/lib/core/tree/mapTree.js.map +1 -1
- package/lib/core/tree/sparseTree.d.ts.map +1 -1
- package/lib/core/tree/sparseTree.js +1 -0
- package/lib/core/tree/sparseTree.js.map +1 -1
- package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
- package/lib/core/tree/treeTextFormat.js +5 -9
- package/lib/core/tree/treeTextFormat.js.map +1 -1
- package/lib/feature-libraries/changeAtomIdBTree.d.ts +10 -0
- package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
- package/lib/feature-libraries/changeAtomIdBTree.js +11 -0
- package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -0
- package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -6
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +19 -11
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +15 -5
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +19 -14
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +2 -0
- package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/mappedEditBuilder.js +6 -0
- package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +11 -13
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +3 -2
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +3 -2
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js +6 -6
- package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.js +10 -1
- package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.js +12 -9
- package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +55 -0
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js +5 -5
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +4 -2
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +3 -1
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +49 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +298 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +15 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +27 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +27 -290
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +14 -8
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +118 -88
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/{modularChangeFormat.d.ts → modularChangeFormatV1.d.ts} +5 -6
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +4 -4
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +112 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +18 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +13 -3
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
- package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +4 -4
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +35 -40
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +15 -3
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts +7 -21
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +30 -68
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/feature-libraries/schema-index/index.d.ts +2 -2
- package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/index.js +2 -2
- package/lib/feature-libraries/schema-index/index.js.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +0 -10
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/schemaChecker.js +11 -6
- package/lib/feature-libraries/schemaChecker.js.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.js +17 -13
- package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
- package/lib/feature-libraries/sequence-field/invert.js +5 -4
- package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.js +15 -9
- package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/lib/feature-libraries/sequence-field/rebase.js +26 -18
- package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/replaceRevisions.js +41 -36
- package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +16 -8
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +4 -2
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +6 -3
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.js +46 -27
- package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.js +7 -7
- package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
- package/lib/feature-libraries/treeTextCursor.js +2 -2
- package/lib/feature-libraries/treeTextCursor.js.map +1 -1
- package/lib/feature-libraries/valueUtilities.d.ts.map +1 -1
- package/lib/feature-libraries/valueUtilities.js +16 -8
- package/lib/feature-libraries/valueUtilities.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +2 -3
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +20 -9
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +30 -13
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +9 -8
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.js +4 -2
- package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +3 -2
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +19 -14
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.js +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +35 -29
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +21 -23
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +2 -0
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +32 -19
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +3 -1
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +5 -3
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.js +2 -2
- package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/lib/shared-tree-core/editManager.js +1 -1
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js +9 -4
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js +6 -0
- package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.js +1 -0
- package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +3 -3
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js +2 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +8 -4
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/messageFormat.d.ts +1 -0
- package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormat.js +6 -0
- package/lib/shared-tree-core/messageFormat.js.map +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
- package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.js +8 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.js +4 -4
- package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +12 -8
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +25 -8
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +67 -32
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.d.ts +2 -2
- package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.js +3 -3
- package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
- package/lib/simple-tree/api/configuration.js +1 -1
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js +13 -9
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/lib/simple-tree/api/discrepancies.js +21 -17
- package/lib/simple-tree/api/discrepancies.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +12 -8
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js +18 -9
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaCodec.js +10 -5
- package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +15 -11
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.js +10 -10
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +4 -7
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/transactionTypes.d.ts +17 -4
- package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/lib/simple-tree/api/transactionTypes.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +21 -13
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +14 -9
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +6 -3
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +20 -15
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/getTreeNodeForField.d.ts.map +1 -1
- package/lib/simple-tree/getTreeNodeForField.js +2 -1
- package/lib/simple-tree/getTreeNodeForField.js.map +1 -1
- package/lib/simple-tree/index.d.ts +1 -1
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +9 -6
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +15 -15
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +4 -5
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +2 -3
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +9 -5
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/treeFactory.js +7 -3
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/bTreeUtils.js +1 -1
- package/lib/util/bTreeUtils.js.map +1 -1
- package/lib/util/breakable.js +7 -9
- package/lib/util/breakable.js.map +1 -1
- package/lib/util/idAllocator.d.ts.map +1 -1
- package/lib/util/idAllocator.js +1 -2
- package/lib/util/idAllocator.js.map +1 -1
- package/lib/util/nestedMap.d.ts.map +1 -1
- package/lib/util/nestedMap.js +1 -1
- package/lib/util/nestedMap.js.map +1 -1
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +16 -15
- package/lib/util/utils.js.map +1 -1
- package/package.json +32 -32
- package/src/codec/codec.ts +48 -8
- package/src/codec/index.ts +4 -1
- package/src/codec/versioned/codec.ts +340 -22
- package/src/codec/versioned/index.ts +3 -1
- package/src/core/index.ts +2 -2
- package/src/core/rebase/changeRebaser.ts +40 -6
- package/src/core/rebase/index.ts +1 -1
- package/src/core/rebase/types.ts +6 -18
- package/src/core/rebase/utils.ts +3 -3
- package/src/core/schema-stored/schema.ts +3 -3
- package/src/core/tree/anchorSet.ts +3 -4
- package/src/core/tree/detachedFieldIndex.ts +13 -74
- package/src/core/tree/detachedFieldIndexCodecCommon.ts +4 -8
- package/src/core/tree/detachedFieldIndexCodecV1.ts +3 -7
- package/src/core/tree/detachedFieldIndexCodecV2.ts +5 -9
- package/src/core/tree/detachedFieldIndexCodecs.ts +21 -64
- package/src/core/tree/index.ts +1 -1
- package/src/core/tree/mapTree.ts +1 -1
- package/src/core/tree/sparseTree.ts +1 -0
- package/src/core/tree/treeTextFormat.ts +5 -9
- package/src/feature-libraries/changeAtomIdBTree.ts +24 -0
- package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +5 -5
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +7 -4
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +19 -11
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +3 -3
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +9 -5
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +1 -1
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +48 -17
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +12 -2
- package/src/feature-libraries/default-schema/mappedEditBuilder.ts +6 -0
- package/src/feature-libraries/flex-tree/lazyField.ts +13 -14
- package/src/feature-libraries/index.ts +10 -5
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +5 -5
- package/src/feature-libraries/mitigatedChangeFamily.ts +11 -6
- package/src/feature-libraries/modular-schema/comparison.ts +12 -9
- package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +70 -0
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +3 -6
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +5 -7
- package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +1 -1
- package/src/feature-libraries/modular-schema/index.ts +5 -2
- package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +703 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +89 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +39 -523
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +159 -125
- package/src/feature-libraries/modular-schema/{modularChangeFormat.ts → modularChangeFormatV1.ts} +4 -4
- package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +34 -0
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +13 -4
- package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +1 -1
- package/src/feature-libraries/object-forest/objectForest.ts +4 -4
- package/src/feature-libraries/optional-field/optionalField.ts +34 -46
- package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +18 -3
- package/src/feature-libraries/schema-index/codec.ts +30 -90
- package/src/feature-libraries/schema-index/index.ts +2 -4
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +0 -17
- package/src/feature-libraries/schemaChecker.ts +11 -6
- package/src/feature-libraries/sequence-field/compose.ts +17 -13
- package/src/feature-libraries/sequence-field/invert.ts +5 -4
- package/src/feature-libraries/sequence-field/moveEffectTable.ts +15 -9
- package/src/feature-libraries/sequence-field/rebase.ts +26 -18
- package/src/feature-libraries/sequence-field/replaceRevisions.ts +52 -56
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +16 -8
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +4 -2
- package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +6 -3
- package/src/feature-libraries/sequence-field/utils.ts +46 -27
- package/src/feature-libraries/treeCursorUtils.ts +7 -7
- package/src/feature-libraries/treeTextCursor.ts +2 -2
- package/src/feature-libraries/valueUtilities.ts +16 -8
- package/src/index.ts +4 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizingTreeView.ts +23 -13
- package/src/shared-tree/sharedTree.ts +30 -14
- package/src/shared-tree/sharedTreeChangeCodecs.ts +10 -9
- package/src/shared-tree/sharedTreeChangeEnricher.ts +4 -2
- package/src/shared-tree/sharedTreeChangeFamily.ts +29 -19
- package/src/shared-tree/sharedTreeEditBuilder.ts +9 -5
- package/src/shared-tree/treeAlpha.ts +60 -51
- package/src/shared-tree/treeCheckout.ts +66 -50
- package/src/shared-tree-core/branch.ts +8 -3
- package/src/shared-tree-core/branchCommitEnricher.ts +3 -8
- package/src/shared-tree-core/editManager.ts +1 -1
- package/src/shared-tree-core/editManagerCodecs.ts +9 -4
- package/src/shared-tree-core/editManagerFormatCommons.ts +6 -0
- package/src/shared-tree-core/editManagerFormatV1toV4.ts +3 -1
- package/src/shared-tree-core/editManagerSummarizer.ts +3 -3
- package/src/shared-tree-core/messageCodecV1ToV4.ts +2 -1
- package/src/shared-tree-core/messageCodecVSharedBranches.ts +2 -1
- package/src/shared-tree-core/messageCodecs.ts +8 -4
- package/src/shared-tree-core/messageFormat.ts +6 -1
- package/src/shared-tree-core/messageFormatV1ToV4.ts +16 -2
- package/src/shared-tree-core/sequenceIdUtils.ts +4 -4
- package/src/shared-tree-core/sharedTreeCore.ts +11 -7
- package/src/shared-tree-core/transaction.ts +115 -56
- package/src/shared-tree-core/transactionEnricher.ts +5 -6
- package/src/simple-tree/api/configuration.ts +1 -1
- package/src/simple-tree/api/customTree.ts +14 -10
- package/src/simple-tree/api/discrepancies.ts +23 -17
- package/src/simple-tree/api/index.ts +2 -0
- package/src/simple-tree/api/schemaFactory.ts +11 -7
- package/src/simple-tree/api/schemaFromSimple.ts +18 -9
- package/src/simple-tree/api/simpleSchemaCodec.ts +10 -5
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +17 -13
- package/src/simple-tree/api/simpleTreeIndex.ts +8 -8
- package/src/simple-tree/api/storedSchema.ts +10 -7
- package/src/simple-tree/api/transactionTypes.ts +19 -4
- package/src/simple-tree/api/treeNodeApi.ts +21 -13
- package/src/simple-tree/api/verboseTree.ts +14 -9
- package/src/simple-tree/core/treeNodeKernel.ts +6 -3
- package/src/simple-tree/core/unhydratedFlexTree.ts +22 -17
- package/src/simple-tree/getTreeNodeForField.ts +2 -1
- package/src/simple-tree/index.ts +2 -0
- package/src/simple-tree/leafNodeSchema.ts +8 -5
- package/src/simple-tree/node-kinds/array/arrayNode.ts +23 -23
- package/src/simple-tree/node-kinds/object/objectNode.ts +4 -5
- package/src/simple-tree/node-kinds/record/recordNode.ts +2 -3
- package/src/simple-tree/toStoredSchema.ts +9 -5
- package/src/treeFactory.ts +10 -5
- package/src/util/bTreeUtils.ts +1 -1
- package/src/util/breakable.ts +9 -9
- package/src/util/idAllocator.ts +1 -2
- package/src/util/nestedMap.ts +1 -3
- package/src/util/utils.ts +14 -13
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchorSet.js","sourceRoot":"","sources":["../../../src/core/tree/anchorSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;AAEH,6DAA6D;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAKN,oBAAoB,EACpB,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,WAAW,GACX,MAAM,qBAAqB,CAAC;AAK7B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACN,oBAAoB,GAMpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC;;GAEG;AACH,MAAM,WAAW,GAAW,KAAK,CAAC,CAAC,CAAC,CAAC;AA+MrC;;;;;;;;;;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,GAAG,KAAK,EAAE,CAAC;YAC1B,GAAG,GAAG,GAAG,CAAC,CAAC,iCAAiC;QAC7C,CAAC;aAAM,CAAC;YACP,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,gCAAgC;QAChD,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC,CAAC,qEAAqE;AACxF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { HasListeners, Listenable } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype Brand,\n\ttype BrandedKey,\n\ttype BrandedMapSubset,\n\ttype Opaque,\n\tReferenceCountedBase,\n\tbrand,\n\tbrandedSlot,\n\tgetOrAddEmptyToMap,\n\tgetOrCreate,\n} from \"../../util/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { ITreeCursorSynchronous } from \"./cursor.js\";\nimport type * as Delta from \"./delta.js\";\nimport { offsetDetachId } from \"./deltaUtil.js\";\nimport {\n\tisDetachedUpPathRoot,\n\ttype INormalizedUpPath,\n\ttype NormalizedUpPath,\n\ttype PlaceIndex,\n\ttype Range,\n\ttype UpPath,\n} from \"./pathTree.js\";\nimport { EmptyKey } from \"./types.js\";\nimport type { DeltaVisitor } from \"./visitDelta.js\";\n\n/**\n * A way to refer to a particular tree location within an {@link AnchorSet}.\n * Associated with a ref count on the underlying {@link AnchorNode}.\n */\nexport type Anchor = Brand<number, \"rebaser.Anchor\">;\n\n/**\n * A singleton which represents a permanently invalid location (i.e. there is never a node there)\n */\nconst NeverAnchor: Anchor = brand(0);\n\n/**\n * Maps anchors (which must be ones this locator knows about) to paths.\n */\nexport interface AnchorLocator {\n\t/**\n\t * Get the current location of an Anchor.\n\t * The returned value should not be used after an edit has occurred.\n\t *\n\t * TODO: support extra/custom return types for specific/custom anchor types:\n\t * for now caller must rely on data in anchor + returned node location\n\t * (not ideal for anchors for places or ranges instead of nodes).\n\t */\n\tlocate(anchor: Anchor): AnchorNode | undefined;\n}\n\n/**\n * Stores arbitrary, user-defined data on an {@link Anchor}.\n * This data is preserved over the course of that anchor's lifetime.\n * @see {@link anchorSlot} for creation and an example use case.\n */\nexport type AnchorSlot<TContent> = BrandedKey<Opaque<Brand<number, \"AnchorSlot\">>, TContent>;\n\n/**\n * Events for {@link AnchorNode}.\n * These events are triggered while the internal data structures are being updated.\n * Thus these events must not trigger reading of the anchorSet or forest.\n *\n * TODO:\n * - Include sub-deltas in events.\n * - Add more events.\n */\nexport interface AnchorEvents {\n\t/**\n\t * When the anchor node will never get reused by its AnchorSet.\n\t * This means that the content it corresponds to has been permanently destroyed.\n\t *\n\t * @remarks\n\t * When this happens depends entirely on how the anchorSet is used.\n\t * It's possible nodes removed from the tree will be kept indefinitely, and thus never trigger this event, or they may be discarded immediately.\n\t *\n\t * @privateRemarks\n\t * The specifics of the delta visit algorithm can impact the behavior of these events.\n\t * Refer to the privateRemarks of specific events and/or the documentation of the delta visit algorithm (as of\n\t * 2024-04-02, src/core/tree/visitDelta.ts) for more information.\n\t */\n\tafterDestroy(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if one or more of this node's\n\t * direct children are about to change due to updates from the batch.\n\t *\n\t * @remarks\n\t * Does not include edits of child subtrees: instead only includes changes to nodes which are direct children in this\n\t * node's fields.\n\t */\n\tchildrenChanging(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if one or more of this node's\n\t * direct children just changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * Does not include edits of child subtrees: instead only includes changes to nodes which are direct children in this\n\t * node's fields.\n\t *\n\t * Compare to {@link AnchorEvents.childrenChangedAfterBatch} which is emitted after the whole batch has been applied.\n\t */\n\tchildrenChanged(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted after a batch of changes has been applied (i.e. when a delta visit completes), if one or more of this node's\n\t * direct children changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * Does not include edits of child subtrees: instead only includes changes to nodes which are direct children in this\n\t * node's fields.\n\t *\n\t * This event is guaranteed to be emitted on a given node only once per batch.\n\t *\n\t * Compare to {@link AnchorEvents.childrenChanged} which is emitted in the middle of the batch/delta-visit.\n\t */\n\tchildrenChangedAfterBatch(arg: {\n\t\tchangedFields: ReadonlySet<FieldKey>;\n\t}): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if something in the subtree\n\t * rooted at `anchor` _may_ be about to change due to updates from the batch.\n\t *\n\t * @remarks\n\t * Called on every parent (transitively) when a change is occurring.\n\t */\n\tsubtreeChanging(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if something in the subtree\n\t * rooted at `anchor` _may_ have just changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * While this event is always emitted in the presence of changes to the subtree,\n\t * it may also be emitted even though no changes have been made to the subtree.\n\t * It may be emitted multiple times within the application of a single edit or transaction.\n\t *\n\t * If this event is emitted by a node, it will later be emitted by all its ancestors up to the root as well, at\n\t * least once on each ancestor.\n\t *\n\t * Compare to {@link AnchorEvents.subtreeChangedAfterBatch} which is emitted after the whole batch has been applied.\n\t *\n\t * @privateRemarks\n\t * The delta visit algorithm is complicated and it may fire this event multiple times for the same change to a node.\n\t * The change to the tree may not be visible until the event fires for the last time.\n\t * Refer to the documentation of the delta visit algorithm for more details.\n\t */\n\tsubtreeChanged(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted after a batch of changes has been applied (i.e. when a delta visit completes), if something in the subtree\n\t * rooted at `anchor` changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * If this event is emitted by a node, it will later be emitted by all its ancestors up to the root as well, from bottom to top.\n\t *\n\t * This event is guaranteed to be emitted on a given node only once per batch.\n\t *\n\t * Compare to {@link AnchorEvents.subtreeChanged} which is emitted in the middle of the batch/delta-visit.\n\t *\n\t * @privateRemarks\n\t * Note that because this is fired after the full batch of changes is applied, it guarantees that something in the\n\t * subtree changed, compared to {@link AnchorEvents.subtreeChanged} or {@link AnchorEvents.subtreeChanging} which\n\t * fire when something _may_ have changed or _may_ be about to change.\n\t */\n\tsubtreeChangedAfterBatch(): void;\n}\n\n/**\n * Events for {@link AnchorSet}.\n * These events are triggered while the internal data structures are being updated.\n * Thus these events must not trigger reading of the anchorSet or forest.\n *\n * TODO:\n * - Design how events should be ordered.\n * - Include sub-deltas in events.\n * - Add more events.\n */\nexport interface AnchorSetRootEvents {\n\t/**\n\t * What children are at the root is changing.\n\t */\n\tchildrenChanging(anchors: AnchorSet): void;\n\n\t/**\n\t * Something in the tree is changing.\n\t */\n\ttreeChanging(anchors: AnchorSet): void;\n}\n\n/**\n * Node in a tree of anchors.\n */\nexport interface AnchorNode extends INormalizedUpPath<AnchorNode> {\n\t/**\n\t * Events for this anchor node.\n\t */\n\treadonly events: Listenable<AnchorEvents> & HasListeners<AnchorEvents>;\n\n\t/**\n\t * Allows access to data stored on the Anchor in \"slots\".\n\t * Use {@link anchorSlot} to create slots.\n\t */\n\t// See note on BrandedKey\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\treadonly slots: BrandedMapSubset<AnchorSlot<any>>;\n\n\t/**\n\t * The set this anchor node is part of.\n\t */\n\treadonly anchorSet: AnchorSet;\n\n\t/**\n\t * Gets a child of this node.\n\t *\n\t * @remarks\n\t * This does not return an AnchorNode since there might not be one, and lazily creating one here would have messy lifetime management (See {@link AnchorNode#getOrCreateChildRef})\n\t * If an AnchorNode is required, use the AnchorSet to track then locate the returned path.\n\t * TODO:\n\t * Revisit this API.\n\t * Perhaps if we use weak down pointers and remove ref counting, we can make this return a AnchorNode.\n\t *\n\t */\n\tchild(key: FieldKey, index: number): UpPath<AnchorNode>;\n\n\t/**\n\t * Gets the child AnchorNode if already exists.\n\t *\n\t * Does NOT add a ref, so the returned AnchorNode must be used with care.\n\t */\n\tchildIfAnchored(key: FieldKey, index: number): AnchorNode | undefined;\n\n\t/**\n\t * Gets a child AnchorNode (creating it if needed), and an Anchor owning a ref to it.\n\t * Caller is responsible for freeing the returned Anchor, and must not use the AnchorNode after that.\n\t */\n\tgetOrCreateChildRef(key: FieldKey, index: number): [Anchor, AnchorNode];\n}\n\n/**\n * Define a strongly typed slot on anchors in which data can be stored.\n *\n * @remarks\n * This is mainly useful for caching data associated with a location in the tree.\n *\n * Example usage:\n * ```typescript\n * const counterSlot = anchorSlot<number>();\n *\n * function useSlot(anchor: AnchorNode): void {\n * \tanchor.slots.set(counterSlot, 1 + anchor.slots.get(counterSlot) ?? 0);\n * }\n * ```\n */\nexport function anchorSlot<TContent>(): AnchorSlot<TContent> {\n\treturn brandedSlot<AnchorSlot<TContent>>();\n}\n\n/**\n * Collection of Anchors at a specific revision.\n *\n * See `Rebaser` for how to update across revisions.\n *\n * TODO: this should not be package exported.\n * If it's needed outside the package an Interface should be used instead which can reduce its\n * API surface to a small subset.\n *\n * @sealed\n */\nexport class AnchorSet implements AnchorLocator {\n\treadonly #events = createEmitter<AnchorSetRootEvents>();\n\tpublic readonly events: Listenable<AnchorSetRootEvents> = this.#events;\n\n\t/**\n\t * Incrementing counter to give each anchor in this set a unique index for its identifier.\n\t * \"0\" is reserved for the `NeverAnchor`.\n\t */\n\tprivate anchorCounter = 1;\n\n\t/**\n\t * Incrementing number that is bumped each time that the {@link AnchorSet} is changed.\n\t * This allows consumers to cache state associated with a particular generation number and later determine if that state may have been invalidated using a comparison with the current generation number.\n\t * For example, anchor slots can be used to cache the removal status of a node to memoize repeated walks up the tree.\n\t */\n\tpublic generationNumber = 0;\n\n\t/**\n\t * Special root node under which all anchors in this anchor set are transitively parented.\n\t * This does not appear in the UpPaths (instead they use undefined for the root).\n\t * Immediate children of this root are in detached fields (which have their identifiers used as the field keys).\n\t *\n\t * This is allocated with refCount one, which is never freed so it is never cleaned up\n\t * (as long as this AnchorSet is not garbage collected).\n\t *\n\t * There should never be any children other than the special root detached field under this between transactions:\n\t * TODO: check for and enforce this.\n\t */\n\tprivate readonly root = new PathNode(this, EmptyKey, 0, undefined);\n\n\t// TODO: anchor system could be optimized a bit to avoid the maps (Anchor is ref to Path, path has ref count).\n\t// For now use this more encapsulated approach with maps.\n\tprivate readonly anchorToPath: Map<Anchor, PathNode> = new Map();\n\n\tprivate activeVisitor?: DeltaVisitor;\n\n\tpublic constructor() {\n\t\tthis.events.on(\"treeChanging\", () => {\n\t\t\tthis.generationNumber += 1;\n\t\t});\n\t}\n\n\t/**\n\t * Allows access to data stored on the AnchorSet in \"slots\".\n\t * Use {@link anchorSlot} to create slots.\n\t *\n\t * @privateRemarks\n\t * This forwards to the slots of the special above root anchor which locate can't access.\n\t */\n\t// See note on BrandedKey.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic get slots(): BrandedMapSubset<AnchorSlot<any>> {\n\t\treturn this.root.slots;\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<AnchorNode> {\n\t\tconst stack: PathNode[] = [];\n\t\tlet node: PathNode | undefined = this.root;\n\t\twhile (node !== undefined) {\n\t\t\tyield node;\n\t\t\tfor (const [_, children] of node.children) {\n\t\t\t\tfor (const child of children) {\n\t\t\t\t\tstack.push(child);\n\t\t\t\t}\n\t\t\t}\n\t\t\tnode = stack.pop();\n\t\t}\n\t}\n\n\t/**\n\t * Check if there are currently no anchors tracked.\n\t * Mainly for testing anchor cleanup.\n\t */\n\tpublic isEmpty(): boolean {\n\t\treturn this.root.children.size === 0;\n\t}\n\n\tpublic locate(anchor: Anchor): AnchorNode | undefined {\n\t\tif (anchor === NeverAnchor) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst path = this.anchorToPath.get(anchor);\n\t\tassert(\n\t\t\tpath !== undefined,\n\t\t\t0x3a6 /* Cannot locate anchor which is not in this AnchorSet */,\n\t\t);\n\t\treturn path.status === Status.Alive ? path : undefined;\n\t}\n\n\tpublic forget(anchor: Anchor): void {\n\t\tif (anchor !== NeverAnchor) {\n\t\t\tconst path = this.anchorToPath.get(anchor);\n\t\t\tassert(path !== undefined, 0x351 /* cannot forget unknown Anchor */);\n\t\t\tpath.removeRef();\n\t\t\tthis.anchorToPath.delete(anchor);\n\t\t}\n\t}\n\n\t/**\n\t * TODO: Add APIs need to allow callers of this function to reduce copying here.\n\t * Ex: maybe return something extending UpPath here.\n\t * @param path - the path to the node to be tracked. If null, returns an anchor\n\t * which is permanently invalid.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic track(path: UpPath | null): Anchor {\n\t\tif (path === null) {\n\t\t\treturn NeverAnchor;\n\t\t}\n\n\t\tconst foundPath = this.trackInner(path);\n\t\tconst anchor: Anchor = brand(this.anchorCounter++);\n\t\tthis.anchorToPath.set(anchor, foundPath);\n\t\treturn anchor;\n\t}\n\n\t/**\n\t * Finds a path node, creating if needed, and adds a ref count to it.\n\t */\n\tprivate trackInner(path: UpPath): PathNode {\n\t\tif (path instanceof PathNode && path.anchorSet === this) {\n\t\t\tpath.addRef();\n\t\t\treturn path;\n\t\t}\n\t\tconst parent = path.parent ?? this.root;\n\t\tconst parentPath = this.trackInner(parent);\n\n\t\tconst child = parentPath.getOrCreateChild(path.parentField, path.parentIndex);\n\n\t\t// Now that child is added (if needed), remove the extra ref that we added in the recursive call.\n\t\tparentPath.removeRef();\n\n\t\treturn child;\n\t}\n\n\t/**\n\t * Finds a path node if it already exists.\n\t *\n\t * Does not add a ref!\n\t */\n\tpublic find(path: UpPath): PathNode | undefined {\n\t\tif (path instanceof PathNode) {\n\t\t\tif (path.anchorSet === this) {\n\t\t\t\treturn path;\n\t\t\t}\n\t\t}\n\t\tconst parent = path.parent ?? this.root;\n\t\tconst parentPath = this.find(parent);\n\t\treturn parentPath?.childIfAnchored(path.parentField, path.parentIndex);\n\t}\n\n\t/**\n\t * Returns an equivalent path making as much of it with PathNodes as possible.\n\t * This allows future operations (like find, track, locate) on this path (and derived ones) to be faster.\n\t * Note that the returned path may use AnchorNodes from this AnchorSet,\n\t * but does not have a tracked reference to them, so this should not be held onto across anything that might free an AnchorNode.\n\t *\n\t * @remarks\n\t * Also ensures that any PathNode in the path is from this AnchorSet.\n\t */\n\tpublic internalizePath(originalPath: UpPath): UpPath {\n\t\tlet path: UpPath | undefined = originalPath;\n\t\tconst stack: UpPath[] = [];\n\t\twhile (path !== undefined) {\n\t\t\tif (path instanceof PathNode && path.anchorSet === this) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tstack.push(path);\n\t\t\tpath = path.parent;\n\t\t}\n\n\t\t// Now `path` contains an internalized path.\n\t\t// It just needs the paths from stackOut to wrap it.\n\n\t\tlet wrapWith: UpPath | undefined;\n\t\twhile ((wrapWith = stack.pop()) !== undefined) {\n\t\t\tif (path === undefined || path instanceof PathNode) {\n\t\t\t\t// If path already has an anchor, get an anchor for it's child if there is one:\n\t\t\t\tconst child = (path ?? this.root).childIfAnchored(\n\t\t\t\t\twrapWith.parentField,\n\t\t\t\t\twrapWith.parentIndex,\n\t\t\t\t);\n\t\t\t\tif (child !== undefined) {\n\t\t\t\t\tpath = child;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Replacing this if with a ternary makes the documentation harder to include and hurts readability.\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (path === wrapWith.parent && !(wrapWith instanceof PathNode)) {\n\t\t\t\t// path is safe to reuse from input path, so use it to avoid allocating another object.\n\t\t\t\tpath = wrapWith;\n\t\t\t} else {\n\t\t\t\tpath = {\n\t\t\t\t\tparent: path,\n\t\t\t\t\tparentField: wrapWith.parentField,\n\t\t\t\t\tparentIndex: wrapWith.parentIndex,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn path ?? fail(0xaea /* internalize path must be a path */);\n\t}\n\n\t/**\n\t * Recursively marks the given `nodes` and their descendants as disposed and pointing to a deleted node.\n\t * Note that this does NOT detach the nodes.\n\t */\n\tprivate deepDelete(nodes: readonly PathNode[]): void {\n\t\tconst stack = [...nodes];\n\t\twhile (stack.length > 0) {\n\t\t\tconst node = stack.pop()!;\n\t\t\tassert(node.status === Status.Alive, 0x408 /* PathNode must be alive */);\n\t\t\tnode.status = Status.Dangling;\n\t\t\tnode.events.emit(\"afterDestroy\", node);\n\t\t\tfor (const children of node.children.values()) {\n\t\t\t\tstack.push(...children);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Decouple nodes from their parent.\n\t * This removes the reference from the parent to the decoupled children, and updates the indexes of the remaining children accordingly.\n\t * This does NOT update the decoupled children: both their index and parent are left at their existing values.\n\t * To decouple and fixup the children, see `removeChildren` and `moveChildren`.\n\t * @param startPath - The path to the first node that is being decoupled.\n\t * @param count - number of siblings that are decoupled from the original tree.\n\t *\n\t * TODO: tests\n\t */\n\tprivate decoupleNodes(startPath: UpPath, count: number): PathNode[] {\n\t\tassert(count > 0, 0x681 /* count must be positive */);\n\n\t\tconst sourceParent = this.find(startPath.parent ?? this.root);\n\t\tconst sourceChildren = sourceParent?.children?.get(startPath.parentField);\n\t\tlet nodes: PathNode[] = [];\n\n\t\tif (sourceChildren !== undefined) {\n\t\t\tlet numberBeforeDecouple = 0;\n\t\t\tlet numberToDecouple = 0;\n\t\t\tlet index = 0;\n\t\t\twhile (\n\t\t\t\tindex < sourceChildren.length &&\n\t\t\t\tsourceChildren[index]!.parentIndex < startPath.parentIndex\n\t\t\t) {\n\t\t\t\tnumberBeforeDecouple++;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\twhile (\n\t\t\t\tindex < sourceChildren.length &&\n\t\t\t\tsourceChildren[index]!.parentIndex < startPath.parentIndex + count\n\t\t\t) {\n\t\t\t\tnumberToDecouple++;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\twhile (index < sourceChildren.length) {\n\t\t\t\t// Fix indexes in source after moved items (subtract count).\n\t\t\t\tsourceChildren[index]!.parentIndex -= count;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\t// Sever the parent -> child connections\n\t\t\tnodes = sourceChildren.splice(numberBeforeDecouple, numberToDecouple);\n\t\t\tif (sourceChildren.length === 0) {\n\t\t\t\tsourceParent!.afterEmptyField(startPath.parentField);\n\t\t\t}\n\t\t}\n\n\t\treturn nodes;\n\t}\n\n\t/**\n\t * Couple nodes to a parent.\n\t * @param destination - where the siblings are coupled to.\n\t * @param count - number of siblings that are coupled in the original tree.\n\t * @param coupleInfo - this object contains the nodes to couple and the parent index of the first node that is coupled in the original tree.\n\t *\n\t * TODO: tests\n\t */\n\tprivate coupleNodes(\n\t\tdestination: UpPath,\n\t\tcount: number,\n\t\tcoupleInfo: { startParentIndex: number; nodes: PathNode[] },\n\t): void {\n\t\tassert(coupleInfo.nodes.length > 0, 0x682 /* coupleInfo must have nodes to couple */);\n\n\t\t// The destination needs to be created if it does not exist yet.\n\t\tconst destinationPath = this.trackInner(destination.parent ?? this.root);\n\n\t\t// Update nodes for new parent.\n\t\tfor (const node of coupleInfo.nodes) {\n\t\t\tnode.parentIndex += destination.parentIndex - coupleInfo.startParentIndex;\n\t\t\tnode.parentPath = destinationPath;\n\t\t\tnode.parentField = destination.parentField;\n\t\t\t// If the destination is a detached root, propagate its detachedNodeId, otherwise remove any existing one\n\t\t\tnode.detachedNodeId = isDetachedUpPathRoot(destination)\n\t\t\t\t? offsetDetachId(\n\t\t\t\t\t\tdestination.detachedNodeId,\n\t\t\t\t\t\tnode.parentIndex - destination.parentIndex,\n\t\t\t\t\t)\n\t\t\t\t: undefined;\n\t\t}\n\n\t\t// Update new parent to add children\n\t\tconst field = destinationPath.children.get(destination.parentField);\n\t\tif (field === undefined) {\n\t\t\tdestinationPath.children.set(destination.parentField, coupleInfo.nodes);\n\t\t} else {\n\t\t\t// Update existing field contents\n\t\t\tconst numberBeforeCouple = this.increaseParentIndexes(\n\t\t\t\tfield,\n\t\t\t\tdestination.parentIndex,\n\t\t\t\tcount,\n\t\t\t);\n\n\t\t\t// TODO: this will fail for very large numbers of anchors due to argument limits.\n\t\t\tfield.splice(numberBeforeCouple, 0, ...coupleInfo.nodes);\n\t\t}\n\n\t\tdestinationPath.removeRef();\n\t}\n\n\t/**\n\t * Updates the parent indexes within `field` to account for `count` children being inserted at `fromParentIndex`. Note that\n\t * `fromParentIndex` is the logical position within the field, not the index with the sparse PathNode array.\n\t *\n\t * @param field - the field to update.\n\t * @param fromParentIndex - the logical index within the field to start updating from.\n\t * @param count - the number to increase parent indexes.\n\t * @returns the number of items in the field that are not increased.\n\t *\n\t * TODO: tests\n\t */\n\tprivate increaseParentIndexes(\n\t\tfield: PathNode[],\n\t\tfromParentIndex: number,\n\t\tcount: number,\n\t): number {\n\t\tlet index = 0;\n\t\twhile (index < field.length && field[index]!.parentIndex < fromParentIndex) {\n\t\t\tindex++;\n\t\t}\n\t\tconst numberBeforeIncrease = index;\n\t\twhile (index < field.length) {\n\t\t\tfield[index]!.parentIndex += count;\n\t\t\tindex++;\n\t\t}\n\n\t\treturn numberBeforeIncrease;\n\t}\n\n\t/**\n\t * Updates paths for a range move (including re-parenting path items and updating indexes).\n\t * @param sourceStart - where the siblings are removed from.\n\t * @param destination - where the siblings are moved to.\n\t * @param count - number of siblings to move.\n\t *\n\t * TODO:\n\t * How should anchors that become invalid, then valid again (ex: into content that was deleted, then undone) work?\n\t * Add an API to resurrect them? Store them in special detached fields? Store them in special non-detached fields?\n\t *\n\t * TODO:\n\t * How should custom anchors work (ex: ones not just tied to a specific Node)?\n\t * This design assumes they can be expressed in terms of a Node anchor + some extra stuff,\n\t * but we don't have an API for the extra stuff yet.\n\t *\n\t * TODO: tests\n\t */\n\tprivate moveChildren(sourceStart: UpPath, destination: UpPath, count: number): void {\n\t\tconst nodes = this.decoupleNodes(sourceStart, count);\n\t\tif (nodes.length > 0) {\n\t\t\tthis.coupleNodes(destination, count, {\n\t\t\t\tstartParentIndex: sourceStart.parentIndex,\n\t\t\t\tnodes,\n\t\t\t});\n\t\t} else {\n\t\t\t// If there are no nodes to move, we still need to update the parent indexes of the nodes\n\t\t\t// affected in the move in.\n\t\t\tthis.offsetChildren(destination, count);\n\t\t}\n\t}\n\n\tprivate removeChildren(path: UpPath, count: number): void {\n\t\tconst nodes = this.decoupleNodes(path, count);\n\t\tthis.deepDelete(nodes);\n\t}\n\n\t/**\n\t * Updates the parent indexes of all the nodes located at right side of the given path by the given offset.\n\t * @param firstSiblingToOffset - the path to offset children of.\n\t * @param offset - the offset to apply to the children.\n\t *\n\t */\n\tprivate offsetChildren(firstSiblingToOffset: UpPath, offset: number): void {\n\t\tconst nodePath = this.find(firstSiblingToOffset.parent ?? this.root);\n\t\tconst field = nodePath?.children.get(firstSiblingToOffset.parentField);\n\t\tif (field !== undefined) {\n\t\t\tthis.increaseParentIndexes(field, firstSiblingToOffset.parentIndex, offset);\n\t\t}\n\t}\n\n\t/**\n\t * Provides a visitor that can be used to mutate this {@link AnchorSet}.\n\t *\n\t * @returns A visitor that can be used to mutate this {@link AnchorSet}.\n\t *\n\t * @remarks\n\t * Mutating the {@link AnchorSet} does NOT update the forest.\n\t * The visitor must be released after use by calling {@link DeltaVisitor.free} on it.\n\t * It is invalid to acquire a visitor without releasing the previous one,\n\t * and this method will throw an error if this is attempted.\n\t */\n\tpublic acquireVisitor(): DeltaVisitor {\n\t\tassert(\n\t\t\tthis.activeVisitor === undefined,\n\t\t\t0x767 /* Must release existing visitor before acquiring another */,\n\t\t);\n\n\t\tconst referencedPathNodes: PathNode[] = [];\n\t\tconst visitor = {\n\t\t\tanchorSet: this,\n\t\t\t// Run `withNode` on anchorNode for parent if there is such an anchorNode.\n\t\t\t// If at root, run `withRoot` instead.\n\t\t\tmaybeWithNode(withNode: (anchorNode: PathNode) => void, withRoot?: () => void) {\n\t\t\t\tif (this.parent === undefined && withRoot !== undefined) {\n\t\t\t\t\twithRoot();\n\t\t\t\t} else {\n\t\t\t\t\tassert(this.parent !== undefined, 0x5b0 /* parent must exist */);\n\t\t\t\t\t// TODO:Perf:\n\t\t\t\t\t// When traversing to a depth D when there are not anchors in that subtree, this goes O(D^2).\n\t\t\t\t\t// Delta traversal should early out in this case because no work is needed (and all move outs are known to not contain anchors).\n\t\t\t\t\tthis.parent = this.anchorSet.internalizePath(this.parent);\n\t\t\t\t\tif (this.parent instanceof PathNode) {\n\t\t\t\t\t\tthis.parent.addRef();\n\t\t\t\t\t\treferencedPathNodes.push(this.parent);\n\t\t\t\t\t\twithNode(this.parent);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tparentField: undefined as FieldKey | undefined,\n\t\t\tparent: undefined as UpPath | undefined,\n\n\t\t\t/**\n\t\t\t * Events collected during the visit which get sent as a batch during \"free\".\n\t\t\t */\n\t\t\tbufferedEvents: [] as BufferedEvent[],\n\n\t\t\t/**\n\t\t\t * 'currentDepth' and 'depthThresholdForSubtreeChanged' serve to keep track of when do we need to emit\n\t\t\t * subtreeChangedAfterBatch events.\n\t\t\t * The algorithm works as follows:\n\t\t\t *\n\t\t\t * - Initialize both to 0.\n\t\t\t * - As we walk the tree from the root towards the leaves, when we enter a node increment currentDepth by 1.\n\t\t\t * - When we edit a node, set depthThresholdForSubtreeChanged = currentDepth.\n\t\t\t * Intuitively, depthThresholdForSubtreeChanged means \"as you walk the tree towards the root, when you exit a\n\t\t\t * node at this depth you should emit a subtreeChangedAfterBatch event\".\n\t\t\t * - When we exit a node, if d === currentDepth then emit a subtreeChangedAfterBatch and decrement d by 1.\n\t\t\t * Then decrement currentDepth unconditionally.\n\t\t\t *\n\t\t\t * Note that the event will be emitted when exiting a node that was edited (depthThresholdForSubtreeChanged will\n\t\t\t * have been set to the current depth when the edit happened), it will be emitted when exiting a node that is the\n\t\t\t * parent of a node that already emitted the event (because both depthThresholdForSubtreeChanged and currentDepth\n\t\t\t * get decremented when exiting a node so they stay in sync), and if we're already emitting the event but start\n\t\t\t * walking the tree back towards the leaves in a path where no edits happen, currentDepth will be increased again\n\t\t\t * as we walk that path, depthThresholdForSubtreeChanged will not, and thus no event will be emitted when walking\n\t\t\t * back up that path, until we get back to the depth where we were already emitting the event, and will continue\n\t\t\t * emitting it on the way to the root.\n\t\t\t */\n\t\t\tcurrentDepth: 0,\n\t\t\t/**\n\t\t\t * See {@link visitor.currentDepth}.\n\t\t\t */\n\t\t\tdepthThresholdForSubtreeChanged: 0,\n\n\t\t\tfree() {\n\t\t\t\tassert(\n\t\t\t\t\tthis.anchorSet.activeVisitor !== undefined,\n\t\t\t\t\t0x768 /* Multiple free calls for same visitor */,\n\t\t\t\t);\n\t\t\t\tfor (const node of referencedPathNodes) {\n\t\t\t\t\tnode.removeRef();\n\t\t\t\t}\n\t\t\t\tthis.anchorSet.activeVisitor = undefined;\n\n\t\t\t\t// Aggregate changedFields by node.\n\t\t\t\tconst eventsByNode: Map<PathNode, Set<FieldKey>> = new Map();\n\t\t\t\tfor (const { node, event, changedField } of this.bufferedEvents) {\n\t\t\t\t\tif (event === \"childrenChangedAfterBatch\") {\n\t\t\t\t\t\tconst keys = getOrCreate(eventsByNode, node, () => new Set());\n\t\t\t\t\t\tkeys.add(\n\t\t\t\t\t\t\tchangedField ??\n\t\t\t\t\t\t\t\tfail(0xb57 /* childrenChangedAfterBatch events should have a changedField */),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst alreadyEmitted = new Map<PathNode, (keyof AnchorEvents)[]>();\n\t\t\t\tfor (const { node, event } of this.bufferedEvents) {\n\t\t\t\t\tconst emittedEvents = getOrAddEmptyToMap(alreadyEmitted, node);\n\t\t\t\t\tif (emittedEvents.includes(event)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\temittedEvents.push(event);\n\t\t\t\t\tif (event === \"childrenChangedAfterBatch\") {\n\t\t\t\t\t\tconst changedFields =\n\t\t\t\t\t\t\teventsByNode.get(node) ??\n\t\t\t\t\t\t\tfail(0xaeb /* childrenChangedAfterBatch events should have changedFields */);\n\t\t\t\t\t\tnode.events.emit(event, { changedFields });\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode.events.emit(event);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tnotifyChildrenChanging(): void {\n\t\t\t\tthis.maybeWithNode(\n\t\t\t\t\t(p) => p.events.emit(\"childrenChanging\", p),\n\t\t\t\t\t() => this.anchorSet.#events.emit(\"childrenChanging\", this.anchorSet),\n\t\t\t\t);\n\t\t\t},\n\t\t\tnotifyChildrenChanged(): void {\n\t\t\t\tthis.maybeWithNode(\n\t\t\t\t\t(p) => {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t\t\t0xa24 /* Must be in a field to modify its contents */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tp.events.emit(\"childrenChanged\", p);\n\t\t\t\t\t\tthis.bufferedEvents.push({\n\t\t\t\t\t\t\tnode: p,\n\t\t\t\t\t\t\tevent: \"childrenChangedAfterBatch\",\n\t\t\t\t\t\t\tchangedField: this.parentField,\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\t() => {},\n\t\t\t\t);\n\t\t\t},\n\t\t\tattach(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.attachEdit(source, count, destination);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tattachEdit(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a2 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath = {\n\t\t\t\t\tparent: this.anchorSet.root,\n\t\t\t\t\tparentField: source,\n\t\t\t\t\tparentIndex: 0,\n\t\t\t\t};\n\t\t\t\tconst destinationPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tparentField: this.parentField,\n\t\t\t\t\tparentIndex: destination,\n\t\t\t\t};\n\t\t\t\tthis.anchorSet.moveChildren(sourcePath, destinationPath, count);\n\t\t\t\tthis.depthThresholdForSubtreeChanged = this.currentDepth;\n\t\t\t},\n\t\t\tdetach(\n\t\t\t\tsource: Range,\n\t\t\t\tdestination: FieldKey,\n\t\t\t\tdetachedNodeId: Delta.DetachedNodeId,\n\t\t\t): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.detachEdit(source, destination, detachedNodeId);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tdetachEdit(\n\t\t\t\tsource: Range,\n\t\t\t\tdestination: FieldKey,\n\t\t\t\tdetachedNodeId: Delta.DetachedNodeId,\n\t\t\t): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a5 /* Must be in a field in order to detach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: UpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tparentField: this.parentField,\n\t\t\t\t\tparentIndex: source.start,\n\t\t\t\t};\n\t\t\t\tconst destinationPath: NormalizedUpPath = {\n\t\t\t\t\tparent: this.anchorSet.root,\n\t\t\t\t\tparentField: destination,\n\t\t\t\t\tparentIndex: 0,\n\t\t\t\t\tdetachedNodeId,\n\t\t\t\t};\n\t\t\t\tthis.anchorSet.moveChildren(sourcePath, destinationPath, source.end - source.start);\n\t\t\t\tthis.depthThresholdForSubtreeChanged = this.currentDepth;\n\t\t\t},\n\t\t\treplace(\n\t\t\t\tnewContentSource: FieldKey,\n\t\t\t\trange: Range,\n\t\t\t\toldContentDestination: FieldKey,\n\t\t\t\tdestinationDetachedNodeId: Delta.DetachedNodeId,\n\t\t\t): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.detachEdit(range, oldContentDestination, destinationDetachedNodeId);\n\t\t\t\tthis.attachEdit(newContentSource, range.end - range.start, range.start);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tdestroy(detachedField: FieldKey, count: number): void {\n\t\t\t\tthis.anchorSet.removeChildren(\n\t\t\t\t\t{\n\t\t\t\t\t\tparent: undefined,\n\t\t\t\t\t\tparentField: detachedField,\n\t\t\t\t\t\tparentIndex: 0,\n\t\t\t\t\t},\n\t\t\t\t\tcount,\n\t\t\t\t);\n\t\t\t},\n\t\t\tcreate(content: ITreeCursorSynchronous[], destination: FieldKey): void {\n\t\t\t\t// Nothing to do since content can only be created in a new detached field,\n\t\t\t\t// which cannot contain any anchors.\n\t\t\t},\n\t\t\tenterNode(index: number): void {\n\t\t\t\tassert(this.parentField !== undefined, 0x3ab /* Must be in a field to enter node */);\n\n\t\t\t\tthis.parent = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tparentField: this.parentField,\n\t\t\t\t\tparentIndex: index,\n\t\t\t\t};\n\t\t\t\tthis.parentField = undefined;\n\t\t\t\tthis.maybeWithNode((p) => {\n\t\t\t\t\tp.events.emit(\"subtreeChanging\", p);\n\t\t\t\t});\n\t\t\t\tthis.currentDepth++;\n\t\t\t},\n\t\t\texitNode(index: number): void {\n\t\t\t\tassert(this.parent !== undefined, 0x3ac /* Must have parent node */);\n\t\t\t\tif (this.depthThresholdForSubtreeChanged === this.currentDepth) {\n\t\t\t\t\tthis.maybeWithNode((p) => {\n\t\t\t\t\t\tp.events.emit(\"subtreeChanged\", p);\n\n\t\t\t\t\t\tthis.bufferedEvents.push({\n\t\t\t\t\t\t\tnode: p,\n\t\t\t\t\t\t\tevent: \"subtreeChangedAfterBatch\",\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t\tthis.depthThresholdForSubtreeChanged--;\n\t\t\t\t}\n\t\t\t\tconst parent = this.parent;\n\t\t\t\tthis.parentField = parent.parentField;\n\t\t\t\tthis.parent = parent.parent;\n\t\t\t\tthis.currentDepth--;\n\t\t\t},\n\t\t\tenterField(key: FieldKey): void {\n\t\t\t\tthis.parentField = key;\n\t\t\t},\n\t\t\texitField(key: FieldKey): void {\n\t\t\t\tthis.parentField = undefined;\n\t\t\t},\n\t\t};\n\t\tthis.#events.emit(\"treeChanging\", this);\n\t\tthis.activeVisitor = visitor;\n\t\treturn visitor;\n\t}\n}\n\n/**\n * Indicates the status of a `NodePath`.\n */\nenum Status {\n\t/**\n\t * Indicates the `NodePath` is being maintained and corresponds to a valid\n\t * (i.e., not removed) node in the document.\n\t */\n\tAlive,\n\t/**\n\t * Indicates the `NodePath` is not being maintained by the `AnchorSet`.\n\t * The `NodePath` may or may not correspond to a valid node in the document.\n\t *\n\t * Accessing such a node is invalid.\n\t * Nodes in this state are retained to detect use-after-free bugs.\n\t */\n\tDisposed,\n\t/**\n\t * Indicates the `NodePath` corresponds to a removed node in the document.\n\t * Such `NodePath`s are not maintained by the `AnchorSet` (other than updating\n\t * their status to `Disposed` when appropriate).\n\t *\n\t * Accessing such a node is invalid.\n\t * Nodes in this state are retained to detect use-after-free bugs.\n\t */\n\tDangling,\n}\n\n/**\n * Tree of anchors.\n *\n * Contains both child and parent pointers, which are kept in sync.\n *\n * Each anchor is equivalent to a path through the tree.\n * This tree structure stores a collection of these paths, but deduplicating the common prefixes of the tree\n * prefix-tree style.\n *\n * These anchors are used instead of just holding onto the node objects in forests for several reasons:\n *\n * - Update policy might be more complex than just tracking a node object in the forest.\n *\n * - Not all forests will have node objects: some may use compressed binary formats with no objects to reference.\n *\n * - Anchors are needed even when not using forests, and for nodes that are outside the currently loaded part of the\n * forest.\n *\n * - Forest in general do not need to support up pointers, but they are needed for anchors.\n *\n * Thus this can be thought of as a sparse copy of the subset of trees which are used as anchors,\n * plus the parent paths for them.\n *\n * ReferenceCountedBase tracks the number of references to this from external sources (`Anchors` via `AnchorSet`.).\n * Kept alive as if any of the follow are true:\n * 1. there are children.\n * 2. refcount is non-zero.\n * 3. events are registered.\n */\nclass PathNode extends ReferenceCountedBase implements AnchorNode {\n\tpublic status: Status = Status.Alive;\n\t/**\n\t * Event emitter for this anchor.\n\t */\n\tpublic readonly events = createEmitter<AnchorEvents>(() => this.considerDispose());\n\n\t/**\n\t * PathNode arrays are kept sorted the PathNode's parentIndex for efficient search.\n\t * Users of this field must take care to maintain invariants (correct parent pointers, not empty child arrays etc.)\n\t *\n\t * Performance Note:\n\t * Large child lists could be updated more efficiently here using a data-structure optimized\n\t * for efficient prefix sum updates, such as a Fenwick tree or Finger tree.\n\t * This would be complicated by the need for parent pointers (including indexes),\n\t * but is possible to do.\n\t */\n\tpublic readonly children: Map<FieldKey, PathNode[]> = new Map();\n\n\t// See note on BrandedKey.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic readonly slots: BrandedMapSubset<AnchorSlot<any>> = new Map();\n\n\t/**\n\t * {@inheritdoc UpPath.detachedNodeId}\n\t */\n\tpublic detachedNodeId: Delta.DetachedNodeId | undefined;\n\n\t/**\n\t * Construct a PathNode with refcount 1.\n\t * @param anchorSet - used to determine if this PathNode is already part of a specific anchorSet\n\t * to early out UpPath walking.\n\t */\n\tpublic constructor(\n\t\tpublic readonly anchorSet: AnchorSet,\n\t\tpublic parentField: FieldKey,\n\t\tpublic parentIndex: number,\n\t\t/**\n\t\t * The parent of this `PathNode` (an up pointer in the `PathNode` tree).\n\t\t * If the status of this node is `Alive`, then there must be a corresponding down pointer from the\n\t\t * `parentPath` node to this node.\n\t\t * When undefined, this node is the {@link AnchorSet.root} for `this.anchorSet` and thus has no parent.\n\t\t *\n\t\t * When updating the tree, `AnchorSet` may transiently leave the up and down pointers inconsistent\n\t\t * (updating down pointers first), but must ensure they are consistent before the editing operation returns\n\t\t * to non-`AnchorSet` code.\n\t\t * This consistency guarantee only applies to nodes that are `Alive`.\n\t\t */\n\t\tpublic parentPath: PathNode | undefined,\n\t) {\n\t\tsuper(1);\n\t}\n\n\tpublic child(key: FieldKey, index: number): UpPath<AnchorNode> {\n\t\t// Fast path: if child exists, return it.\n\t\treturn (\n\t\t\tthis.childIfAnchored(key, index) ?? {\n\t\t\t\tparent: this,\n\t\t\t\tparentField: key,\n\t\t\t\tparentIndex: index,\n\t\t\t}\n\t\t);\n\t}\n\n\tpublic getOrCreateChildRef(key: FieldKey, index: number): [Anchor, AnchorNode] {\n\t\tconst anchor = this.anchorSet.track(this.child(key, index));\n\t\tconst node =\n\t\t\tthis.anchorSet.locate(anchor) ??\n\t\t\tfail(0xaec /* cannot reference child that does not exist */);\n\t\treturn [anchor, node];\n\t}\n\n\t/**\n\t * Whether or not this `PathNode` is the special root node that sits above all the detached fields.\n\t * @remarks\n\t * In this case, the fields are detached sequences.\n\t * Note that the special root node should never appear in an UpPath\n\t * since UpPaths represent this root as `undefined`.\n\t */\n\tprivate isRoot(): boolean {\n\t\treturn this.parentPath === undefined;\n\t}\n\n\tpublic get parent(): PathNode | undefined {\n\t\tassert(this.status !== Status.Disposed, 0x409 /* PathNode must not be disposed */);\n\t\tassert(\n\t\t\tthis.parentPath !== undefined,\n\t\t\t0x355 /* PathNode.parent is an UpPath API and thus should never be called on the root PathNode. */,\n\t\t);\n\t\t// Root PathNode corresponds to the undefined root for UpPath API.\n\t\tif (this.parentPath.isRoot()) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.parentPath;\n\t}\n\n\tpublic addRef(count = 1): void {\n\t\tassert(this.status === Status.Alive, 0x40a /* PathNode must be alive */);\n\t\tthis.referenceAdded(count);\n\t}\n\n\tpublic removeRef(count = 1): void {\n\t\tassert(this.status !== Status.Disposed, 0x40b /* PathNode must not be disposed */);\n\t\tthis.referenceRemoved(count);\n\t}\n\n\t// Called when refcount is set to 0.\n\t// Node may be kept alive by children or events after this point.\n\tprotected onUnreferenced(): void {\n\t\tthis.considerDispose();\n\t}\n\n\t/**\n\t * Gets a child, adding a ref to it.\n\t * Creates child (with 1 ref) if needed.\n\t */\n\tpublic getOrCreateChild(key: FieldKey, index: number): PathNode {\n\t\tassert(this.status === Status.Alive, 0x40c /* PathNode must be alive */);\n\t\tlet field = this.children.get(key);\n\t\tif (field === undefined) {\n\t\t\tfield = [];\n\t\t\tthis.children.set(key, field);\n\t\t}\n\t\tlet child = binaryFind(field, index);\n\t\tif (child === undefined) {\n\t\t\tchild = new PathNode(this.anchorSet, key, index, this);\n\t\t\tfield.push(child);\n\t\t\t// Keep list sorted by index.\n\t\t\tfield.sort((a, b) => a.parentIndex - b.parentIndex);\n\t\t} else {\n\t\t\tchild.addRef();\n\t\t}\n\t\treturn child;\n\t}\n\n\tpublic childIfAnchored(key: FieldKey, index: number): PathNode | undefined {\n\t\tassert(this.status === Status.Alive, 0x40d /* PathNode must be alive */);\n\t\tconst field = this.children.get(key);\n\n\t\treturn field === undefined ? undefined : binaryFind(field, index);\n\t}\n\n\t/**\n\t * Removes reference from this to `child`.\n\t * Since PathNodes are doubly linked,\n\t * the caller must ensure that the reference from child to parent is also removed (or the child is no longer used).\n\t */\n\tpublic removeChild(child: PathNode): void {\n\t\tassert(this.status === Status.Alive, 0x40e /* PathNode must be alive */);\n\t\tconst key = child.parentField;\n\t\tconst field = this.children.get(key);\n\t\t// TODO: should do more optimized search (ex: binary search or better) using child.parentIndex()\n\t\t// Note that this is the index in the list of child paths, not the index within the field\n\t\tconst childIndex = field?.indexOf(child) ?? -1;\n\t\tassert(childIndex !== -1, 0x35c /* child must be parented to be removed */);\n\t\tfield?.splice(childIndex, 1);\n\t\tif (field?.length === 0) {\n\t\t\tthis.afterEmptyField(key);\n\t\t}\n\t}\n\n\t/**\n\t * Call this after directly editing the child array for a field to be empty.\n\t * Handles cleaning up unneeded data\n\t * (like the field in the map, and possibly this entire PathNode and its parents if they are no longer needed.)\n\t */\n\tpublic afterEmptyField(key: FieldKey): void {\n\t\tassert(this.status === Status.Alive, 0x40f /* PathNode must be alive */);\n\t\tthis.children.delete(key);\n\t\tthis.considerDispose();\n\t}\n\n\t/**\n\t * If node is no longer needed (has no references, no children and no events):\n\t * removes this from parent if alive, and sets this to disposed.\n\t * Must only be called when .\n\t *\n\t * Allowed when dangling (but not when disposed).\n\t */\n\tprivate considerDispose(): void {\n\t\tassert(this.status !== Status.Disposed, 0x41d /* PathNode must not be disposed */);\n\t\tif (this.isUnreferenced() && this.children.size === 0 && !this.events.hasListeners()) {\n\t\t\tif (this.status === Status.Alive) {\n\t\t\t\tthis.parentPath?.removeChild(this);\n\t\t\t}\n\t\t\tthis.status = Status.Disposed;\n\t\t}\n\t}\n}\n\n/**\n * Find a child PathNode by index using a binary search.\n * @param sorted - array of PathNode's sorted by parentIndex.\n * @param index - index being looked for.\n * @returns child with the requested parentIndex, or undefined.\n * @privateRemarks\n * This function is very commonly used with small arrays (length 0 or one for all non sequence fields),\n * and is currently a hot path due to how flex tree leaves to excessive cursor to anchor and anchor to cursor translations,\n * both of which walk paths down the AnchorSet.\n * Additionally current usages tends to fully populate the anchor tree leading the correct array index to be the requested parent index.\n * This makes the performance of this performance both important in small cases and easy to overly tune to the current usage patterns.\n * This lead to not implementing a general purpose reusable binary search.\n * Once this function is not so heavily overused due to inefficient patterns in flex-tree,\n * replacing it with a standard binary search is likely fine.\n * Until then, care and benchmarking should be used when messing with this function.\n */\nfunction binaryFind(sorted: readonly PathNode[], index: number): PathNode | undefined {\n\t// Try guessing the list is not sparse as a starter:\n\tconst guess = sorted[index];\n\tif (guess !== undefined && guess.parentIndex === index) {\n\t\treturn guess;\n\t}\n\n\t// inclusive\n\tlet min = 0;\n\t// exclusive\n\tlet max = sorted.length;\n\n\twhile (min !== max) {\n\t\tconst mid = Math.floor((min + max) / 2);\n\t\tconst item = sorted[mid]!;\n\t\tconst found = item.parentIndex;\n\t\tif (found === index) {\n\t\t\treturn item; // Found the target, return it.\n\t\t} else if (found > index) {\n\t\t\tmax = mid; // Continue search on lower half.\n\t\t} else {\n\t\t\tmin = mid + 1; // Continue search on left half.\n\t\t}\n\t}\n\treturn undefined; // If we reach here, target is not in array (or array was not sorted)\n}\n\ninterface BufferedEvent {\n\tnode: PathNode;\n\tevent: keyof AnchorEvents;\n\t/**\n\t * The key for the impacted field, if the event is associated with a key.\n\t * Some events, such as afterDestroy, do not involve a key, and thus leave this undefined.\n\t */\n\tchangedField?: FieldKey;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"anchorSet.js","sourceRoot":"","sources":["../../../src/core/tree/anchorSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;AAEH,6DAA6D;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAKN,oBAAoB,EACpB,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,WAAW,GACX,MAAM,qBAAqB,CAAC;AAK7B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACN,oBAAoB,GAMpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC;;GAEG;AACH,MAAM,WAAW,GAAW,KAAK,CAAC,CAAC,CAAC,CAAC;AA+MrC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,UAAU;IACzB,OAAO,WAAW,EAAwB,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,OAAO,SAAS;IAoCrB;QAnCS,4BAAU,aAAa,EAAuB,EAAC;QACxC,WAAM,GAAoC,uBAAA,IAAI,yBAAQ,CAAC;QAEvE;;;WAGG;QACK,kBAAa,GAAG,CAAC,CAAC;QAE1B;;;;WAIG;QACI,qBAAgB,GAAG,CAAC,CAAC;QAE5B;;;;;;;;;;WAUG;QACc,SAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;QAEnE,8GAA8G;QAC9G,yDAAyD;QACxC,iBAAY,GAA0B,IAAI,GAAG,EAAE,CAAC;QAKhE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;YACnC,IAAI,CAAC,gBAAgB,IAAI,CAA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AAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,KAAK,KAAK,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACd,CAAC;IAED,YAAY;IACZ,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,YAAY;IACZ,IAAI,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;IAExB,OAAO,GAAG,KAAK,GAAG,EAAE,CAAC;QACpB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC;QAC/B,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC,CAAC,+BAA+B;QAC7C,CAAC;aAAM,IAAI,KAAK,GAAG,KAAK,EAAE,CAAC;YAC1B,GAAG,GAAG,GAAG,CAAC,CAAC,iCAAiC;QAC7C,CAAC;aAAM,CAAC;YACP,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,gCAAgC;QAChD,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC,CAAC,qEAAqE;AACxF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { HasListeners, Listenable } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype Brand,\n\ttype BrandedKey,\n\ttype BrandedMapSubset,\n\ttype Opaque,\n\tReferenceCountedBase,\n\tbrand,\n\tbrandedSlot,\n\tgetOrAddEmptyToMap,\n\tgetOrCreate,\n} from \"../../util/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type { ITreeCursorSynchronous } from \"./cursor.js\";\nimport type * as Delta from \"./delta.js\";\nimport { offsetDetachId } from \"./deltaUtil.js\";\nimport {\n\tisDetachedUpPathRoot,\n\ttype INormalizedUpPath,\n\ttype NormalizedUpPath,\n\ttype PlaceIndex,\n\ttype Range,\n\ttype UpPath,\n} from \"./pathTree.js\";\nimport { EmptyKey } from \"./types.js\";\nimport type { DeltaVisitor } from \"./visitDelta.js\";\n\n/**\n * A way to refer to a particular tree location within an {@link AnchorSet}.\n * Associated with a ref count on the underlying {@link AnchorNode}.\n */\nexport type Anchor = Brand<number, \"rebaser.Anchor\">;\n\n/**\n * A singleton which represents a permanently invalid location (i.e. there is never a node there)\n */\nconst NeverAnchor: Anchor = brand(0);\n\n/**\n * Maps anchors (which must be ones this locator knows about) to paths.\n */\nexport interface AnchorLocator {\n\t/**\n\t * Get the current location of an Anchor.\n\t * The returned value should not be used after an edit has occurred.\n\t *\n\t * TODO: support extra/custom return types for specific/custom anchor types:\n\t * for now caller must rely on data in anchor + returned node location\n\t * (not ideal for anchors for places or ranges instead of nodes).\n\t */\n\tlocate(anchor: Anchor): AnchorNode | undefined;\n}\n\n/**\n * Stores arbitrary, user-defined data on an {@link Anchor}.\n * This data is preserved over the course of that anchor's lifetime.\n * @see {@link anchorSlot} for creation and an example use case.\n */\nexport type AnchorSlot<TContent> = BrandedKey<Opaque<Brand<number, \"AnchorSlot\">>, TContent>;\n\n/**\n * Events for {@link AnchorNode}.\n * These events are triggered while the internal data structures are being updated.\n * Thus these events must not trigger reading of the anchorSet or forest.\n *\n * TODO:\n * - Include sub-deltas in events.\n * - Add more events.\n */\nexport interface AnchorEvents {\n\t/**\n\t * When the anchor node will never get reused by its AnchorSet.\n\t * This means that the content it corresponds to has been permanently destroyed.\n\t *\n\t * @remarks\n\t * When this happens depends entirely on how the anchorSet is used.\n\t * It's possible nodes removed from the tree will be kept indefinitely, and thus never trigger this event, or they may be discarded immediately.\n\t *\n\t * @privateRemarks\n\t * The specifics of the delta visit algorithm can impact the behavior of these events.\n\t * Refer to the privateRemarks of specific events and/or the documentation of the delta visit algorithm (as of\n\t * 2024-04-02, src/core/tree/visitDelta.ts) for more information.\n\t */\n\tafterDestroy(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if one or more of this node's\n\t * direct children are about to change due to updates from the batch.\n\t *\n\t * @remarks\n\t * Does not include edits of child subtrees: instead only includes changes to nodes which are direct children in this\n\t * node's fields.\n\t */\n\tchildrenChanging(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if one or more of this node's\n\t * direct children just changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * Does not include edits of child subtrees: instead only includes changes to nodes which are direct children in this\n\t * node's fields.\n\t *\n\t * Compare to {@link AnchorEvents.childrenChangedAfterBatch} which is emitted after the whole batch has been applied.\n\t */\n\tchildrenChanged(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted after a batch of changes has been applied (i.e. when a delta visit completes), if one or more of this node's\n\t * direct children changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * Does not include edits of child subtrees: instead only includes changes to nodes which are direct children in this\n\t * node's fields.\n\t *\n\t * This event is guaranteed to be emitted on a given node only once per batch.\n\t *\n\t * Compare to {@link AnchorEvents.childrenChanged} which is emitted in the middle of the batch/delta-visit.\n\t */\n\tchildrenChangedAfterBatch(arg: {\n\t\tchangedFields: ReadonlySet<FieldKey>;\n\t}): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if something in the subtree\n\t * rooted at `anchor` _may_ be about to change due to updates from the batch.\n\t *\n\t * @remarks\n\t * Called on every parent (transitively) when a change is occurring.\n\t */\n\tsubtreeChanging(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if something in the subtree\n\t * rooted at `anchor` _may_ have just changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * While this event is always emitted in the presence of changes to the subtree,\n\t * it may also be emitted even though no changes have been made to the subtree.\n\t * It may be emitted multiple times within the application of a single edit or transaction.\n\t *\n\t * If this event is emitted by a node, it will later be emitted by all its ancestors up to the root as well, at\n\t * least once on each ancestor.\n\t *\n\t * Compare to {@link AnchorEvents.subtreeChangedAfterBatch} which is emitted after the whole batch has been applied.\n\t *\n\t * @privateRemarks\n\t * The delta visit algorithm is complicated and it may fire this event multiple times for the same change to a node.\n\t * The change to the tree may not be visible until the event fires for the last time.\n\t * Refer to the documentation of the delta visit algorithm for more details.\n\t */\n\tsubtreeChanged(anchor: AnchorNode): void;\n\n\t/**\n\t * Emitted after a batch of changes has been applied (i.e. when a delta visit completes), if something in the subtree\n\t * rooted at `anchor` changed due to updates from the batch.\n\t *\n\t * @remarks\n\t * If this event is emitted by a node, it will later be emitted by all its ancestors up to the root as well, from bottom to top.\n\t *\n\t * This event is guaranteed to be emitted on a given node only once per batch.\n\t *\n\t * Compare to {@link AnchorEvents.subtreeChanged} which is emitted in the middle of the batch/delta-visit.\n\t *\n\t * @privateRemarks\n\t * Note that because this is fired after the full batch of changes is applied, it guarantees that something in the\n\t * subtree changed, compared to {@link AnchorEvents.subtreeChanged} or {@link AnchorEvents.subtreeChanging} which\n\t * fire when something _may_ have changed or _may_ be about to change.\n\t */\n\tsubtreeChangedAfterBatch(): void;\n}\n\n/**\n * Events for {@link AnchorSet}.\n * These events are triggered while the internal data structures are being updated.\n * Thus these events must not trigger reading of the anchorSet or forest.\n *\n * TODO:\n * - Design how events should be ordered.\n * - Include sub-deltas in events.\n * - Add more events.\n */\nexport interface AnchorSetRootEvents {\n\t/**\n\t * What children are at the root is changing.\n\t */\n\tchildrenChanging(anchors: AnchorSet): void;\n\n\t/**\n\t * Something in the tree is changing.\n\t */\n\ttreeChanging(anchors: AnchorSet): void;\n}\n\n/**\n * Node in a tree of anchors.\n */\nexport interface AnchorNode extends INormalizedUpPath<AnchorNode> {\n\t/**\n\t * Events for this anchor node.\n\t */\n\treadonly events: Listenable<AnchorEvents> & HasListeners<AnchorEvents>;\n\n\t/**\n\t * Allows access to data stored on the Anchor in \"slots\".\n\t * Use {@link anchorSlot} to create slots.\n\t */\n\t// See note on BrandedKey\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\treadonly slots: BrandedMapSubset<AnchorSlot<any>>;\n\n\t/**\n\t * The set this anchor node is part of.\n\t */\n\treadonly anchorSet: AnchorSet;\n\n\t/**\n\t * Gets a child of this node.\n\t *\n\t * @remarks\n\t * This does not return an AnchorNode since there might not be one, and lazily creating one here would have messy lifetime management (See {@link AnchorNode#getOrCreateChildRef})\n\t * If an AnchorNode is required, use the AnchorSet to track then locate the returned path.\n\t * TODO:\n\t * Revisit this API.\n\t * Perhaps if we use weak down pointers and remove ref counting, we can make this return a AnchorNode.\n\t *\n\t */\n\tchild(key: FieldKey, index: number): UpPath<AnchorNode>;\n\n\t/**\n\t * Gets the child AnchorNode if already exists.\n\t *\n\t * Does NOT add a ref, so the returned AnchorNode must be used with care.\n\t */\n\tchildIfAnchored(key: FieldKey, index: number): AnchorNode | undefined;\n\n\t/**\n\t * Gets a child AnchorNode (creating it if needed), and an Anchor owning a ref to it.\n\t * Caller is responsible for freeing the returned Anchor, and must not use the AnchorNode after that.\n\t */\n\tgetOrCreateChildRef(key: FieldKey, index: number): [Anchor, AnchorNode];\n}\n\n/**\n * Define a strongly typed slot on anchors in which data can be stored.\n *\n * @remarks\n * This is mainly useful for caching data associated with a location in the tree.\n *\n * Example usage:\n * ```typescript\n * const counterSlot = anchorSlot<number>();\n *\n * function useSlot(anchor: AnchorNode): void {\n * \tanchor.slots.set(counterSlot, 1 + anchor.slots.get(counterSlot) ?? 0);\n * }\n * ```\n */\nexport function anchorSlot<TContent>(): AnchorSlot<TContent> {\n\treturn brandedSlot<AnchorSlot<TContent>>();\n}\n\n/**\n * Collection of Anchors at a specific revision.\n *\n * See `Rebaser` for how to update across revisions.\n *\n * TODO: this should not be package exported.\n * If it's needed outside the package an Interface should be used instead which can reduce its\n * API surface to a small subset.\n *\n * @sealed\n */\nexport class AnchorSet implements AnchorLocator {\n\treadonly #events = createEmitter<AnchorSetRootEvents>();\n\tpublic readonly events: Listenable<AnchorSetRootEvents> = this.#events;\n\n\t/**\n\t * Incrementing counter to give each anchor in this set a unique index for its identifier.\n\t * \"0\" is reserved for the `NeverAnchor`.\n\t */\n\tprivate anchorCounter = 1;\n\n\t/**\n\t * Incrementing number that is bumped each time that the {@link AnchorSet} is changed.\n\t * This allows consumers to cache state associated with a particular generation number and later determine if that state may have been invalidated using a comparison with the current generation number.\n\t * For example, anchor slots can be used to cache the removal status of a node to memoize repeated walks up the tree.\n\t */\n\tpublic generationNumber = 0;\n\n\t/**\n\t * Special root node under which all anchors in this anchor set are transitively parented.\n\t * This does not appear in the UpPaths (instead they use undefined for the root).\n\t * Immediate children of this root are in detached fields (which have their identifiers used as the field keys).\n\t *\n\t * This is allocated with refCount one, which is never freed so it is never cleaned up\n\t * (as long as this AnchorSet is not garbage collected).\n\t *\n\t * There should never be any children other than the special root detached field under this between transactions:\n\t * TODO: check for and enforce this.\n\t */\n\tprivate readonly root = new PathNode(this, EmptyKey, 0, undefined);\n\n\t// TODO: anchor system could be optimized a bit to avoid the maps (Anchor is ref to Path, path has ref count).\n\t// For now use this more encapsulated approach with maps.\n\tprivate readonly anchorToPath: Map<Anchor, PathNode> = new Map();\n\n\tprivate activeVisitor?: DeltaVisitor;\n\n\tpublic constructor() {\n\t\tthis.events.on(\"treeChanging\", () => {\n\t\t\tthis.generationNumber += 1;\n\t\t});\n\t}\n\n\t/**\n\t * Allows access to data stored on the AnchorSet in \"slots\".\n\t * Use {@link anchorSlot} to create slots.\n\t *\n\t * @privateRemarks\n\t * This forwards to the slots of the special above root anchor which locate can't access.\n\t */\n\t// See note on BrandedKey.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic get slots(): BrandedMapSubset<AnchorSlot<any>> {\n\t\treturn this.root.slots;\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<AnchorNode> {\n\t\tconst stack: PathNode[] = [];\n\t\tlet node: PathNode | undefined = this.root;\n\t\twhile (node !== undefined) {\n\t\t\tyield node;\n\t\t\tfor (const [_, children] of node.children) {\n\t\t\t\tfor (const child of children) {\n\t\t\t\t\tstack.push(child);\n\t\t\t\t}\n\t\t\t}\n\t\t\tnode = stack.pop();\n\t\t}\n\t}\n\n\t/**\n\t * Check if there are currently no anchors tracked.\n\t * Mainly for testing anchor cleanup.\n\t */\n\tpublic isEmpty(): boolean {\n\t\treturn this.root.children.size === 0;\n\t}\n\n\tpublic locate(anchor: Anchor): AnchorNode | undefined {\n\t\tif (anchor === NeverAnchor) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst path = this.anchorToPath.get(anchor);\n\t\tassert(\n\t\t\tpath !== undefined,\n\t\t\t0x3a6 /* Cannot locate anchor which is not in this AnchorSet */,\n\t\t);\n\t\treturn path.status === Status.Alive ? path : undefined;\n\t}\n\n\tpublic forget(anchor: Anchor): void {\n\t\tif (anchor !== NeverAnchor) {\n\t\t\tconst path = this.anchorToPath.get(anchor);\n\t\t\tassert(path !== undefined, 0x351 /* cannot forget unknown Anchor */);\n\t\t\tpath.removeRef();\n\t\t\tthis.anchorToPath.delete(anchor);\n\t\t}\n\t}\n\n\t/**\n\t * TODO: Add APIs need to allow callers of this function to reduce copying here.\n\t * Ex: maybe return something extending UpPath here.\n\t * @param path - the path to the node to be tracked. If null, returns an anchor\n\t * which is permanently invalid.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic track(path: UpPath | null): Anchor {\n\t\tif (path === null) {\n\t\t\treturn NeverAnchor;\n\t\t}\n\n\t\tconst foundPath = this.trackInner(path);\n\t\tconst anchor: Anchor = brand(this.anchorCounter++);\n\t\tthis.anchorToPath.set(anchor, foundPath);\n\t\treturn anchor;\n\t}\n\n\t/**\n\t * Finds a path node, creating if needed, and adds a ref count to it.\n\t */\n\tprivate trackInner(path: UpPath): PathNode {\n\t\tif (path instanceof PathNode && path.anchorSet === this) {\n\t\t\tpath.addRef();\n\t\t\treturn path;\n\t\t}\n\t\tconst parent = path.parent ?? this.root;\n\t\tconst parentPath = this.trackInner(parent);\n\n\t\tconst child = parentPath.getOrCreateChild(path.parentField, path.parentIndex);\n\n\t\t// Now that child is added (if needed), remove the extra ref that we added in the recursive call.\n\t\tparentPath.removeRef();\n\n\t\treturn child;\n\t}\n\n\t/**\n\t * Finds a path node if it already exists.\n\t *\n\t * Does not add a ref!\n\t */\n\tpublic find(path: UpPath): PathNode | undefined {\n\t\tif (path instanceof PathNode && path.anchorSet === this) {\n\t\t\treturn path;\n\t\t}\n\t\tconst parent = path.parent ?? this.root;\n\t\tconst parentPath = this.find(parent);\n\t\treturn parentPath?.childIfAnchored(path.parentField, path.parentIndex);\n\t}\n\n\t/**\n\t * Returns an equivalent path making as much of it with PathNodes as possible.\n\t * This allows future operations (like find, track, locate) on this path (and derived ones) to be faster.\n\t * Note that the returned path may use AnchorNodes from this AnchorSet,\n\t * but does not have a tracked reference to them, so this should not be held onto across anything that might free an AnchorNode.\n\t *\n\t * @remarks\n\t * Also ensures that any PathNode in the path is from this AnchorSet.\n\t */\n\tpublic internalizePath(originalPath: UpPath): UpPath {\n\t\tlet path: UpPath | undefined = originalPath;\n\t\tconst stack: UpPath[] = [];\n\t\twhile (path !== undefined) {\n\t\t\tif (path instanceof PathNode && path.anchorSet === this) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tstack.push(path);\n\t\t\tpath = path.parent;\n\t\t}\n\n\t\t// Now `path` contains an internalized path.\n\t\t// It just needs the paths from stackOut to wrap it.\n\n\t\tlet wrapWith: UpPath | undefined;\n\t\twhile ((wrapWith = stack.pop()) !== undefined) {\n\t\t\tif (path === undefined || path instanceof PathNode) {\n\t\t\t\t// If path already has an anchor, get an anchor for it's child if there is one:\n\t\t\t\tconst child = (path ?? this.root).childIfAnchored(\n\t\t\t\t\twrapWith.parentField,\n\t\t\t\t\twrapWith.parentIndex,\n\t\t\t\t);\n\t\t\t\tif (child !== undefined) {\n\t\t\t\t\tpath = child;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Replacing this if with a ternary makes the documentation harder to include and hurts readability.\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (path === wrapWith.parent && !(wrapWith instanceof PathNode)) {\n\t\t\t\t// path is safe to reuse from input path, so use it to avoid allocating another object.\n\t\t\t\tpath = wrapWith;\n\t\t\t} else {\n\t\t\t\tpath = {\n\t\t\t\t\tparent: path,\n\t\t\t\t\tparentField: wrapWith.parentField,\n\t\t\t\t\tparentIndex: wrapWith.parentIndex,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn path ?? fail(0xaea /* internalize path must be a path */);\n\t}\n\n\t/**\n\t * Recursively marks the given `nodes` and their descendants as disposed and pointing to a deleted node.\n\t * Note that this does NOT detach the nodes.\n\t */\n\tprivate deepDelete(nodes: readonly PathNode[]): void {\n\t\tconst stack = [...nodes];\n\t\twhile (stack.length > 0) {\n\t\t\tconst node = stack.pop()!;\n\t\t\tassert(node.status === Status.Alive, 0x408 /* PathNode must be alive */);\n\t\t\tnode.status = Status.Dangling;\n\t\t\tnode.events.emit(\"afterDestroy\", node);\n\t\t\tfor (const children of node.children.values()) {\n\t\t\t\tstack.push(...children);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Decouple nodes from their parent.\n\t * This removes the reference from the parent to the decoupled children, and updates the indexes of the remaining children accordingly.\n\t * This does NOT update the decoupled children: both their index and parent are left at their existing values.\n\t * To decouple and fixup the children, see `removeChildren` and `moveChildren`.\n\t * @param startPath - The path to the first node that is being decoupled.\n\t * @param count - number of siblings that are decoupled from the original tree.\n\t *\n\t * TODO: tests\n\t */\n\tprivate decoupleNodes(startPath: UpPath, count: number): PathNode[] {\n\t\tassert(count > 0, 0x681 /* count must be positive */);\n\n\t\tconst sourceParent = this.find(startPath.parent ?? this.root);\n\t\tconst sourceChildren = sourceParent?.children?.get(startPath.parentField);\n\t\tlet nodes: PathNode[] = [];\n\n\t\tif (sourceChildren !== undefined) {\n\t\t\tlet numberBeforeDecouple = 0;\n\t\t\tlet numberToDecouple = 0;\n\t\t\tlet index = 0;\n\t\t\twhile (\n\t\t\t\tindex < sourceChildren.length &&\n\t\t\t\tsourceChildren[index]!.parentIndex < startPath.parentIndex\n\t\t\t) {\n\t\t\t\tnumberBeforeDecouple++;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\twhile (\n\t\t\t\tindex < sourceChildren.length &&\n\t\t\t\tsourceChildren[index]!.parentIndex < startPath.parentIndex + count\n\t\t\t) {\n\t\t\t\tnumberToDecouple++;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\twhile (index < sourceChildren.length) {\n\t\t\t\t// Fix indexes in source after moved items (subtract count).\n\t\t\t\tsourceChildren[index]!.parentIndex -= count;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\t// Sever the parent -> child connections\n\t\t\tnodes = sourceChildren.splice(numberBeforeDecouple, numberToDecouple);\n\t\t\tif (sourceChildren.length === 0) {\n\t\t\t\tsourceParent!.afterEmptyField(startPath.parentField);\n\t\t\t}\n\t\t}\n\n\t\treturn nodes;\n\t}\n\n\t/**\n\t * Couple nodes to a parent.\n\t * @param destination - where the siblings are coupled to.\n\t * @param count - number of siblings that are coupled in the original tree.\n\t * @param coupleInfo - this object contains the nodes to couple and the parent index of the first node that is coupled in the original tree.\n\t *\n\t * TODO: tests\n\t */\n\tprivate coupleNodes(\n\t\tdestination: UpPath,\n\t\tcount: number,\n\t\tcoupleInfo: { startParentIndex: number; nodes: PathNode[] },\n\t): void {\n\t\tassert(coupleInfo.nodes.length > 0, 0x682 /* coupleInfo must have nodes to couple */);\n\n\t\t// The destination needs to be created if it does not exist yet.\n\t\tconst destinationPath = this.trackInner(destination.parent ?? this.root);\n\n\t\t// Update nodes for new parent.\n\t\tfor (const node of coupleInfo.nodes) {\n\t\t\tnode.parentIndex += destination.parentIndex - coupleInfo.startParentIndex;\n\t\t\tnode.parentPath = destinationPath;\n\t\t\tnode.parentField = destination.parentField;\n\t\t\t// If the destination is a detached root, propagate its detachedNodeId, otherwise remove any existing one\n\t\t\tnode.detachedNodeId = isDetachedUpPathRoot(destination)\n\t\t\t\t? offsetDetachId(\n\t\t\t\t\t\tdestination.detachedNodeId,\n\t\t\t\t\t\tnode.parentIndex - destination.parentIndex,\n\t\t\t\t\t)\n\t\t\t\t: undefined;\n\t\t}\n\n\t\t// Update new parent to add children\n\t\tconst field = destinationPath.children.get(destination.parentField);\n\t\tif (field === undefined) {\n\t\t\tdestinationPath.children.set(destination.parentField, coupleInfo.nodes);\n\t\t} else {\n\t\t\t// Update existing field contents\n\t\t\tconst numberBeforeCouple = this.increaseParentIndexes(\n\t\t\t\tfield,\n\t\t\t\tdestination.parentIndex,\n\t\t\t\tcount,\n\t\t\t);\n\n\t\t\t// TODO: this will fail for very large numbers of anchors due to argument limits.\n\t\t\tfield.splice(numberBeforeCouple, 0, ...coupleInfo.nodes);\n\t\t}\n\n\t\tdestinationPath.removeRef();\n\t}\n\n\t/**\n\t * Updates the parent indexes within `field` to account for `count` children being inserted at `fromParentIndex`. Note that\n\t * `fromParentIndex` is the logical position within the field, not the index with the sparse PathNode array.\n\t *\n\t * @param field - the field to update.\n\t * @param fromParentIndex - the logical index within the field to start updating from.\n\t * @param count - the number to increase parent indexes.\n\t * @returns the number of items in the field that are not increased.\n\t *\n\t * TODO: tests\n\t */\n\tprivate increaseParentIndexes(\n\t\tfield: PathNode[],\n\t\tfromParentIndex: number,\n\t\tcount: number,\n\t): number {\n\t\tlet index = 0;\n\t\twhile (index < field.length && field[index]!.parentIndex < fromParentIndex) {\n\t\t\tindex++;\n\t\t}\n\t\tconst numberBeforeIncrease = index;\n\t\twhile (index < field.length) {\n\t\t\tfield[index]!.parentIndex += count;\n\t\t\tindex++;\n\t\t}\n\n\t\treturn numberBeforeIncrease;\n\t}\n\n\t/**\n\t * Updates paths for a range move (including re-parenting path items and updating indexes).\n\t * @param sourceStart - where the siblings are removed from.\n\t * @param destination - where the siblings are moved to.\n\t * @param count - number of siblings to move.\n\t *\n\t * TODO:\n\t * How should anchors that become invalid, then valid again (ex: into content that was deleted, then undone) work?\n\t * Add an API to resurrect them? Store them in special detached fields? Store them in special non-detached fields?\n\t *\n\t * TODO:\n\t * How should custom anchors work (ex: ones not just tied to a specific Node)?\n\t * This design assumes they can be expressed in terms of a Node anchor + some extra stuff,\n\t * but we don't have an API for the extra stuff yet.\n\t *\n\t * TODO: tests\n\t */\n\tprivate moveChildren(sourceStart: UpPath, destination: UpPath, count: number): void {\n\t\tconst nodes = this.decoupleNodes(sourceStart, count);\n\t\tif (nodes.length > 0) {\n\t\t\tthis.coupleNodes(destination, count, {\n\t\t\t\tstartParentIndex: sourceStart.parentIndex,\n\t\t\t\tnodes,\n\t\t\t});\n\t\t} else {\n\t\t\t// If there are no nodes to move, we still need to update the parent indexes of the nodes\n\t\t\t// affected in the move in.\n\t\t\tthis.offsetChildren(destination, count);\n\t\t}\n\t}\n\n\tprivate removeChildren(path: UpPath, count: number): void {\n\t\tconst nodes = this.decoupleNodes(path, count);\n\t\tthis.deepDelete(nodes);\n\t}\n\n\t/**\n\t * Updates the parent indexes of all the nodes located at right side of the given path by the given offset.\n\t * @param firstSiblingToOffset - the path to offset children of.\n\t * @param offset - the offset to apply to the children.\n\t *\n\t */\n\tprivate offsetChildren(firstSiblingToOffset: UpPath, offset: number): void {\n\t\tconst nodePath = this.find(firstSiblingToOffset.parent ?? this.root);\n\t\tconst field = nodePath?.children.get(firstSiblingToOffset.parentField);\n\t\tif (field !== undefined) {\n\t\t\tthis.increaseParentIndexes(field, firstSiblingToOffset.parentIndex, offset);\n\t\t}\n\t}\n\n\t/**\n\t * Provides a visitor that can be used to mutate this {@link AnchorSet}.\n\t *\n\t * @returns A visitor that can be used to mutate this {@link AnchorSet}.\n\t *\n\t * @remarks\n\t * Mutating the {@link AnchorSet} does NOT update the forest.\n\t * The visitor must be released after use by calling {@link DeltaVisitor.free} on it.\n\t * It is invalid to acquire a visitor without releasing the previous one,\n\t * and this method will throw an error if this is attempted.\n\t */\n\tpublic acquireVisitor(): DeltaVisitor {\n\t\tassert(\n\t\t\tthis.activeVisitor === undefined,\n\t\t\t0x767 /* Must release existing visitor before acquiring another */,\n\t\t);\n\n\t\tconst referencedPathNodes: PathNode[] = [];\n\t\tconst visitor = {\n\t\t\tanchorSet: this,\n\t\t\t// Run `withNode` on anchorNode for parent if there is such an anchorNode.\n\t\t\t// If at root, run `withRoot` instead.\n\t\t\tmaybeWithNode(withNode: (anchorNode: PathNode) => void, withRoot?: () => void) {\n\t\t\t\tif (this.parent === undefined && withRoot !== undefined) {\n\t\t\t\t\twithRoot();\n\t\t\t\t} else {\n\t\t\t\t\tassert(this.parent !== undefined, 0x5b0 /* parent must exist */);\n\t\t\t\t\t// TODO:Perf:\n\t\t\t\t\t// When traversing to a depth D when there are not anchors in that subtree, this goes O(D^2).\n\t\t\t\t\t// Delta traversal should early out in this case because no work is needed (and all move outs are known to not contain anchors).\n\t\t\t\t\tthis.parent = this.anchorSet.internalizePath(this.parent);\n\t\t\t\t\tif (this.parent instanceof PathNode) {\n\t\t\t\t\t\tthis.parent.addRef();\n\t\t\t\t\t\treferencedPathNodes.push(this.parent);\n\t\t\t\t\t\twithNode(this.parent);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tparentField: undefined as FieldKey | undefined,\n\t\t\tparent: undefined as UpPath | undefined,\n\n\t\t\t/**\n\t\t\t * Events collected during the visit which get sent as a batch during \"free\".\n\t\t\t */\n\t\t\tbufferedEvents: [] as BufferedEvent[],\n\n\t\t\t/**\n\t\t\t * 'currentDepth' and 'depthThresholdForSubtreeChanged' serve to keep track of when do we need to emit\n\t\t\t * subtreeChangedAfterBatch events.\n\t\t\t * The algorithm works as follows:\n\t\t\t *\n\t\t\t * - Initialize both to 0.\n\t\t\t * - As we walk the tree from the root towards the leaves, when we enter a node increment currentDepth by 1.\n\t\t\t * - When we edit a node, set depthThresholdForSubtreeChanged = currentDepth.\n\t\t\t * Intuitively, depthThresholdForSubtreeChanged means \"as you walk the tree towards the root, when you exit a\n\t\t\t * node at this depth you should emit a subtreeChangedAfterBatch event\".\n\t\t\t * - When we exit a node, if d === currentDepth then emit a subtreeChangedAfterBatch and decrement d by 1.\n\t\t\t * Then decrement currentDepth unconditionally.\n\t\t\t *\n\t\t\t * Note that the event will be emitted when exiting a node that was edited (depthThresholdForSubtreeChanged will\n\t\t\t * have been set to the current depth when the edit happened), it will be emitted when exiting a node that is the\n\t\t\t * parent of a node that already emitted the event (because both depthThresholdForSubtreeChanged and currentDepth\n\t\t\t * get decremented when exiting a node so they stay in sync), and if we're already emitting the event but start\n\t\t\t * walking the tree back towards the leaves in a path where no edits happen, currentDepth will be increased again\n\t\t\t * as we walk that path, depthThresholdForSubtreeChanged will not, and thus no event will be emitted when walking\n\t\t\t * back up that path, until we get back to the depth where we were already emitting the event, and will continue\n\t\t\t * emitting it on the way to the root.\n\t\t\t */\n\t\t\tcurrentDepth: 0,\n\t\t\t/**\n\t\t\t * See {@link visitor.currentDepth}.\n\t\t\t */\n\t\t\tdepthThresholdForSubtreeChanged: 0,\n\n\t\t\tfree() {\n\t\t\t\tassert(\n\t\t\t\t\tthis.anchorSet.activeVisitor !== undefined,\n\t\t\t\t\t0x768 /* Multiple free calls for same visitor */,\n\t\t\t\t);\n\t\t\t\tfor (const node of referencedPathNodes) {\n\t\t\t\t\tnode.removeRef();\n\t\t\t\t}\n\t\t\t\tthis.anchorSet.activeVisitor = undefined;\n\n\t\t\t\t// Aggregate changedFields by node.\n\t\t\t\tconst eventsByNode: Map<PathNode, Set<FieldKey>> = new Map();\n\t\t\t\tfor (const { node, event, changedField } of this.bufferedEvents) {\n\t\t\t\t\tif (event === \"childrenChangedAfterBatch\") {\n\t\t\t\t\t\tconst keys = getOrCreate(eventsByNode, node, () => new Set());\n\t\t\t\t\t\tkeys.add(\n\t\t\t\t\t\t\tchangedField ??\n\t\t\t\t\t\t\t\tfail(0xb57 /* childrenChangedAfterBatch events should have a changedField */),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst alreadyEmitted = new Map<PathNode, (keyof AnchorEvents)[]>();\n\t\t\t\tfor (const { node, event } of this.bufferedEvents) {\n\t\t\t\t\tconst emittedEvents = getOrAddEmptyToMap(alreadyEmitted, node);\n\t\t\t\t\tif (emittedEvents.includes(event)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\temittedEvents.push(event);\n\t\t\t\t\tif (event === \"childrenChangedAfterBatch\") {\n\t\t\t\t\t\tconst changedFields =\n\t\t\t\t\t\t\teventsByNode.get(node) ??\n\t\t\t\t\t\t\tfail(0xaeb /* childrenChangedAfterBatch events should have changedFields */);\n\t\t\t\t\t\tnode.events.emit(event, { changedFields });\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode.events.emit(event);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tnotifyChildrenChanging(): void {\n\t\t\t\tthis.maybeWithNode(\n\t\t\t\t\t(p) => p.events.emit(\"childrenChanging\", p),\n\t\t\t\t\t() => this.anchorSet.#events.emit(\"childrenChanging\", this.anchorSet),\n\t\t\t\t);\n\t\t\t},\n\t\t\tnotifyChildrenChanged(): void {\n\t\t\t\tthis.maybeWithNode(\n\t\t\t\t\t(p) => {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t\t\t0xa24 /* Must be in a field to modify its contents */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tp.events.emit(\"childrenChanged\", p);\n\t\t\t\t\t\tthis.bufferedEvents.push({\n\t\t\t\t\t\t\tnode: p,\n\t\t\t\t\t\t\tevent: \"childrenChangedAfterBatch\",\n\t\t\t\t\t\t\tchangedField: this.parentField,\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\t() => {},\n\t\t\t\t);\n\t\t\t},\n\t\t\tattach(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.attachEdit(source, count, destination);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tattachEdit(source: FieldKey, count: number, destination: PlaceIndex): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a2 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath = {\n\t\t\t\t\tparent: this.anchorSet.root,\n\t\t\t\t\tparentField: source,\n\t\t\t\t\tparentIndex: 0,\n\t\t\t\t};\n\t\t\t\tconst destinationPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tparentField: this.parentField,\n\t\t\t\t\tparentIndex: destination,\n\t\t\t\t};\n\t\t\t\tthis.anchorSet.moveChildren(sourcePath, destinationPath, count);\n\t\t\t\tthis.depthThresholdForSubtreeChanged = this.currentDepth;\n\t\t\t},\n\t\t\tdetach(\n\t\t\t\tsource: Range,\n\t\t\t\tdestination: FieldKey,\n\t\t\t\tdetachedNodeId: Delta.DetachedNodeId,\n\t\t\t): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.detachEdit(source, destination, detachedNodeId);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tdetachEdit(\n\t\t\t\tsource: Range,\n\t\t\t\tdestination: FieldKey,\n\t\t\t\tdetachedNodeId: Delta.DetachedNodeId,\n\t\t\t): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a5 /* Must be in a field in order to detach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: UpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tparentField: this.parentField,\n\t\t\t\t\tparentIndex: source.start,\n\t\t\t\t};\n\t\t\t\tconst destinationPath: NormalizedUpPath = {\n\t\t\t\t\tparent: this.anchorSet.root,\n\t\t\t\t\tparentField: destination,\n\t\t\t\t\tparentIndex: 0,\n\t\t\t\t\tdetachedNodeId,\n\t\t\t\t};\n\t\t\t\tthis.anchorSet.moveChildren(sourcePath, destinationPath, source.end - source.start);\n\t\t\t\tthis.depthThresholdForSubtreeChanged = this.currentDepth;\n\t\t\t},\n\t\t\treplace(\n\t\t\t\tnewContentSource: FieldKey,\n\t\t\t\trange: Range,\n\t\t\t\toldContentDestination: FieldKey,\n\t\t\t\tdestinationDetachedNodeId: Delta.DetachedNodeId,\n\t\t\t): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.detachEdit(range, oldContentDestination, destinationDetachedNodeId);\n\t\t\t\tthis.attachEdit(newContentSource, range.end - range.start, range.start);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tdestroy(detachedField: FieldKey, count: number): void {\n\t\t\t\tthis.anchorSet.removeChildren(\n\t\t\t\t\t{\n\t\t\t\t\t\tparent: undefined,\n\t\t\t\t\t\tparentField: detachedField,\n\t\t\t\t\t\tparentIndex: 0,\n\t\t\t\t\t},\n\t\t\t\t\tcount,\n\t\t\t\t);\n\t\t\t},\n\t\t\tcreate(content: ITreeCursorSynchronous[], destination: FieldKey): void {\n\t\t\t\t// Nothing to do since content can only be created in a new detached field,\n\t\t\t\t// which cannot contain any anchors.\n\t\t\t},\n\t\t\tenterNode(index: number): void {\n\t\t\t\tassert(this.parentField !== undefined, 0x3ab /* Must be in a field to enter node */);\n\n\t\t\t\tthis.parent = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tparentField: this.parentField,\n\t\t\t\t\tparentIndex: index,\n\t\t\t\t};\n\t\t\t\tthis.parentField = undefined;\n\t\t\t\tthis.maybeWithNode((p) => {\n\t\t\t\t\tp.events.emit(\"subtreeChanging\", p);\n\t\t\t\t});\n\t\t\t\tthis.currentDepth++;\n\t\t\t},\n\t\t\texitNode(index: number): void {\n\t\t\t\tassert(this.parent !== undefined, 0x3ac /* Must have parent node */);\n\t\t\t\tif (this.depthThresholdForSubtreeChanged === this.currentDepth) {\n\t\t\t\t\tthis.maybeWithNode((p) => {\n\t\t\t\t\t\tp.events.emit(\"subtreeChanged\", p);\n\n\t\t\t\t\t\tthis.bufferedEvents.push({\n\t\t\t\t\t\t\tnode: p,\n\t\t\t\t\t\t\tevent: \"subtreeChangedAfterBatch\",\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t\tthis.depthThresholdForSubtreeChanged--;\n\t\t\t\t}\n\t\t\t\tconst parent = this.parent;\n\t\t\t\tthis.parentField = parent.parentField;\n\t\t\t\tthis.parent = parent.parent;\n\t\t\t\tthis.currentDepth--;\n\t\t\t},\n\t\t\tenterField(key: FieldKey): void {\n\t\t\t\tthis.parentField = key;\n\t\t\t},\n\t\t\texitField(key: FieldKey): void {\n\t\t\t\tthis.parentField = undefined;\n\t\t\t},\n\t\t};\n\t\tthis.#events.emit(\"treeChanging\", this);\n\t\tthis.activeVisitor = visitor;\n\t\treturn visitor;\n\t}\n}\n\n/**\n * Indicates the status of a `NodePath`.\n */\nenum Status {\n\t/**\n\t * Indicates the `NodePath` is being maintained and corresponds to a valid\n\t * (i.e., not removed) node in the document.\n\t */\n\tAlive,\n\t/**\n\t * Indicates the `NodePath` is not being maintained by the `AnchorSet`.\n\t * The `NodePath` may or may not correspond to a valid node in the document.\n\t *\n\t * Accessing such a node is invalid.\n\t * Nodes in this state are retained to detect use-after-free bugs.\n\t */\n\tDisposed,\n\t/**\n\t * Indicates the `NodePath` corresponds to a removed node in the document.\n\t * Such `NodePath`s are not maintained by the `AnchorSet` (other than updating\n\t * their status to `Disposed` when appropriate).\n\t *\n\t * Accessing such a node is invalid.\n\t * Nodes in this state are retained to detect use-after-free bugs.\n\t */\n\tDangling,\n}\n\n/**\n * Tree of anchors.\n *\n * Contains both child and parent pointers, which are kept in sync.\n *\n * Each anchor is equivalent to a path through the tree.\n * This tree structure stores a collection of these paths, but deduplicating the common prefixes of the tree\n * prefix-tree style.\n *\n * These anchors are used instead of just holding onto the node objects in forests for several reasons:\n *\n * - Update policy might be more complex than just tracking a node object in the forest.\n *\n * - Not all forests will have node objects: some may use compressed binary formats with no objects to reference.\n *\n * - Anchors are needed even when not using forests, and for nodes that are outside the currently loaded part of the\n * forest.\n *\n * - Forest in general do not need to support up pointers, but they are needed for anchors.\n *\n * Thus this can be thought of as a sparse copy of the subset of trees which are used as anchors,\n * plus the parent paths for them.\n *\n * ReferenceCountedBase tracks the number of references to this from external sources (`Anchors` via `AnchorSet`.).\n * Kept alive as if any of the follow are true:\n * 1. there are children.\n * 2. refcount is non-zero.\n * 3. events are registered.\n */\nclass PathNode extends ReferenceCountedBase implements AnchorNode {\n\tpublic status: Status = Status.Alive;\n\t/**\n\t * Event emitter for this anchor.\n\t */\n\tpublic readonly events = createEmitter<AnchorEvents>(() => this.considerDispose());\n\n\t/**\n\t * PathNode arrays are kept sorted the PathNode's parentIndex for efficient search.\n\t * Users of this field must take care to maintain invariants (correct parent pointers, not empty child arrays etc.)\n\t *\n\t * Performance Note:\n\t * Large child lists could be updated more efficiently here using a data-structure optimized\n\t * for efficient prefix sum updates, such as a Fenwick tree or Finger tree.\n\t * This would be complicated by the need for parent pointers (including indexes),\n\t * but is possible to do.\n\t */\n\tpublic readonly children: Map<FieldKey, PathNode[]> = new Map();\n\n\t// See note on BrandedKey.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic readonly slots: BrandedMapSubset<AnchorSlot<any>> = new Map();\n\n\t/**\n\t * {@inheritdoc UpPath.detachedNodeId}\n\t */\n\tpublic detachedNodeId: Delta.DetachedNodeId | undefined;\n\n\t/**\n\t * Construct a PathNode with refcount 1.\n\t * @param anchorSet - used to determine if this PathNode is already part of a specific anchorSet\n\t * to early out UpPath walking.\n\t */\n\tpublic constructor(\n\t\tpublic readonly anchorSet: AnchorSet,\n\t\tpublic parentField: FieldKey,\n\t\tpublic parentIndex: number,\n\t\t/**\n\t\t * The parent of this `PathNode` (an up pointer in the `PathNode` tree).\n\t\t * If the status of this node is `Alive`, then there must be a corresponding down pointer from the\n\t\t * `parentPath` node to this node.\n\t\t * When undefined, this node is the {@link AnchorSet.root} for `this.anchorSet` and thus has no parent.\n\t\t *\n\t\t * When updating the tree, `AnchorSet` may transiently leave the up and down pointers inconsistent\n\t\t * (updating down pointers first), but must ensure they are consistent before the editing operation returns\n\t\t * to non-`AnchorSet` code.\n\t\t * This consistency guarantee only applies to nodes that are `Alive`.\n\t\t */\n\t\tpublic parentPath: PathNode | undefined,\n\t) {\n\t\tsuper(1);\n\t}\n\n\tpublic child(key: FieldKey, index: number): UpPath<AnchorNode> {\n\t\t// Fast path: if child exists, return it.\n\t\treturn (\n\t\t\tthis.childIfAnchored(key, index) ?? {\n\t\t\t\tparent: this,\n\t\t\t\tparentField: key,\n\t\t\t\tparentIndex: index,\n\t\t\t}\n\t\t);\n\t}\n\n\tpublic getOrCreateChildRef(key: FieldKey, index: number): [Anchor, AnchorNode] {\n\t\tconst anchor = this.anchorSet.track(this.child(key, index));\n\t\tconst node =\n\t\t\tthis.anchorSet.locate(anchor) ??\n\t\t\tfail(0xaec /* cannot reference child that does not exist */);\n\t\treturn [anchor, node];\n\t}\n\n\t/**\n\t * Whether or not this `PathNode` is the special root node that sits above all the detached fields.\n\t * @remarks\n\t * In this case, the fields are detached sequences.\n\t * Note that the special root node should never appear in an UpPath\n\t * since UpPaths represent this root as `undefined`.\n\t */\n\tprivate isRoot(): boolean {\n\t\treturn this.parentPath === undefined;\n\t}\n\n\tpublic get parent(): PathNode | undefined {\n\t\tassert(this.status !== Status.Disposed, 0x409 /* PathNode must not be disposed */);\n\t\tassert(\n\t\t\tthis.parentPath !== undefined,\n\t\t\t0x355 /* PathNode.parent is an UpPath API and thus should never be called on the root PathNode. */,\n\t\t);\n\t\t// Root PathNode corresponds to the undefined root for UpPath API.\n\t\tif (this.parentPath.isRoot()) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.parentPath;\n\t}\n\n\tpublic addRef(count = 1): void {\n\t\tassert(this.status === Status.Alive, 0x40a /* PathNode must be alive */);\n\t\tthis.referenceAdded(count);\n\t}\n\n\tpublic removeRef(count = 1): void {\n\t\tassert(this.status !== Status.Disposed, 0x40b /* PathNode must not be disposed */);\n\t\tthis.referenceRemoved(count);\n\t}\n\n\t// Called when refcount is set to 0.\n\t// Node may be kept alive by children or events after this point.\n\tprotected onUnreferenced(): void {\n\t\tthis.considerDispose();\n\t}\n\n\t/**\n\t * Gets a child, adding a ref to it.\n\t * Creates child (with 1 ref) if needed.\n\t */\n\tpublic getOrCreateChild(key: FieldKey, index: number): PathNode {\n\t\tassert(this.status === Status.Alive, 0x40c /* PathNode must be alive */);\n\t\tlet field = this.children.get(key);\n\t\tif (field === undefined) {\n\t\t\tfield = [];\n\t\t\tthis.children.set(key, field);\n\t\t}\n\t\tlet child = binaryFind(field, index);\n\t\tif (child === undefined) {\n\t\t\tchild = new PathNode(this.anchorSet, key, index, this);\n\t\t\tfield.push(child);\n\t\t\t// Keep list sorted by index.\n\t\t\tfield.sort((a, b) => a.parentIndex - b.parentIndex);\n\t\t} else {\n\t\t\tchild.addRef();\n\t\t}\n\t\treturn child;\n\t}\n\n\tpublic childIfAnchored(key: FieldKey, index: number): PathNode | undefined {\n\t\tassert(this.status === Status.Alive, 0x40d /* PathNode must be alive */);\n\t\tconst field = this.children.get(key);\n\n\t\treturn field === undefined ? undefined : binaryFind(field, index);\n\t}\n\n\t/**\n\t * Removes reference from this to `child`.\n\t * Since PathNodes are doubly linked,\n\t * the caller must ensure that the reference from child to parent is also removed (or the child is no longer used).\n\t */\n\tpublic removeChild(child: PathNode): void {\n\t\tassert(this.status === Status.Alive, 0x40e /* PathNode must be alive */);\n\t\tconst key = child.parentField;\n\t\tconst field = this.children.get(key);\n\t\t// TODO: should do more optimized search (ex: binary search or better) using child.parentIndex()\n\t\t// Note that this is the index in the list of child paths, not the index within the field\n\t\tconst childIndex = field?.indexOf(child) ?? -1;\n\t\tassert(childIndex !== -1, 0x35c /* child must be parented to be removed */);\n\t\tfield?.splice(childIndex, 1);\n\t\tif (field?.length === 0) {\n\t\t\tthis.afterEmptyField(key);\n\t\t}\n\t}\n\n\t/**\n\t * Call this after directly editing the child array for a field to be empty.\n\t * Handles cleaning up unneeded data\n\t * (like the field in the map, and possibly this entire PathNode and its parents if they are no longer needed.)\n\t */\n\tpublic afterEmptyField(key: FieldKey): void {\n\t\tassert(this.status === Status.Alive, 0x40f /* PathNode must be alive */);\n\t\tthis.children.delete(key);\n\t\tthis.considerDispose();\n\t}\n\n\t/**\n\t * If node is no longer needed (has no references, no children and no events):\n\t * removes this from parent if alive, and sets this to disposed.\n\t * Must only be called when .\n\t *\n\t * Allowed when dangling (but not when disposed).\n\t */\n\tprivate considerDispose(): void {\n\t\tassert(this.status !== Status.Disposed, 0x41d /* PathNode must not be disposed */);\n\t\tif (this.isUnreferenced() && this.children.size === 0 && !this.events.hasListeners()) {\n\t\t\tif (this.status === Status.Alive) {\n\t\t\t\t// eslint-disable-next-line unicorn/prefer-dom-node-remove -- Custom tree structure, not DOM\n\t\t\t\tthis.parentPath?.removeChild(this);\n\t\t\t}\n\t\t\tthis.status = Status.Disposed;\n\t\t}\n\t}\n}\n\n/**\n * Find a child PathNode by index using a binary search.\n * @param sorted - array of PathNode's sorted by parentIndex.\n * @param index - index being looked for.\n * @returns child with the requested parentIndex, or undefined.\n * @privateRemarks\n * This function is very commonly used with small arrays (length 0 or one for all non sequence fields),\n * and is currently a hot path due to how flex tree leaves to excessive cursor to anchor and anchor to cursor translations,\n * both of which walk paths down the AnchorSet.\n * Additionally current usages tends to fully populate the anchor tree leading the correct array index to be the requested parent index.\n * This makes the performance of this performance both important in small cases and easy to overly tune to the current usage patterns.\n * This lead to not implementing a general purpose reusable binary search.\n * Once this function is not so heavily overused due to inefficient patterns in flex-tree,\n * replacing it with a standard binary search is likely fine.\n * Until then, care and benchmarking should be used when messing with this function.\n */\nfunction binaryFind(sorted: readonly PathNode[], index: number): PathNode | undefined {\n\t// Try guessing the list is not sparse as a starter:\n\tconst guess = sorted[index];\n\tif (guess !== undefined && guess.parentIndex === index) {\n\t\treturn guess;\n\t}\n\n\t// inclusive\n\tlet min = 0;\n\t// exclusive\n\tlet max = sorted.length;\n\n\twhile (min !== max) {\n\t\tconst mid = Math.floor((min + max) / 2);\n\t\tconst item = sorted[mid]!;\n\t\tconst found = item.parentIndex;\n\t\tif (found === index) {\n\t\t\treturn item; // Found the target, return it.\n\t\t} else if (found > index) {\n\t\t\tmax = mid; // Continue search on lower half.\n\t\t} else {\n\t\t\tmin = mid + 1; // Continue search on left half.\n\t\t}\n\t}\n\treturn undefined; // If we reach here, target is not in array (or array was not sorted)\n}\n\ninterface BufferedEvent {\n\tnode: PathNode;\n\tevent: keyof AnchorEvents;\n\t/**\n\t * The key for the impacted field, if the event is associated with a key.\n\t * Some events, such as afterDestroy, do not involve a key, and thus leave this undefined.\n\t */\n\tchangedField?: FieldKey;\n}\n"]}
|
|
@@ -8,7 +8,7 @@ import { type IdAllocator, type JsonCompatibleReadOnly } from "../../util/index.
|
|
|
8
8
|
import type { RevisionTag, RevisionTagCodec } from "../rebase/index.js";
|
|
9
9
|
import type { FieldKey } from "../schema-stored/index.js";
|
|
10
10
|
import type * as Delta from "./delta.js";
|
|
11
|
-
import type { ForestRootId
|
|
11
|
+
import type { ForestRootId } from "./detachedFieldIndexTypes.js";
|
|
12
12
|
/**
|
|
13
13
|
* Readonly interface for {@link DetachedFieldIndex}.
|
|
14
14
|
*/
|
|
@@ -88,7 +88,6 @@ export declare class DetachedFieldIndex implements ReadOnlyDetachedFieldIndex {
|
|
|
88
88
|
* Removes all entries from the index.
|
|
89
89
|
*/
|
|
90
90
|
purge(): void;
|
|
91
|
-
updateMajor(current: Major, updated: Major): void;
|
|
92
91
|
toFieldKey(id: ForestRootId): FieldKey;
|
|
93
92
|
tryGetEntry(id: Delta.DetachedNodeId): ForestRootId | undefined;
|
|
94
93
|
getEntry(id: Delta.DetachedNodeId): ForestRootId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detachedFieldIndex.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EACN,KAAK,iBAAiB,EAItB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAS3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAGX,YAAY,
|
|
1
|
+
{"version":3,"file":"detachedFieldIndex.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EACN,KAAK,iBAAiB,EAItB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAS3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAGX,YAAY,EAGZ,MAAM,8BAA8B,CAAC;AAGtC;;GAEG;AACH,MAAM,WAAW,0B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,UAAU,CAAC,EAAE,EAAE,YAAY,GAAG,QAAQ;IAItC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,cAAc,GAAG,YAAY,GAAG,SAAS;IAI/D,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,cAAc,GAAG,YAAY;IAMvD;;OAEG;IACK,6BAA6B,CAAC,QAAQ,EAAE,WAAW,GAAG,QAAQ,CAAC,YAAY,CAAC;IAOpF;;OAEG;IACI,gCAAgC,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI;IAiB7D,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,GAAG,IAAI;IAWtD;;;;;;;OAOG;IACI,WAAW,CACjB,MAAM,CAAC,EAAE,KAAK,CAAC,cAAc,EAC7B,QAAQ,CAAC,EAAE,WAAW,EACtB,KAAK,GAAE,MAAU,GACf,YAAY;IAsBf;;OAEG;IACI,oBAAoB,CAC1B,EAAE,EAAE,KAAK,CAAC,cAAc,EACxB,QAAQ,EAAE,WAAW,GAAG,SAAS,GAC/B,IAAI;IAmBA,MAAM,IAAI,sBAAsB;IAOvC;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,sBAAsB,GAAG,IAAI;IAmBnD;;;;OAIG;IACI,yBAAyB,CAAC,cAAc,EAAE,WAAW,GAAG,IAAI;CAqBnE"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
6
6
|
import { FluidClientVersion, FormatValidatorNoOp, } from "../../codec/index.js";
|
|
7
7
|
import { brand, deleteFromNestedMap, forEachInNestedMap, idAllocatorFromMaxId, populateNestedMap, setInNestedMap, tryGetFromNestedMap, } from "../../util/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import { detachedFieldIndexCodecBuilder } from "./detachedFieldIndexCodecs.js";
|
|
9
9
|
/**
|
|
10
10
|
* The tree index records detached field IDs and associates them with a change atom ID.
|
|
11
11
|
*/
|
|
@@ -44,7 +44,11 @@ export class DetachedFieldIndex {
|
|
|
44
44
|
jsonValidator: FormatValidatorNoOp,
|
|
45
45
|
minVersionForCollab: FluidClientVersion.v2_0,
|
|
46
46
|
};
|
|
47
|
-
this.codec =
|
|
47
|
+
this.codec = detachedFieldIndexCodecBuilder.build({
|
|
48
|
+
...this.options,
|
|
49
|
+
revisionTagCodec,
|
|
50
|
+
idCompressor,
|
|
51
|
+
});
|
|
48
52
|
}
|
|
49
53
|
clone() {
|
|
50
54
|
const clone = new DetachedFieldIndex(this.name, idAllocatorFromMaxId(this.rootIdAllocator.getMaxId()), this.revisionTagCodec, this.idCompressor, this.options);
|
|
@@ -66,18 +70,18 @@ export class DetachedFieldIndex {
|
|
|
66
70
|
}
|
|
67
71
|
*entries() {
|
|
68
72
|
for (const [major, innerMap] of this.detachedNodeToField) {
|
|
69
|
-
if (major
|
|
73
|
+
if (major === undefined) {
|
|
70
74
|
for (const [minor, { root, latestRelevantRevision }] of innerMap) {
|
|
71
|
-
yield latestRelevantRevision
|
|
72
|
-
? { id: {
|
|
73
|
-
: { id: {
|
|
75
|
+
yield latestRelevantRevision === undefined
|
|
76
|
+
? { id: { minor }, root }
|
|
77
|
+
: { id: { minor }, root, latestRelevantRevision };
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
80
|
else {
|
|
77
81
|
for (const [minor, { root, latestRelevantRevision }] of innerMap) {
|
|
78
|
-
yield latestRelevantRevision
|
|
79
|
-
? { id: { minor }, root
|
|
80
|
-
: { id: { minor }, root };
|
|
82
|
+
yield latestRelevantRevision === undefined
|
|
83
|
+
? { id: { major, minor }, root }
|
|
84
|
+
: { id: { major, minor }, root, latestRelevantRevision };
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
87
|
}
|
|
@@ -89,54 +93,6 @@ export class DetachedFieldIndex {
|
|
|
89
93
|
this.detachedNodeToField.clear();
|
|
90
94
|
this.latestRelevantRevisionToFields.clear();
|
|
91
95
|
}
|
|
92
|
-
updateMajor(current, updated) {
|
|
93
|
-
// Update latestRelevantRevision information corresponding to `current`
|
|
94
|
-
{
|
|
95
|
-
const inner = this.latestRelevantRevisionToFields.get(current);
|
|
96
|
-
if (inner !== undefined) {
|
|
97
|
-
for (const nodeId of inner.values()) {
|
|
98
|
-
const entry = tryGetFromNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor);
|
|
99
|
-
assert(entry !== undefined, 0x9b8 /* Inconsistent data: missing detached node entry */);
|
|
100
|
-
setInNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor, {
|
|
101
|
-
...entry,
|
|
102
|
-
latestRelevantRevision: updated,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
this.latestRelevantRevisionToFields.delete(current);
|
|
106
|
-
const updatedInner = this.latestRelevantRevisionToFields.get(updated);
|
|
107
|
-
if (updatedInner !== undefined) {
|
|
108
|
-
for (const [root, nodeId] of inner) {
|
|
109
|
-
updatedInner.set(root, nodeId);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
this.latestRelevantRevisionToFields.set(updated, inner);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
// Update the major keys corresponding to `current`
|
|
118
|
-
{
|
|
119
|
-
const innerCurrent = this.detachedNodeToField.get(current);
|
|
120
|
-
if (innerCurrent !== undefined) {
|
|
121
|
-
this.detachedNodeToField.delete(current);
|
|
122
|
-
const innerUpdated = this.detachedNodeToField.get(updated);
|
|
123
|
-
if (innerUpdated === undefined) {
|
|
124
|
-
this.detachedNodeToField.set(updated, innerCurrent);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
for (const [minor, entry] of innerCurrent) {
|
|
128
|
-
assert(innerUpdated.get(minor) === undefined, 0x7a9 /* Collision during index update */);
|
|
129
|
-
innerUpdated.set(minor, entry);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
for (const [minor, entry] of innerCurrent) {
|
|
133
|
-
const entryInLatest = this.latestRelevantRevisionToFields.get(entry.latestRelevantRevision);
|
|
134
|
-
assert(entryInLatest !== undefined, 0x9b9 /* Inconsistent data: missing node entry in latestRelevantRevision */);
|
|
135
|
-
entryInLatest.set(entry.root, { major: updated, minor });
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
96
|
toFieldKey(id) {
|
|
141
97
|
return brand(`${this.name}-${id}`);
|
|
142
98
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detachedFieldIndex.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EAEN,kBAAkB,EAClB,mBAAmB,GAEnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAIN,KAAK,EACL,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAY7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAoC5E;;GAEG;AACH,MAAM,OAAO,kBAAkB;IA+B9B;;;OAGG;IACH,YACkB,IAAY,EACrB,eAA0C,EACjC,gBAAkC,EAClC,YAA2B,EAC5C,OAA2B;QAJV,SAAI,GAAJ,IAAI,CAAQ;QACrB,oBAAe,GAAf,eAAe,CAA2B;QACjC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,iBAAY,GAAZ,YAAY,CAAe;QAtC7C;;WAEG;QACK,wBAAmB,GAA2C,IAAI,GAAG,EAAE,CAAC;QAChF;;;;;;WAMG;QACK,mCAA8B,GAIlC,IAAI,GAAG,EAAE,CAAC;QAKd;;;;;;;WAOG;QACK,kBAAa,GAAG,IAAI,CAAC;QAa5B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI;YACzB,aAAa,EAAE,mBAAmB;YAClC,mBAAmB,EAAE,kBAAkB,CAAC,IAAI;S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2C,IAAI,GAAG,EAAE,CAAC;QACjF,MAAM,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,kBAAkB,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YACvE,cAAc,CAAC,sBAAsB,EAAE,KAAK,EAAE,KAAK,EAAE;gBACpD,IAAI;gBACJ,sBAAsB,EAAE,cAAc;aACtC,CAAC,CAAC;YACH,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,mBAAmB,GAAG,sBAAsB,CAAC;QAClD,IAAI,CAAC,8BAA8B,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,CAAC,8BAA8B,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACjE,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC3B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\tFormatValidatorNoOp,\n\ttype IJsonCodec,\n} from \"../../codec/index.js\";\nimport {\n\ttype IdAllocator,\n\ttype JsonCompatibleReadOnly,\n\ttype NestedMap,\n\tbrand,\n\tdeleteFromNestedMap,\n\tforEachInNestedMap,\n\tidAllocatorFromMaxId,\n\tpopulateNestedMap,\n\tsetInNestedMap,\n\ttryGetFromNestedMap,\n} from \"../../util/index.js\";\nimport type { RevisionTag, RevisionTagCodec } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type * as Delta from \"./delta.js\";\nimport type {\n\tDetachedField,\n\tDetachedFieldSummaryData,\n\tForestRootId,\n\tMajor,\n\tMinor,\n} from \"./detachedFieldIndexTypes.js\";\nimport { makeDetachedFieldIndexCodec } from \"./detachedFieldIndexCodecs.js\";\n\n/**\n * Readonly interface for {@link DetachedFieldIndex}.\n */\nexport interface ReadOnlyDetachedFieldIndex {\n\t/**\n\t * Creates a deep clone of this `DetachedFieldIndex`.\n\t */\n\tclone(): DetachedFieldIndex;\n\n\t/**\n\t * Returns a field key for the given ID.\n\t * This does not save the field key on the index. To do so, call {@link createEntry}.\n\t */\n\ttoFieldKey(id: ForestRootId): FieldKey;\n\n\t/**\n\t * Returns the `ForestRootId` associated with the given id.\n\t * Returns undefined if no such id is known to the index.\n\t */\n\ttryGetEntry(id: Delta.DetachedNodeId): ForestRootId | undefined;\n\n\t/**\n\t * Returns the `ForestRootId` associated with the given id.\n\t * Fails if no such id is known to the index.\n\t */\n\tgetEntry(id: Delta.DetachedNodeId): ForestRootId;\n}\n\n/**\n * Restores the originating DetachedFieldIndex to the state it was in when the checkpoint was created.\n * Can be invoked multiple times.\n */\nexport type DetachedFieldIndexCheckpoint = () => void;\n\n/**\n * The tree index records detached field IDs and associates them with a change atom ID.\n */\nexport class DetachedFieldIndex implements ReadOnlyDetachedFieldIndex {\n\t/**\n\t * A mapping from detached node ids to detached fields.\n\t */\n\tprivate detachedNodeToField: NestedMap<Major, Minor, DetachedField> = new Map();\n\t/**\n\t * A map from revisions to all detached fields for which the revision is the latest relevant revision.\n\t * See {@link DetachedField.latestRelevantRevision}.\n\t *\n\t * @remarks\n\t * undefined revisions are tolerated but any roots not associated with a revision must be disposed manually\n\t */\n\tprivate latestRelevantRevisionToFields: NestedMap<\n\t\tRevisionTag | undefined,\n\t\tForestRootId,\n\t\tDelta.DetachedNodeId\n\t> = new Map();\n\n\tprivate readonly codec: IJsonCodec<DetachedFieldSummaryData>;\n\tprivate readonly options: CodecWriteOptions;\n\n\t/**\n\t * The process for loading `DetachedFieldIndex` data from a summary is split into two steps:\n\t * 1. Call {@link loadData}\n\t * 2. Call {@link setRevisionsForLoadedData}\n\t *\n\t * This flag is only set to `false` after calling `loadData` and is set back to `true` after calling `setRevisionsForLoadedData`.\n\t * This helps ensure that `setRevisionsForLoadedData` is only called after `loadData` and only called once.\n\t */\n\tprivate isFullyLoaded = true;\n\n\t/**\n\t * @param name - A name for the index, used as a prefix for the generated field keys.\n\t * @param rootIdAllocator - An ID allocator used to generate unique field keys.\n\t */\n\tpublic constructor(\n\t\tprivate readonly name: string,\n\t\tprivate rootIdAllocator: IdAllocator<ForestRootId>,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\toptions?: CodecWriteOptions,\n\t) {\n\t\tthis.options = options ?? {\n\t\t\tjsonValidator: FormatValidatorNoOp,\n\t\t\tminVersionForCollab: FluidClientVersion.v2_0,\n\t\t};\n\t\tthis.codec = makeDetachedFieldIndexCodec(revisionTagCodec, this.options, idCompressor);\n\t}\n\n\tpublic clone(): DetachedFieldIndex {\n\t\tconst clone = new DetachedFieldIndex(\n\t\t\tthis.name,\n\t\t\tidAllocatorFromMaxId(this.rootIdAllocator.getMaxId()) as IdAllocator<ForestRootId>,\n\t\t\tthis.revisionTagCodec,\n\t\t\tthis.idCompressor,\n\t\t\tthis.options,\n\t\t);\n\t\tpopulateNestedMap(this.detachedNodeToField, clone.detachedNodeToField, true);\n\t\tpopulateNestedMap(\n\t\t\tthis.latestRelevantRevisionToFields,\n\t\t\tclone.latestRelevantRevisionToFields,\n\t\t\ttrue,\n\t\t);\n\t\treturn clone;\n\t}\n\n\t/**\n\t * Creates a restorable checkpoint of the current state of the DetachedFieldIndex.\n\t */\n\tpublic createCheckpoint(): DetachedFieldIndexCheckpoint {\n\t\tconst clone = this.clone();\n\t\treturn () => {\n\t\t\tthis.purge();\n\t\t\tpopulateNestedMap(clone.detachedNodeToField, this.detachedNodeToField, true);\n\t\t\tpopulateNestedMap(\n\t\t\t\tclone.latestRelevantRevisionToFields,\n\t\t\t\tthis.latestRelevantRevisionToFields,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tthis.rootIdAllocator = idAllocatorFromMaxId(\n\t\t\t\tclone.rootIdAllocator.getMaxId(),\n\t\t\t) as IdAllocator<ForestRootId>;\n\t\t};\n\t}\n\n\tpublic *entries(): Generator<{\n\t\troot: ForestRootId;\n\t\tlatestRelevantRevision?: RevisionTag;\n\t\tid: Delta.DetachedNodeId;\n\t}> {\n\t\tfor (const [major, innerMap] of this.detachedNodeToField) {\n\t\t\tif (major !== undefined) {\n\t\t\t\tfor (const [minor, { root, latestRelevantRevision }] of innerMap) {\n\t\t\t\t\tyield latestRelevantRevision !== undefined\n\t\t\t\t\t\t? { id: { major, minor }, root, latestRelevantRevision }\n\t\t\t\t\t\t: { id: { major, minor }, root };\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (const [minor, { root, latestRelevantRevision }] of innerMap) {\n\t\t\t\t\tyield latestRelevantRevision !== undefined\n\t\t\t\t\t\t? { id: { minor }, root, latestRelevantRevision }\n\t\t\t\t\t\t: { id: { minor }, root };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes all entries from the index.\n\t */\n\tpublic purge(): void {\n\t\tthis.detachedNodeToField.clear();\n\t\tthis.latestRelevantRevisionToFields.clear();\n\t}\n\n\tpublic updateMajor(current: Major, updated: Major): void {\n\t\t// Update latestRelevantRevision information corresponding to `current`\n\t\t{\n\t\t\tconst inner = this.latestRelevantRevisionToFields.get(current);\n\t\t\tif (inner !== undefined) {\n\t\t\t\tfor (const nodeId of inner.values()) {\n\t\t\t\t\tconst entry = tryGetFromNestedMap(\n\t\t\t\t\t\tthis.detachedNodeToField,\n\t\t\t\t\t\tnodeId.major,\n\t\t\t\t\t\tnodeId.minor,\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tentry !== undefined,\n\t\t\t\t\t\t0x9b8 /* Inconsistent data: missing detached node entry */,\n\t\t\t\t\t);\n\t\t\t\t\tsetInNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor, {\n\t\t\t\t\t\t...entry,\n\t\t\t\t\t\tlatestRelevantRevision: updated,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis.latestRelevantRevisionToFields.delete(current);\n\n\t\t\t\tconst updatedInner = this.latestRelevantRevisionToFields.get(updated);\n\t\t\t\tif (updatedInner !== undefined) {\n\t\t\t\t\tfor (const [root, nodeId] of inner) {\n\t\t\t\t\t\tupdatedInner.set(root, nodeId);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.latestRelevantRevisionToFields.set(updated, inner);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Update the major keys corresponding to `current`\n\t\t{\n\t\t\tconst innerCurrent = this.detachedNodeToField.get(current);\n\t\t\tif (innerCurrent !== undefined) {\n\t\t\t\tthis.detachedNodeToField.delete(current);\n\t\t\t\tconst innerUpdated = this.detachedNodeToField.get(updated);\n\t\t\t\tif (innerUpdated === undefined) {\n\t\t\t\t\tthis.detachedNodeToField.set(updated, innerCurrent);\n\t\t\t\t} else {\n\t\t\t\t\tfor (const [minor, entry] of innerCurrent) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tinnerUpdated.get(minor) === undefined,\n\t\t\t\t\t\t\t0x7a9 /* Collision during index update */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tinnerUpdated.set(minor, entry);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const [minor, entry] of innerCurrent) {\n\t\t\t\t\tconst entryInLatest = this.latestRelevantRevisionToFields.get(\n\t\t\t\t\t\tentry.latestRelevantRevision,\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tentryInLatest !== undefined,\n\t\t\t\t\t\t0x9b9 /* Inconsistent data: missing node entry in latestRelevantRevision */,\n\t\t\t\t\t);\n\t\t\t\t\tentryInLatest.set(entry.root, { major: updated, minor });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic toFieldKey(id: ForestRootId): FieldKey {\n\t\treturn brand(`${this.name}-${id}`);\n\t}\n\n\tpublic tryGetEntry(id: Delta.DetachedNodeId): ForestRootId | undefined {\n\t\treturn tryGetFromNestedMap(this.detachedNodeToField, id.major, id.minor)?.root;\n\t}\n\n\tpublic getEntry(id: Delta.DetachedNodeId): ForestRootId {\n\t\tconst key = this.tryGetEntry(id);\n\t\tassert(key !== undefined, 0x7aa /* Unknown removed node ID */);\n\t\treturn key;\n\t}\n\n\t/**\n\t * Returns the detached root IDs for all the trees that were detached or last modified by the given revision.\n\t */\n\tpublic *getRootsLastTouchedByRevision(revision: RevisionTag): Iterable<ForestRootId> {\n\t\tconst roots = this.latestRelevantRevisionToFields.get(revision);\n\t\tif (roots !== undefined) {\n\t\t\tyield* roots.keys();\n\t\t}\n\t}\n\n\t/**\n\t * Removes the detached roots for all the trees that were detached or last modified by the given revision.\n\t */\n\tpublic deleteRootsLastTouchedByRevision(revision: RevisionTag): void {\n\t\tconst entries = this.latestRelevantRevisionToFields.get(revision);\n\t\tif (entries === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.latestRelevantRevisionToFields.delete(revision);\n\t\tfor (const detachedNodeId of entries.values()) {\n\t\t\tconst found = deleteFromNestedMap(\n\t\t\t\tthis.detachedNodeToField,\n\t\t\t\tdetachedNodeId.major,\n\t\t\t\tdetachedNodeId.minor,\n\t\t\t);\n\t\t\tassert(found, 0x9ba /* Unable to delete unknown entry */);\n\t\t}\n\t}\n\n\tpublic deleteEntry(nodeId: Delta.DetachedNodeId): void {\n\t\tconst entry = tryGetFromNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor);\n\t\tassert(entry !== undefined, 0x9bb /* Unable to delete unknown entry */);\n\t\tdeleteFromNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor);\n\t\tdeleteFromNestedMap(\n\t\t\tthis.latestRelevantRevisionToFields,\n\t\t\tentry.latestRelevantRevision,\n\t\t\tentry.root,\n\t\t);\n\t}\n\n\t/**\n\t * Associates the DetachedNodeId with a field key and creates an entry for it in the index.\n\t * @param nodeId - The ID of the detached node.\n\t * @param revision - The revision that last detached the root.\n\t * See {@link DetachedField.latestRelevantRevision} for details.\n\t * @param count - The number of entries to create. These entries will have consecutive minor IDs.\n\t * @returns The atomic ID that the `DetachedFieldIndex` uses to uniquely identify the first root.\n\t */\n\tpublic createEntry(\n\t\tnodeId?: Delta.DetachedNodeId,\n\t\trevision?: RevisionTag,\n\t\tcount: number = 1,\n\t): ForestRootId {\n\t\tconst root = this.rootIdAllocator.allocate(count);\n\t\tif (nodeId !== undefined) {\n\t\t\tfor (let i = 0; i < count; i++) {\n\t\t\t\tassert(\n\t\t\t\t\ttryGetFromNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor + i) ===\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t0x7ce /* Detached node ID already exists in index */,\n\t\t\t\t);\n\t\t\t\tsetInNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor + i, {\n\t\t\t\t\troot: brand<ForestRootId>(root + i),\n\t\t\t\t\tlatestRelevantRevision: revision,\n\t\t\t\t});\n\t\t\t\tsetInNestedMap(this.latestRelevantRevisionToFields, revision, root + i, {\n\t\t\t\t\tmajor: nodeId.major,\n\t\t\t\t\tminor: nodeId.minor + i,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn root;\n\t}\n\n\t/**\n\t * Updates the latest revision that is relevant to the provided root\n\t */\n\tpublic updateLatestRevision(\n\t\tid: Delta.DetachedNodeId,\n\t\trevision: RevisionTag | undefined,\n\t): void {\n\t\tconst fieldEntry = tryGetFromNestedMap(this.detachedNodeToField, id.major, id.minor);\n\t\tassert(\n\t\t\tfieldEntry !== undefined,\n\t\t\t0x9bc /* detached node id does not exist in the detached field index */,\n\t\t);\n\t\tconst { root, latestRelevantRevision: previousRevision } = fieldEntry;\n\n\t\t// remove this root from the set of roots for the previous latest revision\n\t\tdeleteFromNestedMap(this.latestRelevantRevisionToFields, previousRevision, root);\n\n\t\t// add this root to the set of roots for the new latest revision\n\t\tsetInNestedMap(this.latestRelevantRevisionToFields, revision, root, id);\n\t\tsetInNestedMap(this.detachedNodeToField, id.major, id.minor, {\n\t\t\troot,\n\t\t\tlatestRelevantRevision: revision,\n\t\t});\n\t}\n\n\tpublic encode(): JsonCompatibleReadOnly {\n\t\treturn this.codec.encode({\n\t\t\tdata: this.detachedNodeToField,\n\t\t\tmaxId: this.rootIdAllocator.getMaxId(),\n\t\t});\n\t}\n\n\t/**\n\t * Loads the tree index from the given string, this overrides any existing data.\n\t */\n\tpublic loadData(data: JsonCompatibleReadOnly): void {\n\t\tconst detachedFieldIndex: DetachedFieldSummaryData = this.codec.decode(data);\n\n\t\tthis.rootIdAllocator = idAllocatorFromMaxId(\n\t\t\tdetachedFieldIndex.maxId,\n\t\t) as IdAllocator<ForestRootId>;\n\n\t\tthis.detachedNodeToField = new Map();\n\t\tthis.latestRelevantRevisionToFields = new Map();\n\t\tthis.isFullyLoaded = false;\n\t\tconst rootMap = new Map<ForestRootId, Delta.DetachedNodeId>();\n\t\tforEachInNestedMap(detachedFieldIndex.data, ({ root }, major, minor) => {\n\t\t\tsetInNestedMap(this.detachedNodeToField, major, minor, { root });\n\t\t\trootMap.set(root, { major, minor });\n\t\t});\n\n\t\tthis.latestRelevantRevisionToFields.set(undefined, rootMap);\n\t}\n\n\t/**\n\t * Sets the latest relevant revision for any roots that have an undefined latest relevant revision.\n\t * This occurs when the detached field index is loaded from a summary and can only be called once after\n\t * the summary has been loaded.\n\t */\n\tpublic setRevisionsForLoadedData(latestRevision: RevisionTag): void {\n\t\tassert(\n\t\t\t!this.isFullyLoaded,\n\t\t\t0x9bd /* revisions should only be set once using this function after loading data from a summary */,\n\t\t);\n\n\t\tconst newDetachedNodeToField: NestedMap<Major, Minor, DetachedField> = new Map();\n\t\tconst rootMap = new Map();\n\t\tforEachInNestedMap(this.detachedNodeToField, ({ root }, major, minor) => {\n\t\t\tsetInNestedMap(newDetachedNodeToField, major, minor, {\n\t\t\t\troot,\n\t\t\t\tlatestRelevantRevision: latestRevision,\n\t\t\t});\n\t\t\trootMap.set(root, { major, minor });\n\t\t});\n\n\t\tthis.detachedNodeToField = newDetachedNodeToField;\n\t\tthis.latestRelevantRevisionToFields.delete(undefined);\n\t\tthis.latestRelevantRevisionToFields.set(latestRevision, rootMap);\n\t\tthis.isFullyLoaded = true;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"detachedFieldIndex.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EAEN,kBAAkB,EAClB,mBAAmB,GAEnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAIN,KAAK,EACL,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAY7B,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAoC/E;;GAEG;AACH,MAAM,OAAO,kBAAkB;IA+B9B;;;OAGG;IACH,YACkB,IAAY,EACrB,eAA0C,EACjC,gBAAkC,EAClC,YAA2B,EAC5C,OAA2B;QAJV,SAAI,GAAJ,IAAI,CAAQ;QACrB,oBAAe,GAAf,eAAe,CAA2B;QACjC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,iBAAY,GAAZ,YAAY,CAAe;QAtC7C;;WAEG;QACK,wBAAmB,GAA2C,IAAI,GAAG,EAAE,CAAC;QAChF;;;;;;WAMG;QACK,mCAA8B,GAIlC,IAAI,GAAG,EAAE,CAAC;QAKd;;;;;;;WAOG;QACK,kBAAa,GAAG,IAAI,CAAC;QAa5B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI;YACzB,aAAa,EAAE,mBAAmB;YAClC,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,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,8BAA8B,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACI,yBAAyB,CAAC,cAA2B;QAC3D,MAAM,CACL,CAAC,IAAI,CAAC,aAAa,EACnB,KAAK,CAAC,6FAA6F,CACnG,CAAC;QAEF,MAAM,sBAAsB,GAA2C,IAAI,GAAG,EAAE,CAAC;QACjF,MAAM,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,kBAAkB,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YACvE,cAAc,CAAC,sBAAsB,EAAE,KAAK,EAAE,KAAK,EAAE;gBACpD,IAAI;gBACJ,sBAAsB,EAAE,cAAc;aACtC,CAAC,CAAC;YACH,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,mBAAmB,GAAG,sBAAsB,CAAC;QAClD,IAAI,CAAC,8BAA8B,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,CAAC,8BAA8B,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACjE,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC3B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\tFormatValidatorNoOp,\n\ttype IJsonCodec,\n} from \"../../codec/index.js\";\nimport {\n\ttype IdAllocator,\n\ttype JsonCompatibleReadOnly,\n\ttype NestedMap,\n\tbrand,\n\tdeleteFromNestedMap,\n\tforEachInNestedMap,\n\tidAllocatorFromMaxId,\n\tpopulateNestedMap,\n\tsetInNestedMap,\n\ttryGetFromNestedMap,\n} from \"../../util/index.js\";\nimport type { RevisionTag, RevisionTagCodec } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type * as Delta from \"./delta.js\";\nimport type {\n\tDetachedField,\n\tDetachedFieldSummaryData,\n\tForestRootId,\n\tMajor,\n\tMinor,\n} from \"./detachedFieldIndexTypes.js\";\nimport { detachedFieldIndexCodecBuilder } from \"./detachedFieldIndexCodecs.js\";\n\n/**\n * Readonly interface for {@link DetachedFieldIndex}.\n */\nexport interface ReadOnlyDetachedFieldIndex {\n\t/**\n\t * Creates a deep clone of this `DetachedFieldIndex`.\n\t */\n\tclone(): DetachedFieldIndex;\n\n\t/**\n\t * Returns a field key for the given ID.\n\t * This does not save the field key on the index. To do so, call {@link createEntry}.\n\t */\n\ttoFieldKey(id: ForestRootId): FieldKey;\n\n\t/**\n\t * Returns the `ForestRootId` associated with the given id.\n\t * Returns undefined if no such id is known to the index.\n\t */\n\ttryGetEntry(id: Delta.DetachedNodeId): ForestRootId | undefined;\n\n\t/**\n\t * Returns the `ForestRootId` associated with the given id.\n\t * Fails if no such id is known to the index.\n\t */\n\tgetEntry(id: Delta.DetachedNodeId): ForestRootId;\n}\n\n/**\n * Restores the originating DetachedFieldIndex to the state it was in when the checkpoint was created.\n * Can be invoked multiple times.\n */\nexport type DetachedFieldIndexCheckpoint = () => void;\n\n/**\n * The tree index records detached field IDs and associates them with a change atom ID.\n */\nexport class DetachedFieldIndex implements ReadOnlyDetachedFieldIndex {\n\t/**\n\t * A mapping from detached node ids to detached fields.\n\t */\n\tprivate detachedNodeToField: NestedMap<Major, Minor, DetachedField> = new Map();\n\t/**\n\t * A map from revisions to all detached fields for which the revision is the latest relevant revision.\n\t * See {@link DetachedField.latestRelevantRevision}.\n\t *\n\t * @remarks\n\t * undefined revisions are tolerated but any roots not associated with a revision must be disposed manually\n\t */\n\tprivate latestRelevantRevisionToFields: NestedMap<\n\t\tRevisionTag | undefined,\n\t\tForestRootId,\n\t\tDelta.DetachedNodeId\n\t> = new Map();\n\n\tprivate readonly codec: IJsonCodec<DetachedFieldSummaryData>;\n\tprivate readonly options: CodecWriteOptions;\n\n\t/**\n\t * The process for loading `DetachedFieldIndex` data from a summary is split into two steps:\n\t * 1. Call {@link loadData}\n\t * 2. Call {@link setRevisionsForLoadedData}\n\t *\n\t * This flag is only set to `false` after calling `loadData` and is set back to `true` after calling `setRevisionsForLoadedData`.\n\t * This helps ensure that `setRevisionsForLoadedData` is only called after `loadData` and only called once.\n\t */\n\tprivate isFullyLoaded = true;\n\n\t/**\n\t * @param name - A name for the index, used as a prefix for the generated field keys.\n\t * @param rootIdAllocator - An ID allocator used to generate unique field keys.\n\t */\n\tpublic constructor(\n\t\tprivate readonly name: string,\n\t\tprivate rootIdAllocator: IdAllocator<ForestRootId>,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\toptions?: CodecWriteOptions,\n\t) {\n\t\tthis.options = options ?? {\n\t\t\tjsonValidator: FormatValidatorNoOp,\n\t\t\tminVersionForCollab: FluidClientVersion.v2_0,\n\t\t};\n\t\tthis.codec = detachedFieldIndexCodecBuilder.build({\n\t\t\t...this.options,\n\t\t\trevisionTagCodec,\n\t\t\tidCompressor,\n\t\t});\n\t}\n\n\tpublic clone(): DetachedFieldIndex {\n\t\tconst clone = new DetachedFieldIndex(\n\t\t\tthis.name,\n\t\t\tidAllocatorFromMaxId(this.rootIdAllocator.getMaxId()) as IdAllocator<ForestRootId>,\n\t\t\tthis.revisionTagCodec,\n\t\t\tthis.idCompressor,\n\t\t\tthis.options,\n\t\t);\n\t\tpopulateNestedMap(this.detachedNodeToField, clone.detachedNodeToField, true);\n\t\tpopulateNestedMap(\n\t\t\tthis.latestRelevantRevisionToFields,\n\t\t\tclone.latestRelevantRevisionToFields,\n\t\t\ttrue,\n\t\t);\n\t\treturn clone;\n\t}\n\n\t/**\n\t * Creates a restorable checkpoint of the current state of the DetachedFieldIndex.\n\t */\n\tpublic createCheckpoint(): DetachedFieldIndexCheckpoint {\n\t\tconst clone = this.clone();\n\t\treturn () => {\n\t\t\tthis.purge();\n\t\t\tpopulateNestedMap(clone.detachedNodeToField, this.detachedNodeToField, true);\n\t\t\tpopulateNestedMap(\n\t\t\t\tclone.latestRelevantRevisionToFields,\n\t\t\t\tthis.latestRelevantRevisionToFields,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tthis.rootIdAllocator = idAllocatorFromMaxId(\n\t\t\t\tclone.rootIdAllocator.getMaxId(),\n\t\t\t) as IdAllocator<ForestRootId>;\n\t\t};\n\t}\n\n\tpublic *entries(): Generator<{\n\t\troot: ForestRootId;\n\t\tlatestRelevantRevision?: RevisionTag;\n\t\tid: Delta.DetachedNodeId;\n\t}> {\n\t\tfor (const [major, innerMap] of this.detachedNodeToField) {\n\t\t\tif (major === undefined) {\n\t\t\t\tfor (const [minor, { root, latestRelevantRevision }] of innerMap) {\n\t\t\t\t\tyield latestRelevantRevision === undefined\n\t\t\t\t\t\t? { id: { minor }, root }\n\t\t\t\t\t\t: { id: { minor }, root, latestRelevantRevision };\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (const [minor, { root, latestRelevantRevision }] of innerMap) {\n\t\t\t\t\tyield latestRelevantRevision === undefined\n\t\t\t\t\t\t? { id: { major, minor }, root }\n\t\t\t\t\t\t: { id: { major, minor }, root, latestRelevantRevision };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes all entries from the index.\n\t */\n\tpublic purge(): void {\n\t\tthis.detachedNodeToField.clear();\n\t\tthis.latestRelevantRevisionToFields.clear();\n\t}\n\n\tpublic toFieldKey(id: ForestRootId): FieldKey {\n\t\treturn brand(`${this.name}-${id}`);\n\t}\n\n\tpublic tryGetEntry(id: Delta.DetachedNodeId): ForestRootId | undefined {\n\t\treturn tryGetFromNestedMap(this.detachedNodeToField, id.major, id.minor)?.root;\n\t}\n\n\tpublic getEntry(id: Delta.DetachedNodeId): ForestRootId {\n\t\tconst key = this.tryGetEntry(id);\n\t\tassert(key !== undefined, 0x7aa /* Unknown removed node ID */);\n\t\treturn key;\n\t}\n\n\t/**\n\t * Returns the detached root IDs for all the trees that were detached or last modified by the given revision.\n\t */\n\tpublic *getRootsLastTouchedByRevision(revision: RevisionTag): Iterable<ForestRootId> {\n\t\tconst roots = this.latestRelevantRevisionToFields.get(revision);\n\t\tif (roots !== undefined) {\n\t\t\tyield* roots.keys();\n\t\t}\n\t}\n\n\t/**\n\t * Removes the detached roots for all the trees that were detached or last modified by the given revision.\n\t */\n\tpublic deleteRootsLastTouchedByRevision(revision: RevisionTag): void {\n\t\tconst entries = this.latestRelevantRevisionToFields.get(revision);\n\t\tif (entries === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.latestRelevantRevisionToFields.delete(revision);\n\t\tfor (const detachedNodeId of entries.values()) {\n\t\t\tconst found = deleteFromNestedMap(\n\t\t\t\tthis.detachedNodeToField,\n\t\t\t\tdetachedNodeId.major,\n\t\t\t\tdetachedNodeId.minor,\n\t\t\t);\n\t\t\tassert(found, 0x9ba /* Unable to delete unknown entry */);\n\t\t}\n\t}\n\n\tpublic deleteEntry(nodeId: Delta.DetachedNodeId): void {\n\t\tconst entry = tryGetFromNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor);\n\t\tassert(entry !== undefined, 0x9bb /* Unable to delete unknown entry */);\n\t\tdeleteFromNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor);\n\t\tdeleteFromNestedMap(\n\t\t\tthis.latestRelevantRevisionToFields,\n\t\t\tentry.latestRelevantRevision,\n\t\t\tentry.root,\n\t\t);\n\t}\n\n\t/**\n\t * Associates the DetachedNodeId with a field key and creates an entry for it in the index.\n\t * @param nodeId - The ID of the detached node.\n\t * @param revision - The revision that last detached the root.\n\t * See {@link DetachedField.latestRelevantRevision} for details.\n\t * @param count - The number of entries to create. These entries will have consecutive minor IDs.\n\t * @returns The atomic ID that the `DetachedFieldIndex` uses to uniquely identify the first root.\n\t */\n\tpublic createEntry(\n\t\tnodeId?: Delta.DetachedNodeId,\n\t\trevision?: RevisionTag,\n\t\tcount: number = 1,\n\t): ForestRootId {\n\t\tconst root = this.rootIdAllocator.allocate(count);\n\t\tif (nodeId !== undefined) {\n\t\t\tfor (let i = 0; i < count; i++) {\n\t\t\t\tassert(\n\t\t\t\t\ttryGetFromNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor + i) ===\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t0x7ce /* Detached node ID already exists in index */,\n\t\t\t\t);\n\t\t\t\tsetInNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor + i, {\n\t\t\t\t\troot: brand<ForestRootId>(root + i),\n\t\t\t\t\tlatestRelevantRevision: revision,\n\t\t\t\t});\n\t\t\t\tsetInNestedMap(this.latestRelevantRevisionToFields, revision, root + i, {\n\t\t\t\t\tmajor: nodeId.major,\n\t\t\t\t\tminor: nodeId.minor + i,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn root;\n\t}\n\n\t/**\n\t * Updates the latest revision that is relevant to the provided root\n\t */\n\tpublic updateLatestRevision(\n\t\tid: Delta.DetachedNodeId,\n\t\trevision: RevisionTag | undefined,\n\t): void {\n\t\tconst fieldEntry = tryGetFromNestedMap(this.detachedNodeToField, id.major, id.minor);\n\t\tassert(\n\t\t\tfieldEntry !== undefined,\n\t\t\t0x9bc /* detached node id does not exist in the detached field index */,\n\t\t);\n\t\tconst { root, latestRelevantRevision: previousRevision } = fieldEntry;\n\n\t\t// remove this root from the set of roots for the previous latest revision\n\t\tdeleteFromNestedMap(this.latestRelevantRevisionToFields, previousRevision, root);\n\n\t\t// add this root to the set of roots for the new latest revision\n\t\tsetInNestedMap(this.latestRelevantRevisionToFields, revision, root, id);\n\t\tsetInNestedMap(this.detachedNodeToField, id.major, id.minor, {\n\t\t\troot,\n\t\t\tlatestRelevantRevision: revision,\n\t\t});\n\t}\n\n\tpublic encode(): JsonCompatibleReadOnly {\n\t\treturn this.codec.encode({\n\t\t\tdata: this.detachedNodeToField,\n\t\t\tmaxId: this.rootIdAllocator.getMaxId(),\n\t\t});\n\t}\n\n\t/**\n\t * Loads the tree index from the given string, this overrides any existing data.\n\t */\n\tpublic loadData(data: JsonCompatibleReadOnly): void {\n\t\tconst detachedFieldIndex: DetachedFieldSummaryData = this.codec.decode(data);\n\n\t\tthis.rootIdAllocator = idAllocatorFromMaxId(\n\t\t\tdetachedFieldIndex.maxId,\n\t\t) as IdAllocator<ForestRootId>;\n\n\t\tthis.detachedNodeToField = new Map();\n\t\tthis.latestRelevantRevisionToFields = new Map();\n\t\tthis.isFullyLoaded = false;\n\t\tconst rootMap = new Map<ForestRootId, Delta.DetachedNodeId>();\n\t\tforEachInNestedMap(detachedFieldIndex.data, ({ root }, major, minor) => {\n\t\t\tsetInNestedMap(this.detachedNodeToField, major, minor, { root });\n\t\t\trootMap.set(root, { major, minor });\n\t\t});\n\n\t\tthis.latestRelevantRevisionToFields.set(undefined, rootMap);\n\t}\n\n\t/**\n\t * Sets the latest relevant revision for any roots that have an undefined latest relevant revision.\n\t * This occurs when the detached field index is loaded from a summary and can only be called once after\n\t * the summary has been loaded.\n\t */\n\tpublic setRevisionsForLoadedData(latestRevision: RevisionTag): void {\n\t\tassert(\n\t\t\t!this.isFullyLoaded,\n\t\t\t0x9bd /* revisions should only be set once using this function after loading data from a summary */,\n\t\t);\n\n\t\tconst newDetachedNodeToField: NestedMap<Major, Minor, DetachedField> = new Map();\n\t\tconst rootMap = new Map();\n\t\tforEachInNestedMap(this.detachedNodeToField, ({ root }, major, minor) => {\n\t\t\tsetInNestedMap(newDetachedNodeToField, major, minor, {\n\t\t\t\troot,\n\t\t\t\tlatestRelevantRevision: latestRevision,\n\t\t\t});\n\t\t\trootMap.set(root, { major, minor });\n\t\t});\n\n\t\tthis.detachedNodeToField = newDetachedNodeToField;\n\t\tthis.latestRelevantRevisionToFields.delete(undefined);\n\t\tthis.latestRelevantRevisionToFields.set(latestRevision, rootMap);\n\t\tthis.isFullyLoaded = true;\n\t}\n}\n"]}
|
|
@@ -2,17 +2,25 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import type { IJsonCodec } from "../../codec/index.js";
|
|
6
6
|
import { type DetachedFieldIndexFormatVersion } from "./detachedFieldIndexFormatCommon.js";
|
|
7
7
|
import type { DetachedFieldSummaryData, Major } from "./detachedFieldIndexTypes.js";
|
|
8
8
|
import type { Static, TSchema } from "@sinclair/typebox";
|
|
9
|
-
export declare function makeDetachedFieldIndexCodecFromMajorCodec<TEncodedRevisionTag, TEncodedRevisionTagSchema extends TSchema, TVersion extends DetachedFieldIndexFormatVersion>(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
export declare function makeDetachedFieldIndexCodecFromMajorCodec<TEncodedRevisionTag, TEncodedRevisionTagSchema extends TSchema, TVersion extends DetachedFieldIndexFormatVersion>(majorCodec: IJsonCodec<Major, TEncodedRevisionTag>, version: TVersion, encodedRevisionTagSchema: TEncodedRevisionTagSchema): {
|
|
10
|
+
schema: import("@sinclair/typebox").TObject<{
|
|
11
|
+
version: import("@sinclair/typebox").TLiteral<TVersion>;
|
|
12
|
+
data: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTuple<[TEncodedRevisionTagSchema, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>]>>]>, import("@sinclair/typebox").TTuple<[TEncodedRevisionTagSchema, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>]>]>>;
|
|
13
|
+
maxId: import("@sinclair/typebox").TUnsafe<import("./detachedFieldIndexTypes.js").ForestRootId>;
|
|
14
|
+
}>;
|
|
15
|
+
encode: (data: DetachedFieldSummaryData) => {
|
|
16
|
+
data: ([Static<TEncodedRevisionTagSchema, unknown[] & []>, [number, import("./detachedFieldIndexTypes.js").ForestRootId][]] | [Static<TEncodedRevisionTagSchema, unknown[] & []>, number, import("./detachedFieldIndexTypes.js").ForestRootId])[];
|
|
17
|
+
version: TVersion;
|
|
18
|
+
maxId: import("./detachedFieldIndexTypes.js").ForestRootId;
|
|
19
|
+
};
|
|
20
|
+
decode: (parsed: {
|
|
21
|
+
data: ([Static<TEncodedRevisionTagSchema, unknown[] & []>, [number, import("./detachedFieldIndexTypes.js").ForestRootId][]] | [Static<TEncodedRevisionTagSchema, unknown[] & []>, number, import("./detachedFieldIndexTypes.js").ForestRootId])[];
|
|
22
|
+
version: TVersion;
|
|
23
|
+
maxId: import("./detachedFieldIndexTypes.js").ForestRootId;
|
|
24
|
+
}) => DetachedFieldSummaryData;
|
|
25
|
+
};
|
|
18
26
|
//# sourceMappingURL=detachedFieldIndexCodecCommon.d.ts.map
|