@fluid-experimental/tree 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/EditLog.d.ts.map +1 -1
  2. package/dist/EditLog.js +4 -7
  3. package/dist/EditLog.js.map +1 -1
  4. package/dist/LogViewer.d.ts.map +1 -1
  5. package/dist/LogViewer.js +1 -7
  6. package/dist/LogViewer.js.map +1 -1
  7. package/dist/SharedTree.d.ts.map +1 -1
  8. package/dist/SharedTree.js +12 -12
  9. package/dist/SharedTree.js.map +1 -1
  10. package/dist/SharedTreeEncoder.d.ts.map +1 -1
  11. package/dist/SharedTreeEncoder.js +6 -12
  12. package/dist/SharedTreeEncoder.js.map +1 -1
  13. package/dist/TransactionInternal.d.ts.map +1 -1
  14. package/dist/TransactionInternal.js +4 -7
  15. package/dist/TransactionInternal.js.map +1 -1
  16. package/dist/id-compressor/IdCompressor.d.ts +3 -1
  17. package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
  18. package/dist/id-compressor/IdCompressor.js +45 -17
  19. package/dist/id-compressor/IdCompressor.js.map +1 -1
  20. package/lib/EditLog.d.ts.map +1 -1
  21. package/lib/EditLog.js +4 -7
  22. package/lib/EditLog.js.map +1 -1
  23. package/lib/LogViewer.d.ts.map +1 -1
  24. package/lib/LogViewer.js +1 -7
  25. package/lib/LogViewer.js.map +1 -1
  26. package/lib/SharedTree.d.ts.map +1 -1
  27. package/lib/SharedTree.js +12 -12
  28. package/lib/SharedTree.js.map +1 -1
  29. package/lib/SharedTreeEncoder.d.ts.map +1 -1
  30. package/lib/SharedTreeEncoder.js +6 -12
  31. package/lib/SharedTreeEncoder.js.map +1 -1
  32. package/lib/TransactionInternal.d.ts.map +1 -1
  33. package/lib/TransactionInternal.js +4 -7
  34. package/lib/TransactionInternal.js.map +1 -1
  35. package/lib/id-compressor/IdCompressor.d.ts +3 -1
  36. package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
  37. package/lib/id-compressor/IdCompressor.js +45 -17
  38. package/lib/id-compressor/IdCompressor.js.map +1 -1
  39. package/lib/test/MergeHealthTelemetryHeartbeat.tests.js +1 -1
  40. package/lib/test/MergeHealthTelemetryHeartbeat.tests.js.map +1 -1
  41. package/lib/test/SessionIdNormalizer.tests.js +4 -6
  42. package/lib/test/SessionIdNormalizer.tests.js.map +1 -1
  43. package/lib/test/Summary.tests.js +3 -6
  44. package/lib/test/Summary.tests.js.map +1 -1
  45. package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
  46. package/lib/test/utilities/SharedTreeTests.js +33 -11
  47. package/lib/test/utilities/SharedTreeTests.js.map +1 -1
  48. package/lib/test/utilities/TestNode.d.ts.map +1 -1
  49. package/lib/test/utilities/TestNode.js +2 -12
  50. package/lib/test/utilities/TestNode.js.map +1 -1
  51. package/package.json +18 -18
  52. package/src/EditLog.ts +21 -23
  53. package/src/LogViewer.ts +1 -6
  54. package/src/SharedTree.ts +17 -16
  55. package/src/SharedTreeEncoder.ts +6 -17
  56. package/src/TransactionInternal.ts +11 -13
  57. package/src/id-compressor/IdCompressor.ts +46 -15
@@ -1 +1 @@
1
- {"version":3,"file":"EditLog.d.ts","sourceRoot":"","sources":["../src/EditLog.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEnF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAiB,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAExG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,WAAW,cA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,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS;IAIzF;;;OAGG;IACI,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI;IAO9C,OAAO,CAAC,OAAO;IAMf;;OAEG;IACI,MAAM,CAAC,yBAAyB,EAAE,KAAK,EAAE,OAAO,CAAC,yBAAyB,CAAC,GAAG,OAAO;IAM5F;;;OAGG;IACI,iBAAiB,IAAI,cAAc,CAAC,OAAO,EAAE,eAAe,CAAC;IACpE;;;;OAIG;IACI,iBAAiB,CAAC,iBAAiB,EACzC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC,GAC9F,cAAc,CAAC,iBAAiB,EAAE,eAAe,CAAC;IA2BrD,OAAO,CAAC,aAAa;CAqBrB"}
package/dist/EditLog.js CHANGED
@@ -395,8 +395,8 @@ class EditLog extends common_utils_1.TypedEventEmitter {
395
395
  return (0, Common_1.compareArrays)(this.editIds, other.editIds);
396
396
  }
397
397
  getEditLogSummary(compressEdit) {
398
- if (compressEdit !== undefined) {
399
- return {
398
+ return compressEdit !== undefined
399
+ ? {
400
400
  editChunks: this.editChunks.toArray().map(([startRevision, { handle, edits }]) => {
401
401
  var _a, _b;
402
402
  return ({
@@ -405,10 +405,8 @@ class EditLog extends common_utils_1.TypedEventEmitter {
405
405
  });
406
406
  }),
407
407
  editIds: this.sequencedEditIds,
408
- };
409
- }
410
- else {
411
- return {
408
+ }
409
+ : {
412
410
  editChunks: this.editChunks.toArray().map(([startRevision, { handle, edits }]) => {
413
411
  var _a, _b;
414
412
  return ({
@@ -418,7 +416,6 @@ class EditLog extends common_utils_1.TypedEventEmitter {
418
416
  }),
419
417
  editIds: this.sequencedEditIds,
420
418
  };
421
- }
422
419
  }
423
420
  addKeyToCache(newKey) {
424
421
  // Indices are only added to the cache if they are not higher than the maximum evicted index.
@@ -1 +1 @@
1
- {"version":3,"file":"EditLog.js","sourceRoot":"","sources":["../src/EditLog.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,gEAAiC;AACjC,+DAAiE;AAEjE,qCAAiG;AAGjG,uDAAwG;AACxG,6CAAyD;AAmIzD;;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,EAAE,IAAI,CAAC,EAAE,EAAE,aAAa,EAAE,CAAC;AACvC,CAAC;AAPD,8CAOC;AAED,SAAS,aAAa,CAAU,EAAU,EAAE,IAA4B;IACvE,uBAAS,EAAE,IAAK,IAAI,EAAG;AACxB,CAAC;AAED;;;GAGG;AACH,SAAgB,oCAAoC,CAAC,OAAyC;IAC7F,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE/B,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;QAChC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC1B,eAAe,EAAE,CAAC;SAClB;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;AACxB,CAAC;AAXD,oFAWC;AAED;;;;KAIK;AACL,MAAM,oBAAoB,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAiBtD;;;;;;GAMG;AACH,MAAa,OAA2B,SAAQ,gCAAiC;IAmChF;;;;OAIG;IACH,YACC,UAAwD,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,EACvF,MAAyB,EACzB,oBAA0D,EAAE,EAC5D,yBAAyB,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM;QAElD,KAAK,EAAE,CA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BACF,YAAY,CAAC,KAAK,GAAG,SAAS,CAAC;aAC/B;SACD;IACF,CAAC;CACD;AAxeD,0BAweC;AAED,SAAS,YAAY,CACpB,KAA8D;IAE9D,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC","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 } from '@fluidframework/common-utils';\nimport type { IEvent, ITelemetryLogger } from '@fluidframework/common-definitions';\nimport { assert, assertNotUndefined, compareArrays, compareFiniteNumbers, fail } from './Common';\nimport type { EditId } from './Identifiers';\nimport type { StringInterner } from './StringInterner';\nimport { Edit, EditLogSummary, editsPerChunk, EditWithoutId, FluidEditHandle } from './persisted-types';\nimport { SharedTreeDiagnosticEvent } from './EventTypes';\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 * Edits are virtualized, however, edits added during the current session are guaranteed to be available\n * synchronously.\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\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 */\n\tgetEditInSessionAtIndex(index: number): Edit<TChange>;\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 */\n\ttryGetEdit(editId: EditId): Promise<Edit<TChange> | undefined>;\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 */\nexport interface EditChunk<TChange> {\n\thandle?: EditHandle<TChange>;\n\tedits?: EditWithoutId<TChange>[];\n}\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 * @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\nfunction joinEditAndId<TChange>(id: EditId, edit: EditWithoutId<TChange>): Edit<TChange> {\n\treturn { id, ...edit };\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 */\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 * The number of blobs to be loaded in memory at any time.\n * TODO:#49901: Change cache size once the virtualized history summary format is being written.\n * \t\t This is so the summarizer doesn't have to reload every edit to generate summaries.\n * */\nconst loadedChunkCacheSize = Number.POSITIVE_INFINITY;\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 * Events which may be emitted by `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\tprivate _minSequenceNumber = 0;\n\n\tprivate readonly sequencedEditIds: EditId[];\n\tprivate readonly editChunks: BTree<number, EditChunk<TChange>>;\n\tprivate readonly localEdits: Edit<TChange>[] = [];\n\tprivate readonly loadedChunkCache: number[] = [];\n\tprivate readonly indexOfFirstEditInSession: number;\n\tprivate readonly maximumEvictableIndex: number;\n\n\tprivate readonly allEditIds: Map<EditId, OrderedEditId> = new Map();\n\tprivate readonly _editAddedHandlers: Set<EditAddedHandler<TChange>> = new Set();\n\n\tprivate readonly logger?: ITelemetryLogger;\n\n\t/**\n\t * The number of edits associated with each blob.\n\t */\n\tpublic readonly editsPerChunk: number;\n\n\t/**\n\t * @returns The index of the earliest edit available through `getEditInSessionAtIndex`.\n\t */\n\tpublic get earliestAvailableEditIndex(): number {\n\t\treturn this.maximumEvictableIndex + 1;\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 */\n\tpublic constructor(\n\t\tsummary: EditLogSummary<TChange, EditHandle<TChange>> = { editIds: [], editChunks: [] },\n\t\tlogger?: ITelemetryLogger,\n\t\teditAddedHandlers: readonly EditAddedHandler<TChange>[] = [],\n\t\tindexOfFirstEditInSession = summary.editIds.length\n\t) {\n\t\tsuper();\n\t\tconst { editChunks, editIds } = summary;\n\t\tthis.logger = logger;\n\t\tthis.editsPerChunk = editsPerChunk;\n\n\t\tfor (const handler of editAddedHandlers) {\n\t\t\tthis.registerEditAddedHandler(handler);\n\t\t}\n\n\t\tthis.editChunks = new BTree<number, EditChunk<TChange>>(undefined, compareFiniteNumbers);\n\n\t\teditChunks.forEach((editChunkOrHandle) => {\n\t\t\tconst { startRevision, chunk } = editChunkOrHandle;\n\n\t\t\tif (isEditHandle(chunk)) {\n\t\t\t\tthis.editChunks.set(startRevision, { handle: chunk });\n\t\t\t} else {\n\t\t\t\tthis.editChunks.set(startRevision, { edits: chunk as EditWithoutId<TChange>[] });\n\t\t\t}\n\t\t});\n\n\t\tthis.sequencedEditIds = editIds.slice();\n\n\t\tthis.indexOfFirstEditInSession = indexOfFirstEditInSession;\n\t\tthis.maximumEvictableIndex = this.indexOfFirstEditInSession - 1;\n\n\t\tthis.sequencedEditIds.forEach((id, index) => {\n\t\t\tconst encounteredEditId = this.allEditIds.get(id);\n\t\t\tassert(encounteredEditId === undefined, 'Duplicate acked edit.');\n\t\t\tthis.allEditIds.set(id, { isLocal: false, index });\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 * {@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.sequencedEditIds.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.sequencedEditIds.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.sequencedEditIds.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 = assertNotUndefined(this.allEditIds.get(this.localEdits[0].id));\n\t\t\tassert(firstLocal.isLocal);\n\t\t\treturn this.numberOfSequencedEdits + orderedEdit.localSequence - firstLocal.localSequence;\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 assertNotUndefined(this.allEditIds.get(editId), '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.numberOfSequencedEdits <= index) {\n\t\t\treturn this.localEdits[index - this.numberOfSequencedEdits].id;\n\t\t}\n\n\t\treturn this.sequencedEditIds[index];\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.getEditAtIndex}\n\t */\n\tpublic async getEditAtIndex(index: number): Promise<Edit<TChange>> {\n\t\tif (index < this.numberOfSequencedEdits) {\n\t\t\tconst [startRevision, editChunk] = assertNotUndefined(this.editChunks.getPairOrNextLower(index));\n\t\t\tconst { handle, edits } = editChunk;\n\n\t\t\tif (edits === undefined) {\n\t\t\t\tassert(handle !== undefined, 'An edit chunk should include at least a handle or edits.');\n\t\t\t\tconst edits = await handle.get();\n\n\t\t\t\t// Make sure the loaded edit chunk is the correct size. If a higher starting revison is set, the length is the difference of both.\n\t\t\t\t// Otherwise, it means that there are no sequenced edits in memory so the length is the difference of the number of\n\t\t\t\t// sequenced edits and the starting revision.\n\t\t\t\tconst nextKey = this.editChunks.nextHigherKey(index);\n\t\t\t\tconst expectedEditLength =\n\t\t\t\t\t(nextKey === undefined ? this.numberOfSequencedEdits : nextKey) - startRevision;\n\t\t\t\tassert(edits.length === expectedEditLength, 'The chunk does not contain the correct number of edits.');\n\n\t\t\t\teditChunk.edits = edits;\n\n\t\t\t\tthis.addKeyToCache(startRevision);\n\t\t\t\treturn joinEditAndId(this.getIdAtIndex(index), edits[index - startRevision]);\n\t\t\t}\n\n\t\t\treturn joinEditAndId(this.getIdAtIndex(index), edits[index - startRevision]);\n\t\t}\n\n\t\treturn this.localEdits[index - this.numberOfSequencedEdits];\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.getEditInSessionAtIndex}\n\t */\n\tpublic getEditInSessionAtIndex(index: number): Edit<TChange> {\n\t\tassert(\n\t\t\tindex > this.maximumEvictableIndex,\n\t\t\t'Edit to retrieve must have been added to the log during the current session.'\n\t\t);\n\n\t\tif (index < this.numberOfSequencedEdits) {\n\t\t\tconst [startRevision, editChunk] = assertNotUndefined(this.editChunks.getPairOrNextLower(index));\n\t\t\tconst { edits } = editChunk;\n\n\t\t\treturn joinEditAndId(\n\t\t\t\tthis.getIdAtIndex(index),\n\t\t\t\tassertNotUndefined(edits, 'Edits should not have been evicted.')[index - startRevision]\n\t\t\t);\n\t\t}\n\n\t\tassert(index - this.numberOfSequencedEdits < this.localEdits.length, 'Edit to retrieve must be in the log.');\n\t\treturn this.localEdits[index - this.numberOfSequencedEdits];\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.tryGetEdit}\n\t */\n\tpublic async tryGetEdit(editId: EditId): Promise<Edit<TChange> | undefined> {\n\t\ttry {\n\t\t\tconst index = this.getIndexOfId(editId);\n\t\t\treturn await this.getEditAtIndex(index);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * @returns The edits of edit chunks that do not have associated edit handles, does not include the last edit chunk if it is not full.\n\t */\n\tpublic *getEditChunksReadyForUpload(): Iterable<[number, readonly EditWithoutId<TChange>[]]> {\n\t\tconst maxStartRevision = this.editChunks.maxKey();\n\n\t\tif (maxStartRevision === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const [startRevision, chunk] of this.editChunks.entries(undefined, [])) {\n\t\t\tif (chunk.handle === undefined) {\n\t\t\t\tconst edits = assertNotUndefined(chunk.edits);\n\n\t\t\t\t// If there is no handle, the chunk should either not be the last chunk or should be full if it is.\n\t\t\t\tif (maxStartRevision !== startRevision || edits.length >= this.editsPerChunk) {\n\t\t\t\t\tyield [startRevision, edits];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Assigns provided handles to edit chunks based on chunk index specified.\n\t */\n\tpublic processEditChunkHandle(chunkHandle: EditHandle<TChange>, startRevision: number): void {\n\t\tconst chunk = this.editChunks.get(startRevision);\n\t\tif (chunk !== undefined) {\n\t\t\tassertNotUndefined(\n\t\t\t\tchunk.edits,\n\t\t\t\t'A chunk handle op should not be received before the edit ops it corresponds to.'\n\t\t\t);\n\t\t\tchunk.handle = chunkHandle;\n\t\t\tthis.addKeyToCache(startRevision);\n\t\t} else {\n\t\t\tthis.logger?.sendErrorEvent({ eventName: 'UnexpectedHistoryChunk' });\n\t\t\tthis.emit(SharedTreeDiagnosticEvent.UnexpectedHistoryChunk);\n\t\t}\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\tconst { id, editWithoutId } = separateEditAndId(edit);\n\n\t\tassert(\n\t\t\tminSequenceNumber >= this.minSequenceNumber,\n\t\t\t'Sequenced edits should carry a monotonically increasing min number'\n\t\t);\n\t\t// The new minSequenceNumber indicates that no future edit will require information from edits with a smaller or equal seq number\n\t\t// for its resolution.\n\t\tthis._minSequenceNumber = minSequenceNumber;\n\t\t// TODO:#57176: Increment maximumEvictableIndex to reflect the fact we can now evict edits with a sequenceNumber lower or equal to\n\t\t// it. Note that this will change the meaning of our 'InSession' APIs so we should make sure to rename them at the same time.\n\t\t// The code might look like this:\n\t\t// while (this.maximumEvictableIndex + 1 < this.indexOfFirstEditInSession) {\n\t\t// \tconst nextEdit = this.getEditInSessionAtIndex(this.maximumEvictableIndex + 1);\n\t\t// \tconst nextEditInfo = this.getOrderedEditId(nextEdit.id) as SequencedOrderedEditId;\n\t\t// \tif (\n\t\t// \t\tnextEditInfo.sequenceInfo !== undefined &&\n\t\t// \t\tnextEditInfo.sequenceInfo.sequenceNumber > minSequenceNumber\n\t\t// \t) {\n\t\t// \t\tbreak;\n\t\t// \t}\n\t\t// \t++this.maximumEvictableIndex;\n\t\t// }\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, 'Duplicate acked edit.');\n\t\t\t// Remove it from localEdits. Due to ordering requirements, it must be first.\n\t\t\tconst oldLocalEditId = assertNotUndefined(this.localEdits.shift(), 'Local edit should exist').id;\n\t\t\tassert(oldLocalEditId === id, 'Causal ordering should be upheld');\n\t\t}\n\n\t\t// The starting revision for a newly created chunk.\n\t\tconst startRevision = this.numberOfSequencedEdits;\n\t\t// The initial edits for a newly created chunk.\n\t\tconst edits: EditWithoutId<TChange>[] = [editWithoutId];\n\n\t\tconst lastPair = this.editChunks.nextLowerPair(undefined);\n\t\tif (lastPair === undefined) {\n\t\t\tthis.editChunks.set(startRevision, { edits });\n\t\t} else {\n\t\t\t// Add to the last edit chunk if it has room and hasn't already been uploaded, otherwise create a new chunk.\n\t\t\t// If the chunk has a corresponding handle, create a new chunk.\n\t\t\tconst { edits: lastEditChunk, handle } = lastPair[1];\n\t\t\tif (handle === undefined && lastEditChunk !== undefined && lastEditChunk.length < this.editsPerChunk) {\n\t\t\t\tlastEditChunk.push(editWithoutId);\n\t\t\t} else {\n\t\t\t\tassert(\n\t\t\t\t\thandle !== undefined || lastEditChunk !== undefined,\n\t\t\t\t\t'An edit chunk must have either a handle or a list of edits.'\n\t\t\t\t);\n\t\t\t\tthis.editChunks.set(startRevision, { edits });\n\t\t\t}\n\t\t}\n\n\t\tthis.sequencedEditIds.push(id);\n\t\tconst sequencedEditId: SequencedOrderedEditId = {\n\t\t\tindex: this.numberOfSequencedEdits - 1,\n\t\t\tisLocal: false,\n\t\t\tsequenceInfo: info,\n\t\t};\n\t\tthis.allEditIds.set(id, sequencedEditId);\n\t\tthis.emitAdd(edit, false, encounteredEditId !== undefined);\n\t}\n\n\t/**\n\t * @returns The last edit chunk i.e. the chunk which the most recent sequenced edits have been placed into, as well as its starting revision.\n\t * Returns undefined iff there are no sequenced edits.\n\t * When defined, this chunk is guaranteed to contain at least one edit\n\t * (though it may be necessary to load the chunk via its handle to use it)\n\t */\n\tpublic getLastEditChunk(): [startRevision: number, edits: EditChunk<TChange>] | undefined {\n\t\treturn this.editChunks.nextLowerPair(undefined);\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\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\tif (compressEdit !== undefined) {\n\t\t\treturn {\n\t\t\t\teditChunks: this.editChunks.toArray().map(([startRevision, { handle, edits }]) => ({\n\t\t\t\t\tstartRevision,\n\t\t\t\t\tchunk:\n\t\t\t\t\t\thandle?.baseHandle ??\n\t\t\t\t\t\tedits?.map((edit) => compressEdit(edit)) ??\n\t\t\t\t\t\tfail('An edit chunk must have either a handle or a list of edits.'),\n\t\t\t\t})),\n\t\t\t\teditIds: this.sequencedEditIds,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\teditChunks: this.editChunks.toArray().map(([startRevision, { handle, edits }]) => ({\n\t\t\t\t\tstartRevision,\n\t\t\t\t\tchunk:\n\t\t\t\t\t\thandle?.baseHandle ??\n\t\t\t\t\t\tedits ??\n\t\t\t\t\t\tfail('An edit chunk must have either a handle or a list of edits.'),\n\t\t\t\t})),\n\t\t\t\teditIds: this.sequencedEditIds,\n\t\t\t};\n\t\t}\n\t}\n\n\tprivate addKeyToCache(newKey: number): void {\n\t\t// Indices are only added to the cache if they are not higher than the maximum evicted index.\n\t\tif (newKey <= this.maximumEvictableIndex) {\n\t\t\t// If the new index is already in the cache, remove it first to update its last usage.\n\t\t\tif (newKey in this.loadedChunkCache) {\n\t\t\t\tthis.loadedChunkCache.splice(this.loadedChunkCache.indexOf(newKey), 1);\n\t\t\t}\n\n\t\t\tthis.loadedChunkCache.push(newKey);\n\n\t\t\t// If the cache is out of space, evict the oldest index in the cache.\n\t\t\tif (this.loadedChunkCache.length > loadedChunkCacheSize) {\n\t\t\t\tconst indexToEvict = assertNotUndefined(this.loadedChunkCache.shift());\n\t\t\t\tconst chunkToEvict = assertNotUndefined(\n\t\t\t\t\tthis.editChunks.get(indexToEvict),\n\t\t\t\t\t'Chunk start revision added to cache should exist in the edit log.'\n\t\t\t\t);\n\t\t\t\tchunkToEvict.edits = undefined;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction isEditHandle<TChange>(\n\tchunk: EditHandle<TChange> | readonly EditWithoutId<unknown>[]\n): chunk is EditHandle<TChange> {\n\treturn !Array.isArray(chunk);\n}\n"]}
1
+ {"version":3,"file":"EditLog.js","sourceRoot":"","sources":["../src/EditLog.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,gEAAiC;AACjC,+DAAiE;AAEjE,qCAAiG;AAGjG,uDAAwG;AACxG,6CAAyD;AAmIzD;;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,EAAE,IAAI,CAAC,EAAE,EAAE,aAAa,EAAE,CAAC;AACvC,CAAC;AAPD,8CAOC;AAED,SAAS,aAAa,CAAU,EAAU,EAAE,IAA4B;IACvE,uBAAS,EAAE,IAAK,IAAI,EAAG;AACxB,CAAC;AAED;;;GAGG;AACH,SAAgB,oCAAoC,CAAC,OAAyC;IAC7F,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE/B,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;QAChC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC1B,eAAe,EAAE,CAAC;SAClB;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;AACxB,CAAC;AAXD,oFAWC;AAED;;;;KAIK;AACL,MAAM,oBAAoB,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAiBtD;;;;;;GAMG;AACH,MAAa,OAA2B,SAAQ,g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AAkB,EAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAC;gBACvE,MAAM,YAAY,GAAG,IAAA,2BAAkB,EACtC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,EACjC,mEAAmE,CACnE,CAAC;gBACF,YAAY,CAAC,KAAK,GAAG,SAAS,CAAC;aAC/B;SACD;IACF,CAAC;CACD;AAteD,0BAseC;AAED,SAAS,YAAY,CACpB,KAA8D;IAE9D,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC","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 } from '@fluidframework/common-utils';\nimport type { IEvent, ITelemetryLogger } from '@fluidframework/common-definitions';\nimport { assert, assertNotUndefined, compareArrays, compareFiniteNumbers, fail } from './Common';\nimport type { EditId } from './Identifiers';\nimport type { StringInterner } from './StringInterner';\nimport { Edit, EditLogSummary, editsPerChunk, EditWithoutId, FluidEditHandle } from './persisted-types';\nimport { SharedTreeDiagnosticEvent } from './EventTypes';\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 * Edits are virtualized, however, edits added during the current session are guaranteed to be available\n * synchronously.\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\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 */\n\tgetEditInSessionAtIndex(index: number): Edit<TChange>;\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 */\n\ttryGetEdit(editId: EditId): Promise<Edit<TChange> | undefined>;\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 */\nexport interface EditChunk<TChange> {\n\thandle?: EditHandle<TChange>;\n\tedits?: EditWithoutId<TChange>[];\n}\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 * @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\nfunction joinEditAndId<TChange>(id: EditId, edit: EditWithoutId<TChange>): Edit<TChange> {\n\treturn { id, ...edit };\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 */\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 * The number of blobs to be loaded in memory at any time.\n * TODO:#49901: Change cache size once the virtualized history summary format is being written.\n * \t\t This is so the summarizer doesn't have to reload every edit to generate summaries.\n * */\nconst loadedChunkCacheSize = Number.POSITIVE_INFINITY;\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 * Events which may be emitted by `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\tprivate _minSequenceNumber = 0;\n\n\tprivate readonly sequencedEditIds: EditId[];\n\tprivate readonly editChunks: BTree<number, EditChunk<TChange>>;\n\tprivate readonly localEdits: Edit<TChange>[] = [];\n\tprivate readonly loadedChunkCache: number[] = [];\n\tprivate readonly indexOfFirstEditInSession: number;\n\tprivate readonly maximumEvictableIndex: number;\n\n\tprivate readonly allEditIds: Map<EditId, OrderedEditId> = new Map();\n\tprivate readonly _editAddedHandlers: Set<EditAddedHandler<TChange>> = new Set();\n\n\tprivate readonly logger?: ITelemetryLogger;\n\n\t/**\n\t * The number of edits associated with each blob.\n\t */\n\tpublic readonly editsPerChunk: number;\n\n\t/**\n\t * @returns The index of the earliest edit available through `getEditInSessionAtIndex`.\n\t */\n\tpublic get earliestAvailableEditIndex(): number {\n\t\treturn this.maximumEvictableIndex + 1;\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 */\n\tpublic constructor(\n\t\tsummary: EditLogSummary<TChange, EditHandle<TChange>> = { editIds: [], editChunks: [] },\n\t\tlogger?: ITelemetryLogger,\n\t\teditAddedHandlers: readonly EditAddedHandler<TChange>[] = [],\n\t\tindexOfFirstEditInSession = summary.editIds.length\n\t) {\n\t\tsuper();\n\t\tconst { editChunks, editIds } = summary;\n\t\tthis.logger = logger;\n\t\tthis.editsPerChunk = editsPerChunk;\n\n\t\tfor (const handler of editAddedHandlers) {\n\t\t\tthis.registerEditAddedHandler(handler);\n\t\t}\n\n\t\tthis.editChunks = new BTree<number, EditChunk<TChange>>(undefined, compareFiniteNumbers);\n\n\t\teditChunks.forEach((editChunkOrHandle) => {\n\t\t\tconst { startRevision, chunk } = editChunkOrHandle;\n\n\t\t\tif (isEditHandle(chunk)) {\n\t\t\t\tthis.editChunks.set(startRevision, { handle: chunk });\n\t\t\t} else {\n\t\t\t\tthis.editChunks.set(startRevision, { edits: chunk as EditWithoutId<TChange>[] });\n\t\t\t}\n\t\t});\n\n\t\tthis.sequencedEditIds = editIds.slice();\n\n\t\tthis.indexOfFirstEditInSession = indexOfFirstEditInSession;\n\t\tthis.maximumEvictableIndex = this.indexOfFirstEditInSession - 1;\n\n\t\tthis.sequencedEditIds.forEach((id, index) => {\n\t\t\tconst encounteredEditId = this.allEditIds.get(id);\n\t\t\tassert(encounteredEditId === undefined, 'Duplicate acked edit.');\n\t\t\tthis.allEditIds.set(id, { isLocal: false, index });\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 * {@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.sequencedEditIds.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.sequencedEditIds.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.sequencedEditIds.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 = assertNotUndefined(this.allEditIds.get(this.localEdits[0].id));\n\t\t\tassert(firstLocal.isLocal);\n\t\t\treturn this.numberOfSequencedEdits + orderedEdit.localSequence - firstLocal.localSequence;\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 assertNotUndefined(this.allEditIds.get(editId), '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.numberOfSequencedEdits <= index) {\n\t\t\treturn this.localEdits[index - this.numberOfSequencedEdits].id;\n\t\t}\n\n\t\treturn this.sequencedEditIds[index];\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.getEditAtIndex}\n\t */\n\tpublic async getEditAtIndex(index: number): Promise<Edit<TChange>> {\n\t\tif (index < this.numberOfSequencedEdits) {\n\t\t\tconst [startRevision, editChunk] = assertNotUndefined(this.editChunks.getPairOrNextLower(index));\n\t\t\tconst { handle, edits } = editChunk;\n\n\t\t\tif (edits === undefined) {\n\t\t\t\tassert(handle !== undefined, 'An edit chunk should include at least a handle or edits.');\n\t\t\t\tconst edits = await handle.get();\n\n\t\t\t\t// Make sure the loaded edit chunk is the correct size. If a higher starting revison is set, the length is the difference of both.\n\t\t\t\t// Otherwise, it means that there are no sequenced edits in memory so the length is the difference of the number of\n\t\t\t\t// sequenced edits and the starting revision.\n\t\t\t\tconst nextKey = this.editChunks.nextHigherKey(index);\n\t\t\t\tconst expectedEditLength =\n\t\t\t\t\t(nextKey === undefined ? this.numberOfSequencedEdits : nextKey) - startRevision;\n\t\t\t\tassert(edits.length === expectedEditLength, 'The chunk does not contain the correct number of edits.');\n\n\t\t\t\teditChunk.edits = edits;\n\n\t\t\t\tthis.addKeyToCache(startRevision);\n\t\t\t\treturn joinEditAndId(this.getIdAtIndex(index), edits[index - startRevision]);\n\t\t\t}\n\n\t\t\treturn joinEditAndId(this.getIdAtIndex(index), edits[index - startRevision]);\n\t\t}\n\n\t\treturn this.localEdits[index - this.numberOfSequencedEdits];\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.getEditInSessionAtIndex}\n\t */\n\tpublic getEditInSessionAtIndex(index: number): Edit<TChange> {\n\t\tassert(\n\t\t\tindex > this.maximumEvictableIndex,\n\t\t\t'Edit to retrieve must have been added to the log during the current session.'\n\t\t);\n\n\t\tif (index < this.numberOfSequencedEdits) {\n\t\t\tconst [startRevision, editChunk] = assertNotUndefined(this.editChunks.getPairOrNextLower(index));\n\t\t\tconst { edits } = editChunk;\n\n\t\t\treturn joinEditAndId(\n\t\t\t\tthis.getIdAtIndex(index),\n\t\t\t\tassertNotUndefined(edits, 'Edits should not have been evicted.')[index - startRevision]\n\t\t\t);\n\t\t}\n\n\t\tassert(index - this.numberOfSequencedEdits < this.localEdits.length, 'Edit to retrieve must be in the log.');\n\t\treturn this.localEdits[index - this.numberOfSequencedEdits];\n\t}\n\n\t/**\n\t * {@inheritDoc OrderedEditSet.tryGetEdit}\n\t */\n\tpublic async tryGetEdit(editId: EditId): Promise<Edit<TChange> | undefined> {\n\t\ttry {\n\t\t\tconst index = this.getIndexOfId(editId);\n\t\t\treturn await this.getEditAtIndex(index);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * @returns The edits of edit chunks that do not have associated edit handles, does not include the last edit chunk if it is not full.\n\t */\n\tpublic *getEditChunksReadyForUpload(): Iterable<[number, readonly EditWithoutId<TChange>[]]> {\n\t\tconst maxStartRevision = this.editChunks.maxKey();\n\n\t\tif (maxStartRevision === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const [startRevision, chunk] of this.editChunks.entries(undefined, [])) {\n\t\t\tif (chunk.handle === undefined) {\n\t\t\t\tconst edits = assertNotUndefined(chunk.edits);\n\n\t\t\t\t// If there is no handle, the chunk should either not be the last chunk or should be full if it is.\n\t\t\t\tif (maxStartRevision !== startRevision || edits.length >= this.editsPerChunk) {\n\t\t\t\t\tyield [startRevision, edits];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Assigns provided handles to edit chunks based on chunk index specified.\n\t */\n\tpublic processEditChunkHandle(chunkHandle: EditHandle<TChange>, startRevision: number): void {\n\t\tconst chunk = this.editChunks.get(startRevision);\n\t\tif (chunk !== undefined) {\n\t\t\tassertNotUndefined(\n\t\t\t\tchunk.edits,\n\t\t\t\t'A chunk handle op should not be received before the edit ops it corresponds to.'\n\t\t\t);\n\t\t\tchunk.handle = chunkHandle;\n\t\t\tthis.addKeyToCache(startRevision);\n\t\t} else {\n\t\t\tthis.logger?.sendErrorEvent({ eventName: 'UnexpectedHistoryChunk' });\n\t\t\tthis.emit(SharedTreeDiagnosticEvent.UnexpectedHistoryChunk);\n\t\t}\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\tconst { id, editWithoutId } = separateEditAndId(edit);\n\n\t\tassert(\n\t\t\tminSequenceNumber >= this.minSequenceNumber,\n\t\t\t'Sequenced edits should carry a monotonically increasing min number'\n\t\t);\n\t\t// The new minSequenceNumber indicates that no future edit will require information from edits with a smaller or equal seq number\n\t\t// for its resolution.\n\t\tthis._minSequenceNumber = minSequenceNumber;\n\t\t// TODO:#57176: Increment maximumEvictableIndex to reflect the fact we can now evict edits with a sequenceNumber lower or equal to\n\t\t// it. Note that this will change the meaning of our 'InSession' APIs so we should make sure to rename them at the same time.\n\t\t// The code might look like this:\n\t\t// while (this.maximumEvictableIndex + 1 < this.indexOfFirstEditInSession) {\n\t\t// \tconst nextEdit = this.getEditInSessionAtIndex(this.maximumEvictableIndex + 1);\n\t\t// \tconst nextEditInfo = this.getOrderedEditId(nextEdit.id) as SequencedOrderedEditId;\n\t\t// \tif (\n\t\t// \t\tnextEditInfo.sequenceInfo !== undefined &&\n\t\t// \t\tnextEditInfo.sequenceInfo.sequenceNumber > minSequenceNumber\n\t\t// \t) {\n\t\t// \t\tbreak;\n\t\t// \t}\n\t\t// \t++this.maximumEvictableIndex;\n\t\t// }\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, 'Duplicate acked edit.');\n\t\t\t// Remove it from localEdits. Due to ordering requirements, it must be first.\n\t\t\tconst oldLocalEditId = assertNotUndefined(this.localEdits.shift(), 'Local edit should exist').id;\n\t\t\tassert(oldLocalEditId === id, 'Causal ordering should be upheld');\n\t\t}\n\n\t\t// The starting revision for a newly created chunk.\n\t\tconst startRevision = this.numberOfSequencedEdits;\n\t\t// The initial edits for a newly created chunk.\n\t\tconst edits: EditWithoutId<TChange>[] = [editWithoutId];\n\n\t\tconst lastPair = this.editChunks.nextLowerPair(undefined);\n\t\tif (lastPair === undefined) {\n\t\t\tthis.editChunks.set(startRevision, { edits });\n\t\t} else {\n\t\t\t// Add to the last edit chunk if it has room and hasn't already been uploaded, otherwise create a new chunk.\n\t\t\t// If the chunk has a corresponding handle, create a new chunk.\n\t\t\tconst { edits: lastEditChunk, handle } = lastPair[1];\n\t\t\tif (handle === undefined && lastEditChunk !== undefined && lastEditChunk.length < this.editsPerChunk) {\n\t\t\t\tlastEditChunk.push(editWithoutId);\n\t\t\t} else {\n\t\t\t\tassert(\n\t\t\t\t\thandle !== undefined || lastEditChunk !== undefined,\n\t\t\t\t\t'An edit chunk must have either a handle or a list of edits.'\n\t\t\t\t);\n\t\t\t\tthis.editChunks.set(startRevision, { edits });\n\t\t\t}\n\t\t}\n\n\t\tthis.sequencedEditIds.push(id);\n\t\tconst sequencedEditId: SequencedOrderedEditId = {\n\t\t\tindex: this.numberOfSequencedEdits - 1,\n\t\t\tisLocal: false,\n\t\t\tsequenceInfo: info,\n\t\t};\n\t\tthis.allEditIds.set(id, sequencedEditId);\n\t\tthis.emitAdd(edit, false, encounteredEditId !== undefined);\n\t}\n\n\t/**\n\t * @returns The last edit chunk i.e. the chunk which the most recent sequenced edits have been placed into, as well as its starting revision.\n\t * Returns undefined iff there are no sequenced edits.\n\t * When defined, this chunk is guaranteed to contain at least one edit\n\t * (though it may be necessary to load the chunk via its handle to use it)\n\t */\n\tpublic getLastEditChunk(): [startRevision: number, edits: EditChunk<TChange>] | undefined {\n\t\treturn this.editChunks.nextLowerPair(undefined);\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\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\treturn compressEdit !== undefined\n\t\t\t? {\n\t\t\t\t\teditChunks: this.editChunks.toArray().map(([startRevision, { handle, edits }]) => ({\n\t\t\t\t\t\tstartRevision,\n\t\t\t\t\t\tchunk:\n\t\t\t\t\t\t\thandle?.baseHandle ??\n\t\t\t\t\t\t\tedits?.map((edit) => compressEdit(edit)) ??\n\t\t\t\t\t\t\tfail('An edit chunk must have either a handle or a list of edits.'),\n\t\t\t\t\t})),\n\t\t\t\t\teditIds: this.sequencedEditIds,\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\teditChunks: this.editChunks.toArray().map(([startRevision, { handle, edits }]) => ({\n\t\t\t\t\t\tstartRevision,\n\t\t\t\t\t\tchunk:\n\t\t\t\t\t\t\thandle?.baseHandle ??\n\t\t\t\t\t\t\tedits ??\n\t\t\t\t\t\t\tfail('An edit chunk must have either a handle or a list of edits.'),\n\t\t\t\t\t})),\n\t\t\t\t\teditIds: this.sequencedEditIds,\n\t\t\t };\n\t}\n\n\tprivate addKeyToCache(newKey: number): void {\n\t\t// Indices are only added to the cache if they are not higher than the maximum evicted index.\n\t\tif (newKey <= this.maximumEvictableIndex) {\n\t\t\t// If the new index is already in the cache, remove it first to update its last usage.\n\t\t\tif (newKey in this.loadedChunkCache) {\n\t\t\t\tthis.loadedChunkCache.splice(this.loadedChunkCache.indexOf(newKey), 1);\n\t\t\t}\n\n\t\t\tthis.loadedChunkCache.push(newKey);\n\n\t\t\t// If the cache is out of space, evict the oldest index in the cache.\n\t\t\tif (this.loadedChunkCache.length > loadedChunkCacheSize) {\n\t\t\t\tconst indexToEvict = assertNotUndefined(this.loadedChunkCache.shift());\n\t\t\t\tconst chunkToEvict = assertNotUndefined(\n\t\t\t\t\tthis.editChunks.get(indexToEvict),\n\t\t\t\t\t'Chunk start revision added to cache should exist in the edit log.'\n\t\t\t\t);\n\t\t\t\tchunkToEvict.edits = undefined;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction isEditHandle<TChange>(\n\tchunk: EditHandle<TChange> | readonly EditWithoutId<unknown>[]\n): chunk is EditHandle<TChange> {\n\treturn !Array.isArray(chunk);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"LogViewer.d.ts","sourceRoot":"","sources":["../src/LogViewer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,OAAO,EAA0B,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAsB,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAsB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE3E;;;;;;;;;;;;;;;;;;GAkBG;AACH,oBAAY,kBAAkB,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;AAEtG;;;;;;;GAOG;AACH,oBAAY,2BAA2B,GAAG,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW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206
206
  const revision = editIndex + 1;
207
- let nextView;
208
- if (editingResult.status === persisted_types_1.EditStatus.Applied) {
209
- nextView = editingResult.after;
210
- }
211
- else {
212
- nextView = prevView;
213
- }
207
+ const nextView = editingResult.status === persisted_types_1.EditStatus.Applied ? editingResult.after : prevView;
214
208
  const computedCacheEntry = editingResult.status === persisted_types_1.EditStatus.Applied
215
209
  ? { view: nextView, status: editingResult.status, steps: editingResult.steps }
216
210
  : { view: nextView, status: editingResult.status, failure: editingResult.failure };
@@ -1 +1 @@
1
- {"version":3,"file":"LogViewer.js","sourceRoot":"","sources":["../src/LogViewer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,oDAA4B;AAC5B,qCAA8C;AAG9C,6DAAoE;AAEpE,uDAAqE;AAErE,+DAA2E;AAyJ3E;;;;;;GAMG;AACH,MAAa,gBAAgB;IAoE5B;;;;;;;;;OASG;IACH,YACC,GAA4B,EAC5B,QAAsB,EACtB,iBAA+C,EAAE,EACjD,oBAAwC,aAAI,EAC5C,6BAA0D,aAAI,EAC9D,qBAAqB,GAAG,CAAC;QA5E1B;;;;WAIG;QACc,uBAAkB,GAAG,IAAI,gBAAM,EAAiC,CAAC;QAqBlF;;;;WAIG;QACc,uBAAkB,GAAG,IAAI,gBAAM,EAAU,CAAC;QA+C1D,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE;YACrC,IAAA,eAAM,EAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,6BAA6B,CAAC,CAAC;YAClE,IAAA,eAAM,EAAC,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,2DAA2D,CAAC,CAAC;QAC7G,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,sBAAsB,GAAG,IAAI,uCAAkB,CACnD,gBAAgB,CAAC,qBAAqB,EACtC,qBAAqB,EACrB,CAAC,G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AC,OAAO;yBACpB,CAAC;iBACL;aACD;SACD;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;;AAjeF,4CAkeC;AA/dA;;GAEG;AACoB,sCAAqB,GAAG,EAAE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport Denque from 'denque';\nimport { assert, fail, noop } from './Common';\nimport { EditLog, SequencedOrderedEditId } from './EditLog';\nimport { EditId } from './Identifiers';\nimport { Revision, RevisionValueCache } from './RevisionValueCache';\nimport { ReconciliationChange, ReconciliationEdit, ReconciliationPath } from './ReconciliationPath';\nimport { ChangeInternal, Edit, EditStatus } from './persisted-types';\nimport { RevisionView } from './RevisionView';\nimport { EditingResult, TransactionInternal } from './TransactionInternal';\n\n/**\n * Callback for when an edit is applied (meaning the result of applying it to a particular revision is computed).\n *\n * Edits may be applied any time a TreeView is computed that includes them.\n * Depending on the caching policy of the LogViewer, a given edit may or may not be applied in order to compute a TreeView containing it.\n *\n * If the same edit occurs in different contexts (ex: a local edit is adjusted for a new remote edit),\n * that it will be reapplied, and this may result in different results.\n *\n * Edits may additionally be reapplied at other times since their previous output might not be cached.\n *\n * If an application requests the current view, this will force all edits to be applied.\n * Such an application can use this callback can be log each edit as it comes it to see its status,\n * however this may include duplicates, as well as entries for reapplications in modified contexts.\n *\n * In the context of this callback,\n * skipping the first evaluation of an edit in a particular context due to setKnownEditingResult is still considered applying.\n * To use this call back to track when the actual computational work of applying edits is done, only count cases when `wasCached` is false.\n */\nexport type EditStatusCallback = (editResult: EditStatus, editId: EditId, wasCached: boolean) => void;\n\n/**\n * Callback for when a sequenced edit is applied.\n * This includes local edits though the callback is only invoked once the sequenced version is received.\n *\n * For edits that were local (see {@link SequencedEditResult.wasLocal}, this callback will only be called once.\n * For non-local edits, it may be called multiple times: the number of calls and when they occur depends on caching and is an implementation\n * detail.\n */\nexport type SequencedEditResultCallback = (args: SequencedEditResult) => void;\n\n/**\n * The relevant information pertaining to the application of a sequenced edit.\n */\nexport interface SequencedEditResult {\n\t/**\n\t * The edit that was applied.\n\t */\n\tedit: Edit<ChangeInternal>;\n\t/**\n\t * true iff the edit was local.\n\t */\n\twasLocal: boolean;\n\t/**\n\t * The result of applying the edit.\n\t */\n\tresult: AttemptedEditResultCacheEntry;\n\t/**\n\t * The reconciliation path for the edit.\n\t */\n\treconciliationPath: ReconciliationPath;\n}\n\n/**\n * The data cached by `CachingLogViewer` for an edit.\n */\nexport type EditCacheEntry = SuccessfulEditCacheEntry | UnsuccessfulEditCacheEntry | SummarizedEditResultCacheEntry;\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has attempted to apply locally.\n */\nexport type AttemptedEditResultCacheEntry = SuccessfulEditCacheEntry | UnsuccessfulEditCacheEntry;\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has successfully applied locally.\n */\nexport interface SuccessfulEditCacheEntry {\n\t/**\n\t * The revision view resulting from the edit.\n\t */\n\treadonly view: RevisionView;\n\t/**\n\t * The status code for the edit that produced the revision.\n\t */\n\treadonly status: EditStatus.Applied;\n\t/**\n\t * The resolved changes that were applied during the edit and their associated outcome.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has unsuccessfully attempted to apply locally.\n */\nexport interface UnsuccessfulEditCacheEntry {\n\t/**\n\t * The revision view resulting from the edit.\n\t */\n\treadonly view: RevisionView;\n\t/**\n\t * The status code for the edit that produced the revision.\n\t */\n\treadonly status: EditStatus.Invalid | EditStatus.Malformed;\n\t/**\n\t * Information about the failure encountered by the edit\n\t */\n\treadonly failure: TransactionInternal.Failure;\n}\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has retrieved from a summary.\n * TODO:#57176: once summarized edits carry enough information remove this interface and use `AttemptedEditResultCacheEntry` instead.\n */\nexport interface SummarizedEditResultCacheEntry {\n\t/**\n\t * The revision view resulting from the edit.\n\t */\n\treadonly view: RevisionView;\n\t/**\n\t * Not specified on `SummarizedEditResultCacheEntry`.\n\t * Declared to allow checking `entry.status` against undefined.\n\t */\n\treadonly status?: never;\n}\n\nexport type CachedEditingResult = AttemptedEditResultCacheEntry & {\n\t/**\n\t * Unique identifier for this edit. Must never be reused.\n\t * Used for referencing and de-duplicating edits.\n\t */\n\treadonly id: EditId;\n\treadonly before: RevisionView;\n\treadonly changes: readonly ChangeInternal[];\n};\n\n/**\n * Creates `RevisionView`s for the revisions in an `EditLog`\n */\nexport interface LogViewer {\n\t/**\n\t * Returns the `TreeView` output associated with the largest revision in `editLog` less than (but not equal to) the supplied revision.\n\t *\n\t * For example:\n\t * - revision 0 returns the initialRevision.\n\t * - revision 1 returns the output of editLog[0] (or initialRevision if there is no edit 0).\n\t * - revision Number.POSITIVE_INFINITY returns the newest revision.\n\t */\n\tgetRevisionView(revision: Revision): Promise<RevisionView>;\n\n\t/**\n\t * Returns the `TreeView` output associated with the largest revision in `editLog` less than (but not equal to) the supplied revision.\n\t * Can only be used to retrieve revisions added during the current sessions.\n\t *\n\t * For example:\n\t * - revision 0 returns the initialRevision.\n\t * - revision 1 returns the output of editLog[0] (or initialRevision if there is no edit 0).\n\t * - revision Number.POSITIVE_INFINITY returns the newest revision.\n\t */\n\tgetRevisionViewInSession(revision: Revision): RevisionView;\n}\n\n/**\n * Creates views for revisions associated with an EditLog and caches the results.\n *\n * Does so by listening for edits added to the log. If the underlying EditLog or its listeners need to be reused beyond the lifetime of\n * a CachingLogViewer instance, that instance should be disposed with `detachFromEditLog` to ensure it is garbage-collectable.\n * @internal\n */\nexport class CachingLogViewer implements LogViewer {\n\tpublic readonly log: EditLog<ChangeInternal>;\n\n\t/**\n\t * Maximum size of the sequenced revision cache.\n\t */\n\tpublic static readonly sequencedCacheSizeMax = 50;\n\n\t/**\n\t * A cache for local revisions.\n\t * It is invalidated whenever a new sequenced edit (that was not already a local edit) is added to the log.\n\t * When a previously local edit is sequenced, this cache is adjusted to account for it, not invalidated.\n\t */\n\tprivate readonly localRevisionCache = new Denque<AttemptedEditResultCacheEntry>();\n\n\t/**\n\t * Cache of sequenced revisions.\n\t */\n\tprivate readonly sequencedRevisionCache: RevisionValueCache<EditCacheEntry>;\n\n\t/**\n\t * Called whenever a sequenced edit is applied.\n\t * This will have been called at least once for any edit if a revision after than edit has been requested.\n\t * It may be called multiple times: the number of calls and when they occur depends on caching and is an implementation detail.\n\t */\n\tprivate readonly processSequencedEditResult: SequencedEditResultCallback;\n\n\t/**\n\t * Called whenever an edit is processed.\n\t * This will have been called at least once for any edit if a revision after than edit has been requested.\n\t * It may be called multiple times: the number of calls and when they occur depends on caching and is an implementation detail.\n\t */\n\tprivate readonly processEditStatus: EditStatusCallback;\n\n\t/**\n\t * The ordered queue of edits that originated from this client that have never been applied (by this log viewer) in a sequenced state.\n\t * This means these edits may be local or sequenced, and may have been applied (possibly multiple times) while still local.\n\t * Used to log telemetry about the result of edit application. Edits are removed when first applied after being sequenced.\n\t */\n\tprivate readonly unappliedSelfEdits = new Denque<EditId>();\n\n\t/**\n\t * Cache of applying a edit.\n\t * Due to use of Transactions in checkouts, a common pattern involves applying an edit\n\t * as part of the transaction, then submitting it.\n\t * This cache helps optimize that case by avoiding recomputing the edit if no other edits were added during the transaction.\n\t */\n\tprivate cachedEditResult?: { editId: EditId; result: EditingResult };\n\n\t/**\n\t * Cache entry for the highest revision.\n\t * `undefined` when not cached.\n\t */\n\tprivate highestRevisionCacheEntry?: EditCacheEntry;\n\n\t/**\n\t * Removes this log viewer from the set of handleEditAdded listeners on its underlying log.\n\t * This should be called if the underlying log or its listeners are re-used past the lifetime of this log viewer.\n\t */\n\tpublic readonly detachFromEditLog: () => void;\n\n\t/**\n\t * @returns true if the highest revision is cached.\n\t */\n\tpublic highestRevisionCached(): boolean {\n\t\treturn this.highestRevisionCacheEntry !== undefined;\n\t}\n\n\t/**\n\t * Create a new LogViewer\n\t * @param log - the edit log which revisions will be based on.\n\t * @param baseTree - the tree used in the view corresponding to the 0th revision.\n\t * @param knownRevisions - a set of [sequencedRevision, view] pairs that are known (have been precomputed) at construction time.\n\t * These revisions are guaranteed to never be evicted from the cache.\n\t * @param expensiveValidation - Iff true, additional correctness assertions will be run during LogViewer operations.\n\t * @param processEditStatus - called after applying an edit.\n\t * @param processSequencedEditResult - called after applying a sequenced edit.\n\t */\n\tpublic constructor(\n\t\tlog: EditLog<ChangeInternal>,\n\t\tbaseView: RevisionView,\n\t\tknownRevisions: [Revision, EditCacheEntry][] = [],\n\t\tprocessEditStatus: EditStatusCallback = noop,\n\t\tprocessSequencedEditResult: SequencedEditResultCallback = noop,\n\t\tminimumSequenceNumber = 0\n\t) {\n\t\tthis.log = log;\n\t\tknownRevisions.forEach(([revision]) => {\n\t\t\tassert(Number.isInteger(revision), 'revision must be an integer');\n\t\t\tassert(this.log.isSequencedRevision(revision), 'revision must correspond to the result of a SequencedEdit');\n\t\t});\n\n\t\tthis.sequencedRevisionCache = new RevisionValueCache(\n\t\t\tCachingLogViewer.sequencedCacheSizeMax,\n\t\t\tminimumSequenceNumber,\n\t\t\t[...knownRevisions, [0, { view: baseView }]]\n\t\t);\n\t\tthis.processEditStatus = processEditStatus ?? noop;\n\t\tthis.processSequencedEditResult = processSequencedEditResult ?? noop;\n\t\tthis.detachFromEditLog = this.log.registerEditAddedHandler(this.handleEditAdded.bind(this));\n\t}\n\n\t/**\n\t * As a performance optimization, this method caches views generated by local edits if they are sequenced without\n\t * being interleaved with remote edits.\n\t */\n\tprivate handleEditAdded(edit: Edit<ChangeInternal>, isLocal: boolean, wasLocal: boolean): void {\n\t\t// Clear highestRevisionCacheEntry, since what revision is highest might change.\n\t\t// Note that as an optimization we could skip clearing this when a local edit is sequenced.\n\t\tthis.highestRevisionCacheEntry = undefined;\n\n\t\tif (isLocal) {\n\t\t\tthis.unappliedSelfEdits.push(edit.id);\n\t\t} else if (wasLocal) {\n\t\t\t// If the new sequenced edit was generated by this client, the corresponding cache entry (if there is one)\n\t\t\t// will be at the front of the queue. If the queue is empty, then a concurrent sequenced edit from remote client\n\t\t\t// must have invalidated the queue cache.\n\t\t\tconst entry = this.localRevisionCache.shift();\n\t\t\tif (entry !== undefined) {\n\t\t\t\tconst revision = this.log.numberOfSequencedEdits;\n\t\t\t\tconst { view } = entry;\n\t\t\t\tthis.sequencedRevisionCache.cacheValue(\n\t\t\t\t\trevision,\n\t\t\t\t\tentry.status === EditStatus.Applied\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tview,\n\t\t\t\t\t\t\t\tstatus: entry.status,\n\t\t\t\t\t\t\t\tsteps: entry.steps,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tview,\n\t\t\t\t\t\t\t\tstatus: entry.status,\n\t\t\t\t\t\t\t\tfailure: entry.failure,\n\t\t\t\t\t\t }\n\t\t\t\t);\n\t\t\t\tthis.handleSequencedEditResult(edit, entry, []);\n\t\t\t}\n\t\t} else {\n\t\t\t// Invalidate any cached results of applying edits which are ordered after `edit` (which are all remaining local edits)\n\t\t\tthis.localRevisionCache.clear();\n\t\t}\n\t}\n\n\tpublic async getEditResult(revision: Revision): Promise<EditCacheEntry> {\n\t\tconst startingPoint = this.getStartingPoint(revision);\n\t\tconst { startRevision } = startingPoint;\n\t\tlet current: EditCacheEntry = startingPoint;\n\t\tfor (let i = startRevision; i < revision && i < this.log.length; i++) {\n\t\t\tconst edit = await this.log.getEditAtIndex(i);\n\t\t\tcurrent = this.applyEdit(current.view, edit, i);\n\t\t}\n\t\treturn current;\n\t}\n\n\tpublic async getRevisionView(revision: Revision): Promise<RevisionView> {\n\t\treturn (await this.getEditResult(revision)).view;\n\t}\n\n\tpublic getEditResultInSession(revision: Revision): EditCacheEntry {\n\t\tconst startingPoint = this.getStartingPoint(revision);\n\t\tconst { startRevision } = startingPoint;\n\t\tlet current: EditCacheEntry = startingPoint;\n\t\tfor (let i = startRevision; i < revision && i < this.log.length; i++) {\n\t\t\tconst edit = this.log.getEditInSessionAtIndex(i);\n\t\t\tcurrent = this.applyEdit(current.view, edit, i);\n\t\t}\n\t\treturn current;\n\t}\n\n\tpublic getRevisionViewInSession(revision: Revision): RevisionView {\n\t\treturn this.getEditResultInSession(revision).view;\n\t}\n\n\t/**\n\t * Informs the CachingLogViewer of the latest known minimumSequenceNumber for all connected clients.\n\t * This can be used to provide more aggressive caching of revisions within the collaboration window, as those revisions\n\t * are more likely to be demanded to resolve conflicts.\n\t * @param minSequenceNumber - the minimum known sequence number of all connected clients.\n\t */\n\tpublic setMinimumSequenceNumber(minimumSequenceNumber: number): void {\n\t\t// Sequence numbers in Fluid are 1-indexed, meaning they correspond to revisions, and can be used as revisions.\n\t\t// This ensures that all revisions >= minimumSequenceNumber are kept in the cache, meaning that even if all clients are caught up\n\t\t// the most recent sequenced revision will be cached.\n\t\tthis.sequencedRevisionCache.updateRetentionWindow(minimumSequenceNumber);\n\t}\n\n\t/**\n\t * Inform the CachingLogViewer that a particular edit is known to have a specific result when applied to a particular TreeView.\n\t * CachingLogViewer may use this information as an optimization to avoid re-running the edit if re-applied to the same TreeView.\n\t */\n\tpublic setKnownEditingResult(edit: Edit<ChangeInternal>, result: EditingResult): void {\n\t\tthis.cachedEditResult = { editId: edit.id, result };\n\t}\n\n\t/**\n\t * @returns the cached revision view closest to the requested `revision`.\n\t */\n\tprivate getStartingPoint(revision: Revision): { startRevision: Revision } & EditCacheEntry {\n\t\t// Per the documentation for revision, the returned view should be the output of the edit at the largest index <= `revision`.\n\t\tconst revisionClamped = Math.min(revision, this.log.length);\n\n\t\t// If the highest revision is requested, and it's cached, use highestRevisionCacheEntry.\n\t\tif (revisionClamped === this.log.length && this.highestRevisionCacheEntry !== undefined) {\n\t\t\treturn { ...this.highestRevisionCacheEntry, startRevision: revisionClamped };\n\t\t}\n\n\t\tlet current: EditCacheEntry;\n\t\tlet startRevision: Revision;\n\t\tconst { numberOfSequencedEdits } = this.log;\n\t\tconst isLocalRevision = revisionClamped > numberOfSequencedEdits;\n\t\tif (isLocalRevision && !this.localRevisionCache.isEmpty()) {\n\t\t\tconst { length } = this.localRevisionCache;\n\t\t\t// Local revision view cache is indexed such that the view for revision 0 (a local edit) is stored at index 0 in the cache.\n\t\t\t// This is because the local cache does not contain an entry for the implicit initial tree edit.\n\t\t\tconst localCacheIndex = revisionClamped - 1 - numberOfSequencedEdits;\n\t\t\tif (localCacheIndex < length) {\n\t\t\t\tconst cached =\n\t\t\t\t\tthis.localRevisionCache.peekAt(localCacheIndex) ?? fail('missing tail of localRevisionViewCache');\n\t\t\t\treturn {\n\t\t\t\t\t...cached,\n\t\t\t\t\tstartRevision: revisionClamped,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tcurrent = this.localRevisionCache.peekAt(length - 1) ?? fail('missing tail of localRevisionViewCache');\n\t\t\t\tstartRevision = numberOfSequencedEdits + length;\n\t\t\t}\n\t\t} else {\n\t\t\tconst [cachedRevision, cachedView] =\n\t\t\t\tthis.sequencedRevisionCache.getClosestEntry(revisionClamped) ??\n\t\t\t\tfail('No preceding revision view cached.');\n\n\t\t\tstartRevision = cachedRevision;\n\t\t\tcurrent = cachedView;\n\t\t}\n\t\treturn { startRevision, ...current };\n\t}\n\n\t/**\n\t * Helper for applying an edit at the supplied revision view.\n\t * Must only be called in the order that edits appear in the log.\n\t * Must only be called once for a given local edit as long as the local cache has not been invalidated.\n\t * Must only be called once for a given sequenced edit.\n\t * @returns the resulting revision view and the outcome of edit that produced it.\n\t */\n\tprivate applyEdit(\n\t\tprevView: RevisionView,\n\t\tedit: Edit<ChangeInternal>,\n\t\teditIndex: number\n\t): AttemptedEditResultCacheEntry {\n\t\tlet editingResult: EditingResult;\n\t\tlet cached;\n\t\tlet reconciliationPath: ReconciliationPath = [];\n\t\tif (\n\t\t\tthis.cachedEditResult !== undefined &&\n\t\t\tthis.cachedEditResult.editId === edit.id &&\n\t\t\tthis.cachedEditResult.result.before === prevView\n\t\t) {\n\t\t\teditingResult = this.cachedEditResult.result;\n\t\t\tcached = true;\n\t\t} else {\n\t\t\treconciliationPath = this.reconciliationPathFromEdit(edit.id);\n\t\t\teditingResult = TransactionInternal.factory(prevView)\n\t\t\t\t.applyChanges(edit.changes, reconciliationPath)\n\t\t\t\t.close();\n\t\t\tcached = false;\n\t\t}\n\n\t\tconst revision = editIndex + 1;\n\t\tlet nextView: RevisionView;\n\t\tif (editingResult.status === EditStatus.Applied) {\n\t\t\tnextView = editingResult.after;\n\t\t} else {\n\t\t\tnextView = prevView;\n\t\t}\n\n\t\tconst computedCacheEntry =\n\t\t\teditingResult.status === EditStatus.Applied\n\t\t\t\t? { view: nextView, status: editingResult.status, steps: editingResult.steps }\n\t\t\t\t: { view: nextView, status: editingResult.status, failure: editingResult.failure };\n\n\t\tif (this.log.isSequencedRevision(revision)) {\n\t\t\tthis.sequencedRevisionCache.cacheValue(revision, computedCacheEntry);\n\t\t\tthis.handleSequencedEditResult(edit, computedCacheEntry, reconciliationPath);\n\t\t} else {\n\t\t\t// This relies on local edits being append only, and that generating the view for a local revision requires generating\n\t\t\t// the views for all local revisions before it in the log. Thus, generating such a view will necessarily require\n\t\t\t// calls to this method for all local revisions prior, guaranteeing the correct push order.\n\t\t\tassert(\n\t\t\t\trevision === this.log.numberOfSequencedEdits + this.localRevisionCache.length + 1,\n\t\t\t\t'Local revision view cached out of order.'\n\t\t\t);\n\t\t\tthis.localRevisionCache.push(computedCacheEntry);\n\t\t}\n\n\t\t// Only update highestRevisionCacheEntry if this snapshot is the highest revision.\n\t\tif (revision >= this.log.length) {\n\t\t\tthis.highestRevisionCacheEntry = computedCacheEntry;\n\t\t}\n\n\t\tthis.processEditStatus(editingResult.status, this.log.getIdAtIndex(editIndex), cached);\n\t\treturn computedCacheEntry;\n\t}\n\n\t/**\n\t * Helper for performing caching when a sequenced local edit is first applied.\n\t * Invokes the `processSequencedEditResult` handler that was passed to the constructor (if any).\n\t * Must only be called for non-cached sequenced edits.\n\t */\n\tprivate handleSequencedEditResult(\n\t\tedit: Edit<ChangeInternal>,\n\t\tresult: AttemptedEditResultCacheEntry,\n\t\treconciliationPath: ReconciliationPath\n\t): void {\n\t\tlet wasLocal = false;\n\t\t// This is the first time this sequenced edit has been processed by this LogViewer. If it was a local edit, log telemetry\n\t\t// in the event that it was invalid or malformed.\n\t\tif (this.unappliedSelfEdits.length > 0) {\n\t\t\tif (edit.id === this.unappliedSelfEdits.peekFront()) {\n\t\t\t\twasLocal = true;\n\t\t\t\tthis.unappliedSelfEdits.shift();\n\t\t\t}\n\t\t}\n\t\tthis.processSequencedEditResult({ edit, wasLocal, result, reconciliationPath });\n\t}\n\n\t/**\n\t * We currently compute only the \"main branch\" part of the reconciliation path (meaning we don't include inverts of the edits\n\t * that occurred on the rebased branch). Doing so is only needed for the sequential anchor resolution approach which is not\n\t * yet supported.\n\t * @param editId - The ID for the edit to get the reconciliation path for.\n\t */\n\tpublic reconciliationPathFromEdit(editId: EditId): ReconciliationPath {\n\t\tconst reconciliationPath: ReconciliationEdit[] = [];\n\t\tlet cached = false;\n\t\treturn new Proxy(reconciliationPath, {\n\t\t\tget: (target, prop): unknown => {\n\t\t\t\tif (!cached) {\n\t\t\t\t\tcached = true;\n\t\t\t\t\tconst orderedId = this.log.getOrderedEditId(editId);\n\t\t\t\t\tif (orderedId.isLocal === false && orderedId.sequenceInfo !== undefined) {\n\t\t\t\t\t\tconst earliestSequenced = this.earliestSequencedEditInSession();\n\t\t\t\t\t\tif (earliestSequenced !== undefined) {\n\t\t\t\t\t\t\tconst earliestEditSequenceNumber = earliestSequenced.sequenceNumber;\n\t\t\t\t\t\t\tconst targetSequenceNumber = Math.max(\n\t\t\t\t\t\t\t\tearliestEditSequenceNumber,\n\t\t\t\t\t\t\t\torderedId.sequenceInfo.referenceSequenceNumber\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (targetSequenceNumber < orderedId.sequenceInfo.sequenceNumber) {\n\t\t\t\t\t\t\t\tconst firstEdit = this.getEditResultFromSequenceNumber(targetSequenceNumber);\n\t\t\t\t\t\t\t\tif (firstEdit !== undefined) {\n\t\t\t\t\t\t\t\t\tif (firstEdit.status === EditStatus.Applied) {\n\t\t\t\t\t\t\t\t\t\tconst firstEditInfo = this.log.getOrderedEditId(\n\t\t\t\t\t\t\t\t\t\t\tfirstEdit.id\n\t\t\t\t\t\t\t\t\t\t) as SequencedOrderedEditId;\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\tfirstEditInfo.sequenceInfo !== undefined &&\n\t\t\t\t\t\t\t\t\t\t\tfirstEditInfo.sequenceInfo.sequenceNumber >\n\t\t\t\t\t\t\t\t\t\t\t\torderedId.sequenceInfo.referenceSequenceNumber\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\treconciliationPath.push({\n\t\t\t\t\t\t\t\t\t\t\t\t...firstEdit.steps,\n\t\t\t\t\t\t\t\t\t\t\t\tbefore: firstEdit.before,\n\t\t\t\t\t\t\t\t\t\t\t\tafter: firstEdit.view,\n\t\t\t\t\t\t\t\t\t\t\t\tlength: firstEdit.steps.length,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\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\tconst lowestIndex = this.log.getIndexOfId(firstEdit.id) + 1;\n\t\t\t\t\t\t\t\t\tconst highestIndex = this.log.getIndexOfId(editId) - 1;\n\t\t\t\t\t\t\t\t\tfor (let index = lowestIndex; index <= highestIndex; ++index) {\n\t\t\t\t\t\t\t\t\t\tconst edit = this.getEditResultFromIndex(index);\n\t\t\t\t\t\t\t\t\t\tif (edit.status === EditStatus.Applied) {\n\t\t\t\t\t\t\t\t\t\t\treconciliationPath.push({\n\t\t\t\t\t\t\t\t\t\t\t\t...edit.steps,\n\t\t\t\t\t\t\t\t\t\t\t\tbefore: edit.before,\n\t\t\t\t\t\t\t\t\t\t\t\tafter: edit.view,\n\t\t\t\t\t\t\t\t\t\t\t\tlength: edit.steps.length,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\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}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[prop];\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * @returns Edit information for the earliest known sequenced edit.\n\t */\n\tpublic earliestSequencedEditInSession(): { edit: Edit<ChangeInternal>; sequenceNumber: number } | undefined {\n\t\tconst earliestEditIndex = this.log.earliestAvailableEditIndex;\n\t\tconst lastSequencedEdit = this.log.numberOfSequencedEdits + earliestEditIndex - 1;\n\t\tfor (let index = earliestEditIndex; index <= lastSequencedEdit; ++index) {\n\t\t\tconst edit = this.log.getEditInSessionAtIndex(index);\n\t\t\tconst editOrderedId = this.log.getOrderedEditId(edit.id) as SequencedOrderedEditId;\n\t\t\tif (editOrderedId.sequenceInfo !== undefined) {\n\t\t\t\treturn { edit, sequenceNumber: editOrderedId.sequenceInfo.sequenceNumber };\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * @returns Edit result information for the edit at the given `index`.\n\t */\n\tprivate getEditResultFromIndex(index: number): CachedEditingResult {\n\t\tconst edit = this.log.getEditInSessionAtIndex(index);\n\t\tconst before = this.getRevisionViewInSession(index);\n\t\tconst resultAfter = this.getEditResultInSession(index + 1);\n\t\tif (resultAfter.status === undefined) {\n\t\t\tfail('The status of every edit in session should be known');\n\t\t}\n\t\treturn resultAfter.status === EditStatus.Applied\n\t\t\t? {\n\t\t\t\t\tid: edit.id,\n\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\tbefore,\n\t\t\t\t\tchanges: edit.changes,\n\t\t\t\t\tview: resultAfter.view,\n\t\t\t\t\tsteps: resultAfter.steps,\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\tid: edit.id,\n\t\t\t\t\tstatus: resultAfter.status,\n\t\t\t\t\tfailure: resultAfter.failure,\n\t\t\t\t\tbefore,\n\t\t\t\t\tview: resultAfter.view,\n\t\t\t\t\tchanges: edit.changes,\n\t\t\t };\n\t}\n\n\t/**\n\t * @param sequenceNumber - The server-assigned sequenced number assigned to the edit of interest.\n\t * @returns Edit result information for the edit with the given sequence number or the nearest sequenced edit before that.\n\t * Undefined if no sequenced edit occurred at or prior to the given sequenceNumber.\n\t */\n\tpublic getEditResultFromSequenceNumber(sequenceNumber: number): CachedEditingResult | undefined {\n\t\tconst earliestSequenced = this.earliestSequencedEditInSession();\n\t\tif (earliestSequenced !== undefined && sequenceNumber >= earliestSequenced.sequenceNumber) {\n\t\t\tconst lowestIndex = this.log.getIndexOfId(earliestSequenced.edit.id);\n\t\t\tconst highestIndex = this.log.numberOfSequencedEdits - 1;\n\t\t\tfor (let index = highestIndex; index >= lowestIndex; --index) {\n\t\t\t\tconst edit = this.log.getEditInSessionAtIndex(index);\n\t\t\t\tconst orderedId = this.log.getOrderedEditId(edit.id) as SequencedOrderedEditId;\n\t\t\t\t// If `orderedId.sequenceInfo.sequenceNumber` is equal to the requested `sequenceNumber` then we have found the edit of\n\t\t\t\t// interest and simply return its associated information.\n\t\t\t\t// Note that the check bellow also is also satisfied if `orderedId.sequenceInfo.sequenceNumber`is lower than the requested\n\t\t\t\t// `sequenceNumber`. This can happen when the edit for the requested `sequenceNumber` has either not yet been received or\n\t\t\t\t// has been processed by a different DDS (several DDSes can share the same stream of operations and will only see those\n\t\t\t\t// relevant to them). In such cases, we return the edit info for the last known edit before that.\n\t\t\t\tif (orderedId.sequenceInfo && orderedId.sequenceInfo.sequenceNumber <= sequenceNumber) {\n\t\t\t\t\tconst before = this.getRevisionViewInSession(index);\n\t\t\t\t\tconst resultAfter = this.getEditResultInSession(index + 1);\n\t\t\t\t\tif (resultAfter.status === undefined) {\n\t\t\t\t\t\tfail('The status of every edit in session should be known');\n\t\t\t\t\t}\n\t\t\t\t\treturn resultAfter.status === EditStatus.Applied\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: edit.id,\n\t\t\t\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\t\tchanges: edit.changes,\n\t\t\t\t\t\t\t\tview: resultAfter.view,\n\t\t\t\t\t\t\t\tsteps: resultAfter.steps,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tid: edit.id,\n\t\t\t\t\t\t\t\tstatus: resultAfter.status,\n\t\t\t\t\t\t\t\tfailure: resultAfter.failure,\n\t\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\t\tview: resultAfter.view,\n\t\t\t\t\t\t\t\tchanges: edit.changes,\n\t\t\t\t\t\t };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"LogViewer.js","sourceRoot":"","sources":["../src/LogViewer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,oDAA4B;AAC5B,qCAA8C;AAG9C,6DAAoE;AAEpE,uDAAqE;AAErE,+DAA2E;AAyJ3E;;;;;;GAMG;AACH,MAAa,gBAAgB;IAoE5B;;;;;;;;;OASG;IACH,YACC,GAA4B,EAC5B,QAAsB,EACtB,iBAA+C,EAAE,EACjD,oBAAwC,aAAI,EAC5C,6BAA0D,aAAI,EAC9D,qBAAqB,GAAG,CAAC;QA5E1B;;;;WAIG;QACc,uBAAkB,GAAG,IAAI,gBAAM,EAAiC,CAAC;QAqBlF;;;;WAIG;QACc,uBAAkB,GAAG,IAAI,gBAAM,EAAU,CAAC;QA+C1D,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE;YACrC,IAAA,eAAM,EAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,6BAA6B,CAAC,CAAC;YAClE,IAAA,eAAM,EAAC,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,QAAQ,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M;4BAC1B,OAAO,EAAE,WAAW,CAAC,OAAO;4BAC5B,MAAM;4BACN,IAAI,EAAE,WAAW,CAAC,IAAI;4BACtB,OAAO,EAAE,IAAI,CAAC,OAAO;yBACpB,CAAC;iBACL;aACD;SACD;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;;AA5dF,4CA6dC;AA1dA;;GAEG;AACoB,sCAAqB,GAAG,EAAE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport Denque from 'denque';\nimport { assert, fail, noop } from './Common';\nimport { EditLog, SequencedOrderedEditId } from './EditLog';\nimport { EditId } from './Identifiers';\nimport { Revision, RevisionValueCache } from './RevisionValueCache';\nimport { ReconciliationChange, ReconciliationEdit, ReconciliationPath } from './ReconciliationPath';\nimport { ChangeInternal, Edit, EditStatus } from './persisted-types';\nimport { RevisionView } from './RevisionView';\nimport { EditingResult, TransactionInternal } from './TransactionInternal';\n\n/**\n * Callback for when an edit is applied (meaning the result of applying it to a particular revision is computed).\n *\n * Edits may be applied any time a TreeView is computed that includes them.\n * Depending on the caching policy of the LogViewer, a given edit may or may not be applied in order to compute a TreeView containing it.\n *\n * If the same edit occurs in different contexts (ex: a local edit is adjusted for a new remote edit),\n * that it will be reapplied, and this may result in different results.\n *\n * Edits may additionally be reapplied at other times since their previous output might not be cached.\n *\n * If an application requests the current view, this will force all edits to be applied.\n * Such an application can use this callback can be log each edit as it comes it to see its status,\n * however this may include duplicates, as well as entries for reapplications in modified contexts.\n *\n * In the context of this callback,\n * skipping the first evaluation of an edit in a particular context due to setKnownEditingResult is still considered applying.\n * To use this call back to track when the actual computational work of applying edits is done, only count cases when `wasCached` is false.\n */\nexport type EditStatusCallback = (editResult: EditStatus, editId: EditId, wasCached: boolean) => void;\n\n/**\n * Callback for when a sequenced edit is applied.\n * This includes local edits though the callback is only invoked once the sequenced version is received.\n *\n * For edits that were local (see {@link SequencedEditResult.wasLocal}, this callback will only be called once.\n * For non-local edits, it may be called multiple times: the number of calls and when they occur depends on caching and is an implementation\n * detail.\n */\nexport type SequencedEditResultCallback = (args: SequencedEditResult) => void;\n\n/**\n * The relevant information pertaining to the application of a sequenced edit.\n */\nexport interface SequencedEditResult {\n\t/**\n\t * The edit that was applied.\n\t */\n\tedit: Edit<ChangeInternal>;\n\t/**\n\t * true iff the edit was local.\n\t */\n\twasLocal: boolean;\n\t/**\n\t * The result of applying the edit.\n\t */\n\tresult: AttemptedEditResultCacheEntry;\n\t/**\n\t * The reconciliation path for the edit.\n\t */\n\treconciliationPath: ReconciliationPath;\n}\n\n/**\n * The data cached by `CachingLogViewer` for an edit.\n */\nexport type EditCacheEntry = SuccessfulEditCacheEntry | UnsuccessfulEditCacheEntry | SummarizedEditResultCacheEntry;\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has attempted to apply locally.\n */\nexport type AttemptedEditResultCacheEntry = SuccessfulEditCacheEntry | UnsuccessfulEditCacheEntry;\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has successfully applied locally.\n */\nexport interface SuccessfulEditCacheEntry {\n\t/**\n\t * The revision view resulting from the edit.\n\t */\n\treadonly view: RevisionView;\n\t/**\n\t * The status code for the edit that produced the revision.\n\t */\n\treadonly status: EditStatus.Applied;\n\t/**\n\t * The resolved changes that were applied during the edit and their associated outcome.\n\t */\n\treadonly steps: readonly ReconciliationChange[];\n}\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has unsuccessfully attempted to apply locally.\n */\nexport interface UnsuccessfulEditCacheEntry {\n\t/**\n\t * The revision view resulting from the edit.\n\t */\n\treadonly view: RevisionView;\n\t/**\n\t * The status code for the edit that produced the revision.\n\t */\n\treadonly status: EditStatus.Invalid | EditStatus.Malformed;\n\t/**\n\t * Information about the failure encountered by the edit\n\t */\n\treadonly failure: TransactionInternal.Failure;\n}\n\n/**\n * The data cached by `CachingLogViewer` for an edit that it has retrieved from a summary.\n * TODO:#57176: once summarized edits carry enough information remove this interface and use `AttemptedEditResultCacheEntry` instead.\n */\nexport interface SummarizedEditResultCacheEntry {\n\t/**\n\t * The revision view resulting from the edit.\n\t */\n\treadonly view: RevisionView;\n\t/**\n\t * Not specified on `SummarizedEditResultCacheEntry`.\n\t * Declared to allow checking `entry.status` against undefined.\n\t */\n\treadonly status?: never;\n}\n\nexport type CachedEditingResult = AttemptedEditResultCacheEntry & {\n\t/**\n\t * Unique identifier for this edit. Must never be reused.\n\t * Used for referencing and de-duplicating edits.\n\t */\n\treadonly id: EditId;\n\treadonly before: RevisionView;\n\treadonly changes: readonly ChangeInternal[];\n};\n\n/**\n * Creates `RevisionView`s for the revisions in an `EditLog`\n */\nexport interface LogViewer {\n\t/**\n\t * Returns the `TreeView` output associated with the largest revision in `editLog` less than (but not equal to) the supplied revision.\n\t *\n\t * For example:\n\t * - revision 0 returns the initialRevision.\n\t * - revision 1 returns the output of editLog[0] (or initialRevision if there is no edit 0).\n\t * - revision Number.POSITIVE_INFINITY returns the newest revision.\n\t */\n\tgetRevisionView(revision: Revision): Promise<RevisionView>;\n\n\t/**\n\t * Returns the `TreeView` output associated with the largest revision in `editLog` less than (but not equal to) the supplied revision.\n\t * Can only be used to retrieve revisions added during the current sessions.\n\t *\n\t * For example:\n\t * - revision 0 returns the initialRevision.\n\t * - revision 1 returns the output of editLog[0] (or initialRevision if there is no edit 0).\n\t * - revision Number.POSITIVE_INFINITY returns the newest revision.\n\t */\n\tgetRevisionViewInSession(revision: Revision): RevisionView;\n}\n\n/**\n * Creates views for revisions associated with an EditLog and caches the results.\n *\n * Does so by listening for edits added to the log. If the underlying EditLog or its listeners need to be reused beyond the lifetime of\n * a CachingLogViewer instance, that instance should be disposed with `detachFromEditLog` to ensure it is garbage-collectable.\n * @internal\n */\nexport class CachingLogViewer implements LogViewer {\n\tpublic readonly log: EditLog<ChangeInternal>;\n\n\t/**\n\t * Maximum size of the sequenced revision cache.\n\t */\n\tpublic static readonly sequencedCacheSizeMax = 50;\n\n\t/**\n\t * A cache for local revisions.\n\t * It is invalidated whenever a new sequenced edit (that was not already a local edit) is added to the log.\n\t * When a previously local edit is sequenced, this cache is adjusted to account for it, not invalidated.\n\t */\n\tprivate readonly localRevisionCache = new Denque<AttemptedEditResultCacheEntry>();\n\n\t/**\n\t * Cache of sequenced revisions.\n\t */\n\tprivate readonly sequencedRevisionCache: RevisionValueCache<EditCacheEntry>;\n\n\t/**\n\t * Called whenever a sequenced edit is applied.\n\t * This will have been called at least once for any edit if a revision after than edit has been requested.\n\t * It may be called multiple times: the number of calls and when they occur depends on caching and is an implementation detail.\n\t */\n\tprivate readonly processSequencedEditResult: SequencedEditResultCallback;\n\n\t/**\n\t * Called whenever an edit is processed.\n\t * This will have been called at least once for any edit if a revision after than edit has been requested.\n\t * It may be called multiple times: the number of calls and when they occur depends on caching and is an implementation detail.\n\t */\n\tprivate readonly processEditStatus: EditStatusCallback;\n\n\t/**\n\t * The ordered queue of edits that originated from this client that have never been applied (by this log viewer) in a sequenced state.\n\t * This means these edits may be local or sequenced, and may have been applied (possibly multiple times) while still local.\n\t * Used to log telemetry about the result of edit application. Edits are removed when first applied after being sequenced.\n\t */\n\tprivate readonly unappliedSelfEdits = new Denque<EditId>();\n\n\t/**\n\t * Cache of applying a edit.\n\t * Due to use of Transactions in checkouts, a common pattern involves applying an edit\n\t * as part of the transaction, then submitting it.\n\t * This cache helps optimize that case by avoiding recomputing the edit if no other edits were added during the transaction.\n\t */\n\tprivate cachedEditResult?: { editId: EditId; result: EditingResult };\n\n\t/**\n\t * Cache entry for the highest revision.\n\t * `undefined` when not cached.\n\t */\n\tprivate highestRevisionCacheEntry?: EditCacheEntry;\n\n\t/**\n\t * Removes this log viewer from the set of handleEditAdded listeners on its underlying log.\n\t * This should be called if the underlying log or its listeners are re-used past the lifetime of this log viewer.\n\t */\n\tpublic readonly detachFromEditLog: () => void;\n\n\t/**\n\t * @returns true if the highest revision is cached.\n\t */\n\tpublic highestRevisionCached(): boolean {\n\t\treturn this.highestRevisionCacheEntry !== undefined;\n\t}\n\n\t/**\n\t * Create a new LogViewer\n\t * @param log - the edit log which revisions will be based on.\n\t * @param baseTree - the tree used in the view corresponding to the 0th revision.\n\t * @param knownRevisions - a set of [sequencedRevision, view] pairs that are known (have been precomputed) at construction time.\n\t * These revisions are guaranteed to never be evicted from the cache.\n\t * @param expensiveValidation - Iff true, additional correctness assertions will be run during LogViewer operations.\n\t * @param processEditStatus - called after applying an edit.\n\t * @param processSequencedEditResult - called after applying a sequenced edit.\n\t */\n\tpublic constructor(\n\t\tlog: EditLog<ChangeInternal>,\n\t\tbaseView: RevisionView,\n\t\tknownRevisions: [Revision, EditCacheEntry][] = [],\n\t\tprocessEditStatus: EditStatusCallback = noop,\n\t\tprocessSequencedEditResult: SequencedEditResultCallback = noop,\n\t\tminimumSequenceNumber = 0\n\t) {\n\t\tthis.log = log;\n\t\tknownRevisions.forEach(([revision]) => {\n\t\t\tassert(Number.isInteger(revision), 'revision must be an integer');\n\t\t\tassert(this.log.isSequencedRevision(revision), 'revision must correspond to the result of a SequencedEdit');\n\t\t});\n\n\t\tthis.sequencedRevisionCache = new RevisionValueCache(\n\t\t\tCachingLogViewer.sequencedCacheSizeMax,\n\t\t\tminimumSequenceNumber,\n\t\t\t[...knownRevisions, [0, { view: baseView }]]\n\t\t);\n\t\tthis.processEditStatus = processEditStatus ?? noop;\n\t\tthis.processSequencedEditResult = processSequencedEditResult ?? noop;\n\t\tthis.detachFromEditLog = this.log.registerEditAddedHandler(this.handleEditAdded.bind(this));\n\t}\n\n\t/**\n\t * As a performance optimization, this method caches views generated by local edits if they are sequenced without\n\t * being interleaved with remote edits.\n\t */\n\tprivate handleEditAdded(edit: Edit<ChangeInternal>, isLocal: boolean, wasLocal: boolean): void {\n\t\t// Clear highestRevisionCacheEntry, since what revision is highest might change.\n\t\t// Note that as an optimization we could skip clearing this when a local edit is sequenced.\n\t\tthis.highestRevisionCacheEntry = undefined;\n\n\t\tif (isLocal) {\n\t\t\tthis.unappliedSelfEdits.push(edit.id);\n\t\t} else if (wasLocal) {\n\t\t\t// If the new sequenced edit was generated by this client, the corresponding cache entry (if there is one)\n\t\t\t// will be at the front of the queue. If the queue is empty, then a concurrent sequenced edit from remote client\n\t\t\t// must have invalidated the queue cache.\n\t\t\tconst entry = this.localRevisionCache.shift();\n\t\t\tif (entry !== undefined) {\n\t\t\t\tconst revision = this.log.numberOfSequencedEdits;\n\t\t\t\tconst { view } = entry;\n\t\t\t\tthis.sequencedRevisionCache.cacheValue(\n\t\t\t\t\trevision,\n\t\t\t\t\tentry.status === EditStatus.Applied\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tview,\n\t\t\t\t\t\t\t\tstatus: entry.status,\n\t\t\t\t\t\t\t\tsteps: entry.steps,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tview,\n\t\t\t\t\t\t\t\tstatus: entry.status,\n\t\t\t\t\t\t\t\tfailure: entry.failure,\n\t\t\t\t\t\t }\n\t\t\t\t);\n\t\t\t\tthis.handleSequencedEditResult(edit, entry, []);\n\t\t\t}\n\t\t} else {\n\t\t\t// Invalidate any cached results of applying edits which are ordered after `edit` (which are all remaining local edits)\n\t\t\tthis.localRevisionCache.clear();\n\t\t}\n\t}\n\n\tpublic async getEditResult(revision: Revision): Promise<EditCacheEntry> {\n\t\tconst startingPoint = this.getStartingPoint(revision);\n\t\tconst { startRevision } = startingPoint;\n\t\tlet current: EditCacheEntry = startingPoint;\n\t\tfor (let i = startRevision; i < revision && i < this.log.length; i++) {\n\t\t\tconst edit = await this.log.getEditAtIndex(i);\n\t\t\tcurrent = this.applyEdit(current.view, edit, i);\n\t\t}\n\t\treturn current;\n\t}\n\n\tpublic async getRevisionView(revision: Revision): Promise<RevisionView> {\n\t\treturn (await this.getEditResult(revision)).view;\n\t}\n\n\tpublic getEditResultInSession(revision: Revision): EditCacheEntry {\n\t\tconst startingPoint = this.getStartingPoint(revision);\n\t\tconst { startRevision } = startingPoint;\n\t\tlet current: EditCacheEntry = startingPoint;\n\t\tfor (let i = startRevision; i < revision && i < this.log.length; i++) {\n\t\t\tconst edit = this.log.getEditInSessionAtIndex(i);\n\t\t\tcurrent = this.applyEdit(current.view, edit, i);\n\t\t}\n\t\treturn current;\n\t}\n\n\tpublic getRevisionViewInSession(revision: Revision): RevisionView {\n\t\treturn this.getEditResultInSession(revision).view;\n\t}\n\n\t/**\n\t * Informs the CachingLogViewer of the latest known minimumSequenceNumber for all connected clients.\n\t * This can be used to provide more aggressive caching of revisions within the collaboration window, as those revisions\n\t * are more likely to be demanded to resolve conflicts.\n\t * @param minSequenceNumber - the minimum known sequence number of all connected clients.\n\t */\n\tpublic setMinimumSequenceNumber(minimumSequenceNumber: number): void {\n\t\t// Sequence numbers in Fluid are 1-indexed, meaning they correspond to revisions, and can be used as revisions.\n\t\t// This ensures that all revisions >= minimumSequenceNumber are kept in the cache, meaning that even if all clients are caught up\n\t\t// the most recent sequenced revision will be cached.\n\t\tthis.sequencedRevisionCache.updateRetentionWindow(minimumSequenceNumber);\n\t}\n\n\t/**\n\t * Inform the CachingLogViewer that a particular edit is known to have a specific result when applied to a particular TreeView.\n\t * CachingLogViewer may use this information as an optimization to avoid re-running the edit if re-applied to the same TreeView.\n\t */\n\tpublic setKnownEditingResult(edit: Edit<ChangeInternal>, result: EditingResult): void {\n\t\tthis.cachedEditResult = { editId: edit.id, result };\n\t}\n\n\t/**\n\t * @returns the cached revision view closest to the requested `revision`.\n\t */\n\tprivate getStartingPoint(revision: Revision): { startRevision: Revision } & EditCacheEntry {\n\t\t// Per the documentation for revision, the returned view should be the output of the edit at the largest index <= `revision`.\n\t\tconst revisionClamped = Math.min(revision, this.log.length);\n\n\t\t// If the highest revision is requested, and it's cached, use highestRevisionCacheEntry.\n\t\tif (revisionClamped === this.log.length && this.highestRevisionCacheEntry !== undefined) {\n\t\t\treturn { ...this.highestRevisionCacheEntry, startRevision: revisionClamped };\n\t\t}\n\n\t\tlet current: EditCacheEntry;\n\t\tlet startRevision: Revision;\n\t\tconst { numberOfSequencedEdits } = this.log;\n\t\tconst isLocalRevision = revisionClamped > numberOfSequencedEdits;\n\t\tif (isLocalRevision && !this.localRevisionCache.isEmpty()) {\n\t\t\tconst { length } = this.localRevisionCache;\n\t\t\t// Local revision view cache is indexed such that the view for revision 0 (a local edit) is stored at index 0 in the cache.\n\t\t\t// This is because the local cache does not contain an entry for the implicit initial tree edit.\n\t\t\tconst localCacheIndex = revisionClamped - 1 - numberOfSequencedEdits;\n\t\t\tif (localCacheIndex < length) {\n\t\t\t\tconst cached =\n\t\t\t\t\tthis.localRevisionCache.peekAt(localCacheIndex) ?? fail('missing tail of localRevisionViewCache');\n\t\t\t\treturn {\n\t\t\t\t\t...cached,\n\t\t\t\t\tstartRevision: revisionClamped,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tcurrent = this.localRevisionCache.peekAt(length - 1) ?? fail('missing tail of localRevisionViewCache');\n\t\t\t\tstartRevision = numberOfSequencedEdits + length;\n\t\t\t}\n\t\t} else {\n\t\t\tconst [cachedRevision, cachedView] =\n\t\t\t\tthis.sequencedRevisionCache.getClosestEntry(revisionClamped) ??\n\t\t\t\tfail('No preceding revision view cached.');\n\n\t\t\tstartRevision = cachedRevision;\n\t\t\tcurrent = cachedView;\n\t\t}\n\t\treturn { startRevision, ...current };\n\t}\n\n\t/**\n\t * Helper for applying an edit at the supplied revision view.\n\t * Must only be called in the order that edits appear in the log.\n\t * Must only be called once for a given local edit as long as the local cache has not been invalidated.\n\t * Must only be called once for a given sequenced edit.\n\t * @returns the resulting revision view and the outcome of edit that produced it.\n\t */\n\tprivate applyEdit(\n\t\tprevView: RevisionView,\n\t\tedit: Edit<ChangeInternal>,\n\t\teditIndex: number\n\t): AttemptedEditResultCacheEntry {\n\t\tlet editingResult: EditingResult;\n\t\tlet cached;\n\t\tlet reconciliationPath: ReconciliationPath = [];\n\t\tif (\n\t\t\tthis.cachedEditResult !== undefined &&\n\t\t\tthis.cachedEditResult.editId === edit.id &&\n\t\t\tthis.cachedEditResult.result.before === prevView\n\t\t) {\n\t\t\teditingResult = this.cachedEditResult.result;\n\t\t\tcached = true;\n\t\t} else {\n\t\t\treconciliationPath = this.reconciliationPathFromEdit(edit.id);\n\t\t\teditingResult = TransactionInternal.factory(prevView)\n\t\t\t\t.applyChanges(edit.changes, reconciliationPath)\n\t\t\t\t.close();\n\t\t\tcached = false;\n\t\t}\n\n\t\tconst revision = editIndex + 1;\n\t\tconst nextView: RevisionView = editingResult.status === EditStatus.Applied ? editingResult.after : prevView;\n\n\t\tconst computedCacheEntry =\n\t\t\teditingResult.status === EditStatus.Applied\n\t\t\t\t? { view: nextView, status: editingResult.status, steps: editingResult.steps }\n\t\t\t\t: { view: nextView, status: editingResult.status, failure: editingResult.failure };\n\n\t\tif (this.log.isSequencedRevision(revision)) {\n\t\t\tthis.sequencedRevisionCache.cacheValue(revision, computedCacheEntry);\n\t\t\tthis.handleSequencedEditResult(edit, computedCacheEntry, reconciliationPath);\n\t\t} else {\n\t\t\t// This relies on local edits being append only, and that generating the view for a local revision requires generating\n\t\t\t// the views for all local revisions before it in the log. Thus, generating such a view will necessarily require\n\t\t\t// calls to this method for all local revisions prior, guaranteeing the correct push order.\n\t\t\tassert(\n\t\t\t\trevision === this.log.numberOfSequencedEdits + this.localRevisionCache.length + 1,\n\t\t\t\t'Local revision view cached out of order.'\n\t\t\t);\n\t\t\tthis.localRevisionCache.push(computedCacheEntry);\n\t\t}\n\n\t\t// Only update highestRevisionCacheEntry if this snapshot is the highest revision.\n\t\tif (revision >= this.log.length) {\n\t\t\tthis.highestRevisionCacheEntry = computedCacheEntry;\n\t\t}\n\n\t\tthis.processEditStatus(editingResult.status, this.log.getIdAtIndex(editIndex), cached);\n\t\treturn computedCacheEntry;\n\t}\n\n\t/**\n\t * Helper for performing caching when a sequenced local edit is first applied.\n\t * Invokes the `processSequencedEditResult` handler that was passed to the constructor (if any).\n\t * Must only be called for non-cached sequenced edits.\n\t */\n\tprivate handleSequencedEditResult(\n\t\tedit: Edit<ChangeInternal>,\n\t\tresult: AttemptedEditResultCacheEntry,\n\t\treconciliationPath: ReconciliationPath\n\t): void {\n\t\tlet wasLocal = false;\n\t\t// This is the first time this sequenced edit has been processed by this LogViewer. If it was a local edit, log telemetry\n\t\t// in the event that it was invalid or malformed.\n\t\tif (this.unappliedSelfEdits.length > 0) {\n\t\t\tif (edit.id === this.unappliedSelfEdits.peekFront()) {\n\t\t\t\twasLocal = true;\n\t\t\t\tthis.unappliedSelfEdits.shift();\n\t\t\t}\n\t\t}\n\t\tthis.processSequencedEditResult({ edit, wasLocal, result, reconciliationPath });\n\t}\n\n\t/**\n\t * We currently compute only the \"main branch\" part of the reconciliation path (meaning we don't include inverts of the edits\n\t * that occurred on the rebased branch). Doing so is only needed for the sequential anchor resolution approach which is not\n\t * yet supported.\n\t * @param editId - The ID for the edit to get the reconciliation path for.\n\t */\n\tpublic reconciliationPathFromEdit(editId: EditId): ReconciliationPath {\n\t\tconst reconciliationPath: ReconciliationEdit[] = [];\n\t\tlet cached = false;\n\t\treturn new Proxy(reconciliationPath, {\n\t\t\tget: (target, prop): unknown => {\n\t\t\t\tif (!cached) {\n\t\t\t\t\tcached = true;\n\t\t\t\t\tconst orderedId = this.log.getOrderedEditId(editId);\n\t\t\t\t\tif (orderedId.isLocal === false && orderedId.sequenceInfo !== undefined) {\n\t\t\t\t\t\tconst earliestSequenced = this.earliestSequencedEditInSession();\n\t\t\t\t\t\tif (earliestSequenced !== undefined) {\n\t\t\t\t\t\t\tconst earliestEditSequenceNumber = earliestSequenced.sequenceNumber;\n\t\t\t\t\t\t\tconst targetSequenceNumber = Math.max(\n\t\t\t\t\t\t\t\tearliestEditSequenceNumber,\n\t\t\t\t\t\t\t\torderedId.sequenceInfo.referenceSequenceNumber\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (targetSequenceNumber < orderedId.sequenceInfo.sequenceNumber) {\n\t\t\t\t\t\t\t\tconst firstEdit = this.getEditResultFromSequenceNumber(targetSequenceNumber);\n\t\t\t\t\t\t\t\tif (firstEdit !== undefined) {\n\t\t\t\t\t\t\t\t\tif (firstEdit.status === EditStatus.Applied) {\n\t\t\t\t\t\t\t\t\t\tconst firstEditInfo = this.log.getOrderedEditId(\n\t\t\t\t\t\t\t\t\t\t\tfirstEdit.id\n\t\t\t\t\t\t\t\t\t\t) as SequencedOrderedEditId;\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\tfirstEditInfo.sequenceInfo !== undefined &&\n\t\t\t\t\t\t\t\t\t\t\tfirstEditInfo.sequenceInfo.sequenceNumber >\n\t\t\t\t\t\t\t\t\t\t\t\torderedId.sequenceInfo.referenceSequenceNumber\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\treconciliationPath.push({\n\t\t\t\t\t\t\t\t\t\t\t\t...firstEdit.steps,\n\t\t\t\t\t\t\t\t\t\t\t\tbefore: firstEdit.before,\n\t\t\t\t\t\t\t\t\t\t\t\tafter: firstEdit.view,\n\t\t\t\t\t\t\t\t\t\t\t\tlength: firstEdit.steps.length,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\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\tconst lowestIndex = this.log.getIndexOfId(firstEdit.id) + 1;\n\t\t\t\t\t\t\t\t\tconst highestIndex = this.log.getIndexOfId(editId) - 1;\n\t\t\t\t\t\t\t\t\tfor (let index = lowestIndex; index <= highestIndex; ++index) {\n\t\t\t\t\t\t\t\t\t\tconst edit = this.getEditResultFromIndex(index);\n\t\t\t\t\t\t\t\t\t\tif (edit.status === EditStatus.Applied) {\n\t\t\t\t\t\t\t\t\t\t\treconciliationPath.push({\n\t\t\t\t\t\t\t\t\t\t\t\t...edit.steps,\n\t\t\t\t\t\t\t\t\t\t\t\tbefore: edit.before,\n\t\t\t\t\t\t\t\t\t\t\t\tafter: edit.view,\n\t\t\t\t\t\t\t\t\t\t\t\tlength: edit.steps.length,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\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}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[prop];\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * @returns Edit information for the earliest known sequenced edit.\n\t */\n\tpublic earliestSequencedEditInSession(): { edit: Edit<ChangeInternal>; sequenceNumber: number } | undefined {\n\t\tconst earliestEditIndex = this.log.earliestAvailableEditIndex;\n\t\tconst lastSequencedEdit = this.log.numberOfSequencedEdits + earliestEditIndex - 1;\n\t\tfor (let index = earliestEditIndex; index <= lastSequencedEdit; ++index) {\n\t\t\tconst edit = this.log.getEditInSessionAtIndex(index);\n\t\t\tconst editOrderedId = this.log.getOrderedEditId(edit.id) as SequencedOrderedEditId;\n\t\t\tif (editOrderedId.sequenceInfo !== undefined) {\n\t\t\t\treturn { edit, sequenceNumber: editOrderedId.sequenceInfo.sequenceNumber };\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * @returns Edit result information for the edit at the given `index`.\n\t */\n\tprivate getEditResultFromIndex(index: number): CachedEditingResult {\n\t\tconst edit = this.log.getEditInSessionAtIndex(index);\n\t\tconst before = this.getRevisionViewInSession(index);\n\t\tconst resultAfter = this.getEditResultInSession(index + 1);\n\t\tif (resultAfter.status === undefined) {\n\t\t\tfail('The status of every edit in session should be known');\n\t\t}\n\t\treturn resultAfter.status === EditStatus.Applied\n\t\t\t? {\n\t\t\t\t\tid: edit.id,\n\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\tbefore,\n\t\t\t\t\tchanges: edit.changes,\n\t\t\t\t\tview: resultAfter.view,\n\t\t\t\t\tsteps: resultAfter.steps,\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\tid: edit.id,\n\t\t\t\t\tstatus: resultAfter.status,\n\t\t\t\t\tfailure: resultAfter.failure,\n\t\t\t\t\tbefore,\n\t\t\t\t\tview: resultAfter.view,\n\t\t\t\t\tchanges: edit.changes,\n\t\t\t };\n\t}\n\n\t/**\n\t * @param sequenceNumber - The server-assigned sequenced number assigned to the edit of interest.\n\t * @returns Edit result information for the edit with the given sequence number or the nearest sequenced edit before that.\n\t * Undefined if no sequenced edit occurred at or prior to the given sequenceNumber.\n\t */\n\tpublic getEditResultFromSequenceNumber(sequenceNumber: number): CachedEditingResult | undefined {\n\t\tconst earliestSequenced = this.earliestSequencedEditInSession();\n\t\tif (earliestSequenced !== undefined && sequenceNumber >= earliestSequenced.sequenceNumber) {\n\t\t\tconst lowestIndex = this.log.getIndexOfId(earliestSequenced.edit.id);\n\t\t\tconst highestIndex = this.log.numberOfSequencedEdits - 1;\n\t\t\tfor (let index = highestIndex; index >= lowestIndex; --index) {\n\t\t\t\tconst edit = this.log.getEditInSessionAtIndex(index);\n\t\t\t\tconst orderedId = this.log.getOrderedEditId(edit.id) as SequencedOrderedEditId;\n\t\t\t\t// If `orderedId.sequenceInfo.sequenceNumber` is equal to the requested `sequenceNumber` then we have found the edit of\n\t\t\t\t// interest and simply return its associated information.\n\t\t\t\t// Note that the check bellow also is also satisfied if `orderedId.sequenceInfo.sequenceNumber`is lower than the requested\n\t\t\t\t// `sequenceNumber`. This can happen when the edit for the requested `sequenceNumber` has either not yet been received or\n\t\t\t\t// has been processed by a different DDS (several DDSes can share the same stream of operations and will only see those\n\t\t\t\t// relevant to them). In such cases, we return the edit info for the last known edit before that.\n\t\t\t\tif (orderedId.sequenceInfo && orderedId.sequenceInfo.sequenceNumber <= sequenceNumber) {\n\t\t\t\t\tconst before = this.getRevisionViewInSession(index);\n\t\t\t\t\tconst resultAfter = this.getEditResultInSession(index + 1);\n\t\t\t\t\tif (resultAfter.status === undefined) {\n\t\t\t\t\t\tfail('The status of every edit in session should be known');\n\t\t\t\t\t}\n\t\t\t\t\treturn resultAfter.status === EditStatus.Applied\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: edit.id,\n\t\t\t\t\t\t\t\tstatus: EditStatus.Applied,\n\t\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\t\tchanges: edit.changes,\n\t\t\t\t\t\t\t\tview: resultAfter.view,\n\t\t\t\t\t\t\t\tsteps: resultAfter.steps,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tid: edit.id,\n\t\t\t\t\t\t\t\tstatus: resultAfter.status,\n\t\t\t\t\t\t\t\tfailure: resultAfter.failure,\n\t\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\t\tview: resultAfter.view,\n\t\t\t\t\t\t\t\tchanges: edit.changes,\n\t\t\t\t\t\t };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SharedTree.d.ts","sourceRoot":"","sources":["../src/SharedTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACR,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAEN,gBAAgB,EAChB,mBAAmB,EAEnB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAA6D,cAAc,EAAE,MAAM,WAAW,CAAC;AACtG,OAAO,EACN,MAAM,EACN,MAAM,EACN,YAAY,EAIZ,aAAa,EACb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAIN,SAAS,EAGT,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAEN,cAAc,EA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C,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,YAAY,GACnD,MAAM,EAAE;IAaX;;;;;;OAMG;IACI,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,GAAG,SAAS,cAAc,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC;IAa/G;;;;OAIG;IACI,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc;IAmExD,OAAO,CAAC,gBAAgB;IAgBxB;;;;;OAKG;IACI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAYjD;;;;;;OAMG;IACI,aAAa,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,cAAc,EAAE,GAAG,SAAS;IAIhH;;OAEG;IACH,OAAO,CAAC,YAAY;IAyBpB,OAAO,CAAC,aAAa;IAIrB,oEAAoE;IACpE,OAAO,CAAC,QAAQ;IAQT,UAAU,IAAI,sBAAsB;IAI3C;;;;;;;;;OASG;IACH,SAAS,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI;IA6C3C,OAAO,CAAC,iBAAiB;IAKzB;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;CAuB7B"}
@@ -166,7 +166,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
166
166
  this.logger = telemetry_utils_1.ChildLogger.create(runtime.logger, 'SharedTree', sharedTreeTelemetryProperties);
167
167
  this.sequencedEditAppliedLogger = telemetry_utils_1.ChildLogger.create(this.logger, 'SequencedEditApplied', sharedTreeTelemetryProperties);
168
168
  const attributionId = options.attributionId;
169
- this.idCompressor = new id_compressor_1.IdCompressor((0, id_compressor_1.createSessionId)(), persisted_types_1.reservedIdCount, attributionId);
169
+ this.idCompressor = new id_compressor_1.IdCompressor((0, id_compressor_1.createSessionId)(), persisted_types_1.reservedIdCount, attributionId, this.logger);
170
170
  const { editLog, cachingLogViewer } = this.initializeNewEditLogFromSummary({
171
171
  editChunks: [],
172
172
  editIds: [],
@@ -225,18 +225,15 @@ class SharedTree extends shared_object_base_1.SharedObject {
225
225
  getHistoryPolicy(options) {
226
226
  var _a;
227
227
  const noCompatOptions = options;
228
- if (typeof noCompatOptions.summarizeHistory === 'object') {
229
- return {
228
+ return typeof noCompatOptions.summarizeHistory === 'object'
229
+ ? {
230
230
  summarizeHistory: true,
231
231
  uploadEditChunks: noCompatOptions.summarizeHistory.uploadEditChunks,
232
- };
233
- }
234
- else {
235
- return {
232
+ }
233
+ : {
236
234
  summarizeHistory: (_a = noCompatOptions.summarizeHistory) !== null && _a !== void 0 ? _a : false,
237
235
  uploadEditChunks: false,
238
236
  };
239
- }
240
237
  }
241
238
  /**
242
239
  * The write format version currently used by this `SharedTree`. This is always initialized to the write format
@@ -657,9 +654,12 @@ class SharedTree extends shared_object_base_1.SharedObject {
657
654
  const typedMessage = message;
658
655
  this.cachingLogViewer.setMinimumSequenceNumber(typedMessage.minimumSequenceNumber);
659
656
  const op = typedMessage.contents;
657
+ if (op.version === undefined) {
658
+ // Back-compat: some legacy documents may contain trailing ops with an unstamped version; normalize them.
659
+ op.version = persisted_types_1.WriteFormat.v0_0_2;
660
+ }
660
661
  const { type, version } = op;
661
- const resolvedVersion = version !== null && version !== void 0 ? version : persisted_types_1.WriteFormat.v0_0_2;
662
- const sameVersion = resolvedVersion === this.writeFormat;
662
+ const sameVersion = version === this.writeFormat;
663
663
  // Edit and handle ops should only be processed if they're the same version as the tree write version.
664
664
  // Update ops should only be processed if they're not the same version.
665
665
  if (sameVersion) {
@@ -690,7 +690,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
690
690
  else if (type === persisted_types_1.SharedTreeOpType.Update) {
691
691
  this.processVersionUpdate(op.version);
692
692
  }
693
- else if (compareSummaryFormatVersions(resolvedVersion, this.writeFormat) === 1) {
693
+ else if (compareSummaryFormatVersions(version, this.writeFormat) === 1) {
694
694
  // An op version newer than our current version should not be received. If this happens, either an
695
695
  // incorrect op version has been written or an update op was skipped.
696
696
  const error = 'Newer op version received by a client that has yet to be updated.';
@@ -803,7 +803,7 @@ class SharedTree extends shared_object_base_1.SharedObject {
803
803
  this.interner = new StringInterner_1.MutableStringInterner([InitialTree_1.initialTree.definition]);
804
804
  const oldIdCompressor = this.idCompressor;
805
805
  // Create the IdCompressor that will be used after the upgrade
806
- const newIdCompressor = new id_compressor_1.IdCompressor((0, id_compressor_1.createSessionId)(), persisted_types_1.reservedIdCount, this.attributionId);
806
+ const newIdCompressor = new id_compressor_1.IdCompressor((0, id_compressor_1.createSessionId)(), persisted_types_1.reservedIdCount, this.attributionId, this.logger);
807
807
  const newContext = (0, NodeIdUtilities_1.getNodeIdContext)(newIdCompressor);
808
808
  // Generate all local IDs in the new compressor that were in the old compressor and preserve their UUIDs.
809
809
  // This will allow the client to continue to use local IDs that were allocated pre-upgrade