@fluid-experimental/tree 2.0.0-dev.4.4.0.162574 → 2.0.0-dev.5.2.0.169897

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/Checkout.d.ts.map +1 -1
  3. package/dist/Checkout.js.map +1 -1
  4. package/dist/EditLog.d.ts +3 -2
  5. package/dist/EditLog.d.ts.map +1 -1
  6. package/dist/EditLog.js.map +1 -1
  7. package/dist/HistoryEditFactory.d.ts +2 -2
  8. package/dist/HistoryEditFactory.d.ts.map +1 -1
  9. package/dist/HistoryEditFactory.js.map +1 -1
  10. package/dist/MergeHealth.d.ts.map +1 -1
  11. package/dist/MergeHealth.js.map +1 -1
  12. package/dist/SharedTree.d.ts +4 -3
  13. package/dist/SharedTree.d.ts.map +1 -1
  14. package/dist/SharedTree.js.map +1 -1
  15. package/dist/id-compressor/IdCompressor.d.ts +2 -2
  16. package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
  17. package/dist/id-compressor/IdCompressor.js.map +1 -1
  18. package/dist/id-compressor/Logger.d.ts +2 -2
  19. package/dist/id-compressor/Logger.d.ts.map +1 -1
  20. package/dist/id-compressor/Logger.js.map +1 -1
  21. package/dist/tsdoc-metadata.json +11 -0
  22. package/lib/Checkout.d.ts.map +1 -1
  23. package/lib/Checkout.js.map +1 -1
  24. package/lib/EditLog.d.ts +3 -2
  25. package/lib/EditLog.d.ts.map +1 -1
  26. package/lib/EditLog.js.map +1 -1
  27. package/lib/HistoryEditFactory.d.ts +2 -2
  28. package/lib/HistoryEditFactory.d.ts.map +1 -1
  29. package/lib/HistoryEditFactory.js.map +1 -1
  30. package/lib/MergeHealth.d.ts.map +1 -1
  31. package/lib/MergeHealth.js.map +1 -1
  32. package/lib/SharedTree.d.ts +4 -3
  33. package/lib/SharedTree.d.ts.map +1 -1
  34. package/lib/SharedTree.js +1 -1
  35. package/lib/SharedTree.js.map +1 -1
  36. package/lib/id-compressor/IdCompressor.d.ts +2 -2
  37. package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
  38. package/lib/id-compressor/IdCompressor.js.map +1 -1
  39. package/lib/id-compressor/Logger.d.ts +2 -2
  40. package/lib/id-compressor/Logger.d.ts.map +1 -1
  41. package/lib/id-compressor/Logger.js.map +1 -1
  42. package/lib/test/utilities/IdCompressorTestUtilities.d.ts +2 -2
  43. package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -1
  44. package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -1
  45. package/package.json +21 -23
  46. package/src/Checkout.ts +3 -3
  47. package/src/EditLog.ts +3 -2
  48. package/src/HistoryEditFactory.ts +2 -2
  49. package/src/MergeHealth.ts +2 -2
  50. package/src/SharedTree.ts +10 -5
  51. package/src/id-compressor/IdCompressor.ts +2 -2
  52. package/src/id-compressor/Logger.ts +5 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @fluid-experimental/tree
2
2
 
3
+ ## 2.0.0-internal.5.0.0
4
+
5
+ Dependency updates only.
6
+
7
+ ## 2.0.0-internal.4.4.0
8
+
9
+ Dependency updates only.
10
+
3
11
  ## 2.0.0-internal.4.1.0
4
12
 
5
13
  Dependency updates only.
@@ -1 +1 @@
1
- {"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAe,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,WAAW,EAA0C,MAAM,oCAAoC,CAAC;AAEtH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,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AQ,GAAG,IAAI,CAAC,YAAY,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;YAC5C,6GAA6G;YAC7G,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;SACvD;IACF,CAAC;IAaD;;;OAGG;IACI,OAAO,CAAC,KAAa;QAC3B,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO;SACP;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,6BAA6B;QAC7B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,4BAAe,CAAC,aAAa,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACzE,CAAC;CACD;AArWD,4BAqWC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/common-utils';\nimport { ChildLogger, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';\nimport { IDisposable, IErrorEvent, ITelemetryLogger, ITelemetryProperties } from '@fluidframework/common-definitions';\nimport { assertWithMessage, fail, RestOrArray, unwrapRestOrArray } from './Common';\nimport { EditId } from './Identifiers';\nimport { CachingLogViewer } from './LogViewer';\nimport { TreeView } from './TreeView';\nimport { RevisionView } from './RevisionView';\nimport { EditCommittedHandler, SharedTree } from './SharedTree';\nimport { EditingResult, GenericTransaction, TransactionInternal, ValidEditingResult } from './TransactionInternal';\nimport { ChangeInternal, Edit, EditStatus } from './persisted-types';\nimport { SharedTreeEvent } from './EventTypes';\nimport { newEditId } from './EditUtilities';\nimport { Change } from './ChangeTypes';\n\n/**\n * An event emitted by a `Checkout` to indicate a state change. See {@link ICheckoutEvents} for event argument information.\n * @public\n */\nexport enum CheckoutEvent {\n\t/**\n\t * `currentView` has changed.\n\t * Passed a before and after TreeView.\n\t */\n\tViewChange = 'viewChange',\n}\n\n/**\n * Events which may be emitted by `Checkout`. See {@link CheckoutEvent} for documentation of event semantics.\n */\nexport interface ICheckoutEvents extends IErrorEvent {\n\t(event: 'viewChange', listener: (before: TreeView, after: TreeView) => void);\n}\n\n/**\n * The result of validation of an Edit.\n * @public\n */\nexport enum EditValidationResult {\n\t/**\n\t * The edit contained one or more malformed changes (e.g. was missing required fields such as `id`),\n\t * or contained a sequence of changes that could not possibly be applied sequentially without error\n\t * (e.g. an edit which tries to insert the same detached node twice).\n\t */\n\tMalformed,\n\t/**\n\t * The edit is well-formed but cannot be applied to the current view, generally because concurrent changes\n\t * caused one or more merge conflicts.\n\t * For example, the edit refers to the `StablePlace` after node `C`, but `C` has since been deleted.\n\t */\n\tInvalid,\n\t/**\n\t * The edit is well-formed and can be applied to the current view.\n\t */\n\tValid,\n}\n\n/**\n * A mutable Checkout of a SharedTree, allowing viewing and interactive transactional editing.\n * Provides {@link https://en.wikipedia.org/wiki/Snapshot_isolation | snapshot-isolation} while editing.\n *\n * A Checkout always shows a consistent sequence of versions of the SharedTree, but it may skip intermediate versions, and may fall behind.\n * In this case consistent means the sequence of versions could occur with fully synchronous shared tree access,\n * though the timing of sequenced edits arriving to the Checkout may be later than they actually arrive in the SharedTree.\n * Specifically no sequenced edits will arrive during an ongoing edit (to implement snapshot isolation):\n * they will be applied asynchronously some time after the ongoing edit is ended.\n *\n * Events emitted by `Checkout` are documented in {@link CheckoutEvent}.\n * Exceptions thrown during event handling will be emitted as error events, which are automatically surfaced as error events on the\n * `SharedTree` used at construction time.\n * @public\n */\nexport abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEvents> implements IDisposable {\n\t/**\n\t * The view of the latest committed revision.\n\t * Does not include changes from any open edits.\n\t *\n\t * When this changes, emitChange must be called.\n\t */\n\tprotected abstract get latestCommittedView(): RevisionView;\n\n\t/**\n\t * The last view for which invalidation was sent.\n\t * Updated by emitChange.\n\t */\n\tprivate previousView: TreeView;\n\n\t/**\n\t * A handler for 'committedEdit' SharedTreeEvent\n\t */\n\tprivate readonly editCommittedHandler: EditCommittedHandler;\n\n\t/**\n\t * The shared tree this checkout views/edits.\n\t */\n\tpublic readonly tree: SharedTree;\n\n\t/**\n\t * `tree`'s log viewer as a CachingLogViewer if it is one, otherwise undefined.\n\t * Used for optimizations if provided.\n\t */\n\tprivate readonly cachingLogViewer?: CachingLogViewer;\n\n\t/**\n\t * Holds the state required to manage the currently open edit.\n\t * Undefined if there is currently not an open edit.\n\t *\n\t * Since `currentView` exposes the the intermediate state from this edit,\n\t * operations that modify `currentEdit.view` must call `emitChange` to handle invalidation.\n\t */\n\tprivate currentEdit?: GenericTransaction;\n\n\tprivate readonly logger: ITelemetryLogger;\n\n\tpublic disposed: boolean = false;\n\n\tprotected constructor(tree: SharedTree, currentView: RevisionView, onEditCommitted: EditCommittedHandler) {\n\t\tsuper((_event, error: unknown) => {\n\t\t\tthis.tree.emit('error', error);\n\t\t});\n\t\tthis.tree = tree;\n\t\tthis.logger = ChildLogger.create(this.tree.logger, 'Checkout');\n\t\tif (tree.logViewer instanceof CachingLogViewer) {\n\t\t\tthis.cachingLogViewer = tree.logViewer;\n\t\t}\n\t\tthis.previousView = currentView;\n\t\tthis.editCommittedHandler = onEditCommitted;\n\n\t\t// If there is an ongoing edit, emitChange will no-op, which is fine.\n\t\tthis.tree.on(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n\n\t/**\n\t * @returns the current view of the tree, including the result of changes applied so far during an edit.\n\t * Note that any external edits (from other clients) will not added to view while there is a `currentEdit`.\n\t */\n\tpublic get currentView(): TreeView {\n\t\treturn this.currentEdit?.view ?? this.latestCommittedView;\n\t}\n\n\t/**\n\t * @returns true iff there is an open edit.\n\t * @internal\n\t */\n\tpublic hasOpenEdit(): boolean {\n\t\treturn this.currentEdit !== undefined;\n\t}\n\n\t/**\n\t * Opens a new edit operation.\n\t * Changes accumulate in the edit via calls to `applyChanges()`.\n\t */\n\tpublic openEdit(): void {\n\t\tassert(this.currentEdit === undefined, 0x600 /* An edit is already open. */);\n\t\tthis.currentEdit = TransactionInternal.factory(this.latestCommittedView);\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation and commits it to the history.\n\t *\n\t * Malformed edits are considered an error, and will assert:\n\t * All named detached sequences must have been used or the Edit is malformed.\n\t *\n\t * @returns the `id` of the committed edit\n\t */\n\tpublic closeEdit(): EditId {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 0x601 /* An edit is not open. */);\n\t\tthis.currentEdit = undefined;\n\t\tassert(\n\t\t\tcurrentEdit.failure === undefined,\n\t\t\t0x66d /* Cannot close a transaction that has already failed. Use abortEdit instead. */\n\t\t);\n\n\t\tconst editingResult = currentEdit.close();\n\t\tthis.validateChangesApplied(editingResult);\n\t\tconst id: EditId = newEditId();\n\t\tthis.handleNewEdit(id, editingResult);\n\t\treturn id;\n\t}\n\n\tprivate validateChangesApplied(result: EditingResult): asserts result is ValidEditingResult;\n\tprivate validateChangesApplied(result: {\n\t\tstatus: EditStatus;\n\t\tfailure: TransactionInternal.Failure | undefined;\n\t}): asserts result is { status: EditStatus.Applied; failure: undefined };\n\tprivate validateChangesApplied(\n\t\tresult: EditingResult | { status: EditStatus; failure: TransactionInternal.Failure | undefined }\n\t) {\n\t\tif (result.status === EditStatus.Applied) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { failure } = result as { failure: TransactionInternal.Failure };\n\t\tconst additionalProps: ITelemetryProperties = {};\n\t\tswitch (failure.kind) {\n\t\t\tcase TransactionInternal.FailureKind.BadPlace:\n\t\t\t\tadditionalProps.placeFailure = failure.placeFailure;\n\t\t\t\tbreak;\n\t\t\tcase TransactionInternal.FailureKind.BadRange: {\n\t\t\t\tconst { rangeFailure } = failure;\n\t\t\t\tif (typeof rangeFailure === 'string') {\n\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure;\n\t\t\t\t} else {\n\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure.kind;\n\t\t\t\t\tadditionalProps.rangeEndpointFailure = rangeFailure.placeFailure;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\n\t\tthis.logger.sendErrorEvent({\n\t\t\teventName: 'FailedLocalEdit',\n\t\t\tstatus: result.status === 0 ? 'Malformed' : 'Invalid',\n\t\t\tfailureKind: failure.kind,\n\t\t\t...additionalProps,\n\t\t});\n\t\tfail('Locally constructed edits must be well-formed and valid.');\n\t}\n\n\t/**\n\t * Inform the Checkout that a particular edit is know to have a specific result when applied to a particular TreeView.\n\t * This may be used as a caching hint to avoid recomputation.\n\t */\n\tprotected hintKnownEditingResult(edit: Edit<ChangeInternal>, result: ValidEditingResult): void {\n\t\t// As an optimization, inform logViewer of this editing result so it can reuse it if applied to the same before revision.\n\t\tthis.cachingLogViewer?.setKnownEditingResult(edit, result);\n\t}\n\n\t/**\n\t * Take any needed action between when an edit is completed.\n\t * Usually this will include submitting it to a SharedTree.\n\t *\n\t * Override this to customize.\n\t */\n\tprotected handleNewEdit(id: EditId, result: ValidEditingResult): void {\n\t\tconst edit: Edit<ChangeInternal> = { id, changes: result.changes };\n\n\t\tthis.hintKnownEditingResult(edit, result);\n\n\t\t// Since external edits could have been applied while currentEdit was pending,\n\t\t// do not use the produced view: just go to the newest revision\n\t\t// (which processLocalEdit will do, including invalidation).\n\t\tthis.tree.applyEditInternal(edit);\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tpublic applyChanges(changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: RestOrArray<Change>): void {\n\t\tassert(this.currentEdit !== undefined, 0x602 /* Changes must be applied as part of an ongoing edit. */);\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tthis.validateChangesApplied({ status, failure: this.currentEdit.failure });\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tprotected tryApplyChangesInternal(changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: RestOrArray<ChangeInternal>): EditStatus {\n\t\tassert(this.currentEdit !== undefined, 0x603 /* Changes must be applied as part of an ongoing edit. */);\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray);\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t}\n\t\treturn status;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t */\n\tpublic applyEdit(changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: RestOrArray<Change>): EditId {\n\t\tthis.openEdit();\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tthis.applyChanges(changeArray);\n\t\treturn this.closeEdit();\n\t}\n\n\t/**\n\t * Apply an edit, if valid, otherwise does nothing (the edit is not added to the history).\n\t * If the edit applied, its changes will be immediately visible on this checkout, though it still may end up invalid once sequenced due to concurrent edits.\n\t * @returns The EditId if the edit was valid and thus applied, and undefined if it was invalid and thus not applied.\n\t */\n\tpublic tryApplyEdit(changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: RestOrArray<Change>): EditId | undefined {\n\t\tthis.openEdit();\n\n\t\tassert(this.currentEdit !== undefined, 0x604 /* Changes must be applied as part of an ongoing edit. */);\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t\treturn this.closeEdit();\n\t\t}\n\n\t\tthis.abortEdit();\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Rebases the ongoing edit to the latest revision loaded by this 'Checkout'.\n\t * If the rebase succeeds (none of the changes in the ongoing edit became invalid), the ongoing edit will remain open and the current\n\t * view will reflect those changes.\n\t *\n\t * If the rebase fails (changes become invalid), the ongoing edit will be aborted and\n\t * currentView will return to showing the newest committed revision as it always does when there is no ongoing edit.\n\t *\n\t * Must only be called during an open edit.\n\t * @returns - the result of the rebase.\n\t */\n\tpublic rebaseCurrentEdit(): EditValidationResult.Valid | EditValidationResult.Invalid {\n\t\tassert(this.currentEdit !== undefined, 0x605 /* An edit is not open. */);\n\t\tassert(this.currentEdit.status === EditStatus.Applied, 0x606 /* Local edits should always be valid. */);\n\t\t// When closed, the result might indicate Malformed due to unused detached entities.\n\t\t// This is not an error, as the edit was still open and can still use those entities.\n\t\tconst priorResults = this.currentEdit.close();\n\t\tconst rebasedEdit = TransactionInternal.factory(this.latestCommittedView).applyChanges(priorResults.changes);\n\t\tassert(\n\t\t\trebasedEdit.status !== EditStatus.Malformed,\n\t\t\t0x607 /* Malformed changes should have been caught on original application. */\n\t\t);\n\t\tlet status: EditValidationResult.Valid | EditValidationResult.Invalid;\n\t\tif (rebasedEdit.status === EditStatus.Invalid) {\n\t\t\tstatus = EditValidationResult.Invalid;\n\t\t\tthis.currentEdit = undefined;\n\t\t} else {\n\t\t\tstatus = EditValidationResult.Valid;\n\t\t\tthis.currentEdit = rebasedEdit;\n\t\t}\n\t\tthis.emitChange();\n\t\treturn status;\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation without committing it to the history.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic abortEdit(): void {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 0x608 /* An edit is not open. */);\n\t\tthis.currentEdit = undefined;\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * @returns the {@link EditStatus} of the current edit.\n\t * Has no side effects.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic getEditStatus(): EditStatus {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 0x609 /* An edit is not open. */);\n\t\t// TODO: could this ever be anything other than 'Applied'\n\t\t// TODO: shouldn't this be an EditValidationResult since 'Applied' does not indicate the edit has been applied?\n\t\treturn currentEdit.status;\n\t}\n\n\t/**\n\t * Reverts a collection of edits.\n\t * @param editIds - the edits to revert\n\t */\n\tpublic revert(editId: EditId): void {\n\t\tassertWithMessage(this.currentEdit !== undefined);\n\t\tconst index = this.tree.edits.getIndexOfId(editId);\n\t\tconst edit =\n\t\t\tthis.tree.edits.tryGetEditAtIndex(index) ?? fail('Edit with the specified ID does not exist in memory');\n\t\tconst before = this.tree.logViewer.getRevisionViewInMemory(index);\n\t\tconst changes = this.tree.revertChanges(edit.changes, before);\n\t\tif (changes !== undefined) {\n\t\t\tthis.tryApplyChangesInternal(changes);\n\t\t}\n\t}\n\n\t/**\n\t * Send invalidation message for all changes since last call to emitChange.\n\t * This must be called every time `currentView` could have changed.\n\t * It is ok to make excessive calls to this: change notifications will be cheaply de-duplicated.\n\t */\n\tprotected emitChange(): void {\n\t\tconst current = this.currentView;\n\t\tconst previous = this.previousView;\n\t\tif (!previous.hasEqualForest(current, true)) {\n\t\t\t// Set previousView before calling emit to make reentrant case work (where the event handler causes an edit).\n\t\t\tthis.previousView = current;\n\t\t\tthis.emit(CheckoutEvent.ViewChange, previous, current);\n\t\t}\n\t}\n\n\t/**\n\t * @returns a Promise which completes after all currently known edits are available in this checkout.\n\t */\n\tpublic abstract waitForPendingUpdates(): Promise<void>;\n\n\t/**\n\t * @returns a Promise which completes after edits that were closed on this checkout (before calling this) have been\n\t * submitted to Fluid. This does NOT wait for the Fluid service to ack them\n\t */\n\tpublic abstract waitForEditsToSubmit(): Promise<void>;\n\n\t/**\n\t * release all unmanaged resources\n\t * e.g. unregister event listeners\n\t */\n\tpublic dispose(error?: Error): void {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.disposed = true;\n\n\t\t// remove registered listener\n\t\tthis.tree.off(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n}\n"]}
1
+ {"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../src/Checkout.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,qEAAkH;AAElH,qCAAmF;AAEnF,2CAA+C;AAI/C,+DAAmH;AACnH,uDAAqE;AACrE,6CAA+C;AAC/C,mDAA4C;AAG5C;;;GAGG;AACH,IAAY,aAMX;AAND,WAAY,aAAa;IACxB;;;OAGG;IACH,0CAAyB,CAAA;AAC1B,CAAC,EANW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAMxB;AASD;;;GAGG;AACH,IAAY,oBAiBX;AAjBD,WAAY,oBAAoB;IAC/B;;;;OAIG;IACH,yEAAS,CAAA;IACT;;;;OAIG;IACH,qEAAO,CAAA;IACP;;OAEG;IACH,iEAAK,CAAA;AACN,CAAC,EAjBW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAiB/B;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAsB,QAAS,SAAQ,+CAA8C;IA4CpF,YAAsB,IAAgB,EAAE,WAAyB,EAAE,eAAqC;QACvG,KAAK,CAAC,CAAC,MAAM,EAAE,KAAc,EAAE,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;QALG,aAAQ,GAAY,KAAK,CAAC;QAMhC,IAAI,CAAC,IAAI,GAAG,IAAI,CAA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WD,4BAqWC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/common-utils';\nimport { ChildLogger, EventEmitterWithErrorHandling, ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';\nimport { IDisposable, IErrorEvent, ITelemetryProperties } from '@fluidframework/common-definitions';\nimport { assertWithMessage, fail, RestOrArray, unwrapRestOrArray } from './Common';\nimport { EditId } from './Identifiers';\nimport { CachingLogViewer } from './LogViewer';\nimport { TreeView } from './TreeView';\nimport { RevisionView } from './RevisionView';\nimport { EditCommittedHandler, SharedTree } from './SharedTree';\nimport { EditingResult, GenericTransaction, TransactionInternal, ValidEditingResult } from './TransactionInternal';\nimport { ChangeInternal, Edit, EditStatus } from './persisted-types';\nimport { SharedTreeEvent } from './EventTypes';\nimport { newEditId } from './EditUtilities';\nimport { Change } from './ChangeTypes';\n\n/**\n * An event emitted by a `Checkout` to indicate a state change. See {@link ICheckoutEvents} for event argument information.\n * @public\n */\nexport enum CheckoutEvent {\n\t/**\n\t * `currentView` has changed.\n\t * Passed a before and after TreeView.\n\t */\n\tViewChange = 'viewChange',\n}\n\n/**\n * Events which may be emitted by `Checkout`. See {@link CheckoutEvent} for documentation of event semantics.\n */\nexport interface ICheckoutEvents extends IErrorEvent {\n\t(event: 'viewChange', listener: (before: TreeView, after: TreeView) => void);\n}\n\n/**\n * The result of validation of an Edit.\n * @public\n */\nexport enum EditValidationResult {\n\t/**\n\t * The edit contained one or more malformed changes (e.g. was missing required fields such as `id`),\n\t * or contained a sequence of changes that could not possibly be applied sequentially without error\n\t * (e.g. an edit which tries to insert the same detached node twice).\n\t */\n\tMalformed,\n\t/**\n\t * The edit is well-formed but cannot be applied to the current view, generally because concurrent changes\n\t * caused one or more merge conflicts.\n\t * For example, the edit refers to the `StablePlace` after node `C`, but `C` has since been deleted.\n\t */\n\tInvalid,\n\t/**\n\t * The edit is well-formed and can be applied to the current view.\n\t */\n\tValid,\n}\n\n/**\n * A mutable Checkout of a SharedTree, allowing viewing and interactive transactional editing.\n * Provides {@link https://en.wikipedia.org/wiki/Snapshot_isolation | snapshot-isolation} while editing.\n *\n * A Checkout always shows a consistent sequence of versions of the SharedTree, but it may skip intermediate versions, and may fall behind.\n * In this case consistent means the sequence of versions could occur with fully synchronous shared tree access,\n * though the timing of sequenced edits arriving to the Checkout may be later than they actually arrive in the SharedTree.\n * Specifically no sequenced edits will arrive during an ongoing edit (to implement snapshot isolation):\n * they will be applied asynchronously some time after the ongoing edit is ended.\n *\n * Events emitted by `Checkout` are documented in {@link CheckoutEvent}.\n * Exceptions thrown during event handling will be emitted as error events, which are automatically surfaced as error events on the\n * `SharedTree` used at construction time.\n * @public\n */\nexport abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEvents> implements IDisposable {\n\t/**\n\t * The view of the latest committed revision.\n\t * Does not include changes from any open edits.\n\t *\n\t * When this changes, emitChange must be called.\n\t */\n\tprotected abstract get latestCommittedView(): RevisionView;\n\n\t/**\n\t * The last view for which invalidation was sent.\n\t * Updated by emitChange.\n\t */\n\tprivate previousView: TreeView;\n\n\t/**\n\t * A handler for 'committedEdit' SharedTreeEvent\n\t */\n\tprivate readonly editCommittedHandler: EditCommittedHandler;\n\n\t/**\n\t * The shared tree this checkout views/edits.\n\t */\n\tpublic readonly tree: SharedTree;\n\n\t/**\n\t * `tree`'s log viewer as a CachingLogViewer if it is one, otherwise undefined.\n\t * Used for optimizations if provided.\n\t */\n\tprivate readonly cachingLogViewer?: CachingLogViewer;\n\n\t/**\n\t * Holds the state required to manage the currently open edit.\n\t * Undefined if there is currently not an open edit.\n\t *\n\t * Since `currentView` exposes the the intermediate state from this edit,\n\t * operations that modify `currentEdit.view` must call `emitChange` to handle invalidation.\n\t */\n\tprivate currentEdit?: GenericTransaction;\n\n\tprivate readonly logger: ITelemetryLoggerExt;\n\n\tpublic disposed: boolean = false;\n\n\tprotected constructor(tree: SharedTree, currentView: RevisionView, onEditCommitted: EditCommittedHandler) {\n\t\tsuper((_event, error: unknown) => {\n\t\t\tthis.tree.emit('error', error);\n\t\t});\n\t\tthis.tree = tree;\n\t\tthis.logger = ChildLogger.create(this.tree.logger, 'Checkout');\n\t\tif (tree.logViewer instanceof CachingLogViewer) {\n\t\t\tthis.cachingLogViewer = tree.logViewer;\n\t\t}\n\t\tthis.previousView = currentView;\n\t\tthis.editCommittedHandler = onEditCommitted;\n\n\t\t// If there is an ongoing edit, emitChange will no-op, which is fine.\n\t\tthis.tree.on(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n\n\t/**\n\t * @returns the current view of the tree, including the result of changes applied so far during an edit.\n\t * Note that any external edits (from other clients) will not added to view while there is a `currentEdit`.\n\t */\n\tpublic get currentView(): TreeView {\n\t\treturn this.currentEdit?.view ?? this.latestCommittedView;\n\t}\n\n\t/**\n\t * @returns true iff there is an open edit.\n\t * @internal\n\t */\n\tpublic hasOpenEdit(): boolean {\n\t\treturn this.currentEdit !== undefined;\n\t}\n\n\t/**\n\t * Opens a new edit operation.\n\t * Changes accumulate in the edit via calls to `applyChanges()`.\n\t */\n\tpublic openEdit(): void {\n\t\tassert(this.currentEdit === undefined, 0x600 /* An edit is already open. */);\n\t\tthis.currentEdit = TransactionInternal.factory(this.latestCommittedView);\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation and commits it to the history.\n\t *\n\t * Malformed edits are considered an error, and will assert:\n\t * All named detached sequences must have been used or the Edit is malformed.\n\t *\n\t * @returns the `id` of the committed edit\n\t */\n\tpublic closeEdit(): EditId {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 0x601 /* An edit is not open. */);\n\t\tthis.currentEdit = undefined;\n\t\tassert(\n\t\t\tcurrentEdit.failure === undefined,\n\t\t\t0x66d /* Cannot close a transaction that has already failed. Use abortEdit instead. */\n\t\t);\n\n\t\tconst editingResult = currentEdit.close();\n\t\tthis.validateChangesApplied(editingResult);\n\t\tconst id: EditId = newEditId();\n\t\tthis.handleNewEdit(id, editingResult);\n\t\treturn id;\n\t}\n\n\tprivate validateChangesApplied(result: EditingResult): asserts result is ValidEditingResult;\n\tprivate validateChangesApplied(result: {\n\t\tstatus: EditStatus;\n\t\tfailure: TransactionInternal.Failure | undefined;\n\t}): asserts result is { status: EditStatus.Applied; failure: undefined };\n\tprivate validateChangesApplied(\n\t\tresult: EditingResult | { status: EditStatus; failure: TransactionInternal.Failure | undefined }\n\t) {\n\t\tif (result.status === EditStatus.Applied) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { failure } = result as { failure: TransactionInternal.Failure };\n\t\tconst additionalProps: ITelemetryProperties = {};\n\t\tswitch (failure.kind) {\n\t\t\tcase TransactionInternal.FailureKind.BadPlace:\n\t\t\t\tadditionalProps.placeFailure = failure.placeFailure;\n\t\t\t\tbreak;\n\t\t\tcase TransactionInternal.FailureKind.BadRange: {\n\t\t\t\tconst { rangeFailure } = failure;\n\t\t\t\tif (typeof rangeFailure === 'string') {\n\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure;\n\t\t\t\t} else {\n\t\t\t\t\tadditionalProps.rangeFailure = rangeFailure.kind;\n\t\t\t\t\tadditionalProps.rangeEndpointFailure = rangeFailure.placeFailure;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\n\t\tthis.logger.sendErrorEvent({\n\t\t\teventName: 'FailedLocalEdit',\n\t\t\tstatus: result.status === 0 ? 'Malformed' : 'Invalid',\n\t\t\tfailureKind: failure.kind,\n\t\t\t...additionalProps,\n\t\t});\n\t\tfail('Locally constructed edits must be well-formed and valid.');\n\t}\n\n\t/**\n\t * Inform the Checkout that a particular edit is know to have a specific result when applied to a particular TreeView.\n\t * This may be used as a caching hint to avoid recomputation.\n\t */\n\tprotected hintKnownEditingResult(edit: Edit<ChangeInternal>, result: ValidEditingResult): void {\n\t\t// As an optimization, inform logViewer of this editing result so it can reuse it if applied to the same before revision.\n\t\tthis.cachingLogViewer?.setKnownEditingResult(edit, result);\n\t}\n\n\t/**\n\t * Take any needed action between when an edit is completed.\n\t * Usually this will include submitting it to a SharedTree.\n\t *\n\t * Override this to customize.\n\t */\n\tprotected handleNewEdit(id: EditId, result: ValidEditingResult): void {\n\t\tconst edit: Edit<ChangeInternal> = { id, changes: result.changes };\n\n\t\tthis.hintKnownEditingResult(edit, result);\n\n\t\t// Since external edits could have been applied while currentEdit was pending,\n\t\t// do not use the produced view: just go to the newest revision\n\t\t// (which processLocalEdit will do, including invalidation).\n\t\tthis.tree.applyEditInternal(edit);\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tpublic applyChanges(changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: readonly Change[]): void;\n\tpublic applyChanges(...changes: RestOrArray<Change>): void {\n\t\tassert(this.currentEdit !== undefined, 0x602 /* Changes must be applied as part of an ongoing edit. */);\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tthis.validateChangesApplied({ status, failure: this.currentEdit.failure });\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * Applies the supplied changes to the tree and emits a change event.\n\t * Must be called during an ongoing edit (see `openEdit()`/`closeEdit()`).\n\t * `changes` must be well-formed and valid: it is an error if they do not apply cleanly.\n\t */\n\tprotected tryApplyChangesInternal(changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: readonly ChangeInternal[]): EditStatus;\n\tprotected tryApplyChangesInternal(...changes: RestOrArray<ChangeInternal>): EditStatus {\n\t\tassert(this.currentEdit !== undefined, 0x603 /* Changes must be applied as part of an ongoing edit. */);\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray);\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t}\n\t\treturn status;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t */\n\tpublic applyEdit(changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: readonly Change[]): EditId;\n\tpublic applyEdit(...changes: RestOrArray<Change>): EditId {\n\t\tthis.openEdit();\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tthis.applyChanges(changeArray);\n\t\treturn this.closeEdit();\n\t}\n\n\t/**\n\t * Apply an edit, if valid, otherwise does nothing (the edit is not added to the history).\n\t * If the edit applied, its changes will be immediately visible on this checkout, though it still may end up invalid once sequenced due to concurrent edits.\n\t * @returns The EditId if the edit was valid and thus applied, and undefined if it was invalid and thus not applied.\n\t */\n\tpublic tryApplyEdit(changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: readonly Change[]): EditId | undefined;\n\tpublic tryApplyEdit(...changes: RestOrArray<Change>): EditId | undefined {\n\t\tthis.openEdit();\n\n\t\tassert(this.currentEdit !== undefined, 0x604 /* Changes must be applied as part of an ongoing edit. */);\n\t\tconst changeArray = unwrapRestOrArray(changes);\n\t\tconst { status } = this.currentEdit.applyChanges(changeArray.map((c) => this.tree.internalizeChange(c)));\n\t\tif (status === EditStatus.Applied) {\n\t\t\tthis.emitChange();\n\t\t\treturn this.closeEdit();\n\t\t}\n\n\t\tthis.abortEdit();\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Rebases the ongoing edit to the latest revision loaded by this 'Checkout'.\n\t * If the rebase succeeds (none of the changes in the ongoing edit became invalid), the ongoing edit will remain open and the current\n\t * view will reflect those changes.\n\t *\n\t * If the rebase fails (changes become invalid), the ongoing edit will be aborted and\n\t * currentView will return to showing the newest committed revision as it always does when there is no ongoing edit.\n\t *\n\t * Must only be called during an open edit.\n\t * @returns - the result of the rebase.\n\t */\n\tpublic rebaseCurrentEdit(): EditValidationResult.Valid | EditValidationResult.Invalid {\n\t\tassert(this.currentEdit !== undefined, 0x605 /* An edit is not open. */);\n\t\tassert(this.currentEdit.status === EditStatus.Applied, 0x606 /* Local edits should always be valid. */);\n\t\t// When closed, the result might indicate Malformed due to unused detached entities.\n\t\t// This is not an error, as the edit was still open and can still use those entities.\n\t\tconst priorResults = this.currentEdit.close();\n\t\tconst rebasedEdit = TransactionInternal.factory(this.latestCommittedView).applyChanges(priorResults.changes);\n\t\tassert(\n\t\t\trebasedEdit.status !== EditStatus.Malformed,\n\t\t\t0x607 /* Malformed changes should have been caught on original application. */\n\t\t);\n\t\tlet status: EditValidationResult.Valid | EditValidationResult.Invalid;\n\t\tif (rebasedEdit.status === EditStatus.Invalid) {\n\t\t\tstatus = EditValidationResult.Invalid;\n\t\t\tthis.currentEdit = undefined;\n\t\t} else {\n\t\t\tstatus = EditValidationResult.Valid;\n\t\t\tthis.currentEdit = rebasedEdit;\n\t\t}\n\t\tthis.emitChange();\n\t\treturn status;\n\t}\n\n\t/**\n\t * Ends the ongoing edit operation without committing it to the history.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic abortEdit(): void {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 0x608 /* An edit is not open. */);\n\t\tthis.currentEdit = undefined;\n\t\tthis.emitChange();\n\t}\n\n\t/**\n\t * @returns the {@link EditStatus} of the current edit.\n\t * Has no side effects.\n\t * Can only be called if an edit is open.\n\t */\n\tpublic getEditStatus(): EditStatus {\n\t\tconst { currentEdit } = this;\n\t\tassert(currentEdit !== undefined, 0x609 /* An edit is not open. */);\n\t\t// TODO: could this ever be anything other than 'Applied'\n\t\t// TODO: shouldn't this be an EditValidationResult since 'Applied' does not indicate the edit has been applied?\n\t\treturn currentEdit.status;\n\t}\n\n\t/**\n\t * Reverts a collection of edits.\n\t * @param editIds - the edits to revert\n\t */\n\tpublic revert(editId: EditId): void {\n\t\tassertWithMessage(this.currentEdit !== undefined);\n\t\tconst index = this.tree.edits.getIndexOfId(editId);\n\t\tconst edit =\n\t\t\tthis.tree.edits.tryGetEditAtIndex(index) ?? fail('Edit with the specified ID does not exist in memory');\n\t\tconst before = this.tree.logViewer.getRevisionViewInMemory(index);\n\t\tconst changes = this.tree.revertChanges(edit.changes, before);\n\t\tif (changes !== undefined) {\n\t\t\tthis.tryApplyChangesInternal(changes);\n\t\t}\n\t}\n\n\t/**\n\t * Send invalidation message for all changes since last call to emitChange.\n\t * This must be called every time `currentView` could have changed.\n\t * It is ok to make excessive calls to this: change notifications will be cheaply de-duplicated.\n\t */\n\tprotected emitChange(): void {\n\t\tconst current = this.currentView;\n\t\tconst previous = this.previousView;\n\t\tif (!previous.hasEqualForest(current, true)) {\n\t\t\t// Set previousView before calling emit to make reentrant case work (where the event handler causes an edit).\n\t\t\tthis.previousView = current;\n\t\t\tthis.emit(CheckoutEvent.ViewChange, previous, current);\n\t\t}\n\t}\n\n\t/**\n\t * @returns a Promise which completes after all currently known edits are available in this checkout.\n\t */\n\tpublic abstract waitForPendingUpdates(): Promise<void>;\n\n\t/**\n\t * @returns a Promise which completes after edits that were closed on this checkout (before calling this) have been\n\t * submitted to Fluid. This does NOT wait for the Fluid service to ack them\n\t */\n\tpublic abstract waitForEditsToSubmit(): Promise<void>;\n\n\t/**\n\t * release all unmanaged resources\n\t * e.g. unregister event listeners\n\t */\n\tpublic dispose(error?: Error): void {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.disposed = true;\n\n\t\t// remove registered listener\n\t\tthis.tree.off(SharedTreeEvent.EditCommitted, this.editCommittedHandler);\n\t}\n}\n"]}
package/dist/EditLog.d.ts CHANGED
@@ -3,7 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { TypedEventEmitter } from '@fluidframework/common-utils';
6
- import type { IEvent, ITelemetryLogger } from '@fluidframework/common-definitions';
6
+ import type { IEvent } from '@fluidframework/common-definitions';
7
+ import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
7
8
  import type { EditId } from './Identifiers';
8
9
  import type { StringInterner } from './StringInterner';
9
10
  import { Edit, EditLogSummary, EditWithoutId, FluidEditHandle } from './persisted-types';
@@ -206,7 +207,7 @@ export declare class EditLog<TChange = unknown> extends TypedEventEmitter<IEditL
206
207
  * @param editEvictionHandlers - Handlers that are called before edits are evicted from memory. This provides a chance for
207
208
  * callers to work with the edits before they are lost.
208
209
  */
209
- constructor(summary?: EditLogSummary<TChange, EditHandle<TChange>>, logger?: ITelemetryLogger | undefined, editAddedHandlers?: readonly EditAddedHandler<TChange>[], targetLength?: number, evictionFrequency?: number, editEvictionHandlers?: readonly EditEvictionHandler[]);
210
+ constructor(summary?: EditLogSummary<TChange, EditHandle<TChange>>, logger?: ITelemetryLoggerExt | undefined, editAddedHandlers?: readonly EditAddedHandler<TChange>[], targetLength?: number, evictionFrequency?: number, editEvictionHandlers?: readonly EditEvictionHandler[]);
210
211
  /**
211
212
  * Registers a handler for when an edit is added to this `EditLog`.
212
213
  * @returns A callback which can be invoked to unregister this handler.
@@ -1 +1 @@
1
- {"version":3,"file":"EditLog.d.ts","sourceRoot":"","sources":["../src/EditLog.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAU,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGnF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO,GAAG,OAAO;I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MAAc;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAC3C,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,cAAc,CAAC,KAAa;;QACxC,OAAO,MAAA,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,mCAAI,IAAA,aAAI,EAAC,gBAAgB,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACI,uBAAuB,CAAC,KAAa;;QAC3C,OAAO,MAAA,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,mCAAI,IAAA,aAAI,EAAC,gBAAgB,CAAC,CAAC;IAChE,CAAC;CACD;AA/aD,0BA+aC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport BTree from 'sorted-btree';\nimport { TypedEventEmitter, assert } from '@fluidframework/common-utils';\nimport type { IEvent, ITelemetryLogger } from '@fluidframework/common-definitions';\nimport { compareArrays } from '@fluidframework/core-utils';\nimport { fail } from './Common';\nimport type { EditId } from './Identifiers';\nimport type { StringInterner } from './StringInterner';\nimport { Edit, EditLogSummary, EditWithoutId, FluidEditHandle } from './persisted-types';\nimport type { ChangeCompressor } from './ChangeCompression';\n\n/**\n * An ordered set of Edits associated with a SharedTree.\n * Supports fast lookup of edits by ID and enforces idempotence.\n * @public\n * @sealed\n */\nexport interface OrderedEditSet<TChange = unknown> {\n\t/**\n\t * The length of this `OrderedEditSet`.\n\t */\n\treadonly length: number;\n\n\t/**\n\t * The edit IDs of all edits in the log.\n\t */\n\treadonly editIds: readonly EditId[];\n\n\t/**\n\t * @returns the index of the edit with the given editId within this `OrderedEditSet`.\n\t */\n\tgetIndexOfId(editId: EditId): number;\n\n\t/**\n\t * @returns the id of the edit at the given index within this 'OrderedEditSet'.\n\t */\n\tgetIdAtIndex(index: number): EditId;\n\n\t/**\n\t * @returns the index of the edit with the given editId within this `OrderedEditSet`, or `undefined` if no such edit exists.\n\t */\n\ttryGetIndexOfId(editId: EditId): number | undefined;\n\n\t/**\n\t * @returns the edit at the given index within this `OrderedEditSet`.\n\t */\n\ttryGetEditAtIndex(index: number): Edit<TChange> | undefined;\n\n\t/**\n\t * @returns the edit with the given identifier within this `OrderedEditSet`.\n\t */\n\ttryGetEditFromId(editId: EditId): Edit<TChange> | undefined;\n\n\t/**\n\t * @returns the Edit associated with the EditId or undefined if there is no such edit in the set.\n\t * @deprecated Edit virtualization is no longer supported. Don't use the asynchronous APIs. Instead, use {@link OrderedEditSet.tryGetEditFromId}.\n\t */\n\ttryGetEdit(editId: EditId): Promise<Edit<TChange> | undefined>;\n\n\t/**\n\t * @returns the edit at the given index within this `OrderedEditSet`.\n\t * @deprecated Edit virtualization is no longer supported. Don't use the asynchronous APIs.\n\t */\n\tgetEditAtIndex(index: number): Promise<Edit<TChange>>;\n\n\t/**\n\t * @returns the edit at the given index. Must have been added to the log during the current session.\n\t * @deprecated this will be removed in favor of {@link OrderedEditSet.tryGetEditAtIndex}\n\t */\n\tgetEditInSessionAtIndex(index: number): Edit<TChange>;\n}\n\n/**\n * Server-provided metadata for edits that have been sequenced.\n */\nexport interface EditSequencingInfo {\n\t/**\n\t * The server-assigned sequence number of the op.\n\t */\n\treadonly sequenceNumber: number;\n\t/**\n\t * Last known sequenced edit at the time this op was issued.\n\t */\n\treadonly referenceSequenceNumber: number;\n}\n\n/**\n * Server-provided metadata for edits that have been sequenced.\n */\nexport interface MessageSequencingInfo extends EditSequencingInfo {\n\t/**\n\t * Last sequenced edit that all clients are guaranteed to be aware of.\n\t * If not specified, then some clients have not seen any edits yet.\n\t */\n\treadonly minimumSequenceNumber?: number;\n}\n\n/**\n * Metadata for a sequenced edit.\n */\nexport interface SequencedOrderedEditId {\n\treadonly isLocal: false;\n\treadonly index: number;\n\t/**\n\t * Information about the edit's relationship to other sequenced edits.\n\t * Undefined iff the edit was loaded from a summary.\n\t */\n\treadonly sequenceInfo?: EditSequencingInfo;\n}\n\n/**\n * Metadata for a local edit.\n */\nexport interface LocalOrderedEditId {\n\treadonly isLocal: true;\n\treadonly localSequence: number;\n}\n\n/**\n * Metadata for an edit.\n */\nexport type OrderedEditId = SequencedOrderedEditId | LocalOrderedEditId;\n\n/**\n * Compressor+interner pair used for encoding an {@link EditLog} into a summary.\n * @internal\n */\nexport interface EditLogEncoder {\n\tcompressor: ChangeCompressor;\n\tinterner: StringInterner;\n}\n\n/**\n * A sequence of edits that may or may not need to be downloaded into the EditLog from an external service\n * @deprecated Edit virtualization is no longer supported.\n */\nexport interface EditChunk<TChange> {\n\thandle?: EditHandle<TChange>;\n\tedits?: EditWithoutId<TChange>[];\n}\n/**\n * EditHandles are used to load edit chunks stored outside of the EditLog.\n * This is typically implemented by a wrapper around an IFluidHandle<ArrayBufferLike>.\n * @deprecated Edit virtualization is no longer supported.\n * @public\n */\nexport interface EditHandle<TChange> {\n\treadonly get: () => Promise<EditWithoutId<TChange>[]>;\n\treadonly baseHandle: FluidEditHandle;\n}\n\n/**\n * Returns an object that separates an Edit into two fields, id and editWithoutId.\n */\nexport function separateEditAndId<TChange>(edit: Edit<TChange>): {\n\tid: EditId;\n\teditWithoutId: EditWithoutId<TChange>;\n} {\n\tconst editWithoutId = { ...edit, id: undefined };\n\tdelete editWithoutId.id;\n\treturn { id: edit.id, editWithoutId };\n}\n\n/**\n * @param summary - The edit log summary to parse.\n * @returns the number of handles saved to the provided edit log summary.\n * @deprecated Edit virtualization is no longer supported.\n */\nexport function getNumberOfHandlesFromEditLogSummary(summary: EditLogSummary<unknown, unknown>): number {\n\tconst { editChunks } = summary;\n\n\tlet numberOfHandles = 0;\n\teditChunks.forEach(({ chunk }) => {\n\t\tif (!Array.isArray(chunk)) {\n\t\t\tnumberOfHandles++;\n\t\t}\n\t});\n\n\treturn numberOfHandles;\n}\n\n/**\n * Event fired when an edit is added to an `EditLog`.\n * @param edit - The edit that was added to the log\n * @param isLocal - true iff this edit was generated locally\n */\nexport type EditAddedHandler<TChange> = (edit: Edit<TChange>, isLocal: boolean, wasLocal: boolean) => void;\n\n/**\n * Event fired before edits are evicted from the edit log. It takes in a count of the number of edits to evict\n * starting from the oldest in memory edit. To get the edit itself, call {@link EditLog.getEditAtIndex}.\n * The edit index corresponds to the count + {@link EditLog.earliestAvailableEditIndex}.\n */\nexport type EditEvictionHandler = (editsToEvict: number) => void;\n\n/**\n * Events which may be emitted by {@link EditLog}\n * @public\n */\nexport interface IEditLogEvents extends IEvent {\n\t(event: 'unexpectedHistoryChunk', listener: () => void);\n}\n\n/**\n * The edit history log for SharedTree.\n * Contains only completed edits (no in-progress edits).\n * Ordered first by locality (acked or local), then by time of insertion.\n * May not contain more than one edit with the same ID.\n * @sealed\n */\nexport class EditLog<TChange = unknown> extends TypedEventEmitter<IEditLogEvents> implements OrderedEditSet<TChange> {\n\tprivate localEditSequence = 0;\n\n\tprivate readonly sequenceNumberToIndex?: BTree<number, number>;\n\tprivate _minSequenceNumber = 0;\n\n\tprivate readonly sequencedEdits: Edit<TChange>[] = [];\n\tprivate readonly localEdits: Edit<TChange>[] = [];\n\n\tprivate readonly allEditIds: Map<EditId, OrderedEditId> = new Map();\n\tprivate _earliestAvailableEditIndex = 0;\n\tprivate readonly _editAddedHandlers: Set<EditAddedHandler<TChange>> = new Set();\n\tprivate readonly _editEvictionHandlers: Set<EditEvictionHandler> = new Set();\n\n\t/**\n\t * @returns The index of the earliest edit stored in this log.\n\t * Edit indices are unique and strictly increasing within the session.\n\t */\n\tpublic get earliestAvailableEditIndex(): number {\n\t\treturn this._earliestAvailableEditIndex;\n\t}\n\n\t/**\n\t * @returns The sequence number of the latest edit known by all nodes.\n\t */\n\tpublic get minSequenceNumber(): number {\n\t\treturn this._minSequenceNumber;\n\t}\n\n\t/**\n\t * Construct an `EditLog` using the given options.\n\t * @param summary - An edit log summary used to populate the edit log.\n\t * @param logger - An optional logger to record telemetry/errors\n\t * @param editAddedHandlers - Optional handlers that are called when edits are added.\n\t * @param targetLength - The target number of sequenced edits that the log will try to store in memory.\n\t * Depending on eviction frequency and the collaboration window, there can be more edits in memory at a given time.\n\t * Edits greater than or equal to the `minSequenceNumber` (aka in the collaboration window) are not evicted.\n\t * @param evictionFrequency - The rate at which edits are evicted from memory. This is a factor of the editLogSize.\n\t * For example, with the default frequency of inMemoryHistorySize * 2 and a size of 10, the log will evict once it reaches 20 sequenced edits\n\t * down to 10 edits, also keeping any that are still in the collaboration window.\n\t * @param editEvictionHandlers - Handlers that are called before edits are evicted from memory. This provides a chance for\n\t * callers to work with the edits before they are lost.\n\t */\n\tpublic constructor(\n\t\tsummary: EditLogSummary<TChange, EditHandle<TChange>> = { editIds: [], editChunks: [] },\n\t\tprivate readonly logger?: ITelemetryLogger,\n\t\teditAddedHandlers: readonly EditAddedHandler<TChange>[] = [],\n\t\tprivate readonly targetLength = Infinity,\n\t\tprivate readonly evictionFrequency = targetLength * 2,\n\t\teditEvictionHandlers: readonly EditEvictionHandler[] = []\n\t) {\n\t\tsuper();\n\t\tconst { editChunks, editIds } = summary;\n\n\t\tfor (const handler of editAddedHandlers) {\n\t\t\tthis.registerEditAddedHandler(handler);\n\t\t}\n\n\t\tif (targetLength !== Infinity) {\n\t\t\tif (targetLength < 0 || evictionFrequency < 0) {\n\t\t\t\tfail('targetLength and evictionFrequency should not be negative');\n\t\t\t}\n\t\t\tthis.sequenceNumberToIndex = new BTree([[0, 0]]);\n\t\t\tfor (const handler of editEvictionHandlers) {\n\t\t\t\tthis.registerEditEvictionHandler(handler);\n\t\t\t}\n\t\t}\n\n\t\teditChunks.forEach((editChunkOrHandle) => {\n\t\t\tconst { startRevision, chunk } = editChunkOrHandle;\n\n\t\t\tif (Array.isArray(chunk)) {\n\t\t\t\tfor (const [index, edit] of chunk.entries()) {\n\t\t\t\t\tconst editIndex = startRevision + index;\n\t\t\t\t\tconst id = editIds[editIndex];\n\t\t\t\t\tthis.sequencedEdits.push({ id, ...edit });\n\t\t\t\t\tconst encounteredEditId = this.allEditIds.get(id);\n\t\t\t\t\tassert(encounteredEditId === undefined, 0x60a /* Duplicate acked edit. */);\n\t\t\t\t\tthis.allEditIds.set(id, { isLocal: false, index: editIndex });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Ignore any edit handles, these edits are now unrecoverable.\n\t\t\t\t// This should instead download the edit chunk and store them but history is not\n\t\t\t\t// being used so we're going with the simpler solution.\n\t\t\t\tthis.logger?.sendErrorEvent({ eventName: 'UnexpectedEditHandleInSummary' });\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Registers a handler for when an edit is added to this `EditLog`.\n\t * @returns A callback which can be invoked to unregister this handler.\n\t */\n\tpublic registerEditAddedHandler(handler: EditAddedHandler<TChange>): () => void {\n\t\tthis._editAddedHandlers.add(handler);\n\t\treturn () => this._editAddedHandlers.delete(handler);\n\t}\n\n\t/**\n\t * @returns the `EditAddedHandler`s registered on this `EditLog`.\n\t */\n\tpublic get editAddedHandlers(): readonly EditAddedHandler<TChange>[] {\n\t\treturn Array.from(this._editAddedHandlers);\n\t}\n\n\t/**\n\t * Registers a handler that is called before an edit is evicted from this `EditLog`.\n\t * @returns A callback which can be invoked to unregister this handler.\n\t */\n\tpublic registerEditEvictionHandler(handler: EditEvictionHandler): () => void {\n\t\tthis._editEvictionHandlers.add(handler);\n\t\treturn () => this._editEvictionHandlers.delete(handler);\n\t}\n\n\t/**\n\t * @returns the `EditEvictedHandler`s registered on this `EditLog`.\n\t */\n\tpublic get editEvictedHandlers(): readonly EditEvictionHandler[] {\n\t\treturn Array.from(this._editEvictionHandlers);\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.length}\n\t */\n\tpublic get length(): number {\n\t\treturn this.numberOfSequencedEdits + this.numberOfLocalEdits;\n\t}\n\n\t/**\n\t * The number of sequenced (acked) edits in the log.\n\t */\n\tpublic get numberOfSequencedEdits(): number {\n\t\treturn this.sequencedEdits.length;\n\t}\n\n\t/**\n\t * The number of local (unacked) edits in the log.\n\t */\n\tpublic get numberOfLocalEdits(): number {\n\t\treturn this.localEdits.length;\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.editIds}\n\t */\n\tpublic get editIds(): EditId[] {\n\t\treturn this.sequencedEdits.map(({ id }) => id).concat(this.localEdits.map(({ id }) => id));\n\t}\n\n\t/**\n\t * @returns true iff the edit is contained in this 'EditLog' and it is a local edit (not sequenced).\n\t */\n\tpublic isLocalEdit(editId: EditId): boolean {\n\t\tconst entry = this.allEditIds.get(editId);\n\t\treturn entry?.isLocal ?? false;\n\t}\n\n\t/**\n\t * @returns true iff the revision is a sequenced revision (not local).\n\t */\n\tpublic isSequencedRevision(revision: number): boolean {\n\t\treturn revision <= this.sequencedEdits.length;\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.tryGetIndexOfId}\n\t */\n\tpublic tryGetIndexOfId(editId: EditId): number | undefined {\n\t\tconst orderedEdit = this.allEditIds.get(editId);\n\t\tif (orderedEdit === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (orderedEdit.isLocal) {\n\t\t\tconst firstLocal = this.allEditIds.get(this.localEdits[0].id) ?? fail('edit not found');\n\t\t\tassert(firstLocal.isLocal, 0x60b /* local edit should be local */);\n\t\t\treturn (\n\t\t\t\tthis._earliestAvailableEditIndex +\n\t\t\t\tthis.numberOfSequencedEdits +\n\t\t\t\torderedEdit.localSequence -\n\t\t\t\tfirstLocal.localSequence\n\t\t\t);\n\t\t}\n\t\treturn orderedEdit.index;\n\t}\n\n\t/**\n\t * @returns Edit metadata for the edit with the given `editId`.\n\t */\n\tpublic getOrderedEditId(editId: EditId): OrderedEditId {\n\t\treturn this.allEditIds.get(editId) ?? fail('All edits should exist in this map');\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.getIndexOfId}\n\t */\n\tpublic getIndexOfId(editId: EditId): number {\n\t\treturn this.tryGetIndexOfId(editId) ?? fail('edit not found');\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.getIdAtIndex}\n\t */\n\tpublic getIdAtIndex(index: number): EditId {\n\t\tif (this._earliestAvailableEditIndex + this.numberOfSequencedEdits <= index) {\n\t\t\treturn this.localEdits[index - this.numberOfSequencedEdits].id;\n\t\t}\n\n\t\treturn this.sequencedEdits[index - this._earliestAvailableEditIndex].id;\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.tryGetEditAtIndex}\n\t */\n\tpublic tryGetEditAtIndex(index: number): Edit<TChange> | undefined {\n\t\tif (this._earliestAvailableEditIndex + this.numberOfSequencedEdits <= index) {\n\t\t\treturn this.localEdits[index - this.numberOfSequencedEdits];\n\t\t}\n\n\t\treturn this.sequencedEdits[index - this._earliestAvailableEditIndex];\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.tryGetEditFromId}\n\t */\n\tpublic tryGetEditFromId(editId: EditId): Edit<TChange> | undefined {\n\t\tconst index = this.tryGetIndexOfId(editId);\n\t\treturn index !== undefined ? this.tryGetEditAtIndex(index) : undefined;\n\t}\n\n\t/**\n\t * Sequences all local edits.\n\t */\n\tpublic sequenceLocalEdits(): void {\n\t\tthis.localEdits.slice().forEach((edit) => this.addSequencedEditInternal(edit));\n\t}\n\n\t/**\n\t * Adds a sequenced (non-local) edit to the edit log.\n\t * If the id of the supplied edit matches a local edit already present in the log, the local edit will be replaced.\n\t *\n\t */\n\tpublic addSequencedEdit(edit: Edit<TChange>, message: MessageSequencingInfo): void {\n\t\tthis.addSequencedEditInternal(edit, message, message.minimumSequenceNumber);\n\t}\n\n\t/**\n\t * Returns all local edits from this EditLog\n\t * This is useful for op format upgrades, which might warrant re-submission of these ops using the new format.\n\t * See the breaking change documentation for more information.\n\t */\n\tpublic *getLocalEdits(): Iterable<Edit<TChange>> {\n\t\tfor (const edit of this.localEdits) {\n\t\t\tyield edit;\n\t\t}\n\t}\n\n\t/**\n\t * Adds a sequenced (non-local) edit to the edit log.\n\t * If the id of the supplied edit matches a local edit already present in the log, the local edit will be replaced.\n\t */\n\tprivate addSequencedEditInternal(\n\t\tedit: Edit<TChange>,\n\t\tinfo?: EditSequencingInfo,\n\t\tminSequenceNumber: number = 0\n\t): void {\n\t\tassert(\n\t\t\tminSequenceNumber >= this._minSequenceNumber,\n\t\t\t0x60c /* Sequenced edits should carry a monotonically increasing min number */\n\t\t);\n\t\tthis._minSequenceNumber = minSequenceNumber;\n\n\t\tconst { id } = edit;\n\t\t// The index of the sequenced edit to add\n\t\tconst index = this._earliestAvailableEditIndex + this.numberOfSequencedEdits;\n\n\t\t// Remove the edit from local edits if it exists.\n\t\tconst encounteredEditId = this.allEditIds.get(id);\n\t\tif (encounteredEditId !== undefined) {\n\t\t\t// New edit already exits: it must have been a local edit.\n\t\t\tassert(encounteredEditId.isLocal, 0x60d /* Duplicate acked edit. */);\n\t\t\t// Remove it from localEdits. Due to ordering requirements, it must be first.\n\t\t\tconst oldLocalEditId = this.localEdits.shift()?.id ?? fail('Local edit should exist');\n\t\t\tassert(oldLocalEditId === id, 0x60e /* Causal ordering should be upheld */);\n\t\t}\n\n\t\tthis.sequencedEdits.push(edit);\n\n\t\tconst sequencedEditId: SequencedOrderedEditId = {\n\t\t\tindex,\n\t\t\tisLocal: false,\n\t\t\tsequenceInfo: info,\n\t\t};\n\t\tthis.allEditIds.set(id, sequencedEditId);\n\t\tif (info !== undefined) {\n\t\t\tthis.sequenceNumberToIndex?.set(info.sequenceNumber, index);\n\t\t}\n\t\tthis.emitAdd(edit, false, encounteredEditId !== undefined);\n\n\t\t// Check if any edits need to be evicted due to this addition\n\t\tif (this.sequenceNumberToIndex !== undefined && this.numberOfSequencedEdits >= this.evictionFrequency) {\n\t\t\tthis.evictEdits();\n\t\t}\n\t}\n\n\t/**\n\t * Adds a non-sequenced (local) edit to the edit log.\n\t * Duplicate edits are ignored.\n\t */\n\tpublic addLocalEdit(edit: Edit<TChange>): void {\n\t\tthis.localEdits.push(edit);\n\t\tconst localEditId: LocalOrderedEditId = { localSequence: this.localEditSequence++, isLocal: true };\n\t\tthis.allEditIds.set(edit.id, localEditId);\n\t\tthis.emitAdd(edit, true, false);\n\t}\n\n\tprivate emitAdd(editAdded: Edit<TChange>, isLocal: boolean, wasLocal: boolean): void {\n\t\tfor (const handler of this._editAddedHandlers) {\n\t\t\thandler(editAdded, isLocal, wasLocal);\n\t\t}\n\t}\n\n\tprivate evictEdits(): void {\n\t\tassert(\n\t\t\tthis.sequenceNumberToIndex !== undefined,\n\t\t\t0x60f /* Edits should never be evicted if the target length is set to infinity */\n\t\t);\n\n\t\tconst minSequenceIndex =\n\t\t\tthis.sequenceNumberToIndex.getPairOrNextHigher(this._minSequenceNumber)?.[1] ??\n\t\t\tfail('No index associated with that sequence number.');\n\t\t// Exclude any edits in the collab window from being evicted\n\t\tconst numberOfEvictableEdits = minSequenceIndex - this.earliestAvailableEditIndex;\n\n\t\tif (numberOfEvictableEdits > 0) {\n\t\t\t// Evict either all but the target log size or the number of evictable edits, whichever is smaller\n\t\t\tconst numberOfDesiredEditsToEvict = this.numberOfSequencedEdits - this.targetLength;\n\t\t\tconst numberOfEditsToEvict = Math.min(numberOfEvictableEdits, numberOfDesiredEditsToEvict);\n\t\t\tfor (const handler of this._editEvictionHandlers) {\n\t\t\t\thandler(numberOfEditsToEvict);\n\t\t\t}\n\n\t\t\t// Remove the edits and move up the earliest available index\n\t\t\tconst removedEdits = this.sequencedEdits.splice(0, numberOfEditsToEvict);\n\t\t\tthis._earliestAvailableEditIndex += numberOfEditsToEvict;\n\n\t\t\t// On eviction, we need to remove the IDs of edits that have been evicted\n\t\t\tremovedEdits.forEach((edit) => this.allEditIds.delete(edit.id));\n\n\t\t\t// The minSequenceNumber is strictly increasing so we can clear sequence numbers before it\n\t\t\tthis.sequenceNumberToIndex.deleteRange(0, this._minSequenceNumber, false);\n\t\t}\n\t}\n\n\t/**\n\t * @returns true iff this `EditLog` and `other` are equivalent, regardless of locality.\n\t */\n\tpublic equals<TOtherChangeTypesInternal>(other: EditLog<TOtherChangeTypesInternal>): boolean {\n\t\t// TODO #45414: We should also be deep comparing the list of changes in the edit. This is not straightforward.\n\t\t// We can use our edit validation code when we write it since it will need to do deep walks of the changes.\n\t\treturn compareArrays(this.editIds, other.editIds);\n\t}\n\n\t/**\n\t * @returns the summary of this `OrderedEditSet` that can be used to reconstruct the edit set.\n\t * @internal\n\t */\n\tpublic getEditLogSummary(): EditLogSummary<TChange, FluidEditHandle>;\n\t/**\n\t * @param compressEdit - a function which compresses edits\n\t * @returns the summary of this `OrderedEditSet` that can be used to reconstruct the edit set.\n\t * @internal\n\t */\n\tpublic getEditLogSummary<TCompressedChange>(\n\t\tcompressEdit: (edit: Pick<Edit<TChange>, 'changes'>) => Pick<Edit<TCompressedChange>, 'changes'>\n\t): EditLogSummary<TCompressedChange, FluidEditHandle>;\n\tpublic getEditLogSummary<TCompressedChange>(\n\t\tcompressEdit?: (edit: Pick<Edit<TChange>, 'changes'>) => Pick<Edit<TCompressedChange>, 'changes'>\n\t): EditLogSummary<TChange, FluidEditHandle> | EditLogSummary<TCompressedChange, FluidEditHandle> {\n\t\tconst editIds = this.sequencedEdits.map(({ id }) => id);\n\t\treturn compressEdit !== undefined\n\t\t\t? {\n\t\t\t\t\teditChunks:\n\t\t\t\t\t\tthis.sequencedEdits.length === 0\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t// Store all edits within a single \"chunk\"\n\t\t\t\t\t\t\t\t\t\tstartRevision: 0,\n\t\t\t\t\t\t\t\t\t\tchunk: this.sequencedEdits.map((edit) => compressEdit(edit)),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t ],\n\t\t\t\t\teditIds,\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\teditChunks:\n\t\t\t\t\t\tthis.sequencedEdits.length === 0\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t// Store all edits within a single \"chunk\"\n\t\t\t\t\t\t\t\t\t\tstartRevision: 0,\n\t\t\t\t\t\t\t\t\t\tchunk: this.sequencedEdits.map(({ changes }) => ({ changes })),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t ],\n\t\t\t\t\teditIds,\n\t\t\t };\n\t}\n\n\t// APIS DEPRECATED DUE TO HISTORY'S PEACEFUL DEATH\n\t/**\n\t * @deprecated Edit virtualization is no longer supported. Don't use the asynchronous APIs. Instead, use {@link OrderedEditSet.tryGetEditFromId}.\n\t */\n\tpublic async tryGetEdit(editId: EditId): Promise<Edit<TChange> | undefined> {\n\t\tconst index = this.tryGetIndexOfId(editId);\n\t\treturn index !== undefined ? this.tryGetEditAtIndex(index) : undefined;\n\t}\n\n\t/**\n\t * @deprecated Edit virtualization is no longer supported. Don't use the asynchronous APIs. Instead, use {@link OrderedEditSet.tryGetEditFromId}.\n\t */\n\tpublic async getEditAtIndex(index: number): Promise<Edit<TChange>> {\n\t\treturn this.tryGetEditAtIndex(index) ?? fail('Edit not found');\n\t}\n\n\t/**\n\t * @deprecated Edit virtualization is no longer supported. Instead, use {@link OrderedEditSet.tryGetEditFromId}.\n\t */\n\tpublic getEditInSessionAtIndex(index: number): Edit<TChange> {\n\t\treturn this.tryGetEditAtIndex(index) ?? fail('Edit not found');\n\t}\n}\n"]}
1
+ {"version":3,"file":"EditLog.js","sourceRoot":"","sources":["../src/EditLog.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,gEAAiC;AACjC,+DAAyE;AAGzE,2DAA2D;AAC3D,qCAAgC;AAkJhC;;GAEG;AACH,SAAgB,iBAAiB,CAAU,IAAmB;IAI7D,MAAM,aAAa,mCAAQ,IAAI,KAAE,EAAE,EAAE,SAAS,GAAE,CAAC;IACjD,OAAO,aAAa,CAAC,EAAE,CAAC;IACxB,OAAO,EAAE,EAAE,EA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CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACI,uBAAuB,CAAC,KAAa;;QAC3C,OAAO,MAAA,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,mCAAI,IAAA,aAAI,EAAC,gBAAgB,CAAC,CAAC;IAChE,CAAC;CACD;AA/aD,0BA+aC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport BTree from 'sorted-btree';\nimport { TypedEventEmitter, assert } from '@fluidframework/common-utils';\nimport type { IEvent } from '@fluidframework/common-definitions';\nimport { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';\nimport { compareArrays } from '@fluidframework/core-utils';\nimport { fail } from './Common';\nimport type { EditId } from './Identifiers';\nimport type { StringInterner } from './StringInterner';\nimport { Edit, EditLogSummary, EditWithoutId, FluidEditHandle } from './persisted-types';\nimport type { ChangeCompressor } from './ChangeCompression';\n\n/**\n * An ordered set of Edits associated with a SharedTree.\n * Supports fast lookup of edits by ID and enforces idempotence.\n * @public\n * @sealed\n */\nexport interface OrderedEditSet<TChange = unknown> {\n\t/**\n\t * The length of this `OrderedEditSet`.\n\t */\n\treadonly length: number;\n\n\t/**\n\t * The edit IDs of all edits in the log.\n\t */\n\treadonly editIds: readonly EditId[];\n\n\t/**\n\t * @returns the index of the edit with the given editId within this `OrderedEditSet`.\n\t */\n\tgetIndexOfId(editId: EditId): number;\n\n\t/**\n\t * @returns the id of the edit at the given index within this 'OrderedEditSet'.\n\t */\n\tgetIdAtIndex(index: number): EditId;\n\n\t/**\n\t * @returns the index of the edit with the given editId within this `OrderedEditSet`, or `undefined` if no such edit exists.\n\t */\n\ttryGetIndexOfId(editId: EditId): number | undefined;\n\n\t/**\n\t * @returns the edit at the given index within this `OrderedEditSet`.\n\t */\n\ttryGetEditAtIndex(index: number): Edit<TChange> | undefined;\n\n\t/**\n\t * @returns the edit with the given identifier within this `OrderedEditSet`.\n\t */\n\ttryGetEditFromId(editId: EditId): Edit<TChange> | undefined;\n\n\t/**\n\t * @returns the Edit associated with the EditId or undefined if there is no such edit in the set.\n\t * @deprecated Edit virtualization is no longer supported. Don't use the asynchronous APIs. Instead, use {@link OrderedEditSet.tryGetEditFromId}.\n\t */\n\ttryGetEdit(editId: EditId): Promise<Edit<TChange> | undefined>;\n\n\t/**\n\t * @returns the edit at the given index within this `OrderedEditSet`.\n\t * @deprecated Edit virtualization is no longer supported. Don't use the asynchronous APIs.\n\t */\n\tgetEditAtIndex(index: number): Promise<Edit<TChange>>;\n\n\t/**\n\t * @returns the edit at the given index. Must have been added to the log during the current session.\n\t * @deprecated this will be removed in favor of {@link OrderedEditSet.tryGetEditAtIndex}\n\t */\n\tgetEditInSessionAtIndex(index: number): Edit<TChange>;\n}\n\n/**\n * Server-provided metadata for edits that have been sequenced.\n */\nexport interface EditSequencingInfo {\n\t/**\n\t * The server-assigned sequence number of the op.\n\t */\n\treadonly sequenceNumber: number;\n\t/**\n\t * Last known sequenced edit at the time this op was issued.\n\t */\n\treadonly referenceSequenceNumber: number;\n}\n\n/**\n * Server-provided metadata for edits that have been sequenced.\n */\nexport interface MessageSequencingInfo extends EditSequencingInfo {\n\t/**\n\t * Last sequenced edit that all clients are guaranteed to be aware of.\n\t * If not specified, then some clients have not seen any edits yet.\n\t */\n\treadonly minimumSequenceNumber?: number;\n}\n\n/**\n * Metadata for a sequenced edit.\n */\nexport interface SequencedOrderedEditId {\n\treadonly isLocal: false;\n\treadonly index: number;\n\t/**\n\t * Information about the edit's relationship to other sequenced edits.\n\t * Undefined iff the edit was loaded from a summary.\n\t */\n\treadonly sequenceInfo?: EditSequencingInfo;\n}\n\n/**\n * Metadata for a local edit.\n */\nexport interface LocalOrderedEditId {\n\treadonly isLocal: true;\n\treadonly localSequence: number;\n}\n\n/**\n * Metadata for an edit.\n */\nexport type OrderedEditId = SequencedOrderedEditId | LocalOrderedEditId;\n\n/**\n * Compressor+interner pair used for encoding an {@link EditLog} into a summary.\n * @internal\n */\nexport interface EditLogEncoder {\n\tcompressor: ChangeCompressor;\n\tinterner: StringInterner;\n}\n\n/**\n * A sequence of edits that may or may not need to be downloaded into the EditLog from an external service\n * @deprecated Edit virtualization is no longer supported.\n */\nexport interface EditChunk<TChange> {\n\thandle?: EditHandle<TChange>;\n\tedits?: EditWithoutId<TChange>[];\n}\n/**\n * EditHandles are used to load edit chunks stored outside of the EditLog.\n * This is typically implemented by a wrapper around an IFluidHandle<ArrayBufferLike>.\n * @deprecated Edit virtualization is no longer supported.\n * @public\n */\nexport interface EditHandle<TChange> {\n\treadonly get: () => Promise<EditWithoutId<TChange>[]>;\n\treadonly baseHandle: FluidEditHandle;\n}\n\n/**\n * Returns an object that separates an Edit into two fields, id and editWithoutId.\n */\nexport function separateEditAndId<TChange>(edit: Edit<TChange>): {\n\tid: EditId;\n\teditWithoutId: EditWithoutId<TChange>;\n} {\n\tconst editWithoutId = { ...edit, id: undefined };\n\tdelete editWithoutId.id;\n\treturn { id: edit.id, editWithoutId };\n}\n\n/**\n * @param summary - The edit log summary to parse.\n * @returns the number of handles saved to the provided edit log summary.\n * @deprecated Edit virtualization is no longer supported.\n */\nexport function getNumberOfHandlesFromEditLogSummary(summary: EditLogSummary<unknown, unknown>): number {\n\tconst { editChunks } = summary;\n\n\tlet numberOfHandles = 0;\n\teditChunks.forEach(({ chunk }) => {\n\t\tif (!Array.isArray(chunk)) {\n\t\t\tnumberOfHandles++;\n\t\t}\n\t});\n\n\treturn numberOfHandles;\n}\n\n/**\n * Event fired when an edit is added to an `EditLog`.\n * @param edit - The edit that was added to the log\n * @param isLocal - true iff this edit was generated locally\n */\nexport type EditAddedHandler<TChange> = (edit: Edit<TChange>, isLocal: boolean, wasLocal: boolean) => void;\n\n/**\n * Event fired before edits are evicted from the edit log. It takes in a count of the number of edits to evict\n * starting from the oldest in memory edit. To get the edit itself, call {@link EditLog.getEditAtIndex}.\n * The edit index corresponds to the count + {@link EditLog.earliestAvailableEditIndex}.\n */\nexport type EditEvictionHandler = (editsToEvict: number) => void;\n\n/**\n * Events which may be emitted by {@link EditLog}\n * @public\n */\nexport interface IEditLogEvents extends IEvent {\n\t(event: 'unexpectedHistoryChunk', listener: () => void);\n}\n\n/**\n * The edit history log for SharedTree.\n * Contains only completed edits (no in-progress edits).\n * Ordered first by locality (acked or local), then by time of insertion.\n * May not contain more than one edit with the same ID.\n * @sealed\n */\nexport class EditLog<TChange = unknown> extends TypedEventEmitter<IEditLogEvents> implements OrderedEditSet<TChange> {\n\tprivate localEditSequence = 0;\n\n\tprivate readonly sequenceNumberToIndex?: BTree<number, number>;\n\tprivate _minSequenceNumber = 0;\n\n\tprivate readonly sequencedEdits: Edit<TChange>[] = [];\n\tprivate readonly localEdits: Edit<TChange>[] = [];\n\n\tprivate readonly allEditIds: Map<EditId, OrderedEditId> = new Map();\n\tprivate _earliestAvailableEditIndex = 0;\n\tprivate readonly _editAddedHandlers: Set<EditAddedHandler<TChange>> = new Set();\n\tprivate readonly _editEvictionHandlers: Set<EditEvictionHandler> = new Set();\n\n\t/**\n\t * @returns The index of the earliest edit stored in this log.\n\t * Edit indices are unique and strictly increasing within the session.\n\t */\n\tpublic get earliestAvailableEditIndex(): number {\n\t\treturn this._earliestAvailableEditIndex;\n\t}\n\n\t/**\n\t * @returns The sequence number of the latest edit known by all nodes.\n\t */\n\tpublic get minSequenceNumber(): number {\n\t\treturn this._minSequenceNumber;\n\t}\n\n\t/**\n\t * Construct an `EditLog` using the given options.\n\t * @param summary - An edit log summary used to populate the edit log.\n\t * @param logger - An optional logger to record telemetry/errors\n\t * @param editAddedHandlers - Optional handlers that are called when edits are added.\n\t * @param targetLength - The target number of sequenced edits that the log will try to store in memory.\n\t * Depending on eviction frequency and the collaboration window, there can be more edits in memory at a given time.\n\t * Edits greater than or equal to the `minSequenceNumber` (aka in the collaboration window) are not evicted.\n\t * @param evictionFrequency - The rate at which edits are evicted from memory. This is a factor of the editLogSize.\n\t * For example, with the default frequency of inMemoryHistorySize * 2 and a size of 10, the log will evict once it reaches 20 sequenced edits\n\t * down to 10 edits, also keeping any that are still in the collaboration window.\n\t * @param editEvictionHandlers - Handlers that are called before edits are evicted from memory. This provides a chance for\n\t * callers to work with the edits before they are lost.\n\t */\n\tpublic constructor(\n\t\tsummary: EditLogSummary<TChange, EditHandle<TChange>> = { editIds: [], editChunks: [] },\n\t\tprivate readonly logger?: ITelemetryLoggerExt,\n\t\teditAddedHandlers: readonly EditAddedHandler<TChange>[] = [],\n\t\tprivate readonly targetLength = Infinity,\n\t\tprivate readonly evictionFrequency = targetLength * 2,\n\t\teditEvictionHandlers: readonly EditEvictionHandler[] = []\n\t) {\n\t\tsuper();\n\t\tconst { editChunks, editIds } = summary;\n\n\t\tfor (const handler of editAddedHandlers) {\n\t\t\tthis.registerEditAddedHandler(handler);\n\t\t}\n\n\t\tif (targetLength !== Infinity) {\n\t\t\tif (targetLength < 0 || evictionFrequency < 0) {\n\t\t\t\tfail('targetLength and evictionFrequency should not be negative');\n\t\t\t}\n\t\t\tthis.sequenceNumberToIndex = new BTree([[0, 0]]);\n\t\t\tfor (const handler of editEvictionHandlers) {\n\t\t\t\tthis.registerEditEvictionHandler(handler);\n\t\t\t}\n\t\t}\n\n\t\teditChunks.forEach((editChunkOrHandle) => {\n\t\t\tconst { startRevision, chunk } = editChunkOrHandle;\n\n\t\t\tif (Array.isArray(chunk)) {\n\t\t\t\tfor (const [index, edit] of chunk.entries()) {\n\t\t\t\t\tconst editIndex = startRevision + index;\n\t\t\t\t\tconst id = editIds[editIndex];\n\t\t\t\t\tthis.sequencedEdits.push({ id, ...edit });\n\t\t\t\t\tconst encounteredEditId = this.allEditIds.get(id);\n\t\t\t\t\tassert(encounteredEditId === undefined, 0x60a /* Duplicate acked edit. */);\n\t\t\t\t\tthis.allEditIds.set(id, { isLocal: false, index: editIndex });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Ignore any edit handles, these edits are now unrecoverable.\n\t\t\t\t// This should instead download the edit chunk and store them but history is not\n\t\t\t\t// being used so we're going with the simpler solution.\n\t\t\t\tthis.logger?.sendErrorEvent({ eventName: 'UnexpectedEditHandleInSummary' });\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Registers a handler for when an edit is added to this `EditLog`.\n\t * @returns A callback which can be invoked to unregister this handler.\n\t */\n\tpublic registerEditAddedHandler(handler: EditAddedHandler<TChange>): () => void {\n\t\tthis._editAddedHandlers.add(handler);\n\t\treturn () => this._editAddedHandlers.delete(handler);\n\t}\n\n\t/**\n\t * @returns the `EditAddedHandler`s registered on this `EditLog`.\n\t */\n\tpublic get editAddedHandlers(): readonly EditAddedHandler<TChange>[] {\n\t\treturn Array.from(this._editAddedHandlers);\n\t}\n\n\t/**\n\t * Registers a handler that is called before an edit is evicted from this `EditLog`.\n\t * @returns A callback which can be invoked to unregister this handler.\n\t */\n\tpublic registerEditEvictionHandler(handler: EditEvictionHandler): () => void {\n\t\tthis._editEvictionHandlers.add(handler);\n\t\treturn () => this._editEvictionHandlers.delete(handler);\n\t}\n\n\t/**\n\t * @returns the `EditEvictedHandler`s registered on this `EditLog`.\n\t */\n\tpublic get editEvictedHandlers(): readonly EditEvictionHandler[] {\n\t\treturn Array.from(this._editEvictionHandlers);\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.length}\n\t */\n\tpublic get length(): number {\n\t\treturn this.numberOfSequencedEdits + this.numberOfLocalEdits;\n\t}\n\n\t/**\n\t * The number of sequenced (acked) edits in the log.\n\t */\n\tpublic get numberOfSequencedEdits(): number {\n\t\treturn this.sequencedEdits.length;\n\t}\n\n\t/**\n\t * The number of local (unacked) edits in the log.\n\t */\n\tpublic get numberOfLocalEdits(): number {\n\t\treturn this.localEdits.length;\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.editIds}\n\t */\n\tpublic get editIds(): EditId[] {\n\t\treturn this.sequencedEdits.map(({ id }) => id).concat(this.localEdits.map(({ id }) => id));\n\t}\n\n\t/**\n\t * @returns true iff the edit is contained in this 'EditLog' and it is a local edit (not sequenced).\n\t */\n\tpublic isLocalEdit(editId: EditId): boolean {\n\t\tconst entry = this.allEditIds.get(editId);\n\t\treturn entry?.isLocal ?? false;\n\t}\n\n\t/**\n\t * @returns true iff the revision is a sequenced revision (not local).\n\t */\n\tpublic isSequencedRevision(revision: number): boolean {\n\t\treturn revision <= this.sequencedEdits.length;\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.tryGetIndexOfId}\n\t */\n\tpublic tryGetIndexOfId(editId: EditId): number | undefined {\n\t\tconst orderedEdit = this.allEditIds.get(editId);\n\t\tif (orderedEdit === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (orderedEdit.isLocal) {\n\t\t\tconst firstLocal = this.allEditIds.get(this.localEdits[0].id) ?? fail('edit not found');\n\t\t\tassert(firstLocal.isLocal, 0x60b /* local edit should be local */);\n\t\t\treturn (\n\t\t\t\tthis._earliestAvailableEditIndex +\n\t\t\t\tthis.numberOfSequencedEdits +\n\t\t\t\torderedEdit.localSequence -\n\t\t\t\tfirstLocal.localSequence\n\t\t\t);\n\t\t}\n\t\treturn orderedEdit.index;\n\t}\n\n\t/**\n\t * @returns Edit metadata for the edit with the given `editId`.\n\t */\n\tpublic getOrderedEditId(editId: EditId): OrderedEditId {\n\t\treturn this.allEditIds.get(editId) ?? fail('All edits should exist in this map');\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.getIndexOfId}\n\t */\n\tpublic getIndexOfId(editId: EditId): number {\n\t\treturn this.tryGetIndexOfId(editId) ?? fail('edit not found');\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.getIdAtIndex}\n\t */\n\tpublic getIdAtIndex(index: number): EditId {\n\t\tif (this._earliestAvailableEditIndex + this.numberOfSequencedEdits <= index) {\n\t\t\treturn this.localEdits[index - this.numberOfSequencedEdits].id;\n\t\t}\n\n\t\treturn this.sequencedEdits[index - this._earliestAvailableEditIndex].id;\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.tryGetEditAtIndex}\n\t */\n\tpublic tryGetEditAtIndex(index: number): Edit<TChange> | undefined {\n\t\tif (this._earliestAvailableEditIndex + this.numberOfSequencedEdits <= index) {\n\t\t\treturn this.localEdits[index - this.numberOfSequencedEdits];\n\t\t}\n\n\t\treturn this.sequencedEdits[index - this._earliestAvailableEditIndex];\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.tryGetEditFromId}\n\t */\n\tpublic tryGetEditFromId(editId: EditId): Edit<TChange> | undefined {\n\t\tconst index = this.tryGetIndexOfId(editId);\n\t\treturn index !== undefined ? this.tryGetEditAtIndex(index) : undefined;\n\t}\n\n\t/**\n\t * Sequences all local edits.\n\t */\n\tpublic sequenceLocalEdits(): void {\n\t\tthis.localEdits.slice().forEach((edit) => this.addSequencedEditInternal(edit));\n\t}\n\n\t/**\n\t * Adds a sequenced (non-local) edit to the edit log.\n\t * If the id of the supplied edit matches a local edit already present in the log, the local edit will be replaced.\n\t *\n\t */\n\tpublic addSequencedEdit(edit: Edit<TChange>, message: MessageSequencingInfo): void {\n\t\tthis.addSequencedEditInternal(edit, message, message.minimumSequenceNumber);\n\t}\n\n\t/**\n\t * Returns all local edits from this EditLog\n\t * This is useful for op format upgrades, which might warrant re-submission of these ops using the new format.\n\t * See the breaking change documentation for more information.\n\t */\n\tpublic *getLocalEdits(): Iterable<Edit<TChange>> {\n\t\tfor (const edit of this.localEdits) {\n\t\t\tyield edit;\n\t\t}\n\t}\n\n\t/**\n\t * Adds a sequenced (non-local) edit to the edit log.\n\t * If the id of the supplied edit matches a local edit already present in the log, the local edit will be replaced.\n\t */\n\tprivate addSequencedEditInternal(\n\t\tedit: Edit<TChange>,\n\t\tinfo?: EditSequencingInfo,\n\t\tminSequenceNumber: number = 0\n\t): void {\n\t\tassert(\n\t\t\tminSequenceNumber >= this._minSequenceNumber,\n\t\t\t0x60c /* Sequenced edits should carry a monotonically increasing min number */\n\t\t);\n\t\tthis._minSequenceNumber = minSequenceNumber;\n\n\t\tconst { id } = edit;\n\t\t// The index of the sequenced edit to add\n\t\tconst index = this._earliestAvailableEditIndex + this.numberOfSequencedEdits;\n\n\t\t// Remove the edit from local edits if it exists.\n\t\tconst encounteredEditId = this.allEditIds.get(id);\n\t\tif (encounteredEditId !== undefined) {\n\t\t\t// New edit already exits: it must have been a local edit.\n\t\t\tassert(encounteredEditId.isLocal, 0x60d /* Duplicate acked edit. */);\n\t\t\t// Remove it from localEdits. Due to ordering requirements, it must be first.\n\t\t\tconst oldLocalEditId = this.localEdits.shift()?.id ?? fail('Local edit should exist');\n\t\t\tassert(oldLocalEditId === id, 0x60e /* Causal ordering should be upheld */);\n\t\t}\n\n\t\tthis.sequencedEdits.push(edit);\n\n\t\tconst sequencedEditId: SequencedOrderedEditId = {\n\t\t\tindex,\n\t\t\tisLocal: false,\n\t\t\tsequenceInfo: info,\n\t\t};\n\t\tthis.allEditIds.set(id, sequencedEditId);\n\t\tif (info !== undefined) {\n\t\t\tthis.sequenceNumberToIndex?.set(info.sequenceNumber, index);\n\t\t}\n\t\tthis.emitAdd(edit, false, encounteredEditId !== undefined);\n\n\t\t// Check if any edits need to be evicted due to this addition\n\t\tif (this.sequenceNumberToIndex !== undefined && this.numberOfSequencedEdits >= this.evictionFrequency) {\n\t\t\tthis.evictEdits();\n\t\t}\n\t}\n\n\t/**\n\t * Adds a non-sequenced (local) edit to the edit log.\n\t * Duplicate edits are ignored.\n\t */\n\tpublic addLocalEdit(edit: Edit<TChange>): void {\n\t\tthis.localEdits.push(edit);\n\t\tconst localEditId: LocalOrderedEditId = { localSequence: this.localEditSequence++, isLocal: true };\n\t\tthis.allEditIds.set(edit.id, localEditId);\n\t\tthis.emitAdd(edit, true, false);\n\t}\n\n\tprivate emitAdd(editAdded: Edit<TChange>, isLocal: boolean, wasLocal: boolean): void {\n\t\tfor (const handler of this._editAddedHandlers) {\n\t\t\thandler(editAdded, isLocal, wasLocal);\n\t\t}\n\t}\n\n\tprivate evictEdits(): void {\n\t\tassert(\n\t\t\tthis.sequenceNumberToIndex !== undefined,\n\t\t\t0x60f /* Edits should never be evicted if the target length is set to infinity */\n\t\t);\n\n\t\tconst minSequenceIndex =\n\t\t\tthis.sequenceNumberToIndex.getPairOrNextHigher(this._minSequenceNumber)?.[1] ??\n\t\t\tfail('No index associated with that sequence number.');\n\t\t// Exclude any edits in the collab window from being evicted\n\t\tconst numberOfEvictableEdits = minSequenceIndex - this.earliestAvailableEditIndex;\n\n\t\tif (numberOfEvictableEdits > 0) {\n\t\t\t// Evict either all but the target log size or the number of evictable edits, whichever is smaller\n\t\t\tconst numberOfDesiredEditsToEvict = this.numberOfSequencedEdits - this.targetLength;\n\t\t\tconst numberOfEditsToEvict = Math.min(numberOfEvictableEdits, numberOfDesiredEditsToEvict);\n\t\t\tfor (const handler of this._editEvictionHandlers) {\n\t\t\t\thandler(numberOfEditsToEvict);\n\t\t\t}\n\n\t\t\t// Remove the edits and move up the earliest available index\n\t\t\tconst removedEdits = this.sequencedEdits.splice(0, numberOfEditsToEvict);\n\t\t\tthis._earliestAvailableEditIndex += numberOfEditsToEvict;\n\n\t\t\t// On eviction, we need to remove the IDs of edits that have been evicted\n\t\t\tremovedEdits.forEach((edit) => this.allEditIds.delete(edit.id));\n\n\t\t\t// The minSequenceNumber is strictly increasing so we can clear sequence numbers before it\n\t\t\tthis.sequenceNumberToIndex.deleteRange(0, this._minSequenceNumber, false);\n\t\t}\n\t}\n\n\t/**\n\t * @returns true iff this `EditLog` and `other` are equivalent, regardless of locality.\n\t */\n\tpublic equals<TOtherChangeTypesInternal>(other: EditLog<TOtherChangeTypesInternal>): boolean {\n\t\t// TODO #45414: We should also be deep comparing the list of changes in the edit. This is not straightforward.\n\t\t// We can use our edit validation code when we write it since it will need to do deep walks of the changes.\n\t\treturn compareArrays(this.editIds, other.editIds);\n\t}\n\n\t/**\n\t * @returns the summary of this `OrderedEditSet` that can be used to reconstruct the edit set.\n\t * @internal\n\t */\n\tpublic getEditLogSummary(): EditLogSummary<TChange, FluidEditHandle>;\n\t/**\n\t * @param compressEdit - a function which compresses edits\n\t * @returns the summary of this `OrderedEditSet` that can be used to reconstruct the edit set.\n\t * @internal\n\t */\n\tpublic getEditLogSummary<TCompressedChange>(\n\t\tcompressEdit: (edit: Pick<Edit<TChange>, 'changes'>) => Pick<Edit<TCompressedChange>, 'changes'>\n\t): EditLogSummary<TCompressedChange, FluidEditHandle>;\n\tpublic getEditLogSummary<TCompressedChange>(\n\t\tcompressEdit?: (edit: Pick<Edit<TChange>, 'changes'>) => Pick<Edit<TCompressedChange>, 'changes'>\n\t): EditLogSummary<TChange, FluidEditHandle> | EditLogSummary<TCompressedChange, FluidEditHandle> {\n\t\tconst editIds = this.sequencedEdits.map(({ id }) => id);\n\t\treturn compressEdit !== undefined\n\t\t\t? {\n\t\t\t\t\teditChunks:\n\t\t\t\t\t\tthis.sequencedEdits.length === 0\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t// Store all edits within a single \"chunk\"\n\t\t\t\t\t\t\t\t\t\tstartRevision: 0,\n\t\t\t\t\t\t\t\t\t\tchunk: this.sequencedEdits.map((edit) => compressEdit(edit)),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t ],\n\t\t\t\t\teditIds,\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\teditChunks:\n\t\t\t\t\t\tthis.sequencedEdits.length === 0\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t// Store all edits within a single \"chunk\"\n\t\t\t\t\t\t\t\t\t\tstartRevision: 0,\n\t\t\t\t\t\t\t\t\t\tchunk: this.sequencedEdits.map(({ changes }) => ({ changes })),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t ],\n\t\t\t\t\teditIds,\n\t\t\t };\n\t}\n\n\t// APIS DEPRECATED DUE TO HISTORY'S PEACEFUL DEATH\n\t/**\n\t * @deprecated Edit virtualization is no longer supported. Don't use the asynchronous APIs. Instead, use {@link OrderedEditSet.tryGetEditFromId}.\n\t */\n\tpublic async tryGetEdit(editId: EditId): Promise<Edit<TChange> | undefined> {\n\t\tconst index = this.tryGetIndexOfId(editId);\n\t\treturn index !== undefined ? this.tryGetEditAtIndex(index) : undefined;\n\t}\n\n\t/**\n\t * @deprecated Edit virtualization is no longer supported. Don't use the asynchronous APIs. Instead, use {@link OrderedEditSet.tryGetEditFromId}.\n\t */\n\tpublic async getEditAtIndex(index: number): Promise<Edit<TChange>> {\n\t\treturn this.tryGetEditAtIndex(index) ?? fail('Edit not found');\n\t}\n\n\t/**\n\t * @deprecated Edit virtualization is no longer supported. Instead, use {@link OrderedEditSet.tryGetEditFromId}.\n\t */\n\tpublic getEditInSessionAtIndex(index: number): Edit<TChange> {\n\t\treturn this.tryGetEditAtIndex(index) ?? fail('Edit not found');\n\t}\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ITelemetryLogger } from '@fluidframework/common-definitions';
5
+ import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
6
6
  import { ChangeInternal } from './persisted-types';
7
7
  import { RevisionView } from './RevisionView';
8
8
  /**
@@ -27,5 +27,5 @@ export declare enum HistoryEditFactoryEvents {
27
27
  * TODO:#68574: Pass a view that corresponds to the appropriate Fluid reference sequence number rather than the view just before
28
28
  * @internal
29
29
  */
30
- export declare function revert(changes: readonly ChangeInternal[], before: RevisionView, logger?: ITelemetryLogger, emit?: (event: string | symbol, ...args: any[]) => void): ChangeInternal[] | undefined;
30
+ export declare function revert(changes: readonly ChangeInternal[], before: RevisionView, logger?: ITelemetryLoggerExt, emit?: (event: string | symbol, ...args: any[]) => void): ChangeInternal[] | undefined;
31
31
  //# sourceMappingURL=HistoryEditFactory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HistoryEditFactory.d.ts","sourceRoot":"","sources":["../src/HistoryEditFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAItE,OAAO,EACN,cAAc,EASd,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C;;GAEG;AACH,oBAAY,wBAAwB;IACnC,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;CAC7B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CACrB,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,MAAM,EAAE,YAAY,EACpB,MAAM,CAAC,EAAE,gBAAgB,EACzB,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GACrD,cAAc,EAAE,GAAG,SAAS,CAkI9B"}
1
+ {"version":3,"file":"HistoryEditFactory.d.ts","sourceRoot":"","sources":["../src/HistoryEditFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAItE,OAAO,EACN,cAAc,EASd,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C;;GAEG;AACH,oBAAY,wBAAwB;IACnC,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;CAC7B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CACrB,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,MAAM,EAAE,YAAY,EACpB,MAAM,CAAC,EAAE,mBAAmB,EAC5B,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GACrD,cAAc,EAAE,GAAG,SAAS,CAkI9B"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gB,EAAE,EAAE,CAAC,CAAC,EAC5E,kBAAkB,CAClB;YACD,gCAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;SAC5D;QACD,eAAe;KACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,sBAAsB,CAAC,QAA0B,EAAE,gBAA0B;IACrF,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;IAClC,MAAM,IAAI,GAAG,gBAAgB,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IAC3D,IAAI,IAAI,KAAK,SAAS,EAAE;QACvB,oFAAoF;QACpF,OAAO,SAAS,CAAC;KACjB;IAED,+EAA+E;IAC/E,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;QAC1B,OAAO,CAAC,gCAAc,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;KAC/D;IACD,OAAO,CAAC,gCAAc,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/common-utils';\nimport { ITelemetryLogger } from '@fluidframework/common-definitions';\nimport { DetachedSequenceId, isDetachedSequenceId, NodeId } from './Identifiers';\nimport { fail } from './Common';\nimport { rangeFromStableRange } from './TreeViewUtilities';\nimport {\n\tChangeInternal,\n\tChangeTypeInternal,\n\tDetachInternal,\n\tSetValueInternal,\n\tInsertInternal,\n\tBuildNodeInternal,\n\tSide,\n\tStableRangeInternal,\n\tEditStatus,\n} from './persisted-types';\nimport { TransactionInternal } from './TransactionInternal';\nimport { RangeValidationResultKind, validateStableRange } from './EditUtilities';\nimport { StablePlace } from './ChangeTypes';\nimport { RevisionView } from './RevisionView';\nimport { TreeView } from './TreeView';\nimport { getChangeNodeFromViewNode } from './SerializationUtilities';\n\n/**\n * Events emitted from the history edit factory\n */\nexport enum HistoryEditFactoryEvents {\n\tMalformedEdit = 'malformedEdit',\n\tMissingNodes = 'missingNodes',\n}\n\n/**\n * Given a sequence of changes, produces an inverse sequence of changes, i.e. the minimal changes required to revert the given changes\n * @param changes - the changes for which to produce an inverse.\n * @param before - a view of the tree state before `changes` are/were applied - used as a basis for generating the inverse.\n * @param logger - an optional logger for logging telemetry coming from the revert operation\n * @param emit - an optional event emitter to emit events from the revert operation and to allow clients to respond to them\n * @returns if the changes could be reverted, a sequence of changes _r_ that will produce `before` if applied to a view _A_, where _A_ is the result of\n * applying `changes` to `before`. Note that the size of the array of reverted changes may not be the same as the input array, and may even be empty in cases where\n * the view did not change. Applying _r_ to views other than _A_ is legal but may cause the changes to fail to apply or may not be a true semantic inverse.\n * If the changes could not be reverted given the state of `before`, returns undefined.\n *\n * TODO: what should this do if `changes` fails to apply to `before`?\n * TODO:#68574: Pass a view that corresponds to the appropriate Fluid reference sequence number rather than the view just before\n * @internal\n */\nexport function revert(\n\tchanges: readonly ChangeInternal[],\n\tbefore: RevisionView,\n\tlogger?: ITelemetryLogger,\n\temit?: (event: string | symbol, ...args: any[]) => void\n): ChangeInternal[] | undefined {\n\tconst result: ChangeInternal[] = [];\n\n\tconst builtNodes = new Map<DetachedSequenceId, NodeId[]>();\n\tconst detachedNodes = new Map<DetachedSequenceId, NodeId[]>();\n\n\t// Open edit on revision to update it as changes are walked through\n\tconst editor = TransactionInternal.factory(before);\n\t// Apply `edit`, generating an inverse as we go.\n\tfor (const change of changes) {\n\t\t// Generate an inverse of each change\n\t\tswitch (change.type) {\n\t\t\tcase ChangeTypeInternal.Build: {\n\t\t\t\t// Save nodes added to the detached state for use in future changes\n\t\t\t\tconst { destination, source } = change;\n\t\t\t\tassert(\n\t\t\t\t\t!builtNodes.has(destination),\n\t\t\t\t\t0x626 /* Cannot revert Build: destination is already used by a Build */\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\t!detachedNodes.has(destination),\n\t\t\t\t\t0x627 /* Cannot revert Build: destination is already used by a Detach */\n\t\t\t\t);\n\t\t\t\tbuiltNodes.set(\n\t\t\t\t\tdestination,\n\t\t\t\t\tsource.reduce((ids: NodeId[], curr: BuildNodeInternal) => {\n\t\t\t\t\t\tif (isDetachedSequenceId(curr)) {\n\t\t\t\t\t\t\tconst nodesForDetachedSequence =\n\t\t\t\t\t\t\t\tbuiltNodes.get(curr) ?? fail('detached sequence must have associated built nodes');\n\n\t\t\t\t\t\t\tids.push(...nodesForDetachedSequence);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tids.push(curr.identifier);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn ids;\n\t\t\t\t\t}, [])\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.Insert: {\n\t\t\t\tconst { source } = change;\n\t\t\t\tconst nodesBuilt = builtNodes.get(source);\n\t\t\t\tconst nodesDetached = detachedNodes.get(source);\n\n\t\t\t\tif (nodesBuilt !== undefined) {\n\t\t\t\t\tif (nodesBuilt.length === 0) {\n\t\t\t\t\t\tbuiltNodes.delete(source);\n\t\t\t\t\t\tlogger?.sendTelemetryEvent({ eventName: 'reverting insertion of empty traits' });\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tresult.unshift(createInvertedInsert(change, nodesBuilt));\n\t\t\t\t\tbuiltNodes.delete(source);\n\t\t\t\t} else if (nodesDetached !== undefined) {\n\t\t\t\t\tif (nodesDetached.length === 0) {\n\t\t\t\t\t\tdetachedNodes.delete(source);\n\t\t\t\t\t\tlogger?.sendTelemetryEvent({ eventName: 'reverting insertion of empty traits' });\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tresult.unshift(createInvertedInsert(change, nodesDetached, true));\n\t\t\t\t\tdetachedNodes.delete(source);\n\t\t\t\t} else {\n\t\t\t\t\t// Cannot revert an insert whose source is no longer available for inserting (i.e. not just built, and not detached)\n\t\t\t\t\tif (emit !== undefined) {\n\t\t\t\t\t\temit(HistoryEditFactoryEvents.MissingNodes, change, changes);\n\t\t\t\t\t}\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.Detach: {\n\t\t\t\tconst { destination } = change;\n\t\t\t\tconst invert = createInvertedDetach(change, editor.view);\n\t\t\t\tif (invert === undefined) {\n\t\t\t\t\t// Cannot revert a detach whose source does not exist in the tree\n\t\t\t\t\t// TODO:68574: May not be possible once associated todo in `createInvertedDetach` is addressed\n\t\t\t\t\tif (emit !== undefined) {\n\t\t\t\t\t\temit(HistoryEditFactoryEvents.MissingNodes, change, changes);\n\t\t\t\t\t}\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tconst { invertedDetach, detachedNodeIds } = invert;\n\n\t\t\t\tif (detachedNodeIds.length === 0) {\n\t\t\t\t\tlogger?.sendTelemetryEvent({ eventName: 'reverting detachment of empty traits' });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (destination !== undefined) {\n\t\t\t\t\tif (builtNodes.has(destination) || detachedNodes.has(destination)) {\n\t\t\t\t\t\t// Malformed: destination was already used by a prior build or detach\n\t\t\t\t\t\tif (emit !== undefined) {\n\t\t\t\t\t\t\temit(HistoryEditFactoryEvents.MalformedEdit, change, changes);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\tdetachedNodes.set(destination, detachedNodeIds);\n\t\t\t\t}\n\n\t\t\t\tresult.unshift(...invertedDetach);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.SetValue: {\n\t\t\t\tconst invert = createInvertedSetValue(change, editor.view);\n\t\t\t\tif (invert === undefined) {\n\t\t\t\t\t// Cannot revert a set for a node that does not exist in the tree\n\t\t\t\t\t// TODO:68574: May not be possible once associated todo in `createInvertedSetValue` is addressed\n\t\t\t\t\tif (emit !== undefined) {\n\t\t\t\t\t\temit(HistoryEditFactoryEvents.MissingNodes, change, changes);\n\t\t\t\t\t}\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tresult.unshift(...invert);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.Constraint:\n\t\t\t\t// TODO:#46759: Support Constraint in reverts\n\t\t\t\tfail('Revert currently does not support Constraints');\n\t\t\tdefault:\n\t\t\t\tfail('Revert does not support the change type.');\n\t\t}\n\n\t\t// Abort the entire revert if this change can't be applied successfully.\n\t\tif (editor.applyChange(change).status !== EditStatus.Applied) {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\teditor.close();\n\treturn result;\n}\n\n/**\n * The inverse of an Insert is a Detach that starts before the leftmost node inserted and ends after the rightmost.\n */\nfunction createInvertedInsert(\n\tinsert: InsertInternal,\n\tnodesInserted: readonly NodeId[],\n\tsaveDetached = false\n): ChangeInternal {\n\tconst leftmostNode = nodesInserted[0];\n\tconst rightmostNode = nodesInserted[nodesInserted.length - 1];\n\n\tconst source: StableRangeInternal = {\n\t\tstart: {\n\t\t\treferenceSibling: leftmostNode,\n\t\t\tside: Side.Before,\n\t\t},\n\t\tend: {\n\t\t\treferenceSibling: rightmostNode,\n\t\t\tside: Side.After,\n\t\t},\n\t};\n\n\treturn ChangeInternal.detach(source, saveDetached ? insert.source : undefined);\n}\n\n/**\n * If a detach does not include a destination, its inverse is a build and insert. Otherwise, it is just an insert.\n * Information on the nodes that were detached is obtained by going to the revision before the detach.\n *\n * The anchor for the resulting Insert is chosen in the following order:\n *\n * ```markdown\n * 1. If detach.source.start.side is After: detach.source.start\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"After B\", the anchor for the resulting Insert will also be \"After B\".\n *\n * For nodes [A..F] G H where [A..F] represents the detached nodes,\n * if detach.source.start is \"After start of trait\", the anchor for the resulting Insert will also be\n * \"After start of trait\".\n *\n * 2. Else if detach.source.end.side is Before: detach.source.end\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"Before C\" and detach.source.end is \"Before G\",\n * the anchor for the resulting Insert will be \"Before G\".\n *\n * 3. Else: After the node directly to the left of the originally detached nodes\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"Before C\" and detach.source.end is \"After F\",\n * the anchor for the resulting Insert will be \"After B\".\n * ```\n *\n * When choosing the anchor, the existing anchors on detach.source are preferred when they have a valid sibling.\n * Otherwise, the valid anchor to the left of the originally detached nodes is chosen.\n */\nfunction createInvertedDetach(\n\tdetach: DetachInternal,\n\tviewBeforeChange: TreeView\n): { invertedDetach: ChangeInternal[]; detachedNodeIds: NodeId[] } | undefined {\n\tconst validatedSource = validateStableRange(viewBeforeChange, detach.source);\n\tif (validatedSource.result !== RangeValidationResultKind.Valid) {\n\t\t// TODO:#68574: having the reference view would potentially allow us to revert some detaches that currently conflict\n\t\treturn undefined;\n\t}\n\n\tconst { start, end } = rangeFromStableRange(viewBeforeChange, validatedSource);\n\tconst { trait: referenceTrait } = start;\n\tconst nodes = viewBeforeChange.getTrait(referenceTrait);\n\n\tconst startIndex = viewBeforeChange.findIndexWithinTrait(start);\n\tconst endIndex = viewBeforeChange.findIndexWithinTrait(end);\n\tconst detachedNodeIds: NodeId[] = nodes.slice(startIndex, endIndex);\n\n\tconst leftOfDetached = nodes.slice(0, startIndex);\n\n\tlet insertDestination: StablePlace;\n\n\tif (start.side === Side.After) {\n\t\tinsertDestination =\n\t\t\tstart.sibling === undefined\n\t\t\t\t? { side: Side.After, referenceTrait }\n\t\t\t\t: { side: Side.After, referenceSibling: start.sibling };\n\t} else if (end.side === Side.Before) {\n\t\tinsertDestination =\n\t\t\tend.sibling === undefined\n\t\t\t\t? { side: Side.Before, referenceTrait }\n\t\t\t\t: { side: Side.Before, referenceSibling: end.sibling };\n\t} else {\n\t\tconst referenceSibling = leftOfDetached.pop();\n\t\tinsertDestination = {\n\t\t\tside: Side.After,\n\t\t\treferenceSibling,\n\t\t\treferenceTrait: referenceSibling === undefined ? referenceTrait : undefined,\n\t\t};\n\t}\n\n\tif (detach.destination !== undefined) {\n\t\treturn {\n\t\t\tinvertedDetach: [ChangeInternal.insert(detach.destination, insertDestination)],\n\t\t\tdetachedNodeIds,\n\t\t};\n\t}\n\n\tconst detachedSequenceId = 0 as DetachedSequenceId;\n\treturn {\n\t\tinvertedDetach: [\n\t\t\tChangeInternal.build(\n\t\t\t\tdetachedNodeIds.map((id) => getChangeNodeFromViewNode(viewBeforeChange, id)),\n\t\t\t\tdetachedSequenceId\n\t\t\t),\n\t\t\tChangeInternal.insert(detachedSequenceId, insertDestination),\n\t\t],\n\t\tdetachedNodeIds,\n\t};\n}\n\n/**\n * The inverse of a SetValue is a SetValue that sets the value to what it was prior to the change.\n */\nfunction createInvertedSetValue(setValue: SetValueInternal, viewBeforeChange: TreeView): ChangeInternal[] | undefined {\n\tconst { nodeToModify } = setValue;\n\tconst node = viewBeforeChange.tryGetViewNode(nodeToModify);\n\tif (node === undefined) {\n\t\t// TODO:68574: With a reference view, may be able to better resolve conflicting sets\n\t\treturn undefined;\n\t}\n\n\t// Rationale: 'undefined' is reserved for future use (see 'SetValue' interface)\n\tif (node.payload !== null) {\n\t\treturn [ChangeInternal.setPayload(nodeToModify, node.payload)];\n\t}\n\treturn [ChangeInternal.clearPayload(nodeToModify)];\n}\n"]}
1
+ {"version":3,"file":"HistoryEditFactory.js","sourceRoot":"","sources":["../src/HistoryEditFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAEtD,+CAAiF;AACjF,qCAAgC;AAChC,2DAA2D;AAC3D,uDAU2B;AAC3B,+DAA4D;AAC5D,mDAAiF;AAIjF,qEAAqE;AAErE;;GAEG;AACH,IAAY,wBAGX;AAHD,WAAY,wBAAwB;IACnC,2DAA+B,CAAA;IAC/B,yDAA6B,CAAA;AAC9B,CAAC,EAHW,wBAAwB,GAAxB,gCAAwB,KAAxB,g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pF,OAAO,SAAS,CAAC;KACjB;IAED,+EAA+E;IAC/E,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;QAC1B,OAAO,CAAC,gCAAc,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;KAC/D;IACD,OAAO,CAAC,gCAAc,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from '@fluidframework/common-utils';\nimport { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';\nimport { DetachedSequenceId, isDetachedSequenceId, NodeId } from './Identifiers';\nimport { fail } from './Common';\nimport { rangeFromStableRange } from './TreeViewUtilities';\nimport {\n\tChangeInternal,\n\tChangeTypeInternal,\n\tDetachInternal,\n\tSetValueInternal,\n\tInsertInternal,\n\tBuildNodeInternal,\n\tSide,\n\tStableRangeInternal,\n\tEditStatus,\n} from './persisted-types';\nimport { TransactionInternal } from './TransactionInternal';\nimport { RangeValidationResultKind, validateStableRange } from './EditUtilities';\nimport { StablePlace } from './ChangeTypes';\nimport { RevisionView } from './RevisionView';\nimport { TreeView } from './TreeView';\nimport { getChangeNodeFromViewNode } from './SerializationUtilities';\n\n/**\n * Events emitted from the history edit factory\n */\nexport enum HistoryEditFactoryEvents {\n\tMalformedEdit = 'malformedEdit',\n\tMissingNodes = 'missingNodes',\n}\n\n/**\n * Given a sequence of changes, produces an inverse sequence of changes, i.e. the minimal changes required to revert the given changes\n * @param changes - the changes for which to produce an inverse.\n * @param before - a view of the tree state before `changes` are/were applied - used as a basis for generating the inverse.\n * @param logger - an optional logger for logging telemetry coming from the revert operation\n * @param emit - an optional event emitter to emit events from the revert operation and to allow clients to respond to them\n * @returns if the changes could be reverted, a sequence of changes _r_ that will produce `before` if applied to a view _A_, where _A_ is the result of\n * applying `changes` to `before`. Note that the size of the array of reverted changes may not be the same as the input array, and may even be empty in cases where\n * the view did not change. Applying _r_ to views other than _A_ is legal but may cause the changes to fail to apply or may not be a true semantic inverse.\n * If the changes could not be reverted given the state of `before`, returns undefined.\n *\n * TODO: what should this do if `changes` fails to apply to `before`?\n * TODO:#68574: Pass a view that corresponds to the appropriate Fluid reference sequence number rather than the view just before\n * @internal\n */\nexport function revert(\n\tchanges: readonly ChangeInternal[],\n\tbefore: RevisionView,\n\tlogger?: ITelemetryLoggerExt,\n\temit?: (event: string | symbol, ...args: any[]) => void\n): ChangeInternal[] | undefined {\n\tconst result: ChangeInternal[] = [];\n\n\tconst builtNodes = new Map<DetachedSequenceId, NodeId[]>();\n\tconst detachedNodes = new Map<DetachedSequenceId, NodeId[]>();\n\n\t// Open edit on revision to update it as changes are walked through\n\tconst editor = TransactionInternal.factory(before);\n\t// Apply `edit`, generating an inverse as we go.\n\tfor (const change of changes) {\n\t\t// Generate an inverse of each change\n\t\tswitch (change.type) {\n\t\t\tcase ChangeTypeInternal.Build: {\n\t\t\t\t// Save nodes added to the detached state for use in future changes\n\t\t\t\tconst { destination, source } = change;\n\t\t\t\tassert(\n\t\t\t\t\t!builtNodes.has(destination),\n\t\t\t\t\t0x626 /* Cannot revert Build: destination is already used by a Build */\n\t\t\t\t);\n\t\t\t\tassert(\n\t\t\t\t\t!detachedNodes.has(destination),\n\t\t\t\t\t0x627 /* Cannot revert Build: destination is already used by a Detach */\n\t\t\t\t);\n\t\t\t\tbuiltNodes.set(\n\t\t\t\t\tdestination,\n\t\t\t\t\tsource.reduce((ids: NodeId[], curr: BuildNodeInternal) => {\n\t\t\t\t\t\tif (isDetachedSequenceId(curr)) {\n\t\t\t\t\t\t\tconst nodesForDetachedSequence =\n\t\t\t\t\t\t\t\tbuiltNodes.get(curr) ?? fail('detached sequence must have associated built nodes');\n\n\t\t\t\t\t\t\tids.push(...nodesForDetachedSequence);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tids.push(curr.identifier);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn ids;\n\t\t\t\t\t}, [])\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.Insert: {\n\t\t\t\tconst { source } = change;\n\t\t\t\tconst nodesBuilt = builtNodes.get(source);\n\t\t\t\tconst nodesDetached = detachedNodes.get(source);\n\n\t\t\t\tif (nodesBuilt !== undefined) {\n\t\t\t\t\tif (nodesBuilt.length === 0) {\n\t\t\t\t\t\tbuiltNodes.delete(source);\n\t\t\t\t\t\tlogger?.sendTelemetryEvent({ eventName: 'reverting insertion of empty traits' });\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tresult.unshift(createInvertedInsert(change, nodesBuilt));\n\t\t\t\t\tbuiltNodes.delete(source);\n\t\t\t\t} else if (nodesDetached !== undefined) {\n\t\t\t\t\tif (nodesDetached.length === 0) {\n\t\t\t\t\t\tdetachedNodes.delete(source);\n\t\t\t\t\t\tlogger?.sendTelemetryEvent({ eventName: 'reverting insertion of empty traits' });\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tresult.unshift(createInvertedInsert(change, nodesDetached, true));\n\t\t\t\t\tdetachedNodes.delete(source);\n\t\t\t\t} else {\n\t\t\t\t\t// Cannot revert an insert whose source is no longer available for inserting (i.e. not just built, and not detached)\n\t\t\t\t\tif (emit !== undefined) {\n\t\t\t\t\t\temit(HistoryEditFactoryEvents.MissingNodes, change, changes);\n\t\t\t\t\t}\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.Detach: {\n\t\t\t\tconst { destination } = change;\n\t\t\t\tconst invert = createInvertedDetach(change, editor.view);\n\t\t\t\tif (invert === undefined) {\n\t\t\t\t\t// Cannot revert a detach whose source does not exist in the tree\n\t\t\t\t\t// TODO:68574: May not be possible once associated todo in `createInvertedDetach` is addressed\n\t\t\t\t\tif (emit !== undefined) {\n\t\t\t\t\t\temit(HistoryEditFactoryEvents.MissingNodes, change, changes);\n\t\t\t\t\t}\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tconst { invertedDetach, detachedNodeIds } = invert;\n\n\t\t\t\tif (detachedNodeIds.length === 0) {\n\t\t\t\t\tlogger?.sendTelemetryEvent({ eventName: 'reverting detachment of empty traits' });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (destination !== undefined) {\n\t\t\t\t\tif (builtNodes.has(destination) || detachedNodes.has(destination)) {\n\t\t\t\t\t\t// Malformed: destination was already used by a prior build or detach\n\t\t\t\t\t\tif (emit !== undefined) {\n\t\t\t\t\t\t\temit(HistoryEditFactoryEvents.MalformedEdit, change, changes);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\tdetachedNodes.set(destination, detachedNodeIds);\n\t\t\t\t}\n\n\t\t\t\tresult.unshift(...invertedDetach);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.SetValue: {\n\t\t\t\tconst invert = createInvertedSetValue(change, editor.view);\n\t\t\t\tif (invert === undefined) {\n\t\t\t\t\t// Cannot revert a set for a node that does not exist in the tree\n\t\t\t\t\t// TODO:68574: May not be possible once associated todo in `createInvertedSetValue` is addressed\n\t\t\t\t\tif (emit !== undefined) {\n\t\t\t\t\t\temit(HistoryEditFactoryEvents.MissingNodes, change, changes);\n\t\t\t\t\t}\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tresult.unshift(...invert);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ChangeTypeInternal.Constraint:\n\t\t\t\t// TODO:#46759: Support Constraint in reverts\n\t\t\t\tfail('Revert currently does not support Constraints');\n\t\t\tdefault:\n\t\t\t\tfail('Revert does not support the change type.');\n\t\t}\n\n\t\t// Abort the entire revert if this change can't be applied successfully.\n\t\tif (editor.applyChange(change).status !== EditStatus.Applied) {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\teditor.close();\n\treturn result;\n}\n\n/**\n * The inverse of an Insert is a Detach that starts before the leftmost node inserted and ends after the rightmost.\n */\nfunction createInvertedInsert(\n\tinsert: InsertInternal,\n\tnodesInserted: readonly NodeId[],\n\tsaveDetached = false\n): ChangeInternal {\n\tconst leftmostNode = nodesInserted[0];\n\tconst rightmostNode = nodesInserted[nodesInserted.length - 1];\n\n\tconst source: StableRangeInternal = {\n\t\tstart: {\n\t\t\treferenceSibling: leftmostNode,\n\t\t\tside: Side.Before,\n\t\t},\n\t\tend: {\n\t\t\treferenceSibling: rightmostNode,\n\t\t\tside: Side.After,\n\t\t},\n\t};\n\n\treturn ChangeInternal.detach(source, saveDetached ? insert.source : undefined);\n}\n\n/**\n * If a detach does not include a destination, its inverse is a build and insert. Otherwise, it is just an insert.\n * Information on the nodes that were detached is obtained by going to the revision before the detach.\n *\n * The anchor for the resulting Insert is chosen in the following order:\n *\n * ```markdown\n * 1. If detach.source.start.side is After: detach.source.start\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"After B\", the anchor for the resulting Insert will also be \"After B\".\n *\n * For nodes [A..F] G H where [A..F] represents the detached nodes,\n * if detach.source.start is \"After start of trait\", the anchor for the resulting Insert will also be\n * \"After start of trait\".\n *\n * 2. Else if detach.source.end.side is Before: detach.source.end\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"Before C\" and detach.source.end is \"Before G\",\n * the anchor for the resulting Insert will be \"Before G\".\n *\n * 3. Else: After the node directly to the left of the originally detached nodes\n *\n * ex: For nodes A B [C..F] G H where [C..F] represents the detached nodes,\n * if detach.source.start is \"Before C\" and detach.source.end is \"After F\",\n * the anchor for the resulting Insert will be \"After B\".\n * ```\n *\n * When choosing the anchor, the existing anchors on detach.source are preferred when they have a valid sibling.\n * Otherwise, the valid anchor to the left of the originally detached nodes is chosen.\n */\nfunction createInvertedDetach(\n\tdetach: DetachInternal,\n\tviewBeforeChange: TreeView\n): { invertedDetach: ChangeInternal[]; detachedNodeIds: NodeId[] } | undefined {\n\tconst validatedSource = validateStableRange(viewBeforeChange, detach.source);\n\tif (validatedSource.result !== RangeValidationResultKind.Valid) {\n\t\t// TODO:#68574: having the reference view would potentially allow us to revert some detaches that currently conflict\n\t\treturn undefined;\n\t}\n\n\tconst { start, end } = rangeFromStableRange(viewBeforeChange, validatedSource);\n\tconst { trait: referenceTrait } = start;\n\tconst nodes = viewBeforeChange.getTrait(referenceTrait);\n\n\tconst startIndex = viewBeforeChange.findIndexWithinTrait(start);\n\tconst endIndex = viewBeforeChange.findIndexWithinTrait(end);\n\tconst detachedNodeIds: NodeId[] = nodes.slice(startIndex, endIndex);\n\n\tconst leftOfDetached = nodes.slice(0, startIndex);\n\n\tlet insertDestination: StablePlace;\n\n\tif (start.side === Side.After) {\n\t\tinsertDestination =\n\t\t\tstart.sibling === undefined\n\t\t\t\t? { side: Side.After, referenceTrait }\n\t\t\t\t: { side: Side.After, referenceSibling: start.sibling };\n\t} else if (end.side === Side.Before) {\n\t\tinsertDestination =\n\t\t\tend.sibling === undefined\n\t\t\t\t? { side: Side.Before, referenceTrait }\n\t\t\t\t: { side: Side.Before, referenceSibling: end.sibling };\n\t} else {\n\t\tconst referenceSibling = leftOfDetached.pop();\n\t\tinsertDestination = {\n\t\t\tside: Side.After,\n\t\t\treferenceSibling,\n\t\t\treferenceTrait: referenceSibling === undefined ? referenceTrait : undefined,\n\t\t};\n\t}\n\n\tif (detach.destination !== undefined) {\n\t\treturn {\n\t\t\tinvertedDetach: [ChangeInternal.insert(detach.destination, insertDestination)],\n\t\t\tdetachedNodeIds,\n\t\t};\n\t}\n\n\tconst detachedSequenceId = 0 as DetachedSequenceId;\n\treturn {\n\t\tinvertedDetach: [\n\t\t\tChangeInternal.build(\n\t\t\t\tdetachedNodeIds.map((id) => getChangeNodeFromViewNode(viewBeforeChange, id)),\n\t\t\t\tdetachedSequenceId\n\t\t\t),\n\t\t\tChangeInternal.insert(detachedSequenceId, insertDestination),\n\t\t],\n\t\tdetachedNodeIds,\n\t};\n}\n\n/**\n * The inverse of a SetValue is a SetValue that sets the value to what it was prior to the change.\n */\nfunction createInvertedSetValue(setValue: SetValueInternal, viewBeforeChange: TreeView): ChangeInternal[] | undefined {\n\tconst { nodeToModify } = setValue;\n\tconst node = viewBeforeChange.tryGetViewNode(nodeToModify);\n\tif (node === undefined) {\n\t\t// TODO:68574: With a reference view, may be able to better resolve conflicting sets\n\t\treturn undefined;\n\t}\n\n\t// Rationale: 'undefined' is reserved for future use (see 'SetValue' interface)\n\tif (node.payload !== null) {\n\t\treturn [ChangeInternal.setPayload(nodeToModify, node.payload)];\n\t}\n\treturn [ChangeInternal.clearPayload(nodeToModify)];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MergeHealth.d.ts","sourceRoot":"","sources":["../src/MergeHealth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAsC,UAAU,EAAE,MAAM,cAAc,CAAC;AAG9E;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAgBzF;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;;;;;;;;;OAaG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;;;;;;;;OASG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;;;;;;;;;;OAaG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,4BAA4B,EAAE,MAAM,CAAC;IAErC;;;OAGG;IACH,4BAA4B,EAAE,MAAM,CAAC;IAErC;;;OAGG;IACH,2BAA2B,EAAE,MAAM,CAAC;IAEpC;;;;OAIG;IACH,2BAA2B,EAAE,MAAM,CAAC;IAEpC;;;OAGG;IACH,yBAAyB,E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