@fluidframework/tree 2.2.0 → 2.3.0-288113
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/api-report/tree.alpha.api.md +39 -3
- package/api-report/tree.beta.api.md +8 -3
- package/api-report/tree.public.api.md +8 -3
- package/dist/beta.d.ts +1 -0
- package/dist/core/tree/anchorSet.d.ts +4 -6
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +11 -1
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/events/events.d.ts +7 -1
- package/dist/events/events.d.ts.map +1 -1
- package/dist/events/events.js +5 -2
- package/dist/events/events.js.map +1 -1
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -2
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.js +0 -12
- package/dist/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +4 -95
- package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js +1 -30
- package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/dist/feature-libraries/flex-tree/index.d.ts +2 -2
- package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/index.js +1 -3
- package/dist/feature-libraries/flex-tree/index.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts +0 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +0 -3
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts +3 -10
- package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyNode.js +2 -87
- package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +1 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +2 -4
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -31
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +1 -0
- package/dist/simple-tree/api/treeNodeApi.d.ts +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +30 -2
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +5 -19
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +1 -1
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts +18 -5
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +57 -21
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/types.d.ts +28 -10
- package/dist/simple-tree/core/types.d.ts.map +1 -1
- package/dist/simple-tree/core/types.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/lib/beta.d.ts +1 -0
- package/lib/core/tree/anchorSet.d.ts +4 -6
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +11 -1
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/events/events.d.ts +7 -1
- package/lib/events/events.d.ts.map +1 -1
- package/lib/events/events.js +5 -2
- package/lib/events/events.js.map +1 -1
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts +0 -2
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.js +0 -12
- package/lib/feature-libraries/flex-map-tree/mapTreeNode.js.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +4 -95
- package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js +0 -29
- package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
- package/lib/feature-libraries/flex-tree/index.d.ts +2 -2
- package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/index.js +1 -1
- package/lib/feature-libraries/flex-tree/index.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts +0 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +0 -3
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts +3 -10
- package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyNode.js +3 -86
- package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +1 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +1 -0
- package/lib/simple-tree/api/treeNodeApi.d.ts +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +30 -2
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +5 -19
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +1 -1
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts +18 -5
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +58 -22
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/types.d.ts +28 -10
- package/lib/simple-tree/core/types.d.ts.map +1 -1
- package/lib/simple-tree/core/types.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/package.json +22 -32
- package/src/core/tree/anchorSet.ts +20 -9
- package/src/events/events.ts +10 -2
- package/src/feature-libraries/flex-map-tree/mapTreeNode.ts +0 -21
- package/src/feature-libraries/flex-tree/flexTreeTypes.ts +3 -170
- package/src/feature-libraries/flex-tree/index.ts +1 -17
- package/src/feature-libraries/flex-tree/lazyField.ts +0 -6
- package/src/feature-libraries/flex-tree/lazyNode.ts +3 -154
- package/src/feature-libraries/index.ts +0 -14
- package/src/index.ts +8 -0
- package/src/packageVersion.ts +1 -1
- package/src/simple-tree/api/treeNodeApi.ts +37 -5
- package/src/simple-tree/arrayNode.ts +3 -12
- package/src/simple-tree/core/index.ts +1 -0
- package/src/simple-tree/core/treeNodeKernel.ts +88 -29
- package/src/simple-tree/core/types.ts +35 -9
- package/src/simple-tree/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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AI,KAAK,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,eAAe,CAAC,GAAa;QACnC,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACzE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,eAAe,EAAE,CAAC;IACxB,CAAC;IAED;;;;;;OAMG;IACK,eAAe;QACtB,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACnF,IAAI,IAAI,CAAC,cAAc,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC;YACtF,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;gBAClC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC/B,CAAC;IACF,CAAC;CACD","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 { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { type Listenable, createEmitter } from \"../../events/index.js\";\nimport {\n\ttype Brand,\n\ttype BrandedKey,\n\ttype BrandedMapSubset,\n\ttype Opaque,\n\tReferenceCountedBase,\n\tbrand,\n\tbrandedSlot,\n\tfail,\n} from \"../../util/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type * as Delta from \"./delta.js\";\nimport type {\n\tDetachedPlaceUpPath,\n\tDetachedRangeUpPath,\n\tPlaceIndex,\n\tPlaceUpPath,\n\tRange,\n\tRangeUpPath,\n\tUpPath,\n} from \"./pathTree.js\";\nimport { EmptyKey, type Value } from \"./types.js\";\nimport type { DeltaVisitor } from \"./visitDelta.js\";\nimport type { PathVisitor } from \"./visitPath.js\";\nimport type { AnnouncedVisitor } from \"./visitorUtils.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(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_ be about to change due to updates from the batch.\n\t *\n\t * @remarks\n\t * The event can optionally return a {@link PathVisitor} to traverse the subtree.\n\t * Called on every parent (transitively) when a change is occurring.\n\t */\n\tsubtreeChanging(anchor: AnchorNode): PathVisitor | 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(anchor: AnchorNode): void;\n\n\t/**\n\t * Value on this node is changing.\n\t */\n\tvalueChanging(anchor: AnchorNode, value: Value): 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 UpPath<AnchorNode>, Listenable<AnchorEvents> {\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 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 Listenable<AnchorSetRootEvents>, AnchorLocator {\n\tprivate readonly events = createEmitter<AnchorSetRootEvents>();\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.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\tpublic on<K extends keyof AnchorSetRootEvents>(\n\t\teventName: K,\n\t\tlistener: AnchorSetRootEvents[K],\n\t): () => void {\n\t\treturn this.events.on(eventName, listener);\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\tprivate 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?.tryGetChild(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).tryGetChild(\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(\"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}\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(): AnnouncedVisitor & 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\t// Lookup table for path visitors collected from {@link AnchorEvents.visitSubtreeChanging} emitted events.\n\t\t\t// The key is the path of the node that the visitor is registered on. The code ensures that the path visitor visits only the appropriate subtrees\n\t\t\t// by maintaining the mapping only during time between the {@link DeltaVisitor.enterNode} and {@link DeltaVisitor.exitNode} calls for a given anchorNode.\n\t\t\tpathVisitors: new Map<PathNode, Set<PathVisitor>>(),\n\t\t\tparentField: undefined as FieldKey | undefined,\n\t\t\tparent: undefined as UpPath | undefined,\n\t\t\tbufferedEvents: [] as { node: PathNode; event: keyof AnchorEvents }[],\n\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// - 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// 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\tcurrentDepth: 0,\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\t\t\t\tconst alreadyEmitted = new Map<PathNode, string[]>();\n\t\t\t\tfor (const { node, event } of this.bufferedEvents) {\n\t\t\t\t\tif (!alreadyEmitted.has(node)) {\n\t\t\t\t\t\talreadyEmitted.set(node, []);\n\t\t\t\t\t}\n\t\t\t\t\tconst emittedEvents = alreadyEmitted.get(node);\n\t\t\t\t\tif (emittedEvents?.includes(event) ?? false) {\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\tnode.events.emit(event, node);\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\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});\n\t\t\t\t\t},\n\t\t\t\t\t() => {},\n\t\t\t\t);\n\t\t\t},\n\t\t\tbeforeAttach(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\t0x7a0 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst destinationPath: PlaceUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\tindex: destination,\n\t\t\t\t};\n\t\t\t\tconst sourcePath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: source,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: count,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeAttach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tafterAttach(source: FieldKey, destination: Range): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a1 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: source,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tconst destinationPath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...destination,\n\t\t\t\t};\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.afterAttach(sourcePath, destinationPath);\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\tbeforeDetach(source: Range, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a3 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...source,\n\t\t\t\t};\n\t\t\t\tconst destinationPath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: destination,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeDetach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tafterDetach(source: PlaceIndex, count: number, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a4 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: PlaceUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\tindex: source,\n\t\t\t\t};\n\t\t\t\tconst destinationPath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: destination,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: count,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.afterDetach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tdetach(source: Range, destination: FieldKey): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.detachEdit(source, destination);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tdetachEdit(source: Range, destination: FieldKey): 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 = {\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 = {\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};\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\tbeforeReplace(newContent: FieldKey, oldContent: Range, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a6 /* Must be in a field in order to replace */,\n\t\t\t\t);\n\t\t\t\tconst oldContentPath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...oldContent,\n\t\t\t\t};\n\t\t\t\tconst newNodesSourcePath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: newContent,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: oldContent.end - oldContent.start,\n\t\t\t\t});\n\t\t\t\tconst oldNodesDestinationPath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: destination,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeReplace(\n\t\t\t\t\t\t\tnewNodesSourcePath,\n\t\t\t\t\t\t\toldContentPath,\n\t\t\t\t\t\t\toldNodesDestinationPath,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tafterReplace(newContentSource: FieldKey, newContent: Range, oldContent: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a7 /* Must be in a field in order to replace */,\n\t\t\t\t);\n\t\t\t\tconst newContentPath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...newContent,\n\t\t\t\t};\n\t\t\t\tconst newNodesSourcePath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: newContentSource,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tconst oldNodesDestinationPath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: oldContent,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: newContent.end - newContent.start,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.afterReplace(\n\t\t\t\t\t\t\tnewNodesSourcePath,\n\t\t\t\t\t\t\tnewContentPath,\n\t\t\t\t\t\t\toldNodesDestinationPath,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\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): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.detachEdit(range, oldContentDestination);\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\tbeforeDestroy(detachedField: FieldKey, count: number): void {\n\t\t\t\tconst range: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: detachedField,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: count,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeDestroy(range);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tcreate(content: Delta.ProtoNodes, 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\tafterCreate(content: Delta.ProtoNodes, destination: FieldKey): void {\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tconst rangePath: DetachedRangeUpPath = brand({\n\t\t\t\t\t\t\tfield: destination,\n\t\t\t\t\t\t\tstart: 0,\n\t\t\t\t\t\t\tend: content.length,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tpathVisitor.afterCreate(rangePath);\n\t\t\t\t\t}\n\t\t\t\t}\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\t// avoid multiple pass side-effects\n\t\t\t\t\tif (!this.pathVisitors.has(p)) {\n\t\t\t\t\t\tconst visitors: (PathVisitor | void)[] = p.events.emitAndCollect(\n\t\t\t\t\t\t\t\"subtreeChanging\",\n\t\t\t\t\t\t\tp,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (visitors.length > 0) {\n\t\t\t\t\t\t\tthis.pathVisitors.set(\n\t\t\t\t\t\t\t\tp,\n\t\t\t\t\t\t\t\tnew Set(visitors.filter((v): v is PathVisitor => v !== undefined)),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\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\tthis.maybeWithNode((p) => {\n\t\t\t\t\tp.events.emit(\"subtreeChanged\", p);\n\t\t\t\t\tif (this.depthThresholdForSubtreeChanged === this.currentDepth) {\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\tthis.depthThresholdForSubtreeChanged--;\n\t\t\t\t\t}\n\t\t\t\t\t// Remove subtree path visitors added at this node if there are any\n\t\t\t\t\tthis.pathVisitors.delete(p);\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 UpPath<PathNode>, 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 * 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 on<K extends keyof AnchorEvents>(\n\t\teventName: K,\n\t\tlistener: AnchorEvents[K],\n\t): () => void {\n\t\treturn this.events.on(eventName, listener);\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.tryGetChild(key, index) ?? { parent: this, parentField: key, parentIndex: index }\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) ?? fail(\"cannot reference child that does not exist\");\n\t\treturn [anchor, node];\n\t}\n\n\t/**\n\t * @returns true iff this PathNode is the special root node that sits above all the detached fields.\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\t// TODO: should do more optimized search (ex: binary search).\n\t\tlet child = field.find((c) => c.parentIndex === 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\t/**\n\t * Gets a child if it exists.\n\t * Does NOT add a ref.\n\t */\n\tpublic tryGetChild(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\t// TODO: should do more optimized search (ex: binary search or better) using index.\n\t\treturn field?.find((c) => c.parentIndex === 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"]}
|
|
1
|
+
{"version":3,"file":"anchorSet.js","sourceRoot":"","sources":["../../../src/core/tree/anchorSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,6DAA6D;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAmB,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAKN,oBAAoB,EACpB,KAAK,EACL,WAAW,EACX,IAAI,GACJ,MAAM,qBAAqB,CAAC;AAa7B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAWtC;;GAEG;AACH,MAAM,WAAW,GAAW,KAAK,CAAC,CAAC,CAAC,CAAC;AAqMrC;;;;;;;;;;;;;;GAcG;AACH,MAAM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,CAAC,UAAU,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC5E,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QAC7B,IAAI,KAAK,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;IACF,CAAC;IAED;;;;OAIG;IACI,eAAe,CAAC,GAAa;QACnC,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACzE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,eAAe,EAAE,CAAC;IACxB,CAAC;IAED;;;;;;OAMG;IACK,eAAe;QACtB,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACnF,IAAI,IAAI,CAAC,cAAc,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC;YACtF,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;gBAClC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC/B,CAAC;IACF,CAAC;CACD","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 { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { type Listenable, createEmitter } from \"../../events/index.js\";\nimport {\n\ttype Brand,\n\ttype BrandedKey,\n\ttype BrandedMapSubset,\n\ttype Opaque,\n\tReferenceCountedBase,\n\tbrand,\n\tbrandedSlot,\n\tfail,\n} from \"../../util/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type * as Delta from \"./delta.js\";\nimport type {\n\tDetachedPlaceUpPath,\n\tDetachedRangeUpPath,\n\tPlaceIndex,\n\tPlaceUpPath,\n\tRange,\n\tRangeUpPath,\n\tUpPath,\n} from \"./pathTree.js\";\nimport { EmptyKey } from \"./types.js\";\nimport type { DeltaVisitor } from \"./visitDelta.js\";\nimport type { PathVisitor } from \"./visitPath.js\";\nimport type { AnnouncedVisitor } from \"./visitorUtils.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\tanchor: AnchorNode;\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 * The event can optionally return a {@link PathVisitor} to traverse the subtree.\n\t * Called on every parent (transitively) when a change is occurring.\n\t */\n\tsubtreeChanging(anchor: AnchorNode): PathVisitor | 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(anchor: AnchorNode): 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 UpPath<AnchorNode>, Listenable<AnchorEvents> {\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 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 Listenable<AnchorSetRootEvents>, AnchorLocator {\n\tprivate readonly events = createEmitter<AnchorSetRootEvents>();\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.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\tpublic on<K extends keyof AnchorSetRootEvents>(\n\t\teventName: K,\n\t\tlistener: AnchorSetRootEvents[K],\n\t): () => void {\n\t\treturn this.events.on(eventName, listener);\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\tprivate 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?.tryGetChild(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).tryGetChild(\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(\"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}\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(): AnnouncedVisitor & 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\t// Lookup table for path visitors collected from {@link AnchorEvents.visitSubtreeChanging} emitted events.\n\t\t\t// The key is the path of the node that the visitor is registered on. The code ensures that the path visitor visits only the appropriate subtrees\n\t\t\t// by maintaining the mapping only during time between the {@link DeltaVisitor.enterNode} and {@link DeltaVisitor.exitNode} calls for a given anchorNode.\n\t\t\tpathVisitors: new Map<PathNode, Set<PathVisitor>>(),\n\t\t\tparentField: undefined as FieldKey | undefined,\n\t\t\tparent: undefined as UpPath | undefined,\n\t\t\tbufferedEvents: [] as {\n\t\t\t\tnode: PathNode;\n\t\t\t\tevent: keyof AnchorEvents;\n\t\t\t\tchangedField?: FieldKey;\n\t\t\t}[],\n\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// - 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// 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\tcurrentDepth: 0,\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\t\t\t\tconst alreadyEmitted = new Map<PathNode, string[]>();\n\t\t\t\tfor (const { node, event } of this.bufferedEvents) {\n\t\t\t\t\tif (!alreadyEmitted.has(node)) {\n\t\t\t\t\t\talreadyEmitted.set(node, []);\n\t\t\t\t\t}\n\t\t\t\t\tconst emittedEvents = alreadyEmitted.get(node);\n\t\t\t\t\tif (emittedEvents?.includes(event) ?? false) {\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 fieldKeys = this.bufferedEvents\n\t\t\t\t\t\t\t.filter((e) => e.node === node && e.event === event)\n\t\t\t\t\t\t\t.map((e) => e.changedField as FieldKey);\n\t\t\t\t\t\tnode.events.emit(event, { anchor: node, changedFields: new Set(fieldKeys) });\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode.events.emit(event, node);\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(this.parentField !== undefined, \"Must be in a field\");\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\tbeforeAttach(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\t0x7a0 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst destinationPath: PlaceUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\tindex: destination,\n\t\t\t\t};\n\t\t\t\tconst sourcePath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: source,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: count,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeAttach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tafterAttach(source: FieldKey, destination: Range): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a1 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: source,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tconst destinationPath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...destination,\n\t\t\t\t};\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.afterAttach(sourcePath, destinationPath);\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\tbeforeDetach(source: Range, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a3 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...source,\n\t\t\t\t};\n\t\t\t\tconst destinationPath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: destination,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeDetach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tafterDetach(source: PlaceIndex, count: number, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a4 /* Must be in a field in order to attach */,\n\t\t\t\t);\n\t\t\t\tconst sourcePath: PlaceUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\tindex: source,\n\t\t\t\t};\n\t\t\t\tconst destinationPath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: destination,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: count,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.afterDetach(sourcePath, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tdetach(source: Range, destination: FieldKey): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.detachEdit(source, destination);\n\t\t\t\tthis.notifyChildrenChanged();\n\t\t\t},\n\t\t\tdetachEdit(source: Range, destination: FieldKey): 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 = {\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 = {\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};\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\tbeforeReplace(newContent: FieldKey, oldContent: Range, destination: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a6 /* Must be in a field in order to replace */,\n\t\t\t\t);\n\t\t\t\tconst oldContentPath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...oldContent,\n\t\t\t\t};\n\t\t\t\tconst newNodesSourcePath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: newContent,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: oldContent.end - oldContent.start,\n\t\t\t\t});\n\t\t\t\tconst oldNodesDestinationPath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: destination,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeReplace(\n\t\t\t\t\t\t\tnewNodesSourcePath,\n\t\t\t\t\t\t\toldContentPath,\n\t\t\t\t\t\t\toldNodesDestinationPath,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tafterReplace(newContentSource: FieldKey, newContent: Range, oldContent: FieldKey): void {\n\t\t\t\tassert(\n\t\t\t\t\tthis.parentField !== undefined,\n\t\t\t\t\t0x7a7 /* Must be in a field in order to replace */,\n\t\t\t\t);\n\t\t\t\tconst newContentPath: RangeUpPath = {\n\t\t\t\t\tparent: this.parent,\n\t\t\t\t\tfield: this.parentField,\n\t\t\t\t\t...newContent,\n\t\t\t\t};\n\t\t\t\tconst newNodesSourcePath: DetachedPlaceUpPath = brand({\n\t\t\t\t\tfield: newContentSource,\n\t\t\t\t\tindex: 0,\n\t\t\t\t});\n\t\t\t\tconst oldNodesDestinationPath: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: oldContent,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: newContent.end - newContent.start,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.afterReplace(\n\t\t\t\t\t\t\tnewNodesSourcePath,\n\t\t\t\t\t\t\tnewContentPath,\n\t\t\t\t\t\t\toldNodesDestinationPath,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\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): void {\n\t\t\t\tthis.notifyChildrenChanging();\n\t\t\t\tthis.detachEdit(range, oldContentDestination);\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\tbeforeDestroy(detachedField: FieldKey, count: number): void {\n\t\t\t\tconst range: DetachedRangeUpPath = brand({\n\t\t\t\t\tfield: detachedField,\n\t\t\t\t\tstart: 0,\n\t\t\t\t\tend: count,\n\t\t\t\t});\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tpathVisitor.beforeDestroy(range);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tcreate(content: Delta.ProtoNodes, 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\tafterCreate(content: Delta.ProtoNodes, destination: FieldKey): void {\n\t\t\t\tfor (const visitors of this.pathVisitors.values()) {\n\t\t\t\t\tfor (const pathVisitor of visitors) {\n\t\t\t\t\t\tconst rangePath: DetachedRangeUpPath = brand({\n\t\t\t\t\t\t\tfield: destination,\n\t\t\t\t\t\t\tstart: 0,\n\t\t\t\t\t\t\tend: content.length,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tpathVisitor.afterCreate(rangePath);\n\t\t\t\t\t}\n\t\t\t\t}\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\t// avoid multiple pass side-effects\n\t\t\t\t\tif (!this.pathVisitors.has(p)) {\n\t\t\t\t\t\tconst visitors: (PathVisitor | void)[] = p.events.emitAndCollect(\n\t\t\t\t\t\t\t\"subtreeChanging\",\n\t\t\t\t\t\t\tp,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (visitors.length > 0) {\n\t\t\t\t\t\t\tthis.pathVisitors.set(\n\t\t\t\t\t\t\t\tp,\n\t\t\t\t\t\t\t\tnew Set(visitors.filter((v): v is PathVisitor => v !== undefined)),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\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\tthis.maybeWithNode((p) => {\n\t\t\t\t\tp.events.emit(\"subtreeChanged\", p);\n\t\t\t\t\tif (this.depthThresholdForSubtreeChanged === this.currentDepth) {\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\tthis.depthThresholdForSubtreeChanged--;\n\t\t\t\t\t}\n\t\t\t\t\t// Remove subtree path visitors added at this node if there are any\n\t\t\t\t\tthis.pathVisitors.delete(p);\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 UpPath<PathNode>, 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 * 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 on<K extends keyof AnchorEvents>(\n\t\teventName: K,\n\t\tlistener: AnchorEvents[K],\n\t): () => void {\n\t\treturn this.events.on(eventName, listener);\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.tryGetChild(key, index) ?? { parent: this, parentField: key, parentIndex: index }\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) ?? fail(\"cannot reference child that does not exist\");\n\t\treturn [anchor, node];\n\t}\n\n\t/**\n\t * @returns true iff this PathNode is the special root node that sits above all the detached fields.\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\t// TODO: should do more optimized search (ex: binary search).\n\t\tlet child = field.find((c) => c.parentIndex === 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\t/**\n\t * Gets a child if it exists.\n\t * Does NOT add a ref.\n\t */\n\tpublic tryGetChild(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\t// TODO: should do more optimized search (ex: binary search or better) using index.\n\t\treturn field?.find((c) => c.parentIndex === 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"]}
|
package/lib/events/events.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ export interface Listenable<TListeners extends object> {
|
|
|
94
94
|
export type Off = () => void;
|
|
95
95
|
/**
|
|
96
96
|
* Interface for an event emitter that can emit typed events to subscribed listeners.
|
|
97
|
+
* @sealed @alpha
|
|
97
98
|
*/
|
|
98
99
|
export interface IEmitter<TListeners extends Listeners<TListeners>> {
|
|
99
100
|
/**
|
|
@@ -119,14 +120,18 @@ export interface IEmitter<TListeners extends Listeners<TListeners>> {
|
|
|
119
120
|
*
|
|
120
121
|
* A class can delegate handling {@link Listenable} to the returned value while using it to emit the events.
|
|
121
122
|
* See also `EventEmitter` which be used as a base class to implement {@link Listenable} via extension.
|
|
123
|
+
* @alpha
|
|
122
124
|
*/
|
|
123
125
|
export declare function createEmitter<TListeners extends object>(noListeners?: NoListenersCallback<TListeners>): Listenable<TListeners> & IEmitter<TListeners> & HasListeners<TListeners>;
|
|
124
126
|
/**
|
|
125
127
|
* Called when the last listener for `eventName` is removed.
|
|
126
128
|
* Useful for determining when to clean up resources related to detecting when the event might occurs.
|
|
129
|
+
* @alpha
|
|
127
130
|
*/
|
|
128
131
|
export type NoListenersCallback<TListeners extends object> = (eventName: keyof Listeners<TListeners>) => void;
|
|
129
132
|
/**
|
|
133
|
+
* Allows querying if an object has listeners.
|
|
134
|
+
* @sealed @alpha
|
|
130
135
|
*/
|
|
131
136
|
export interface HasListeners<TListeners extends Listeners<TListeners>> {
|
|
132
137
|
/**
|
|
@@ -162,7 +167,7 @@ export interface HasListeners<TListeners extends Listeners<TListeners>> {
|
|
|
162
167
|
*
|
|
163
168
|
* ```typescript
|
|
164
169
|
* class MyClass implements ISubscribable<MyEvents> {
|
|
165
|
-
* private readonly events =
|
|
170
|
+
* private readonly events = createEmitter<MyEvents>();
|
|
166
171
|
*
|
|
167
172
|
* private load() {
|
|
168
173
|
* this.events.emit("loaded");
|
|
@@ -173,6 +178,7 @@ export interface HasListeners<TListeners extends Listeners<TListeners>> {
|
|
|
173
178
|
* }
|
|
174
179
|
* }
|
|
175
180
|
* ```
|
|
181
|
+
* @alpha
|
|
176
182
|
*/
|
|
177
183
|
export declare class EventEmitter<TListeners extends Listeners<TListeners>> implements Listenable<TListeners>, HasListeners<TListeners> {
|
|
178
184
|
private readonly noListeners?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAG9D;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,KAAK,CAAC,SAAS,CACtF,CAAC,EAAE,MAAM,CAAC,KACN,OAAO,GACT,CAAC,GACD,KAAK,CAAC;AAET;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,SAAS,IAAI,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAE9F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI;KACxC,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;CACrF,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,kBAAkB,CAC7B,UAAU,SAAS,SAAS,CAAC,UAAU,CAAC,EACxC,OAAO,SAAS,MAAM,GAAG,MAAM,IAC5B;KACF,CAAC,IAAI,MAAM,SAAS,CAAC,UAA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E,CAAC,EACZ,GAAG,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAChC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE;IAa9B;;;;;;OAMG;IACI,EAAE,CAAC,CAAC,SAAS,MAAM,SAAS,CAAC,UAAU,CAAC,EAC9C,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,GACrB,GAAG;IAeC,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,UAAU,GAAG,OAAO;CAM1D;AAED;;GAEG;AACH,qBAAa,sBAAsB,CAAC,UAAU,SAAS,SAAS,CAAC,UAAU,CAAC,CAC3E,SAAQ,YAAY,CAAC,UAAU,CAC/B,YAAW,QAAQ,CAAC,UAAU,CAAC;gBAEZ,WAAW,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC;IAIhD,IAAI,CAAC,CAAC,SAAS,MAAM,UAAU,EAC9C,SAAS,EAAE,CAAC,EACZ,GAAG,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAChC,IAAI;IAIS,cAAc,CAAC,CAAC,SAAS,MAAM,UAAU,EACxD,SAAS,EAAE,CAAC,EACZ,GAAG,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAChC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE;CAG9B"}
|
package/lib/events/events.js
CHANGED
|
@@ -8,6 +8,7 @@ import { getOrCreate } from "../util/index.js";
|
|
|
8
8
|
*
|
|
9
9
|
* A class can delegate handling {@link Listenable} to the returned value while using it to emit the events.
|
|
10
10
|
* See also `EventEmitter` which be used as a base class to implement {@link Listenable} via extension.
|
|
11
|
+
* @alpha
|
|
11
12
|
*/
|
|
12
13
|
export function createEmitter(noListeners) {
|
|
13
14
|
return new ComposableEventEmitter(noListeners);
|
|
@@ -35,7 +36,7 @@ export function createEmitter(noListeners) {
|
|
|
35
36
|
*
|
|
36
37
|
* ```typescript
|
|
37
38
|
* class MyClass implements ISubscribable<MyEvents> {
|
|
38
|
-
* private readonly events =
|
|
39
|
+
* private readonly events = createEmitter<MyEvents>();
|
|
39
40
|
*
|
|
40
41
|
* private load() {
|
|
41
42
|
* this.events.emit("loaded");
|
|
@@ -46,6 +47,7 @@ export function createEmitter(noListeners) {
|
|
|
46
47
|
* }
|
|
47
48
|
* }
|
|
48
49
|
* ```
|
|
50
|
+
* @alpha
|
|
49
51
|
*/
|
|
50
52
|
export class EventEmitter {
|
|
51
53
|
// Because this is protected and not public, calling this externally (not from a subclass) makes sending events to the constructed instance impossible.
|
|
@@ -57,7 +59,8 @@ export class EventEmitter {
|
|
|
57
59
|
emit(eventName, ...args) {
|
|
58
60
|
const listeners = this.listeners.get(eventName);
|
|
59
61
|
if (listeners !== undefined) {
|
|
60
|
-
|
|
62
|
+
// Current TS (5.4.5) cannot spread `args` into `listener()`, but assigning to an array first makes it work.
|
|
63
|
+
const argArray = args;
|
|
61
64
|
// This explicitly copies listeners so that new listeners added during this call to emit will not receive this event.
|
|
62
65
|
for (const [off, listener] of [...listeners]) {
|
|
63
66
|
// If listener has been unsubscribed while invoking other listeners, skip it.
|
package/lib/events/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAwI/C;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC5B,WAA6C;IAE7C,OAAO,IAAI,sBAAsB,CAAa,WAAW,CAAC,CAAC;AAC5D,CAAC;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,OAAO,YAAY;IAQxB,uJAAuJ;IACvJ,6FAA6F;IAC7F,YAAuC,WAA6C;QAA7C,gBAAW,GAAX,WAAW,CAAkC;QAPjE,c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GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;gBAC5C,IAAI,gBAAgB,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACjC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;oBACjC,IAAI,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC;gBAC/B,CAAC;YACF,CAAC;QACF,CAAC,CAAC;QAEF,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC3E,OAAO,GAAG,CAAC;IACZ,CAAC;IAEM,YAAY,CAAC,SAA4B;QAC/C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,sBACZ,SAAQ,YAAwB;IAGhC,YAAmB,WAA6C;QAC/D,KAAK,CAAC,WAAW,CAAC,CAAC;IACpB,CAAC;IAEe,IAAI,CACnB,SAAY,EACZ,GAAG,IAA+B;QAElC,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IACvC,CAAC;IAEe,cAAc,CAC7B,SAAY,EACZ,GAAG,IAA+B;QAElC,OAAO,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IACjD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IEvent } from \"@fluidframework/core-interfaces\";\nimport { getOrCreate } from \"../util/index.js\";\n\n/**\n * Convert a union of types to an intersection of those types. Useful for `TransformEvents`.\n * @privateRemarks\n * First an always true extends clause is used (T extends T) to distribute T into to a union of types contravariant over each member of the T union.\n * Then the constraint on the type parameter in this new context is inferred, giving the intersection.\n */\nexport type UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) extends (\n\tk: infer U,\n) => unknown\n\t? U\n\t: never;\n\n/**\n * `true` iff the given type is an acceptable shape for a {@link Listeners | event} listener\n * @public\n */\nexport type IsListener<TListener> = TListener extends (...args: any[]) => void ? true : false;\n\n/**\n * Used to specify the kinds of events emitted by a {@link Listenable}.\n *\n * @remarks\n * Any object type is a valid {@link Listeners}, but only the {@link IsListener | event-like} properties of that\n * type will be included.\n *\n * @example\n * ```typescript\n * interface MyEvents {\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }\n * ```\n *\n * @public\n */\nexport type Listeners<T extends object> = {\n\t[P in (string | symbol) & keyof T as IsListener<T[P]> extends true ? P : never]: T[P];\n};\n\n/**\n * Converts a {@link Listeners} type (i.e. the event registry for a {@link Listenable}) into a type consumable\n * by an IEventProvider from `@fluidframework/core-interfaces`.\n * @param E - the `Events` type to transform\n * @param Target - an optional `IEvent` type that will be merged into the result along with the transformed `E`\n *\n * @example\n *\n * ```typescript\n * interface MyEvents {\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }\n *\n * class MySharedObject extends SharedObject<TransformEvents<MyEvents, ISharedObjectEvents>> {\n * // ...\n * }\n * ```\n */\nexport type TransformListeners<\n\tTListeners extends Listeners<TListeners>,\n\tTTarget extends IEvent = IEvent,\n> = {\n\t[P in keyof Listeners<TListeners>]: (event: P, listener: TListeners[P]) => void;\n} extends Record<string | number | symbol, infer Z>\n\t? UnionToIntersection<Z> & TTarget\n\t: never;\n\n/**\n * An object which allows the registration of listeners so that subscribers can be notified when an event happens.\n * @param TListeners - All the {@link Listeners | events} that this subscribable supports\n *\n * @privateRemarks\n * `EventEmitter` can be used as a base class to implement this via extension.\n * ```ts\n * type MyEventEmitter = IEventEmitter<{\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }>\n * ```\n * {@link createEmitter} can help implement this interface via delegation.\n *\n * @sealed @public\n */\nexport interface Listenable<TListeners extends object> {\n\t/**\n\t * Register an event listener.\n\t * @param eventName - the name of the event\n\t * @param listener - the handler to run when the event is fired by the emitter\n\t * @returns a {@link Off | function} which will deregister the listener when called.\n\t * This deregistration function is idempotent and therefore may be safely called more than once with no effect.\n\t * @remarks Do not register the exact same `listener` object for the same event more than once.\n\t * Doing so will result in undefined behavior, and is not guaranteed to behave the same in future versions of this library.\n\t */\n\ton<K extends keyof Listeners<TListeners>>(eventName: K, listener: TListeners[K]): Off;\n}\n\n/**\n * A function that, when called, will deregister an event listener subscription that was previously registered.\n * @remarks\n * It is returned by the {@link Listenable.on | event registration function} when event registration occurs.\n * @public\n */\nexport type Off = () => void;\n\n/**\n * Interface for an event emitter that can emit typed events to subscribed listeners.\n */\nexport interface IEmitter<TListeners extends Listeners<TListeners>> {\n\t/**\n\t * Emits an event with the specified name and arguments, notifying all subscribers by calling their registered listener functions.\n\t * @param eventName - the name of the event to fire\n\t * @param args - the arguments passed to the event listener functions\n\t */\n\temit<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void;\n\n\t/**\n\t * Emits an event with the specified name and arguments, notifying all subscribers by calling their registered listener functions.\n\t * It also collects the return values of all listeners into an array.\n\t *\n\t * Warning: This method should be used with caution. It deviates from the standard event-based integration pattern as creates substantial coupling between the emitter and its listeners.\n\t * For the majority of use-cases it is recommended to use the standard {@link IEmitter.emit} functionality.\n\t * @param eventName - the name of the event to fire\n\t * @param args - the arguments passed to the event listener functions\n\t * @returns An array of the return values of each listener, preserving the order listeners were called.\n\t */\n\temitAndCollect<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[];\n}\n\n/**\n * Create a {@link Listenable} that can be instructed to emit events via the {@link IEmitter} interface.\n *\n * A class can delegate handling {@link Listenable} to the returned value while using it to emit the events.\n * See also `EventEmitter` which be used as a base class to implement {@link Listenable} via extension.\n */\nexport function createEmitter<TListeners extends object>(\n\tnoListeners?: NoListenersCallback<TListeners>,\n): Listenable<TListeners> & IEmitter<TListeners> & HasListeners<TListeners> {\n\treturn new ComposableEventEmitter<TListeners>(noListeners);\n}\n\n/**\n * Called when the last listener for `eventName` is removed.\n * Useful for determining when to clean up resources related to detecting when the event might occurs.\n */\nexport type NoListenersCallback<TListeners extends object> = (\n\teventName: keyof Listeners<TListeners>,\n) => void;\n\n/**\n */\nexport interface HasListeners<TListeners extends Listeners<TListeners>> {\n\t/**\n\t * When no `eventName` is provided, returns true iff there are any listeners.\n\t *\n\t * When `eventName` is provided, returns true iff there are listeners for that event.\n\t *\n\t * @remarks\n\t * This can be used to know when its safe to cleanup data-structures which only exist to fire events for their listeners.\n\t */\n\thasListeners(eventName?: keyof Listeners<TListeners>): boolean;\n}\n\n/**\n * Provides an API for subscribing to and listening to events.\n *\n * @remarks Classes wishing to emit events may either extend this class or compose over it.\n *\n * @example Extending this class\n *\n * ```typescript\n * interface MyEvents {\n * \"loaded\": () => void;\n * }\n *\n * class MyClass extends EventEmitter<MyEvents> {\n * private load() {\n * this.emit(\"loaded\");\n * }\n * }\n * ```\n *\n * @example Composing over this class\n *\n * ```typescript\n * class MyClass implements ISubscribable<MyEvents> {\n * private readonly events = EventEmitter.create<MyEvents>();\n *\n * private load() {\n * this.events.emit(\"loaded\");\n * }\n *\n * public on<K extends keyof MyEvents>(eventName: K, listener: MyEvents[K]): Off {\n * return this.events.on(eventName, listener);\n * }\n * }\n * ```\n */\nexport class EventEmitter<TListeners extends Listeners<TListeners>>\n\timplements Listenable<TListeners>, HasListeners<TListeners>\n{\n\tprotected readonly listeners = new Map<\n\t\tkeyof TListeners,\n\t\tMap<Off, (...args: any[]) => TListeners[keyof TListeners]>\n\t>();\n\n\t// Because this is protected and not public, calling this externally (not from a subclass) makes sending events to the constructed instance impossible.\n\t// Instead, use the static `create` function to get an instance which allows emitting events.\n\tprotected constructor(private readonly noListeners?: NoListenersCallback<TListeners>) {}\n\n\tprotected emit<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners !== undefined) {\n\t\t\tconst argArray: unknown[] = args; // TODO: Current TS (4.5.5) cannot spread `args` into `listener()`, but future versions (e.g. 4.8.4) can.\n\t\t\t// This explicitly copies listeners so that new listeners added during this call to emit will not receive this event.\n\t\t\tfor (const [off, listener] of [...listeners]) {\n\t\t\t\t// If listener has been unsubscribed while invoking other listeners, skip it.\n\t\t\t\tif (listeners.has(off)) {\n\t\t\t\t\tlistener(...argArray);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected emitAndCollect<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[] {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners !== undefined) {\n\t\t\tconst argArray: unknown[] = args;\n\t\t\tconst resultArray: ReturnType<TListeners[K]>[] = [];\n\t\t\tfor (const listener of [...listeners.values()]) {\n\t\t\t\tresultArray.push(listener(...argArray));\n\t\t\t}\n\t\t\treturn resultArray;\n\t\t}\n\t\treturn [];\n\t}\n\n\t/**\n\t * Register an event listener.\n\t * @param eventName - the name of the event\n\t * @param listener - the handler to run when the event is fired by the emitter\n\t * @returns a function which will deregister the listener when run.\n\t * This function will error if called more than once.\n\t */\n\tpublic on<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\tlistener: TListeners[K],\n\t): Off {\n\t\tconst off: Off = () => {\n\t\t\tconst currentListeners = this.listeners.get(eventName);\n\t\t\tif (currentListeners?.delete(off) === true) {\n\t\t\t\tif (currentListeners.size === 0) {\n\t\t\t\t\tthis.listeners.delete(eventName);\n\t\t\t\t\tthis.noListeners?.(eventName);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tgetOrCreate(this.listeners, eventName, () => new Map()).set(off, listener);\n\t\treturn off;\n\t}\n\n\tpublic hasListeners(eventName?: keyof TListeners): boolean {\n\t\tif (eventName === undefined) {\n\t\t\treturn this.listeners.size !== 0;\n\t\t}\n\t\treturn this.listeners.has(eventName);\n\t}\n}\n\n/**\n * This class exposes the constructor and the `emit` method of `EventEmitter`, elevating them from protected to public\n */\nexport class ComposableEventEmitter<TListeners extends Listeners<TListeners>>\n\textends EventEmitter<TListeners>\n\timplements IEmitter<TListeners>\n{\n\tpublic constructor(noListeners?: NoListenersCallback<TListeners>) {\n\t\tsuper(noListeners);\n\t}\n\n\tpublic override emit<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void {\n\t\treturn super.emit(eventName, ...args);\n\t}\n\n\tpublic override emitAndCollect<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[] {\n\t\treturn super.emitAndCollect(eventName, ...args);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAyI/C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC5B,WAA6C;IAE7C,OAAO,IAAI,sBAAsB,CAAa,WAAW,CAAC,CAAC;AAC5D,CAAC;AA2BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,OAAO,YAAY;IAQxB,uJAAuJ;IACvJ,6FAA6F;IAC7F,YAAuC,WAA6C;QAA7C,gBAAW,GAAX,WAAW,CAAkC;QAPjE,cAAS,GAAG,IAAI,GAAG,EAGnC,CAAC;IAImF,CAAC;IAE9E,IAAI,CACb,SAAY,EACZ,GAAG,IAA+B;QAElC,MAAM,SAAS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,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;oBACjC,IAAI,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC;gBAC/B,CAAC;YACF,CAAC;QACF,CAAC,CAAC;QAEF,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC3E,OAAO,GAAG,CAAC;IACZ,CAAC;IAEM,YAAY,CAAC,SAA4B;QAC/C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,sBACZ,SAAQ,YAAwB;IAGhC,YAAmB,WAA6C;QAC/D,KAAK,CAAC,WAAW,CAAC,CAAC;IACpB,CAAC;IAEe,IAAI,CACnB,SAAY,EACZ,GAAG,IAA+B;QAElC,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IACvC,CAAC;IAEe,cAAc,CAC7B,SAAY,EACZ,GAAG,IAA+B;QAElC,OAAO,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IACjD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IEvent } from \"@fluidframework/core-interfaces\";\nimport { getOrCreate } from \"../util/index.js\";\n\n/**\n * Convert a union of types to an intersection of those types. Useful for `TransformEvents`.\n * @privateRemarks\n * First an always true extends clause is used (T extends T) to distribute T into to a union of types contravariant over each member of the T union.\n * Then the constraint on the type parameter in this new context is inferred, giving the intersection.\n */\nexport type UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) extends (\n\tk: infer U,\n) => unknown\n\t? U\n\t: never;\n\n/**\n * `true` iff the given type is an acceptable shape for a {@link Listeners | event} listener\n * @public\n */\nexport type IsListener<TListener> = TListener extends (...args: any[]) => void ? true : false;\n\n/**\n * Used to specify the kinds of events emitted by a {@link Listenable}.\n *\n * @remarks\n * Any object type is a valid {@link Listeners}, but only the {@link IsListener | event-like} properties of that\n * type will be included.\n *\n * @example\n * ```typescript\n * interface MyEvents {\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }\n * ```\n *\n * @public\n */\nexport type Listeners<T extends object> = {\n\t[P in (string | symbol) & keyof T as IsListener<T[P]> extends true ? P : never]: T[P];\n};\n\n/**\n * Converts a {@link Listeners} type (i.e. the event registry for a {@link Listenable}) into a type consumable\n * by an IEventProvider from `@fluidframework/core-interfaces`.\n * @param E - the `Events` type to transform\n * @param Target - an optional `IEvent` type that will be merged into the result along with the transformed `E`\n *\n * @example\n *\n * ```typescript\n * interface MyEvents {\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }\n *\n * class MySharedObject extends SharedObject<TransformEvents<MyEvents, ISharedObjectEvents>> {\n * // ...\n * }\n * ```\n */\nexport type TransformListeners<\n\tTListeners extends Listeners<TListeners>,\n\tTTarget extends IEvent = IEvent,\n> = {\n\t[P in keyof Listeners<TListeners>]: (event: P, listener: TListeners[P]) => void;\n} extends Record<string | number | symbol, infer Z>\n\t? UnionToIntersection<Z> & TTarget\n\t: never;\n\n/**\n * An object which allows the registration of listeners so that subscribers can be notified when an event happens.\n * @param TListeners - All the {@link Listeners | events} that this subscribable supports\n *\n * @privateRemarks\n * `EventEmitter` can be used as a base class to implement this via extension.\n * ```ts\n * type MyEventEmitter = IEventEmitter<{\n * load: (user: string, data: IUserData) => void;\n * error: (errorCode: number) => void;\n * }>\n * ```\n * {@link createEmitter} can help implement this interface via delegation.\n *\n * @sealed @public\n */\nexport interface Listenable<TListeners extends object> {\n\t/**\n\t * Register an event listener.\n\t * @param eventName - the name of the event\n\t * @param listener - the handler to run when the event is fired by the emitter\n\t * @returns a {@link Off | function} which will deregister the listener when called.\n\t * This deregistration function is idempotent and therefore may be safely called more than once with no effect.\n\t * @remarks Do not register the exact same `listener` object for the same event more than once.\n\t * Doing so will result in undefined behavior, and is not guaranteed to behave the same in future versions of this library.\n\t */\n\ton<K extends keyof Listeners<TListeners>>(eventName: K, listener: TListeners[K]): Off;\n}\n\n/**\n * A function that, when called, will deregister an event listener subscription that was previously registered.\n * @remarks\n * It is returned by the {@link Listenable.on | event registration function} when event registration occurs.\n * @public\n */\nexport type Off = () => void;\n\n/**\n * Interface for an event emitter that can emit typed events to subscribed listeners.\n * @sealed @alpha\n */\nexport interface IEmitter<TListeners extends Listeners<TListeners>> {\n\t/**\n\t * Emits an event with the specified name and arguments, notifying all subscribers by calling their registered listener functions.\n\t * @param eventName - the name of the event to fire\n\t * @param args - the arguments passed to the event listener functions\n\t */\n\temit<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void;\n\n\t/**\n\t * Emits an event with the specified name and arguments, notifying all subscribers by calling their registered listener functions.\n\t * It also collects the return values of all listeners into an array.\n\t *\n\t * Warning: This method should be used with caution. It deviates from the standard event-based integration pattern as creates substantial coupling between the emitter and its listeners.\n\t * For the majority of use-cases it is recommended to use the standard {@link IEmitter.emit} functionality.\n\t * @param eventName - the name of the event to fire\n\t * @param args - the arguments passed to the event listener functions\n\t * @returns An array of the return values of each listener, preserving the order listeners were called.\n\t */\n\temitAndCollect<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[];\n}\n\n/**\n * Create a {@link Listenable} that can be instructed to emit events via the {@link IEmitter} interface.\n *\n * A class can delegate handling {@link Listenable} to the returned value while using it to emit the events.\n * See also `EventEmitter` which be used as a base class to implement {@link Listenable} via extension.\n * @alpha\n */\nexport function createEmitter<TListeners extends object>(\n\tnoListeners?: NoListenersCallback<TListeners>,\n): Listenable<TListeners> & IEmitter<TListeners> & HasListeners<TListeners> {\n\treturn new ComposableEventEmitter<TListeners>(noListeners);\n}\n\n/**\n * Called when the last listener for `eventName` is removed.\n * Useful for determining when to clean up resources related to detecting when the event might occurs.\n * @alpha\n */\nexport type NoListenersCallback<TListeners extends object> = (\n\teventName: keyof Listeners<TListeners>,\n) => void;\n\n/**\n * Allows querying if an object has listeners.\n * @sealed @alpha\n */\nexport interface HasListeners<TListeners extends Listeners<TListeners>> {\n\t/**\n\t * When no `eventName` is provided, returns true iff there are any listeners.\n\t *\n\t * When `eventName` is provided, returns true iff there are listeners for that event.\n\t *\n\t * @remarks\n\t * This can be used to know when its safe to cleanup data-structures which only exist to fire events for their listeners.\n\t */\n\thasListeners(eventName?: keyof Listeners<TListeners>): boolean;\n}\n\n/**\n * Provides an API for subscribing to and listening to events.\n *\n * @remarks Classes wishing to emit events may either extend this class or compose over it.\n *\n * @example Extending this class\n *\n * ```typescript\n * interface MyEvents {\n * \"loaded\": () => void;\n * }\n *\n * class MyClass extends EventEmitter<MyEvents> {\n * private load() {\n * this.emit(\"loaded\");\n * }\n * }\n * ```\n *\n * @example Composing over this class\n *\n * ```typescript\n * class MyClass implements ISubscribable<MyEvents> {\n * private readonly events = createEmitter<MyEvents>();\n *\n * private load() {\n * this.events.emit(\"loaded\");\n * }\n *\n * public on<K extends keyof MyEvents>(eventName: K, listener: MyEvents[K]): Off {\n * return this.events.on(eventName, listener);\n * }\n * }\n * ```\n * @alpha\n */\nexport class EventEmitter<TListeners extends Listeners<TListeners>>\n\timplements Listenable<TListeners>, HasListeners<TListeners>\n{\n\tprotected readonly listeners = new Map<\n\t\tkeyof TListeners,\n\t\tMap<Off, (...args: any[]) => TListeners[keyof TListeners]>\n\t>();\n\n\t// Because this is protected and not public, calling this externally (not from a subclass) makes sending events to the constructed instance impossible.\n\t// Instead, use the static `create` function to get an instance which allows emitting events.\n\tprotected constructor(private readonly noListeners?: NoListenersCallback<TListeners>) {}\n\n\tprotected emit<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners !== undefined) {\n\t\t\t// Current TS (5.4.5) cannot spread `args` into `listener()`, but assigning to an array first makes it work.\n\t\t\tconst argArray: unknown[] = args;\n\n\t\t\t// This explicitly copies listeners so that new listeners added during this call to emit will not receive this event.\n\t\t\tfor (const [off, listener] of [...listeners]) {\n\t\t\t\t// If listener has been unsubscribed while invoking other listeners, skip it.\n\t\t\t\tif (listeners.has(off)) {\n\t\t\t\t\tlistener(...argArray);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected emitAndCollect<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[] {\n\t\tconst listeners = this.listeners.get(eventName);\n\t\tif (listeners !== undefined) {\n\t\t\tconst argArray: unknown[] = args;\n\t\t\tconst resultArray: ReturnType<TListeners[K]>[] = [];\n\t\t\tfor (const listener of [...listeners.values()]) {\n\t\t\t\tresultArray.push(listener(...argArray));\n\t\t\t}\n\t\t\treturn resultArray;\n\t\t}\n\t\treturn [];\n\t}\n\n\t/**\n\t * Register an event listener.\n\t * @param eventName - the name of the event\n\t * @param listener - the handler to run when the event is fired by the emitter\n\t * @returns a function which will deregister the listener when run.\n\t * This function will error if called more than once.\n\t */\n\tpublic on<K extends keyof Listeners<TListeners>>(\n\t\teventName: K,\n\t\tlistener: TListeners[K],\n\t): Off {\n\t\tconst off: Off = () => {\n\t\t\tconst currentListeners = this.listeners.get(eventName);\n\t\t\tif (currentListeners?.delete(off) === true) {\n\t\t\t\tif (currentListeners.size === 0) {\n\t\t\t\t\tthis.listeners.delete(eventName);\n\t\t\t\t\tthis.noListeners?.(eventName);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tgetOrCreate(this.listeners, eventName, () => new Map()).set(off, listener);\n\t\treturn off;\n\t}\n\n\tpublic hasListeners(eventName?: keyof TListeners): boolean {\n\t\tif (eventName === undefined) {\n\t\t\treturn this.listeners.size !== 0;\n\t\t}\n\t\treturn this.listeners.has(eventName);\n\t}\n}\n\n/**\n * This class exposes the constructor and the `emit` method of `EventEmitter`, elevating them from protected to public\n */\nexport class ComposableEventEmitter<TListeners extends Listeners<TListeners>>\n\textends EventEmitter<TListeners>\n\timplements IEmitter<TListeners>\n{\n\tpublic constructor(noListeners?: NoListenersCallback<TListeners>) {\n\t\tsuper(noListeners);\n\t}\n\n\tpublic override emit<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): void {\n\t\treturn super.emit(eventName, ...args);\n\t}\n\n\tpublic override emitAndCollect<K extends keyof TListeners>(\n\t\teventName: K,\n\t\t...args: Parameters<TListeners[K]>\n\t): ReturnType<TListeners[K]>[] {\n\t\treturn super.emitAndCollect(eventName, ...args);\n\t}\n}\n"]}
|
|
@@ -102,13 +102,11 @@ export declare class EagerMapTreeMapNode<TSchema extends FlexMapNodeSchema> exte
|
|
|
102
102
|
FieldKey,
|
|
103
103
|
FlexTreeUnboxField<TSchema["info"], "notEmpty">
|
|
104
104
|
]>;
|
|
105
|
-
forEach(callbackFn: (value: FlexTreeUnboxField<TSchema["info"], "notEmpty">, key: FieldKey, map: FlexTreeMapNode<TSchema>) => void, thisArg?: unknown): void;
|
|
106
105
|
getBoxed(key: string): FlexTreeTypedField<TSchema["info"]>;
|
|
107
106
|
[Symbol.iterator](): IterableIterator<[
|
|
108
107
|
FieldKey,
|
|
109
108
|
FlexTreeUnboxField<TSchema["info"], "notEmpty">
|
|
110
109
|
]>;
|
|
111
|
-
boxedIterator(): IterableIterator<FlexTreeTypedField<TSchema["info"]>>;
|
|
112
110
|
}
|
|
113
111
|
/**
|
|
114
112
|
* A readonly {@link FlexTreeField} which wraps an array of {@link MapTrees}.
|
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agerMapTreeNode {
|
|
|
135
135
|
unboxedField(this.tryGetField(key) ?? fail("Unexpected empty map field"), key, this.mapTree, this),
|
|
136
136
|
]);
|
|
137
137
|
}
|
|
138
|
-
forEach(callbackFn, thisArg) {
|
|
139
|
-
const fn = thisArg !== undefined ? callbackFn.bind(thisArg) : callbackFn;
|
|
140
|
-
for (const [key, value] of this.entries()) {
|
|
141
|
-
fn(value, key, this);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
138
|
getBoxed(key) {
|
|
145
139
|
return super.getBoxed(key);
|
|
146
140
|
}
|
|
147
141
|
[Symbol.iterator]() {
|
|
148
142
|
return this.entries();
|
|
149
143
|
}
|
|
150
|
-
boxedIterator() {
|
|
151
|
-
return super.boxedIterator();
|
|
152
|
-
}
|
|
153
144
|
}
|
|
154
145
|
class EagerMapTreeLeafNode extends EagerMapTreeNode {
|
|
155
146
|
get value() {
|
|
@@ -342,9 +333,6 @@ class EagerMapTreeSequenceField extends EagerMapTreeField {
|
|
|
342
333
|
map(callbackfn) {
|
|
343
334
|
return Array.from(this, callbackfn);
|
|
344
335
|
}
|
|
345
|
-
mapBoxed(callbackfn) {
|
|
346
|
-
return Array.from(this.boxedIterator(), callbackfn);
|
|
347
|
-
}
|
|
348
336
|
*[Symbol.iterator]() {
|
|
349
337
|
for (const [i, mapTree] of this.mapTrees.entries()) {
|
|
350
338
|
yield unboxedUnion(this.schema, mapTree, { parent: this, index: i });
|