@fluid-experimental/tree 0.55.0 → 0.56.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generic/GenericSharedTree.d.ts +1 -1
- package/dist/generic/GenericSharedTree.d.ts.map +1 -1
- package/dist/generic/GenericSharedTree.js +1 -1
- package/dist/generic/GenericSharedTree.js.map +1 -1
- package/lib/generic/GenericSharedTree.d.ts +1 -1
- package/lib/generic/GenericSharedTree.d.ts.map +1 -1
- package/lib/generic/GenericSharedTree.js +1 -1
- package/lib/generic/GenericSharedTree.js.map +1 -1
- package/package.json +13 -14
- package/src/generic/GenericSharedTree.ts +1 -1
|
@@ -150,7 +150,7 @@ export declare abstract class GenericSharedTree<TChange> extends SharedObject<IS
|
|
|
150
150
|
/**
|
|
151
151
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
152
152
|
*/
|
|
153
|
-
summarizeCore(serializer: IFluidSerializer
|
|
153
|
+
summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
|
|
154
154
|
/**
|
|
155
155
|
* Saves this SharedTree into a serialized summary.
|
|
156
156
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericSharedTree.d.ts","sourceRoot":"","sources":["../../src/generic/GenericSharedTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAEN,gBAAgB,EAChB,mBAAmB,EAEnB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAAW,cAAc,EAAE,MAAM,YAAY,CAAC;AAC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-base#SharedObject.summarizeCore}
|
|
219
219
|
*/
|
|
220
|
-
summarizeCore(serializer
|
|
220
|
+
summarizeCore(serializer) {
|
|
221
221
|
return shared_object_base_1.createSingleBlobSummary(snapshotFileName, this.saveSerializedSummary({ serializer }));
|
|
222
222
|
}
|
|
223
223
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericSharedTree.js","sourceRoot":"","sources":["../../src/generic/GenericSharedTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AAQzE,iFAAoE;AACpE,2EAM4C;AAE5C,qEAA8G;AAE9G,sCAA6D;AAC7D,wCAAqD;AAErD,0CAAuC;AACvC,gDAA6C;AAC7C,4CAA+E;AAC/E,0EAAyG;AACzG,qDAQ0B;AAC1B,uCAAsG;AAEtG,iEAAiD;AAEjD;;GAEG;AACH,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC,MAAM,cAAc,GAA+B;IAClD,OAAO,EAAE,4CAAiB;IAC1B,WAAW,EAAE,yBAAW;IACxB,WAAW,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,OAAO,EAAE,EAAE;KACX;CACD,CAAC;AAEF;;;GAGG;AACH,IAAY,eAUX;AAVD,WAAY,eAAe;IAC1B;;;;;;;OAOG;IACH,kDAA+B,CAAA;AAChC,CAAC,EAVW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAU1B;AAED;;;GAGG;AACH,IAAY,yBA0BX;AA1BD,WAAY,yBAAyB;IACpC;;OAEG;IACH,wEAA2C,CAAA;IAC3C;;;;;OAKG;IACH,wDAA2B,CAAA;IAC3B;;;;;OAKG;IACH,sEAAyC,CAAA;IACzC;;;;;OAKG;IACH,0EAA6C,CAAA;AAC9C,CAAC,EA1BW,yBAAyB,GAAzB,iCAAyB,KAAzB,iCAAyB,QA0BpC;AA2BD,MAAM,6BAA6B,GAAiC,EAAE,GAAG,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,EAAE,CAAC;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B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AA9cD,8CA8cC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, IsoBuffer } from '@fluidframework/common-utils';\nimport { IFluidHandle } from '@fluidframework/core-interfaces';\nimport { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelAttributes,\n} from '@fluidframework/datastore-definitions';\nimport { AttachState } from '@fluidframework/container-definitions';\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tISharedObjectEvents,\n\tserializeHandles,\n\tSharedObject,\n} from '@fluidframework/shared-object-base';\nimport { ITelemetryLogger } from '@fluidframework/common-definitions';\nimport { ChildLogger, ITelemetryLoggerPropertyBags, PerformanceEvent } from '@fluidframework/telemetry-utils';\nimport { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';\nimport { assert, assertNotUndefined, fail } from '../Common';\nimport { EditLog, OrderedEditSet } from '../EditLog';\nimport { EditId } from '../Identifiers';\nimport { Snapshot } from '../Snapshot';\nimport { initialTree } from '../InitialTree';\nimport { CachingLogViewer, EditStatusCallback, LogViewer } from '../LogViewer';\nimport { convertSummaryToReadFormat, deserialize, readFormatVersion } from '../SummaryBackCompatibility';\nimport {\n\tEdit,\n\tSharedTreeOpType,\n\tSharedTreeEditOp,\n\tSharedTreeHandleOp,\n\tEditWithoutId,\n\tSharedTreeOp,\n\tEditStatus,\n} from './PersistedTypes';\nimport { serialize, SharedTreeSummarizer, SharedTreeSummary, SharedTreeSummaryBase } from './Summary';\nimport { GenericTransaction } from './GenericTransaction';\nimport { newEdit } from './GenericEditUtilities';\n\n/**\n * Filename where the snapshot is stored.\n */\nconst snapshotFileName = 'header';\n\nconst initialSummary: SharedTreeSummary<unknown> = {\n\tversion: readFormatVersion,\n\tcurrentTree: initialTree,\n\teditHistory: {\n\t\teditChunks: [],\n\t\teditIds: [],\n\t},\n};\n\n/**\n * An event emitted by a `SharedTree` to indicate a state change. See {@link ISharedTreeEvents} for event argument information.\n * @public\n */\nexport enum SharedTreeEvent {\n\t/**\n\t * An edit has been committed to the log.\n\t * This happens when either:\n\t * \t1. A locally generated edit is added to the log.\n\t * \t2. A remotely generated edit is added to the log.\n\t * Note that, for locally generated edits, this event will not be emitted again when that edit is sequenced.\n\t * Passed the EditId of the committed edit, i.e. supports callbacks of type {@link EditCommittedHandler}.\n\t */\n\tEditCommitted = 'committedEdit',\n}\n\n/**\n * An event emitted by a `SharedTree` for diagnostic purposes.\n * See {@link ISharedTreeEvents} for event argument information.\n */\nexport enum SharedTreeDiagnosticEvent {\n\t/**\n\t * A single catch up blob has been uploaded.\n\t */\n\tCatchUpBlobUploaded = 'uploadedCatchUpBlob',\n\t/**\n\t * A valid edit (local or remote) has been applied.\n\t * Passed the EditId of the applied edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tAppliedEdit = 'appliedEdit',\n\t/**\n\t * An invalid edit (local or remote) has been dropped.\n\t * Passed the EditId of the dropped edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tDroppedInvalidEdit = 'droppedInvalidEdit',\n\t/**\n\t * A malformed edit (local or remote) has been dropped.\n\t * Passed the EditId of the dropped edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tDroppedMalformedEdit = 'droppedMalformedEdit',\n}\n\n/**\n * The arguments included when the EditCommitted SharedTreeEvent is emitted.\n * @public\n */\nexport interface EditCommittedEventArguments<TSharedTree> {\n\t/** The ID of the edit committed. */\n\teditId: EditId;\n\t/** Whether or not this is a local edit. */\n\tlocal: boolean;\n\t/** The tree the edit was committed on. Required for local edit events handled by SharedTreeUndoRedoHandler. */\n\ttree: TSharedTree;\n}\n\n/**\n * Events which may be emitted by `SharedTree`. See {@link SharedTreeEvent} for documentation of event semantics.\n */\nexport interface ISharedTreeEvents<TSharedTree> extends ISharedObjectEvents {\n\t(event: 'committedEdit', listener: EditCommittedHandler<TSharedTree>);\n}\n\n/**\n * Expected type for a handler of the `EditCommitted` event.\n */\nexport type EditCommittedHandler<TSharedTree> = (args: EditCommittedEventArguments<TSharedTree>) => void;\n\nconst sharedTreeTelemetryProperties: ITelemetryLoggerPropertyBags = { all: { isSharedTreeEvent: true } };\n\n/**\n * A distributed tree.\n * @public\n */\nexport abstract class GenericSharedTree<TChange> extends SharedObject<ISharedTreeEvents<TChange>> {\n\t/**\n\t * The log of completed edits for this SharedTree.\n\t */\n\tprivate editLog: EditLog<TChange>;\n\n\t/**\n\t * As an implementation detail, SharedTree uses a log viewer that caches snapshots at different revisions.\n\t * It is not exposed to avoid accidental correctness issues, but `logViewer` is exposed in order to give clients a way\n\t * to access the revision history.\n\t */\n\tprivate cachingLogViewer: CachingLogViewer<TChange>;\n\n\t/**\n\t * Viewer for trees defined by editLog. This allows access to views of the tree at different revisions (various points in time).\n\t */\n\tpublic get logViewer(): LogViewer {\n\t\treturn this.cachingLogViewer;\n\t}\n\n\tprotected readonly logger: ITelemetryLogger;\n\n\tpublic readonly transactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>;\n\n\t/** Indicates if the client is the oldest member of the quorum. */\n\tprivate currentIsOldest: boolean;\n\n\tprivate readonly processEditResult = (editResult: EditStatus, editId: EditId): void => {\n\t\t// TODO:#44859: Invalid results should be handled by the app\n\t\tthis.emit(GenericSharedTree.eventFromEditResult(editResult), editId);\n\t};\n\n\t/**\n\t * Create a new SharedTreeFactory.\n\t * @param runtime - The runtime the SharedTree will be associated with\n\t * @param id - Unique ID for the SharedTree\n\t * @param expensiveValidation - Enable expensive asserts.\n\t * @param summarizeHistory - Determines if the history is included in summaries.\n\t */\n\tpublic constructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\ttransactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly expensiveValidation = false,\n\t\tprotected readonly summarizeHistory = true\n\t) {\n\t\tsuper(id, runtime, attributes);\n\t\tthis.expensiveValidation = expensiveValidation;\n\t\tthis.transactionFactory = transactionFactory;\n\n\t\t// This code is somewhat duplicated from OldestClientObserver because it currently depends on the container runtime\n\t\t// which SharedTree does not have access to.\n\t\t// TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tthis.currentIsOldest = this.computeIsOldest();\n\t\tquorum.on('addMember', this.updateOldest);\n\t\tquorum.on('removeMember', this.updateOldest);\n\t\truntime.on('connected', this.updateOldest);\n\t\truntime.on('disconnected', this.updateOldest);\n\n\t\tthis.logger = ChildLogger.create(runtime.logger, 'SharedTree', sharedTreeTelemetryProperties);\n\t\tconst { editLog, cachingLogViewer } = this.createEditLogFromSummary(initialSummary, this.processEditResult);\n\n\t\tthis.editLog = editLog;\n\t\tthis.cachingLogViewer = cachingLogViewer;\n\t}\n\n\t/**\n\t * Re-computes currentIsOldest and emits an event if it has changed.\n\t * TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t */\n\tprivate readonly updateOldest = () => {\n\t\tconst oldest = this.computeIsOldest();\n\t\tif (this.currentIsOldest !== oldest) {\n\t\t\tthis.currentIsOldest = oldest;\n\t\t\tif (oldest) {\n\t\t\t\tthis.emit('becameOldest');\n\t\t\t} else {\n\t\t\t\tthis.emit('lostOldest');\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Computes the oldest client in the quorum, true by default if the container is detached and false by default if the client isn't connected.\n\t * TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t */\n\tprivate computeIsOldest(): boolean {\n\t\t// If the container is detached, we are the only ones that know about it and are the oldest by default.\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If we're not connected we can't be the oldest connected client.\n\t\tif (!this.runtime.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.runtime.clientId !== undefined, 'Client id should be set if connected.');\n\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tconst selfSequencedClient = quorum.getMember(this.runtime.clientId);\n\t\t// When in readonly mode our clientId will not be present in the quorum.\n\t\tif (selfSequencedClient === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst members = quorum.getMembers();\n\t\tfor (const sequencedClient of members.values()) {\n\t\t\tif (sequencedClient.sequenceNumber < selfSequencedClient.sequenceNumber) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// No member of the quorum was older\n\t\treturn true;\n\t}\n\n\t/**\n\t * @returns the current view of the tree.\n\t */\n\tpublic get currentView(): Snapshot {\n\t\treturn this.logViewer.getSnapshotInSession(Number.POSITIVE_INFINITY);\n\t}\n\n\t/**\n\t * @returns the edit history of the tree.\n\t */\n\tpublic get edits(): OrderedEditSet<TChange> {\n\t\treturn this.editLog;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t *\n\t * For convenient imperative variants of edits, see `editor`.\n\t * @internal\n\t */\n\tpublic applyEdit(...changes: TChange[]): EditId {\n\t\tconst edit = newEdit(changes);\n\t\tthis.processLocalEdit(edit);\n\t\treturn edit.id;\n\t}\n\n\tprivate deserializeHandle(serializedHandle: string): IFluidHandle<ArrayBufferLike> {\n\t\tconst deserializeHandle = this.serializer.parse(serializedHandle);\n\t\tassert(typeof deserializeHandle === 'object');\n\t\treturn deserializeHandle as IFluidHandle<ArrayBufferLike>;\n\t}\n\n\t/**\n\t * Uploads the edit chunk and sends the chunk starting revision along with the resulting handle as an op.\n\t */\n\tprivate async uploadEditChunk(edits: readonly EditWithoutId<TChange>[], startRevision: number): Promise<void> {\n\t\ttry {\n\t\t\tconst editHandle = await this.runtime.uploadBlob(IsoBuffer.from(JSON.stringify({ edits })));\n\t\t\tthis.submitLocalMessage({\n\t\t\t\teditHandle: serializeHandles(editHandle, this.serializer, this.handle),\n\t\t\t\tstartRevision,\n\t\t\t\ttype: SharedTreeOpType.Handle,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t// If chunk load fails, we will try again later in loadCore on the oldest client so we log the error instead of throwing.\n\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: 'EditChunkUploadFailure',\n\t\t\t\t},\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tpublic summarizeCore(serializer: IFluidSerializer, fullTree: boolean): ISummaryTreeWithStats {\n\t\treturn createSingleBlobSummary(snapshotFileName, this.saveSerializedSummary({ serializer }));\n\t}\n\n\t/**\n\t * Saves this SharedTree into a serialized summary.\n\t *\n\t * @param options - Optional serializer and summarizer to use. If not passed in, SharedTree's serializer and summarizer are used.\n\t * @internal\n\t */\n\tpublic saveSerializedSummary(options?: {\n\t\tserializer?: IFluidSerializer;\n\t\tsummarizer?: SharedTreeSummarizer<TChange>;\n\t}): string {\n\t\tconst { serializer, summarizer } = options || {};\n\n\t\treturn serialize(\n\t\t\tsummarizer ? summarizer(this.editLog, this.currentView) : this.saveSummary(),\n\t\t\tserializer || this.serializer,\n\t\t\tthis.handle\n\t\t);\n\t}\n\n\t/**\n\t * Saves this SharedTree into a summary.\n\t * @internal\n\t */\n\tpublic saveSummary(): SharedTreeSummaryBase {\n\t\t// If local changes exist, emulate the sequencing of those changes.\n\t\t// Doing so is necessary so edits created during DataObject.initializingFirstTime are included.\n\t\t// Doing so is safe because it is guaranteed that the DDS has not yet been attached. This is because summary creation is only\n\t\t// ever invoked on a DataObject containing local changes when it is attached for the first time. In post-attach flows, an extra\n\t\t// instance of the DataObject is created for generating summaries and will never have local edits.\n\t\tif (this.editLog.numberOfLocalEdits > 0) {\n\t\t\tassert(\n\t\t\t\tthis.runtime.attachState !== AttachState.Attached,\n\t\t\t\t'Summarizing should not occur with local edits except on first attach.'\n\t\t\t);\n\t\t\tthis.editLog.sequenceLocalEdits();\n\t\t}\n\n\t\tassert(this.editLog.numberOfLocalEdits === 0, 'generateSummary must not be called with local edits');\n\t\treturn this.generateSummary(this.editLog);\n\t}\n\n\t/**\n\t * Generates a SharedTree summary for the current state of the tree.\n\t * Will never be called when local edits are present.\n\t */\n\tprotected abstract generateSummary(editLog: OrderedEditSet<TChange>): SharedTreeSummaryBase;\n\n\t/**\n\t * Initialize shared tree with a summary.\n\t * @internal\n\t */\n\tpublic loadSummary(summary: SharedTreeSummaryBase): void {\n\t\tconst { editLog, cachingLogViewer } = this.createEditLogFromSummary(summary, this.processEditResult);\n\t\tthis.editLog = editLog;\n\t\tthis.cachingLogViewer = cachingLogViewer;\n\n\t\tif (this.runtime.connected) {\n\t\t\tconst noChunksReadyForUpload = this.editLog.getEditChunksReadyForUpload()[Symbol.iterator]().next().done;\n\t\t\tif (noChunksReadyForUpload === undefined || !noChunksReadyForUpload) {\n\t\t\t\t// A client does not become a member of the quorum until it is within the collaboration window.\n\t\t\t\t//\n\t\t\t\t// The collaboration window is the range from the minimum sequence number enforced by the server and head.\n\t\t\t\t// When a client sends an op, they include the last sequence number the client has processed. We call this the reference\n\t\t\t\t// sequence number.\n\t\t\t\t//\n\t\t\t\t// If there are no members in the quorum, we send a no op op in order to have this client added as a member to the quorum.\n\t\t\t\t// This is required so we can ensure only the oldest client will upload blobs during summary load.\n\t\t\t\tif (this.runtime.getQuorum().getMembers().size === 0) {\n\t\t\t\t\tconst noop: SharedTreeOp = {\n\t\t\t\t\t\ttype: SharedTreeOpType.NoOp,\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.submitLocalMessage(noop);\n\t\t\t\t} else if (this.currentIsOldest) {\n\t\t\t\t\tvoid this.uploadCatchUpBlobs();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If this client becomes the oldest, it should take care of uploading catch up blobs.\n\t\t\tthis.on('becameOldest', () => void this.uploadCatchUpBlobs());\n\t\t}\n\t}\n\n\tprivate static eventFromEditResult(editStatus: EditStatus): SharedTreeDiagnosticEvent {\n\t\tswitch (editStatus) {\n\t\t\tcase EditStatus.Applied:\n\t\t\t\treturn SharedTreeDiagnosticEvent.AppliedEdit;\n\t\t\tcase EditStatus.Invalid:\n\t\t\t\treturn SharedTreeDiagnosticEvent.DroppedInvalidEdit;\n\t\t\tdefault:\n\t\t\t\treturn SharedTreeDiagnosticEvent.DroppedMalformedEdit;\n\t\t}\n\t}\n\n\tprivate createEditLogFromSummary(\n\t\tsummary: SharedTreeSummaryBase,\n\t\tcallback: EditStatusCallback\n\t): { editLog: EditLog<TChange>; cachingLogViewer: CachingLogViewer<TChange> } {\n\t\tconst convertedSummary = convertSummaryToReadFormat<TChange>(summary);\n\t\tif (typeof convertedSummary === 'string') {\n\t\t\tfail(convertedSummary);\n\t\t}\n\t\tconst { editHistory, currentTree } = convertedSummary;\n\t\tconst currentView = Snapshot.fromTree(currentTree);\n\n\t\tconst editLog = new EditLog(editHistory, this.logger);\n\t\tconst logViewer = new CachingLogViewer(\n\t\t\teditLog,\n\t\t\tSnapshot.fromTree(initialTree),\n\t\t\t// TODO:#47830: Store multiple checkpoints in summary.\n\t\t\t[[editLog.length, { snapshot: currentView }]],\n\t\t\tthis.expensiveValidation,\n\t\t\tcallback,\n\t\t\tthis.logger,\n\t\t\tthis.transactionFactory,\n\t\t\t0\n\t\t);\n\n\t\treturn { editLog, cachingLogViewer: logViewer };\n\t}\n\n\t/**\n\t * Upload any full chunks that have yet to be uploaded.\n\t */\n\tprivate async uploadCatchUpBlobs(): Promise<void> {\n\t\tfor (const [startRevision, chunk] of this.editLog.getEditChunksReadyForUpload()) {\n\t\t\tawait this.uploadEditChunk(chunk, startRevision);\n\t\t\tthis.emit(SharedTreeDiagnosticEvent.CatchUpBlobUploaded);\n\t\t}\n\t}\n\n\t/**\n\t * Compares this shared tree to another for equality.\n\t *\n\t * Equality means that the histories as captured by the EditLogs are equal.\n\t *\n\t * Equality does not include:\n\t * - if an edit is open\n\t * - the shared tree's id\n\t * - local vs sequenced status of edits\n\t * - registered event listeners\n\t * - state of caches\n\t * */\n\tpublic equals<TOtherChangeTypes>(sharedTree: GenericSharedTree<TOtherChangeTypes>): boolean {\n\t\tif (!this.currentView.equals(sharedTree.currentView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.editLog.equals(sharedTree.editLog);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst summaryLoadPerformanceEvent = PerformanceEvent.start(this.logger, { eventName: 'SummaryLoad' });\n\n\t\ttry {\n\t\t\tconst newBlob = await storage.readBlob(snapshotFileName);\n\t\t\tconst blobData = bufferToString(newBlob, 'utf8');\n\n\t\t\tconst summary = deserialize(blobData, this.serializer);\n\t\t\tif (typeof summary === 'string') {\n\t\t\t\tfail(summary);\n\t\t\t}\n\t\t\tthis.loadSummary(summary);\n\n\t\t\tsummaryLoadPerformanceEvent.end({ historySize: this.edits.length });\n\t\t} catch (error) {\n\t\t\tsummaryLoadPerformanceEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t */\n\tprotected processCore(message: ISequencedDocumentMessage, local: boolean): void {\n\t\tthis.cachingLogViewer.setMinimumSequenceNumber(message.minimumSequenceNumber);\n\t\tconst { type } = message.contents;\n\t\tif (type === SharedTreeOpType.Handle) {\n\t\t\tconst { editHandle, startRevision } = message.contents as SharedTreeHandleOp;\n\t\t\tthis.editLog.processEditChunkHandle(this.deserializeHandle(editHandle), startRevision);\n\t\t} else if (type === SharedTreeOpType.Edit) {\n\t\t\tconst semiSerializedEdit = message.contents.edit;\n\t\t\t// semiSerializedEdit may have handles which have been replaced by `serializer.encode`.\n\t\t\t// Since there is no API to un-replace them except via parse, re-stringify the edit, then parse it.\n\t\t\t// Stringify using JSON, not IFluidSerializer since OPs use JSON directly.\n\t\t\t// TODO:Performance:#48025: Avoid this serialization round trip.\n\t\t\tconst stringEdit = JSON.stringify(semiSerializedEdit);\n\t\t\tconst parsedEdit = this.serializer.parse(stringEdit);\n\t\t\tconst edit = parsedEdit as Edit<TChange>;\n\t\t\tthis.processSequencedEdit(edit, message);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.registerCore}\n\t */\n\tprotected registerCore(): void {\n\t\t// Do nothing\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {\n\t\t// Do nothing\n\t}\n\n\tprivate processSequencedEdit(edit: Edit<TChange>, message: ISequencedDocumentMessage): void {\n\t\tconst { id: editId } = edit;\n\t\tconst wasLocalEdit = this.editLog.isLocalEdit(editId);\n\n\t\t// If the id of the supplied edit matches a non-local edit already present in the log, this would normally be indicative of an error.\n\t\t// However, the @fluidframework packages prior to 0.37.x have a bug which can cause data corruption by sequencing duplicate edits--\n\t\t// see discussion on the following github issue: https://github.com/microsoft/FluidFramework/issues/4399\n\t\t// To work around this issue, we currently tolerate duplicate ops in loaded documents.\n\t\t// This could be strengthened in the future to only apply to documents which may have been impacted.\n\t\tconst shouldIgnoreEdit = this.editLog.tryGetIndexOfId(editId) !== undefined && !wasLocalEdit;\n\t\tif (shouldIgnoreEdit) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.editLog.addSequencedEdit(edit, message);\n\t\tif (!wasLocalEdit) {\n\t\t\tconst eventArguments: EditCommittedEventArguments<GenericSharedTree<TChange>> = {\n\t\t\t\teditId,\n\t\t\t\tlocal: false,\n\t\t\t\ttree: this,\n\t\t\t};\n\t\t\tthis.emit(SharedTreeEvent.EditCommitted, eventArguments);\n\t\t} else {\n\t\t\t// If this client created the edit that filled up a chunk, it is responsible for uploading that chunk.\n\t\t\tconst lastPair = this.editLog.getLastEditChunk();\n\t\t\tif (lastPair !== undefined) {\n\t\t\t\tconst [startRevision, chunk] = lastPair;\n\t\t\t\tconst edits = assertNotUndefined(chunk.edits);\n\t\t\t\tif (edits.length === this.editLog.editsPerChunk) {\n\t\t\t\t\tvoid this.uploadEditChunk(edits, startRevision);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Add an `Edit` directly.\n\t * External users should use one of the more specialized functions, like applyEdit which handles constructing the actual `Edit` object.\n\t * This is exposed as it is useful for testing, particularly with invalid and malformed Edits.\n\t * @internal\n\t */\n\tpublic processLocalEdit(edit: Edit<TChange>): void {\n\t\tconst editOp: SharedTreeEditOp<TChange> = {\n\t\t\ttype: SharedTreeOpType.Edit,\n\t\t\tedit,\n\t\t};\n\n\t\t// IFluidHandles are not allowed in Ops.\n\t\t// Ops can contain Fluid's Serializable (for payloads) which allows IFluidHandles.\n\t\t// So replace the handles before sending:\n\t\tconst semiSerialized = this.serializer.encode(editOp, this.handle);\n\n\t\t// TODO:44711: what should be passed in when unattached?\n\t\tthis.submitLocalMessage(semiSerialized);\n\t\tthis.editLog.addLocalEdit(edit);\n\n\t\tconst eventArguments: EditCommittedEventArguments<GenericSharedTree<TChange>> = {\n\t\t\teditId: edit.id,\n\t\t\tlocal: true,\n\t\t\ttree: this,\n\t\t};\n\t\tthis.emit(SharedTreeEvent.EditCommitted, eventArguments);\n\t}\n\n\tpublic getRuntime(): IFluidDataStoreRuntime {\n\t\treturn this.runtime;\n\t}\n\n\tprotected applyStashedOp() {\n\t\tthrow new Error('not implemented');\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GenericSharedTree.js","sourceRoot":"","sources":["../../src/generic/GenericSharedTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyE;AAQzE,iFAAoE;AACpE,2EAM4C;AAE5C,qEAA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IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;oBAChD,KAAK,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;iBAChD;aACD;SACD;IACF,CAAC;IAED;;;;;OAKG;IACI,gBAAgB,CAAC,IAAmB;QAC1C,MAAM,MAAM,GAA8B;YACzC,IAAI,EAAE,iCAAgB,CAAC,IAAI;YAC3B,IAAI;SACJ,CAAC;QAEF,wCAAwC;QACxC,kFAAkF;QAClF,yCAAyC;QACzC,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAEnE,wDAAwD;QACxD,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAEhC,MAAM,cAAc,GAA4D;YAC/E,MAAM,EAAE,IAAI,CAAC,EAAE;YACf,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,IAAI;SACV,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;IAC1D,CAAC;IAEM,UAAU;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AA9cD,8CA8cC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, IsoBuffer } from '@fluidframework/common-utils';\nimport { IFluidHandle } from '@fluidframework/core-interfaces';\nimport { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelAttributes,\n} from '@fluidframework/datastore-definitions';\nimport { AttachState } from '@fluidframework/container-definitions';\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tISharedObjectEvents,\n\tserializeHandles,\n\tSharedObject,\n} from '@fluidframework/shared-object-base';\nimport { ITelemetryLogger } from '@fluidframework/common-definitions';\nimport { ChildLogger, ITelemetryLoggerPropertyBags, PerformanceEvent } from '@fluidframework/telemetry-utils';\nimport { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';\nimport { assert, assertNotUndefined, fail } from '../Common';\nimport { EditLog, OrderedEditSet } from '../EditLog';\nimport { EditId } from '../Identifiers';\nimport { Snapshot } from '../Snapshot';\nimport { initialTree } from '../InitialTree';\nimport { CachingLogViewer, EditStatusCallback, LogViewer } from '../LogViewer';\nimport { convertSummaryToReadFormat, deserialize, readFormatVersion } from '../SummaryBackCompatibility';\nimport {\n\tEdit,\n\tSharedTreeOpType,\n\tSharedTreeEditOp,\n\tSharedTreeHandleOp,\n\tEditWithoutId,\n\tSharedTreeOp,\n\tEditStatus,\n} from './PersistedTypes';\nimport { serialize, SharedTreeSummarizer, SharedTreeSummary, SharedTreeSummaryBase } from './Summary';\nimport { GenericTransaction } from './GenericTransaction';\nimport { newEdit } from './GenericEditUtilities';\n\n/**\n * Filename where the snapshot is stored.\n */\nconst snapshotFileName = 'header';\n\nconst initialSummary: SharedTreeSummary<unknown> = {\n\tversion: readFormatVersion,\n\tcurrentTree: initialTree,\n\teditHistory: {\n\t\teditChunks: [],\n\t\teditIds: [],\n\t},\n};\n\n/**\n * An event emitted by a `SharedTree` to indicate a state change. See {@link ISharedTreeEvents} for event argument information.\n * @public\n */\nexport enum SharedTreeEvent {\n\t/**\n\t * An edit has been committed to the log.\n\t * This happens when either:\n\t * \t1. A locally generated edit is added to the log.\n\t * \t2. A remotely generated edit is added to the log.\n\t * Note that, for locally generated edits, this event will not be emitted again when that edit is sequenced.\n\t * Passed the EditId of the committed edit, i.e. supports callbacks of type {@link EditCommittedHandler}.\n\t */\n\tEditCommitted = 'committedEdit',\n}\n\n/**\n * An event emitted by a `SharedTree` for diagnostic purposes.\n * See {@link ISharedTreeEvents} for event argument information.\n */\nexport enum SharedTreeDiagnosticEvent {\n\t/**\n\t * A single catch up blob has been uploaded.\n\t */\n\tCatchUpBlobUploaded = 'uploadedCatchUpBlob',\n\t/**\n\t * A valid edit (local or remote) has been applied.\n\t * Passed the EditId of the applied edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tAppliedEdit = 'appliedEdit',\n\t/**\n\t * An invalid edit (local or remote) has been dropped.\n\t * Passed the EditId of the dropped edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tDroppedInvalidEdit = 'droppedInvalidEdit',\n\t/**\n\t * A malformed edit (local or remote) has been dropped.\n\t * Passed the EditId of the dropped edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tDroppedMalformedEdit = 'droppedMalformedEdit',\n}\n\n/**\n * The arguments included when the EditCommitted SharedTreeEvent is emitted.\n * @public\n */\nexport interface EditCommittedEventArguments<TSharedTree> {\n\t/** The ID of the edit committed. */\n\teditId: EditId;\n\t/** Whether or not this is a local edit. */\n\tlocal: boolean;\n\t/** The tree the edit was committed on. Required for local edit events handled by SharedTreeUndoRedoHandler. */\n\ttree: TSharedTree;\n}\n\n/**\n * Events which may be emitted by `SharedTree`. See {@link SharedTreeEvent} for documentation of event semantics.\n */\nexport interface ISharedTreeEvents<TSharedTree> extends ISharedObjectEvents {\n\t(event: 'committedEdit', listener: EditCommittedHandler<TSharedTree>);\n}\n\n/**\n * Expected type for a handler of the `EditCommitted` event.\n */\nexport type EditCommittedHandler<TSharedTree> = (args: EditCommittedEventArguments<TSharedTree>) => void;\n\nconst sharedTreeTelemetryProperties: ITelemetryLoggerPropertyBags = { all: { isSharedTreeEvent: true } };\n\n/**\n * A distributed tree.\n * @public\n */\nexport abstract class GenericSharedTree<TChange> extends SharedObject<ISharedTreeEvents<TChange>> {\n\t/**\n\t * The log of completed edits for this SharedTree.\n\t */\n\tprivate editLog: EditLog<TChange>;\n\n\t/**\n\t * As an implementation detail, SharedTree uses a log viewer that caches snapshots at different revisions.\n\t * It is not exposed to avoid accidental correctness issues, but `logViewer` is exposed in order to give clients a way\n\t * to access the revision history.\n\t */\n\tprivate cachingLogViewer: CachingLogViewer<TChange>;\n\n\t/**\n\t * Viewer for trees defined by editLog. This allows access to views of the tree at different revisions (various points in time).\n\t */\n\tpublic get logViewer(): LogViewer {\n\t\treturn this.cachingLogViewer;\n\t}\n\n\tprotected readonly logger: ITelemetryLogger;\n\n\tpublic readonly transactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>;\n\n\t/** Indicates if the client is the oldest member of the quorum. */\n\tprivate currentIsOldest: boolean;\n\n\tprivate readonly processEditResult = (editResult: EditStatus, editId: EditId): void => {\n\t\t// TODO:#44859: Invalid results should be handled by the app\n\t\tthis.emit(GenericSharedTree.eventFromEditResult(editResult), editId);\n\t};\n\n\t/**\n\t * Create a new SharedTreeFactory.\n\t * @param runtime - The runtime the SharedTree will be associated with\n\t * @param id - Unique ID for the SharedTree\n\t * @param expensiveValidation - Enable expensive asserts.\n\t * @param summarizeHistory - Determines if the history is included in summaries.\n\t */\n\tpublic constructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\ttransactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly expensiveValidation = false,\n\t\tprotected readonly summarizeHistory = true\n\t) {\n\t\tsuper(id, runtime, attributes);\n\t\tthis.expensiveValidation = expensiveValidation;\n\t\tthis.transactionFactory = transactionFactory;\n\n\t\t// This code is somewhat duplicated from OldestClientObserver because it currently depends on the container runtime\n\t\t// which SharedTree does not have access to.\n\t\t// TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tthis.currentIsOldest = this.computeIsOldest();\n\t\tquorum.on('addMember', this.updateOldest);\n\t\tquorum.on('removeMember', this.updateOldest);\n\t\truntime.on('connected', this.updateOldest);\n\t\truntime.on('disconnected', this.updateOldest);\n\n\t\tthis.logger = ChildLogger.create(runtime.logger, 'SharedTree', sharedTreeTelemetryProperties);\n\t\tconst { editLog, cachingLogViewer } = this.createEditLogFromSummary(initialSummary, this.processEditResult);\n\n\t\tthis.editLog = editLog;\n\t\tthis.cachingLogViewer = cachingLogViewer;\n\t}\n\n\t/**\n\t * Re-computes currentIsOldest and emits an event if it has changed.\n\t * TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t */\n\tprivate readonly updateOldest = () => {\n\t\tconst oldest = this.computeIsOldest();\n\t\tif (this.currentIsOldest !== oldest) {\n\t\t\tthis.currentIsOldest = oldest;\n\t\t\tif (oldest) {\n\t\t\t\tthis.emit('becameOldest');\n\t\t\t} else {\n\t\t\t\tthis.emit('lostOldest');\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Computes the oldest client in the quorum, true by default if the container is detached and false by default if the client isn't connected.\n\t * TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t */\n\tprivate computeIsOldest(): boolean {\n\t\t// If the container is detached, we are the only ones that know about it and are the oldest by default.\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If we're not connected we can't be the oldest connected client.\n\t\tif (!this.runtime.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.runtime.clientId !== undefined, 'Client id should be set if connected.');\n\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tconst selfSequencedClient = quorum.getMember(this.runtime.clientId);\n\t\t// When in readonly mode our clientId will not be present in the quorum.\n\t\tif (selfSequencedClient === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst members = quorum.getMembers();\n\t\tfor (const sequencedClient of members.values()) {\n\t\t\tif (sequencedClient.sequenceNumber < selfSequencedClient.sequenceNumber) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// No member of the quorum was older\n\t\treturn true;\n\t}\n\n\t/**\n\t * @returns the current view of the tree.\n\t */\n\tpublic get currentView(): Snapshot {\n\t\treturn this.logViewer.getSnapshotInSession(Number.POSITIVE_INFINITY);\n\t}\n\n\t/**\n\t * @returns the edit history of the tree.\n\t */\n\tpublic get edits(): OrderedEditSet<TChange> {\n\t\treturn this.editLog;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t *\n\t * For convenient imperative variants of edits, see `editor`.\n\t * @internal\n\t */\n\tpublic applyEdit(...changes: TChange[]): EditId {\n\t\tconst edit = newEdit(changes);\n\t\tthis.processLocalEdit(edit);\n\t\treturn edit.id;\n\t}\n\n\tprivate deserializeHandle(serializedHandle: string): IFluidHandle<ArrayBufferLike> {\n\t\tconst deserializeHandle = this.serializer.parse(serializedHandle);\n\t\tassert(typeof deserializeHandle === 'object');\n\t\treturn deserializeHandle as IFluidHandle<ArrayBufferLike>;\n\t}\n\n\t/**\n\t * Uploads the edit chunk and sends the chunk starting revision along with the resulting handle as an op.\n\t */\n\tprivate async uploadEditChunk(edits: readonly EditWithoutId<TChange>[], startRevision: number): Promise<void> {\n\t\ttry {\n\t\t\tconst editHandle = await this.runtime.uploadBlob(IsoBuffer.from(JSON.stringify({ edits })));\n\t\t\tthis.submitLocalMessage({\n\t\t\t\teditHandle: serializeHandles(editHandle, this.serializer, this.handle),\n\t\t\t\tstartRevision,\n\t\t\t\ttype: SharedTreeOpType.Handle,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t// If chunk load fails, we will try again later in loadCore on the oldest client so we log the error instead of throwing.\n\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: 'EditChunkUploadFailure',\n\t\t\t\t},\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tpublic summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\treturn createSingleBlobSummary(snapshotFileName, this.saveSerializedSummary({ serializer }));\n\t}\n\n\t/**\n\t * Saves this SharedTree into a serialized summary.\n\t *\n\t * @param options - Optional serializer and summarizer to use. If not passed in, SharedTree's serializer and summarizer are used.\n\t * @internal\n\t */\n\tpublic saveSerializedSummary(options?: {\n\t\tserializer?: IFluidSerializer;\n\t\tsummarizer?: SharedTreeSummarizer<TChange>;\n\t}): string {\n\t\tconst { serializer, summarizer } = options || {};\n\n\t\treturn serialize(\n\t\t\tsummarizer ? summarizer(this.editLog, this.currentView) : this.saveSummary(),\n\t\t\tserializer || this.serializer,\n\t\t\tthis.handle\n\t\t);\n\t}\n\n\t/**\n\t * Saves this SharedTree into a summary.\n\t * @internal\n\t */\n\tpublic saveSummary(): SharedTreeSummaryBase {\n\t\t// If local changes exist, emulate the sequencing of those changes.\n\t\t// Doing so is necessary so edits created during DataObject.initializingFirstTime are included.\n\t\t// Doing so is safe because it is guaranteed that the DDS has not yet been attached. This is because summary creation is only\n\t\t// ever invoked on a DataObject containing local changes when it is attached for the first time. In post-attach flows, an extra\n\t\t// instance of the DataObject is created for generating summaries and will never have local edits.\n\t\tif (this.editLog.numberOfLocalEdits > 0) {\n\t\t\tassert(\n\t\t\t\tthis.runtime.attachState !== AttachState.Attached,\n\t\t\t\t'Summarizing should not occur with local edits except on first attach.'\n\t\t\t);\n\t\t\tthis.editLog.sequenceLocalEdits();\n\t\t}\n\n\t\tassert(this.editLog.numberOfLocalEdits === 0, 'generateSummary must not be called with local edits');\n\t\treturn this.generateSummary(this.editLog);\n\t}\n\n\t/**\n\t * Generates a SharedTree summary for the current state of the tree.\n\t * Will never be called when local edits are present.\n\t */\n\tprotected abstract generateSummary(editLog: OrderedEditSet<TChange>): SharedTreeSummaryBase;\n\n\t/**\n\t * Initialize shared tree with a summary.\n\t * @internal\n\t */\n\tpublic loadSummary(summary: SharedTreeSummaryBase): void {\n\t\tconst { editLog, cachingLogViewer } = this.createEditLogFromSummary(summary, this.processEditResult);\n\t\tthis.editLog = editLog;\n\t\tthis.cachingLogViewer = cachingLogViewer;\n\n\t\tif (this.runtime.connected) {\n\t\t\tconst noChunksReadyForUpload = this.editLog.getEditChunksReadyForUpload()[Symbol.iterator]().next().done;\n\t\t\tif (noChunksReadyForUpload === undefined || !noChunksReadyForUpload) {\n\t\t\t\t// A client does not become a member of the quorum until it is within the collaboration window.\n\t\t\t\t//\n\t\t\t\t// The collaboration window is the range from the minimum sequence number enforced by the server and head.\n\t\t\t\t// When a client sends an op, they include the last sequence number the client has processed. We call this the reference\n\t\t\t\t// sequence number.\n\t\t\t\t//\n\t\t\t\t// If there are no members in the quorum, we send a no op op in order to have this client added as a member to the quorum.\n\t\t\t\t// This is required so we can ensure only the oldest client will upload blobs during summary load.\n\t\t\t\tif (this.runtime.getQuorum().getMembers().size === 0) {\n\t\t\t\t\tconst noop: SharedTreeOp = {\n\t\t\t\t\t\ttype: SharedTreeOpType.NoOp,\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.submitLocalMessage(noop);\n\t\t\t\t} else if (this.currentIsOldest) {\n\t\t\t\t\tvoid this.uploadCatchUpBlobs();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If this client becomes the oldest, it should take care of uploading catch up blobs.\n\t\t\tthis.on('becameOldest', () => void this.uploadCatchUpBlobs());\n\t\t}\n\t}\n\n\tprivate static eventFromEditResult(editStatus: EditStatus): SharedTreeDiagnosticEvent {\n\t\tswitch (editStatus) {\n\t\t\tcase EditStatus.Applied:\n\t\t\t\treturn SharedTreeDiagnosticEvent.AppliedEdit;\n\t\t\tcase EditStatus.Invalid:\n\t\t\t\treturn SharedTreeDiagnosticEvent.DroppedInvalidEdit;\n\t\t\tdefault:\n\t\t\t\treturn SharedTreeDiagnosticEvent.DroppedMalformedEdit;\n\t\t}\n\t}\n\n\tprivate createEditLogFromSummary(\n\t\tsummary: SharedTreeSummaryBase,\n\t\tcallback: EditStatusCallback\n\t): { editLog: EditLog<TChange>; cachingLogViewer: CachingLogViewer<TChange> } {\n\t\tconst convertedSummary = convertSummaryToReadFormat<TChange>(summary);\n\t\tif (typeof convertedSummary === 'string') {\n\t\t\tfail(convertedSummary);\n\t\t}\n\t\tconst { editHistory, currentTree } = convertedSummary;\n\t\tconst currentView = Snapshot.fromTree(currentTree);\n\n\t\tconst editLog = new EditLog(editHistory, this.logger);\n\t\tconst logViewer = new CachingLogViewer(\n\t\t\teditLog,\n\t\t\tSnapshot.fromTree(initialTree),\n\t\t\t// TODO:#47830: Store multiple checkpoints in summary.\n\t\t\t[[editLog.length, { snapshot: currentView }]],\n\t\t\tthis.expensiveValidation,\n\t\t\tcallback,\n\t\t\tthis.logger,\n\t\t\tthis.transactionFactory,\n\t\t\t0\n\t\t);\n\n\t\treturn { editLog, cachingLogViewer: logViewer };\n\t}\n\n\t/**\n\t * Upload any full chunks that have yet to be uploaded.\n\t */\n\tprivate async uploadCatchUpBlobs(): Promise<void> {\n\t\tfor (const [startRevision, chunk] of this.editLog.getEditChunksReadyForUpload()) {\n\t\t\tawait this.uploadEditChunk(chunk, startRevision);\n\t\t\tthis.emit(SharedTreeDiagnosticEvent.CatchUpBlobUploaded);\n\t\t}\n\t}\n\n\t/**\n\t * Compares this shared tree to another for equality.\n\t *\n\t * Equality means that the histories as captured by the EditLogs are equal.\n\t *\n\t * Equality does not include:\n\t * - if an edit is open\n\t * - the shared tree's id\n\t * - local vs sequenced status of edits\n\t * - registered event listeners\n\t * - state of caches\n\t * */\n\tpublic equals<TOtherChangeTypes>(sharedTree: GenericSharedTree<TOtherChangeTypes>): boolean {\n\t\tif (!this.currentView.equals(sharedTree.currentView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.editLog.equals(sharedTree.editLog);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst summaryLoadPerformanceEvent = PerformanceEvent.start(this.logger, { eventName: 'SummaryLoad' });\n\n\t\ttry {\n\t\t\tconst newBlob = await storage.readBlob(snapshotFileName);\n\t\t\tconst blobData = bufferToString(newBlob, 'utf8');\n\n\t\t\tconst summary = deserialize(blobData, this.serializer);\n\t\t\tif (typeof summary === 'string') {\n\t\t\t\tfail(summary);\n\t\t\t}\n\t\t\tthis.loadSummary(summary);\n\n\t\t\tsummaryLoadPerformanceEvent.end({ historySize: this.edits.length });\n\t\t} catch (error) {\n\t\t\tsummaryLoadPerformanceEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t */\n\tprotected processCore(message: ISequencedDocumentMessage, local: boolean): void {\n\t\tthis.cachingLogViewer.setMinimumSequenceNumber(message.minimumSequenceNumber);\n\t\tconst { type } = message.contents;\n\t\tif (type === SharedTreeOpType.Handle) {\n\t\t\tconst { editHandle, startRevision } = message.contents as SharedTreeHandleOp;\n\t\t\tthis.editLog.processEditChunkHandle(this.deserializeHandle(editHandle), startRevision);\n\t\t} else if (type === SharedTreeOpType.Edit) {\n\t\t\tconst semiSerializedEdit = message.contents.edit;\n\t\t\t// semiSerializedEdit may have handles which have been replaced by `serializer.encode`.\n\t\t\t// Since there is no API to un-replace them except via parse, re-stringify the edit, then parse it.\n\t\t\t// Stringify using JSON, not IFluidSerializer since OPs use JSON directly.\n\t\t\t// TODO:Performance:#48025: Avoid this serialization round trip.\n\t\t\tconst stringEdit = JSON.stringify(semiSerializedEdit);\n\t\t\tconst parsedEdit = this.serializer.parse(stringEdit);\n\t\t\tconst edit = parsedEdit as Edit<TChange>;\n\t\t\tthis.processSequencedEdit(edit, message);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.registerCore}\n\t */\n\tprotected registerCore(): void {\n\t\t// Do nothing\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {\n\t\t// Do nothing\n\t}\n\n\tprivate processSequencedEdit(edit: Edit<TChange>, message: ISequencedDocumentMessage): void {\n\t\tconst { id: editId } = edit;\n\t\tconst wasLocalEdit = this.editLog.isLocalEdit(editId);\n\n\t\t// If the id of the supplied edit matches a non-local edit already present in the log, this would normally be indicative of an error.\n\t\t// However, the @fluidframework packages prior to 0.37.x have a bug which can cause data corruption by sequencing duplicate edits--\n\t\t// see discussion on the following github issue: https://github.com/microsoft/FluidFramework/issues/4399\n\t\t// To work around this issue, we currently tolerate duplicate ops in loaded documents.\n\t\t// This could be strengthened in the future to only apply to documents which may have been impacted.\n\t\tconst shouldIgnoreEdit = this.editLog.tryGetIndexOfId(editId) !== undefined && !wasLocalEdit;\n\t\tif (shouldIgnoreEdit) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.editLog.addSequencedEdit(edit, message);\n\t\tif (!wasLocalEdit) {\n\t\t\tconst eventArguments: EditCommittedEventArguments<GenericSharedTree<TChange>> = {\n\t\t\t\teditId,\n\t\t\t\tlocal: false,\n\t\t\t\ttree: this,\n\t\t\t};\n\t\t\tthis.emit(SharedTreeEvent.EditCommitted, eventArguments);\n\t\t} else {\n\t\t\t// If this client created the edit that filled up a chunk, it is responsible for uploading that chunk.\n\t\t\tconst lastPair = this.editLog.getLastEditChunk();\n\t\t\tif (lastPair !== undefined) {\n\t\t\t\tconst [startRevision, chunk] = lastPair;\n\t\t\t\tconst edits = assertNotUndefined(chunk.edits);\n\t\t\t\tif (edits.length === this.editLog.editsPerChunk) {\n\t\t\t\t\tvoid this.uploadEditChunk(edits, startRevision);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Add an `Edit` directly.\n\t * External users should use one of the more specialized functions, like applyEdit which handles constructing the actual `Edit` object.\n\t * This is exposed as it is useful for testing, particularly with invalid and malformed Edits.\n\t * @internal\n\t */\n\tpublic processLocalEdit(edit: Edit<TChange>): void {\n\t\tconst editOp: SharedTreeEditOp<TChange> = {\n\t\t\ttype: SharedTreeOpType.Edit,\n\t\t\tedit,\n\t\t};\n\n\t\t// IFluidHandles are not allowed in Ops.\n\t\t// Ops can contain Fluid's Serializable (for payloads) which allows IFluidHandles.\n\t\t// So replace the handles before sending:\n\t\tconst semiSerialized = this.serializer.encode(editOp, this.handle);\n\n\t\t// TODO:44711: what should be passed in when unattached?\n\t\tthis.submitLocalMessage(semiSerialized);\n\t\tthis.editLog.addLocalEdit(edit);\n\n\t\tconst eventArguments: EditCommittedEventArguments<GenericSharedTree<TChange>> = {\n\t\t\teditId: edit.id,\n\t\t\tlocal: true,\n\t\t\ttree: this,\n\t\t};\n\t\tthis.emit(SharedTreeEvent.EditCommitted, eventArguments);\n\t}\n\n\tpublic getRuntime(): IFluidDataStoreRuntime {\n\t\treturn this.runtime;\n\t}\n\n\tprotected applyStashedOp() {\n\t\tthrow new Error('not implemented');\n\t}\n}\n"]}
|
|
@@ -150,7 +150,7 @@ export declare abstract class GenericSharedTree<TChange> extends SharedObject<IS
|
|
|
150
150
|
/**
|
|
151
151
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
152
152
|
*/
|
|
153
|
-
summarizeCore(serializer: IFluidSerializer
|
|
153
|
+
summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
|
|
154
154
|
/**
|
|
155
155
|
* Saves this SharedTree into a serialized summary.
|
|
156
156
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericSharedTree.d.ts","sourceRoot":"","sources":["../../src/generic/GenericSharedTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,MAAM,uCAAuC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;OAKG;IACI,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI;IAuB3C,UAAU,IAAI,sBAAsB;IAI3C,SAAS,CAAC,cAAc;CAGxB"}
|
|
@@ -214,7 +214,7 @@ export class GenericSharedTree extends SharedObject {
|
|
|
214
214
|
/**
|
|
215
215
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
216
216
|
*/
|
|
217
|
-
summarizeCore(serializer
|
|
217
|
+
summarizeCore(serializer) {
|
|
218
218
|
return createSingleBlobSummary(snapshotFileName, this.saveSerializedSummary({ serializer }));
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericSharedTree.js","sourceRoot":"","sources":["../../src/generic/GenericSharedTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAQzE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EACN,uBAAuB,EAGvB,gBAAgB,EAChB,YAAY,GACZ,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAgC,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAE9G,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAkB,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAiC,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACzG,OAAO,EAEN,gBAAgB,EAKhB,UAAU,GACV,MAAM,kBAAkB,CAAC;AA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CAAC,aAAa,EAAE;oBAChD,KAAK,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;iBAChD;aACD;SACD;IACF,CAAC;IAED;;;;;OAKG;IACI,gBAAgB,CAAC,IAAmB;QAC1C,MAAM,MAAM,GAA8B;YACzC,IAAI,EAAE,gBAAgB,CAAC,IAAI;YAC3B,IAAI;SACJ,CAAC;QAEF,wCAAwC;QACxC,kFAAkF;QAClF,yCAAyC;QACzC,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAEnE,wDAAwD;QACxD,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAEhC,MAAM,cAAc,GAA4D;YAC/E,MAAM,EAAE,IAAI,CAAC,EAAE;YACf,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,IAAI;SACV,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;IAC1D,CAAC;IAEM,UAAU;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, IsoBuffer } from '@fluidframework/common-utils';\nimport { IFluidHandle } from '@fluidframework/core-interfaces';\nimport { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelAttributes,\n} from '@fluidframework/datastore-definitions';\nimport { AttachState } from '@fluidframework/container-definitions';\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tISharedObjectEvents,\n\tserializeHandles,\n\tSharedObject,\n} from '@fluidframework/shared-object-base';\nimport { ITelemetryLogger } from '@fluidframework/common-definitions';\nimport { ChildLogger, ITelemetryLoggerPropertyBags, PerformanceEvent } from '@fluidframework/telemetry-utils';\nimport { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';\nimport { assert, assertNotUndefined, fail } from '../Common';\nimport { EditLog, OrderedEditSet } from '../EditLog';\nimport { EditId } from '../Identifiers';\nimport { Snapshot } from '../Snapshot';\nimport { initialTree } from '../InitialTree';\nimport { CachingLogViewer, EditStatusCallback, LogViewer } from '../LogViewer';\nimport { convertSummaryToReadFormat, deserialize, readFormatVersion } from '../SummaryBackCompatibility';\nimport {\n\tEdit,\n\tSharedTreeOpType,\n\tSharedTreeEditOp,\n\tSharedTreeHandleOp,\n\tEditWithoutId,\n\tSharedTreeOp,\n\tEditStatus,\n} from './PersistedTypes';\nimport { serialize, SharedTreeSummarizer, SharedTreeSummary, SharedTreeSummaryBase } from './Summary';\nimport { GenericTransaction } from './GenericTransaction';\nimport { newEdit } from './GenericEditUtilities';\n\n/**\n * Filename where the snapshot is stored.\n */\nconst snapshotFileName = 'header';\n\nconst initialSummary: SharedTreeSummary<unknown> = {\n\tversion: readFormatVersion,\n\tcurrentTree: initialTree,\n\teditHistory: {\n\t\teditChunks: [],\n\t\teditIds: [],\n\t},\n};\n\n/**\n * An event emitted by a `SharedTree` to indicate a state change. See {@link ISharedTreeEvents} for event argument information.\n * @public\n */\nexport enum SharedTreeEvent {\n\t/**\n\t * An edit has been committed to the log.\n\t * This happens when either:\n\t * \t1. A locally generated edit is added to the log.\n\t * \t2. A remotely generated edit is added to the log.\n\t * Note that, for locally generated edits, this event will not be emitted again when that edit is sequenced.\n\t * Passed the EditId of the committed edit, i.e. supports callbacks of type {@link EditCommittedHandler}.\n\t */\n\tEditCommitted = 'committedEdit',\n}\n\n/**\n * An event emitted by a `SharedTree` for diagnostic purposes.\n * See {@link ISharedTreeEvents} for event argument information.\n */\nexport enum SharedTreeDiagnosticEvent {\n\t/**\n\t * A single catch up blob has been uploaded.\n\t */\n\tCatchUpBlobUploaded = 'uploadedCatchUpBlob',\n\t/**\n\t * A valid edit (local or remote) has been applied.\n\t * Passed the EditId of the applied edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tAppliedEdit = 'appliedEdit',\n\t/**\n\t * An invalid edit (local or remote) has been dropped.\n\t * Passed the EditId of the dropped edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tDroppedInvalidEdit = 'droppedInvalidEdit',\n\t/**\n\t * A malformed edit (local or remote) has been dropped.\n\t * Passed the EditId of the dropped edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tDroppedMalformedEdit = 'droppedMalformedEdit',\n}\n\n/**\n * The arguments included when the EditCommitted SharedTreeEvent is emitted.\n * @public\n */\nexport interface EditCommittedEventArguments<TSharedTree> {\n\t/** The ID of the edit committed. */\n\teditId: EditId;\n\t/** Whether or not this is a local edit. */\n\tlocal: boolean;\n\t/** The tree the edit was committed on. Required for local edit events handled by SharedTreeUndoRedoHandler. */\n\ttree: TSharedTree;\n}\n\n/**\n * Events which may be emitted by `SharedTree`. See {@link SharedTreeEvent} for documentation of event semantics.\n */\nexport interface ISharedTreeEvents<TSharedTree> extends ISharedObjectEvents {\n\t(event: 'committedEdit', listener: EditCommittedHandler<TSharedTree>);\n}\n\n/**\n * Expected type for a handler of the `EditCommitted` event.\n */\nexport type EditCommittedHandler<TSharedTree> = (args: EditCommittedEventArguments<TSharedTree>) => void;\n\nconst sharedTreeTelemetryProperties: ITelemetryLoggerPropertyBags = { all: { isSharedTreeEvent: true } };\n\n/**\n * A distributed tree.\n * @public\n */\nexport abstract class GenericSharedTree<TChange> extends SharedObject<ISharedTreeEvents<TChange>> {\n\t/**\n\t * The log of completed edits for this SharedTree.\n\t */\n\tprivate editLog: EditLog<TChange>;\n\n\t/**\n\t * As an implementation detail, SharedTree uses a log viewer that caches snapshots at different revisions.\n\t * It is not exposed to avoid accidental correctness issues, but `logViewer` is exposed in order to give clients a way\n\t * to access the revision history.\n\t */\n\tprivate cachingLogViewer: CachingLogViewer<TChange>;\n\n\t/**\n\t * Viewer for trees defined by editLog. This allows access to views of the tree at different revisions (various points in time).\n\t */\n\tpublic get logViewer(): LogViewer {\n\t\treturn this.cachingLogViewer;\n\t}\n\n\tprotected readonly logger: ITelemetryLogger;\n\n\tpublic readonly transactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>;\n\n\t/** Indicates if the client is the oldest member of the quorum. */\n\tprivate currentIsOldest: boolean;\n\n\tprivate readonly processEditResult = (editResult: EditStatus, editId: EditId): void => {\n\t\t// TODO:#44859: Invalid results should be handled by the app\n\t\tthis.emit(GenericSharedTree.eventFromEditResult(editResult), editId);\n\t};\n\n\t/**\n\t * Create a new SharedTreeFactory.\n\t * @param runtime - The runtime the SharedTree will be associated with\n\t * @param id - Unique ID for the SharedTree\n\t * @param expensiveValidation - Enable expensive asserts.\n\t * @param summarizeHistory - Determines if the history is included in summaries.\n\t */\n\tpublic constructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\ttransactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly expensiveValidation = false,\n\t\tprotected readonly summarizeHistory = true\n\t) {\n\t\tsuper(id, runtime, attributes);\n\t\tthis.expensiveValidation = expensiveValidation;\n\t\tthis.transactionFactory = transactionFactory;\n\n\t\t// This code is somewhat duplicated from OldestClientObserver because it currently depends on the container runtime\n\t\t// which SharedTree does not have access to.\n\t\t// TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tthis.currentIsOldest = this.computeIsOldest();\n\t\tquorum.on('addMember', this.updateOldest);\n\t\tquorum.on('removeMember', this.updateOldest);\n\t\truntime.on('connected', this.updateOldest);\n\t\truntime.on('disconnected', this.updateOldest);\n\n\t\tthis.logger = ChildLogger.create(runtime.logger, 'SharedTree', sharedTreeTelemetryProperties);\n\t\tconst { editLog, cachingLogViewer } = this.createEditLogFromSummary(initialSummary, this.processEditResult);\n\n\t\tthis.editLog = editLog;\n\t\tthis.cachingLogViewer = cachingLogViewer;\n\t}\n\n\t/**\n\t * Re-computes currentIsOldest and emits an event if it has changed.\n\t * TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t */\n\tprivate readonly updateOldest = () => {\n\t\tconst oldest = this.computeIsOldest();\n\t\tif (this.currentIsOldest !== oldest) {\n\t\t\tthis.currentIsOldest = oldest;\n\t\t\tif (oldest) {\n\t\t\t\tthis.emit('becameOldest');\n\t\t\t} else {\n\t\t\t\tthis.emit('lostOldest');\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Computes the oldest client in the quorum, true by default if the container is detached and false by default if the client isn't connected.\n\t * TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t */\n\tprivate computeIsOldest(): boolean {\n\t\t// If the container is detached, we are the only ones that know about it and are the oldest by default.\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If we're not connected we can't be the oldest connected client.\n\t\tif (!this.runtime.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.runtime.clientId !== undefined, 'Client id should be set if connected.');\n\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tconst selfSequencedClient = quorum.getMember(this.runtime.clientId);\n\t\t// When in readonly mode our clientId will not be present in the quorum.\n\t\tif (selfSequencedClient === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst members = quorum.getMembers();\n\t\tfor (const sequencedClient of members.values()) {\n\t\t\tif (sequencedClient.sequenceNumber < selfSequencedClient.sequenceNumber) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// No member of the quorum was older\n\t\treturn true;\n\t}\n\n\t/**\n\t * @returns the current view of the tree.\n\t */\n\tpublic get currentView(): Snapshot {\n\t\treturn this.logViewer.getSnapshotInSession(Number.POSITIVE_INFINITY);\n\t}\n\n\t/**\n\t * @returns the edit history of the tree.\n\t */\n\tpublic get edits(): OrderedEditSet<TChange> {\n\t\treturn this.editLog;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t *\n\t * For convenient imperative variants of edits, see `editor`.\n\t * @internal\n\t */\n\tpublic applyEdit(...changes: TChange[]): EditId {\n\t\tconst edit = newEdit(changes);\n\t\tthis.processLocalEdit(edit);\n\t\treturn edit.id;\n\t}\n\n\tprivate deserializeHandle(serializedHandle: string): IFluidHandle<ArrayBufferLike> {\n\t\tconst deserializeHandle = this.serializer.parse(serializedHandle);\n\t\tassert(typeof deserializeHandle === 'object');\n\t\treturn deserializeHandle as IFluidHandle<ArrayBufferLike>;\n\t}\n\n\t/**\n\t * Uploads the edit chunk and sends the chunk starting revision along with the resulting handle as an op.\n\t */\n\tprivate async uploadEditChunk(edits: readonly EditWithoutId<TChange>[], startRevision: number): Promise<void> {\n\t\ttry {\n\t\t\tconst editHandle = await this.runtime.uploadBlob(IsoBuffer.from(JSON.stringify({ edits })));\n\t\t\tthis.submitLocalMessage({\n\t\t\t\teditHandle: serializeHandles(editHandle, this.serializer, this.handle),\n\t\t\t\tstartRevision,\n\t\t\t\ttype: SharedTreeOpType.Handle,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t// If chunk load fails, we will try again later in loadCore on the oldest client so we log the error instead of throwing.\n\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: 'EditChunkUploadFailure',\n\t\t\t\t},\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tpublic summarizeCore(serializer: IFluidSerializer, fullTree: boolean): ISummaryTreeWithStats {\n\t\treturn createSingleBlobSummary(snapshotFileName, this.saveSerializedSummary({ serializer }));\n\t}\n\n\t/**\n\t * Saves this SharedTree into a serialized summary.\n\t *\n\t * @param options - Optional serializer and summarizer to use. If not passed in, SharedTree's serializer and summarizer are used.\n\t * @internal\n\t */\n\tpublic saveSerializedSummary(options?: {\n\t\tserializer?: IFluidSerializer;\n\t\tsummarizer?: SharedTreeSummarizer<TChange>;\n\t}): string {\n\t\tconst { serializer, summarizer } = options || {};\n\n\t\treturn serialize(\n\t\t\tsummarizer ? summarizer(this.editLog, this.currentView) : this.saveSummary(),\n\t\t\tserializer || this.serializer,\n\t\t\tthis.handle\n\t\t);\n\t}\n\n\t/**\n\t * Saves this SharedTree into a summary.\n\t * @internal\n\t */\n\tpublic saveSummary(): SharedTreeSummaryBase {\n\t\t// If local changes exist, emulate the sequencing of those changes.\n\t\t// Doing so is necessary so edits created during DataObject.initializingFirstTime are included.\n\t\t// Doing so is safe because it is guaranteed that the DDS has not yet been attached. This is because summary creation is only\n\t\t// ever invoked on a DataObject containing local changes when it is attached for the first time. In post-attach flows, an extra\n\t\t// instance of the DataObject is created for generating summaries and will never have local edits.\n\t\tif (this.editLog.numberOfLocalEdits > 0) {\n\t\t\tassert(\n\t\t\t\tthis.runtime.attachState !== AttachState.Attached,\n\t\t\t\t'Summarizing should not occur with local edits except on first attach.'\n\t\t\t);\n\t\t\tthis.editLog.sequenceLocalEdits();\n\t\t}\n\n\t\tassert(this.editLog.numberOfLocalEdits === 0, 'generateSummary must not be called with local edits');\n\t\treturn this.generateSummary(this.editLog);\n\t}\n\n\t/**\n\t * Generates a SharedTree summary for the current state of the tree.\n\t * Will never be called when local edits are present.\n\t */\n\tprotected abstract generateSummary(editLog: OrderedEditSet<TChange>): SharedTreeSummaryBase;\n\n\t/**\n\t * Initialize shared tree with a summary.\n\t * @internal\n\t */\n\tpublic loadSummary(summary: SharedTreeSummaryBase): void {\n\t\tconst { editLog, cachingLogViewer } = this.createEditLogFromSummary(summary, this.processEditResult);\n\t\tthis.editLog = editLog;\n\t\tthis.cachingLogViewer = cachingLogViewer;\n\n\t\tif (this.runtime.connected) {\n\t\t\tconst noChunksReadyForUpload = this.editLog.getEditChunksReadyForUpload()[Symbol.iterator]().next().done;\n\t\t\tif (noChunksReadyForUpload === undefined || !noChunksReadyForUpload) {\n\t\t\t\t// A client does not become a member of the quorum until it is within the collaboration window.\n\t\t\t\t//\n\t\t\t\t// The collaboration window is the range from the minimum sequence number enforced by the server and head.\n\t\t\t\t// When a client sends an op, they include the last sequence number the client has processed. We call this the reference\n\t\t\t\t// sequence number.\n\t\t\t\t//\n\t\t\t\t// If there are no members in the quorum, we send a no op op in order to have this client added as a member to the quorum.\n\t\t\t\t// This is required so we can ensure only the oldest client will upload blobs during summary load.\n\t\t\t\tif (this.runtime.getQuorum().getMembers().size === 0) {\n\t\t\t\t\tconst noop: SharedTreeOp = {\n\t\t\t\t\t\ttype: SharedTreeOpType.NoOp,\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.submitLocalMessage(noop);\n\t\t\t\t} else if (this.currentIsOldest) {\n\t\t\t\t\tvoid this.uploadCatchUpBlobs();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If this client becomes the oldest, it should take care of uploading catch up blobs.\n\t\t\tthis.on('becameOldest', () => void this.uploadCatchUpBlobs());\n\t\t}\n\t}\n\n\tprivate static eventFromEditResult(editStatus: EditStatus): SharedTreeDiagnosticEvent {\n\t\tswitch (editStatus) {\n\t\t\tcase EditStatus.Applied:\n\t\t\t\treturn SharedTreeDiagnosticEvent.AppliedEdit;\n\t\t\tcase EditStatus.Invalid:\n\t\t\t\treturn SharedTreeDiagnosticEvent.DroppedInvalidEdit;\n\t\t\tdefault:\n\t\t\t\treturn SharedTreeDiagnosticEvent.DroppedMalformedEdit;\n\t\t}\n\t}\n\n\tprivate createEditLogFromSummary(\n\t\tsummary: SharedTreeSummaryBase,\n\t\tcallback: EditStatusCallback\n\t): { editLog: EditLog<TChange>; cachingLogViewer: CachingLogViewer<TChange> } {\n\t\tconst convertedSummary = convertSummaryToReadFormat<TChange>(summary);\n\t\tif (typeof convertedSummary === 'string') {\n\t\t\tfail(convertedSummary);\n\t\t}\n\t\tconst { editHistory, currentTree } = convertedSummary;\n\t\tconst currentView = Snapshot.fromTree(currentTree);\n\n\t\tconst editLog = new EditLog(editHistory, this.logger);\n\t\tconst logViewer = new CachingLogViewer(\n\t\t\teditLog,\n\t\t\tSnapshot.fromTree(initialTree),\n\t\t\t// TODO:#47830: Store multiple checkpoints in summary.\n\t\t\t[[editLog.length, { snapshot: currentView }]],\n\t\t\tthis.expensiveValidation,\n\t\t\tcallback,\n\t\t\tthis.logger,\n\t\t\tthis.transactionFactory,\n\t\t\t0\n\t\t);\n\n\t\treturn { editLog, cachingLogViewer: logViewer };\n\t}\n\n\t/**\n\t * Upload any full chunks that have yet to be uploaded.\n\t */\n\tprivate async uploadCatchUpBlobs(): Promise<void> {\n\t\tfor (const [startRevision, chunk] of this.editLog.getEditChunksReadyForUpload()) {\n\t\t\tawait this.uploadEditChunk(chunk, startRevision);\n\t\t\tthis.emit(SharedTreeDiagnosticEvent.CatchUpBlobUploaded);\n\t\t}\n\t}\n\n\t/**\n\t * Compares this shared tree to another for equality.\n\t *\n\t * Equality means that the histories as captured by the EditLogs are equal.\n\t *\n\t * Equality does not include:\n\t * - if an edit is open\n\t * - the shared tree's id\n\t * - local vs sequenced status of edits\n\t * - registered event listeners\n\t * - state of caches\n\t * */\n\tpublic equals<TOtherChangeTypes>(sharedTree: GenericSharedTree<TOtherChangeTypes>): boolean {\n\t\tif (!this.currentView.equals(sharedTree.currentView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.editLog.equals(sharedTree.editLog);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst summaryLoadPerformanceEvent = PerformanceEvent.start(this.logger, { eventName: 'SummaryLoad' });\n\n\t\ttry {\n\t\t\tconst newBlob = await storage.readBlob(snapshotFileName);\n\t\t\tconst blobData = bufferToString(newBlob, 'utf8');\n\n\t\t\tconst summary = deserialize(blobData, this.serializer);\n\t\t\tif (typeof summary === 'string') {\n\t\t\t\tfail(summary);\n\t\t\t}\n\t\t\tthis.loadSummary(summary);\n\n\t\t\tsummaryLoadPerformanceEvent.end({ historySize: this.edits.length });\n\t\t} catch (error) {\n\t\t\tsummaryLoadPerformanceEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t */\n\tprotected processCore(message: ISequencedDocumentMessage, local: boolean): void {\n\t\tthis.cachingLogViewer.setMinimumSequenceNumber(message.minimumSequenceNumber);\n\t\tconst { type } = message.contents;\n\t\tif (type === SharedTreeOpType.Handle) {\n\t\t\tconst { editHandle, startRevision } = message.contents as SharedTreeHandleOp;\n\t\t\tthis.editLog.processEditChunkHandle(this.deserializeHandle(editHandle), startRevision);\n\t\t} else if (type === SharedTreeOpType.Edit) {\n\t\t\tconst semiSerializedEdit = message.contents.edit;\n\t\t\t// semiSerializedEdit may have handles which have been replaced by `serializer.encode`.\n\t\t\t// Since there is no API to un-replace them except via parse, re-stringify the edit, then parse it.\n\t\t\t// Stringify using JSON, not IFluidSerializer since OPs use JSON directly.\n\t\t\t// TODO:Performance:#48025: Avoid this serialization round trip.\n\t\t\tconst stringEdit = JSON.stringify(semiSerializedEdit);\n\t\t\tconst parsedEdit = this.serializer.parse(stringEdit);\n\t\t\tconst edit = parsedEdit as Edit<TChange>;\n\t\t\tthis.processSequencedEdit(edit, message);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.registerCore}\n\t */\n\tprotected registerCore(): void {\n\t\t// Do nothing\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {\n\t\t// Do nothing\n\t}\n\n\tprivate processSequencedEdit(edit: Edit<TChange>, message: ISequencedDocumentMessage): void {\n\t\tconst { id: editId } = edit;\n\t\tconst wasLocalEdit = this.editLog.isLocalEdit(editId);\n\n\t\t// If the id of the supplied edit matches a non-local edit already present in the log, this would normally be indicative of an error.\n\t\t// However, the @fluidframework packages prior to 0.37.x have a bug which can cause data corruption by sequencing duplicate edits--\n\t\t// see discussion on the following github issue: https://github.com/microsoft/FluidFramework/issues/4399\n\t\t// To work around this issue, we currently tolerate duplicate ops in loaded documents.\n\t\t// This could be strengthened in the future to only apply to documents which may have been impacted.\n\t\tconst shouldIgnoreEdit = this.editLog.tryGetIndexOfId(editId) !== undefined && !wasLocalEdit;\n\t\tif (shouldIgnoreEdit) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.editLog.addSequencedEdit(edit, message);\n\t\tif (!wasLocalEdit) {\n\t\t\tconst eventArguments: EditCommittedEventArguments<GenericSharedTree<TChange>> = {\n\t\t\t\teditId,\n\t\t\t\tlocal: false,\n\t\t\t\ttree: this,\n\t\t\t};\n\t\t\tthis.emit(SharedTreeEvent.EditCommitted, eventArguments);\n\t\t} else {\n\t\t\t// If this client created the edit that filled up a chunk, it is responsible for uploading that chunk.\n\t\t\tconst lastPair = this.editLog.getLastEditChunk();\n\t\t\tif (lastPair !== undefined) {\n\t\t\t\tconst [startRevision, chunk] = lastPair;\n\t\t\t\tconst edits = assertNotUndefined(chunk.edits);\n\t\t\t\tif (edits.length === this.editLog.editsPerChunk) {\n\t\t\t\t\tvoid this.uploadEditChunk(edits, startRevision);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Add an `Edit` directly.\n\t * External users should use one of the more specialized functions, like applyEdit which handles constructing the actual `Edit` object.\n\t * This is exposed as it is useful for testing, particularly with invalid and malformed Edits.\n\t * @internal\n\t */\n\tpublic processLocalEdit(edit: Edit<TChange>): void {\n\t\tconst editOp: SharedTreeEditOp<TChange> = {\n\t\t\ttype: SharedTreeOpType.Edit,\n\t\t\tedit,\n\t\t};\n\n\t\t// IFluidHandles are not allowed in Ops.\n\t\t// Ops can contain Fluid's Serializable (for payloads) which allows IFluidHandles.\n\t\t// So replace the handles before sending:\n\t\tconst semiSerialized = this.serializer.encode(editOp, this.handle);\n\n\t\t// TODO:44711: what should be passed in when unattached?\n\t\tthis.submitLocalMessage(semiSerialized);\n\t\tthis.editLog.addLocalEdit(edit);\n\n\t\tconst eventArguments: EditCommittedEventArguments<GenericSharedTree<TChange>> = {\n\t\t\teditId: edit.id,\n\t\t\tlocal: true,\n\t\t\ttree: this,\n\t\t};\n\t\tthis.emit(SharedTreeEvent.EditCommitted, eventArguments);\n\t}\n\n\tpublic getRuntime(): IFluidDataStoreRuntime {\n\t\treturn this.runtime;\n\t}\n\n\tprotected applyStashedOp() {\n\t\tthrow new Error('not implemented');\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GenericSharedTree.js","sourceRoot":"","sources":["../../src/generic/GenericSharedTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAQzE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EACN,uBAAuB,EAGvB,gBAAgB,EAChB,YAAY,GACZ,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAgC,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAE9G,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAkB,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,gBA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,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAC;gBACxC,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC9C,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;oBAChD,KAAK,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;iBAChD;aACD;SACD;IACF,CAAC;IAED;;;;;OAKG;IACI,gBAAgB,CAAC,IAAmB;QAC1C,MAAM,MAAM,GAA8B;YACzC,IAAI,EAAE,gBAAgB,CAAC,IAAI;YAC3B,IAAI;SACJ,CAAC;QAEF,wCAAwC;QACxC,kFAAkF;QAClF,yCAAyC;QACzC,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAEnE,wDAAwD;QACxD,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAEhC,MAAM,cAAc,GAA4D;YAC/E,MAAM,EAAE,IAAI,CAAC,EAAE;YACf,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,IAAI;SACV,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;IAC1D,CAAC;IAEM,UAAU;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, IsoBuffer } from '@fluidframework/common-utils';\nimport { IFluidHandle } from '@fluidframework/core-interfaces';\nimport { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';\nimport {\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelAttributes,\n} from '@fluidframework/datastore-definitions';\nimport { AttachState } from '@fluidframework/container-definitions';\nimport {\n\tcreateSingleBlobSummary,\n\tIFluidSerializer,\n\tISharedObjectEvents,\n\tserializeHandles,\n\tSharedObject,\n} from '@fluidframework/shared-object-base';\nimport { ITelemetryLogger } from '@fluidframework/common-definitions';\nimport { ChildLogger, ITelemetryLoggerPropertyBags, PerformanceEvent } from '@fluidframework/telemetry-utils';\nimport { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';\nimport { assert, assertNotUndefined, fail } from '../Common';\nimport { EditLog, OrderedEditSet } from '../EditLog';\nimport { EditId } from '../Identifiers';\nimport { Snapshot } from '../Snapshot';\nimport { initialTree } from '../InitialTree';\nimport { CachingLogViewer, EditStatusCallback, LogViewer } from '../LogViewer';\nimport { convertSummaryToReadFormat, deserialize, readFormatVersion } from '../SummaryBackCompatibility';\nimport {\n\tEdit,\n\tSharedTreeOpType,\n\tSharedTreeEditOp,\n\tSharedTreeHandleOp,\n\tEditWithoutId,\n\tSharedTreeOp,\n\tEditStatus,\n} from './PersistedTypes';\nimport { serialize, SharedTreeSummarizer, SharedTreeSummary, SharedTreeSummaryBase } from './Summary';\nimport { GenericTransaction } from './GenericTransaction';\nimport { newEdit } from './GenericEditUtilities';\n\n/**\n * Filename where the snapshot is stored.\n */\nconst snapshotFileName = 'header';\n\nconst initialSummary: SharedTreeSummary<unknown> = {\n\tversion: readFormatVersion,\n\tcurrentTree: initialTree,\n\teditHistory: {\n\t\teditChunks: [],\n\t\teditIds: [],\n\t},\n};\n\n/**\n * An event emitted by a `SharedTree` to indicate a state change. See {@link ISharedTreeEvents} for event argument information.\n * @public\n */\nexport enum SharedTreeEvent {\n\t/**\n\t * An edit has been committed to the log.\n\t * This happens when either:\n\t * \t1. A locally generated edit is added to the log.\n\t * \t2. A remotely generated edit is added to the log.\n\t * Note that, for locally generated edits, this event will not be emitted again when that edit is sequenced.\n\t * Passed the EditId of the committed edit, i.e. supports callbacks of type {@link EditCommittedHandler}.\n\t */\n\tEditCommitted = 'committedEdit',\n}\n\n/**\n * An event emitted by a `SharedTree` for diagnostic purposes.\n * See {@link ISharedTreeEvents} for event argument information.\n */\nexport enum SharedTreeDiagnosticEvent {\n\t/**\n\t * A single catch up blob has been uploaded.\n\t */\n\tCatchUpBlobUploaded = 'uploadedCatchUpBlob',\n\t/**\n\t * A valid edit (local or remote) has been applied.\n\t * Passed the EditId of the applied edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tAppliedEdit = 'appliedEdit',\n\t/**\n\t * An invalid edit (local or remote) has been dropped.\n\t * Passed the EditId of the dropped edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tDroppedInvalidEdit = 'droppedInvalidEdit',\n\t/**\n\t * A malformed edit (local or remote) has been dropped.\n\t * Passed the EditId of the dropped edit.\n\t * Note that this may be called multiple times, due to concurrent edits causing reordering,\n\t * and/or due to not caching the output of every edit.\n\t */\n\tDroppedMalformedEdit = 'droppedMalformedEdit',\n}\n\n/**\n * The arguments included when the EditCommitted SharedTreeEvent is emitted.\n * @public\n */\nexport interface EditCommittedEventArguments<TSharedTree> {\n\t/** The ID of the edit committed. */\n\teditId: EditId;\n\t/** Whether or not this is a local edit. */\n\tlocal: boolean;\n\t/** The tree the edit was committed on. Required for local edit events handled by SharedTreeUndoRedoHandler. */\n\ttree: TSharedTree;\n}\n\n/**\n * Events which may be emitted by `SharedTree`. See {@link SharedTreeEvent} for documentation of event semantics.\n */\nexport interface ISharedTreeEvents<TSharedTree> extends ISharedObjectEvents {\n\t(event: 'committedEdit', listener: EditCommittedHandler<TSharedTree>);\n}\n\n/**\n * Expected type for a handler of the `EditCommitted` event.\n */\nexport type EditCommittedHandler<TSharedTree> = (args: EditCommittedEventArguments<TSharedTree>) => void;\n\nconst sharedTreeTelemetryProperties: ITelemetryLoggerPropertyBags = { all: { isSharedTreeEvent: true } };\n\n/**\n * A distributed tree.\n * @public\n */\nexport abstract class GenericSharedTree<TChange> extends SharedObject<ISharedTreeEvents<TChange>> {\n\t/**\n\t * The log of completed edits for this SharedTree.\n\t */\n\tprivate editLog: EditLog<TChange>;\n\n\t/**\n\t * As an implementation detail, SharedTree uses a log viewer that caches snapshots at different revisions.\n\t * It is not exposed to avoid accidental correctness issues, but `logViewer` is exposed in order to give clients a way\n\t * to access the revision history.\n\t */\n\tprivate cachingLogViewer: CachingLogViewer<TChange>;\n\n\t/**\n\t * Viewer for trees defined by editLog. This allows access to views of the tree at different revisions (various points in time).\n\t */\n\tpublic get logViewer(): LogViewer {\n\t\treturn this.cachingLogViewer;\n\t}\n\n\tprotected readonly logger: ITelemetryLogger;\n\n\tpublic readonly transactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>;\n\n\t/** Indicates if the client is the oldest member of the quorum. */\n\tprivate currentIsOldest: boolean;\n\n\tprivate readonly processEditResult = (editResult: EditStatus, editId: EditId): void => {\n\t\t// TODO:#44859: Invalid results should be handled by the app\n\t\tthis.emit(GenericSharedTree.eventFromEditResult(editResult), editId);\n\t};\n\n\t/**\n\t * Create a new SharedTreeFactory.\n\t * @param runtime - The runtime the SharedTree will be associated with\n\t * @param id - Unique ID for the SharedTree\n\t * @param expensiveValidation - Enable expensive asserts.\n\t * @param summarizeHistory - Determines if the history is included in summaries.\n\t */\n\tpublic constructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\ttransactionFactory: (snapshot: Snapshot) => GenericTransaction<TChange>,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly expensiveValidation = false,\n\t\tprotected readonly summarizeHistory = true\n\t) {\n\t\tsuper(id, runtime, attributes);\n\t\tthis.expensiveValidation = expensiveValidation;\n\t\tthis.transactionFactory = transactionFactory;\n\n\t\t// This code is somewhat duplicated from OldestClientObserver because it currently depends on the container runtime\n\t\t// which SharedTree does not have access to.\n\t\t// TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tthis.currentIsOldest = this.computeIsOldest();\n\t\tquorum.on('addMember', this.updateOldest);\n\t\tquorum.on('removeMember', this.updateOldest);\n\t\truntime.on('connected', this.updateOldest);\n\t\truntime.on('disconnected', this.updateOldest);\n\n\t\tthis.logger = ChildLogger.create(runtime.logger, 'SharedTree', sharedTreeTelemetryProperties);\n\t\tconst { editLog, cachingLogViewer } = this.createEditLogFromSummary(initialSummary, this.processEditResult);\n\n\t\tthis.editLog = editLog;\n\t\tthis.cachingLogViewer = cachingLogViewer;\n\t}\n\n\t/**\n\t * Re-computes currentIsOldest and emits an event if it has changed.\n\t * TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t */\n\tprivate readonly updateOldest = () => {\n\t\tconst oldest = this.computeIsOldest();\n\t\tif (this.currentIsOldest !== oldest) {\n\t\t\tthis.currentIsOldest = oldest;\n\t\t\tif (oldest) {\n\t\t\t\tthis.emit('becameOldest');\n\t\t\t} else {\n\t\t\t\tthis.emit('lostOldest');\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * Computes the oldest client in the quorum, true by default if the container is detached and false by default if the client isn't connected.\n\t * TODO:#55900: Get rid of copy-pasted OldestClientObserver code\n\t */\n\tprivate computeIsOldest(): boolean {\n\t\t// If the container is detached, we are the only ones that know about it and are the oldest by default.\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If we're not connected we can't be the oldest connected client.\n\t\tif (!this.runtime.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\tassert(this.runtime.clientId !== undefined, 'Client id should be set if connected.');\n\n\t\tconst quorum = this.runtime.getQuorum();\n\t\tconst selfSequencedClient = quorum.getMember(this.runtime.clientId);\n\t\t// When in readonly mode our clientId will not be present in the quorum.\n\t\tif (selfSequencedClient === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst members = quorum.getMembers();\n\t\tfor (const sequencedClient of members.values()) {\n\t\t\tif (sequencedClient.sequenceNumber < selfSequencedClient.sequenceNumber) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// No member of the quorum was older\n\t\treturn true;\n\t}\n\n\t/**\n\t * @returns the current view of the tree.\n\t */\n\tpublic get currentView(): Snapshot {\n\t\treturn this.logViewer.getSnapshotInSession(Number.POSITIVE_INFINITY);\n\t}\n\n\t/**\n\t * @returns the edit history of the tree.\n\t */\n\tpublic get edits(): OrderedEditSet<TChange> {\n\t\treturn this.editLog;\n\t}\n\n\t/**\n\t * Convenience helper for applying an edit containing the given changes.\n\t * Opens an edit, applies the given changes, and closes the edit. See (`openEdit()`/`applyChanges()`/`closeEdit()`).\n\t *\n\t * For convenient imperative variants of edits, see `editor`.\n\t * @internal\n\t */\n\tpublic applyEdit(...changes: TChange[]): EditId {\n\t\tconst edit = newEdit(changes);\n\t\tthis.processLocalEdit(edit);\n\t\treturn edit.id;\n\t}\n\n\tprivate deserializeHandle(serializedHandle: string): IFluidHandle<ArrayBufferLike> {\n\t\tconst deserializeHandle = this.serializer.parse(serializedHandle);\n\t\tassert(typeof deserializeHandle === 'object');\n\t\treturn deserializeHandle as IFluidHandle<ArrayBufferLike>;\n\t}\n\n\t/**\n\t * Uploads the edit chunk and sends the chunk starting revision along with the resulting handle as an op.\n\t */\n\tprivate async uploadEditChunk(edits: readonly EditWithoutId<TChange>[], startRevision: number): Promise<void> {\n\t\ttry {\n\t\t\tconst editHandle = await this.runtime.uploadBlob(IsoBuffer.from(JSON.stringify({ edits })));\n\t\t\tthis.submitLocalMessage({\n\t\t\t\teditHandle: serializeHandles(editHandle, this.serializer, this.handle),\n\t\t\t\tstartRevision,\n\t\t\t\ttype: SharedTreeOpType.Handle,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t// If chunk load fails, we will try again later in loadCore on the oldest client so we log the error instead of throwing.\n\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: 'EditChunkUploadFailure',\n\t\t\t\t},\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tpublic summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\treturn createSingleBlobSummary(snapshotFileName, this.saveSerializedSummary({ serializer }));\n\t}\n\n\t/**\n\t * Saves this SharedTree into a serialized summary.\n\t *\n\t * @param options - Optional serializer and summarizer to use. If not passed in, SharedTree's serializer and summarizer are used.\n\t * @internal\n\t */\n\tpublic saveSerializedSummary(options?: {\n\t\tserializer?: IFluidSerializer;\n\t\tsummarizer?: SharedTreeSummarizer<TChange>;\n\t}): string {\n\t\tconst { serializer, summarizer } = options || {};\n\n\t\treturn serialize(\n\t\t\tsummarizer ? summarizer(this.editLog, this.currentView) : this.saveSummary(),\n\t\t\tserializer || this.serializer,\n\t\t\tthis.handle\n\t\t);\n\t}\n\n\t/**\n\t * Saves this SharedTree into a summary.\n\t * @internal\n\t */\n\tpublic saveSummary(): SharedTreeSummaryBase {\n\t\t// If local changes exist, emulate the sequencing of those changes.\n\t\t// Doing so is necessary so edits created during DataObject.initializingFirstTime are included.\n\t\t// Doing so is safe because it is guaranteed that the DDS has not yet been attached. This is because summary creation is only\n\t\t// ever invoked on a DataObject containing local changes when it is attached for the first time. In post-attach flows, an extra\n\t\t// instance of the DataObject is created for generating summaries and will never have local edits.\n\t\tif (this.editLog.numberOfLocalEdits > 0) {\n\t\t\tassert(\n\t\t\t\tthis.runtime.attachState !== AttachState.Attached,\n\t\t\t\t'Summarizing should not occur with local edits except on first attach.'\n\t\t\t);\n\t\t\tthis.editLog.sequenceLocalEdits();\n\t\t}\n\n\t\tassert(this.editLog.numberOfLocalEdits === 0, 'generateSummary must not be called with local edits');\n\t\treturn this.generateSummary(this.editLog);\n\t}\n\n\t/**\n\t * Generates a SharedTree summary for the current state of the tree.\n\t * Will never be called when local edits are present.\n\t */\n\tprotected abstract generateSummary(editLog: OrderedEditSet<TChange>): SharedTreeSummaryBase;\n\n\t/**\n\t * Initialize shared tree with a summary.\n\t * @internal\n\t */\n\tpublic loadSummary(summary: SharedTreeSummaryBase): void {\n\t\tconst { editLog, cachingLogViewer } = this.createEditLogFromSummary(summary, this.processEditResult);\n\t\tthis.editLog = editLog;\n\t\tthis.cachingLogViewer = cachingLogViewer;\n\n\t\tif (this.runtime.connected) {\n\t\t\tconst noChunksReadyForUpload = this.editLog.getEditChunksReadyForUpload()[Symbol.iterator]().next().done;\n\t\t\tif (noChunksReadyForUpload === undefined || !noChunksReadyForUpload) {\n\t\t\t\t// A client does not become a member of the quorum until it is within the collaboration window.\n\t\t\t\t//\n\t\t\t\t// The collaboration window is the range from the minimum sequence number enforced by the server and head.\n\t\t\t\t// When a client sends an op, they include the last sequence number the client has processed. We call this the reference\n\t\t\t\t// sequence number.\n\t\t\t\t//\n\t\t\t\t// If there are no members in the quorum, we send a no op op in order to have this client added as a member to the quorum.\n\t\t\t\t// This is required so we can ensure only the oldest client will upload blobs during summary load.\n\t\t\t\tif (this.runtime.getQuorum().getMembers().size === 0) {\n\t\t\t\t\tconst noop: SharedTreeOp = {\n\t\t\t\t\t\ttype: SharedTreeOpType.NoOp,\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.submitLocalMessage(noop);\n\t\t\t\t} else if (this.currentIsOldest) {\n\t\t\t\t\tvoid this.uploadCatchUpBlobs();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If this client becomes the oldest, it should take care of uploading catch up blobs.\n\t\t\tthis.on('becameOldest', () => void this.uploadCatchUpBlobs());\n\t\t}\n\t}\n\n\tprivate static eventFromEditResult(editStatus: EditStatus): SharedTreeDiagnosticEvent {\n\t\tswitch (editStatus) {\n\t\t\tcase EditStatus.Applied:\n\t\t\t\treturn SharedTreeDiagnosticEvent.AppliedEdit;\n\t\t\tcase EditStatus.Invalid:\n\t\t\t\treturn SharedTreeDiagnosticEvent.DroppedInvalidEdit;\n\t\t\tdefault:\n\t\t\t\treturn SharedTreeDiagnosticEvent.DroppedMalformedEdit;\n\t\t}\n\t}\n\n\tprivate createEditLogFromSummary(\n\t\tsummary: SharedTreeSummaryBase,\n\t\tcallback: EditStatusCallback\n\t): { editLog: EditLog<TChange>; cachingLogViewer: CachingLogViewer<TChange> } {\n\t\tconst convertedSummary = convertSummaryToReadFormat<TChange>(summary);\n\t\tif (typeof convertedSummary === 'string') {\n\t\t\tfail(convertedSummary);\n\t\t}\n\t\tconst { editHistory, currentTree } = convertedSummary;\n\t\tconst currentView = Snapshot.fromTree(currentTree);\n\n\t\tconst editLog = new EditLog(editHistory, this.logger);\n\t\tconst logViewer = new CachingLogViewer(\n\t\t\teditLog,\n\t\t\tSnapshot.fromTree(initialTree),\n\t\t\t// TODO:#47830: Store multiple checkpoints in summary.\n\t\t\t[[editLog.length, { snapshot: currentView }]],\n\t\t\tthis.expensiveValidation,\n\t\t\tcallback,\n\t\t\tthis.logger,\n\t\t\tthis.transactionFactory,\n\t\t\t0\n\t\t);\n\n\t\treturn { editLog, cachingLogViewer: logViewer };\n\t}\n\n\t/**\n\t * Upload any full chunks that have yet to be uploaded.\n\t */\n\tprivate async uploadCatchUpBlobs(): Promise<void> {\n\t\tfor (const [startRevision, chunk] of this.editLog.getEditChunksReadyForUpload()) {\n\t\t\tawait this.uploadEditChunk(chunk, startRevision);\n\t\t\tthis.emit(SharedTreeDiagnosticEvent.CatchUpBlobUploaded);\n\t\t}\n\t}\n\n\t/**\n\t * Compares this shared tree to another for equality.\n\t *\n\t * Equality means that the histories as captured by the EditLogs are equal.\n\t *\n\t * Equality does not include:\n\t * - if an edit is open\n\t * - the shared tree's id\n\t * - local vs sequenced status of edits\n\t * - registered event listeners\n\t * - state of caches\n\t * */\n\tpublic equals<TOtherChangeTypes>(sharedTree: GenericSharedTree<TOtherChangeTypes>): boolean {\n\t\tif (!this.currentView.equals(sharedTree.currentView)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.editLog.equals(sharedTree.editLog);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst summaryLoadPerformanceEvent = PerformanceEvent.start(this.logger, { eventName: 'SummaryLoad' });\n\n\t\ttry {\n\t\t\tconst newBlob = await storage.readBlob(snapshotFileName);\n\t\t\tconst blobData = bufferToString(newBlob, 'utf8');\n\n\t\t\tconst summary = deserialize(blobData, this.serializer);\n\t\t\tif (typeof summary === 'string') {\n\t\t\t\tfail(summary);\n\t\t\t}\n\t\t\tthis.loadSummary(summary);\n\n\t\t\tsummaryLoadPerformanceEvent.end({ historySize: this.edits.length });\n\t\t} catch (error) {\n\t\t\tsummaryLoadPerformanceEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}\n\t */\n\tprotected processCore(message: ISequencedDocumentMessage, local: boolean): void {\n\t\tthis.cachingLogViewer.setMinimumSequenceNumber(message.minimumSequenceNumber);\n\t\tconst { type } = message.contents;\n\t\tif (type === SharedTreeOpType.Handle) {\n\t\t\tconst { editHandle, startRevision } = message.contents as SharedTreeHandleOp;\n\t\t\tthis.editLog.processEditChunkHandle(this.deserializeHandle(editHandle), startRevision);\n\t\t} else if (type === SharedTreeOpType.Edit) {\n\t\t\tconst semiSerializedEdit = message.contents.edit;\n\t\t\t// semiSerializedEdit may have handles which have been replaced by `serializer.encode`.\n\t\t\t// Since there is no API to un-replace them except via parse, re-stringify the edit, then parse it.\n\t\t\t// Stringify using JSON, not IFluidSerializer since OPs use JSON directly.\n\t\t\t// TODO:Performance:#48025: Avoid this serialization round trip.\n\t\t\tconst stringEdit = JSON.stringify(semiSerializedEdit);\n\t\t\tconst parsedEdit = this.serializer.parse(stringEdit);\n\t\t\tconst edit = parsedEdit as Edit<TChange>;\n\t\t\tthis.processSequencedEdit(edit, message);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.registerCore}\n\t */\n\tprotected registerCore(): void {\n\t\t// Do nothing\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {\n\t\t// Do nothing\n\t}\n\n\tprivate processSequencedEdit(edit: Edit<TChange>, message: ISequencedDocumentMessage): void {\n\t\tconst { id: editId } = edit;\n\t\tconst wasLocalEdit = this.editLog.isLocalEdit(editId);\n\n\t\t// If the id of the supplied edit matches a non-local edit already present in the log, this would normally be indicative of an error.\n\t\t// However, the @fluidframework packages prior to 0.37.x have a bug which can cause data corruption by sequencing duplicate edits--\n\t\t// see discussion on the following github issue: https://github.com/microsoft/FluidFramework/issues/4399\n\t\t// To work around this issue, we currently tolerate duplicate ops in loaded documents.\n\t\t// This could be strengthened in the future to only apply to documents which may have been impacted.\n\t\tconst shouldIgnoreEdit = this.editLog.tryGetIndexOfId(editId) !== undefined && !wasLocalEdit;\n\t\tif (shouldIgnoreEdit) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.editLog.addSequencedEdit(edit, message);\n\t\tif (!wasLocalEdit) {\n\t\t\tconst eventArguments: EditCommittedEventArguments<GenericSharedTree<TChange>> = {\n\t\t\t\teditId,\n\t\t\t\tlocal: false,\n\t\t\t\ttree: this,\n\t\t\t};\n\t\t\tthis.emit(SharedTreeEvent.EditCommitted, eventArguments);\n\t\t} else {\n\t\t\t// If this client created the edit that filled up a chunk, it is responsible for uploading that chunk.\n\t\t\tconst lastPair = this.editLog.getLastEditChunk();\n\t\t\tif (lastPair !== undefined) {\n\t\t\t\tconst [startRevision, chunk] = lastPair;\n\t\t\t\tconst edits = assertNotUndefined(chunk.edits);\n\t\t\t\tif (edits.length === this.editLog.editsPerChunk) {\n\t\t\t\t\tvoid this.uploadEditChunk(edits, startRevision);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Add an `Edit` directly.\n\t * External users should use one of the more specialized functions, like applyEdit which handles constructing the actual `Edit` object.\n\t * This is exposed as it is useful for testing, particularly with invalid and malformed Edits.\n\t * @internal\n\t */\n\tpublic processLocalEdit(edit: Edit<TChange>): void {\n\t\tconst editOp: SharedTreeEditOp<TChange> = {\n\t\t\ttype: SharedTreeOpType.Edit,\n\t\t\tedit,\n\t\t};\n\n\t\t// IFluidHandles are not allowed in Ops.\n\t\t// Ops can contain Fluid's Serializable (for payloads) which allows IFluidHandles.\n\t\t// So replace the handles before sending:\n\t\tconst semiSerialized = this.serializer.encode(editOp, this.handle);\n\n\t\t// TODO:44711: what should be passed in when unattached?\n\t\tthis.submitLocalMessage(semiSerialized);\n\t\tthis.editLog.addLocalEdit(edit);\n\n\t\tconst eventArguments: EditCommittedEventArguments<GenericSharedTree<TChange>> = {\n\t\t\teditId: edit.id,\n\t\t\tlocal: true,\n\t\t\ttree: this,\n\t\t};\n\t\tthis.emit(SharedTreeEvent.EditCommitted, eventArguments);\n\t}\n\n\tpublic getRuntime(): IFluidDataStoreRuntime {\n\t\treturn this.runtime;\n\t}\n\n\tprotected applyStashedOp() {\n\t\tthrow new Error('not implemented');\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/tree",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.1",
|
|
4
4
|
"description": "Distributed tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": "https://github.com/microsoft/FluidFramework",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
34
34
|
"@fluidframework/common-utils": "^0.32.1",
|
|
35
|
-
"@fluidframework/container-definitions": "^0.
|
|
36
|
-
"@fluidframework/core-interfaces": "^0.
|
|
37
|
-
"@fluidframework/datastore-definitions": "^0.
|
|
35
|
+
"@fluidframework/container-definitions": "^0.45.0",
|
|
36
|
+
"@fluidframework/core-interfaces": "^0.42.0",
|
|
37
|
+
"@fluidframework/datastore-definitions": "^0.56.1",
|
|
38
38
|
"@fluidframework/protocol-definitions": "^0.1026.0",
|
|
39
|
-
"@fluidframework/runtime-definitions": "^0.
|
|
40
|
-
"@fluidframework/shared-object-base": "^0.
|
|
41
|
-
"@fluidframework/telemetry-utils": "^0.
|
|
39
|
+
"@fluidframework/runtime-definitions": "^0.56.1",
|
|
40
|
+
"@fluidframework/shared-object-base": "^0.56.1",
|
|
41
|
+
"@fluidframework/telemetry-utils": "^0.56.1",
|
|
42
42
|
"buffer": "^6.0.3",
|
|
43
43
|
"denque": "^1.5.0",
|
|
44
44
|
"lru-cache": "^6.0.0",
|
|
@@ -47,14 +47,13 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@fluidframework/build-common": "^0.23.0",
|
|
50
|
-
"@fluidframework/container-loader": "^0.
|
|
50
|
+
"@fluidframework/container-loader": "^0.56.1",
|
|
51
51
|
"@fluidframework/eslint-config-fluid": "^0.25.0",
|
|
52
|
-
"@fluidframework/mocha-test-setup": "^0.
|
|
53
|
-
"@fluidframework/runtime-
|
|
54
|
-
"@fluidframework/
|
|
55
|
-
"@fluidframework/test-
|
|
56
|
-
"@fluidframework/test-
|
|
57
|
-
"@fluidframework/test-utils": "^0.55.0",
|
|
52
|
+
"@fluidframework/mocha-test-setup": "^0.56.1",
|
|
53
|
+
"@fluidframework/runtime-utils": "^0.56.1",
|
|
54
|
+
"@fluidframework/test-drivers": "^0.56.1",
|
|
55
|
+
"@fluidframework/test-runtime-utils": "^0.56.1",
|
|
56
|
+
"@fluidframework/test-utils": "^0.56.1",
|
|
58
57
|
"@microsoft/api-extractor": "^7.16.1",
|
|
59
58
|
"@rushstack/eslint-config": "^2.5.1",
|
|
60
59
|
"@types/lru-cache": "^5.1.0",
|
|
@@ -312,7 +312,7 @@ export abstract class GenericSharedTree<TChange> extends SharedObject<ISharedTre
|
|
|
312
312
|
/**
|
|
313
313
|
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
314
314
|
*/
|
|
315
|
-
public summarizeCore(serializer: IFluidSerializer
|
|
315
|
+
public summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {
|
|
316
316
|
return createSingleBlobSummary(snapshotFileName, this.saveSerializedSummary({ serializer }));
|
|
317
317
|
}
|
|
318
318
|
|